Author Topic: Boss & Lackey(s) Spawn Trigger Template Script  (Read 426 times)

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
Boss & Lackey(s) Spawn Trigger Template Script
« on: August 14, 2010, 02:20:15 pm »


               ////////////////////////////////////////////////////////////////////////////
//Script Name: spawn_boss_oe  
// (Template Script - Save Under a Unique Name FIRST!)
///////////////////////////////////////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On: 8/14/10
///////////////////////////////////////////////////////////////////////////
/*
   NOTE: This script goes in the OnEnter event of a tracks trigger

   This is a custom template for spawning bosses and lackeys based upon
   the # of party members in the area, which allows for scaling the boss
   encounter to make the encounter more balanced if the PC  is alone
   and to make the encounter more challenging for parties..

****IMPORTANT NOTE: You MUST use a unique tagname for EVERY Tracks Trigger You Create!!****

*/
/////////////////////////////////////////////////////////////////////////////
//////////////IMPORTANT SETTINGS - PLEASE ADJUST////////////////////////////
///////////////////////////////////////////////////////////////////////////
//Set this to how often you want the boss to spawn for ANYONE who was in
//the area when the Boss was spawned (by any party member in the area)
const float BOSS_SPAWN_TIME = 1800.0; //Default = 30 Minutes(1800 Seconds)

//Set this to the Multiplier of Henchment Spawned (BE CAREFUL)
//If you set this to 1 (1 henchmen / party member in the area will spawn)
//if you set this to 4 (4 henchmen / party member in the area will spawn)
const int HENCHMEN_MULTIPLIER = 1; //Default = 1 (1 Henchment / Party Member)

//Set this to the (resref)(NOT Tagname) of the Boss to be spawned..
const string BOSS_RESREF = "resref"; //Don't delete the "";

//Set this to the (resref) of the First Henchment to Spawn
const string HENCHMEN_RESREF =  "resref";

//Set this to the Second (resref) of the Henchment to Spawn
const string HENCHEMENT_2_RESREF = "resref";

//IF you are spawning in 2 Different Henchmen for the boss, then set
//the following to TRUE, it's set to FALSE by default which means..
//The script will only use the First Henchmen
const int USE_2_HENCHMEN = FALSE; //Default = FALSE use only 1 Henchmen

//Set this to the VFX Constant you wish to use on the Boss which is spawning in
//You MUST use a constant!      Example:       VFX_FNF_HOWL_WAR_CRY

const int BOSS_SPAWN_VFX = VFX_FNF_SOUND_BURST;
//NOTE: This helps the PC see the boss too. '<img'>

///////////////////////////////////////////////////////////////////////////////
//////////WARNING:  DON'T TOUCH ANYTHING BELOW THIS LINE//////////////////////
/////////////////////////////////////////////////////////////////////////////

//Required Include
#include "nw_i0_generic"

//Declare Custom Prototype
int GetPartyCount(object oPC);

////////////////////////////////////////////////////////////////////////////

