Aller au contenu

Photo

Creating a trigger from a script?


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

#1
Ivanovich

Ivanovich
  • Members
  • 74 messages
Greets.

Is there anyway to create a trigger from a script?  My intention is to have a custom spell create a trigger that freezes anyone who steps into it, except the caster.  The point would be that the caster would create a place where he/she was protected from melee attacks.

The one thing I am unsure of is how to size the trigger.  If created, is it just set to a default square (as if created by the DM in game?) or can it's size be customized?

Thanks in advance.

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
I have never found a way to change the size of a trigger via scripting. 

I would suggest looking more a making an Area of Effect.   Function - EffectAreaOfEffect

Hope that helps.
L8

#3
Ivanovich

Ivanovich
  • Members
  • 74 messages
Actually, that seems like it will work quite nicely. thank you, Lightfoot.

#4
Ivanovich

Ivanovich
  • Members
  • 74 messages
Ok, I've gotten most of it to work, thank you. 

The problem I have is in the HeartBeat script identified in the AreaOfEffect script.

I am trying to have an effect "pulse" while the spell is in effect, but no matter what I do, the Visualeffect won't show up in the heartbeat.  Here is the code:



void main()
{
object oCaster = GetAreaOfEffectCreator();
location lCaster = GetLocation(OBJECT_SELF);

ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(778), oCaster, 0.0);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(792), oCaster, 1.0);

}



If I try applying the visual effect to the caster, nothing happens.  If I apply it to the Location of the caster, it only occurs where the caster originally stood, and repeats until the areaeffect is over.

Thoughts?

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
My best guess is that the creator of the effect is not who/what you think it is. Can you post the part of your script where your area of effect is created?

#6
Ivanovich

Ivanovich
  • Members
  • 74 messages
Sure. It's very simple. A scroll is used to execute the following script:

object oCaster = GetItemActivator();
int iHD = GetHitDice(oCaster);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectAreaOfAffect(1500, "saronenter", "sarhb", "saronexit"), oCaster, RoundsToSeconds(iHD));

That's it. The script I posted before is the "sarhb" script.

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Since you are not appying the command to anything in particular the
creator of the effect is the module. So in your second script when you call GetAreaOfEffectCreator it is getting the module. Therefore since oCaster is the module you can not properly apply the visual effects. Pretty sure this is your issue.

Try your line like this and see if that helps:

AssignCommand(oCaster, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectAreaOfAffect(1500,
"saronenter", "sarhb", "saronexit"), oCaster, RoundsToSeconds(iHD)));

Good Luck.

#8
Ivanovich

Ivanovich
  • Members
  • 74 messages
That worked perfectly. Thank you, GoG.