Author Topic: Unable to add item property  (Read 432 times)

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Unable to add item property
« on: February 26, 2011, 08:35:26 pm »


               I've been banging my head on this for days now, hoping someone can shed some light on this.

I have this code in the OnSpawn script of a creature, the first one doesn't get added but the second one does.

AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyOnMonsterHitProperties(IP_CONST_ONMONSTERHIT_LEVELDRAIN, 3), oBite);

AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyOnMonsterHitProperties(IP_CONST_ONMONSTERHIT_ABILITYDRAIN, IP_CONST_ABILITY_STR), oBite);
Am I supposed to use some kind of predefined constant instead of a number from 1-5 as it says in the function's comments?

Thanks,
420
               
               

               


                     Modifié par 420, 26 février 2011 - 08:44 .
                     
                  


            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Unable to add item property
« Reply #1 on: February 26, 2011, 08:52:03 pm »


               Hiya 420.

Yea I thought about it a minute and remembered there are some properties that had special parameters that had to be set.

Gonna mess with it...

AddItemProperty(DURATION_TYPE_PERMANENT, 
ItemPropertyOnMonsterHitProperties(IP_CONST_ONMONSTERHIT_LEVELDRAIN, 3),
 oBite);


From Lexicon
#include "x2_inc_itemprop"
void main()
{
object oPC = GetPCSpeaker();
object oItem = GetItemInSlot(INVENTORY_SLOT_CWEAPON_B, oPC);
int nProperty =

IP_CONST_ONMONSTERHIT_LEVELDRAIN
;
int nSpecial = 3;
if (!GetIsObjectValid(oItem)) return;

itemproperty ipAdd = ItemPropertyOnMonsterHitProperties(nProperty, nSpecial);

IPSafeAddItemProperty(oItem, ipAdd);
}


Edit*

The above does compile, but it does not work.

Just spent a little over an hour with it.
I used every variable and constant that allows for [*_LEVELDRAIN] (and every variation there of) and could not get the item to take the property. I noticed in the  " ItemPropertyOnHitProps ", it doesn't even list level drain as an option, though it does for Ability Drain.

I can only take a WAG at it, but given the above, the ability or property function may be broken with out it being redone in a void statement.

Your easiest answere 420, is to simply put the property on the creature items that you want to have it.
Save a lot of time, and no where near this big of a headache.

Edit2*
Forgot to mention I tried running this in the OnHeartBeat prior to the main script running.
Also changed oPC to object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

Even used one that set the DC to 40, and no dice.
So it's beyond my ability to figure out.
               
               

               


                     Modifié par Xovian, 26 février 2011 - 10:53 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Unable to add item property
« Reply #2 on: February 27, 2011, 07:48:34 pm »


               Thanks for all your testing Xovian! I can also confirm that IP_CONST_ONMONSTERHIT_WOUNDING, which also requires a value of 1-5, cannot be added.

Xovian wrote...

Your easiest answere 420, is to simply put the property on the creature items that you want to have it.
Save a lot of time, and no where near this big of a headache.

Well, the problem is that I scale my creatures to the level of the PC on the quest and in some cases, like this one, I scale their equipment too. So I'm spawning one of the standard familiar bites (dire rat) based on the creature's level, then adding some other nastyness. The level drain should be set to 1-5 based on the creature's level.

I did find a workaround however: I made 5 different creature bites with level drain 1-5. Then I simply spawn the proper one onto the creature, cycle through the itemproperties and add those to the existing bite attack that the creature already has equipped. Works perfectly.

Thanks again,
420
               
               

               
            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Unable to add item property
« Reply #3 on: February 27, 2011, 08:46:18 pm »


               

420 wrote...

Thanks for all your testing Xovian! I can also confirm that IP_CONST_ONMONSTERHIT_WOUNDING, which also requires a value of 1-5, cannot be added.

Well, the problem is that I scale my creatures to the level of the PC on the quest and in some cases, like this one, I scale their equipment too. So I'm spawning one of the standard familiar bites (dire rat) based on the creature's level, then adding some other nastyness. The level drain should be set to 1-5 based on the creature's level.

I did find a workaround however: I made 5 different creature bites with level drain 1-5. Then I simply spawn the proper one onto the creature, cycle through the itemproperties and add those to the existing bite attack that the creature already has equipped. Works perfectly.

Thanks again,
420

No problem at all. I might not be as good as Lightfoot at off the top of my head scripting, but if i have a piece of a script I can generally get it to work the way i want it to. Unfortantly for whatever reason, that property there was no way to make it work. Considering you can add it to a creatures properties as you did, makes me wonder if it is hard coded somewhere with a constant or not, thus when we tried to script a variable to the interger, it became invalid.

I do the same thing for the most part with my Henchman and NPC's, unless I want them to be a specific template/level. It was one of the things i enjoyed about Inifinite Dungeons and Darkness Over Daggerford.
I also tend to use a modified variant of Cdaulepp's Random Properties, because I dislike having a given creature always being the exact same.

At any rate, glad you found a work around, was going to suggest that you just add the specific bite by script if needed, but you have already done so.

Well at least we know some of the properties aren't able to be added now, so it's something else we've gotten to learn even though the games been out for how long now?

p.s. Forgot to mention, tried the above script with several variants, including oPC = OBJECT_SELF. So no matter how it was done, by conversation, by onheartbeat, or in general, I couldn't get the property to be added. Just wanted to give the info so others would see that I tried various methods.
               
               

               


                     Modifié par Xovian, 27 février 2011 - 08:54 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Unable to add item property
« Reply #4 on: February 27, 2011, 11:13:36 pm »


               

Xovian wrote...