//Main Script..
void main()
{
  //Declare Major Variables..
  object oPC = GetEnteringObject();
  object oTarget;
  object oSpawn;
  location lTarget;
  int nInt;
  object oMe = OBJECT_SELF; //The Tracks Trigger
  int i = 0;
  string sTag = GetTag(oMe);
  string sName = GetName(oPC);

  //First check to see if the PC has spawn this trigger before!
  int nSpawned = GetLocalInt(GetModule(),sTag + sName);
  //If they have spawned the boss recently, stop here...
  if(nSpawned == TRUE)
  {
   FloatingTextStringOnCreature("You already destroyed this boss, move along.", oPC, TRUE);
   return;
  }

  //Next Set that the PC's have entered this trigger before & Get the party count! (In THIS Area)
  int iParty = GetPartyCount(oPC);

  //Always Spawn in the Boss & Always Use this VFX...
  oTarget = oPC;
  lTarget = GetLocation(oTarget);
  oSpawn = CreateObject(OBJECT_TYPE_CREATURE, BOSS_RESREF, lTarget);
  oTarget = oSpawn;
  SetIsTemporaryEnemy(oPC, oTarget);
  AssignCommand(oTarget, ActionAttack(oPC));
  AssignCommand(oTarget, DetermineCombatRound(oPC));

  //Apply the VFX to the boss
  nInt = GetObjectType(oTarget);
  if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(BOSS_SPAWN_VFX), oTarget));
  else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(BOSS_SPAWN_VFX), GetLocation(oTarget)));

 //If there is at least 2 party members in the area!
 if(iParty >=2)
 {
   //Multiply the # of Henchmen we are going to spawn by the # of Party Members..
   iParty = iParty * HENCHMEN_MULTIPLIER;

   for(i=0; i<iParty; i++)
   {
    lTarget = GetLocation(OBJECT_SELF); //Spawn them somewhere on the Trigger..
    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, HENCHMEN_RESREF, lTarget);
    oTarget = oSpawn;
    SetIsTemporaryEnemy(oPC, oTarget);
    AssignCommand(oTarget, ActionAttack(oPC));
    AssignCommand(oTarget, DetermineCombatRound(oPC));

    //If we are using 2 Seperate Henchment..
    if(USE_2_HENCHMEN == TRUE)
    {
     lTarget = GetLocation(OBJECT_SELF); //Spawn them somewhere on the Trigger..
     oSpawn = CreateObject(OBJECT_TYPE_CREATURE, HENCHEMENT_2_RESREF, lTarget);
     oTarget = oSpawn;
     SetIsTemporaryEnemy(oPC, oTarget);
     AssignCommand(oTarget, ActionAttack(oPC));
     AssignCommand(oTarget, DetermineCombatRound(oPC));
    }

  //End For Loop
  }

 //End if we have Multiple Party Members..
 }

//Main Script End
}
//////////////////////////////////////////////////////////////////////////////

//Define Custom Prototype
int GetPartyCount(object oPC)
{
  object oArea, oA2;
  oArea = GetArea(oPC);
  int i = 0;
  object oP;
  string sTag = GetTag(OBJECT_SELF); //The Tracks Trigger
  string sID = GetName(oPC);
  string sOP;

  //First Tag the PC noting they have spawned the boss!
  DelayCommand(0.5, SetLocalInt(GetModule(), sTag + sID, TRUE));
  //Set this on the module so logging will not clear it!
  DelayCommand(BOSS_SPAWN_TIME, SetLocalInt(GetModule(), sTag + sID, FALSE));

  oP = GetFirstFactionMember(oPC, TRUE); //Don't Count Summons!
  while(GetIsObjectValid(oP))
  {
   oA2 = GetArea(oP);
   if(oA2 == oArea)
   {
    i += 1;
    //Tag the Party Member in the area as having Spawned the Boss!
    sOP = GetName(oP);
    DelayCommand(0.5, SetLocalInt(GetModule(), sTag + sOP, TRUE));
    DelayCommand(BOSS_SPAWN_TIME, SetLocalInt(GetModule(), sTag + sOP, FALSE));
   }
    oP = GetNextFactionMember(oPC, TRUE);
  }

  //Note, we don't count the original PC!

  return i;

//Prototype End
}
///////////////////////////////////////////////////////////////////////////////
               
               

               


                     Modifié par Genisys, 16 août 2010 - 07:41 .
                     
                  


            

Legacy_Genisys

  • Hero Member
  • *****
  • Posts: 961
  • Karma: +0/-0
Boss & Lackey(s) Spawn Trigger Template Script
« Reply #1 on: August 14, 2010, 02:22:02 pm »


               I hope someone likes & uses this...

This system is for Server or LAN - Multiplayer Modules only... not needed for single player modules..

Did anyone see any flaws I need to correct in this script?

Any feedback here?
               
               

               


                     Modifié par Genisys, 15 août 2010 - 02:27 .
                     
                  


            

Legacy_xXslaughterhouseXx

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
Boss & Lackey(s) Spawn Trigger Template Script
« Reply #2 on: November 19, 2010, 12:44:46 am »


               I have a question for ya.  Is there a function in this script (or in the Bioware encounter system, that I may be missing) that gives the option to spawn a boss only if there are more/less than a particular amount of people in given area?