In the past I have removed specific effects by identifying them based on what object created the effect. I am currently trying to remove an effect added by a trigger. The problem is when I add the function GetTag(GetEffectCreator(effecttoremove)), I cannot get a string to return. Here is the script below.
____________________________
/* used in 2021, evil wizard's dungeon, removes the spell failure effect
added by the trigger.
*/
void main()
{
object oExit = GetExitingObject();
//object oBoot = GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
//object oGlove = GetItemInSlot(INVENTORY_SLOT_ARMS,oPC);
//Use a loop to cycle through the effects on the exiting object.
effect eCheck = GetFirstEffect(oExit);
int nEffectCheck = GetIsEffectValid(eCheck);
while (nEffectCheck == TRUE)
{
FloatingTextStringOnCreature("effect is valid" ,oExit);
object oCreator = GetEffectCreator(eCheck);
string sCreator = GetTag(oCreator);
int nIsOcreatorValid = GetIsObjectValid(oCreator);
if (nIsOcreatorValid = TRUE)
{
FloatingTextStringOnCreature("oCreator is valid",oExit);
}
FloatingTextStringOnCreature(sCreator,oExit);
if (sCreator == "2021_spell_failure_trigger")
{
RemoveEffect(oExit,eCheck);
}
//
eCheck = GetNextEffect(oExit);
nEffectCheck = GetIsEffectValid(eCheck);
}
}
___________________________________________________
You can see several places where I insert floatingtextstrings to check the progress of the script. The strings "effect is valid" and "oCreator is valid" both fire. The string which should be the tag of the effect creator will not float over the PC's head.
Any input is appreciated.
For reference, here is the script that fires when the PC enters the trigger:
____________________________
/*executes subroutine to allow checking to see what object
added the effect*/
void main()
{
object oEnter = GetEnteringObject();
AddScriptParameterObject(oEnter);
ExecuteScriptEnhanced("2021_add_spell_failure",GetObjectByTag("blaedrig"),TRUE);
//ExecuteScript("test",OBJECT_SELF);
//FloatingTextStringOnCreature("worked",oEnter);
}
Can't Get Tag of object executing script
Débuté par
M. Rieder
, oct. 28 2010 01:13
#1
Posté 28 octobre 2010 - 01:13
#2
Posté 28 octobre 2010 - 03:26
You might take a look at Lugaid's solution in this thread http://nwn2forums.bi...81965&forum=114. It sounds like what you are trying to do.
Regards
Regards
#3
Posté 28 octobre 2010 - 09:09
Does the trigger have a tag to begin with, just asking? Try doing object to int instead and see what you come up with, or a get is object valid. I know not everything has a tag, like players generally don't.
Generally i use geteffectcreator() == OBJECT_SELF in these cases, no reason why you need the tag. But then i use tested code to iterate things entering and exiting a trigger instead of doing new code for that. ( look at spells like grease, same basic coding works on my triggers )
Generally i use geteffectcreator() == OBJECT_SELF in these cases, no reason why you need the tag. But then i use tested code to iterate things entering and exiting a trigger instead of doing new code for that. ( look at spells like grease, same basic coding works on my triggers )
Modifié par painofdungeoneternal, 28 octobre 2010 - 09:11 .
#4
Posté 29 octobre 2010 - 01:14
I changed the code to take out the tag. Now my conditional reads
______
if (GetEffectCreator==OBJECT_SELF)
________-
It still does not work though. I put in checks to see if the GetEffectCreator() is a valid object and it appears to be. I'm pretty stumped here.
______
if (GetEffectCreator==OBJECT_SELF)
________-
It still does not work though. I put in checks to see if the GetEffectCreator() is a valid object and it appears to be. I'm pretty stumped here.
#5
Posté 29 octobre 2010 - 01:34
I re-wrote the scripts. Here they are:
On enter trigger:
______________
void main()
{
object oEnter = GetEnteringObject();
effect eEffect = EffectSpellFailure();
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eEffect,oEnter);
}
___________________
On Exit Trigger
________________
void main()
{
object oExit = GetExitingObject();
effect eEffectCheck = GetFirstEffect(oExit);
int nEffectCheck = GetIsEffectValid(eEffectCheck);
while (nEffectCheck == TRUE)
{
FloatingTextStringOnCreature("worked1",oExit);
if (GetEffectCreator(eEffectCheck) == OBJECT_SELF)
{
FloatingTextStringOnCreature("worked2",oExit);
RemoveEffect(oExit,eEffectCheck);
}
eEffectCheck = GetNextEffect(oExit);
}
}
________________________
The effect is valid, because the string "worked1" appears over my PC. The effect is not removed and the loop continues until the computer automatically stops it to stop a crash.
There appears to be a problem with determining the effect creator, although the trigger runs the script and should be the effect creator.
On enter trigger:
______________
void main()
{
object oEnter = GetEnteringObject();
effect eEffect = EffectSpellFailure();
ApplyEffectToObject(DURATION_TYPE_PERMANENT,eEffect,oEnter);
}
___________________
On Exit Trigger
________________
void main()
{
object oExit = GetExitingObject();
effect eEffectCheck = GetFirstEffect(oExit);
int nEffectCheck = GetIsEffectValid(eEffectCheck);
while (nEffectCheck == TRUE)
{
FloatingTextStringOnCreature("worked1",oExit);
if (GetEffectCreator(eEffectCheck) == OBJECT_SELF)
{
FloatingTextStringOnCreature("worked2",oExit);
RemoveEffect(oExit,eEffectCheck);
}
eEffectCheck = GetNextEffect(oExit);
}
}
________________________
The effect is valid, because the string "worked1" appears over my PC. The effect is not removed and the loop continues until the computer automatically stops it to stop a crash.
There appears to be a problem with determining the effect creator, although the trigger runs the script and should be the effect creator.
Modifié par M. Rieder, 29 octobre 2010 - 01:35 .
#6
Posté 29 octobre 2010 - 01:46
I just copied Lugaid's script from Last of the Danaan, which definitely works, and it wouldn't work in my campaign.
#7
Posté 29 octobre 2010 - 01:47
I'm stumped.
#8
Posté 29 octobre 2010 - 01:56
I just changed the effect to blindness and it worked great. Apparently removing spell failure is trickier than I expected.
#9
Posté 30 octobre 2010 - 12:03
I had to change the conditional from checking the effect creator to the type of effect. Since there is no way the PC will have spell failure on them from any other source, this will work.
Apparently, if you add spell failure, you cannot check for the object that created the effect.
Apparently, if you add spell failure, you cannot check for the object that created the effect.





Retour en haut






