Author Topic: Simple looping VFX  (Read 497 times)

Legacy_mwplayer

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Simple looping VFX
« on: June 16, 2011, 10:28:27 am »


               I need to make a simple, looping VFX. But I can't figure out how to do it, lol. I'm using it as a visual effect for an earthquake (VFX_COM_CHUNK_STONE_MEDIUM, VFX_COM_CHUNK_STONE_SMALL, etc). If anyone could help me with such a script that'd be really chill. Thanks!
               
               

               
            

Legacy_Borden Haelven

  • Hero Member
  • *****
  • Posts: 681
  • Karma: +0/-0
Simple looping VFX
« Reply #1 on: June 16, 2011, 11:43:57 am »


               Create ten waypoints with tags WP_Quake_1 thro 10 run the script using whatever trigger you wish and you'll have about 15 seconds of earthquake with effects. To increase duration simply increase number of waypoints and *while(iCount <= 11)* in steps of 2.



void main()
{
object oPC = GetFirstPC();
object oTarget;
int iCount = 1;
int iCount2 = 0;
float fDelay = 0.0;
    while(iCount <= 11)
    {
        DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SCREEN_SHAKE), oPC));
        oTarget = GetObjectByTag("WP_Quake_" + IntToString(0 + iCount));
        DelayCommand(fDelay,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_CHUNK_STONE_MEDIUM), GetLocation(oTarget)));
        oTarget = GetObjectByTag("WP_Quake_" + IntToString(1 + iCount));
        DelayCommand(fDelay + 1.5,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_CHUNK_STONE_SMALL), GetLocation(oTarget)));
        iCount = iCount + 2;
        iCount2++;
        fDelay = 3.0 * iCount2;
    }
}
               
               

               


                     Modifié par Borden Haelven, 16 juin 2011 - 10:47 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Simple looping VFX
« Reply #2 on: June 16, 2011, 01:04:31 pm »


               To Further optimize this, I would say to ONLY run the script, IF a player is in the area.
After all, what is the point in doing VFX if no players are there to see it?

Earthquakes should be targetted on all players in the area, in order to make sure they all hear the rumble.
               
               

               
            

Legacy_Borden Haelven

  • Hero Member
  • *****
  • Posts: 681
  • Karma: +0/-0
Simple looping VFX
« Reply #3 on: June 16, 2011, 02:45:54 pm »


               Point taken Baaleos, I just used GetFirstPC() to simplify testing. @ mwplayer, PM me the details and I'll do a proper job for you.
Just thought: I could use some of the code from this :- http://nwvault.ign.c...s.Detail&id=600 to make the rock chunk effects fire around each player without needing waypoints. Just thought 2: I could add looping_Spasm to the player to make them look like they're staggering during the quake. What do you think?
               
               

               


                     Modifié par Borden Haelven, 16 juin 2011 - 01:54 .
                     
                  


            

Legacy_Borden Haelven

  • Hero Member
  • *****
  • Posts: 681
  • Karma: +0/-0
Simple looping VFX
« Reply #4 on: June 19, 2011, 07:01:37 pm »


               This should do the trick. http://cid-75666f62d...ake^_Effect.erf
It's run by a heartbeat script that only fires when there are players in the area. It can be turned on and off bby script as well. HIH
               
               

               
            

Legacy_mwplayer

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Simple looping VFX
« Reply #5 on: June 20, 2011, 09:53:11 am »


               Thanks for the help so far. Download link doesn't work btw, but so far I've managed to make my own script suited to my own needs based off of someone's I've found. But I've ran into a real problem now. Right now it just causes the infamous TMI error.


#include "are_eff_quake"

void RunVisualEffectLoop(object oVFX, object oPC, float fFrequency)

{
  if((GetArea(oVFX) != GetArea(oPC)))

  {

   DeleteLocalInt( oVFX, "VFXLoopActive");

    return;
  }

 effect eRocksoup = EffectVisualEffect(137);

ApplyEffectAtLocation( DURATION_TYPE_INSTANT, eRocksoup, GetLocation(oVFX));


  DelayCommand( fFrequency, RunVisualEffectLoop(oVFX, oPC, fFrequency));
}

void ShakeScreen(object oPC)
{
    if (GetArea(oPC)!=OBJECT_SELF)
        return;
    effect eVis=EffectVisualEffect(VFX_FNF_SCREEN_SHAKE);
    location lLoc=GetLocation(oPC);
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,lLoc);
    if (!GetLocalInt(OBJECT_SELF,"StopShake"))
        DelayCommand(3.0,ShakeScreen(oPC));
        RandomQuakes();
}
void main()
{
    object oPC=GetEnteringObject();
    if (!GetIsPC(oPC) || GetIsDM(oPC))
        return;

        int nCount = 1;

   object oFirst = GetObjectByTag("obj_looprockfirst");

  object oVFX = GetObjectByTag("obj_looprock");

  if(!GetIsObjectValid(oVFX) || GetLocalInt(oVFX, "VFXLoopActive")) return;
  while (GetIsObjectValid(oVFX))
  {
  SetLocalInt(oVFX, "VFXLoopActive", TRUE);
  float fDelayMagnitude = 7.0 +IntToFloat(Random(5));
  RunVisualEffectLoop(oVFX, oPC, fDelayMagnitude);

  object oVFX = GetNearestObjectByTag("obj_looprock", oFirst, 1);
  }


    if (!GetLocalInt(OBJECT_SELF,"StopShake"))
        ShakeScreen(oPC);
}



