Author Topic: Creating a trigger from a script?  (Read 267 times)

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Creating a trigger from a script?
« on: May 05, 2011, 01:28:54 pm »


               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.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #1 on: May 05, 2011, 01:39:11 pm »


               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
               
               

               
            

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #2 on: May 05, 2011, 05:55:26 pm »


               Actually, that seems like it will work quite nicely.  thank you, Lightfoot.
               
               

               
            

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #3 on: May 05, 2011, 08:32:10 pm »


               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?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #4 on: May 05, 2011, 09:04:48 pm »


               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?
               
               

               
            

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #5 on: May 05, 2011, 09:38:22 pm »


               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.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #6 on: May 05, 2011, 10:09:17 pm »


               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.
               
               

               
            

Legacy_Ivanovich

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
Creating a trigger from a script?
« Reply #7 on: May 06, 2011, 07:09:23 pm »


               That worked perfectly.  Thank you, GoG.