ActivateItem Script Question
Zephirius
Member Posts: 419
Just trying to create a potion of Cause Serious Wounds. Didn't see any in the toolset.
As is it now the PC goes through all of the animations, but no spell?
As is it now the PC goes through all of the animations, but no spell?
} // Potion of Cause Serious Wounds object oUsed7 = GetItemActivated(); if (GetTag(oUsed7) == "SERIOUS_WOUNDS") { object oPC = GetItemActivatedTarget(); //object oPC = GetItemActivator(); AssignCommand(oPC, ActionCastSpellAtObject (SPELL_INFLICT_SERIOUS_WOUNDS, oPC, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)); }
0
Comments
It might be best just to apply effects in this case rather than having the player cast a spell. Something like:
As a touch attack it does "work". In the chat window the feedback indicates a successful hit occurred on the PC. But that's all that happens.
void main()
{
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;
object oPC = GetItemActivator();
object oItem = GetItemActivated();
{
//do stuff here
}
}
Also I removed your extraneous { } around your comment as it served no purpose and if you are not careful can cause problems in whatever code you place there.
TR
I never declare variables inside brackets (after an if statement) I always declare them at the top of the script. Im not sure if this is a good or bad thing but its just a habit I developed over the years.
As to variables declared in smaller scopes, it just depends. If for example in this case you had them before the if so they were executed even if it was not ACTIVATE then you'd be doing a few extra "syscalls" and instructions. As written there's really no difference here. If you do all your variables that way then you are probably doing a few extra instructions here or there in your scripts but I don't think that will matter much. We are beyond the days of having to micro optimize instruction counts