Aller au contenu

Photo

troubles with ExecuteScriptEnhanced


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
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.

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
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
Olblach

Olblach
  • Members
  • 175 messages
This works:



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
Quilistan

Quilistan
  • Members
  • 111 messages
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?

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
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);

}

}



________________________

#6
BigfootNZ

BigfootNZ
  • Members
  • 131 messages
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.

Modifié par BigfootNZ, 12 novembre 2010 - 09:38 .


#7
Morbane

Morbane
  • Members
  • 1 883 messages
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 :)