Turning omni on/off, now it works!

Freeform discussion about anything related to modding Transcendence.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I would like to create a weapon with an omnidirectional turret that you can turn on and off !
When off the weapon is stronger, when on the weapon is weaker, but omni ! :wink:

I'm testing this (that doesn't work):
<!-- Omni - non omni laser -->

<ItemType UNID="&itOmniswitch;"
name= "Omniswitch Laser"
level= "4"
value= "5400"
mass= "5500"
frequency= "rare"
modifiers= "EnergyWeapon; MajorItem"

description= "The omnidirectional turret of this laser can be turned on and off, when off the laser is connected to an extra capacitor and deliver a stronger beam."
>

<Image imageID="&rsItems1;" imageX="96" imageY="0" imageWidth="96" imageHeight="96"/>

<Weapon
type= "beam"

omnidirectional= "SOmni"
damage= "laser:2d4+2"
fireRate= "15"
lifetime= "30"
powerUse= "55"

beamType= "laser"
primaryColor= "0xf1, 0x5f, 0x2a"
secondaryColor= "0xff, 0x00, 0x00"
sound= "&snLaserCannon;"
maxCharges= "1"
>
</Weapon>

<Invoke installedOnly="true">

(block (charges maxCharges SOmni)
(setq charges (shpGetItemCharges gSource gItem))
(setq maxCharges 1)

(switch
(eq charges maxCharges)
(block Nil
(setq "SOmni" "True")
(setq charges 0)
(objSendMessage gSource Nil (cat "Omnidirectional turret on!" ))
(shpEnhanceItem gPlayerShip &itOmniswitch; 0x0605)
)

(block Nil
(setq "SOmni" "False")
(setq charges 1)
(objSendMessage gSource Nil (cat "Omnidirectional turret Off!" ))
(shpEnhanceItem gPlayerShip &itOmniswitch; 0x8605)
)
)
)
</Invoke>
</ItemType>
Someone has a better idea ?
Last edited by digdug on Wed Dec 26, 2007 3:31 pm, edited 2 times in total.
darksider
Commonwealth Pilot
Commonwealth Pilot
Posts: 90
Joined: Mon Nov 06, 2006 6:59 am
Location: CSC Asia

Oh, I once thought exactly the same thing :)

I thought as following;

1. Make 2 weapons, and make one "notrandom" and "CannotOrder"
2. Make them to be able to invoke to switch - but, how?
a. invoke to, first, uninstall and erase the item, then create the other item, then install it - but, what do I do about its enhancement?
b. just make it polymorph into the other item, if possible. I guess I can't.

And then I decided it requires more than my knowledge and dropped the idea. :?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

That's a good idea:
I coded the 2 weapons, 1 notrandom and notforsale.
Then added the <invoke> for both of them in order to switch between the omni and the not-omni version. But the game crashes when I use it, what I'm doing wrong ?:
here the 2 invokes:
<Invoke installedOnly="true">

(block Nil
(shpRemoveDevice gPlayerShip &itOmniswitch;)
(objRemoveItem gPlayerShip &itOmniswitch; 1)
(objAddItem gPlayerShip (itmCreate &itOmniswitch2; 1))
(shpInstallDevice gPlayerShip &itOmniswitch2;)
(objSendMessage gSource Nil (cat "Omnidirectional turret Off!"))
)


</Invoke>
<Invoke installedOnly="true">

(block Nil
(shpRemoveDevice gPlayerShip &itOmniswitch2;)
(objRemoveItem gPlayerShip &itOmniswitch2; 1)
(objAddItem gPlayerShip (itmCreate &itOmniswitch; 1))
(shpInstallDevice gPlayerShip &itOmniswitch;)
(objSendMessage gSource Nil (cat "Omnidirectional turret On!"))
)

</Invoke>
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

with no knowledge of lisp or George's , it looks like the function gPlayerShip in the third line after "(block Nil"

Code: Select all

"(objAddItem gPlayerShip (itmCreate &itOmniswitch; 1)) "
takes two parameters as indicated by the line immediately before it and thus should be:

Code: Select all

"(objAddItem gPlayerShip (itmCreate &itOmniswitch); 1) "
I am absolutely clueless however.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

