Author Topic: Earthquake  (Read 381 times)

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Earthquake
« on: April 13, 2011, 08:49:13 pm »


               Forgive me all,  I have looked through my work and cant remember how to make a earth quake effect, I did use a crature and have that creature cast actual earthquake spell but I dont want to hurt the chars with the spell I just want an effect.  I'm a little rummy from RL, and it seems to have sliped my mind.  Any help to refresh would be great.  Thanks
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Earthquake
« Reply #1 on: April 13, 2011, 09:01:10 pm »


               Well the spell itself has a couple of effects...if you are just looking for the visual effect it would be:
VFX_FNF_SCREEN_SHAKE. And you only need to apply it to 1 object in the area..in most cases whoever or whatever is casting the spell or calling the script with the visual.

And just in case you wanted to have a peek at the spell it's   x0_s0_earthquake
               
               

               


                     Modifié par GhostOfGod, 13 avril 2011 - 08:16 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Earthquake
« Reply #2 on: April 13, 2011, 09:40:15 pm »


               Yea, I remember that one.  The Main Problem I had when messing with it was that the Object it is applied to has to be seen by the PC.  if it is not seen by the PC then they notice no quake effect.  I Can remember firing it off as a DM appling the effect to myself and having all the players wonder why they where falling over, OOPS.  

Here is the include for the last version I had.  At least I hope it was may last version.  One warning I never got around to placing a check to not knock over the DM.  My DM fell many times due to the quakes.  

Quote
 
// File Name: are_eff_quake
 // 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;     // 9 sec
 int INCREAS_DC_PER_LENGTH  = 5;     // For evey extra round the quake lasts add 5 to the DC.
 
 

// @ 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);

//Returns true if a PC is in the area.
int  GetIsPCInArea(object oArea=OBJECT_SELF);


// Sets up a Delayed Quake Per the Constants above.
void SetUpQuake(int bForce= FALSE);
 

// Private function to the QuakeEarth function
void Fall( );

// @ 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 );


// Privat function to make sure the Effect is seen buy all PC's in the area.
void ApplyShakeToArea(object oArea)
{
    object oPC = GetFirstPC();
    effect eShake = EffectVisualEffect(356);
    int nCount= 0;
    int i;
    int bNotSeen;
    while(GetIsObjectValid(oPC))
    {
        if (GetArea(oPC) == oArea)
        {
            bNotSeen=TRUE;
            for(i=0;i<nCount;i++)
            {
                if (LineOfSightObject(GetLocalObject(OBJECT_SELF,"ShLoc"+IntToString(i)),oPC))
                {
                   bNotSeen = FALSE;
                   break;
                }
            }
            if (bNotSeen)
            {
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eShake, GetLocation(oPC),4.5);
                //fill in  effect Dead spot if running more then one round.
                DelayCommand(4.5,ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eShake, GetLocation(oPC),1.5));
                SetLocalObject(OBJECT_SELF,"ShLoc"+IntToString(i),oPC);
                nCount++;
            }
        }
        oPC=GetNextPC();
    }
    // clean up unneeded locals
    for (i=0;i<nCount;i++) DeleteLocalObject( OBJECT_SELF,"ShLoc"+IntToString(i));

}


void QuakeEarth( int nDuration = 1, int nDC = 20  , object oCenter=OBJECT_SELF )
{
    int nCount;
    int nSave;
    float fDelay;
    object oCreature;


    // Adjust for if oCenter is running on the area and not an object.
    if (GetArea( oCenter) == oCenter) oCenter=GetNearestCreature(CREATURE_TYPE_IS_ALIVE,TRUE,GetFirstObjectInArea(oCenter) ,1) ;
    if (oCenter==OBJECT_INVALID) return;

    ApplyShakeToArea(GetArea(oCenter));

    // Set up for first time through kd loop.
    if(GetObjectType(oCenter)== OBJECT_TYPE_CREATURE)
    {
        oCreature = oCenter;
        nCount= 0;
    }
    else
    {
        oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oCenter ,1);
        nCount = 1;
    }
    //Loop through creatures to see who falls down.
    do
    {
        if (!ReflexSave(oCreature, nDC ))
        {
             fDelay=  GetDistanceBetween (oCreature,oCenter);
             fDelay= (fDelay /5 - FloatToInt(fDelay/5))*4;
             DelayCommand ( fDelay ,AssignCommand (oCreature,Fall()));
        }
        nCount++;
        oCreature=GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oCenter ,nCount );
    }
    while (GetIsObjectValid(oCreature));


    nDuration--;
    if( nDuration  ) DelayCommand(6.0,QuakeEarth(nDuration, nDC-INCREAS_DC_PER_LENGTH, oCenter));
}

 void Fall( )
{
   int nAnination;
   float fDelay=IntToFloat(Random(4)+2);
   int nRoll = d4();
   switch (nRoll)
   {
      case 1: nAnination = ANIMATION_LOOPING_DEAD_BACK; break;
      case 2: nAnination = ANIMATION_LOOPING_DEAD_FRONT; break;
      case 3: nAnination = ANIMATION_LOOPING_SIT_CROSS; break;
      case 4: nAnination = ANIMATION_LOOPING_PAUSE_DRUNK; fDelay=fDelay/2; break;
   }
 

    ClearAllActions();

    PlayAnimation(nAnination, 1.0 ,fDelay);
    SetCommandable(FALSE);
    DelayCommand( fDelay, SetCommandable(TRUE));
}

