repair droids

Post about your finished mods here.
Post Reply
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

I've been working on a new mod, but it's giving me some problems, you can find it here.

the concept:
1. small tracked vehicle that crawls around on the ship fixing any damage it finds, like a patch spider.

2. the advanced version can also repair devices installed on the ship automatically.

3. it is smart enough to uninstall itself to protect itself from damage when enemies are near and the shield is at full damage (ie. it is vulnerable to damage), then install itself again when it thinks it is safe.

The install/uninstall operation just flat out fails and I don't know why.
Last edited by Bobby on Mon Dec 14, 2009 1:31 pm, edited 1 time in total.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

the file on Xelerus has some trouble, it's 22bytes, an empty zip.

However I had the same trouble with the randomizer. when using shpInstallDevice and shpUninstallDevice I found that you cannot use anymore the same variable, because the item is changed. (it is now in the cargo, or on the ship respectively)

so, when i want to do something else with the uninstalled item, or installed, I found that objEnumItems or objGetItems do the trick and save me from crashes.

Here is an example of "evil" trick to change a shield to a ship (arco), I use it to reset the shield to a class II deflector on Arco in the randomizer.
It's not very nice, it's not elegant scripting, but prevents me to have crashes, and leaves no "ghost" items.

Code: Select all

;little hack for Arco Vaughn, remove the shield (if there is any) and install a level II deflector.
	(if	(eq (objgetname theAIship) "Arco Vaughn's heavy raider")
	 		(block (ShieldToInstall)
				(objEnumItems theAIship "sI" theShieldThatGetsUninstalled
				 (shpremoveDevice theAIship theShieldThatGetsUninstalled)
				 )
				(objEnumItems theAIship "sU" theUninstalledShield
				 (objRemoveItem theAIship theUninstalledShield)
				 )
				(setq ShieldToInstall (itmCreate &itClass2Deflector; 1))
				(objAddItem theAIship ShieldToInstall)
				(objEnumItems theAIship "sU" theShieldThatWillBeInstalled
						 (shpInstallDevice theAIship theShieldThatWillBeInstalled)
					)
			)
	)
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

I must have forgot to copy it into the zip.... it's in there now.

now it will successfully uninstall itself, I think trying to charge gItem before removing it made the game still look for the uncharged gItem and fail to find it.

I almost have it working, its 3 lines of code away. The problem is this, it will install itself when the shield goes back up, or the enemies are far enough away, but it will do so even if it was never installed originally.

I need a way to mark an item somehow, so it will know if it is supposed to act on it's own or if the player chose to remove it for some reason, it should only install itself automatically if it removed itself, not if the player removed it.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

to do that you can use the new <OnInstall> and <OnUninstall> and mark the item using itmSetData during installation and unmarking it during uninstallation.
(itmSetData item attrib data) -> item

the function is not on xelerus, yet, and hopefully is less tricky than in previous versions.

then you can retrieve the status of the item in your code and prevent the running of the auto-installation.
(itmGetData item attrib) -> data

there are probably better ideas, but this is what came to my mind.
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

don't <onInstall> and <onUninstall> always run when the device is installed or uninstalled? if so it would react the same regardless who removed it.

I tried itmSetData first, but it didn't seem to want to work, so I tried charges, then data, then charges again, and I think I got it.

Code: Select all

(setq gItem (objSetItemCharges gSource gItem 1))
charging it changes gItem, but passing the new gItem to the install/uninstall code seems to work.


EDIT: the working version is up on xelerus
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

just a note for items on space objects I would use objSetItemData not itmSetData as itmSetData doesn't change the item on the space object it just returns a copy of the item with the relevant changes.
Crying is not a proper retort!
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Very cool bobby, I look forward to trying it out.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Made a full playthrough with them and they work great!
As an added bonus they will repair damaged patch spiders!
I like that they hide and come back automatically, definitely adds to their longevity.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Good to hear that, thanks Prohet.

patch spiders breaking was the original inspiration, and they can also repair each other if you have two.

I've noticed a problem with the auto-hide though.
EDIT: fixed

as it stands now they will uninstall to hide even if the cargo hold is full, they are apparently small enough to hide in the airlock or crew's quarters.

I've also changed them to not fix broken stuff in the hold, that seems very exploitable.

EDIT: they will now attack and kill any pteravores that get on the ship with a chance of being damaged in the fight, will be in next update. does anyone know how to create debris from in code?
Post Reply