Author Topic: Storm Script  (Read 336 times)

Legacy_Llionei

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Storm Script
« on: June 26, 2011, 09:57:00 am »


               I'm working on a script that creates stormy weather but I have one issue. It makes only one loop and I don't know what is wrong.

#include "x2_inc_toollib"

void main()
{
location locLocation1 = GetLocation(GetWaypointByTag("WP_lightning1"));
location locLocation2 = GetLocation(GetWaypointByTag("WP_lightning2"));
location locLocation3 = GetLocation(GetWaypointByTag("WP_lightning3"));
location locLocation4 = GetLocation(GetWaypointByTag("WP_lightning4"));
location locLocation5 = GetLocation(GetWaypointByTag("WP_lightning5"));
location locLocation6 = GetLocation(GetWaypointByTag("WP_lightning6"));
location locLocation7 = GetLocation(GetWaypointByTag("WP_lightning7"));
effect eVis = EffectVisualEffect(VFX_IMP_LIGHTNING_M);
int nLoop;

SetWeather (OBJECT_SELF, WEATHER_RAIN);
TLChangeAreaGroundTiles(GetArea(OBJECT_SELF), X2_TL_GROUNDTILE_WATER, 16, 16, 0.6);


    for (nLoop = 1; nLoop<15; nLoop++)
    {
        DelayCommand(5.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation1, 2.0));
        DelayCommand(9.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation2, 2.0));
        DelayCommand(12.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation3, 2.0));
        DelayCommand(16.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation4, 2.0));
        DelayCommand(24.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation5, 2.0));
        DelayCommand(26.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation6, 2.0));
        DelayCommand(30.0, ApplyEffectAtLocation (DURATION_TYPE_TEMPORARY, eVis, locLocation7, 2.0));
        nLoop = nLoop + 1;
    }
}

At least someone could give me a better storm script. '<img'>
               
               

               


                     Modifié par Llionei, 26 juin 2011 - 08:57 .
                     
                  


            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Storm Script
« Reply #1 on: June 26, 2011, 10:43:02 am »


               Since you use a 'for' loop you dont need the line "nLoop = nLoop+1;"
Anyway, if you do fix that, your script will shoot 14 simultaneous lightning after 5, 9, 12... seconds all in the same spot.

Since you say the script loops only once, I would assume there is something wrong with the for loop, but I cant say what because I really dont use for loops that much.

If you want to have permanent lightning vfx's running around you should put it in a heartbeat script, randomly creating the vfx at one of the waypoints every beat.

Also since you are using an IMP vfx, you should make them DURATION_TYPE_INSTANT and remove the 'duration' of 2.0 seconds.
               
               

               


                     Modifié par Xardex, 26 juin 2011 - 09:45 .
                     
                  


            

Legacy_Llionei

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Storm Script
« Reply #2 on: June 26, 2011, 05:12:33 pm »


               Thanks for a tip.
Previously, I put it in the OnEnter, and now it's in OnHeartBeat and everything works just fine.