I want to add an effect to anyone entering a trigger. I want the trigger to be the object adding the effect so I can specifically pick out the effect to remove when the object leaves the trigger. I am trying to do this by making the trigger execute a script which adds the effect, then use the function GetEffectCreator() to identify which effect to remove.
So I think I have to use a script with parameters in order to pass the entering object from the "on enter" script to the script which is to be executed. The function AddScriptParameterObject() in conjunction with ExecuteScriptEnhanced() should allow me to execute a function with parameters, right? Well, I can't get it to work. Here are the scripts:
On Enter Script:
______________________--
void main()
{
object oEnter = GetEnteringObject();
AddScriptParameterObject(oEnter);
ExecuteScriptEnhanced("2021_add_spell_failure",OBJECT_SELF,FALSE);
//ExecuteScript("test",OBJECT_SELF);
//FloatingTextStringOnCreature("worked",oEnter);
}
_________________________-
"2021_add_spell_failure" (script to be executed)
___________________________
void main(object oEnter)
{
object oPC = GetFirstPC();
effect eSpellFailure = EffectSpellFailure();
int nDurationType = DURATION_TYPE_PERMANENT;
//FloatingTextStringOnCreature("worked1", oPC);
ApplyEffectToObject(nDurationType,eSpellFailure,oEnter);
}
_________________________________
Thanks for any help.
troubles with ExecuteScriptEnhanced
Débuté par
M. Rieder
, oct. 27 2010 01:20
#1
Posté 27 octobre 2010 - 01:20
#2
Posté 27 octobre 2010 - 02:53
I haven't worked with ExecuteScriptEnhanced, so I can't help you there, but you could always set oEnter as a local object on the thing running the script, instead of passing it along as a parameter.
#3
Posté 27 octobre 2010 - 09:32
This works:
You must clear params or it won't work. Don't ask me the logic behind this, my only guess is that it clears params set before the script execution not after.
Now since you pass OBJECT_SELF you could have called GetEnteringObject() in the second script.
void main()
{
object oPC = GetLastUsedBy() ;
AddScriptParameterObject(oPC) ;
ExecuteScriptEnhanced("enhanced", OBJECT_SELF, TRUE) ;
}
void main(object param)
{
SpeakString("param:"+GetName(param)) ;
}
You must clear params or it won't work. Don't ask me the logic behind this, my only guess is that it clears params set before the script execution not after.
Now since you pass OBJECT_SELF you could have called GetEnteringObject() in the second script.
#4
Posté 27 octobre 2010 - 10:01
If you don't mind I would love to see your finished working scripts for this I have a few similar triggers and this sounds like a more efficient way of handling this type of thing.
I was originally using a psuedo heartbeat to repeatedly apply a slow effect to PC's in an area. It was laggy, this sounds like I could apply a slow effect and then know which one to remove later when they exit?
I was originally using a psuedo heartbeat to repeatedly apply a slow effect to PC's in an area. It was laggy, this sounds like I could apply a slow effect and then know which one to remove later when they exit?
#5
Posté 30 octobre 2010 - 12:07
Here is the script that worked for most effects. It did not work for spell failure, but it is similar to a script used in last of the danaan which worked on many effects. I tested it with blindness and it worked well. IF you need a script for spell failure, I can give you the one that worked for me, but it is not as specific.
__________________
void main()
{
object oExit = GetExitingObject();
effect eEffectCheck = GetFirstEffect(oExit);
while (GetIsEffectValid(eEffectCheck))
{
if (GetEffectCreator(eEffectCheck) == OBJECT_SELF)
{
RemoveEffect(oExit,eEffectCheck);
}
eEffectCheck = GetNextEffect(oExit);
}
}
________________________
__________________
void main()
{
object oExit = GetExitingObject();
effect eEffectCheck = GetFirstEffect(oExit);
while (GetIsEffectValid(eEffectCheck))
{
if (GetEffectCreator(eEffectCheck) == OBJECT_SELF)
{
RemoveEffect(oExit,eEffectCheck);
}
eEffectCheck = GetNextEffect(oExit);
}
}
________________________
#6
Posté 12 novembre 2010 - 09:27
Umm why not give the Effect the trigger creates a specific SpellID using SetEffectSpellID()
nwn2.wikia.com/wiki/SetEffectSpellId
Its a little buggy since I think you need to assign it an id that is a negative number greater than -1000 for it to work, cant remember why exactly but I know it was discussed on the old boards. Ive used it myself for adding specific effects for terrain slow and terrain material with penalties to skills and movement speed. Works quite well.
Then all you need to do is use GetEffectSpellID() to check for that specific custom id and remove the effect that way. Ill take a look at my scripts to see if thats right or not latter today.
Also I think certain effects dont play nice with it, so if your linking effects you might have to split them up and give them their own unique spell ids rather than linking them all as one and then giving that single linked effect an id.
nwn2.wikia.com/wiki/SetEffectSpellId
Its a little buggy since I think you need to assign it an id that is a negative number greater than -1000 for it to work, cant remember why exactly but I know it was discussed on the old boards. Ive used it myself for adding specific effects for terrain slow and terrain material with penalties to skills and movement speed. Works quite well.
Then all you need to do is use GetEffectSpellID() to check for that specific custom id and remove the effect that way. Ill take a look at my scripts to see if thats right or not latter today.
Also I think certain effects dont play nice with it, so if your linking effects you might have to split them up and give them their own unique spell ids rather than linking them all as one and then giving that single linked effect an id.
Modifié par BigfootNZ, 12 novembre 2010 - 09:38 .
#7
Posté 13 novembre 2010 - 07:37
The negative reference is used because of the IDs in Spells.2da can be referenced with the GetSpellEffectId() so there will then be no conflicts - afaik





Retour en haut