The thing I added that caused the TMI was when I attempted to make the visual effect play on every waypoint I have designated with the tag "obj_looprock". If I don't do the whole while loop thing, it works. But then it only plays on one waypoint. How do you guys make it play through ALL the waypoints with the tag "obj_looprock", without the TMI error?

EDIT: Nevermind, thanks a lot Borden! I took snippets of your iCount and while code and instead made a lot of waypoints entitled obj_looprock_# to like 15. It now plays at every waypoint '^_^'
               
               

               


                     Modifié par mwplayer, 20 juin 2011 - 08:32 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Simple looping VFX
« Reply #6 on: June 20, 2011, 10:43:37 pm »


               
Quote
mwplayer wrote...

Thanks for the help so far. Download link doesn't work btw, but so far I've managed to make my own script suited to my own needs based off of someone's I've found. But I've ran into a real problem now. Right now it just causes the infamous TMI error.


#include "are_eff_quake"




That include will most likely do what you want all by itsself.

You do not need to set any waypoints down.  It was written to shake the entire area.  Every time the shakes happen it checks to see if the PC can see the shaking or not.  if they cant it just adds another quake effect at there feet. 

When using the include the only two functions in the include that should be used are the first two.  There others are are called by them.  

The two functions to use are. 

{quote]
// @ nDuration  - the number of rounds the effect lasts for.
//                creatures make a save every round.
// @ nDC        - The DC for the reflex save to not fall down.
// @ oCenter    - The Object the effect is centered at.
//              - if oCenter is an area the function will pick an object to center on.
void QuakeEarth( int nDuration = 1, int nDC = 20  , object oCenter=OBJECT_SELF );
// If any of the arguments are set thy will override the Defaults set in the Include file.
void RandomQuakes(int nMinRnd = -1,int nMaxRnd = -1,int nMaxLength = -1 ,int IncDc = -1);[/quote]


So if you wanted a Quake in an area to last for 6 rounds the script would simple be.
Quote

#include "are_eff_quake"
void main()
{
  
QuakeEarth( 6   );

}


Now if you wanted quakes to happen at random intervals you could place the other function in the on enter for the area.
Quote

#include "are_eff_quake"
void main()
{
  If(GetIsPC(GetEnteringObject()))  RandomQuakes(); 
}

That will use the default delays as set by the vars at the top of the include.   Or you can change them either in the include or by entering them as arguments into the function. 

That vars at the top of the include are:
Quote

// Time Delays are is rounds.
// Min Should be at least the amount of time of the quakes.
// There are 10 rounds per minute
 int MIN_RND_BETWEEN_QUAKES = 5;   // 0.5 min
 int MAX_RND_BETWEEN_QUAKES = 100;  // 10 min
 int MAX_LENGHT_OF_QUAKE    = 4;     //24 sec
 int INCREAS_DC_PER_LENGTH  = 5;     // For evey extra round the quake lasts add 5 to the DC.



EDIT;  I forgot to state that the random quakes will only happen as long as there are PC in the area.   They will automaticly shut themselves off as soon as the PC are gone.
               
               

               


                     Modifié par Lightfoot8, 20 juin 2011 - 09:46 .
                     
                  


            

Legacy_Borden Haelven

  • Hero Member
  • *****
  • Posts: 681
  • Karma: +0/-0
Simple looping VFX
« Reply #7 on: June 21, 2011, 12:04:52 am »


               You are creating a never ending while loop.
Add:-
int iCount =1;
to your variable declarations then change the while code to match the code below.


while (GetIsObjectValid(oVFX))
{
SetLocalInt(oVFX, "VFXLoopActive", TRUE);
float fDelayMagnitude = 7.0 +IntToFloat(Random(5));
RunVisualEffectLoop(oVFX, oPC, fDelayMagnitude);

object oVFX = GetNearestObjectByTag("obj_looprock", oFirst, iCount);
iCount++
}

This will make it loopthrough all the waypoints from nearest to farthest ending when it runs out of waypoints.

skydrive.live.com/ Try this link. It is a small erf of a test area and the code and a waypoint template.
               
               

               


                     Modifié par Borden Haelven, 20 juin 2011 - 11:15 .