mmh.. objadditem function works with only 2 parameters, and the second one is always a scrxxxx function.
So maybe it doesn't work like I used it.
I semplified the code to:
(block Nil
(shpRemoveDevice gPlayerShip &itOmniswitch;)
(objRemoveItem gPlayerShip &itOmniswitch; 1)

(shpInstallDevice gPlayerShip (itmCreate &itOmniswitch2; 1))
(objSendMessage gSource Nil (cat "Omnidirectional turret Off!"))
)
and it doesn't work.
So I started removing each line to debug the code and I left only :
(shpRemoveDevice gPlayerShip &itOmniswitch;)
and it crashes transcendence without any msg.

Maybe a weapon (or any device) cannot uninstall itself ? :shock:

[EDIT]
So I tested this code:
<Events>
<OnCreate>
(block (gItem2)
(setq gItem2 &itOmniswitch2;)
(shpRemoveDevice gPlayerShip gItem2)
(objRemoveItem gPlayerShip gItem2 1)
)
</OnCreate>
</Events>
<Invoke installedOnly="true">
(block (gItem gItem2)
(setq gItem (itmCreate &itOmniswitch2; 1))
(objAddItem gPlayerShip gItem)
(shpInstallDevice gPlayerShip gItem)
(objSendMessage gSource Nil (cat "Omnidirectional turret On!"))
)
</Invoke>
My idea was: create the other weapon in the invoke and remove the first using the event <oncreate> on the second weapon, and vice versa.

Result: not working (only creation no removal)

I finished my ideas. :cry:
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

Which line is failing? In the revised version the second device is still removing itself.

How about have the Omni weapon (when used) create a transition item and the transition item removes the omni item (oncreate), creates the regular weapon and the regular weapon (oncreate) removes the transition item?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I'm starting to think that I cannot use <Events><Oncreate> inside an <Itemtype>

In George's code it's used only in <stationtype> and <shipclass>.

When I use it inside an <Itemtype> and then I create the item using an <Invoke>, the code of the oncreate is not esecuted.

Maybe it's just my fault, but I cannot manage to get it to work. :oops:

[EDIT]
I'm going to change approach a third time, I'm going to try with a dockscreen. Inside a dockscreen it's common to remove/install/add/remove items. :)

BTW inside the <Initialize> code I can probably save the enhancement status of the weapon inside a variable and apply it at every switch ?
Burzmali
Militia Commander
Militia Commander
Posts: 395
Joined: Tue Aug 15, 2006 12:14 am

You can't objRemoveItem an item from within its own <Invoke>.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Maybe you could try making a device that does the switch between the two weapons.

I know you can easily make the weapons virtual so that they won't show up in the regular inventory screens, that will keep them from being accidentally removed in a shop- then add a device that switches between them so that the invoke script isn't coming from the weapon.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Burzmali Posted: Tue Nov 27, 2007 10:28 pm
You can't objRemoveItem an item from within its own <Invoke>.
mmh.. ROMs, autons and many consumables use (objRemoveItem gSource gItem 1) from within their own <invoke> code to remove themselves from the cargo.
I'm doing the same stuff and it doesn't work ?
User avatar
FAD
Militia Captain
Militia Captain
Posts: 732
Joined: Thu Aug 10, 2006 5:33 am
Location: Area 51

digdug wrote: mmh.. ROMs, autons and many consumables use (objRemoveItem gSource gItem 1) from within their own <invoke> code to remove themselves from the cargo.
I'm doing the same stuff and it doesn't work ?
Lest we forget that such items are not installed in a slot on the ship when invoked.
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

devices can remove themselves from the player... many times i have left the line that removes an item inside a code executing device only to discover that i use it once and it's gone. not confirmed in weapons, but i see no difference.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I do (shpRemoveDevice gSource gItem) just before the objRemoveItem line of code.
That one works. (I can find the uninstalled weapon into the cargo)




[EDIT] OH MY OH MY, It works !
I read again what bobby wrote, and thought "bobby removes installed devices without uninstalling them..."

I just zapped the shpremovedevice line and now I have a working switchable omni/non-omni weapon ! :D

Merry XMAS everybody ! We have a new kind of weapon.
http://rapidshare.com/files/79047191/om ... h.zip.html
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

NEW VERSION
now the weapon retain the enhancements during the switch !

http://rapidshare.de/files/38210948/omn ... 2.zip.html
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Yay! It works great. :)
Post Reply