Aller au contenu

Photo

Storm Script


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

#1
Llionei

Llionei
  • Members
  • 14 messages
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. :)

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


#2
Xardex

Xardex
  • Members
  • 217 messages
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 .


#3
Llionei

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