Author Topic: Exploding at Random...  (Read 1674 times)

Legacy_PLUSH HYENA of DOOM

  • Hero Member
  • *****
  • Posts: 995
  • Karma: +0/-0
Exploding at Random...
« on: June 28, 2016, 07:05:41 am »


               

Is it, he asked displaying his hideous ignorance of everything but how to make Gigantic Spleen Monsters and Hindu Temples, possible to create a script of the following type which actually works:-


Example (which I'm attempting currently with zero success thus far)...


 


An OnEnter script for a Trigger Box, which causes a Fire and Forget effect (Fireball, in this particular case) to occur at, say, two second intervals, RANDOMLY at RANDOM points within the Trigger Box? OR, alternatively, sets them off randomly at any Waypoint called X, or, any Waypoint from the list X1 to X50 or however many one might want.


I've been having a lot of problems with this, though pathetic and unreliable partial successes convince me it probably can be done.


Ideally I need a simple script that can easily be duplicated for different Effects going off at different random Waypoints of a named set, or randomly within a trigger box. And it has to KEEP setting off random splats once it's started and not pack it in again two seconds later, which mine tend to do thus far.


 


Many thanks in advance for any helpful stuff...



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Exploding at Random...
« Reply #1 on: June 29, 2016, 03:42:51 am »


               

Well, you can maybe try this to start with. There's lots of ways to do this, so maybe someone will come up with a more efficient method.


 


Anyway though, with the script below you'll need to use a trigger and waypoints as I don't know of a way you can select a random location within the boundary of a trigger. The trigger will need to have it's tag changed to Fireball, however I also set it up a couple other examples for having triggers with a different tag play the dispel or horrid wilting VFX. The trigger tag is THE key, and if you want more than just the three examples I setup, you can add them by just following the three examples I have. Put this script in the trigger's OnEnter event.


 


You will also need to place waypoints with Tags of WP_VFX where you want these random VFX to occur. You don't need to add a number to the end of the tag - just setup the first waypoint with that tag and then copy and paste the waypoint to all the places in the area where you want the VFX to potentially fire.


 


And that should be about it...



int GetVFX();
void RecurringVFXLoop();

void main()
{
  if (!GetLocalInt(OBJECT_SELF, "TotalVFXWaypoints")) { //Only run this once if the trigger has not been setup with VFX waypoints
    int i = 1;
    int iTotalVFXWayPoints;
    string sVFXWaypointTag = "WP_VFX"; //This is the tag of the waypoints where the VFX will occur. Change/update as needed

    object oVFXWaypoint = GetNearestObject(OBJECT_TYPE_WAYPOINT, OBJECT_SELF, i);
    while (oVFXWaypoint != OBJECT_INVALID) {
      if (GetTag(oVFXWaypoint) == sVFXWaypointTag) { //Only bother with waypoints that have the sVFXWaypointTag tag
        iTotalVFXWayPoints = iTotalVFXWayPoints+1;
        SetLocalObject(OBJECT_SELF, "VFXWaypoint"+IntToString(iTotalVFXWayPoints), oVFXWaypoint); //Set each waypoint as an object on the trigger for random retrieval in the RecurringVFXLoop function
        SetLocalInt(OBJECT_SELF, "TotalVFXWaypoints", iTotalVFXWayPoints); //Set the total number of random waypoints on the trigger
      }

      i = i+1;
      oVFXWaypoint = GetNearestObject(OBJECT_TYPE_WAYPOINT, OBJECT_SELF, i);
    }

    DelayCommand(0.1, RecurringVFXLoop()); //While probably not necessary, delay this just a split second to make sure the waypoints are set on the trigger
  }
}

int GetTriggerVFX()
{
  string sTag = GetTag(OBJECT_SELF); //You will need to change the tag of the trigger to specify the name of the VFX you want to fire, then set that in the lines below

  int iVFX;
  if (sTag == "Fireball") iVFX = VFX_FNF_FIREBALL; //Play this VFX if the tag of the trigger is Fireball
  else if (sTag == "Dispel") iVFX = VFX_FNF_DISPEL; //Play this VFX if the tag of the trigger is Dispel
  else if (sTag == "Wilting") iVFX = VFX_FNF_HORRID_WILTING; //Play this VFX if the tag of the trigger is Wilting
  //etc, etc, etc

  return iVFX;
}

void RecurringVFXLoop()
{
  int iTotalVFXWaypoints = GetLocalInt(OBJECT_SELF, "TotalVFXWaypoints");
  if (!iTotalVFXWaypoints) {
    PrintString("ERROR: No Random VFX Waypoints were set for a random VFX trigger");
    SendMessageToPC(GetFirstPC(), "ERROR: No Random VFX Waypoints were set for a random VFX trigger");
    return;
  }

  object oRandomVFXWaypoint = GetLocalObject(OBJECT_SELF, "VFXWaypoint"+IntToString(Random(iTotalVFXWaypoints)+1)); //Select a random waypoint to play the VFX at
  ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(GetTriggerVFX()), GetLocation(oRandomVFXWaypoint));

  DelayCommand(2.0, RecurringVFXLoop()); //Fire every two seconds. This will fire indefinitely...
}


               
               

               
            

Legacy_PLUSH HYENA of DOOM

  • Hero Member
  • *****
  • Posts: 995
  • Karma: +0/-0
Exploding at Random...
« Reply #2 on: June 29, 2016, 07:49:47 am »


               

Aaaah... I see where I went wrong now - I was trying to be pathetically and unnecessarily OVERCOMPLICATED! That's almost always where I go wrong with a script, missing the nice, "simple" solution...


 


Shabby Hyena Object drags unpleasantly mangled and half-eaten zebra carcass to your doorstep and deposits it before you... No, honestly, it's the greatest thanks a Hyena can give! It's a great accolade... well, OK, I'll remove the putrefacted zebra and just say "thanks" a lot, if you prefer...


 


Thanks!



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Exploding at Random...
« Reply #3 on: June 29, 2016, 02:56:37 pm »


               

Neat - I've never had a zebra carcass before. Thanks! I figured this was the least I could do for all the neat CC stuff you've created that I use. '<img'>



               
               

               
            

Legacy_PLUSH HYENA of DOOM

  • Hero Member
  • *****
  • Posts: 995
  • Karma: +0/-0
Exploding at Random...
« Reply #4 on: July 01, 2016, 10:56:25 am »


               

Symbiosis! Alive and well in the 21st century.



               
               

               
            

Legacy_PLUSH HYENA of DOOM

  • Hero Member
  • *****
  • Posts: 995
  • Karma: +0/-0
Exploding at Random...
« Reply #5 on: July 14, 2016, 07:29:19 pm »


               

Thayan:- Just a quick additional thank you... I've got this script working as the core of a nice little system of random blobs that go splat now. Just what was required.


Most helpful! Thanks!



               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Exploding at Random...
« Reply #6 on: July 16, 2016, 05:26:17 pm »


               

That's great to hear. I'm glad it work out for you!



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Exploding at Random...
« Reply #7 on: July 16, 2016, 09:55:20 pm »


               

I remember some time back that sixes thrice had a cool thing like this going on where a random spot in an area would have a VFX proceed an area of attack effect, so you'd have to dodge the random explosions.


 


It would be nice to see what his code looked like. Lets see if he shows up.



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Exploding at Random...
« Reply #8 on: July 18, 2016, 07:47:17 am »


               

I just posted a random location generator in this thread that easily be modified/incorporated/used in the ideas here with a little modification.


 


https://forum.biowar...rstorm-in-area/