Enhancement flags?

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

I'm looking at these lines (1592-1595 in SungSlavers.xml), which are about Longzhu shperes enhancing items (specifically shields):

Code: Select all

(if (eq (divide (itmIsEnhanced gItem) 0x100) 0x01)
	(setq newMod 0x0100)
	(setq newMod 0x0102)
	)
I get what most of this is saying, but I'm not sure how this "enhancement flag" (as the Wiki calls it) actually works. These lines check the first two digits of the flag to check whether they're 0x01; if so, newMod is set to 0x0100, if not, newMod is set to 0x0102. newMod is later passed to shpEnhanceItem.

Basically, what I want to know is: what do the digits of the enhancement flag mean? How do they determine the type of enhancement; does the first 01 mean it is enhanced, and the second set of digits determine the amount? Would a +fast weapon be represented with this variable or something else?
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

http://wiki.neurohack.com/transcendence ... hancements
Basically, it's either:

Code: Select all

--  WEAPON

    --  DAMAGE BONUS - Adds from 10 to 150% damage bonus
        0x010X
OR

Code: Select all

--  SHIELD/ARMOR

    --  HP BONUS - Adds from 10 to 150% HP bonus of armor/shield
        0x010X
But there's a lot more, so I could be mistaken.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

Thanks, that page is awesome (and you're right: the last digit determines the % in tens).

Another question (two, actually).

(itmSetProperty gItem 'damaged True) <-- why is this not damaging gItem?

And

How do I subtract enhancements? like, go from 70% to 60%? I just want it to apply a -10% enhancement, and this page says I just preface it with 8 instead of 0 (so... 0x8101 would be -10%). But when I apply a 0x810*, regardless of what the * is, an enhanced item is set to +0%.

I could save the enhancement, remove everything, subtract 1 and add it back, but is there a simpler way?
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

I haven't played with itmsetproperty much, but check for a couple things:
gItem: is it in the <itemtype>'s events tag? It won't work if called from a ship.
Can you dbglog that and see what it returns?

For #2: what is the item you'll be enhancing? I think that you'll have to redo the enhancement since I don't see a way to subtract for current penalties on (I'm assuming) weapons, only setting them.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

It's in <Events> for the dockscreen that a longzhu sphere uses to repair/enhance items. Not a ship. the gItem variable is successfully used in other functions like shpEnhanceItem.

dbglog?

for #2, it's a weapon or a shield. I'll probably redo the enhancement if I can get that working.
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

So I found out that itmSetProperty, for some weird reason, returns a copy of the item with the new property, rather than editing the one I pass in. I tried shpDamageItem and used it correctly (shpDamageItem gPlayerShip gItem) but it didn't work; complaining about not finding the item on the object. How can I actually damage an item?

saving the enhancement and redoing it is refusing to work. How do I set the enhancement to 0? At the moment, I'm calling (shpEnhanceItem gPlayerShip gItem 0x8100) (presumably giving it a damage penalty of 0); this sets the enhancement to 0. But no matter what I do directly after that, it stays at 0. The only way to enhance it again is using another longzhu sphere (so it's no permanent effect, but it still doesn't work right). For instance, this code:

(shpEnhanceItem gPlayerShip gItem 0x8100)

and this code:

(shpEnhanceItem gPlayerShip gItem 0x8100)
(shpEnhanceItem gPlayerShip gItem 0x0102)
(shpEnhanceItem gPlayerShip gItem 0x0102)
(shpEnhanceItem gPlayerShip gItem 0x0102)
(shpEnhanceItem gPlayerShip gItem 0x0102)
(shpEnhanceItem gPlayerShip gItem 0x0102)
(shpEnhanceItem gPlayerShip gItem 0x0102)

do the exact same thing.
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

itmSetProperty, for some weird reason, returns a copy of the item with the new property, rather than editing the one I pass in
that's what I suspected too, while I was reading the thread.

This is , in fact, a normal behaviour of many item functions.
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

OK, so how can I replace the ship's item with the damaged one? OR, how can I get shpDamageItem to work (it says the second parameter should be the ItemListCursor, and from the usage of other functions, I can tell that's what gItem actually is)?
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Dbglog is a function. Look at it on Xelerus (I'm on the phone so derp).
Basically usage is (dbglog (setq thingy 'catonfirenotgood)) will return 'catonfirenotgood and print in debug.txt. 1.08g however, changes the behavior to only print when the game is in debug mode.

What you can try is to get the item and uninstall the first item.
Try (setq blah) and install blah then remove gItem. Blah should be the duplicated item returned by itmsetproperty.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

changing "block Nil" to "block newItem" and adding

(setq newItem (itmSetProperty gItem 'damaged True))
(objAddItem gPlayerShip newItem)
(shpInstallDevice gPlayerShip newItem)
(shpRemoveDevice gPlayerShip gItem)
(objRemoveItem gPlayerShip gItem)

does not work. Trans babbles about "Locals list expected [newItem]" and displays some of the tlisp code.

Also, I looked at the code for repairing items in the exact same Longzhu sphere dockscreen: "(shpRepairItem gPlayerShip gItem)" works. Why does shpDamageItem not work? Using it once removes the enhancement but does NOT damage the item; using it again gives an "Item not found on object" message.

[EDIT] (objSetItemProperty gPlayerShip gItem 'damaged True) has the same bug shpDamageItem does; once, no damage, twice, "Item not found on object". I found the "Locals list expected" problem and I'm going to see if I can get the "create a duplicate" solution working.

[EDIT2] creating a duplicate does not work. The new weapon is not installed and the old weapon is not deleted from inventory.
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

So, with much help fro RPC and TVR___ and other IRC gurus, I got this working. The crux of the matter was that damaging an item, or de-enhancing it and re-enhancing it, takes two commands modifying gItem; but once it's modified, gItem no longer points to the modified item. So I had to damage gItem to get newItem, then either damage newItem or re-enhance it, depending on whether I wanted to actually damage it or just lower the enhancement a bit.

Now I'll balance the mod a bit and release it. Lisp sucks :)
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

ok, if the item is not installed on the ship, it's trivial
- remove the item from the cargo hold
- add the new damaged item to the ship.

if the item is installed, then you have to uninstall it, remove from the cargo, add the new one to the cargo, install the damaged item. If you don't uninstall properly, you get "ghost items".
Note, when you uninstall the item, you create a new item that goes in the cargo. (same function behaviour as the one we are discussing)

It took me a while to debug this while I was writing Weapons extended mod and the ancient switchable omni turbolaser mod.

I will post the helper functions I use in a bit. They are ugly but at least they work.
User avatar
Shivan Hunter
Commonwealth Pilot
Commonwealth Pilot
Posts: 81
Joined: Tue Nov 29, 2011 3:07 am

well, I got the damage working by using objSetItemProperty; I had to do this twice (the first time it just removes enhancement), so I set the result from one to newItem, then called the second one with newItem instead of gItem. Something like this:

Code: Select all

(block (newItem)
    (setq newItem (objSetItemProperty gPlayerShip gItem 'damaged True))
    (objSetItemProperty gPlayerShip newItem 'damaged True)
That properly damaged an object whether or not it's installed. Will this lead to problems later on?
I'm here to shift paradigms and chew bubblegum... and I'm all out of bubblegum.

<+The_Shrike> If you install 2 solar panels, you will have 2 solar panels installed.
<DarthGeek|2> :o
Post Reply