No problem at all. I might not be as good as Lightfoot at off the top of my head scripting..,



  Looks like you did a good job to me.  After I tested it a bit, I just came to the conclusion that it is a bug in the function.   It looks like you two came up with the best solutions, Without having to hak the server to fix the code.  

I also cross refferances the 2da lines with the constants in nwscript, everything matched.  The only conclution I can come up with is the function is buged.  
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Unable to add item property
« Reply #5 on: February 27, 2011, 11:23:04 pm »


               More bad news, I tried these two functions:

AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyOnHitProps(IP_CONST_ONHIT_ABILITYDRAIN, IP_CONST_ABILITY_CON), oBite);

AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyOnMonsterHitProperties(IP_CONST_ONMONSTERHIT_ABILITYDRAIN, IP_CONST_ABILITY_CON), oBite);
They both successfully added the item property but on a failed save they drained strength, not constitution. So it looks like both of those functions are bugged. D'oh!

-420
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Unable to add item property
« Reply #6 on: February 28, 2011, 12:11:21 am »


               I just had a thought that I currently do not have time to test out.  So I thought i would just post it.

It may be possiable to just make a few items blueprints or instances of the items on a few creatures in the game, that have all the Iprops on them that you would like to create dynamicly.   The Idea here is to find the iPop you want to add by getting the item, then finding the iProp useing Get(First/Next)ItemProperty. then just useing the proptery retrived to add the new property to the item. 

Just a thought. 

Note;  Another thing I tought about.  I do not know if the OnMonsterHit Propteries stack.  If they are like the OnHit propteries on weapons you may find that only one of them will work at a time per item.  
               
               

               


                     Modifié par Lightfoot8, 28 février 2011 - 12:13 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Unable to add item property
« Reply #7 on: February 28, 2011, 01:32:10 am »


               btw they stacks

Ok so I looked into it.

Notice, that if you make an level drain monster on hit property its invalid already! I found the fix for it (itempropdef.2da CostTableResRef set to ****), but this will give fixed ammount (bad streff) no matter what integer you specify in function.

By looking into 2das more carefully I noticed interesting thing. The ability drain property should allow ammount, but it does not, so how many strength is actually drained? I wonder it even works - I would guess that no matter what you place in toolset it always drains the strength.

It looks that the functions tries to set specific itemproperty datas, but these datas are not possible due to 2da setting (no costtableresref, param2resref not implemented at all), however I tried to change 2das any way I could think of but it still doesn't repaired these properties, bah.

The problems seems to be in the whole implementation. The current implementation wants to have different costtables and parameters inside one property which seems not to be possible, but the game engine does at least 0costtable 0param1 effect.

Does this itemproperty function really work properly for the rest subtypes with additional parameter?

EDIT: just tried disease and it has same problem, no matter what you pu into function you always end up with demon fever, so the function tries to put our value probably into cost table which is disable for this itemproperty. And it seems that it puts into param1 value first parameter in function int nProperty.
               
               

               


                     Modifié par ShaDoOoW, 28 février 2011 - 01:41 .
                     
                  


            

Legacy_Xovian

  • Full Member
  • ***
  • Posts: 158
  • Karma: +0/-0
Unable to add item property
« Reply #8 on: February 28, 2011, 06:56:24 am »


               Interesting Shadow.
Was no way i was going to go looking that deep into it.
I tend to avoid opening or altering 2das, dont really know how, dont have the incentive to learn.
So I'm glad I wasn't missing something, normally something very simple and easy in my case.

I suppose it goes with out saying, that I need to test the properties from an actual item and see if it too also only effects strength...never really paid attention to that part. Want to see if  both script and items share the same problem, given the 2da, i would think so, but ya never know. Will let you know what I find.


EDIT*
Well from an actual item, the properties do work.

Pic of proof

I had applied a claw and a slam with seperate properties, one being CON like what 420 was using, and I used INT for the other. As you can see from my character sheet, i was effected with both. Love them failed saves on a 1.

Bottom line, if it  "works as advertised" by actually adding them in the toolset, why don't they work for scripting?
You'd think somewhere along the line they use the same code. ':crying:'
               
               

               


                     Modifié par Xovian, 28 février 2011 - 07:16 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Unable to add item property
« Reply #9 on: February 28, 2011, 11:28:12 am »


               

Xovian wrote...

Bottom line, if it  "works as advertised" by actually adding them in the toolset, why don't they work for scripting?

Kk so when various abilities work from toolset this means that the ability choice was really meant for param1 value. However still there was intended to be ammount on param2value which was never implemented, so I guess it drains 1 point right?

Reason why it dont work from scripting have been already discovered, the scripting function tries to put the special parameter into wrong itemproperty field. And workarounds have been also found already. Yet nwnx can help there as it allows to put itemproperty together from scratch.

And unfortunately its not possible to fix it by 2da change except at least guarantee that leveldrain wont be invalid, but the main issue not.
               
               

               


                     Modifié par ShaDoOoW, 28 février 2011 - 11:42 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Unable to add item property
« Reply #10 on: February 28, 2011, 05:57:42 pm »


               

Lightfoot8 wrote...

I just had a thought that I currently do not have time to test out.  So I thought i would just post it.

It may be possiable to just make a few items blueprints or instances of the items on a few creatures in the game, that have all the Iprops on them that you would like to create dynamicly.   The Idea here is to find the iPop you want to add by getting the item, then finding the iProp useing Get(First/Next)ItemProperty. then just useing the proptery retrived to add the new property to the item. 
 

I'll test this. I know the OnMonsterHit props all return item property type 72 but I may be able to detect sub type or something like that.

ShaDoOoW wrote...

However still there was intended to be ammount on param2value which was never implemented, so I guess it drains 1 point right?

Correct, it drains one point per failed save.

-420