void SetUpQuake(int bForce= FALSE)
{
  // set a random delay for PC just entering or still in the area.
  if (( bForce || GetIsPCInArea()) && GetArea(OBJECT_SELF)== GetLocalObject(OBJECT_SELF,"QuakeArea") )
  {
     float fDelay = RoundsToSeconds( Random (  MAX_RND_BETWEEN_QUAKES - MIN_RND_BETWEEN_QUAKES )+  MIN_RND_BETWEEN_QUAKES);
     int nLength = Random(MAX_LENGHT_OF_QUAKE)+1;
     int nDC =  INCREAS_DC_PER_LENGTH * (nLength-1) + 20;
     DelayCommand (fDelay, QuakeEarth( nLength,nDC));
     DelayCommand (fDelay+ 0.5 , SetUpQuake());
  }
  // no PC here so end the quakes
  else
  {
      SetLocalInt(OBJECT_SELF,"TimmerRunning",FALSE);
      //SendMessageToPC(GetFirstPC(),"quakes shutting down");
  }
}

int GetIsPCInArea(object oArea=OBJECT_SELF)
{
   object oPC = GetFirstPC();
   oArea = GetArea(oArea);
   while (GetIsObjectValid(oPC))
   {
       if (GetArea(oPC) == oArea) return TRUE;
       oPC = GetNextPC();
   }
   return FALSE;
}

// 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)
{
   object oPC = GetEnteringObject();
   int bTimmer  = GetLocalInt(OBJECT_SELF,"TimmerRunning");

   // exit if the timmer is already running or it is not a PC unless it is not being ran from the area.
   if ( bTimmer || (!GetIsPC(oPC) && (GetArea(OBJECT_SELF)==OBJECT_SELF))    ) return;

   // Set a Flag that the timmer is running.
   SetLocalInt(OBJECT_SELF,"TimmerRunning",TRUE);
   if(nMinRnd != -1) MIN_RND_BETWEEN_QUAKES = nMinRnd;
   if(nMaxRnd != -1) MAX_RND_BETWEEN_QUAKES = nMaxRnd;
   if(nMaxLength != -1) MAX_LENGHT_OF_QUAKE = nMaxLength;
   if(IncDc != -1) INCREAS_DC_PER_LENGTH = IncDc;
   SetLocalObject(OBJECT_SELF,"QuakeArea",GetArea(OBJECT_SELF));
   SetUpQuake( TRUE );

}


 
 



To just do a Single Quake IT is a simple as.  
 
 [quote]


#include "are_eff_quake"
void main()
{
   QuakeEarth();
 [/quote]


If you wanted an Area to have random quakes all the time. you could just add this to the OnEnter Script.
 
 [quote]

#include "are_eff_quake"
void main ()
{
  RandomQuakes(5,10,5,10);
}
 
 [/quote]

The Random Quakes are set up on a Self Terminating pseudo HB that stops when all the PC's leave the area. 
It also makes sure that all PC in the area have a visual line of site to the Effect.  Fall Patterns follow a ripple from the quake center to similate the roll of the earth, (Everyone will not fall down at the same time if the fail there save).  
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Earthquake
« Reply #3 on: April 13, 2011, 09:51:43 pm »


               Oooh. Nice info there Lightfoot. I didn't know abouth the "being seen" thing. I learned something new.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Earthquake
« Reply #4 on: April 13, 2011, 09:53:50 pm »


               Thanks both of you. vfx_shake_screen how'd I miss that thanks Ghost. I love your script lightfoot. that must of been fun playing a DM that falls down. I needed a good Laugh.
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Earthquake
« Reply #5 on: April 14, 2011, 02:53:59 pm »


               I would like to add if I could.I had a rune gate in my mod when you dial it visual effects were applied to oPC... about 3 effects.My problem was if oPC was invisible other PC's wouldnt see the effects of the gate.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Earthquake
« Reply #6 on: April 14, 2011, 08:17:58 pm »


               As seen in Lightfoots script he checks for other Players before applying the effect, you could do the same, maybe apply to a temp hidden_object placeable and not the pc.  i had to do this with a beam from a statue to a door it would not create beam but once i used a core pillar then set phyno to hidden object... waalaa beam from statue to door.  So what you are doing is creating the effects on the hidden_object that is created at invisable Players location.  Might work try that or send me a pm with your email and then I can try and fix it.  Unless you have already fixed it.