Bug Report: unique prop on an item HELP!!
Quilistan
Member Posts: 187
I can't seem to figure out getting the alternate script in the while loop to fire.
My idea here is I have a weapon that can cast a unique power (unleashing 3 spells, Call Lightning, Chain Lightning, and Gust of Wind, along with an animation that takes a full round). This part seems to be working just fine (maybe some timing tweaks needed, but if fires as it should).
The next idea was to have the weapon "recharge" its uses as it does damage in combat. So I am trying to get it to fire a second script once the unique power use/per/day is at 0.
This is the part that I can't figure out.........
The item is set with both a:
Cast Spell Unique Power
OnHitCastSpell Unique Power
which I think either will fire the script via tag based blah blah blah.... (maybe I am wrong here and this simply isn't possible?)
My idea here is I have a weapon that can cast a unique power (unleashing 3 spells, Call Lightning, Chain Lightning, and Gust of Wind, along with an animation that takes a full round). This part seems to be working just fine (maybe some timing tweaks needed, but if fires as it should).
The next idea was to have the weapon "recharge" its uses as it does damage in combat. So I am trying to get it to fire a second script once the unique power use/per/day is at 0.
This is the part that I can't figure out.........
The item is set with both a:
Cast Spell Unique Power
OnHitCastSpell Unique Power
which I think either will fire the script via tag based blah blah blah.... (maybe I am wrong here and this simply isn't possible?)
void main() { object oPC = GetItemActivator(); object oItem = GetSpellCastItem(); // The item casting triggering this spellscript int nPower = GetHitDice(oPC); itemproperty ip = GetFirstItemProperty(oItem); while (GetIsItemPropertyValid(ip)) { if (GetItemPropertyType(ip) == IP_CONST_CASTSPELL_UNIQUE_POWER) { if (GetItemPropertyUsesPerDayRemaining(oItem, ip) == 0) { ExecuteScript("storm_axe_chrg", oPC); SendMessageToPC(oPC, "Sent Command to run recharge script"); return; } } ip = GetNextItemProperty(oItem); } ClearAllActions(); // oItem = GetSpellCastItem(); // The item casting triggering this spellscript object oSpellTarget = GetSpellTargetObject(); // Have the item activator perform a sequence of actions. AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_VICTORY1)); DelayCommand(1.0, PlayVoiceChat(VOICE_CHAT_TAUNT, oPC)); // Have the item activator cast Call Lightning. DelayCommand(0.1, AssignCommand(oPC, ActionCastSpellAtObject(SPELL_CALL_LIGHTNING, oSpellTarget, METAMAGIC_ANY, TRUE, nPower, PROJECTILE_PATH_TYPE_DEFAULT, TRUE))); // Have the item activator cast Gust of Wind. DelayCommand(0.2, AssignCommand(oPC, ActionCastSpellAtObject(SPELL_GUST_OF_WIND, oSpellTarget, METAMAGIC_ANY, TRUE, nPower, PROJECTILE_PATH_TYPE_DEFAULT, TRUE))); // Have the item activator cast Chain Lightning. DelayCommand(0.3, AssignCommand(oPC, ActionCastSpellAtObject(SPELL_CHAIN_LIGHTNING, oSpellTarget, METAMAGIC_ANY, TRUE, nPower, PROJECTILE_PATH_TYPE_DEFAULT, TRUE))); }
Post edited by Quilistan on
0
Comments
From the looks of what you have here, it will call the recharge script when activated by the user once the charges run out. For debugging that's okay, but it's not what you described it working like.
To get the onHit spell to work, you need GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) to return TRUE.
I think that is usually defined in the module loader script.
Then you need your weapon to be tagged "storm_axe_chrg" for it to call the onHit script.
(If you have "MODULE_VAR_TAGBASED_SCRIPT_PREFIX" set, you'll need that to be on the front of your onHit script name.)
If that's not working for you, feel free to share your storm_axe_chrg script.
I am hoping the same item (same tag) can fire the onhit script through the "execute script" line.
here is the storm_axe_chrg script
New plan. When the item runs out of charges, set it's tag to the charge script. Then, when it's charged, change it back to the first script.
I have implimented the GetUserDefinedItemEventNumber() and it is getting the execute script to fire, so the recharge aspect of the item is working.
Issue now is that it does not recognized the ACTIVATE event as it should, it constantly just runs the OnHit
if I set the if(nEvent) check to the actual intiger 0 for X2_ITEM_EVENT_ACTIVATE it will run the script correctly for the first round of Activates only, following that it defaults to the OnHit event
It's been a while since I played with on hit cast but it looks like it runs as the hitting (at least with weapons) object rather than the module. So oPC may just be OBJECT_SELF in that case.
If I reset the server, so fresh start to everything.
The axe has 3 uses of the Activate Item Unique Power. I use those and they fire the X2_ITEM_EVENT_ACTIVATE event correctly running that specific section of code.
Following that ANY uses of the the Activate Item Unique Power will only fire the X2_ITEM_EVENT_ONHITCAST event section, so it fails to recognize the Activate Item use correctly
Once the item's per day uses goes to zero it should not be able to be activated any more. I don't know if EE has changed this but before in that case I think you had to rest. That is, even if you gave it another use it would still not be usable again that day until the PC rested. You may be hitting that or some variation if the item is not activating anymore at all.
The weapon should allow the player to use 3 unique power actions (this unique power casts Call Lightning, Chain Lightning, and Gust of Wind as ONE GIANT ability), then once those are used up the player can recharge the uses via melee combat.
The onhit event is setup to execute the script storm_axe_chrg script (posted previously, 2nd code posted in this thread) which after so much melee combat it reinstates the Active Unique Power uses.
The issue I am having is once this script (storm_axe_chrg script) fires and the activate unique power uses are reinstated, Activating the item is not working. At that point is treats all activate unique power uses as onhits, and ONLY fires the onhit section of the script. This is regardless of if it is an onhit event or an activated event (it fails to return and activated event correctly)
I can stop fighting, zone, rest and come back and the USE: Unique Power (Activate Item) will not fire the correct event, it only fires the OnHit event after that.
New Test:
ok this last test I used the 3 activate item uses, then without any combat (avoiding the execution of the storm_axe_chrg script) I ran away to rest. The next 3 activate item uses worked as intended.
This means that something about executing the storm_axe_chrg script in the way that I am is breaking something and causing it to no longer recognize the item's Use: Unique Power as an "ACTIVATE_ITEM" event it then fires it as an OnHit event.
storm_axe:
storm_axe_chrg:
BUT it ends up with the same issue. After "recharging" it then fails to recognized the X2_ITEM_EVENT_ACTIVATE event......
I think I am going to try and NOT execute the 2nd script.
I think you have found a bug and we would need Beamdog to fix it.
where do we report bugs? I changed the title to mention a bug.
The main thing I did was make a new local variable on the module to keep track of if on activate has been called. I check that instead of GetUserDefinedItemEventNumber() but only for the on activate section.
The biggest issue with this is, you would have to find all the scripts that get called by on activate and reset the variable to signify that on activate is done.
Perhaps your original "new plan" still needs to be visited. Changing the tag of the item for each behavior. I might mess around with that today.