Author Topic: Any tutorials for scripting battle events?  (Read 309 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Any tutorials for scripting battle events?
« on: August 25, 2013, 12:06:30 am »


                Hi there,
I wanted to make some of the fights in my module a bit more... interesting and not just a simple encounter, just with a stronger enemy.
Anyway, I didn't know how to call it, but I simply mean scripting events that fire at specific points of the battle, i.e. when PC's or the enemy's health got down enough, or after the fight lasts for X seconds and stuff like this.

I don't know if there is any specific category for this kind of scripts, but any info on where I could learn more about them is welcome.

Thanks. '<img'>
               
               

               


                     Modifié par Grani, 24 août 2013 - 11:12 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Any tutorials for scripting battle events?
« Reply #1 on: August 25, 2013, 01:00:40 am »


               You could try to pull apart the scripts on Siege of the Heavens if you wanted.

In terms of the two events you listed there...

Health Percentage
The simplest way to do this would be to add it into the OnDamaged event.  You'd literally add something like...

int x = GetLocalInt('done");

if (x == 0 && GetCurrentHP < GetMaxHP/2)
{
SetLocalInt("done");

blah blah blah
}

That, for example, would execute at 50% health.  You do need to make sure it doesn't fire more than once presumably, hence the x variable.  That's the basic gist.

Another alternative is to have some function or script constantly calling and checking the value of the HP - and then use similar logic.  This is what I did in Siege.

After X Seconds
Again, you could do this in a few ways.  You could simply figure out a way that combat has begun and then call a DelayCommand for something execute X seconds later.  If you want to combine multiple events "Like things every X seconds and things every X%," you may want to do something along the lines of what I did in Siege - which prevented too many things going off at once (unless you WANT that to happen).  Effectively just used local variables to ensure abilities didn't overlap too much.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Any tutorials for scripting battle events?
« Reply #2 on: August 25, 2013, 01:37:51 am »


               That makes sense, thank you. '<img'>