mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-06 22:12:58 -04:00
who isn't sick of converting the freaking scripts? this negates the need
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
|
||||
public class content_spawning_master extends script.base_script
|
||||
{
|
||||
public content_spawning_master()
|
||||
{
|
||||
}
|
||||
public void main() throws InterruptedException
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
include library.utils;
|
||||
|
||||
void main(){}
|
||||
@@ -0,0 +1,25 @@
|
||||
package script.systems.spawning.dropship;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class base extends script.base_script
|
||||
{
|
||||
public base()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
detachScript(self, "ai.ai");
|
||||
detachScript(self, "ai.creature_combat");
|
||||
detachScript(self, "skeleton.humanoid");
|
||||
detachScript(self, "systems.combat.combat_actions");
|
||||
detachScript(self, "systems.combat.credit_for_kills");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
trigger OnAttach()
|
||||
{
|
||||
detachScript (self, "ai.ai");
|
||||
detachScript (self, "ai.creature_combat");
|
||||
detachScript (self, "skeleton.humanoid");
|
||||
detachScript (self, "systems.combat.combat_actions");
|
||||
detachScript (self, "systems.combat.credit_for_kills");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package script.systems.spawning.dropship;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.create;
|
||||
import script.library.utils;
|
||||
|
||||
public class emperorsday_lambda extends script.systems.spawning.dropship.base
|
||||
{
|
||||
public emperorsday_lambda()
|
||||
{
|
||||
}
|
||||
public static final boolean LOGGING_ON = true;
|
||||
public static final String LOGGING_CATEGORY = "empireday";
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.OnAttach: Init");
|
||||
messageTo(self, "handleAttachDelay", null, 2f, false);
|
||||
setHibernationDelay(self, 600.0f);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
public int handleAttachDelay(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.handleAttachDelay: Init");
|
||||
stop(self);
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
messageTo(self, "takeOff", null, 600f, true);
|
||||
queueCommand(self, (-1465754503), self, "", COMMAND_PRIORITY_FRONT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int changePosture(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.changePosture: Init");
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
location ownLocation = getLocation(self);
|
||||
location behind = ownLocation;
|
||||
behind.z = ownLocation.z - 20.0f;
|
||||
faceTo(self, behind);
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int takeOff(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.takeOff: Init");
|
||||
obj_id exitPoint = getObjIdObjVar(self, "exitpoint");
|
||||
if (isValidId(exitPoint))
|
||||
{
|
||||
blog("emperorsday_lambda.changePosture: Facing to exit location");
|
||||
location exitLocation = getLocation(exitPoint);
|
||||
faceTo(self, exitLocation);
|
||||
messageTo(self, "moveToExitPoint", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(self, "changePosture", null, 10, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int moveToExitPoint(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.moveToExitPoint init");
|
||||
obj_id exitPoint = getObjIdObjVar(self, "exitpoint");
|
||||
if (!isValidId(exitPoint))
|
||||
{
|
||||
messageTo(self, "changePosture", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setMovementPercent(self, 16);
|
||||
blog("emperorsday_lambda.moveToExitPoint exit point valid");
|
||||
location loc = getLocation(exitPoint);
|
||||
pathTo(self, loc);
|
||||
messageTo(self, "correctTakeOffThenCleanUp", null, 10, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int correctTakeOffThenCleanUp(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("emperorsday_lambda.correctTakeOffThenCleanUp init");
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
blog("emperorsday_lambda.correctTakeOffThenCleanUp changePosture");
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int selfCleanUp(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean blog(String msg) throws InterruptedException
|
||||
{
|
||||
if (LOGGING_ON && msg != null && !msg.equals(""))
|
||||
{
|
||||
LOG(LOGGING_CATEGORY, msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
include library.create;
|
||||
include library.utils;
|
||||
|
||||
inherits systems.spawning.dropship.base; //This script just removes unneeded scripts from the flying creature
|
||||
|
||||
|
||||
//-----------------LOGGING
|
||||
const boolean LOGGING_ON = true;
|
||||
const string LOGGING_CATEGORY = "empireday";
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
blog("emperorsday_lambda.OnAttach: Init");
|
||||
|
||||
messageTo(self, "handleAttachDelay", null, 2f, false);
|
||||
setHibernationDelay(self, 600.0f);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
|
||||
messageHandler handleAttachDelay()
|
||||
{
|
||||
blog("emperorsday_lambda.handleAttachDelay: Init");
|
||||
|
||||
stop (self);
|
||||
//setName (self, "Stormtrooper Transport");
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
messageTo(self, "takeOff", null, 600f, true);
|
||||
queueCommand(self, ##"stand", self, "", COMMAND_PRIORITY_FRONT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler changePosture()
|
||||
{
|
||||
blog("emperorsday_lambda.changePosture: Init");
|
||||
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
location ownLocation = getLocation(self);
|
||||
location behind = ownLocation;
|
||||
behind.z = ownLocation.z-20.0f;
|
||||
faceTo(self, behind);
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler takeOff()
|
||||
{
|
||||
blog("emperorsday_lambda.takeOff: Init");
|
||||
|
||||
obj_id exitPoint = getObjIdObjVar(self, "exitpoint");
|
||||
if(isValidId(exitPoint))
|
||||
{
|
||||
blog("emperorsday_lambda.changePosture: Facing to exit location");
|
||||
|
||||
location exitLocation = getLocation(exitPoint);
|
||||
faceTo(self, exitLocation);
|
||||
|
||||
messageTo(self, "moveToExitPoint", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageTo (self, "changePosture", null, 10, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler moveToExitPoint()
|
||||
{
|
||||
blog("emperorsday_lambda.moveToExitPoint init");
|
||||
|
||||
obj_id exitPoint = getObjIdObjVar(self, "exitpoint");
|
||||
if(!isValidId(exitPoint))
|
||||
{
|
||||
messageTo (self, "changePosture", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
setMovementPercent(self, 16);
|
||||
blog("emperorsday_lambda.moveToExitPoint exit point valid");
|
||||
location loc = getLocation(exitPoint);
|
||||
pathTo(self, loc);
|
||||
messageTo(self, "correctTakeOffThenCleanUp", null, 10, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler correctTakeOffThenCleanUp()
|
||||
{
|
||||
blog("emperorsday_lambda.correctTakeOffThenCleanUp init");
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
blog("emperorsday_lambda.correctTakeOffThenCleanUp changePosture");
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler selfCleanUp ()
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
boolean blog(string msg)
|
||||
{
|
||||
if(LOGGING_ON && msg != null && !msg.equals(""))
|
||||
LOG(LOGGING_CATEGORY, msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package script.systems.spawning.dropship;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.create;
|
||||
|
||||
public class emperorsday_yt1300 extends script.systems.spawning.dropship.base
|
||||
{
|
||||
public emperorsday_yt1300()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "handleAttachDelay", null, 5.0f, false);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
public int handleAttachDelay(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
queueCommand(self, (-1465754503), self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "takeOff", null, 600.0f, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int changePosture(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
queueCommand(self, (-1114832209), self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "selfCleanUp", null, 60.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int takeOff(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "changePosture", null, 5.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int selfCleanUp(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
|
||||
include library.utils;
|
||||
include library.create;
|
||||
|
||||
inherits systems.spawning.dropship.base;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
messageTo(self, "handleAttachDelay", null, 5.0f, false);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
|
||||
messageHandler handleAttachDelay()
|
||||
{
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
queueCommand(self, ##"stand", self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "takeOff", null, 600.0f, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler changePosture()
|
||||
{
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
queueCommand(self, ##"prone", self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "selfCleanUp", null, 60.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler takeOff()
|
||||
{
|
||||
messageTo (self, "changePosture", null, 5.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler selfCleanUp ()
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package script.systems.spawning.dropship;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
import script.library.create;
|
||||
import script.library.gcw;
|
||||
|
||||
public class lambda extends script.systems.spawning.dropship.base
|
||||
{
|
||||
public lambda()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "handleAttachDelay", null, 2f, false);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
public int handleAttachDelay(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
stop(self);
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
messageTo(self, "spawnPayload", null, 20f, true);
|
||||
queueCommand(self, (-1465754503), self, "", COMMAND_PRIORITY_FRONT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int changePosture(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnPayload(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String[] spawnNames = utils.getStringArrayScriptVar(self, "spawnNames");
|
||||
if (spawnNames != null && spawnNames.length > 0)
|
||||
{
|
||||
location here = getLocation(self);
|
||||
if (here != null)
|
||||
{
|
||||
int pos = 0;
|
||||
obj_id leader = null;
|
||||
Vector spawns = new Vector();
|
||||
spawns.setSize(0);
|
||||
for (int i = 0; i < spawnNames.length; i++)
|
||||
{
|
||||
obj_id thisSpawn = create.object(spawnNames[i], here);
|
||||
if (isIdValid(thisSpawn) && !isIdValid(leader))
|
||||
{
|
||||
leader = thisSpawn;
|
||||
spawns = utils.addElement(spawns, thisSpawn);
|
||||
if (i > 0 && isIdValid(leader))
|
||||
{
|
||||
ai_lib.wander(thisSpawn);
|
||||
attachScript(thisSpawn, "ai.imperial_presence.harass");
|
||||
}
|
||||
}
|
||||
if (isIdValid(thisSpawn))
|
||||
{
|
||||
detachScript(leader, "ai.soldier");
|
||||
setMovementRun(thisSpawn);
|
||||
utils.removeObjVar(thisSpawn, "ai.diction");
|
||||
ai_lib.followInFormation(thisSpawn, leader, 4, ++pos);
|
||||
}
|
||||
}
|
||||
if (spawns != null && spawns.size() > 0)
|
||||
{
|
||||
dictionary spawnParams = utils.getDictionaryScriptVar(self, "spawnParameters");
|
||||
if (spawnParams != null && !spawnParams.isEmpty())
|
||||
{
|
||||
messageTo(((obj_id)spawns.get(0)), "handleSpawnParameters", spawnParams, 1f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
messageTo(self, "changePosture", null, 5, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int selfCleanUp(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
include library.create;
|
||||
include library.gcw;
|
||||
|
||||
inherits systems.spawning.dropship.base;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
messageTo(self, "handleAttachDelay", null, 2f, false);
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
|
||||
messageHandler handleAttachDelay()
|
||||
{
|
||||
stop (self);
|
||||
//setName (self, "Stormtrooper Transport");
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
messageTo(self, "spawnPayload", null, 20f, true);
|
||||
queueCommand(self, ##"stand", self, "", COMMAND_PRIORITY_FRONT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler changePosture()
|
||||
{
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
messageTo(self, "selfCleanUp", null, 60f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler spawnPayload()
|
||||
{
|
||||
string[] spawnNames = utils.getStringArrayScriptVar(self, "spawnNames");
|
||||
if ( spawnNames != null && spawnNames.length > 0 )
|
||||
{
|
||||
location here = getLocation(self);
|
||||
if ( here != null )
|
||||
{
|
||||
int pos = 0;
|
||||
obj_id leader = null;
|
||||
resizeable obj_id[] spawns = new obj_id[0];
|
||||
for ( int i = 0; i < spawnNames.length; i++ )
|
||||
{
|
||||
obj_id thisSpawn = create.object(spawnNames[i], here);
|
||||
if ( isIdValid(thisSpawn) && !isIdValid(leader) )
|
||||
{
|
||||
leader = thisSpawn;
|
||||
spawns = utils.addElement(spawns, thisSpawn);
|
||||
|
||||
if ( i > 0 && isIdValid(leader) )
|
||||
{
|
||||
//ai_lib.FORMATION_COLUMN = 0;
|
||||
ai_lib.wander(thisSpawn);
|
||||
attachScript(thisSpawn, "ai.imperial_presence.harass");
|
||||
}
|
||||
|
||||
}
|
||||
if( isIdValid(thisSpawn))
|
||||
{
|
||||
detachScript(leader, "ai.soldier");
|
||||
setMovementRun(thisSpawn);
|
||||
utils.removeObjVar( thisSpawn, "ai.diction");
|
||||
ai_lib.followInFormation(thisSpawn, leader, 4, ++pos);
|
||||
}
|
||||
}
|
||||
|
||||
if ( spawns != null && spawns.length > 0 )
|
||||
{
|
||||
dictionary spawnParams = utils.getDictionaryScriptVar(self, "spawnParameters");
|
||||
if ( spawnParams != null && !spawnParams.isEmpty() )
|
||||
messageTo(spawns[0], "handleSpawnParameters", spawnParams, 1f, false);
|
||||
//debugSpeakMsg(self, "Sending Msg Handler to myself.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageTo (self, "changePosture", null, 5, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler selfCleanUp ()
|
||||
{
|
||||
if (isIdValid(self))
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package script.systems.spawning.dropship;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
|
||||
public class player_shuttle extends script.systems.spawning.dropship.base
|
||||
{
|
||||
public player_shuttle()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
public int landShuttle(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
queueCommand(self, (-1465754503), self, "", COMMAND_PRIORITY_FRONT);
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int takeOff(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
queueCommand(self, (-1114832209), self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "destroySelf", null, 60.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int explodeThenDestroySelf(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
location locList[] = params.getLocationArray("explosionLocaitonList");
|
||||
if (locList != null && locList.length > 0)
|
||||
{
|
||||
for (int i = 0; i < locList.length; i++)
|
||||
{
|
||||
playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", locList[i], 0);
|
||||
}
|
||||
}
|
||||
messageTo(self, "destroySelf", null, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
location death = getLocation(self);
|
||||
playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", death, 0);
|
||||
messageTo(self, "destroySelf", null, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int destroySelf(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
|
||||
inherits systems.spawning.dropship.base;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
return super.OnAttach(self);
|
||||
}
|
||||
|
||||
messageHandler landShuttle()
|
||||
{
|
||||
queueCommand(self, ##"stand", self, "", COMMAND_PRIORITY_FRONT);
|
||||
setPosture(self, POSTURE_UPRIGHT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler takeOff()
|
||||
{
|
||||
setPosture(self, POSTURE_PRONE);
|
||||
queueCommand(self, ##"prone", self, "", COMMAND_PRIORITY_FRONT);
|
||||
messageTo(self, "destroySelf", null, 60.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler explodeThenDestroySelf()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
|
||||
location locList[] = params.getLocationArray("explosionLocaitonList");
|
||||
if(locList != null && locList.length > 0)
|
||||
{
|
||||
for(int i = 0; i < locList.length; i++)
|
||||
{
|
||||
playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", locList[i], 0);
|
||||
}
|
||||
}
|
||||
messageTo(self, "destroySelf", null, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
location death = getLocation(self);
|
||||
playClientEffectLoc(self, "clienteffect/combat_explosion_lair_large.cef", death, 0);
|
||||
messageTo(self, "destroySelf", null, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler destroySelf()
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package script.systems.spawning.imperial;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.attrib;
|
||||
import script.library.utils;
|
||||
import script.library.create;
|
||||
import script.library.pet_lib;
|
||||
|
||||
public class probot_egg extends script.base_script
|
||||
{
|
||||
public probot_egg()
|
||||
{
|
||||
}
|
||||
public static final float VOL_SPAWN_RANGE = 80f;
|
||||
public static final String VOL_SPAWN = "volSpawnProbot";
|
||||
public static final float VOL_EFFECT_RANGE = 100f;
|
||||
public static final String VOL_EFFECT = "volEffect";
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
createTriggerVolume(VOL_EFFECT, VOL_EFFECT_RANGE, true);
|
||||
createTriggerVolume(VOL_SPAWN, VOL_SPAWN_RANGE, true);
|
||||
setAttributeInterested(self, attrib.ALL);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTriggerVolumeEntered(obj_id self, String volName, obj_id who) throws InterruptedException
|
||||
{
|
||||
if (who == self)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (pet_lib.isPet(who))
|
||||
{
|
||||
obj_id master = getMaster(who);
|
||||
if (isIdValid(master))
|
||||
{
|
||||
who = master;
|
||||
}
|
||||
}
|
||||
if (isPlayer(who))
|
||||
{
|
||||
if (volName.equals(VOL_EFFECT) && !utils.hasScriptVar(self, "playedEffect"))
|
||||
{
|
||||
utils.setScriptVar(self, "playedEffect", true);
|
||||
playClientEffectLoc(who, "clienteffect/probot_delivery.cef", getLocation(self), 0f);
|
||||
removeTriggerVolume(VOL_EFFECT);
|
||||
messageTo(self, "handleSpawnDebris", null, 3f, false);
|
||||
}
|
||||
else if (volName.equals(VOL_SPAWN))
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
params.put("target", who);
|
||||
messageTo(self, "handleSpawnProbot", params, 1f, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleSpawnProbot(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!utils.hasScriptVar(self, "spawnedDebris"))
|
||||
{
|
||||
int numCycle = params.getInt("cycle");
|
||||
if (numCycle > 5)
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
params.put("cycle", ++numCycle);
|
||||
messageTo(self, "handleSpawnProbot", params, 1f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int x = 0;
|
||||
if (x <= 6)
|
||||
{
|
||||
obj_id probot = create.object("imperial_probot_drone", getLocation(self));
|
||||
if (isIdValid(probot))
|
||||
{
|
||||
attachScript(probot, "ai.override_behavior.scout");
|
||||
messageTo(probot, "handleTargetAssignment", params, 1f, false);
|
||||
}
|
||||
}
|
||||
else if (x <= 9)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleSpawnDebris(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
utils.setScriptVar(self, "spawnedDebris", true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
include library.attrib;
|
||||
include library.utils;
|
||||
include library.create;
|
||||
include library.pet_lib;
|
||||
|
||||
const float VOL_SPAWN_RANGE = 80f;
|
||||
const string VOL_SPAWN = "volSpawnProbot";
|
||||
|
||||
const float VOL_EFFECT_RANGE = 100f;
|
||||
const string VOL_EFFECT = "volEffect";
|
||||
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
createTriggerVolume(VOL_EFFECT, VOL_EFFECT_RANGE, true);
|
||||
createTriggerVolume(VOL_SPAWN, VOL_SPAWN_RANGE, true);
|
||||
setAttributeInterested(self, attrib.ALL);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnTriggerVolumeEntered(string volName, obj_id who)
|
||||
{
|
||||
if ( who == self )
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if ( pet_lib.isPet(who) )
|
||||
{
|
||||
obj_id master = getMaster(who);
|
||||
if ( isIdValid(master) )
|
||||
who = master;
|
||||
}
|
||||
|
||||
if ( isPlayer(who) )
|
||||
{
|
||||
if ( volName.equals(VOL_EFFECT) && !utils.hasScriptVar(self, "playedEffect") )
|
||||
{
|
||||
utils.setScriptVar(self, "playedEffect", true);
|
||||
playClientEffectLoc(who, "clienteffect/probot_delivery.cef", getLocation(self), 0f);
|
||||
//playClientEffectObj(who, "clienteffect/probot_delivery.cef", self, "");
|
||||
removeTriggerVolume(VOL_EFFECT);
|
||||
|
||||
messageTo(self, "handleSpawnDebris", null, 3f, false);
|
||||
}
|
||||
else if ( volName.equals(VOL_SPAWN) )
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
params.put("target", who);
|
||||
messageTo(self, "handleSpawnProbot", params, 1f, false);
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleSpawnProbot()
|
||||
{
|
||||
if ( !utils.hasScriptVar(self, "spawnedDebris") )
|
||||
{
|
||||
int numCycle = params.getInt("cycle");
|
||||
if ( numCycle > 5 )
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
params.put("cycle", ++numCycle);
|
||||
messageTo(self, "handleSpawnProbot", params, 1f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
//int x = rand(0,10);
|
||||
int x = 0; //for debug
|
||||
if ( x <= 6 )
|
||||
{
|
||||
obj_id probot = create.object("imperial_probot_drone", getLocation(self));
|
||||
if ( isIdValid(probot) )
|
||||
{
|
||||
attachScript(probot, "ai.override_behavior.scout");
|
||||
messageTo(probot, "handleTargetAssignment", params, 1f, false);
|
||||
}
|
||||
}
|
||||
else if ( x <= 9 )
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
else //x = 10
|
||||
{
|
||||
//spawn treasure like a chest or something
|
||||
}
|
||||
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleSpawnDebris()
|
||||
{
|
||||
utils.setScriptVar(self, "spawnedDebris", true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
|
||||
public class mob_spawn_tracker extends script.base_script
|
||||
{
|
||||
public mob_spawn_tracker()
|
||||
{
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "objParent");
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "respawnMob", null, fltRespawnTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
include library.utils;
|
||||
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "objParent");
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "respawnMob", null, fltRespawnTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.space_utils;
|
||||
import script.library.planetary_map;
|
||||
import script.library.create;
|
||||
import script.library.objvar_mangle;
|
||||
import script.library.utils;
|
||||
import java.lang.Math;
|
||||
import script.library.hue;
|
||||
|
||||
public class mob_spawner extends script.base_script
|
||||
{
|
||||
public mob_spawner()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnPreloadComplete(obj_id self) throws InterruptedException
|
||||
{
|
||||
String strTest = "" + self;
|
||||
location locTest = getLocation(self);
|
||||
String strPlanet = locTest.area;
|
||||
dictionary dctSpawnInfo = dataTableGetRow("datatables/spawning/ground_spawning/static/" + strPlanet + ".iff", strTest);
|
||||
if (dctSpawnInfo == null)
|
||||
{
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self));
|
||||
setName(objTest, "BAD NPC SPAWNER IS HERE!, NO ENTRY IN Ground SPawning " + strPlanet + " NPC SPAWNERS DATATABLE");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String strType = dctSpawnInfo.getString("strType");
|
||||
String strMob = dctSpawnInfo.getString("strMob");
|
||||
String strName = dctSpawnInfo.getString("strName");
|
||||
float fltMinSpawnTime = dctSpawnInfo.getFloat("fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = dctSpawnInfo.getFloat("fltMaxSpawnTime");
|
||||
Vector strScripts = new Vector();
|
||||
strScripts.setSize(0);
|
||||
String strMobToSpawn = "";
|
||||
if (!strType.equals(""))
|
||||
{
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strType + ".iff";
|
||||
String[] strSpawnList = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if ((strSpawnList == null) || (strSpawnList.length == 0))
|
||||
{
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self));
|
||||
setName(objTest, "for object " + self + " bad entry of " + strType + " and planet " + strPlanet);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
utils.setScriptVar(self, "strSpawnList", strSpawnList);
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] strSpawnList = new String[1];
|
||||
strSpawnList[0] = strMob;
|
||||
utils.setScriptVar(self, "strSpawnList", strSpawnList);
|
||||
}
|
||||
for (int intI = 1; intI < 5; intI++)
|
||||
{
|
||||
String strScript = dctSpawnInfo.getString("strScript" + intI);
|
||||
if (!strScript.equals(""))
|
||||
{
|
||||
strScripts = utils.addElement(strScripts, strScript);
|
||||
}
|
||||
}
|
||||
if (strScripts.size() > 0)
|
||||
{
|
||||
utils.setScriptVar(self, "strScripts", strScripts);
|
||||
}
|
||||
if (!strType.equals(""))
|
||||
{
|
||||
utils.setScriptVar(self, "strName", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "strName", strName);
|
||||
}
|
||||
utils.setScriptVar(self, "fltMinSpawnTime", fltMinSpawnTime);
|
||||
utils.setScriptVar(self, "fltMaxSpawnTime", fltMaxSpawnTime);
|
||||
makeMob(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void makeMob(obj_id self) throws InterruptedException
|
||||
{
|
||||
location locTest = getLocation(self);
|
||||
String strPlanet = locTest.area;
|
||||
String[] strSpawnList = utils.getStringArrayScriptVar(self, "strSpawnList");
|
||||
String[] strScripts = utils.getStringArrayScriptVar(self, "strScripts");
|
||||
String strName = utils.getStringScriptVar(self, "strName");
|
||||
float fltMinSpawnTime = utils.getFloatScriptVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = utils.getFloatScriptVar(self, "fltMaxSpawnTime");
|
||||
String strMob = strSpawnList[rand(0, strSpawnList.length - 1)];
|
||||
obj_id objNPC = null;
|
||||
boolean spawnFailed = false;
|
||||
try
|
||||
{
|
||||
objNPC = create.object(strMob, getLocation(self));
|
||||
}
|
||||
catch(Throwable err)
|
||||
{
|
||||
spawnFailed = true;
|
||||
}
|
||||
if (!isIdValid(objNPC) || spawnFailed)
|
||||
{
|
||||
locTest.x = locTest.x + 1;
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", locTest);
|
||||
setName(objTest, "For " + self.toString() + " Bad NPC Type of type " + strMob + " on planet " + strPlanet);
|
||||
return;
|
||||
}
|
||||
setYaw(objNPC, getYaw(self));
|
||||
if (!strName.equals(""))
|
||||
{
|
||||
setName(objNPC, "");
|
||||
setName(objNPC, strName);
|
||||
}
|
||||
if ((strScripts != null) && (strScripts.length > 0))
|
||||
{
|
||||
for (int intI = 0; intI < strScripts.length; intI++)
|
||||
{
|
||||
if (!strScripts[intI].equals(""))
|
||||
{
|
||||
if (!hasScript(objNPC, strScripts[intI]))
|
||||
{
|
||||
attachScript(objNPC, strScripts[intI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
attachScript(objNPC, "systems.spawning.mob_spawn_tracker");
|
||||
utils.setScriptVar(objNPC, "objParent", self);
|
||||
utils.setScriptVar(objNPC, "fltRespawnTime", rand(fltMinSpawnTime, fltMaxSpawnTime));
|
||||
return;
|
||||
}
|
||||
public int respawnMob(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
makeMob(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
include library.space_utils;
|
||||
include library.planetary_map;
|
||||
include library.create;
|
||||
include library.objvar_mangle;
|
||||
include library.utils;
|
||||
include java.lang.Math;
|
||||
include library.hue;
|
||||
|
||||
// npc spawner
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnPreloadComplete()
|
||||
{
|
||||
//LOG("spawn", "ONINTIAILIZE");
|
||||
string strTest = ""+self;
|
||||
|
||||
location locTest = getLocation(self);
|
||||
string strPlanet = locTest.area;
|
||||
|
||||
dictionary dctSpawnInfo = dataTableGetRow("datatables/spawning/ground_spawning/static/"+strPlanet+".iff", strTest);
|
||||
|
||||
if(dctSpawnInfo==null)
|
||||
{
|
||||
//LOG("space", "NO ENTRY FOR "+self);
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self));
|
||||
setName(objTest, "BAD NPC SPAWNER IS HERE!, NO ENTRY IN Ground SPawning "+strPlanet+" NPC SPAWNERS DATATABLE");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// are we spawning a type or a specific
|
||||
string strType = dctSpawnInfo.getString("strType");
|
||||
string strMob = dctSpawnInfo.getString("strMob");
|
||||
string strName = dctSpawnInfo.getString("strName");
|
||||
//LOG("spawn", "strName Raw is "+strName);
|
||||
|
||||
float fltMinSpawnTime= dctSpawnInfo.getFloat("fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = dctSpawnInfo.getFloat("fltMaxSpawnTime");
|
||||
|
||||
resizeable string[] strScripts = new string[0];
|
||||
string strMobToSpawn = "";
|
||||
if(strType!="")
|
||||
{
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strType+".iff";
|
||||
string[] strSpawnList = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if((strSpawnList==null)||(strSpawnList.length==0))
|
||||
{
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", getLocation(self));
|
||||
setName(objTest, "for object "+self+" bad entry of "+strType+" and planet "+strPlanet);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
utils.setScriptVar(self, "strSpawnList", strSpawnList);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] strSpawnList = new string[1];
|
||||
strSpawnList[0] = strMob;
|
||||
utils.setScriptVar(self, "strSpawnList", strSpawnList); // for later use
|
||||
}
|
||||
for(int intI = 1; intI<5; intI++)
|
||||
{
|
||||
string strScript= dctSpawnInfo.getString("strScript"+intI);
|
||||
if(strScript!="")
|
||||
{
|
||||
strScripts = utils.addElement(strScripts, strScript);
|
||||
}
|
||||
}
|
||||
if(strScripts.length>0)
|
||||
{
|
||||
utils.setScriptVar(self, "strScripts", strScripts);
|
||||
}
|
||||
|
||||
if(strType!="")
|
||||
{
|
||||
utils.setScriptVar(self, "strName", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "strName", strName);
|
||||
}
|
||||
utils.setScriptVar(self, "fltMinSpawnTime", fltMinSpawnTime);
|
||||
utils.setScriptVar(self, "fltMaxSpawnTime", fltMaxSpawnTime);
|
||||
makeMob(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void makeMob(obj_id self)
|
||||
{
|
||||
location locTest = getLocation(self);
|
||||
string strPlanet = locTest.area;
|
||||
|
||||
string[] strSpawnList = utils.getStringArrayScriptVar(self, "strSpawnList");
|
||||
string[] strScripts = utils.getStringArrayScriptVar(self, "strScripts");
|
||||
string strName = utils.getStringScriptVar(self, "strName");
|
||||
//LOG("spawn", "Name is "+strName);
|
||||
float fltMinSpawnTime = utils.getFloatScriptVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = utils.getFloatScriptVar(self, "fltMaxSpawnTime");
|
||||
string strMob = strSpawnList[rand(0, strSpawnList.length-1)];
|
||||
obj_id objNPC = null;
|
||||
|
||||
boolean spawnFailed = false;
|
||||
|
||||
try
|
||||
{
|
||||
objNPC = create.object(strMob, getLocation(self));
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
spawnFailed = true;
|
||||
}
|
||||
|
||||
if (!isIdValid(objNPC) || spawnFailed)
|
||||
{
|
||||
locTest.x = locTest.x+1;
|
||||
obj_id objTest = createObject("object/tangible/gravestone/gravestone01.iff", locTest);
|
||||
setName(objTest, "For "+self.toString()+" Bad NPC Type of type "+strMob+" on planet "+ strPlanet);
|
||||
return;
|
||||
}
|
||||
|
||||
setYaw(objNPC, getYaw(self));
|
||||
//LOG("spawn", "Name is "+strName);
|
||||
if(strName!="")
|
||||
{
|
||||
//LOG("spawn", "Setting Name");
|
||||
setName(objNPC, "");
|
||||
setName(objNPC, strName);
|
||||
}
|
||||
if((strScripts!=null)&&(strScripts.length>0))
|
||||
{
|
||||
for(int intI = 0; intI < strScripts.length; intI++)
|
||||
{
|
||||
if(strScripts[intI]!="")
|
||||
{
|
||||
if(!hasScript(objNPC, strScripts[intI]))
|
||||
{
|
||||
attachScript(objNPC, strScripts[intI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//LOG("spawn", "ATTACHING to "+objNPC);
|
||||
|
||||
attachScript(objNPC, "systems.spawning.mob_spawn_tracker");
|
||||
//LOG("spawn","intReturn is "+intReturn);
|
||||
utils.setScriptVar(objNPC, "objParent", self);
|
||||
utils.setScriptVar(objNPC, "fltRespawnTime", rand(fltMinSpawnTime, fltMaxSpawnTime));
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler respawnMob()
|
||||
{
|
||||
makeMob(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class patrol_point_setup extends script.base_script
|
||||
{
|
||||
public patrol_point_setup()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "setPatrolName", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int setPatrolName(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setName(self, "Orphaned Patrol Point");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
trigger OnInitialize()
|
||||
{
|
||||
messageTo(self, "setPatrolName", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler setPatrolName()
|
||||
{
|
||||
setName(self, "Orphaned Patrol Point");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.utils;
|
||||
|
||||
public class patrol_spawned_tracker extends script.base_script
|
||||
{
|
||||
public patrol_spawned_tracker()
|
||||
{
|
||||
}
|
||||
public static final boolean LOGGING = false;
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "respawnAfterDestroy"))
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "parent");
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnIncapacitated(obj_id self, obj_id objAttacker) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "intCleaningUp"))
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "parent");
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "pathToNextPoint", null, 5, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int pathToNextPoint(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
location[] patrolPoints = utils.getLocationArrayScriptVar(self, "patrolPoints");
|
||||
String patrolType = utils.getStringScriptVar(self, "patrolPathType");
|
||||
int pointNum = utils.getIntScriptVar(self, "startingPoint");
|
||||
if (patrolType.equals("cycle"))
|
||||
{
|
||||
ai_lib.setPatrolPath(self, patrolPoints, pointNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
ai_lib.setPatrolFlipPath(self, patrolPoints, pointNum);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void doLogging(String section, String message) throws InterruptedException
|
||||
{
|
||||
if (LOGGING)
|
||||
{
|
||||
LOG("logging/patrol_spawned_tracker/" + section, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.utils;
|
||||
|
||||
const boolean LOGGING = false;
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if(hasObjVar(self, "respawnAfterDestroy"))
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "parent");
|
||||
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnIncapacitated(obj_id objAttacker)
|
||||
{
|
||||
if(!hasObjVar(self, "intCleaningUp"))
|
||||
{
|
||||
obj_id objParent = utils.getObjIdScriptVar(self, "parent");
|
||||
|
||||
float fltRespawnTime = utils.getFloatScriptVar(self, "fltRespawnTime");
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
messageTo (self, "pathToNextPoint", null, 5, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
messageHandler pathToNextPoint()
|
||||
{
|
||||
location[] patrolPoints = utils.getLocationArrayScriptVar(self, "patrolPoints");
|
||||
string patrolType = utils.getStringScriptVar(self, "patrolPathType");
|
||||
int pointNum = utils.getIntScriptVar(self, "startingPoint");
|
||||
|
||||
if (patrolType.equals("cycle"))
|
||||
ai_lib.setPatrolPath(self, patrolPoints, pointNum);
|
||||
else
|
||||
ai_lib.setPatrolFlipPath(self, patrolPoints, pointNum);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void doLogging(string section, string message)
|
||||
{
|
||||
if (LOGGING)
|
||||
LOG("logging/patrol_spawned_tracker/"+section, message);
|
||||
}
|
||||
@@ -0,0 +1,749 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.skill;
|
||||
import script.library.city;
|
||||
import script.library.regions;
|
||||
import script.library.locations;
|
||||
import script.library.battlefield;
|
||||
import script.library.utils;
|
||||
import script.library.create;
|
||||
import script.library.group;
|
||||
import script.library.gcw;
|
||||
import script.library.ai_lib;
|
||||
import script.library.vehicle;
|
||||
|
||||
public class spawn_base extends script.base_script
|
||||
{
|
||||
public spawn_base()
|
||||
{
|
||||
}
|
||||
public static final int SPAWN_HEARBEAT_SPAWN_EVENT = 5;
|
||||
public static final int SPAWN_PLAYER_DELAY_MIN = 30;
|
||||
public static final int SPAWN_PLAYER_DELAY_MAX = 60;
|
||||
public static final int SPAWN_DISTANCE_MIN = 12;
|
||||
public static final int SPAWN_DISTANCE_MAX = 32;
|
||||
public static final int SPAWN_CHECK_DISTANCE = 64;
|
||||
public static final int SPAWN_CHECK_LIMIT = 15;
|
||||
public static final int SPAWN_TEMPLATE_CHECK_DISTANCE = 128;
|
||||
public static final int SPAWN_CHECK_TEMPLATE_LIMIT = 14;
|
||||
public static final int SPAWN_THEATER_CHECK_DISTANCE = 200;
|
||||
public static final int SPAWN_CHECK_THEATER_LIMIT = 1;
|
||||
public static final int EXTERIOR_SPAWN_CHANCE = 50;
|
||||
public static final int EXTERIOR_MAX_NPC = 10;
|
||||
public static final int INTERIOR_MAX_NPC = 10;
|
||||
public static final int EXTERIOR_MIN_NPC = 4;
|
||||
public static final int INTERIOR_MIN_NPC = 4;
|
||||
public static final int PLAYER_TO_NPC_RATIO = 1;
|
||||
public static final boolean boolFastSpawnEnabled = false;
|
||||
public static final int MAXIMUM_SPAWNING_RUN_TIME_RULES = 200;
|
||||
public static final float CREATURES_TO_PLAYERS_RATIO = 20;
|
||||
public static final String[] INVALID_SPAWNING_AREAS =
|
||||
{
|
||||
"tutorial"
|
||||
};
|
||||
public int[] getValidSpawn(dictionary dctPlayerStats) throws InterruptedException
|
||||
{
|
||||
if (dctPlayerStats == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
boolean boolTheatersAllowed = dctPlayerStats.getBoolean("boolTheatersAllowed");
|
||||
String strRegionName = dctPlayerStats.getString("strRegionName");
|
||||
String strPlanet = dctPlayerStats.getString("strPlanet");
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
obj_id objPlayer = dctPlayerStats.getObjId("objPlayer");
|
||||
if (rgnSpawnRegion == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String strRegion = regions.translateGeoToString(rgnSpawnRegion.getGeographicalType());
|
||||
if (strRegion == null || strRegion.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String strFileName = "";
|
||||
if (strRegion.equals("fictional"))
|
||||
{
|
||||
if ((strRegionName == null || strRegionName.equals("")) || (strPlanet == null || strPlanet.equals("")))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
strFileName = getFictionalRegionFileName(strPlanet, strRegionName);
|
||||
}
|
||||
else if (strRegion.equals("overload"))
|
||||
{
|
||||
if (strRegionName == null || strRegionName.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
strFileName = getOverLoadRegionFileName(strRegionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strPlanet == null || strPlanet.equals(""))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
strFileName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strPlanet + "_" + strRegion + ".iff";
|
||||
}
|
||||
if (strFileName == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String[] strTemplates = dataTableGetStringColumn(strFileName, "strTemplate");
|
||||
int[] intMinDifficulties = dataTableGetIntColumn(strFileName, "intMinDifficulty");
|
||||
int[] intMaxDifficulties = dataTableGetIntColumn(strFileName, "intMaxDifficulty");
|
||||
int[] intGcwFactions = null;
|
||||
int[] intGcwThresholds = null;
|
||||
int[] intGcwScoreTypes = null;
|
||||
String[] strGcwSpecificRegions = null;
|
||||
if (dataTableHasColumn(strFileName, "intGCWFaction"))
|
||||
{
|
||||
intGcwFactions = dataTableGetIntColumn(strFileName, "intGCWFaction");
|
||||
intGcwThresholds = dataTableGetIntColumn(strFileName, "intGCWThreshold");
|
||||
intGcwScoreTypes = dataTableGetIntColumn(strFileName, "intGCWScoreType");
|
||||
strGcwSpecificRegions = dataTableGetStringColumn(strFileName, "strGCWSpecificRegion");
|
||||
}
|
||||
boolean checkGCWStats = true;
|
||||
if (strTemplates == null || strTemplates.length == 0 || intMinDifficulties == null || intMaxDifficulties == null)
|
||||
{
|
||||
LOG("spawning", "Invalid spawn template, or min/max difficulty values are invalid. Filename = " + strFileName);
|
||||
return null;
|
||||
}
|
||||
location currentLoc = getLocation(objPlayer);
|
||||
if (intGcwFactions == null || intGcwThresholds == null || intGcwScoreTypes == null)
|
||||
{
|
||||
checkGCWStats = false;
|
||||
}
|
||||
Vector validTemplateIndices = new Vector();
|
||||
validTemplateIndices.setSize(0);
|
||||
if (validTemplateIndices == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < strTemplates.length; ++i)
|
||||
{
|
||||
int intMinDifficulty = intMinDifficulties[i];
|
||||
int intMaxDifficulty = intMaxDifficulties[i];
|
||||
if (checkGCWStats)
|
||||
{
|
||||
int intGcwFaction = intGcwFactions[i];
|
||||
int intGcwThreshold = intGcwThresholds[i];
|
||||
int intGcwScoreType = intGcwScoreTypes[i];
|
||||
String strSpecificRegion = strGcwSpecificRegions == null || strGcwSpecificRegions.length == 0 ? "" : strGcwSpecificRegions[i];
|
||||
if (!checkGalacticCivilWarStandings(intGcwFaction, intGcwThreshold, intGcwScoreType, strSpecificRegion, currentLoc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (checkDifficulty(intMinDifficulty, intMaxDifficulty, dctPlayerStats))
|
||||
{
|
||||
if (!boolTheatersAllowed && strTemplates[i].indexOf("theater") > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
validTemplateIndices = utils.addElement(validTemplateIndices, i);
|
||||
}
|
||||
}
|
||||
int[] _validTemplateIndices = new int[0];
|
||||
if (validTemplateIndices != null)
|
||||
{
|
||||
_validTemplateIndices = new int[validTemplateIndices.size()];
|
||||
for (int _i = 0; _i < validTemplateIndices.size(); ++_i)
|
||||
{
|
||||
_validTemplateIndices[_i] = ((Integer)validTemplateIndices.get(_i)).intValue();
|
||||
}
|
||||
}
|
||||
return _validTemplateIndices;
|
||||
}
|
||||
public boolean checkDifficulty(int intMinTemplateDifficulty, int intMaxTemplateDifficulty, dictionary dctPlayerStats) throws InterruptedException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public int getPlayerSpawnDiffibculty(obj_id objPlayer) throws InterruptedException
|
||||
{
|
||||
obj_id objGroup = getGroupObject(objPlayer);
|
||||
if (!isIdValid(objGroup))
|
||||
{
|
||||
int intPlayerLevel = getLevel(objPlayer);
|
||||
return intPlayerLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
int intGroupLevel = skill.getGroupLevel(objPlayer);
|
||||
return intGroupLevel;
|
||||
}
|
||||
}
|
||||
public obj_id createTemplate(location locSpawnLocation, dictionary params, obj_id objPlayer) throws InterruptedException
|
||||
{
|
||||
String strRegionName = params.getString("strRegionName");
|
||||
String strPlanet = params.getString("strPlanet");
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
if (rgnSpawnRegion == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int intIndex = params.getInt("intIndex");
|
||||
int intPlayerDifficulty = params.getInt("intPlayerDifficulty");
|
||||
int intNumToSpawn = params.getInt("intNumToSpawn");
|
||||
String strTemplateToSpawn = params.getString("strTemplateToSpawn");
|
||||
String strTemplate = params.getString("strTemplate");
|
||||
int intMinDifficulty = params.getInt("intMinDifficulty");
|
||||
int intMaxDifficulty = params.getInt("intMaxDifficulty");
|
||||
String strLairType = params.getString("strLairType");
|
||||
String strBuildingType = params.getString("strBuildingType");
|
||||
obj_id objCreatedTemplate = createObject(strTemplate, locSpawnLocation);
|
||||
if (isIdValid(objCreatedTemplate))
|
||||
{
|
||||
if (group.isGrouped(objPlayer))
|
||||
{
|
||||
obj_id objGroup = getGroupObject(objPlayer);
|
||||
if (isIdValid(objGroup))
|
||||
{
|
||||
int intGroupSize = getGroupSize(objGroup);
|
||||
setObjVar(objCreatedTemplate, "spawning.intGroupSize", intGroupSize);
|
||||
}
|
||||
}
|
||||
attachScript(objCreatedTemplate, "systems.spawning.spawn_template");
|
||||
if (!strLairType.equals(""))
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "spawning.intDifficultyLevel", intPlayerDifficulty);
|
||||
String strDifficulty = create.getLairDifficulty(intMinDifficulty, intMaxDifficulty, intPlayerDifficulty);
|
||||
setObjVar(objCreatedTemplate, "spawning.lairDifficulty", strDifficulty);
|
||||
setObjVar(objCreatedTemplate, "spawning.lairType", strLairType);
|
||||
setObjVar(objCreatedTemplate, "spawning.buildingTrackingType", strBuildingType);
|
||||
if (!strBuildingType.equals(""))
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "spawning.buildingType", strBuildingType);
|
||||
}
|
||||
obj_id groupObject = getGroupObject(objPlayer);
|
||||
if (isIdValid(groupObject))
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "spawning.groupSize", getPCGroupSize(groupObject));
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "spawning.groupSize", 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strTemplate.indexOf("lair") > 0)
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn);
|
||||
if (!strTemplateToSpawn.equals("") && strTemplateToSpawn != null)
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn);
|
||||
}
|
||||
}
|
||||
if (strTemplate.indexOf("herd") > 0)
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn);
|
||||
if ((!strTemplateToSpawn.equals("")) && (strTemplateToSpawn != null))
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
dictionary dctParams = new dictionary();
|
||||
messageTo(objCreatedTemplate, "handle_Spawn_Setup_Complete", dctParams, 0, false);
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
dctParams.put("strLairType", strLairType);
|
||||
dctParams.put("strBuildingType", strBuildingType);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return objCreatedTemplate;
|
||||
}
|
||||
public dictionary chooseWeightedSpawnTemplate(int[] intDataIndex, String strRegionName, String strPlanetName, region rgnRegion) throws InterruptedException
|
||||
{
|
||||
String strFileName;
|
||||
if (strRegionName.equals("fictional"))
|
||||
{
|
||||
String strRegionFullName = rgnRegion.getName();
|
||||
strFileName = getFictionalRegionFileName(strPlanetName, strRegionFullName);
|
||||
}
|
||||
else if (strRegionName.equals("overload"))
|
||||
{
|
||||
strFileName = getOverLoadRegionFileName(strRegionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
strFileName = "datatables/spawning/spawn_lists/" + strPlanetName + "/" + strPlanetName + "_" + strRegionName + ".iff";
|
||||
}
|
||||
dictionary dctRegion = new dictionary();
|
||||
String[] strTemplates = dataTableGetStringColumn(strFileName, "strTemplate");
|
||||
int[] intSpawnLimits = dataTableGetIntColumn(strFileName, "intSpawnLimit");
|
||||
int[] intMinDifficulties = dataTableGetIntColumn(strFileName, "intMinDifficulty");
|
||||
int[] intMaxDifficulties = dataTableGetIntColumn(strFileName, "intMaxDifficulty");
|
||||
int[] intWeightings = dataTableGetIntColumn(strFileName, "intWeighting");
|
||||
int[] intSizes = dataTableGetIntColumn(strFileName, "intSize");
|
||||
int[] intNumToSpawns = dataTableGetIntColumn(strFileName, "intNumToSpawn");
|
||||
String[] strTemplatesToSpawn = dataTableGetStringColumn(strFileName, "strTemplateToSpawn");
|
||||
String[] strLairTypes = dataTableGetStringColumn(strFileName, "strLairType");
|
||||
String[] strBuildingTypes = dataTableGetStringColumn(strFileName, "strBuildingType");
|
||||
int selectedIndex = 0;
|
||||
if (intDataIndex.length != 1)
|
||||
{
|
||||
int weightingGrandTotal = 0;
|
||||
for (int i = 0; i < intDataIndex.length; ++i)
|
||||
{
|
||||
weightingGrandTotal += intWeightings[intDataIndex[i]];
|
||||
}
|
||||
int randomValue = rand(0, weightingGrandTotal - 1);
|
||||
int previousChance = 0;
|
||||
for (int i = 0; i < intDataIndex.length; ++i)
|
||||
{
|
||||
int currentChance = previousChance + intWeightings[intDataIndex[i]];
|
||||
if (randomValue >= previousChance && randomValue < currentChance)
|
||||
{
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
previousChance = currentChance;
|
||||
}
|
||||
}
|
||||
int intIndex = intDataIndex[selectedIndex];
|
||||
dictionary dctSpawnInformation = new dictionary();
|
||||
dctSpawnInformation.put("intIndex", intIndex);
|
||||
dctSpawnInformation.put("strTemplate", strTemplates[intIndex]);
|
||||
dctSpawnInformation.put("intMinDifficulty", intMinDifficulties[intIndex]);
|
||||
dctSpawnInformation.put("intMaxDifficulty", intMaxDifficulties[intIndex]);
|
||||
dctSpawnInformation.put("intSize", intSizes[intIndex]);
|
||||
dctSpawnInformation.put("intNumToSpawn", intNumToSpawns[intIndex]);
|
||||
dctSpawnInformation.put("strLairType", strLairTypes[intIndex]);
|
||||
dctSpawnInformation.put("strBuildingType", strBuildingTypes[intIndex]);
|
||||
dctSpawnInformation.put("strTemplateToSpawn", strTemplatesToSpawn[intIndex]);
|
||||
return dctSpawnInformation;
|
||||
}
|
||||
public void sendSpawnSpam(obj_id objPlayer, boolean boolLogFailures, boolean boolVerboseMode, String strSpam) throws InterruptedException
|
||||
{
|
||||
if (boolLogFailures)
|
||||
{
|
||||
}
|
||||
if (boolVerboseMode && isIdValid(objPlayer))
|
||||
{
|
||||
deltadictionary dctScriptVars = objPlayer.getScriptVars();
|
||||
int intLastSpamTime = dctScriptVars.getInt("intLastSpamTime");
|
||||
int intCurrentTime = getGameTime();
|
||||
int intDifference = intCurrentTime - intLastSpamTime;
|
||||
if (intDifference > 5)
|
||||
{
|
||||
dctScriptVars.put("intLastSpamTime", intCurrentTime);
|
||||
sendSystemMessageTestingOnly(objPlayer, strSpam);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
public boolean getVerboseMode(obj_id objPlayer) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(objPlayer, "spawning.verboseMode"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean checkTemplatesInRange(obj_id objPlayer, location locHome, boolean boolCheckForTheaters, String strObjectType) throws InterruptedException
|
||||
{
|
||||
boolean boolLogFailures = checkSpawnLogFailures();
|
||||
boolean boolVerboseMode = getVerboseMode(objPlayer);
|
||||
final int SPAWN_TEMPLATE_CHECK_DISTANCE = 128;
|
||||
final int SPAWN_CHECK_TEMPLATE_LIMIT = 140;
|
||||
final int SPAWN_THEATER_CHECK_DISTANCE = 200;
|
||||
final int SPAWN_CHECK_THEATER_LIMIT = 1;
|
||||
return true;
|
||||
}
|
||||
public boolean canSpawn(obj_id objPlayer, location locSpawnLocation, boolean boolCheckForTheaters, String strObjectType) throws InterruptedException
|
||||
{
|
||||
boolean boolLogFailures = checkSpawnLogFailures();
|
||||
boolean boolVerboseMode = getVerboseMode(objPlayer);
|
||||
if (!isSpawningAllowed(locSpawnLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final int intServerSpawnLimit = getServerSpawnLimit();
|
||||
final int intNumCreatures = utils.getNumCreaturesForSpawnLimit();
|
||||
final int intNumPlayers = getNumPlayers();
|
||||
if (intNumPlayers > 0)
|
||||
{
|
||||
if (intServerSpawnLimit > 0)
|
||||
{
|
||||
if (intNumCreatures > intServerSpawnLimit)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (intNumCreatures > 5000)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
location locCurrentLocation = getLocation(objPlayer);
|
||||
if (locCurrentLocation.area == "tutorial")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (city.isInCity(locCurrentLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
region[] rgnCities = getRegionsWithMunicipalAtPoint(locCurrentLocation, regions.MUNI_TRUE);
|
||||
if (rgnCities != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
region rgnBattlefield = battlefield.getBattlefield(locCurrentLocation);
|
||||
if (rgnBattlefield != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rgnCities = getRegionsWithGeographicalAtPoint(locCurrentLocation, regions.GEO_CITY);
|
||||
if (rgnCities != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
obj_id objMasterSpawner = getPlanetByName(locCurrentLocation.area);
|
||||
if (hasObjVar(objMasterSpawner, "boolSpawnerIsOn"))
|
||||
{
|
||||
boolean boolSpawnerIsOn;
|
||||
boolSpawnerIsOn = getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn");
|
||||
if (boolSpawnerIsOn == false)
|
||||
{
|
||||
return boolSpawnerIsOn;
|
||||
}
|
||||
}
|
||||
if (locCurrentLocation.cell != obj_id.NULL_ID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (hasObjVar(objPlayer, "spawning.locSpawnLocation"))
|
||||
{
|
||||
int intSpawnedTemplates = 0;
|
||||
if (hasObjVar(objPlayer, "spawning.intSpawnedTemplates"))
|
||||
{
|
||||
intSpawnedTemplates = getIntObjVar(objPlayer, "spawning.intSpawnedTemplates");
|
||||
}
|
||||
if (intSpawnedTemplates >= SPAWN_CHECK_LIMIT)
|
||||
{
|
||||
location locLastSpawnLocation = getLocationObjVar(objPlayer, "spawning.locSpawnLocation");
|
||||
float fltDistance = utils.getDistance(locLastSpawnLocation, locCurrentLocation);
|
||||
if (fltDistance < SPAWN_CHECK_DISTANCE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (locSpawnLocation != null)
|
||||
{
|
||||
if (city.isInCity(locSpawnLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rgnCities = getRegionsWithMunicipalAtPoint(locSpawnLocation, regions.MUNI_TRUE);
|
||||
if (rgnCities != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rgnCities = getRegionsWithGeographicalAtPoint(locSpawnLocation, regions.GEO_CITY);
|
||||
if (rgnCities != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rgnBattlefield = battlefield.getBattlefield(locSpawnLocation);
|
||||
if (rgnBattlefield != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public region getSpawnRegion(obj_id objPlayer) throws InterruptedException
|
||||
{
|
||||
location locTest = getLocation(objPlayer);
|
||||
String strPlanet = locTest.area;
|
||||
region[] rgnRegionList = getRegionsWithSpawnableAtPoint(locTest, regions.SPAWN_TRUE);
|
||||
if (rgnRegionList == null)
|
||||
{
|
||||
rgnRegionList = getRegionsWithSpawnableAtPoint(locTest, regions.SPAWN_DEFAULT);
|
||||
}
|
||||
if (rgnRegionList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
region rgnSpawnRegion = locations.getSmallestRegion(rgnRegionList);
|
||||
String strTestPlanet = rgnSpawnRegion.getPlanetName();
|
||||
if (!strTestPlanet.equals(strPlanet))
|
||||
{
|
||||
}
|
||||
if (rgnSpawnRegion == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (rand(1, 100) > 50)
|
||||
{
|
||||
region rgnOverloadRegion = null;
|
||||
region[] rgnOverloadRegions = getRegionsWithGeographicalAtPoint(locTest, regions.GEO_OVERLOAD);
|
||||
if ((rgnOverloadRegions != null) && (rgnOverloadRegions.length > 0))
|
||||
{
|
||||
rgnOverloadRegion = rgnOverloadRegions[rand(0, rgnOverloadRegions.length - 1)];
|
||||
}
|
||||
if (rgnOverloadRegion != null)
|
||||
{
|
||||
return rgnOverloadRegion;
|
||||
}
|
||||
}
|
||||
return rgnSpawnRegion;
|
||||
}
|
||||
public void preLoadSpawnDataTables(obj_id objMasterSpawner) throws InterruptedException
|
||||
{
|
||||
return;
|
||||
}
|
||||
public boolean checkSpawnLogFailures() throws InterruptedException
|
||||
{
|
||||
String strConfigSetting = getConfigSetting("GameServer", "fastSpawn");
|
||||
if (strConfigSetting == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (strConfigSetting.equals("true"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isSpawningAllowed(location locTest) throws InterruptedException
|
||||
{
|
||||
if (locTest == null || locTest.area == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < INVALID_SPAWNING_AREAS.length; ++i)
|
||||
{
|
||||
if (locTest.area == INVALID_SPAWNING_AREAS[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public String getFictionalRegionFileName(String strPlanet, String strFullName) throws InterruptedException
|
||||
{
|
||||
string_id strId = utils.unpackString(strFullName);
|
||||
String strRegionName = strId.getAsciiId();
|
||||
String strTableName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strRegionName + ".iff";
|
||||
return strTableName;
|
||||
}
|
||||
public String getOverLoadRegionFileName(String strRegionName) throws InterruptedException
|
||||
{
|
||||
int intIndex = strRegionName.indexOf("-");
|
||||
if (intIndex < 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String strFileName = strRegionName.substring(0, intIndex);
|
||||
String strTableName = "datatables/spawning/spawn_lists/spawn_overloads/" + strFileName + ".iff";
|
||||
return strTableName;
|
||||
}
|
||||
public void doSpawnEvent(dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
obj_id objPlayer = params.getObjId("objPlayer");
|
||||
if (!isIdValid(objPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int intPlayerDifficulty = params.getInt("intDifficulty");
|
||||
String strRegionName = params.getString("strRegionName");
|
||||
String strPlanet = params.getString("strPlanet");
|
||||
if (strRegionName == null || strRegionName.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (strPlanet == null || strPlanet.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
if (rgnSpawnRegion == null)
|
||||
{
|
||||
LOG("spawning", objPlayer + " GETREGION RETURNED NULL FOR " + strRegionName + " and planet " + strPlanet);
|
||||
return;
|
||||
}
|
||||
int[] validSpawnIndices = getValidSpawn(params);
|
||||
if (validSpawnIndices == null || validSpawnIndices.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", "for dictionary " + params.toString() + " objvarids is null");
|
||||
LOG("spawn", "for dictionary " + params.toString() + " objvarids is null");
|
||||
return;
|
||||
}
|
||||
String strRegionType = regions.translateGeoToString(rgnSpawnRegion.getGeographicalType());
|
||||
if (strRegionType == null || strRegionType.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dictionary dctSpawnInformation = new dictionary();
|
||||
dctSpawnInformation = chooseWeightedSpawnTemplate(validSpawnIndices, strRegionType, strPlanet, rgnSpawnRegion);
|
||||
if (dctSpawnInformation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dctSpawnInformation.put("intPlayerDifficulty", intPlayerDifficulty);
|
||||
dctSpawnInformation.put("strRegionName", strRegionName);
|
||||
dctSpawnInformation.put("strPlanet", strPlanet);
|
||||
doSpawnTemplate(objPlayer, dctSpawnInformation);
|
||||
}
|
||||
public void doSpawnTemplate(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String strTemplate = params.getString("strTemplate");
|
||||
int intIndex = params.getInt("intIndex");
|
||||
int intMinDifficulty = params.getInt("intMinDifficulty");
|
||||
int intMaxDifficulty = params.getInt("intMaxDifficulty");
|
||||
int intSize = params.getInt("intSize");
|
||||
int intNumToSpawn = params.getInt("intNumToSpawn");
|
||||
String strLairType = params.getString("strLairType");
|
||||
String strBuildingType = params.getString("strBuildingType");
|
||||
String strTemplateToSpawn = params.getString("strBuildingType");
|
||||
String strRegionName = params.getString("strRegionName");
|
||||
String strPlanet = params.getString("strPlanet");
|
||||
int intPlayerDifficulty = params.getInt("intPlayerDifficulty");
|
||||
dictionary dctParams = new dictionary();
|
||||
location locSpawnLocation = getLocation(self);
|
||||
if (canSpawn(self, locSpawnLocation, true, strLairType))
|
||||
{
|
||||
dctParams.put("intMinDifficulty", intMinDifficulty);
|
||||
dctParams.put("intMaxDifficulty", intMaxDifficulty);
|
||||
dctParams.put("strLairType", strLairType);
|
||||
dctParams.put("strBuildingType", strBuildingType);
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
dctParams.put("intIndex", intIndex);
|
||||
dctParams.put("intPlayerDifficulty", intPlayerDifficulty);
|
||||
dctParams.put("intNumToSpawn", intNumToSpawn);
|
||||
dctParams.put("strTemplateToSpawn", strTemplateToSpawn);
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
float fltSize = getLocationSize((float)intSize);
|
||||
utils.setScriptVar(self, "dctSpawnInfo", dctParams);
|
||||
requestLocation(self, "spawnLocation", locSpawnLocation, 100.0f, fltSize, true, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
public int OnLocationReceived(obj_id self, String strId, obj_id objObject, location locSpawnLocation, float fltRadius) throws InterruptedException
|
||||
{
|
||||
if (strId.equals("spawnLocation"))
|
||||
{
|
||||
if (!isIdValid(objObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
dictionary dctSpawnInfo = utils.getDictionaryScriptVar(self, "dctSpawnInfo");
|
||||
if (dctSpawnInfo == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id objCreatedTemplate = createTemplate(locSpawnLocation, dctSpawnInfo, self);
|
||||
setObjVar(objCreatedTemplate, "objLocationReservation", objObject);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public float getLocationSize(float fltLocation) throws InterruptedException
|
||||
{
|
||||
if (fltLocation < 32f)
|
||||
{
|
||||
return 32f;
|
||||
}
|
||||
else if (fltLocation >= 32 && fltLocation <= 48)
|
||||
{
|
||||
return 48f;
|
||||
}
|
||||
else if (fltLocation >= 48 && fltLocation <= 64)
|
||||
{
|
||||
return 64f;
|
||||
}
|
||||
else if (fltLocation >= 64 && fltLocation <= 80)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
}
|
||||
public boolean isGalaticCivilWarWinner(int faction, int threshold, int imperialScore) throws InterruptedException
|
||||
{
|
||||
if (faction == 1 && threshold < imperialScore)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (faction == 2 && threshold < (100 - imperialScore))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean checkGalacticCivilWarStandings(int gcwFaction, int gcwThreshold, int gcwScoreType, String gcwSpecificRegion, location loc) throws InterruptedException
|
||||
{
|
||||
if (gcwFaction > 0 && gcwThreshold > 0)
|
||||
{
|
||||
if (gcwScoreType == 0)
|
||||
{
|
||||
int ImperialScore = getGcwGroupImperialScorePercentile(toLower(getCurrentSceneName()));
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
}
|
||||
else if (gcwScoreType == 1)
|
||||
{
|
||||
int ImperialScore = 0;
|
||||
region[] allRegions = getRegionsAtPoint(loc);
|
||||
if (allRegions != null && allRegions.length > 0)
|
||||
{
|
||||
for (int iter = 0; iter < allRegions.length; ++iter)
|
||||
{
|
||||
region gcwRegion = allRegions[iter];
|
||||
if ((gcwRegion.getName()).startsWith("gcw"))
|
||||
{
|
||||
ImperialScore = getGcwImperialScorePercentile(toLower(gcwRegion.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
}
|
||||
else if (gcwScoreType == 2)
|
||||
{
|
||||
if (gcwSpecificRegion == null || gcwSpecificRegion.equals(""))
|
||||
{
|
||||
LOG("GCWSpawnError", "Invalid Specific region specified");
|
||||
return false;
|
||||
}
|
||||
int ImperialScore = getGcwImperialScorePercentile(toLower(gcwSpecificRegion));
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,974 +0,0 @@
|
||||
/**
|
||||
* Title: spawn_base.script
|
||||
* Description: This is the base set of functions for the spawn system
|
||||
*/
|
||||
|
||||
include library.skill;
|
||||
include library.city;
|
||||
include library.regions;
|
||||
include library.locations;
|
||||
include library.battlefield;
|
||||
include library.utils;
|
||||
include library.create;
|
||||
include library.group;
|
||||
include library.gcw;
|
||||
include library.ai_lib;
|
||||
include library.vehicle;
|
||||
|
||||
const int SPAWN_HEARBEAT_SPAWN_EVENT = 5;
|
||||
|
||||
const int SPAWN_PLAYER_DELAY_MIN = 30;
|
||||
const int SPAWN_PLAYER_DELAY_MAX = 60; // delay for spawn_player spawn events
|
||||
|
||||
const int SPAWN_DISTANCE_MIN = 12; // for use until we get findvalidlocation
|
||||
const int SPAWN_DISTANCE_MAX = 32;
|
||||
|
||||
const int SPAWN_CHECK_DISTANCE = 64; // you must move X meters before you get more spawns after the limit
|
||||
const int SPAWN_CHECK_LIMIT = 15; // you get X creatures!
|
||||
|
||||
const int SPAWN_TEMPLATE_CHECK_DISTANCE = 128;
|
||||
const int SPAWN_CHECK_TEMPLATE_LIMIT = 14; // 14 templates allowed in an area
|
||||
const int SPAWN_THEATER_CHECK_DISTANCE = 200;
|
||||
|
||||
const int SPAWN_CHECK_THEATER_LIMIT = 1;
|
||||
|
||||
const int EXTERIOR_SPAWN_CHANCE = 50; // chance of spawning something outside of a structure
|
||||
|
||||
// TESTING CONSTANTS
|
||||
const int EXTERIOR_MAX_NPC = 10;
|
||||
const int INTERIOR_MAX_NPC = 10;
|
||||
const int EXTERIOR_MIN_NPC = 4;
|
||||
const int INTERIOR_MIN_NPC = 4;
|
||||
const int PLAYER_TO_NPC_RATIO = 1; // for every 1 player, we decrease our max and min by 1
|
||||
|
||||
// END TESTING CONSTANTS;
|
||||
|
||||
const boolean boolFastSpawnEnabled = false;
|
||||
|
||||
const int MAXIMUM_SPAWNING_RUN_TIME_RULES = 200;
|
||||
const float CREATURES_TO_PLAYERS_RATIO = 20;
|
||||
|
||||
const string[] INVALID_SPAWNING_AREAS = { "tutorial" };
|
||||
|
||||
/**
|
||||
@brief this function takes the obj_id of the player, and the obj_id of the master spawn object. It will eventually take a region object id, which will contain the necessary
|
||||
spawn list information. Using this information, it culls out any templates at their max, as well as checks agains the global spawn count. It then returns a dictionary with two elements
|
||||
The first is an array of template id's, and the second element is the number of elements in the array. This is because we don't have any sort of dynamically resizable arrays
|
||||
Eventually this function will also handle all culling based on player difficulty and factional data.
|
||||
@param obj_id objPlayer
|
||||
@param obj_id objMasterSpawner
|
||||
@return dictionary Contains string array strSpawnTypes, and intSpawnListSize
|
||||
*/
|
||||
int[] getValidSpawn(dictionary dctPlayerStats)
|
||||
{
|
||||
if(dctPlayerStats == null)
|
||||
return null;
|
||||
|
||||
boolean boolTheatersAllowed = dctPlayerStats.getBoolean("boolTheatersAllowed");
|
||||
|
||||
string strRegionName = dctPlayerStats.getString("strRegionName");
|
||||
string strPlanet = dctPlayerStats.getString("strPlanet");
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
obj_id objPlayer = dctPlayerStats.getObjId("objPlayer");
|
||||
|
||||
if(rgnSpawnRegion == null)
|
||||
return null;
|
||||
|
||||
string strRegion = regions.translateGeoToString(rgnSpawnRegion.getGeographicalType());
|
||||
|
||||
if(strRegion == null || strRegion.equals(""))
|
||||
return null;
|
||||
|
||||
string strFileName = "";
|
||||
|
||||
if(strRegion == "fictional")
|
||||
{
|
||||
if((strRegionName == null || strRegionName.equals("")) || (strPlanet == null || strPlanet.equals("")))
|
||||
return null;
|
||||
|
||||
strFileName = getFictionalRegionFileName(strPlanet, strRegionName);
|
||||
}
|
||||
else if(strRegion == "overload")
|
||||
{
|
||||
if(strRegionName == null || strRegionName.equals(""))
|
||||
return null;
|
||||
|
||||
strFileName = getOverLoadRegionFileName(strRegionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strPlanet == null || strPlanet.equals(""))
|
||||
return null;
|
||||
|
||||
strFileName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strPlanet + "_" + strRegion + ".iff";
|
||||
}
|
||||
|
||||
if(strFileName == null)
|
||||
return null;
|
||||
|
||||
|
||||
string[] strTemplates = dataTableGetStringColumn(strFileName, "strTemplate");
|
||||
int[] intMinDifficulties = dataTableGetIntColumn(strFileName, "intMinDifficulty");
|
||||
int[] intMaxDifficulties = dataTableGetIntColumn(strFileName, "intMaxDifficulty");
|
||||
int[] intGcwFactions = null;
|
||||
int[] intGcwThresholds = null;
|
||||
int[] intGcwScoreTypes = null;
|
||||
string[] strGcwSpecificRegions = null;
|
||||
|
||||
if(dataTableHasColumn(strFileName, "intGCWFaction"))
|
||||
{
|
||||
intGcwFactions = dataTableGetIntColumn(strFileName, "intGCWFaction");
|
||||
intGcwThresholds = dataTableGetIntColumn(strFileName, "intGCWThreshold");
|
||||
intGcwScoreTypes = dataTableGetIntColumn(strFileName, "intGCWScoreType");
|
||||
strGcwSpecificRegions = dataTableGetStringColumn(strFileName, "strGCWSpecificRegion");
|
||||
}
|
||||
|
||||
boolean checkGCWStats = true;
|
||||
|
||||
if(strTemplates == null || strTemplates.length == 0 || intMinDifficulties == null || intMaxDifficulties == null)
|
||||
{
|
||||
LOG("spawning", "Invalid spawn template, or min/max difficulty values are invalid. Filename = " + strFileName);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
location currentLoc = getLocation(objPlayer);
|
||||
|
||||
if(intGcwFactions == null || intGcwThresholds == null || intGcwScoreTypes == null)
|
||||
{
|
||||
checkGCWStats = false;
|
||||
}
|
||||
|
||||
resizeable int[] validTemplateIndices = new int[0];
|
||||
|
||||
if(validTemplateIndices == null)
|
||||
return null;
|
||||
|
||||
for(int i = 0; i < strTemplates.length; ++i)
|
||||
{
|
||||
int intMinDifficulty = intMinDifficulties[i];
|
||||
int intMaxDifficulty = intMaxDifficulties[i];
|
||||
|
||||
if(checkGCWStats)
|
||||
{
|
||||
int intGcwFaction = intGcwFactions[i];
|
||||
int intGcwThreshold = intGcwThresholds[i];
|
||||
int intGcwScoreType = intGcwScoreTypes[i];
|
||||
string strSpecificRegion = strGcwSpecificRegions == null || strGcwSpecificRegions.length == 0 ? "" : strGcwSpecificRegions[i];
|
||||
|
||||
if(!checkGalacticCivilWarStandings(intGcwFaction, intGcwThreshold, intGcwScoreType, strSpecificRegion, currentLoc))
|
||||
continue;
|
||||
}
|
||||
|
||||
// we now check the difficulty rating and factional ranks.
|
||||
if(checkDifficulty(intMinDifficulty, intMaxDifficulty, dctPlayerStats))
|
||||
{
|
||||
// Skip any theaters we shouldn't be spawning.
|
||||
if(!boolTheatersAllowed && strTemplates[i].indexOf("theater") > 0)
|
||||
continue;
|
||||
|
||||
validTemplateIndices = utils.addElement(validTemplateIndices, i);
|
||||
}
|
||||
}
|
||||
|
||||
return validTemplateIndices;
|
||||
}
|
||||
|
||||
boolean checkDifficulty(int intMinTemplateDifficulty, int intMaxTemplateDifficulty, dictionary dctPlayerStats)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int getPlayerSpawnDiffibculty(obj_id objPlayer)
|
||||
{
|
||||
obj_id objGroup = getGroupObject(objPlayer);
|
||||
|
||||
if(!isIdValid(objGroup))
|
||||
{
|
||||
int intPlayerLevel = getLevel(objPlayer);
|
||||
|
||||
////LOG("difficulty", "intPlayerLevel is "+intPlayerLevel);
|
||||
return intPlayerLevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
int intGroupLevel = skill.getGroupLevel(objPlayer);
|
||||
|
||||
////LOG("difficulty", "intGroupLevel is "+intGroupLevel);
|
||||
return intGroupLevel;
|
||||
}
|
||||
}
|
||||
|
||||
obj_id createTemplate(location locSpawnLocation, dictionary params, obj_id objPlayer)
|
||||
{
|
||||
|
||||
// we'll spawn in 3 quadrants?
|
||||
|
||||
string strRegionName = params.getString("strRegionName");
|
||||
string strPlanet = params.getString("strPlanet");
|
||||
|
||||
////LOG("spawning", "strRegionName is "+strRegionName);
|
||||
////LOG("spawning", "StrPlanet is "+strPlanet);
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
|
||||
if(rgnSpawnRegion == null)
|
||||
{
|
||||
////LOG("spawning", "NULL REGION FOR PLANET "+strPlanet+" and region anme "+strRegionName);
|
||||
return null;
|
||||
|
||||
}
|
||||
int intIndex = params.getInt("intIndex"); // where in teh datatable is this template.
|
||||
int intPlayerDifficulty = params.getInt("intPlayerDifficulty");
|
||||
int intNumToSpawn = params.getInt("intNumToSpawn"); // for herds/lairs
|
||||
string strTemplateToSpawn = params.getString("strTemplateToSpawn"); // for herds/lairs
|
||||
string strTemplate = params.getString("strTemplate"); // what we create.. technically not a template anymore
|
||||
int intMinDifficulty = params.getInt("intMinDifficulty");
|
||||
int intMaxDifficulty = params.getInt("intMaxDifficulty");
|
||||
string strLairType = params.getString("strLairType");
|
||||
string strBuildingType = params.getString("strBuildingType");
|
||||
|
||||
// we maintain 2 ways to spawn shit
|
||||
|
||||
// one is the old way, usuing the majority of the above data. the new way uses strLairType and buildingTYpe.. lairType isn't blank
|
||||
// then we use thew new spawn functionality.
|
||||
// we still plunk down the templates and crap.
|
||||
|
||||
obj_id objCreatedTemplate = createObject(strTemplate, locSpawnLocation);
|
||||
|
||||
////LOG("spawning", objPlayer+" created templante "+strTemplate+" at location +"+locSpawnLocation);
|
||||
if(isIdValid(objCreatedTemplate))
|
||||
{
|
||||
////LOG("spawning", objPlayer+ " checking if player is grouped");
|
||||
if(group.isGrouped(objPlayer))
|
||||
{
|
||||
////LOG("spawning", objPlayer+ " player is grouped");
|
||||
|
||||
obj_id objGroup = getGroupObject(objPlayer);
|
||||
|
||||
if(isIdValid(objGroup))
|
||||
{
|
||||
////LOG("spawning", objPlayer+ "i got a group obect");
|
||||
int intGroupSize = getGroupSize(objGroup);
|
||||
|
||||
setObjVar(objCreatedTemplate, "spawning.intGroupSize", intGroupSize);
|
||||
}
|
||||
}
|
||||
|
||||
////LOG("spawn_base", objPlayer+ " Created obj_id of "+objCreatedTemplate.toString());
|
||||
|
||||
attachScript(objCreatedTemplate, "systems.spawning.spawn_template");
|
||||
|
||||
////LOG("spawn_base", objPlayer+ " set all my obhjvars on the created object");
|
||||
if(strLairType != "")
|
||||
{ // new functionality
|
||||
////LOG("spawning", objPlayer+" strLairType is "+strLairType);
|
||||
// the template has been made.. so lets go to town on it
|
||||
setObjVar(objCreatedTemplate, "spawning.intDifficultyLevel", intPlayerDifficulty);
|
||||
// we need to calculate the size of the thing
|
||||
|
||||
string strDifficulty = create.getLairDifficulty(intMinDifficulty, intMaxDifficulty, intPlayerDifficulty);
|
||||
|
||||
setObjVar(objCreatedTemplate, "spawning.lairDifficulty", strDifficulty);
|
||||
setObjVar(objCreatedTemplate, "spawning.lairType", strLairType);
|
||||
setObjVar(objCreatedTemplate, "spawning.buildingTrackingType", strBuildingType);
|
||||
if(strBuildingType != "")
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "spawning.buildingType", strBuildingType);
|
||||
}
|
||||
|
||||
////LOG("spawning", objPlayer+" i set all my objvars");
|
||||
|
||||
obj_id groupObject = getGroupObject(objPlayer);
|
||||
|
||||
if(isIdValid(groupObject))
|
||||
setObjVar(objCreatedTemplate, "spawning.groupSize", getPCGroupSize(groupObject));
|
||||
else
|
||||
setObjVar(objCreatedTemplate, "spawning.groupSize", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
////LOG("spawning", objPlayer+" OLD DEPRACATED CODE PATH");
|
||||
|
||||
if(strTemplate.indexOf("lair") > 0)
|
||||
{
|
||||
|
||||
setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn);
|
||||
|
||||
if(strTemplateToSpawn != "" && strTemplateToSpawn != null)
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(strTemplate.indexOf("herd") > 0)
|
||||
{
|
||||
|
||||
setObjVar(objCreatedTemplate, "numToSpawn", intNumToSpawn);
|
||||
|
||||
if((strTemplateToSpawn != "") && (strTemplateToSpawn != null))
|
||||
{
|
||||
setObjVar(objCreatedTemplate, "creatureTemplate", strTemplateToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dictionary dctParams = new dictionary();
|
||||
|
||||
////LOG("spawn_message", objPlayer+" Spawn_Setup_Complete being sent to the created object");
|
||||
messageTo(objCreatedTemplate, "handle_Spawn_Setup_Complete", dctParams, 0, false);
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
dctParams.put("strLairType", strLairType);
|
||||
dctParams.put("strBuildingType", strBuildingType);
|
||||
// we'll need planetary setup soon
|
||||
////LOG("spawn_message", objPlayer+ " template_Created being sent to the master spawner");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return objCreatedTemplate;
|
||||
// template created, and all tracking values incremented.
|
||||
}
|
||||
|
||||
dictionary chooseWeightedSpawnTemplate(int[] intDataIndex, string strRegionName, string strPlanetName, region rgnRegion)
|
||||
{
|
||||
string strFileName;
|
||||
|
||||
if(strRegionName == "fictional")
|
||||
{
|
||||
string strRegionFullName = rgnRegion.getName();
|
||||
|
||||
strFileName = getFictionalRegionFileName(strPlanetName, strRegionFullName);
|
||||
}
|
||||
else if(strRegionName == "overload")
|
||||
{
|
||||
strFileName = getOverLoadRegionFileName(strRegionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
strFileName = "datatables/spawning/spawn_lists/" + strPlanetName + "/" + strPlanetName + "_" + strRegionName + ".iff";
|
||||
}
|
||||
|
||||
dictionary dctRegion = new dictionary();
|
||||
|
||||
string[] strTemplates = dataTableGetStringColumn(strFileName, "strTemplate");
|
||||
int[] intSpawnLimits = dataTableGetIntColumn(strFileName, "intSpawnLimit");
|
||||
int[] intMinDifficulties = dataTableGetIntColumn(strFileName, "intMinDifficulty");
|
||||
int[] intMaxDifficulties = dataTableGetIntColumn(strFileName, "intMaxDifficulty");
|
||||
int[] intWeightings = dataTableGetIntColumn(strFileName, "intWeighting");
|
||||
int[] intSizes = dataTableGetIntColumn(strFileName, "intSize");
|
||||
int[] intNumToSpawns = dataTableGetIntColumn(strFileName, "intNumToSpawn"); // for lairs/herds
|
||||
|
||||
string[] strTemplatesToSpawn = dataTableGetStringColumn(strFileName, "strTemplateToSpawn"); // for herds, and sometimes lairs
|
||||
string[] strLairTypes = dataTableGetStringColumn(strFileName, "strLairType");
|
||||
string[] strBuildingTypes = dataTableGetStringColumn(strFileName, "strBuildingType"); // for new creation routines
|
||||
|
||||
int selectedIndex = 0;
|
||||
|
||||
if(intDataIndex.length != 1) // More than one available option
|
||||
{
|
||||
// Do weighted selection
|
||||
int weightingGrandTotal = 0;
|
||||
for(int i = 0; i < intDataIndex.length; ++i)
|
||||
weightingGrandTotal += intWeightings[intDataIndex[i]];
|
||||
|
||||
int randomValue = rand(0, weightingGrandTotal - 1);
|
||||
int previousChance = 0;
|
||||
for(int i = 0; i < intDataIndex.length; ++i)
|
||||
{
|
||||
int currentChance = previousChance + intWeightings[intDataIndex[i]];
|
||||
if(randomValue >= previousChance && randomValue < currentChance)
|
||||
{
|
||||
selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
|
||||
previousChance = currentChance;
|
||||
}
|
||||
}
|
||||
|
||||
// Grab the selected template info and pass it back.
|
||||
int intIndex = intDataIndex[selectedIndex];
|
||||
|
||||
dictionary dctSpawnInformation = new dictionary();
|
||||
|
||||
dctSpawnInformation.put("intIndex", intIndex);
|
||||
|
||||
dctSpawnInformation.put("strTemplate", strTemplates[intIndex]);
|
||||
dctSpawnInformation.put("intMinDifficulty", intMinDifficulties[intIndex]);
|
||||
dctSpawnInformation.put("intMaxDifficulty", intMaxDifficulties[intIndex]);
|
||||
dctSpawnInformation.put("intSize", intSizes[intIndex]);
|
||||
dctSpawnInformation.put("intNumToSpawn", intNumToSpawns[intIndex]);
|
||||
dctSpawnInformation.put("strLairType", strLairTypes[intIndex]);
|
||||
dctSpawnInformation.put("strBuildingType", strBuildingTypes[intIndex]);
|
||||
dctSpawnInformation.put("strTemplateToSpawn", strTemplatesToSpawn[intIndex]);
|
||||
|
||||
|
||||
return dctSpawnInformation;
|
||||
|
||||
}
|
||||
|
||||
void sendSpawnSpam(obj_id objPlayer, boolean boolLogFailures, boolean boolVerboseMode, string strSpam)
|
||||
{
|
||||
if(boolLogFailures)
|
||||
{
|
||||
////LOG("spawning", strSpam);
|
||||
}
|
||||
|
||||
if(boolVerboseMode && isIdValid(objPlayer))
|
||||
{
|
||||
deltadictionary dctScriptVars = objPlayer.getScriptVars();
|
||||
int intLastSpamTime = dctScriptVars.getInt("intLastSpamTime");
|
||||
int intCurrentTime = getGameTime();
|
||||
int intDifference = intCurrentTime - intLastSpamTime;
|
||||
|
||||
if(intDifference > 5)
|
||||
{
|
||||
dctScriptVars.put("intLastSpamTime", intCurrentTime);
|
||||
sendSystemMessageTestingOnly(objPlayer, strSpam);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
boolean getVerboseMode(obj_id objPlayer)
|
||||
{
|
||||
if(hasObjVar(objPlayer, "spawning.verboseMode"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean checkTemplatesInRange(obj_id objPlayer, location locHome, boolean boolCheckForTheaters, string strObjectType) // boolean for finding a REAL spawn location as oppposed to around the playre
|
||||
{
|
||||
boolean boolLogFailures = checkSpawnLogFailures();
|
||||
boolean boolVerboseMode = getVerboseMode(objPlayer);
|
||||
|
||||
const int SPAWN_TEMPLATE_CHECK_DISTANCE = 128;
|
||||
const int SPAWN_CHECK_TEMPLATE_LIMIT = 140; // 14 templates allowed in an area
|
||||
const int SPAWN_THEATER_CHECK_DISTANCE = 200;
|
||||
|
||||
const int SPAWN_CHECK_THEATER_LIMIT = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean canSpawn(obj_id objPlayer, location locSpawnLocation, boolean boolCheckForTheaters, string strObjectType)
|
||||
{
|
||||
boolean boolLogFailures = checkSpawnLogFailures();
|
||||
boolean boolVerboseMode = getVerboseMode(objPlayer);
|
||||
|
||||
if(!isSpawningAllowed(locSpawnLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
////LOG("spawning", "canspawn check");
|
||||
|
||||
const int intServerSpawnLimit = getServerSpawnLimit();
|
||||
|
||||
const int intNumCreatures = utils.getNumCreaturesForSpawnLimit();
|
||||
const int intNumPlayers = getNumPlayers();
|
||||
|
||||
// we need to maintain a 7 to 1 ratio (we don't seem to be doing what this comment suggests - MB 12/03/2009)
|
||||
|
||||
if(intNumPlayers > 0)
|
||||
{
|
||||
if(intServerSpawnLimit > 0)
|
||||
{
|
||||
if(intNumCreatures > intServerSpawnLimit)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(intNumCreatures > 5000)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
location locCurrentLocation = getLocation(objPlayer);
|
||||
|
||||
if(locCurrentLocation.area == "tutorial")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(city.isInCity(locCurrentLocation))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
region[] rgnCities = getRegionsWithMunicipalAtPoint(locCurrentLocation, regions.MUNI_TRUE);
|
||||
|
||||
// in a city
|
||||
if(rgnCities != null)
|
||||
{
|
||||
// LOG("spawn_base", "In a city returning false from canspawn");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
region rgnBattlefield = battlefield.getBattlefield(locCurrentLocation);
|
||||
|
||||
if(rgnBattlefield != null)
|
||||
{
|
||||
// LOG("spawn_base", "In a battlefield returning false from canspawn");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
rgnCities = getRegionsWithGeographicalAtPoint(locCurrentLocation, regions.GEO_CITY);
|
||||
|
||||
// in a city
|
||||
if(rgnCities != null)
|
||||
{
|
||||
// LOG("spawn_base", "In a city returning false from canspawn");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
obj_id objMasterSpawner = getPlanetByName(locCurrentLocation.area);
|
||||
|
||||
if(hasObjVar(objMasterSpawner, "boolSpawnerIsOn"))
|
||||
{
|
||||
boolean boolSpawnerIsOn;
|
||||
|
||||
boolSpawnerIsOn = getBooleanObjVar(objMasterSpawner, "boolSpawnerIsOn");
|
||||
|
||||
// is it set to on?
|
||||
if(boolSpawnerIsOn == false)
|
||||
{
|
||||
// LOG("spawn_base", "Spawner is off. returning false from canspawn");
|
||||
|
||||
return boolSpawnerIsOn;
|
||||
}
|
||||
}
|
||||
|
||||
if(locCurrentLocation.cell != obj_id.NULL_ID)
|
||||
{
|
||||
// LOG("spawn_base", "In a cell returning false from canspawn");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(hasObjVar(objPlayer, "spawning.locSpawnLocation"))
|
||||
{
|
||||
// check quantitities
|
||||
int intSpawnedTemplates = 0;
|
||||
|
||||
if(hasObjVar(objPlayer, "spawning.intSpawnedTemplates"))
|
||||
{
|
||||
intSpawnedTemplates = getIntObjVar(objPlayer, "spawning.intSpawnedTemplates"); // how many we spawned in the current area
|
||||
////LOG("player_spawner", objPlayer + "'s intSpawnedTemplates is "+intSpawnedTemplates);
|
||||
}
|
||||
|
||||
if(intSpawnedTemplates >= SPAWN_CHECK_LIMIT)
|
||||
{
|
||||
// greater than.. check our location
|
||||
|
||||
location locLastSpawnLocation = getLocationObjVar(objPlayer, "spawning.locSpawnLocation");
|
||||
float fltDistance = utils.getDistance(locLastSpawnLocation, locCurrentLocation);
|
||||
|
||||
if(fltDistance < SPAWN_CHECK_DISTANCE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(locSpawnLocation != null)
|
||||
{
|
||||
if(city.isInCity(locSpawnLocation))
|
||||
{
|
||||
// LOG("spawn_base", "city.isInCity(locSpawnLocation) In a city returning false from canspawn");
|
||||
return false;
|
||||
}
|
||||
|
||||
rgnCities = getRegionsWithMunicipalAtPoint(locSpawnLocation, regions.MUNI_TRUE);
|
||||
|
||||
// in a city
|
||||
if(rgnCities != null)
|
||||
{
|
||||
// LOG("spawn_base", "regions.MUNI_TRUE In a city returning false from canspawn");
|
||||
return false;
|
||||
}
|
||||
|
||||
rgnCities = getRegionsWithGeographicalAtPoint(locSpawnLocation, regions.GEO_CITY);
|
||||
|
||||
// in a city
|
||||
if(rgnCities != null)
|
||||
{
|
||||
// LOG("spawn_base", "regions.GEO_CITY In a city returning false from canspawn");
|
||||
return false;
|
||||
}
|
||||
|
||||
rgnBattlefield = battlefield.getBattlefield(locSpawnLocation);
|
||||
|
||||
if(rgnBattlefield != null)
|
||||
{
|
||||
// LOG("spawn_base", "battlefield.getBattlefield In a city returning false from canspawn");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
region getSpawnRegion(obj_id objPlayer)
|
||||
{
|
||||
location locTest = getLocation(objPlayer);
|
||||
string strPlanet = locTest.area;
|
||||
|
||||
region[] rgnRegionList = getRegionsWithSpawnableAtPoint(locTest, regions.SPAWN_TRUE);
|
||||
//region[] rgnRegionList = getRegionsWithGeographicalAtPoint(getLocation(objPlayer), regions.GEO_FICTIONAL);
|
||||
if(rgnRegionList == null)
|
||||
{
|
||||
rgnRegionList = getRegionsWithSpawnableAtPoint(locTest, regions.SPAWN_DEFAULT);
|
||||
}
|
||||
|
||||
if(rgnRegionList == null)
|
||||
{
|
||||
////LOG("DESIGNER_FATAL","************************************SPAWN ERROR****************************************************");
|
||||
////LOG("DESIGNER_FATAL", "region list is empty. This is a critical spawn system failure!");
|
||||
////LOG("DESIGNER_FATAL", "Location was "+getLocation(objPlayer));
|
||||
////LOG("DESIGNER_FATAL","************************************SPAWN ERROR****************************************************");
|
||||
return null;
|
||||
}
|
||||
|
||||
region rgnSpawnRegion = locations.getSmallestRegion(rgnRegionList);
|
||||
string strTestPlanet = rgnSpawnRegion.getPlanetName();
|
||||
|
||||
if(strTestPlanet != strPlanet)
|
||||
{
|
||||
////LOG("DESIGNER_FATAL", "For location "+locTest+" we got a bad set of regions");
|
||||
////LOG("DESIGNER_FATAL", "Player planet is "+strPlanet+" and region planet is "+strTestPlanet);
|
||||
}
|
||||
|
||||
if(rgnSpawnRegion == null)
|
||||
return null;
|
||||
|
||||
if(rand(1, 100) > 50)
|
||||
{
|
||||
region rgnOverloadRegion = null;
|
||||
|
||||
region[] rgnOverloadRegions = getRegionsWithGeographicalAtPoint(locTest, regions.GEO_OVERLOAD);
|
||||
if((rgnOverloadRegions != null) && (rgnOverloadRegions.length > 0))
|
||||
{
|
||||
rgnOverloadRegion = rgnOverloadRegions[rand(0, rgnOverloadRegions.length - 1)];
|
||||
}
|
||||
|
||||
if(rgnOverloadRegion != null)
|
||||
return rgnOverloadRegion;
|
||||
}
|
||||
|
||||
return rgnSpawnRegion;
|
||||
}
|
||||
|
||||
void preLoadSpawnDataTables(obj_id objMasterSpawner)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean checkSpawnLogFailures()
|
||||
{
|
||||
string strConfigSetting = getConfigSetting("GameServer", "fastSpawn");
|
||||
|
||||
if(strConfigSetting == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strConfigSetting == "true")
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isSpawningAllowed(location locTest)
|
||||
{
|
||||
if(locTest == null || locTest.area == null)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < INVALID_SPAWNING_AREAS.length; ++i)
|
||||
{
|
||||
if(locTest.area == INVALID_SPAWNING_AREAS[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
string getFictionalRegionFileName(string strPlanet, string strFullName)
|
||||
{
|
||||
string_id strId = utils.unpackString(strFullName);
|
||||
string strRegionName = strId.getAsciiId();
|
||||
string strTableName = "datatables/spawning/spawn_lists/" + strPlanet + "/" + strRegionName + ".iff";
|
||||
|
||||
return strTableName;
|
||||
}
|
||||
|
||||
string getOverLoadRegionFileName(string strRegionName)
|
||||
{
|
||||
int intIndex = strRegionName.indexOf("-"); // name is filaname-obj_id
|
||||
|
||||
if(intIndex < 0)
|
||||
{
|
||||
|
||||
////LOG("DESIGNER_FATAL", "region name "+strRegionName+" is an overload region wiht a bad name");
|
||||
return "";
|
||||
|
||||
}
|
||||
string strFileName = strRegionName.substring(0, intIndex);
|
||||
string strTableName = "datatables/spawning/spawn_lists/spawn_overloads/" + strFileName + ".iff";
|
||||
|
||||
////LOG("spawning", "GOT FILENAME OF "+strTableName);
|
||||
return strTableName;
|
||||
}
|
||||
|
||||
void doSpawnEvent(dictionary params)
|
||||
{
|
||||
// this is our baseline spawn event handlet
|
||||
// it should parse through passed params, and pick something from the "spawn list" off of the region object.
|
||||
if(params == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
obj_id objPlayer = params.getObjId("objPlayer");
|
||||
|
||||
if(!isIdValid(objPlayer))
|
||||
return;
|
||||
|
||||
int intPlayerDifficulty = params.getInt("intDifficulty"); // player spawn stats
|
||||
string strRegionName = params.getString("strRegionName");
|
||||
string strPlanet = params.getString("strPlanet");
|
||||
|
||||
if(strRegionName == null || strRegionName.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(strPlanet == null || strPlanet.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
region rgnSpawnRegion = getRegion(strPlanet, strRegionName);
|
||||
|
||||
if(rgnSpawnRegion == null)
|
||||
{
|
||||
LOG("spawning", objPlayer + " GETREGION RETURNED NULL FOR " + strRegionName + " and planet " + strPlanet);
|
||||
return;
|
||||
}
|
||||
|
||||
int[] validSpawnIndices = getValidSpawn(params);
|
||||
|
||||
if(validSpawnIndices == null || validSpawnIndices.length == 0)
|
||||
{
|
||||
LOG("DESIGNER_FATAL", "for dictionary " + params.toString() + " objvarids is null");
|
||||
LOG("spawn", "for dictionary " + params.toString() + " objvarids is null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// we've got a full spawn list. Now we need to figure out the weighting for it.
|
||||
string strRegionType = regions.translateGeoToString(rgnSpawnRegion.getGeographicalType());
|
||||
|
||||
if(strRegionType == null || strRegionType.length() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dictionary dctSpawnInformation = new dictionary();
|
||||
dctSpawnInformation = chooseWeightedSpawnTemplate(validSpawnIndices, strRegionType, strPlanet, rgnSpawnRegion);
|
||||
|
||||
if(dctSpawnInformation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
dctSpawnInformation.put("intPlayerDifficulty", intPlayerDifficulty);
|
||||
dctSpawnInformation.put("strRegionName", strRegionName);
|
||||
dctSpawnInformation.put("strPlanet", strPlanet);
|
||||
|
||||
doSpawnTemplate(objPlayer, dctSpawnInformation);
|
||||
|
||||
}
|
||||
|
||||
void doSpawnTemplate(obj_id self, dictionary params)
|
||||
{
|
||||
|
||||
string strTemplate = params.getString("strTemplate");
|
||||
|
||||
int intIndex = params.getInt("intIndex");
|
||||
int intMinDifficulty = params.getInt("intMinDifficulty");
|
||||
int intMaxDifficulty = params.getInt("intMaxDifficulty");
|
||||
int intSize = params.getInt("intSize");
|
||||
int intNumToSpawn = params.getInt("intNumToSpawn");
|
||||
|
||||
string strLairType = params.getString("strLairType");
|
||||
string strBuildingType = params.getString("strBuildingType");
|
||||
string strTemplateToSpawn = params.getString("strBuildingType");
|
||||
string strRegionName = params.getString("strRegionName");
|
||||
string strPlanet = params.getString("strPlanet");
|
||||
int intPlayerDifficulty = params.getInt("intPlayerDifficulty");
|
||||
|
||||
dictionary dctParams = new dictionary();
|
||||
|
||||
// This is a test location hack
|
||||
// we're going to use a min/max that are much smaller/larger based on the type of template
|
||||
location locSpawnLocation = getLocation(self);
|
||||
|
||||
if(canSpawn(self, locSpawnLocation, true, strLairType))
|
||||
{
|
||||
dctParams.put("intMinDifficulty", intMinDifficulty);
|
||||
dctParams.put("intMaxDifficulty", intMaxDifficulty);
|
||||
dctParams.put("strLairType", strLairType);
|
||||
|
||||
dctParams.put("strBuildingType", strBuildingType);
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
dctParams.put("intIndex", intIndex);
|
||||
dctParams.put("intPlayerDifficulty", intPlayerDifficulty);
|
||||
dctParams.put("intNumToSpawn", intNumToSpawn);
|
||||
dctParams.put("strTemplateToSpawn", strTemplateToSpawn);
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
float fltSize = getLocationSize((float) intSize);
|
||||
|
||||
utils.setScriptVar(self, "dctSpawnInfo", dctParams); // for storage. Next good location uses this.
|
||||
requestLocation(self, "spawnLocation", locSpawnLocation, 100.0f, fltSize, true, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger OnLocationReceived(string strId, obj_id objObject, location locSpawnLocation, float fltRadius)
|
||||
{
|
||||
if(strId.equals("spawnLocation"))
|
||||
{
|
||||
if(!isIdValid(objObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE; // bad object
|
||||
}
|
||||
|
||||
dictionary dctSpawnInfo = utils.getDictionaryScriptVar(self, "dctSpawnInfo");
|
||||
|
||||
if(dctSpawnInfo == null)
|
||||
{
|
||||
////LOG("spawning", "No spawn information");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id objCreatedTemplate = createTemplate(locSpawnLocation, dctSpawnInfo, self);
|
||||
|
||||
setObjVar(objCreatedTemplate, "objLocationReservation", objObject);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
float getLocationSize(float fltLocation)
|
||||
{
|
||||
if(fltLocation < 32f)
|
||||
{
|
||||
return 32f;
|
||||
}
|
||||
else if(fltLocation >= 32 && fltLocation <= 48)
|
||||
{
|
||||
return 48f;
|
||||
}
|
||||
else if(fltLocation >= 48 && fltLocation <= 64)
|
||||
{
|
||||
return 64f;
|
||||
|
||||
}
|
||||
else if(fltLocation >= 64 && fltLocation <= 80)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isGalaticCivilWarWinner(int faction, int threshold, int imperialScore)
|
||||
{
|
||||
if(faction == 1 && threshold < imperialScore) // Imperial
|
||||
return true;
|
||||
else if (faction == 2 && threshold < (100 - imperialScore)) // Rebel
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean checkGalacticCivilWarStandings(int gcwFaction, int gcwThreshold, int gcwScoreType, String gcwSpecificRegion, location loc)
|
||||
{
|
||||
if(gcwFaction > 0 && gcwThreshold > 0)
|
||||
{
|
||||
if(gcwScoreType == 0) // Based on Planet Score.
|
||||
{
|
||||
int ImperialScore = getGcwGroupImperialScorePercentile(toLower(getCurrentSceneName()));
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
}
|
||||
else if (gcwScoreType == 1) // Based on the first GCW region we find at this location.
|
||||
{
|
||||
int ImperialScore = 0;
|
||||
region[] allRegions = getRegionsAtPoint(loc);
|
||||
if(allRegions != null && allRegions.length > 0)
|
||||
{
|
||||
for(int iter = 0; iter < allRegions.length; ++iter)
|
||||
{
|
||||
region gcwRegion = allRegions[iter];
|
||||
if(gcwRegion.getName().startsWith("gcw"))
|
||||
{
|
||||
ImperialScore = getGcwImperialScorePercentile(toLower(gcwRegion.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
}
|
||||
else if (gcwScoreType == 2) // Based on a specific region specified by a designer.
|
||||
{
|
||||
if(gcwSpecificRegion == null || gcwSpecificRegion == "")
|
||||
{
|
||||
LOG("GCWSpawnError", "Invalid Specific region specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
int ImperialScore = getGcwImperialScorePercentile(toLower(gcwSpecificRegion));
|
||||
|
||||
return isGalaticCivilWarWinner(gcwFaction, gcwThreshold, ImperialScore);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.space_create;
|
||||
import script.library.ship_ai;
|
||||
import script.library.locations;
|
||||
import script.library.utils;
|
||||
|
||||
public class spawn_egg_manager extends script.base_script
|
||||
{
|
||||
public spawn_egg_manager()
|
||||
{
|
||||
}
|
||||
public static final string_id SID_MUST_BE_IN_CITY = new string_id("city/city", "must_be_in_city");
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnPreloadComplete(obj_id self) throws InterruptedException
|
||||
{
|
||||
LOG("spawn", "Spawning stuff");
|
||||
setObjVar(self, "intNoDump", 1);
|
||||
location locTest = getLocation(self);
|
||||
String strArea = locTest.area;
|
||||
String strDataTable = "";
|
||||
String strName = locations.getCityName(locTest);
|
||||
if (strName != null)
|
||||
{
|
||||
strDataTable = "datatables/spawning/city_layout/" + locTest.area + "_" + strName + ".iff";
|
||||
}
|
||||
if (strDataTable.equals(""))
|
||||
{
|
||||
LOG("spawn", "Did not open datatable 2 " + strDataTable);
|
||||
sendSystemMessage(self, SID_MUST_BE_IN_CITY);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!dataTableOpen(strDataTable))
|
||||
{
|
||||
LOG("spawn", "Did not open datatable " + strDataTable);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String[] strObject = dataTableGetStringColumn(strDataTable, "strObject");
|
||||
float[] fltJX = dataTableGetFloatColumn(strDataTable, "fltJX");
|
||||
float[] fltJY = dataTableGetFloatColumn(strDataTable, "fltJY");
|
||||
float[] fltJZ = dataTableGetFloatColumn(strDataTable, "fltJZ");
|
||||
float[] fltKX = dataTableGetFloatColumn(strDataTable, "fltKX");
|
||||
float[] fltKY = dataTableGetFloatColumn(strDataTable, "fltKY");
|
||||
float[] fltKZ = dataTableGetFloatColumn(strDataTable, "fltKZ");
|
||||
float[] fltPX = dataTableGetFloatColumn(strDataTable, "fltPX");
|
||||
float[] fltPY = dataTableGetFloatColumn(strDataTable, "fltPY");
|
||||
float[] fltPZ = dataTableGetFloatColumn(strDataTable, "fltPZ");
|
||||
String[] strObjVars = dataTableGetStringColumn(strDataTable, "strObjVars");
|
||||
String[] strScripts = dataTableGetStringColumn(strDataTable, "strScripts");
|
||||
for (int intI = 0; intI < strObject.length; intI++)
|
||||
{
|
||||
vector vctK = new vector(fltKX[intI], fltKY[intI], fltKZ[intI]);
|
||||
vctK = vctK.normalize();
|
||||
vector vctJ = new vector(fltJX[intI], fltJY[intI], fltJZ[intI]);
|
||||
vector vctI = vctJ.cross(vctK);
|
||||
vctJ = vctK.cross(vctI);
|
||||
vector vctP = new vector(fltPX[intI], fltPY[intI], fltPZ[intI]);
|
||||
transform tranCreation = new transform();
|
||||
try
|
||||
{
|
||||
tranCreation = new transform(vctI, vctJ, vctK, vctP);
|
||||
}
|
||||
catch(Throwable err)
|
||||
{
|
||||
vctJ = vector.unitY;
|
||||
vctK = vector.unitZ;
|
||||
vctI = vector.unitX;
|
||||
tranCreation = new transform(vctI, vctJ, vctK, vctP);
|
||||
}
|
||||
tranCreation = tranCreation.reorthonormalize();
|
||||
if (!strObject[intI].equals(""))
|
||||
{
|
||||
obj_id objTest = createObject(strObject[intI], tranCreation, null);
|
||||
if ((!isIdValid(objTest)) || (!objTest.isLoaded()))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strObjVars[intI].equals(""))
|
||||
{
|
||||
if ((isIdValid(objTest)) && (objTest.isLoaded()))
|
||||
{
|
||||
setPackedObjvars(objTest, strObjVars[intI]);
|
||||
}
|
||||
}
|
||||
if (!strScripts[intI].equals(""))
|
||||
{
|
||||
String[] strScriptArray = split(strScripts[intI], ',');
|
||||
for (int intJ = 0; intJ < strScriptArray.length; intJ++)
|
||||
{
|
||||
if ((isIdValid(objTest)) && (objTest.isLoaded()))
|
||||
{
|
||||
String script = strScriptArray[intJ];
|
||||
if (script.indexOf("script.") > -1)
|
||||
{
|
||||
script = script.substring(7);
|
||||
}
|
||||
if (!script.equals(""))
|
||||
{
|
||||
if (!hasScript(objTest, script))
|
||||
{
|
||||
attachScript(objTest, script);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG("spawn", "DONE");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
include library.space_create;
|
||||
include library.ship_ai;
|
||||
include library.locations;
|
||||
include library.utils;
|
||||
// this makes EVERYTHING in the zone!
|
||||
|
||||
|
||||
const string_id SID_MUST_BE_IN_CITY = new string_id("city/city", "must_be_in_city");
|
||||
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
trigger OnAttach()
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnPreloadComplete()
|
||||
{
|
||||
|
||||
LOG("spawn", "Spawning stuff");
|
||||
setObjVar(self, "intNoDump", 1);
|
||||
// we make our things
|
||||
// where are we
|
||||
location locTest = getLocation(self);
|
||||
|
||||
string strArea = locTest.area;
|
||||
string strDataTable = "";
|
||||
string strName = locations.getCityName(locTest);
|
||||
if(strName!=null)
|
||||
{
|
||||
strDataTable = "datatables/spawning/city_layout/"+locTest.area+"_"+strName+".iff";
|
||||
}
|
||||
if(strDataTable=="")
|
||||
{
|
||||
LOG("spawn", "Did not open datatable 2 "+strDataTable);
|
||||
sendSystemMessage(self, SID_MUST_BE_IN_CITY);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!dataTableOpen(strDataTable))
|
||||
{
|
||||
LOG("spawn", "Did not open datatable "+strDataTable);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
string[] strObject = dataTableGetStringColumn(strDataTable, "strObject");
|
||||
float[] fltJX = dataTableGetFloatColumn(strDataTable, "fltJX");
|
||||
float[] fltJY = dataTableGetFloatColumn(strDataTable, "fltJY");
|
||||
float[] fltJZ = dataTableGetFloatColumn(strDataTable, "fltJZ");
|
||||
float[] fltKX = dataTableGetFloatColumn(strDataTable, "fltKX");
|
||||
float[] fltKY = dataTableGetFloatColumn(strDataTable, "fltKY");
|
||||
float[] fltKZ = dataTableGetFloatColumn(strDataTable, "fltKZ");
|
||||
float[] fltPX = dataTableGetFloatColumn(strDataTable, "fltPX");
|
||||
float[] fltPY = dataTableGetFloatColumn(strDataTable, "fltPY");
|
||||
float[] fltPZ = dataTableGetFloatColumn(strDataTable, "fltPZ");
|
||||
string[] strObjVars = dataTableGetStringColumn(strDataTable, "strObjVars");
|
||||
string[] strScripts = dataTableGetStringColumn(strDataTable, "strScripts");
|
||||
|
||||
|
||||
for(int intI = 0; intI<strObject.length; intI++)
|
||||
{
|
||||
//LOG("space", "intI is "+intI+" and objVars are "+strObjVars[intI]);
|
||||
vector vctK = new vector(fltKX[intI], fltKY[intI], fltKZ[intI]);
|
||||
vctK = vctK.normalize();
|
||||
vector vctJ = new vector(fltJX[intI], fltJY[intI], fltJZ[intI]);
|
||||
vector vctI = vctJ.cross(vctK);
|
||||
vctJ = vctK.cross(vctI);
|
||||
vector vctP = new vector(fltPX[intI], fltPY[intI], fltPZ[intI]);
|
||||
|
||||
//LOG("space", "Making "+strObject[intI]);
|
||||
transform tranCreation = new transform();
|
||||
try
|
||||
{
|
||||
tranCreation= new transform(vctI, vctJ, vctK, vctP);
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
//LOG("space", "CATASTROPHE!@!@! BAD VECTOR AT "+intI+" object is "+strObject[intI]+" position is "+vctP);
|
||||
// resetting rotation
|
||||
|
||||
vctJ = vector.unitY;
|
||||
vctK = vector.unitZ;
|
||||
vctI = vector.unitX;
|
||||
tranCreation= new transform(vctI, vctJ, vctK, vctP);
|
||||
}
|
||||
tranCreation = tranCreation.reorthonormalize();
|
||||
if(strObject[intI]!="")
|
||||
{
|
||||
obj_id objTest = createObject(strObject[intI], tranCreation, null);
|
||||
if((!isIdValid(objTest))||(!objTest.isLoaded()))
|
||||
{
|
||||
|
||||
//LOG("DESIGNER_FATAL", "For datatable "+strDataTable+" entry "+intI+" and string "+strObject[intI]+" No object could be created");
|
||||
// do we destroy the object and clean up?
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(strObjVars[intI]!="")
|
||||
{
|
||||
if((isIdValid(objTest))&&(objTest.isLoaded()))
|
||||
{
|
||||
//LOG("space", "adding objVars");
|
||||
setPackedObjvars(objTest, strObjVars[intI]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(strScripts[intI]!="")
|
||||
{
|
||||
string[] strScriptArray = split(strScripts[intI], ',');
|
||||
for(int intJ = 0; intJ<strScriptArray.length; intJ++)
|
||||
{
|
||||
if((isIdValid(objTest))&&(objTest.isLoaded()))
|
||||
{
|
||||
//LOG("space", "adding scripts");
|
||||
string script = strScriptArray[intJ];
|
||||
if ( script.indexOf( "script." ) > -1 )
|
||||
{
|
||||
script = script.substring( 7 );
|
||||
}
|
||||
if(script!="")
|
||||
{
|
||||
if ( !hasScript( objTest, script ) )
|
||||
attachScript( objTest, script );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
LOG("spawn","DONE");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.regions;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
import java.lang.Integer;
|
||||
|
||||
public class spawn_master extends script.systems.spawning.spawn_base
|
||||
{
|
||||
public spawn_master()
|
||||
{
|
||||
}
|
||||
public int OnUniverseComplete(obj_id self) throws InterruptedException
|
||||
{
|
||||
String strPlanet = getNameForPlanetObject(self);
|
||||
if (!hasObjVar(self, "boolSpawnerIsOn"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
if (!hasObjVar(self, "intMaxPlanetSpawnCount"))
|
||||
{
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
int intSpawnLimit = getIntObjVar(self, "intMaxPlanetSpawnCount");
|
||||
if (intSpawnLimit > 10000)
|
||||
{
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
}
|
||||
preLoadSpawnDataTables(self);
|
||||
setObjVar(self, "intCurrentPlanetSpawnCount", 0);
|
||||
setObjVar(self, "intMinSpawnDelay", SPAWN_PLAYER_DELAY_MIN);
|
||||
setObjVar(self, "intMaxSpawnDelay", SPAWN_PLAYER_DELAY_MAX);
|
||||
String strConfigSetting = getConfigSetting("GameServer", "spawningInitialState");
|
||||
if (strConfigSetting != null)
|
||||
{
|
||||
if (strConfigSetting.equals("on"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
else if (strConfigSetting.equals("off"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
String strPlanet = getNameForPlanetObject(self);
|
||||
if (!hasObjVar(self, "boolSpawnerIsOn"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
if (!hasObjVar(self, "intMaxPlanetSpawnCount"))
|
||||
{
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
int intSpawnLimit = getIntObjVar(self, "intMaxPlanetSpawnCount");
|
||||
if (intSpawnLimit > 10000)
|
||||
{
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
}
|
||||
preLoadSpawnDataTables(self);
|
||||
setObjVar(self, "intCurrentPlanetSpawnCount", 0);
|
||||
setObjVar(self, "intMinSpawnDelay", SPAWN_PLAYER_DELAY_MIN);
|
||||
setObjVar(self, "intMaxSpawnDelay", SPAWN_PLAYER_DELAY_MAX);
|
||||
String strConfigSetting = getConfigSetting("GameServer", "spawningInitialState");
|
||||
if (strConfigSetting != null)
|
||||
{
|
||||
if (strConfigSetting.equals("on"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
else if (strConfigSetting.equals("off"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
Title: spawn_master.script
|
||||
Description: This is the master spawn script. It tracks all necessary objects, and receives all spawn events from regions and structures. All pertinent tracking data is handled from this script.
|
||||
*/
|
||||
|
||||
include library.regions;
|
||||
include java.util.Set;
|
||||
include java.util.Iterator;
|
||||
include java.lang.Integer;
|
||||
|
||||
inherits systems.spawning.spawn_base;
|
||||
|
||||
|
||||
/*
|
||||
@brief Bootstrap function for trigger volume creation. This will be moved to OnInitialization once it comes online.
|
||||
|
||||
*/
|
||||
trigger OnUniverseComplete()
|
||||
{
|
||||
|
||||
|
||||
string strPlanet = getNameForPlanetObject(self);
|
||||
////debugServerConsoleMsg(self, "Universe completed for "+strPlanet);
|
||||
|
||||
if(!hasObjVar(self, "boolSpawnerIsOn"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true); // Turn master spawner off
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!hasObjVar(self, "intMaxPlanetSpawnCount"))
|
||||
{
|
||||
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int intSpawnLimit = getIntObjVar(self, "intMaxPlanetSpawnCount");
|
||||
if(intSpawnLimit>10000)
|
||||
{
|
||||
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preLoadSpawnDataTables(self);
|
||||
setObjVar(self, "intCurrentPlanetSpawnCount", 0);
|
||||
setObjVar(self, "intMinSpawnDelay", SPAWN_PLAYER_DELAY_MIN);
|
||||
setObjVar(self, "intMaxSpawnDelay", SPAWN_PLAYER_DELAY_MAX);
|
||||
|
||||
string strConfigSetting = getConfigSetting("GameServer", "spawningInitialState");
|
||||
if(strConfigSetting!=null)
|
||||
{
|
||||
if(strConfigSetting=="on")
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
else if(strConfigSetting=="off")
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@brief This is the initialization routine for the entire spawn system. This creates the master trigger volumes, and initializes all necessary spawn values. The values are derived from spawn_base
|
||||
These will be moved once we get a more concrete idea of spawn listings.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
trigger OnAttach()
|
||||
{
|
||||
|
||||
|
||||
string strPlanet = getNameForPlanetObject(self);
|
||||
////debugServerConsoleMsg(self, "Universe completed for "+strPlanet);
|
||||
|
||||
if(!hasObjVar(self, "boolSpawnerIsOn"))
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true); //turn master spawner off
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!hasObjVar(self, "intMaxPlanetSpawnCount"))
|
||||
{
|
||||
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
int intSpawnLimit = getIntObjVar(self, "intMaxPlanetSpawnCount");
|
||||
if(intSpawnLimit>10000)
|
||||
{
|
||||
|
||||
setObjVar(self, "intMaxPlanetSpawnCount", 10000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
preLoadSpawnDataTables(self);
|
||||
setObjVar(self, "intCurrentPlanetSpawnCount", 0);
|
||||
setObjVar(self, "intMinSpawnDelay", SPAWN_PLAYER_DELAY_MIN);
|
||||
setObjVar(self, "intMaxSpawnDelay", SPAWN_PLAYER_DELAY_MAX);
|
||||
|
||||
string strConfigSetting = getConfigSetting("GameServer", "spawningInitialState");
|
||||
if(strConfigSetting!=null)
|
||||
{
|
||||
if(strConfigSetting=="on")
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", true);
|
||||
}
|
||||
else if(strConfigSetting=="off")
|
||||
{
|
||||
setObjVar(self, "boolSpawnerIsOn", false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class spawn_npc_lair_tracker extends script.base_script
|
||||
{
|
||||
public spawn_npc_lair_tracker()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawn_Cleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setObjVar(self, "intDeleting", 1);
|
||||
debugSpeakMsg(self, "I am walking to an interesting place and despawning. Pay no attention to me!");
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawn_removeNPC(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
debugSpeakMsg(self, "I am walking to an interesting place and despawning. Pay no attention to me!");
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnUnloadedFromMemory(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "intDeleting"))
|
||||
{
|
||||
destroyObject(self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "intDeleting"))
|
||||
{
|
||||
obj_id objMaster = getObjIdObjVar(self, "objMaster");
|
||||
dictionary dctParams = new dictionary();
|
||||
dctParams.put("objNPC", self);
|
||||
messageTo(objMaster, "npc_Delete", dctParams, 0, true);
|
||||
setObjVar(self, "intDeleting", 1);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
trigger OnAttach()
|
||||
{
|
||||
// debugServerConsoleMsg(self, "Attached NPC Tracker script");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// Called when the lair itself is being deleted
|
||||
messageHandler spawn_Cleanup()
|
||||
{
|
||||
|
||||
|
||||
setObjVar(self, "intDeleting", 1);
|
||||
debugSpeakMsg(self, "I am walking to an interesting place and despawning. Pay no attention to me!");
|
||||
destroyObject(self);
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// Called when the lair wants to nicely remove an NPC
|
||||
messageHandler spawn_removeNPC()
|
||||
{
|
||||
|
||||
|
||||
debugSpeakMsg(self, "I am walking to an interesting place and despawning. Pay no attention to me!");
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
trigger OnUnloadedFromMemory()
|
||||
{
|
||||
if(!hasObjVar(self, "intDeleting"))
|
||||
{
|
||||
|
||||
destroyObject(self);
|
||||
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
// debugServerConsoleMsg(self, "ONDESTROY FOR NPC TRIGGER");
|
||||
if(!hasObjVar(self, "intDeleting"))
|
||||
{
|
||||
obj_id objMaster = getObjIdObjVar(self, "objMaster");
|
||||
|
||||
dictionary dctParams = new dictionary();
|
||||
dctParams.put("objNPC", self);
|
||||
messageTo(objMaster, "npc_Delete", dctParams, 0, true);
|
||||
// debugServerConsoleMsg(self, "messaged parent");
|
||||
setObjVar(self, "intDeleting", 1);
|
||||
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class spawn_tangible extends script.base_script
|
||||
{
|
||||
public spawn_tangible()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnPreloadComplete(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "spawn.object"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("bomb_spawner", "OnPreloadComplete");
|
||||
if (hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
obj_id currentObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if (!isValidId(currentObject) || !exists(currentObject))
|
||||
{
|
||||
removeObjVar(self, "spawn.oid");
|
||||
}
|
||||
else
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
String objectName = getStringObjVar(self, "spawn.object");
|
||||
if (objectName == null || objectName.equals(""))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
location spawnerLocation = getLocation(self);
|
||||
if (spawnerLocation == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawnedObject = createObject(objectName, spawnerLocation);
|
||||
if (!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(self, "spawn.oid", spawnedObject);
|
||||
setObjVar(spawnedObject, "spawn.spawner", self);
|
||||
if (hasObjVar(self, "collection.aggro"))
|
||||
{
|
||||
setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self, "collection.aggro"));
|
||||
}
|
||||
LOG("bomb_spawner", "spawnedObject: " + spawnedObject);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleTangibleRespawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "spawn.object"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("bomb_spawner", "handleTangibleRespawn");
|
||||
if (hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
obj_id currentObject = getObjIdObjVar(self, "spawn.oid");
|
||||
LOG("bomb_spawner", "found old oid: " + currentObject);
|
||||
if (!isValidId(currentObject) || !exists(currentObject))
|
||||
{
|
||||
LOG("bomb_spawner", "removing Oid: " + currentObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
}
|
||||
else
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
String objectName = getStringObjVar(self, "spawn.object");
|
||||
if (objectName == null || objectName.equals(""))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
location spawnerLocation = getLocation(self);
|
||||
if (spawnerLocation == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawnedObject = createObject(objectName, spawnerLocation);
|
||||
if (!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(self, "spawn.oid", spawnedObject);
|
||||
setObjVar(spawnedObject, "spawn.spawner", self);
|
||||
if (hasObjVar(self, "collection.aggro"))
|
||||
{
|
||||
setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self, "collection.aggro"));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleTangibleDestroy(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if (!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
destroyObject(spawnedObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnRemovingFromWorld(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if (!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
destroyObject(spawnedObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
requestPreloadCompleteTrigger(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnPreloadComplete()
|
||||
{
|
||||
if(!hasObjVar(self, "spawn.object"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
LOG("bomb_spawner","OnPreloadComplete");
|
||||
// If an obj oid exists, check it. If it is still around, just exit.
|
||||
// If not remove the oid
|
||||
if(hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
obj_id currentObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if(!isValidId(currentObject) || !exists(currentObject))
|
||||
{
|
||||
removeObjVar(self, "spawn.oid");
|
||||
}
|
||||
else
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
string objectName = getStringObjVar(self, "spawn.object");
|
||||
if(objectName == null || objectName.equals(""))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
location spawnerLocation = getLocation(self);
|
||||
if(spawnerLocation == null)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id spawnedObject = createObject(objectName, spawnerLocation);
|
||||
if(!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
setObjVar(self, "spawn.oid", spawnedObject);
|
||||
setObjVar(spawnedObject, "spawn.spawner", self);
|
||||
if(hasObjVar(self, "collection.aggro"))
|
||||
setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self,"collection.aggro"));
|
||||
|
||||
LOG("bomb_spawner","spawnedObject: "+spawnedObject);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleTangibleRespawn()
|
||||
{
|
||||
if(!hasObjVar(self, "spawn.object"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
LOG("bomb_spawner","handleTangibleRespawn");
|
||||
|
||||
// If an obj oid exists, check it. If it is still around, just exit.
|
||||
// If not remove the oid
|
||||
if(hasObjVar(self, "spawn.oid"))
|
||||
{
|
||||
obj_id currentObject = getObjIdObjVar(self, "spawn.oid");
|
||||
LOG("bomb_spawner","found old oid: "+currentObject);
|
||||
|
||||
if(!isValidId(currentObject) || !exists(currentObject))
|
||||
{
|
||||
LOG("bomb_spawner","removing Oid: "+currentObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
}
|
||||
else
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
string objectName = getStringObjVar(self, "spawn.object");
|
||||
if(objectName == null || objectName.equals(""))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
|
||||
location spawnerLocation = getLocation(self);
|
||||
if(spawnerLocation == null)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id spawnedObject = createObject(objectName, spawnerLocation);
|
||||
if(!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
setObjVar(self, "spawn.oid", spawnedObject);
|
||||
setObjVar(spawnedObject, "spawn.spawner", self);
|
||||
if(hasObjVar(self, "collection.aggro"))
|
||||
setObjVar(spawnedObject, "collection.aggro", getBooleanObjVar(self,"collection.aggro"));
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleTangibleDestroy()
|
||||
{
|
||||
if(!hasObjVar(self, "spawn.oid"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if(!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
destroyObject(spawnedObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnRemovingFromWorld()
|
||||
{
|
||||
if(!hasObjVar(self, "spawn.oid"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id spawnedObject = getObjIdObjVar(self, "spawn.oid");
|
||||
if(!isValidId(spawnedObject) || !exists(spawnedObject))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
destroyObject(spawnedObject);
|
||||
removeObjVar(self, "spawn.oid");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class spawn_template extends script.systems.spawning.spawn_base
|
||||
{
|
||||
public spawn_template()
|
||||
{
|
||||
}
|
||||
public int OnAddedToWorld(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int template_Cleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
setObjVar(self, "intCleaningUp", 1);
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnRemovingFromWorld(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "intPersistent"))
|
||||
{
|
||||
destroyObject(self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, "intUnloaded", 1);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
obj_id objMasterSpawner;
|
||||
dictionary dctParams = new dictionary();
|
||||
String strTemplate;
|
||||
String strLairType;
|
||||
String strBuildingType;
|
||||
strTemplate = getTemplateName(self);
|
||||
if (hasObjVar(self, "spawning.lairType"))
|
||||
{
|
||||
strLairType = getStringObjVar(self, "spawning.lairType");
|
||||
if (!strLairType.equals(""))
|
||||
{
|
||||
strTemplate = strTemplate + "." + strLairType;
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "spawning.buildingTrackingType"))
|
||||
{
|
||||
strBuildingType = getStringObjVar(self, "spawning.buildingTrackingType");
|
||||
if (!strBuildingType.equals(""))
|
||||
{
|
||||
strTemplate = strTemplate + "." + strBuildingType;
|
||||
}
|
||||
}
|
||||
String strRegionName = getStringObjVar(self, "strRegionName");
|
||||
String strPlanet = getStringObjVar(self, "strPlanet");
|
||||
debugServerConsoleMsg(self, "Template being cleaned up is " + strTemplate);
|
||||
objMasterSpawner = getObjIdObjVar(self, "objMasterSpawner");
|
||||
if (strTemplate != null)
|
||||
{
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
}
|
||||
if (strRegionName != null)
|
||||
{
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
}
|
||||
if (strPlanet != null)
|
||||
{
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
}
|
||||
debugServerConsoleMsg(self, "Sending Message");
|
||||
messageTo(objMasterSpawner, "template_Destroyed", dctParams, 0, false);
|
||||
debugServerConsoleMsg(self, "Message Sent");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean checkIfInCombat(obj_id objLair) throws InterruptedException
|
||||
{
|
||||
int intNumberOfMobiles = getIntObjVar(objLair, "npc_lair.numberOfMobiles");
|
||||
for (int intI = 0; intI < intNumberOfMobiles; intI++)
|
||||
{
|
||||
obj_id objCreature = getObjIdObjVar(objLair, "npc_lair.mobile." + intNumberOfMobiles);
|
||||
int intState = getState(objCreature, STATE_COMBAT);
|
||||
if (intState > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
/*
|
||||
Title: spawn_template.script
|
||||
Description: This script lives on all spawned templates. It notifies the master spawn object when they are destroyed.
|
||||
|
||||
*/
|
||||
inherits systems.spawning.spawn_base;
|
||||
|
||||
|
||||
|
||||
trigger OnAddedToWorld()
|
||||
{
|
||||
|
||||
/*
|
||||
//LOG("spawn_template", "Adding self to world");
|
||||
|
||||
if((hasObjVar(self, "intUnloaded"))||(hasObjVar(self, "intPersistent")))
|
||||
{
|
||||
|
||||
//LOG("spawn_template", "Reregistering with master spawner");
|
||||
removeObjVar(self, "intUnloaded");
|
||||
|
||||
dictionary dctParams = new dictionary();
|
||||
|
||||
|
||||
string strRegionName = getStringObjVar(self, "strRegionName");
|
||||
string strPlanet = getStringObjVar(self, "strPlanet");
|
||||
|
||||
int intObjVarId = getIntObjVar(self, "intObjVarId");
|
||||
obj_id objMasterSpawner = getObjIdObjVar(self, "objMasterSpawner");
|
||||
string strTemplate = getTemplateName(self);
|
||||
|
||||
string strLairType = "";
|
||||
string strBuildingType = "";
|
||||
|
||||
if(hasObjVar(self, "spawning.lairType"))
|
||||
{
|
||||
|
||||
strLairType = getStringObjVar(self, "spawning.lairType");
|
||||
if(strLairType!="")
|
||||
{
|
||||
strTemplate = strTemplate +"."+strLairType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(hasObjVar(self, "spawning.buildingTrackingType"))
|
||||
{
|
||||
|
||||
strBuildingType = getStringObjVar(self, "spawning.buildingTrackingType");
|
||||
if(strBuildingType!="")
|
||||
{
|
||||
|
||||
strTemplate = strTemplate +"."+strBuildingType;
|
||||
}
|
||||
|
||||
}
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
dctParams.put("intObjVarId", intObjVarId);
|
||||
dctParams.put("objSender", self);
|
||||
dctParams.put("strLairType", strLairType);
|
||||
dctParams.put("strBuildingType", strBuildingType);
|
||||
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
debugServerConsoleMsg(self, "Sending Reload Request Message");
|
||||
|
||||
messageTo(objMasterSpawner, "template_Reload", dctParams, 0, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//LOG("spawn_template", "destroying self on //LOGin");
|
||||
destroyObject(self);
|
||||
|
||||
}
|
||||
*/
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
messageHandler template_Cleanup()
|
||||
{
|
||||
setObjVar(self, "intCleaningUp", 1);
|
||||
destroyObject(self);
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
trigger OnRemovingFromWorld()
|
||||
{
|
||||
if(!hasObjVar(self, "intPersistent"))
|
||||
{
|
||||
|
||||
destroyObject(self);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, "intUnloaded", 1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@brief This trigger handles notification of the master spawner when the template is destroyed. This will be used to cleanup all necessary spawn information and counters
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
obj_id objMasterSpawner;
|
||||
dictionary dctParams = new dictionary();
|
||||
|
||||
string strTemplate;
|
||||
string strLairType;
|
||||
string strBuildingType;
|
||||
strTemplate = getTemplateName(self);
|
||||
|
||||
if(hasObjVar(self, "spawning.lairType"))
|
||||
{
|
||||
|
||||
strLairType = getStringObjVar(self, "spawning.lairType");
|
||||
if(strLairType!="")
|
||||
{
|
||||
strTemplate = strTemplate +"."+strLairType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(hasObjVar(self, "spawning.buildingTrackingType"))
|
||||
{
|
||||
|
||||
strBuildingType = getStringObjVar(self, "spawning.buildingTrackingType");
|
||||
if(strBuildingType!="")
|
||||
{
|
||||
|
||||
strTemplate = strTemplate +"."+strBuildingType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
string strRegionName = getStringObjVar(self, "strRegionName");
|
||||
string strPlanet = getStringObjVar(self, "strPlanet");
|
||||
|
||||
|
||||
debugServerConsoleMsg(self, "Template being cleaned up is "+strTemplate);
|
||||
|
||||
objMasterSpawner = getObjIdObjVar(self, "objMasterSpawner");
|
||||
|
||||
|
||||
// dctParams.put("objMasterSpawner", objMasterSpawner);
|
||||
if (strTemplate != null)
|
||||
dctParams.put("strTemplate", strTemplate);
|
||||
if (strRegionName != null)
|
||||
dctParams.put("strRegionName", strRegionName);
|
||||
if (strPlanet != null)
|
||||
dctParams.put("strPlanet", strPlanet);
|
||||
|
||||
|
||||
|
||||
debugServerConsoleMsg(self, "Sending Message");
|
||||
// Now fire it off to the master object
|
||||
messageTo(objMasterSpawner, "template_Destroyed", dctParams, 0, false);
|
||||
debugServerConsoleMsg(self, "Message Sent");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean checkIfInCombat(obj_id objLair)
|
||||
{
|
||||
int intNumberOfMobiles = getIntObjVar(objLair, "npc_lair.numberOfMobiles");
|
||||
// debugSpeakMsg(objLair, "number of mobiles is "+intNumberOfMobiles);
|
||||
for(int intI =0; intI<intNumberOfMobiles; intI++)
|
||||
{
|
||||
obj_id objCreature = getObjIdObjVar(objLair, "npc_lair.mobile."+intNumberOfMobiles);
|
||||
int intState = getState(objCreature, STATE_COMBAT);
|
||||
// debugSpeakMsg(objLair, "intState for "+objCreature+" is "+intState);
|
||||
if(intState>0)
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
|
||||
public class spawned_tracker extends script.base_script
|
||||
{
|
||||
public spawned_tracker()
|
||||
{
|
||||
}
|
||||
public int OnIncapacitated(obj_id self, obj_id objAttacker) throws InterruptedException
|
||||
{
|
||||
if (!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
|
||||
if (utils.hasScriptVar(self, "deathTracker"))
|
||||
{
|
||||
location loc = utils.getLocationScriptVar(self, "deathTracker");
|
||||
dictionary params = new dictionary();
|
||||
params.put("loc", loc);
|
||||
messageTo(objParent, "spawnDestroyed", params, fltRespawnTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "dontCountDeath"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
if (!isIdValid(objParent))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
|
||||
if (utils.hasScriptVar(self, "deathTracker"))
|
||||
{
|
||||
location loc = utils.getLocationScriptVar(self, "deathTracker");
|
||||
dictionary params = new dictionary();
|
||||
params.put("loc", loc);
|
||||
messageTo(objParent, "spawnDestroyed", params, fltRespawnTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int selfDestruct(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "force_cleanup"))
|
||||
{
|
||||
setPosture(self, POSTURE_INCAPACITATED);
|
||||
}
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnRemovingFromWorld(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
include library.utils;
|
||||
|
||||
trigger OnIncapacitated(obj_id objAttacker)
|
||||
{
|
||||
if(!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
|
||||
//If a mob or object has a deathtracker on it it's to track which location they were spawned at for a random spawner
|
||||
//so that we can open that spot up for spawning again.
|
||||
if (utils.hasScriptVar(self, "deathTracker"))
|
||||
{
|
||||
location loc = utils.getLocationScriptVar(self, "deathTracker");
|
||||
dictionary params = new dictionary ();
|
||||
params.put ("loc", loc );
|
||||
messageTo ( objParent, "spawnDestroyed", params, fltRespawnTime, false );
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
//If we for some reason don't want to count the deaths of a spawned object and not have it call the respawn, attach this obj var to it.
|
||||
if (hasObjVar(self, "dontCountDeath"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if(!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
|
||||
if (!isIdValid(objParent)) //do not check exists(objParent) as this will break when spawning
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
float fltRespawnTime = getFloatObjVar(self, "fltRespawnTime");
|
||||
if (utils.hasScriptVar(self, "deathTracker"))
|
||||
{
|
||||
location loc = utils.getLocationScriptVar(self, "deathTracker");
|
||||
dictionary params = new dictionary ();
|
||||
params.put ("loc", loc );
|
||||
messageTo ( objParent, "spawnDestroyed", params, fltRespawnTime, false );
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
messageTo(objParent, "spawnDestroyed", null, fltRespawnTime, false);
|
||||
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler selfDestruct()
|
||||
{
|
||||
if(hasObjVar(self, "force_cleanup"))
|
||||
{
|
||||
//kill NPC so it can be properly cleaned up
|
||||
setPosture(self, POSTURE_INCAPACITATED);
|
||||
}
|
||||
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnRemovingFromWorld()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
import script.library.space_utils;
|
||||
import script.library.spawning;
|
||||
import script.library.create;
|
||||
|
||||
public class spawner_area extends script.base_script
|
||||
{
|
||||
public spawner_area()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doSpawnEvent(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
float fltRadius = getFloatObjVar(self, "fltRadius");
|
||||
String strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
float fltSize = 8.0f;
|
||||
String strSpawn = strSpawnType;
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff";
|
||||
if (dataTableOpen(strFileName))
|
||||
{
|
||||
String[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
float[] fltSizes = dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
if (strSpawns == null || strSpawns.length == 0)
|
||||
{
|
||||
setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file.");
|
||||
}
|
||||
int intRoll = rand(0, strSpawns.length - 1);
|
||||
if (fltSizes.length == 0)
|
||||
{
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE " + strFileName);
|
||||
}
|
||||
if (fltSizes.length != strSpawns.length)
|
||||
{
|
||||
setName(self, "Missing either spawns or sizes in " + strFileName);
|
||||
}
|
||||
fltSize = fltSizes[intRoll];
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
if (strSpawn == null || strSpawn.length() < 1)
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
location locTest = spawning.getRandomLocationInCircle(getLocation(self), fltRadius);
|
||||
fltSize = getClosestSize(fltSize);
|
||||
if (intGoodLocationSpawner > 0)
|
||||
{
|
||||
requestLocation(self, strSpawn, locTest, rand(100, 200), fltSize, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
createMob(strSpawn, null, locTest, fltRadius, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public float getClosestSize(float fltOriginalSize) throws InterruptedException
|
||||
{
|
||||
if (fltOriginalSize <= 4.0f)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 8.0f)
|
||||
{
|
||||
return 8.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 12.0f)
|
||||
{
|
||||
return 12.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 16.0f)
|
||||
{
|
||||
return 16.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 32.0f)
|
||||
{
|
||||
return 32.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 48.0f)
|
||||
{
|
||||
return 48.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 64.0f)
|
||||
{
|
||||
return 64.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 80.0f)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else if (fltOriginalSize <= 96.0f)
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
return 32f;
|
||||
}
|
||||
public void createMob(String strId, obj_id objLocationObject, location locLocation, float fltRadius, obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
float spawnerYaw = getYaw(self);
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
if (intIndex > -1)
|
||||
{
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
if (!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
setYaw(objTemplate, spawnerYaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if (!isIdValid(objMob))
|
||||
{
|
||||
setName(self, "BAD MOB OF TYPE " + strId);
|
||||
return;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
setYaw(objMob, spawnerYaw);
|
||||
}
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
}
|
||||
public int OnLocationReceived(obj_id self, String strId, obj_id objLocationObject, location locLocation, float fltRadius) throws InterruptedException
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
createMob(strId, objLocationObject, locLocation, fltRadius, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount > -1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean canSpawnByConfigSetting() throws InterruptedException
|
||||
{
|
||||
String disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
if (spawns == null || spawns.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
if (isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
{
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
include library.space_utils;
|
||||
include library.spawning;
|
||||
include library.create;
|
||||
|
||||
|
||||
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
//LOG("spawning", "ONATTACACHA!");
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
//LOG("spawning", "ONINITN");
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
messageHandler doSpawnEvent()
|
||||
{
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
//LOG("spawning", "No count 1");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
float fltRadius = getFloatObjVar(self, "fltRadius");
|
||||
string strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
|
||||
// if strSpawnType is the name of a spawning table, use it.
|
||||
// Otherwise, strSpawnType should be directly from creatures.tab
|
||||
float fltSize = 8.0f;
|
||||
string strSpawn = strSpawnType;
|
||||
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strSpawnType+".iff";
|
||||
if ( dataTableOpen(strFileName) )
|
||||
{
|
||||
string[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
float[] fltSizes= dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
|
||||
if( strSpawns==null || strSpawns.length==0 )
|
||||
{
|
||||
//LOG("spawning", "NO SPAWNS IN FILE "+strFileName);
|
||||
setName(self, "Mangled spawner. strFileName is "+strFileName+" I couldnt find any spawns in that file.");
|
||||
}
|
||||
|
||||
int intRoll = rand(0, strSpawns.length-1);
|
||||
//LOG("spawning", "looking for "+strFileName);
|
||||
|
||||
if(fltSizes.length==0)
|
||||
{
|
||||
//LOG("spawning", "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
}
|
||||
if(fltSizes.length!=strSpawns.length)
|
||||
{
|
||||
//LOG("spawning", "Missing either spawns or sizes in "+strFileName);
|
||||
setName(self, "Missing either spawns or sizes in "+strFileName);
|
||||
}
|
||||
|
||||
fltSize = fltSizes[intRoll];
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
//LOG("spawning", "spawning "+strSpawn);
|
||||
|
||||
if( strSpawn==null || strSpawn.length() < 1 )
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
location locTest = spawning.getRandomLocationInCircle(getLocation(self), fltRadius);
|
||||
fltSize = getClosestSize(fltSize);
|
||||
//LOG("spawning", "fltSize is "+fltSize);
|
||||
if(intGoodLocationSpawner>0)
|
||||
{
|
||||
//LOG("spawning", "getting a good location around "+locTest+" with size "+fltSize);
|
||||
requestLocation(self, strSpawn, locTest, rand(100, 200), fltSize, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
createMob(strSpawn, null, locTest, fltRadius, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
float getClosestSize(float fltOriginalSize)
|
||||
{
|
||||
|
||||
if(fltOriginalSize<=4.0f)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
if(fltOriginalSize<=8.0f)
|
||||
{
|
||||
return 8.0f;
|
||||
}
|
||||
if(fltOriginalSize<=12.0f)
|
||||
{
|
||||
return 12.0f;
|
||||
}
|
||||
if(fltOriginalSize<=16.0f)
|
||||
{
|
||||
return 16.0f;
|
||||
}
|
||||
|
||||
if(fltOriginalSize<=32.0f)
|
||||
{
|
||||
return 32.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 48.0f)
|
||||
{
|
||||
return 48.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 64.0f)
|
||||
{
|
||||
return 64.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 80.0f)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else if(fltOriginalSize <= 96.0f)
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
return 32f;
|
||||
|
||||
}
|
||||
void createMob(string strId, obj_id objLocationObject, location locLocation, float fltRadius, obj_id self)
|
||||
{
|
||||
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float spawnerYaw = getYaw(self);
|
||||
|
||||
// SPAWN@!@!@!@!@!
|
||||
|
||||
// the string is actuallywaht we spawn.
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
if(intIndex>-1)
|
||||
{
|
||||
// template
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
if(!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
|
||||
setYaw(objTemplate, spawnerYaw);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// monster
|
||||
//LOG("spawning", "I am going to make a "+strId);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if(!isIdValid(objMob))
|
||||
{
|
||||
|
||||
setName(self , "BAD MOB OF TYPE "+strId);
|
||||
return;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
|
||||
setYaw(objMob, spawnerYaw);
|
||||
|
||||
}
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
//LOG("spawn", "Failed ot check spawncount");
|
||||
return;
|
||||
}
|
||||
//LOG("spawn", "resending doSpawnEvent");
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
trigger OnLocationReceived(string strId, obj_id objLocationObject, location locLocation, float fltRadius)
|
||||
{
|
||||
|
||||
//LOG("spawning", "strId is "+strId+" and objLocationObject is "+objLocationObject+" and location os "+locLocation);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
//LOG("spawning", "got goodlocation 2");
|
||||
// we make our thang. Otherwise
|
||||
createMob(strId, objLocationObject, locLocation, fltRadius, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
// keep trying
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
messageHandler spawnDestroyed()
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if(intCurrentSpawnCount>-1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
boolean canSpawnByConfigSetting()
|
||||
{
|
||||
string disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
return true;
|
||||
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
//Destroy spawned objects when spawner is destroyed.
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
//LOG("spawning", "Reached debugSpawnList");
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
|
||||
if(spawns == null || spawns.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
for(int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
//LOG("spawning", "Reached loop");
|
||||
if(isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.buff;
|
||||
import script.library.craftinglib;
|
||||
import script.library.create;
|
||||
import script.library.datatable;
|
||||
import script.library.group;
|
||||
import script.library.locations;
|
||||
import script.library.regions;
|
||||
import script.library.skill;
|
||||
import script.library.space_utils;
|
||||
import script.library.spawning;
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
|
||||
public class spawner_find_node extends script.base_script
|
||||
{
|
||||
public spawner_find_node()
|
||||
{
|
||||
}
|
||||
public static final int DEFAULT_SEARCH_RADIUS = 100;
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "findNode", null, 3, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int findNode(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object: " + self + " is looking for its node");
|
||||
if (hasObjVar(self, "node"))
|
||||
{
|
||||
obj_id node = getObjIdObjVar(self, "node");
|
||||
if (isValidId(node) && exists(node))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (!hasObjVar(self, "nodeSearchObjVar") || (getStringObjVar(self, "nodeSearchObjVar")).length() <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object didn't have objvar to search for. Aborting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String nodeSearchObjVar = getStringObjVar(self, "nodeSearchObjVar");
|
||||
if (nodeSearchObjVar == null || nodeSearchObjVar.length() <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object failed validation for node objvar. Aborting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int radius = DEFAULT_SEARCH_RADIUS;
|
||||
if (hasObjVar(self, "nodeSearchRadius") && getIntObjVar(self, "nodeSearchRadius") > 0)
|
||||
{
|
||||
radius = getIntObjVar(self, "nodeSearchRadius");
|
||||
}
|
||||
obj_id[] nodeList = getAllObjectsWithObjVar(getLocation(self), radius, nodeSearchObjVar);
|
||||
if (nodeList == null || nodeList.length <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() the nodeList for the master spawner was null or could not find a node");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
setObjVar(self, "parentNode", nodeList[0]);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// Includes
|
||||
include library.buff;
|
||||
include library.craftinglib;
|
||||
include library.create;
|
||||
include library.datatable;
|
||||
include library.group;
|
||||
include library.locations;
|
||||
include library.regions;
|
||||
include library.skill;
|
||||
include library.space_utils;
|
||||
include library.spawning;
|
||||
include library.sui;
|
||||
include library.utils;
|
||||
|
||||
const int DEFAULT_SEARCH_RADIUS = 100;
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
messageTo(self, "findNode", null, 3, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler findNode()
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object: "+self+" is looking for its node");
|
||||
if(hasObjVar(self, "node"))
|
||||
{
|
||||
obj_id node = getObjIdObjVar(self, "node");
|
||||
if(isValidId(node) && exists(node))
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!hasObjVar(self, "nodeSearchObjVar") || getStringObjVar(self, "nodeSearchObjVar").length() <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object didn't have objvar to search for. Aborting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
string nodeSearchObjVar = getStringObjVar(self, "nodeSearchObjVar");
|
||||
if(nodeSearchObjVar == null || nodeSearchObjVar.length() <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() Master Object failed validation for node objvar. Aborting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int radius = DEFAULT_SEARCH_RADIUS;
|
||||
if(hasObjVar(self, "nodeSearchRadius") && getIntObjVar(self, "nodeSearchRadius") > 0)
|
||||
radius = getIntObjVar(self, "nodeSearchRadius");
|
||||
|
||||
obj_id[] nodeList = getAllObjectsWithObjVar(getLocation(self), radius, nodeSearchObjVar);
|
||||
if(nodeList == null || nodeList.length <= 0)
|
||||
{
|
||||
CustomerServiceLog("outbreak_themepark", "spawner_find_node.findNode() the nodeList for the master spawner was null or could not find a node");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
//for now it just sets the first one found.
|
||||
setObjVar(self, "parentNode", nodeList[0]);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
import script.library.space_utils;
|
||||
import script.library.spawning;
|
||||
import script.library.create;
|
||||
import java.util.Vector;
|
||||
|
||||
public class spawner_patrol extends script.base_script
|
||||
{
|
||||
public spawner_patrol()
|
||||
{
|
||||
}
|
||||
public static final int LOCATION_SEARCH_RADIUS = 1000;
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
start(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int startTheaterFromBuildout(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
start(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void start(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "setLocationArray", null, 5, false);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
dictionary dict = new dictionary();
|
||||
dict.put("spawnNum", 0);
|
||||
messageTo(self, "doInitialSpawn", dict, 10, false);
|
||||
}
|
||||
}
|
||||
public int doInitialSpawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
String strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
String[] strSpawns =
|
||||
{
|
||||
strSpawnType
|
||||
};
|
||||
float[] fltSizes =
|
||||
{
|
||||
8.0f
|
||||
};
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff";
|
||||
if (dataTableOpen(strFileName))
|
||||
{
|
||||
strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
fltSizes = dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
if ((strSpawns == null) || (strSpawns.length == 0))
|
||||
{
|
||||
LOG("spawning", "NO SPAWNS IN FILE " + strFileName);
|
||||
setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file.");
|
||||
}
|
||||
if (fltSizes.length == 0)
|
||||
{
|
||||
LOG("spawning", "BAD NUMBER OF SIZES !@!@@ IN FILE " + strFileName);
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE " + strFileName);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (fltSizes.length != strSpawns.length)
|
||||
{
|
||||
LOG("spawning", "Missing either spawns or sizes in " + strFileName);
|
||||
setName(self, "Missing either spawns or sizes in " + strFileName);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
location[] patrolPoints = utils.getLocationArrayScriptVar(self, "patrolArray");
|
||||
if (patrolPoints == null)
|
||||
{
|
||||
LOG("spawning", "ERROR: patrolArray script var not defined.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int spawnNum = params.getInt("spawnNum");
|
||||
int maxSpawns = getIntObjVar(self, "intSpawnCount");
|
||||
if (maxSpawns >= patrolPoints.length)
|
||||
{
|
||||
LOG("spawning", "ERROR: Attempting to spawn more creatures than patrol points.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
Vector goodSpawns = new Vector();
|
||||
for (int i = 0; i < fltSizes.length; ++i)
|
||||
{
|
||||
goodSpawns.addElement(new Integer(i));
|
||||
}
|
||||
int spawnCount = 0;
|
||||
while (spawnCount < maxSpawns)
|
||||
{
|
||||
int roll = rand(0, goodSpawns.size() - 1);
|
||||
int rowIndex = ((Integer)goodSpawns.get(roll)).intValue();
|
||||
float size = fltSizes[rowIndex];
|
||||
String spawn = strSpawns[rowIndex];
|
||||
size = getClosestSize(size);
|
||||
location locTest = patrolPoints[spawnCount];
|
||||
if (createMob(spawn, null, locTest, 0.0f, self, false, spawnCount))
|
||||
{
|
||||
++spawnCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("spawning", "Unable to create creature " + spawn + ". Check data.");
|
||||
utils.removeElementAt(goodSpawns, roll);
|
||||
if (goodSpawns.size() == 0)
|
||||
{
|
||||
LOG("spawning", "All entries in table " + strFileName + " are bad!!!");
|
||||
setName(self, "No valid spawners!");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doSpawnEvent(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
LOG("spawning", "No count 1");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
float fltRadius = getFloatObjVar(self, "fltRadius");
|
||||
String strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
float fltSize = 8.0f;
|
||||
String strSpawn = strSpawnType;
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff";
|
||||
if (dataTableOpen(strFileName))
|
||||
{
|
||||
String[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
float[] fltSizes = dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
if ((strSpawns == null) || (strSpawns.length == 0))
|
||||
{
|
||||
setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file.");
|
||||
}
|
||||
int intRoll = rand(0, strSpawns.length - 1);
|
||||
if (fltSizes.length == 0)
|
||||
{
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE " + strFileName);
|
||||
}
|
||||
if (fltSizes.length != strSpawns.length)
|
||||
{
|
||||
setName(self, "Missing either spawns or sizes in " + strFileName);
|
||||
}
|
||||
fltSize = fltSizes[intRoll];
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
if (strSpawn == null || strSpawn.length() < 1)
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
location locTest = spawning.getRandomLocationInCircle(getLocation(self), fltRadius);
|
||||
fltSize = getClosestSize(fltSize);
|
||||
if (intGoodLocationSpawner > 0)
|
||||
{
|
||||
requestLocation(self, strSpawn, locTest, rand(100, 200), fltSize, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
createMob(strSpawn, null, locTest, fltRadius, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public float getClosestSize(float fltOriginalSize) throws InterruptedException
|
||||
{
|
||||
if (fltOriginalSize <= 4.0f)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 8.0f)
|
||||
{
|
||||
return 8.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 12.0f)
|
||||
{
|
||||
return 12.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 16.0f)
|
||||
{
|
||||
return 16.0f;
|
||||
}
|
||||
if (fltOriginalSize <= 32.0f)
|
||||
{
|
||||
return 32.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 48.0f)
|
||||
{
|
||||
return 48.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 64.0f)
|
||||
{
|
||||
return 64.0f;
|
||||
}
|
||||
else if (fltOriginalSize <= 80.0f)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else if (fltOriginalSize <= 96.0f)
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
return 32f;
|
||||
}
|
||||
public boolean createMob(String creature, obj_id locationObject, location spawnLoc, float spawnRadius, obj_id self) throws InterruptedException
|
||||
{
|
||||
return createMob(creature, locationObject, spawnLoc, spawnRadius, self, true, 0);
|
||||
}
|
||||
public boolean createMob(String strId, obj_id objLocationObject, location locLocation, float fltRadius, obj_id self, boolean doCallBack, int startingPoint) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
if (intIndex > -1)
|
||||
{
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
if (!isIdValid(objTemplate))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
utils.setScriptVar(objTemplate, "parent", self);
|
||||
utils.setScriptVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(objTemplate, "patrolPoints", utils.getLocationArrayScriptVar(self, "patrolArray"));
|
||||
utils.setScriptVar(objTemplate, "patrolPathType", getStringObjVar(self, "patrolPathType"));
|
||||
utils.setScriptVar(objTemplate, "startingPoint", startingPoint);
|
||||
attachScript(objTemplate, "systems.spawning.patrol_spawned_tracker");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if (!isIdValid(objMob))
|
||||
{
|
||||
setName(self, "BAD MOB OF TYPE " + strId);
|
||||
return false;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
spawning.incrementSpawnCount(self);
|
||||
utils.setScriptVar(objMob, "parent", self);
|
||||
utils.setScriptVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(objMob, "patrolPoints", utils.getLocationArrayScriptVar(self, "patrolArray"));
|
||||
utils.setScriptVar(objMob, "patrolPathType", getStringObjVar(self, "patrolPathType"));
|
||||
utils.setScriptVar(objMob, "startingPoint", startingPoint);
|
||||
attachScript(objMob, "systems.spawning.patrol_spawned_tracker");
|
||||
}
|
||||
if (doCallBack)
|
||||
{
|
||||
if (spawning.checkSpawnCount(self))
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int setLocationArray(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String[] patrolPointString = utils.getStringArrayObjVar(self, "strPatrolPointNames");
|
||||
if (patrolPointString == null || patrolPointString.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
Vector patrolPointLocation = new Vector();
|
||||
patrolPointLocation.setSize(0);
|
||||
obj_id[] objects = getObjectsInRange(self, 700);
|
||||
if (objects == null || objects.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(getSelf()));
|
||||
boolean isInInstance = false;
|
||||
obj_id dungeonController = obj_id.NULL_ID;
|
||||
if (hasObjVar(self, "dungeonController"))
|
||||
{
|
||||
isInInstance = true;
|
||||
}
|
||||
if (isInInstance)
|
||||
{
|
||||
dungeonController = getObjIdObjVar(self, "dungeonController");
|
||||
}
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
for (int i = 0; i < patrolPointString.length; i++)
|
||||
{
|
||||
for (int k = 0; k < objects.length; k++)
|
||||
{
|
||||
if (!isIdValid(objects[k]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (hasObjVar(objects[k], "pointName"))
|
||||
{
|
||||
if ((getStringObjVar(objects[k], "pointName")).equals(patrolPointString[i]))
|
||||
{
|
||||
if (isInInstance)
|
||||
{
|
||||
if (getObjIdObjVar(objects[k], "dungeonController") == dungeonController)
|
||||
{
|
||||
setName(objects[k], getStringObjVar(objects[k], "pointName"));
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setName(objects[k], getStringObjVar(objects[k], "pointName"));
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
location[] patrolArray = new location[0];
|
||||
if (patrolPointLocation != null)
|
||||
{
|
||||
patrolArray = new location[patrolPointLocation.size()];
|
||||
patrolPointLocation.toArray(patrolArray);
|
||||
}
|
||||
utils.setScriptVar(self, "patrolArray", patrolArray);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLocationReceived(obj_id self, String strId, obj_id objLocationObject, location locLocation, float fltRadius) throws InterruptedException
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
createMob(strId, objLocationObject, locLocation, fltRadius, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount > -1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean canSpawnByConfigSetting() throws InterruptedException
|
||||
{
|
||||
String disableSpawners = getConfigSetting("GameServer", "disablePatrolSpawners");
|
||||
if (disableSpawners == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
if (spawns == null || spawns.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
if (isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
{
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,473 +0,0 @@
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
include library.space_utils;
|
||||
include library.spawning;
|
||||
include library.create;
|
||||
include java.util.Vector;
|
||||
|
||||
const int LOCATION_SEARCH_RADIUS = 1000;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
start( self );
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler startTheaterFromBuildout()
|
||||
{
|
||||
start( self );
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void start( obj_id self )
|
||||
{
|
||||
messageTo(self, "setLocationArray", null, 5, false);
|
||||
|
||||
if ( ! hasObjVar(self, "registerWithController") )
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
|
||||
if ( canSpawnByConfigSetting() )
|
||||
{
|
||||
dictionary dict = new dictionary();
|
||||
dict.put("spawnNum", 0);
|
||||
messageTo( self, "doInitialSpawn", dict, 10, false );
|
||||
}
|
||||
}
|
||||
|
||||
messageHandler doInitialSpawn()
|
||||
{
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
string strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
|
||||
// if strSpawnType is the name of a spawning table, use it.
|
||||
// Otherwise, strSpawnType should be directly from creatures.tab
|
||||
string[] strSpawns = {strSpawnType};
|
||||
float[] fltSizes = {8.0f};
|
||||
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strSpawnType+".iff";
|
||||
if ( dataTableOpen(strFileName) )
|
||||
{
|
||||
strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
fltSizes = dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
if((strSpawns==null)||(strSpawns.length==0))
|
||||
{
|
||||
LOG("spawning", "NO SPAWNS IN FILE "+strFileName);
|
||||
setName(self, "Mangled spawner. strFileName is "+strFileName+" I couldnt find any spawns in that file.");
|
||||
}
|
||||
|
||||
if(fltSizes.length==0)
|
||||
{
|
||||
LOG("spawning", "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(fltSizes.length!=strSpawns.length)
|
||||
{
|
||||
LOG("spawning", "Missing either spawns or sizes in "+strFileName);
|
||||
setName(self, "Missing either spawns or sizes in "+strFileName);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
location[] patrolPoints = utils.getLocationArrayScriptVar(self, "patrolArray");
|
||||
if (patrolPoints == null)
|
||||
{
|
||||
LOG("spawning", "ERROR: patrolArray script var not defined.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int spawnNum = params.getInt("spawnNum");
|
||||
|
||||
// get maximum number of spawns
|
||||
int maxSpawns = getIntObjVar(self, "intSpawnCount");
|
||||
if (maxSpawns >= patrolPoints.length)
|
||||
{
|
||||
LOG("spawning", "ERROR: Attempting to spawn more creatures than patrol points.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// create a dynamic list of spawnable entries.
|
||||
// we will remove entries from this list if they are reported
|
||||
// as unspawnable.
|
||||
|
||||
resizeable int[] goodSpawns = new Vector();
|
||||
for(int i = 0; i < fltSizes.length; ++i)
|
||||
{
|
||||
goodSpawns.addElement(new Integer(i));
|
||||
}
|
||||
|
||||
int spawnCount = 0;
|
||||
while(spawnCount < maxSpawns)
|
||||
{
|
||||
int roll = rand(0, goodSpawns.size() - 1);
|
||||
int rowIndex = goodSpawns[roll];
|
||||
|
||||
float size = fltSizes[rowIndex];
|
||||
string spawn = strSpawns[rowIndex];
|
||||
|
||||
size = getClosestSize(size);
|
||||
location locTest = patrolPoints[spawnCount];
|
||||
//LOG("spawning", "fltSize is " + size);
|
||||
if (createMob(spawn, null, locTest, 0.0f, self, false, spawnCount))
|
||||
{
|
||||
++spawnCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("spawning", "Unable to create creature " + spawn + ". Check data.");
|
||||
|
||||
// this row is bad, so remove it from our list of potential spawns.
|
||||
utils.removeElementAt(goodSpawns, roll);
|
||||
if (goodSpawns.size() == 0)
|
||||
{
|
||||
// we've removed all of our entries. The entire table is bad,
|
||||
// so warn and exit.
|
||||
LOG("spawning", "All entries in table " + strFileName + " are bad!!!");
|
||||
setName(self, "No valid spawners!");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler doSpawnEvent()
|
||||
{
|
||||
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
LOG("spawning", "No count 1");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
int intGoodLocationSpawner = getIntObjVar(self, "intGoodLocationSpawner");
|
||||
float fltRadius = getFloatObjVar(self, "fltRadius");
|
||||
string strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
|
||||
// if strSpawnType is the name of a spawning table, use it.
|
||||
// Otherwise, strSpawnType should be directly from creatures.tab
|
||||
float fltSize = 8.0f;
|
||||
string strSpawn = strSpawnType;
|
||||
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strSpawnType+".iff";
|
||||
if ( dataTableOpen(strFileName) )
|
||||
{
|
||||
string[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
float[] fltSizes= dataTableGetFloatColumn(strFileName, "fltSize");
|
||||
if((strSpawns==null)||(strSpawns.length==0))
|
||||
{
|
||||
//LOG("spawning", "NO SPAWNS IN FILE "+strFileName);
|
||||
setName(self, "Mangled spawner. strFileName is "+strFileName+" I couldnt find any spawns in that file.");
|
||||
}
|
||||
int intRoll = rand(0, strSpawns.length-1);
|
||||
//LOG("spawning", "looking for "+strFileName);
|
||||
|
||||
if(fltSizes.length==0)
|
||||
{
|
||||
//LOG("spawning", "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
setName(self, "BAD NUMBER OF SIZES !@!@@ IN FILE "+strFileName);
|
||||
}
|
||||
if(fltSizes.length!=strSpawns.length)
|
||||
{
|
||||
//LOG("spawning", "Missing either spawns or sizes in "+strFileName);
|
||||
setName(self, "Missing either spawns or sizes in "+strFileName);
|
||||
}
|
||||
fltSize = fltSizes[intRoll];
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
//LOG("spawning", "spawning "+strSpawn);
|
||||
|
||||
if( strSpawn==null || strSpawn.length() < 1 )
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
location locTest =spawning.getRandomLocationInCircle(getLocation(self), fltRadius);
|
||||
fltSize = getClosestSize(fltSize);
|
||||
//LOG("spawning", "fltSize is "+fltSize);
|
||||
if(intGoodLocationSpawner>0)
|
||||
{
|
||||
//LOG("spawning", "getting a good location around "+locTest+" with size "+fltSize);
|
||||
requestLocation(self, strSpawn, locTest, rand(100, 200), fltSize, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
createMob(strSpawn, null, locTest, fltRadius, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
float getClosestSize(float fltOriginalSize)
|
||||
{
|
||||
|
||||
if(fltOriginalSize<=4.0f)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
if(fltOriginalSize<=8.0f)
|
||||
{
|
||||
return 8.0f;
|
||||
}
|
||||
if(fltOriginalSize<=12.0f)
|
||||
{
|
||||
return 12.0f;
|
||||
}
|
||||
if(fltOriginalSize<=16.0f)
|
||||
{
|
||||
return 16.0f;
|
||||
}
|
||||
|
||||
if(fltOriginalSize<=32.0f)
|
||||
{
|
||||
return 32.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 48.0f)
|
||||
{
|
||||
return 48.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 64.0f)
|
||||
{
|
||||
return 64.0f;
|
||||
}
|
||||
else if(fltOriginalSize <= 80.0f)
|
||||
{
|
||||
return 80f;
|
||||
}
|
||||
else if(fltOriginalSize <= 96.0f)
|
||||
{
|
||||
return 96f;
|
||||
}
|
||||
return 32f;
|
||||
|
||||
}
|
||||
|
||||
boolean createMob(string creature, obj_id locationObject, location spawnLoc, float spawnRadius, obj_id self)
|
||||
{
|
||||
return createMob(creature, locationObject, spawnLoc, spawnRadius, self, true, 0);
|
||||
}
|
||||
|
||||
boolean createMob(string strId, obj_id objLocationObject, location locLocation, float fltRadius, obj_id self, boolean doCallBack, int startingPoint)
|
||||
{
|
||||
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// SPAWN@!@!@!@!@!
|
||||
|
||||
// the string is actuallywaht we spawn.
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
if(intIndex>-1)
|
||||
{
|
||||
// template
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
if(!isIdValid(objTemplate))
|
||||
{
|
||||
//LOG("spawning", "Can't create mob of type " + strId);
|
||||
return false;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
utils.setScriptVar(objTemplate, "parent", self);
|
||||
utils.setScriptVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(objTemplate, "patrolPoints", utils.getLocationArrayScriptVar(self, "patrolArray"));
|
||||
utils.setScriptVar(objTemplate, "patrolPathType", getStringObjVar(self, "patrolPathType"));
|
||||
utils.setScriptVar(objTemplate, "startingPoint", startingPoint);
|
||||
attachScript(objTemplate, "systems.spawning.patrol_spawned_tracker");
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// monster
|
||||
//LOG("spawning", "I am going to make a "+strId);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if(!isIdValid(objMob))
|
||||
{
|
||||
|
||||
setName(self , "BAD MOB OF TYPE "+strId);
|
||||
return false;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
utils.setScriptVar(objMob, "parent", self);
|
||||
utils.setScriptVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(objMob, "patrolPoints", utils.getLocationArrayScriptVar(self, "patrolArray"));
|
||||
utils.setScriptVar(objMob, "patrolPathType", getStringObjVar(self, "patrolPathType"));
|
||||
utils.setScriptVar(objMob, "startingPoint", startingPoint);
|
||||
attachScript(objMob, "systems.spawning.patrol_spawned_tracker");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//LOG("spawn", "resending doSpawnEvent");
|
||||
if (doCallBack)
|
||||
{
|
||||
if( spawning.checkSpawnCount(self) )
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
messageHandler setLocationArray()
|
||||
{
|
||||
string[] patrolPointString = utils.getStringArrayObjVar(self, "strPatrolPointNames");
|
||||
|
||||
if (patrolPointString == null || patrolPointString.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
resizeable location[] patrolPointLocation = new location[0];
|
||||
obj_id[] objects = getObjectsInRange(self, 700);
|
||||
|
||||
if (objects == null || objects.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(getSelf())); // The spawner is patrol point #1
|
||||
boolean isInInstance = false;
|
||||
obj_id dungeonController = obj_id.NULL_ID;
|
||||
|
||||
if (hasObjVar(self, "dungeonController"))
|
||||
isInInstance = true;
|
||||
|
||||
if (isInInstance)
|
||||
dungeonController = getObjIdObjVar(self, "dungeonController");
|
||||
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
for (int i=0;i<patrolPointString.length;i++)
|
||||
{
|
||||
for (int k=0;k<objects.length;k++)
|
||||
{
|
||||
if(!isIdValid(objects[k]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasObjVar(objects[k], "pointName"))
|
||||
{
|
||||
if (getStringObjVar(objects[k], "pointName").equals(patrolPointString[i]))
|
||||
{
|
||||
if (isInInstance)
|
||||
{
|
||||
if (getObjIdObjVar(objects[k], "dungeonController") == dungeonController)
|
||||
{
|
||||
setName(objects[k], getStringObjVar(objects[k], "pointName"));
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setName(objects[k], getStringObjVar(objects[k], "pointName"));
|
||||
patrolPointLocation = utils.addElement(patrolPointLocation, getLocation(objects[k]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
location[] patrolArray = patrolPointLocation;
|
||||
utils.setScriptVar(self, "patrolArray", patrolArray);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnLocationReceived(string strId, obj_id objLocationObject, location locLocation, float fltRadius)
|
||||
{
|
||||
|
||||
//LOG("spawning", "strId is "+strId+" and objLocationObject is "+objLocationObject+" and location os "+locLocation);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
//LOG("spawning", "got goodlocation 2");
|
||||
// we make our thang. Otherwise
|
||||
createMob(strId, objLocationObject, locLocation, fltRadius, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
// keep trying
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
messageHandler spawnDestroyed()
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if(intCurrentSpawnCount>-1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
boolean canSpawnByConfigSetting()
|
||||
{
|
||||
string disableSpawners = getConfigSetting("GameServer", "disablePatrolSpawners");
|
||||
if (disableSpawners == null)
|
||||
return true;
|
||||
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
//Destroy spawned objects when spawner is destroyed.
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
//LOG("spawning", "Reached debugSpawnList");
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
|
||||
if(spawns == null || spawns.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
for(int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
//LOG("spawning", "Reached loop");
|
||||
if(isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
import script.library.space_utils;
|
||||
import script.library.spawning;
|
||||
import script.library.create;
|
||||
|
||||
public class spawner_random extends script.base_script
|
||||
{
|
||||
public spawner_random()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: " + self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: " + self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CAN SPAWN for: " + self);
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CANNOT SPAWN for: " + self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnHearSpeech(obj_id self, obj_id speaker, String text) throws InterruptedException
|
||||
{
|
||||
if (!isGod(speaker))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id target = getIntendedTarget(speaker);
|
||||
if (target != self)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (text.equals("reset"))
|
||||
{
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
debugSpeakMsg(speaker, "reset");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doSpawnEvent(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Initialized for: " + self);
|
||||
String datatable = getStringObjVar(self, "strSpawnTable");
|
||||
if (datatable == null || datatable.equals(""))
|
||||
{
|
||||
debugSpeakMsg(self, "I need a spawn table under objvar strSpawnTable");
|
||||
LOG("spawning", "No spawn datatable set, necessary for random spawners");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numberOfLocations = dataTableGetNumRows(datatable);
|
||||
if (numberOfLocations <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawn table has no rows. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are " + numberOfLocations + " number of rows for the spawner to select from. Random Spawner: " + self);
|
||||
int numberOfSpawns = getIntObjVar(self, "intSpawnCount");
|
||||
if (numberOfSpawns <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawner has no spawn count. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are " + numberOfSpawns + " spawns needed for this spawner to work. Random Spawner: " + self);
|
||||
if (numberOfSpawns >= numberOfLocations)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are more or equal the number of spawns to number of locations. Need to be less. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: spawning.checkSpawnCount(self) reports that it cannot spawn any more. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: We have not reached max spawns for event per spawning.checkSpawnCount library. Spawner: " + self);
|
||||
String strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
if (strSpawnType == null || strSpawnType.equals(""))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent:The strSpawns objvar was invalid. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: " + strSpawnType);
|
||||
String strSpawn = strSpawnType;
|
||||
if (strSpawnType.indexOf(".iff") < 0)
|
||||
{
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff";
|
||||
if (dataTableOpen(strFileName))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns datatable found and opened");
|
||||
String[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if (strSpawns == null || strSpawns.length == 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: no strItem or corrupt data found for strSpawns datatable.");
|
||||
setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file.");
|
||||
}
|
||||
int intRoll = rand(0, strSpawns.length - 1);
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
}
|
||||
if (strSpawn == null || strSpawn.length() < 1)
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int x = rand(0, numberOfLocations - 1);
|
||||
float xCoord = dataTableGetFloat(datatable, x, "loc_x");
|
||||
float yCoord = dataTableGetFloat(datatable, x, "loc_y");
|
||||
float zCoord = dataTableGetFloat(datatable, x, "loc_z");
|
||||
float yaw = dataTableGetFloat(datatable, x, "yaw");
|
||||
location myself = getLocation(self);
|
||||
String planet = myself.area;
|
||||
location locLocation = new location(xCoord, yCoord, zCoord, planet);
|
||||
if (!utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation))
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
{
|
||||
utils.removeScriptVar(self, "locationFindTries");
|
||||
}
|
||||
createMob(strSpawn, null, locLocation, yaw, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
{
|
||||
int nrTries = utils.getIntScriptVar(self, "locationFindTries");
|
||||
utils.setScriptVar(self, "locationFindTries", nrTries + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "locationFindTries", 1);
|
||||
}
|
||||
if (utils.getIntScriptVar(self, "locationFindTries") < 501)
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 3, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("spawning", "Random spawner: " + self + " named: " + getStringObjVar(self, "strName") + " has tried to find a good location for a spawn 500 times. Now giving up");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void createMob(String strId, obj_id objLocationObject, location locLocation, float yaw, obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
float fltLifeTime = 0;
|
||||
if (hasObjVar(self, "fltMinLifeTime"))
|
||||
{
|
||||
if (hasObjVar(self, "fltMaxLifeTime"))
|
||||
{
|
||||
float fltMinLifeTime = getFloatObjVar(self, "fltMinLifeTime");
|
||||
float fltMaxLifeTime = getFloatObjVar(self, "fltMaxLifeTime");
|
||||
if (fltMinLifeTime < fltMaxLifeTime)
|
||||
{
|
||||
fltLifeTime = rand(fltMinLifeTime, fltMaxLifeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intIndex > -1)
|
||||
{
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
if (!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objTemplate);
|
||||
utils.setScriptVar(objTemplate, "deathTracker", locLocation);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
{
|
||||
messageTo(objTemplate, "selfDestruct", null, fltLifeTime, false);
|
||||
}
|
||||
setYaw(objTemplate, yaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if (!isIdValid(objMob))
|
||||
{
|
||||
setName(self, "BAD MOB OF TYPE " + strId);
|
||||
return;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objMob);
|
||||
utils.setScriptVar(objMob, "deathTracker", locLocation);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
{
|
||||
messageTo(objMob, "selfDestruct", null, fltLifeTime, false);
|
||||
}
|
||||
setYaw(objMob, yaw);
|
||||
}
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
}
|
||||
public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount > -1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
location loc = params.getLocation("loc");
|
||||
if (utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + loc))
|
||||
{
|
||||
utils.removeScriptVar(self, "spawnedObjectList.spawnLoc" + loc);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean canSpawnByConfigSetting() throws InterruptedException
|
||||
{
|
||||
String disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
if (spawns == null || spawns.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
if (isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
{
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,340 +0,0 @@
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
include library.space_utils;
|
||||
include library.spawning;
|
||||
include library.create;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: "+self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: "+self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CAN SPAWN for: "+self);
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CANNOT SPAWN for: "+self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
// Testing stuff
|
||||
trigger OnHearSpeech(obj_id speaker, string text)
|
||||
{
|
||||
if (!isGod(speaker))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id target = getIntendedTarget(speaker);
|
||||
|
||||
if (target != self)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if (text.equals("reset"))
|
||||
{
|
||||
// LOG("spawning", "ONRESET");
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
debugSpeakMsg(speaker, "reset");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler doSpawnEvent()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Initialized for: "+self);
|
||||
|
||||
string datatable = getStringObjVar (self, "strSpawnTable");
|
||||
|
||||
if (datatable == null || datatable == "")
|
||||
{
|
||||
debugSpeakMsg(self, "I need a spawn table under objvar strSpawnTable");
|
||||
LOG("spawning", "No spawn datatable set, necessary for random spawners");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int numberOfLocations = dataTableGetNumRows (datatable);
|
||||
if(numberOfLocations <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawn table has no rows. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are "+numberOfLocations+" number of rows for the spawner to select from. Random Spawner: "+self);
|
||||
|
||||
int numberOfSpawns = getIntObjVar (self, "intSpawnCount");
|
||||
if(numberOfSpawns <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawner has no spawn count. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are "+numberOfSpawns+" spawns needed for this spawner to work. Random Spawner: "+ self);
|
||||
|
||||
if(numberOfSpawns >= numberOfLocations)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are more or equal the number of spawns to number of locations. Need to be less. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: spawning.checkSpawnCount(self) reports that it cannot spawn any more. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: We have not reached max spawns for event per spawning.checkSpawnCount library. Spawner: "+self);
|
||||
|
||||
string strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
if(strSpawnType == null || strSpawnType.equals(""))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent:The strSpawns objvar was invalid. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: "+strSpawnType);
|
||||
|
||||
// If strSpawnType is the name of a spawning table, use it.
|
||||
// Otherwise, strSpawnType should be directly from creatures.tab or be an object
|
||||
string strSpawn = strSpawnType;
|
||||
|
||||
if(strSpawnType.indexOf(".iff") < 0)
|
||||
{
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strSpawnType+".iff";
|
||||
if ( dataTableOpen(strFileName) )
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns datatable found and opened");
|
||||
|
||||
string[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if( strSpawns==null || strSpawns.length==0 )
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: no strItem or corrupt data found for strSpawns datatable.");
|
||||
setName(self, "Mangled spawner. strFileName is "+strFileName+" I couldnt find any spawns in that file.");
|
||||
}
|
||||
|
||||
int intRoll = rand(0, strSpawns.length-1);
|
||||
// LOG("spawning", "looking for "+strFileName);
|
||||
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
}
|
||||
// LOG("spawning", "spawning "+strSpawn);
|
||||
if( strSpawn==null || strSpawn.length() < 1 )
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int x = rand(0, numberOfLocations-1);
|
||||
float xCoord = dataTableGetFloat (datatable, x, "loc_x");
|
||||
float yCoord = dataTableGetFloat (datatable, x, "loc_y");
|
||||
float zCoord = dataTableGetFloat (datatable, x, "loc_z");
|
||||
float yaw = dataTableGetFloat (datatable, x, "yaw");
|
||||
// LOG("spawning", "x is " + xCoord + " y is " + yCoord + " z is " + zCoord + " yaw is " + yaw);
|
||||
// LOG("spawning", "random x is " + x);
|
||||
// LOG("spawning", "number of rows is " + numberOfLocations);
|
||||
location myself = getLocation (self);
|
||||
string planet = myself.area;
|
||||
|
||||
location locLocation = new location (xCoord, yCoord, zCoord, planet);
|
||||
|
||||
if (!utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation))
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
utils.removeScriptVar(self, "locationFindTries");
|
||||
|
||||
createMob(strSpawn, null, locLocation, yaw, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (utils.hasScriptVar (self, "locationFindTries"))
|
||||
{
|
||||
int nrTries = utils.getIntScriptVar(self, "locationFindTries");
|
||||
utils.setScriptVar(self, "locationFindTries", nrTries + 1);
|
||||
}
|
||||
else
|
||||
utils.setScriptVar(self, "locationFindTries", 1);
|
||||
|
||||
if (utils.getIntScriptVar (self, "locationFindTries") < 501)
|
||||
messageTo(self, "doSpawnEvent", null, 3, false);
|
||||
else
|
||||
LOG("spawning", "Random spawner: " + self + " named: " + getStringObjVar(self, "strName") + " has tried to find a good location for a spawn 500 times. Now giving up");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void createMob(string strId, obj_id objLocationObject, location locLocation, float yaw, obj_id self)
|
||||
{
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Begin Spawning
|
||||
|
||||
// The string is actually what we spawn.
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
float fltLifeTime = 0;
|
||||
// We might set a min and max life time of object.
|
||||
if (hasObjVar(self, "fltMinLifeTime"))
|
||||
{
|
||||
if (hasObjVar(self, "fltMaxLifeTime"))
|
||||
{
|
||||
float fltMinLifeTime = getFloatObjVar(self, "fltMinLifeTime");
|
||||
float fltMaxLifeTime = getFloatObjVar(self, "fltMaxLifeTime");
|
||||
if (fltMinLifeTime < fltMaxLifeTime)
|
||||
fltLifeTime = rand(fltMinLifeTime, fltMaxLifeTime);
|
||||
}
|
||||
}
|
||||
|
||||
if(intIndex>-1)
|
||||
{
|
||||
// Template
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
if(!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objTemplate);
|
||||
utils.setScriptVar(objTemplate, "deathTracker", locLocation);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
messageTo(objTemplate, "selfDestruct", null, fltLifeTime, false);
|
||||
|
||||
setYaw(objTemplate, yaw);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Monster
|
||||
// LOG("spawning", "I am going to make a "+strId);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
|
||||
if(!isIdValid(objMob))
|
||||
{
|
||||
setName(self , "BAD MOB OF TYPE "+strId);
|
||||
return;
|
||||
}
|
||||
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objMob);
|
||||
utils.setScriptVar(objMob, "deathTracker", locLocation);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
messageTo(objMob, "selfDestruct", null, fltLifeTime, false);
|
||||
|
||||
setYaw(objMob, yaw);
|
||||
|
||||
}
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
// LOG("spawning", "Failed to check spawncount");
|
||||
return;
|
||||
}
|
||||
// LOG("spawning", "resending doSpawnEvent");
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler spawnDestroyed()
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount>-1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
// Opening up the location the mob was at for spawning.
|
||||
location loc = params.getLocation("loc");
|
||||
if (utils.hasScriptVar (self, "spawnedObjectList.spawnLoc" + loc))
|
||||
utils.removeScriptVar (self, "spawnedObjectList.spawnLoc" + loc);
|
||||
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
boolean canSpawnByConfigSetting()
|
||||
{
|
||||
string disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
return true;
|
||||
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Destroy spawned objects when spawner is destroyed.
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
// LOG("spawning", "Reached debugSpawnList");
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
|
||||
if(spawns == null || spawns.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
for(int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
// LOG("spawning", "Reached loop");
|
||||
if(isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.utils;
|
||||
import script.library.ai_lib;
|
||||
import script.library.space_utils;
|
||||
import script.library.spawning;
|
||||
import script.library.create;
|
||||
|
||||
public class spawner_random_proxy extends script.base_script
|
||||
{
|
||||
public spawner_random_proxy()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: " + self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: " + self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CAN SPAWN for: " + self);
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CANNOT SPAWN for: " + self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnHearSpeech(obj_id self, obj_id speaker, String text) throws InterruptedException
|
||||
{
|
||||
if (!isGod(speaker))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id target = getIntendedTarget(speaker);
|
||||
if (target != self)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (text.equals("reset"))
|
||||
{
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
{
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
}
|
||||
if (hasObjVar(self, "strName"))
|
||||
{
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
}
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
debugSpeakMsg(speaker, "reset");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int doSpawnEvent(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Initialized for: " + self);
|
||||
String datatable = getStringObjVar(self, "strSpawnTable");
|
||||
if (datatable == null || datatable.equals(""))
|
||||
{
|
||||
debugSpeakMsg(self, "I need a spawn table under objvar strSpawnTable");
|
||||
LOG("spawning", "No spawn datatable set, necessary for random spawners");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int numberOfLocations = dataTableGetNumRows(datatable);
|
||||
if (numberOfLocations <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawn table has no rows. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are " + numberOfLocations + " number of rows for the spawner to select from. Random Spawner: " + self);
|
||||
int numberOfSpawns = getIntObjVar(self, "intSpawnCount");
|
||||
if (numberOfSpawns <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawner has no spawn count. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are " + numberOfSpawns + " spawns needed for this spawner to work. Random Spawner: " + self);
|
||||
if (numberOfSpawns >= numberOfLocations)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are more or equal the number of spawns to number of locations. Need to be less. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: spawning.checkSpawnCount(self) reports that it cannot spawn any more. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: We have not reached max spawns for event per spawning.checkSpawnCount library. Spawner: " + self);
|
||||
String strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
if (strSpawnType == null || strSpawnType.equals(""))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent:The strSpawns objvar was invalid. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: " + strSpawnType);
|
||||
String strSpawn = strSpawnType;
|
||||
if (strSpawnType.indexOf(".iff") < 0)
|
||||
{
|
||||
String strFileName = "datatables/spawning/ground_spawning/types/" + strSpawnType + ".iff";
|
||||
if (dataTableOpen(strFileName))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns datatable found and opened");
|
||||
String[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if (strSpawns == null || strSpawns.length == 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: no strItem or corrupt data found for strSpawns datatable.");
|
||||
setName(self, "Mangled spawner. strFileName is " + strFileName + " I couldnt find any spawns in that file.");
|
||||
}
|
||||
int intRoll = rand(0, strSpawns.length - 1);
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
}
|
||||
if (strSpawn == null || strSpawn.length() < 1)
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int x = rand(0, numberOfLocations - 1);
|
||||
float xCoord = dataTableGetFloat(datatable, x, "loc_x");
|
||||
float yCoord = dataTableGetFloat(datatable, x, "loc_y");
|
||||
float zCoord = dataTableGetFloat(datatable, x, "loc_z");
|
||||
float yaw = dataTableGetFloat(datatable, x, "yaw");
|
||||
location myself = getLocation(self);
|
||||
String planet = myself.area;
|
||||
location locLocation = new location(xCoord, yCoord, zCoord, planet);
|
||||
if (!utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation))
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
{
|
||||
utils.removeScriptVar(self, "locationFindTries");
|
||||
}
|
||||
createMob(strSpawn, null, locLocation, yaw, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
{
|
||||
int nrTries = utils.getIntScriptVar(self, "locationFindTries");
|
||||
utils.setScriptVar(self, "locationFindTries", nrTries + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "locationFindTries", 1);
|
||||
}
|
||||
if (utils.getIntScriptVar(self, "locationFindTries") < 501)
|
||||
{
|
||||
messageTo(self, "doSpawnEvent", null, 3, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("spawning", "Random spawner: " + self + " named: " + getStringObjVar(self, "strName") + " has tried to find a good location for a spawn 500 times. Now giving up");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void createMob(String strId, obj_id objLocationObject, location locLocation, float yaw, obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
float fltLifeTime = 0;
|
||||
if (hasObjVar(self, "fltMinLifeTime"))
|
||||
{
|
||||
if (hasObjVar(self, "fltMaxLifeTime"))
|
||||
{
|
||||
float fltMinLifeTime = getFloatObjVar(self, "fltMinLifeTime");
|
||||
float fltMaxLifeTime = getFloatObjVar(self, "fltMaxLifeTime");
|
||||
if (fltMinLifeTime < fltMaxLifeTime)
|
||||
{
|
||||
fltLifeTime = rand(fltMinLifeTime, fltMaxLifeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (intIndex > -1)
|
||||
{
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
if (!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objTemplate);
|
||||
utils.setScriptVar(objTemplate, "deathTracker", locLocation);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
{
|
||||
messageTo(objTemplate, "selfDestruct", null, fltLifeTime, false);
|
||||
}
|
||||
setYaw(objTemplate, yaw);
|
||||
if (hasObjVar(self, "strQuest"))
|
||||
{
|
||||
String strQuest = getStringObjVar(self, "strQuest");
|
||||
if (strQuest != null && strQuest.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuest", strQuest);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strSignal"))
|
||||
{
|
||||
String strSignal = getStringObjVar(self, "strSignal");
|
||||
if (strSignal != null && strSignal.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strSignal", strSignal);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strFailSignal"))
|
||||
{
|
||||
String strFailSignal = getStringObjVar(self, "strFailSignal");
|
||||
if (strFailSignal != null && strFailSignal.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strFailSignal", strFailSignal);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strCollection"))
|
||||
{
|
||||
String strCollection = getStringObjVar(self, "strCollection");
|
||||
if (strCollection != null && strCollection.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strCollection", strCollection);
|
||||
}
|
||||
}
|
||||
setObjVar(objTemplate, "locationObjParent", getLocation(self));
|
||||
if (hasObjVar(self, "strQuestBetsy"))
|
||||
{
|
||||
String strQuestBetsy = getStringObjVar(self, "strQuestBetsy");
|
||||
if (strQuestBetsy != null && strQuestBetsy.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestBetsy", strQuestBetsy);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strQuestPerfume"))
|
||||
{
|
||||
String strQuestPerfume = getStringObjVar(self, "strQuestPerfume");
|
||||
if (strQuestPerfume != null && strQuestPerfume.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestPerfume", strQuestPerfume);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strQuestStunBaton"))
|
||||
{
|
||||
String strQuestStunBaton = getStringObjVar(self, "strQuestStunBaton");
|
||||
if (strQuestStunBaton != null && strQuestStunBaton.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestStunBaton", strQuestStunBaton);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strQuestBomberHelmet"))
|
||||
{
|
||||
String strQuestBomberHelmet = getStringObjVar(self, "strQuestBomberHelmet");
|
||||
if (strQuestBomberHelmet != null && strQuestBomberHelmet.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestBomberHelmet", strQuestBomberHelmet);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "strQuestScoutCamera"))
|
||||
{
|
||||
String strQuestScoutCamera = getStringObjVar(self, "strQuestScoutCamera");
|
||||
if (strQuestScoutCamera != null && strQuestScoutCamera.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestScoutCamera", strQuestScoutCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
if (!isIdValid(objMob))
|
||||
{
|
||||
setName(self, "BAD MOB OF TYPE " + strId);
|
||||
return;
|
||||
}
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objMob);
|
||||
utils.setScriptVar(objMob, "deathTracker", locLocation);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
{
|
||||
messageTo(objMob, "selfDestruct", null, fltLifeTime, false);
|
||||
}
|
||||
setYaw(objMob, yaw);
|
||||
}
|
||||
if (!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
}
|
||||
public int spawnDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount > -1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
location loc = params.getLocation("loc");
|
||||
if (utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + loc))
|
||||
{
|
||||
utils.removeScriptVar(self, "spawnedObjectList.spawnLoc" + loc);
|
||||
}
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean canSpawnByConfigSetting() throws InterruptedException
|
||||
{
|
||||
String disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
if (spawns == null || spawns.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
if (isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
{
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,428 +0,0 @@
|
||||
include library.utils;
|
||||
include library.ai_lib;
|
||||
include library.space_utils;
|
||||
include library.spawning;
|
||||
include library.create;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: "+self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: Initialized for: "+self);
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CAN SPAWN for: "+self);
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.OnAttach: CANNOT SPAWN for: "+self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
// Testing stuff
|
||||
trigger OnHearSpeech(obj_id speaker, string text)
|
||||
{
|
||||
if (!isGod(speaker))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id target = getIntendedTarget(speaker);
|
||||
|
||||
if (target != self)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if (text.equals("reset"))
|
||||
{
|
||||
// LOG("spawning", "ONRESET");
|
||||
if (!hasObjVar(self, "registerWithController"))
|
||||
setObjVar(self, "registerWithController", 1);
|
||||
if (hasObjVar(self, "strName"))
|
||||
setName(self, getStringObjVar(self, "strName"));
|
||||
|
||||
if (canSpawnByConfigSetting())
|
||||
messageTo(self, "doSpawnEvent", null, 20, false);
|
||||
|
||||
debugSpeakMsg(speaker, "reset");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler doSpawnEvent()
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Initialized for: "+self);
|
||||
|
||||
string datatable = getStringObjVar (self, "strSpawnTable");
|
||||
|
||||
if (datatable == null || datatable == "")
|
||||
{
|
||||
debugSpeakMsg(self, "I need a spawn table under objvar strSpawnTable");
|
||||
LOG("spawning", "No spawn datatable set, necessary for random spawners");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int numberOfLocations = dataTableGetNumRows (datatable);
|
||||
if(numberOfLocations <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawn table has no rows. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are "+numberOfLocations+" number of rows for the spawner to select from. Random Spawner: "+self);
|
||||
|
||||
int numberOfSpawns = getIntObjVar (self, "intSpawnCount");
|
||||
if(numberOfSpawns <= 0)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: Spawner has no spawn count. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are "+numberOfSpawns+" spawns needed for this spawner to work. Random Spawner: "+ self);
|
||||
|
||||
if(numberOfSpawns >= numberOfLocations)
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: There are more or equal the number of spawns to number of locations. Need to be less. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: spawning.checkSpawnCount(self) reports that it cannot spawn any more. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: We have not reached max spawns for event per spawning.checkSpawnCount library. Spawner: "+self);
|
||||
|
||||
string strSpawnType = getStringObjVar(self, "strSpawns");
|
||||
if(strSpawnType == null || strSpawnType.equals(""))
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent:The strSpawns objvar was invalid. Exiting.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns: "+strSpawnType);
|
||||
|
||||
// If strSpawnType is the name of a spawning table, use it.
|
||||
// Otherwise, strSpawnType should be directly from creatures.tab or be an object
|
||||
string strSpawn = strSpawnType;
|
||||
|
||||
if(strSpawnType.indexOf(".iff") < 0)
|
||||
{
|
||||
string strFileName = "datatables/spawning/ground_spawning/types/"+strSpawnType+".iff";
|
||||
if ( dataTableOpen(strFileName) )
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: strSpawns datatable found and opened");
|
||||
|
||||
string[] strSpawns = dataTableGetStringColumnNoDefaults(strFileName, "strItem");
|
||||
if( strSpawns==null || strSpawns.length==0 )
|
||||
{
|
||||
CustomerServiceLog("holidaySpawner", "spawner_random.doSpawnEvent: no strItem or corrupt data found for strSpawns datatable.");
|
||||
setName(self, "Mangled spawner. strFileName is "+strFileName+" I couldnt find any spawns in that file.");
|
||||
}
|
||||
|
||||
int intRoll = rand(0, strSpawns.length-1);
|
||||
//LOG("spawning", "looking for "+strFileName);
|
||||
|
||||
strSpawn = strSpawns[intRoll];
|
||||
}
|
||||
}
|
||||
// LOG("spawning", "spawning "+strSpawn);
|
||||
if( strSpawn==null || strSpawn.length() < 1 )
|
||||
{
|
||||
setName(self, "Mangled spawner. strSpawn is " + strSpawn + ".");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int x = rand(0, numberOfLocations-1);
|
||||
float xCoord = dataTableGetFloat (datatable, x, "loc_x");
|
||||
float yCoord = dataTableGetFloat (datatable, x, "loc_y");
|
||||
float zCoord = dataTableGetFloat (datatable, x, "loc_z");
|
||||
float yaw = dataTableGetFloat (datatable, x, "yaw");
|
||||
// LOG("spawning", "x is " + xCoord + " y is " + yCoord + " z is " + zCoord + " yaw is " + yaw);
|
||||
// LOG("spawning", "random x is " + x);
|
||||
// LOG("spawning", "number of rows is " + numberOfLocations);
|
||||
location myself = getLocation (self);
|
||||
string planet = myself.area;
|
||||
|
||||
location locLocation = new location (xCoord, yCoord, zCoord, planet);
|
||||
|
||||
if (!utils.hasScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation))
|
||||
{
|
||||
if (utils.hasScriptVar(self, "locationFindTries"))
|
||||
utils.removeScriptVar(self, "locationFindTries");
|
||||
|
||||
createMob(strSpawn, null, locLocation, yaw, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (utils.hasScriptVar (self, "locationFindTries"))
|
||||
{
|
||||
int nrTries = utils.getIntScriptVar(self, "locationFindTries");
|
||||
utils.setScriptVar(self, "locationFindTries", nrTries + 1);
|
||||
}
|
||||
else
|
||||
utils.setScriptVar(self, "locationFindTries", 1);
|
||||
|
||||
if (utils.getIntScriptVar (self, "locationFindTries") < 501)
|
||||
messageTo(self, "doSpawnEvent", null, 3, false);
|
||||
else
|
||||
LOG("spawning", "Random spawner: " + self + " named: " + getStringObjVar(self, "strName") + " has tried to find a good location for a spawn 500 times. Now giving up");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void createMob(string strId, obj_id objLocationObject, location locLocation, float yaw, obj_id self)
|
||||
{
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Begin Spawn
|
||||
|
||||
// The string is actually what we spawn.
|
||||
int intIndex = strId.indexOf(".iff");
|
||||
float fltMinSpawnTime = getFloatObjVar(self, "fltMinSpawnTime");
|
||||
float fltMaxSpawnTime = getFloatObjVar(self, "fltMaxSpawnTime");
|
||||
float fltRespawnTime = rand(fltMinSpawnTime, fltMaxSpawnTime);
|
||||
float fltLifeTime = 0;
|
||||
// We might set a min and max life time of object.
|
||||
if (hasObjVar(self, "fltMinLifeTime"))
|
||||
{
|
||||
if (hasObjVar(self, "fltMaxLifeTime"))
|
||||
{
|
||||
float fltMinLifeTime = getFloatObjVar(self, "fltMinLifeTime");
|
||||
float fltMaxLifeTime = getFloatObjVar(self, "fltMaxLifeTime");
|
||||
if (fltMinLifeTime < fltMaxLifeTime)
|
||||
fltLifeTime = rand(fltMinLifeTime, fltMaxLifeTime);
|
||||
}
|
||||
}
|
||||
|
||||
if(intIndex>-1)
|
||||
{
|
||||
// Template
|
||||
obj_id objTemplate = createObject(strId, locLocation);
|
||||
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
if(!isIdValid(objTemplate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objTemplate);
|
||||
setObjVar(objTemplate, "objParent", self);
|
||||
setObjVar(objTemplate, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objTemplate);
|
||||
utils.setScriptVar(objTemplate, "deathTracker", locLocation);
|
||||
attachScript(objTemplate, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
messageTo(objTemplate, "selfDestruct", null, fltLifeTime, false);
|
||||
|
||||
setYaw(objTemplate, yaw);
|
||||
/* This section is for proxied objects. If you are doing some sort of custom
|
||||
spawning event add your objvars here*/
|
||||
// Is there a quest associated with the spawned obj?
|
||||
if(hasObjVar(self, "strQuest"))
|
||||
{
|
||||
string strQuest = getStringObjVar(self, "strQuest");
|
||||
if(strQuest != null && strQuest.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuest", strQuest);
|
||||
}
|
||||
}
|
||||
|
||||
// Is there a quest signal associated with the spawned obj?
|
||||
if(hasObjVar(self, "strSignal"))
|
||||
{
|
||||
|
||||
string strSignal = getStringObjVar(self, "strSignal");
|
||||
if(strSignal != null && strSignal.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strSignal", strSignal);
|
||||
}
|
||||
}
|
||||
|
||||
// Is there a quest fail signal associated with the spawned obj?
|
||||
if(hasObjVar(self, "strFailSignal"))
|
||||
{
|
||||
|
||||
string strFailSignal = getStringObjVar(self, "strFailSignal");
|
||||
if(strFailSignal != null && strFailSignal.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strFailSignal", strFailSignal);
|
||||
}
|
||||
}
|
||||
|
||||
// Is there a Collection *SLOT* associated with the spawned obj?
|
||||
if(hasObjVar(self, "strCollection"))
|
||||
{
|
||||
string strCollection = getStringObjVar(self, "strCollection");
|
||||
if(strCollection != null && strCollection.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strCollection", strCollection);
|
||||
}
|
||||
}
|
||||
|
||||
// This is for pathing to the parent object. Used in Death Trooper Theme Park
|
||||
setObjVar(objTemplate, "locationObjParent", getLocation(self));
|
||||
|
||||
// Death Trooper Theme Park specific
|
||||
if(hasObjVar(self, "strQuestBetsy"))
|
||||
{
|
||||
string strQuestBetsy = getStringObjVar(self, "strQuestBetsy");
|
||||
if(strQuestBetsy != null && strQuestBetsy.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestBetsy", strQuestBetsy);
|
||||
}
|
||||
}
|
||||
if(hasObjVar(self, "strQuestPerfume"))
|
||||
{
|
||||
string strQuestPerfume = getStringObjVar(self, "strQuestPerfume");
|
||||
if(strQuestPerfume != null && strQuestPerfume.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestPerfume", strQuestPerfume);
|
||||
}
|
||||
}
|
||||
if(hasObjVar(self, "strQuestStunBaton"))
|
||||
{
|
||||
string strQuestStunBaton = getStringObjVar(self, "strQuestStunBaton");
|
||||
if(strQuestStunBaton != null && strQuestStunBaton.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestStunBaton", strQuestStunBaton);
|
||||
}
|
||||
}
|
||||
if(hasObjVar(self, "strQuestBomberHelmet"))
|
||||
{
|
||||
string strQuestBomberHelmet = getStringObjVar(self, "strQuestBomberHelmet");
|
||||
if(strQuestBomberHelmet != null && strQuestBomberHelmet.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestBomberHelmet", strQuestBomberHelmet);
|
||||
}
|
||||
}
|
||||
if(hasObjVar(self, "strQuestScoutCamera"))
|
||||
{
|
||||
string strQuestScoutCamera = getStringObjVar(self, "strQuestScoutCamera");
|
||||
if(strQuestScoutCamera != null && strQuestScoutCamera.length() > 0)
|
||||
{
|
||||
setObjVar(objTemplate, "strQuestScoutCamera", strQuestScoutCamera);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Monster
|
||||
// LOG("spawning", "I am going to make a "+strId);
|
||||
if(isIdValid(objLocationObject))
|
||||
{
|
||||
destroyObject(objLocationObject);
|
||||
}
|
||||
|
||||
obj_id objMob = create.object(strId, locLocation);
|
||||
|
||||
if(!isIdValid(objMob))
|
||||
{
|
||||
setName(self , "BAD MOB OF TYPE "+strId);
|
||||
return;
|
||||
}
|
||||
|
||||
int intBehavior = getIntObjVar(self, "intDefaultBehavior");
|
||||
ai_lib.setDefaultCalmBehavior(objMob, intBehavior);
|
||||
|
||||
spawning.incrementSpawnCount(self);
|
||||
spawning.addToSpawnDebugList(self, objMob);
|
||||
setObjVar(objMob, "objParent", self);
|
||||
setObjVar(objMob, "fltRespawnTime", fltRespawnTime);
|
||||
utils.setScriptVar(self, "spawnedObjectList.spawnLoc" + locLocation, objMob);
|
||||
utils.setScriptVar(objMob, "deathTracker", locLocation);
|
||||
attachScript(objMob, "systems.spawning.spawned_tracker");
|
||||
if (fltLifeTime != 0)
|
||||
messageTo(objMob, "selfDestruct", null, fltLifeTime, false);
|
||||
|
||||
setYaw(objMob, yaw);
|
||||
|
||||
}
|
||||
if(!spawning.checkSpawnCount(self))
|
||||
{
|
||||
// LOG("spawning", "Failed to check spawncount");
|
||||
return;
|
||||
}
|
||||
// LOG("spawning", "resending doSpawnEvent");
|
||||
messageTo(self, "doSpawnEvent", null, fltRespawnTime, false);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler spawnDestroyed()
|
||||
{
|
||||
int intCurrentSpawnCount = utils.getIntScriptVar(self, "intCurrentSpawnCount");
|
||||
intCurrentSpawnCount = intCurrentSpawnCount - 1;
|
||||
if (intCurrentSpawnCount>-1)
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", intCurrentSpawnCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
utils.setScriptVar(self, "intCurrentSpawnCount", 0);
|
||||
}
|
||||
// Opening up the location the mob was at for spawning.
|
||||
location loc = params.getLocation("loc");
|
||||
if (utils.hasScriptVar (self, "spawnedObjectList.spawnLoc" + loc))
|
||||
utils.removeScriptVar (self, "spawnedObjectList.spawnLoc" + loc);
|
||||
|
||||
messageTo(self, "doSpawnEvent", null, 2, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
}
|
||||
|
||||
boolean canSpawnByConfigSetting()
|
||||
{
|
||||
string disableSpawners = getConfigSetting("GameServer", "disableAreaSpawners");
|
||||
if (disableSpawners == null)
|
||||
return true;
|
||||
|
||||
if (disableSpawners.equals("true") || disableSpawners.equals("1"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Destroy spawned objects when spawner is destroyed.
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if (utils.hasScriptVar(self, "debugSpawnList"))
|
||||
{
|
||||
// LOG("spawning", "Reached debugSpawnList");
|
||||
obj_id[] spawns = utils.getObjIdArrayScriptVar(self, "debugSpawnList");
|
||||
|
||||
if(spawns == null || spawns.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
for(int i = 0; i < spawns.length; ++i)
|
||||
{
|
||||
// LOG("spawning", "Reached loop");
|
||||
if(isIdValid(spawns[i]) && exists(spawns[i]))
|
||||
messageTo(spawns[i], "selfDestruct", null, 5, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package script.systems.spawning;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.create;
|
||||
import script.library.utils;
|
||||
|
||||
public class theater_spawnegg extends script.base_script
|
||||
{
|
||||
public theater_spawnegg()
|
||||
{
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "beginSpawning", null, 30, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(self, "spawnList");
|
||||
if (spawnList == null || spawnList.length == 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
for (int i = 0; i < spawnList.length; i++)
|
||||
{
|
||||
if (isIdValid(spawnList[i]))
|
||||
{
|
||||
destroyObject(spawnList[i]);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int beginSpawning(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String strNumToSpawn = getStringObjVar(self, "pop");
|
||||
int numToSpawn = utils.stringToInt(strNumToSpawn);
|
||||
if (numToSpawn < 1)
|
||||
{
|
||||
setObjVar(self, "pop", 1);
|
||||
numToSpawn = 1;
|
||||
}
|
||||
if (numToSpawn > 5)
|
||||
{
|
||||
setObjVar(self, "pop", 5);
|
||||
numToSpawn = 5;
|
||||
}
|
||||
String npcType = getStringObjVar(self, "type");
|
||||
if (npcType == null)
|
||||
{
|
||||
npcType = "none";
|
||||
}
|
||||
if (npcType.equals("none"))
|
||||
{
|
||||
setObjVar(self, "type", "thug");
|
||||
npcType = "thug";
|
||||
}
|
||||
String name = getStringObjVar(self, "name");
|
||||
if (name == null)
|
||||
{
|
||||
name = "default";
|
||||
}
|
||||
String behavior = getStringObjVar(self, "behavior");
|
||||
if (behavior == null)
|
||||
{
|
||||
behavior = "default";
|
||||
}
|
||||
String objVarName = getStringObjVar(self, "objvarname");
|
||||
String objVarType = getStringObjVar(self, "objvartype");
|
||||
String objVarValue = getStringObjVar(self, "objvarvalue");
|
||||
if (objVarName == null)
|
||||
{
|
||||
objVarName = "none";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (objVarValue == null)
|
||||
{
|
||||
objVarName = "none";
|
||||
}
|
||||
}
|
||||
int x = 0;
|
||||
obj_id[] spawnList = new obj_id[numToSpawn];
|
||||
while (x < numToSpawn)
|
||||
{
|
||||
obj_id npc = create.object(npcType, pickLoc(self, x));
|
||||
if (!name.equals("default"))
|
||||
{
|
||||
setName(npc, name);
|
||||
}
|
||||
String script = getStringObjVar(self, "script");
|
||||
if (script == null || script.equals(""))
|
||||
{
|
||||
script = "none";
|
||||
}
|
||||
if (!script.equals("none"))
|
||||
{
|
||||
attachScript(npc, script);
|
||||
}
|
||||
if (!objVarName.equals("none"))
|
||||
{
|
||||
if (objVarType.equalsIgnoreCase("int"))
|
||||
{
|
||||
int intObjVarValue = utils.stringToInt(objVarValue);
|
||||
setObjVar(npc, objVarName, intObjVarValue);
|
||||
}
|
||||
else if (objVarType.equalsIgnoreCase("float"))
|
||||
{
|
||||
float floatObjVarValue = utils.stringToFloat(objVarValue);
|
||||
setObjVar(npc, objVarName, floatObjVarValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(npc, objVarName, objVarValue);
|
||||
}
|
||||
}
|
||||
if (behavior.equalsIgnoreCase("sentinel"))
|
||||
{
|
||||
setObjVar(npc, "SENTINEL", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_SENTINEL);
|
||||
}
|
||||
else if (behavior.equalsIgnoreCase("loiter"))
|
||||
{
|
||||
setObjVar(npc, "LOITER", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_LOITER);
|
||||
}
|
||||
else if (behavior.equalsIgnoreCase("wander"))
|
||||
{
|
||||
setObjVar(npc, "WANDER", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_WANDER);
|
||||
}
|
||||
spawnList[x] = npc;
|
||||
x = x + 1;
|
||||
}
|
||||
setObjVar(self, "spawnList", spawnList);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public location pickLoc(obj_id self, int x) throws InterruptedException
|
||||
{
|
||||
location here = getLocation(self);
|
||||
setObjVar(self, "location", here);
|
||||
location zero = here;
|
||||
here.x = here.x - 1.5f;
|
||||
here.z = here.z - 1.5f;
|
||||
location one = here;
|
||||
here.z = here.z + 3;
|
||||
location two = here;
|
||||
here.x = here.x + 3;
|
||||
location three = here;
|
||||
here.z = here.z - 3;
|
||||
location four = here;
|
||||
here = getLocation(self);
|
||||
here.x = here.x + rand(-3, 3);
|
||||
here.z = here.z + rand(-3, 3);
|
||||
location other = here;
|
||||
if (x == 0)
|
||||
{
|
||||
return zero;
|
||||
}
|
||||
else if (x == 1)
|
||||
{
|
||||
return one;
|
||||
}
|
||||
else if (x == 2)
|
||||
{
|
||||
return two;
|
||||
}
|
||||
else if (x == 3)
|
||||
{
|
||||
return three;
|
||||
}
|
||||
else if (x == 4)
|
||||
{
|
||||
return four;
|
||||
}
|
||||
else
|
||||
{
|
||||
return other;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.create;
|
||||
include library.utils;
|
||||
|
||||
trigger OnInitialize() {
|
||||
|
||||
messageTo (self, "beginSpawning", null, 30, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnDestroy() {
|
||||
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(self, "spawnList");
|
||||
|
||||
if(spawnList == null || spawnList.length == 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
for(int i = 0; i < spawnList.length; i++) {
|
||||
|
||||
if(isIdValid(spawnList[i]))
|
||||
destroyObject(spawnList[i]);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler beginSpawning() {
|
||||
|
||||
string strNumToSpawn = getStringObjVar(self, "pop");
|
||||
int numToSpawn = utils.stringToInt(strNumToSpawn);
|
||||
|
||||
if (numToSpawn < 1) {
|
||||
|
||||
setObjVar(self, "pop", 1);
|
||||
numToSpawn = 1;
|
||||
}
|
||||
|
||||
if (numToSpawn > 5) {
|
||||
|
||||
setObjVar(self, "pop", 5);
|
||||
numToSpawn = 5;
|
||||
}
|
||||
|
||||
string npcType = getStringObjVar(self, "type");
|
||||
|
||||
if (npcType == null) {
|
||||
|
||||
npcType = "none";
|
||||
}
|
||||
|
||||
if (npcType == "none") {
|
||||
|
||||
setObjVar (self, "type", "thug");
|
||||
npcType = "thug";
|
||||
}
|
||||
|
||||
string name = getStringObjVar(self, "name");
|
||||
|
||||
if(name == null) {
|
||||
|
||||
name = "default";
|
||||
}
|
||||
|
||||
string behavior = getStringObjVar(self, "behavior");
|
||||
|
||||
if(behavior == null) {
|
||||
|
||||
behavior = "default";
|
||||
}
|
||||
|
||||
string objVarName = getStringObjVar(self, "objvarname");
|
||||
string objVarType = getStringObjVar(self, "objvartype");
|
||||
string objVarValue = getStringObjVar(self, "objvarvalue");
|
||||
|
||||
if(objVarName == null) {
|
||||
|
||||
objVarName = "none";
|
||||
|
||||
} else {
|
||||
|
||||
if(objVarValue == null) {
|
||||
|
||||
objVarName = "none";
|
||||
}
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
|
||||
obj_id[] spawnList = new obj_id[numToSpawn];
|
||||
|
||||
while (x < numToSpawn) {
|
||||
|
||||
obj_id npc = create.object(npcType, pickLoc(self, x));
|
||||
|
||||
if(!name.equals("default")) {
|
||||
|
||||
setName(npc, name);
|
||||
}
|
||||
|
||||
string script = getStringObjVar(self, "script");
|
||||
|
||||
if(script == null || script == "") {
|
||||
|
||||
script = "none";
|
||||
}
|
||||
|
||||
if(script != "none") {
|
||||
|
||||
attachScript (npc, script);
|
||||
}
|
||||
|
||||
if(objVarName != "none") {
|
||||
|
||||
if(objVarType.equalsIgnoreCase("int")) {
|
||||
|
||||
int intObjVarValue = utils.stringToInt(objVarValue);
|
||||
setObjVar(npc, objVarName, intObjVarValue);
|
||||
|
||||
} else if(objVarType.equalsIgnoreCase("float")) {
|
||||
|
||||
float floatObjVarValue = utils.stringToFloat(objVarValue);
|
||||
setObjVar(npc, objVarName, floatObjVarValue);
|
||||
|
||||
} else {
|
||||
|
||||
setObjVar(npc, objVarName, objVarValue);
|
||||
}
|
||||
}
|
||||
|
||||
if(behavior.equalsIgnoreCase("sentinel")) {
|
||||
|
||||
setObjVar (npc, "SENTINEL", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_SENTINEL);
|
||||
|
||||
} else if(behavior.equalsIgnoreCase("loiter")) {
|
||||
|
||||
setObjVar (npc, "LOITER", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_LOITER);
|
||||
|
||||
} else if(behavior.equalsIgnoreCase("wander")) {
|
||||
|
||||
setObjVar (npc, "WANDER", 1);
|
||||
ai_lib.setDefaultCalmBehavior(npc, ai_lib.BEHAVIOR_WANDER);
|
||||
}
|
||||
|
||||
spawnList[x] = npc;
|
||||
|
||||
x = x + 1;
|
||||
}
|
||||
|
||||
setObjVar(self, "spawnList", spawnList); // Suppress linting - we know the length of this array will be at least 1
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
location pickLoc (obj_id self, int x)
|
||||
{
|
||||
location here = getLocation(self);
|
||||
setObjVar (self, "location", here);
|
||||
|
||||
location zero = here;
|
||||
|
||||
here.x = here.x - 1.5f;
|
||||
here.z = here.z - 1.5f;
|
||||
location one = here;
|
||||
|
||||
here.z = here.z + 3;
|
||||
location two = here;
|
||||
|
||||
here.x = here.x + 3;
|
||||
location three = here;
|
||||
|
||||
here.z = here.z - 3;
|
||||
location four = here;
|
||||
|
||||
here = getLocation(self);
|
||||
here.x = here.x + rand (-3,3);
|
||||
here.z = here.z + rand (-3,3);
|
||||
location other = here;
|
||||
|
||||
if (x == 0)
|
||||
{
|
||||
return zero;
|
||||
}
|
||||
else if (x == 1)
|
||||
{
|
||||
return one;
|
||||
}
|
||||
else if (x == 2)
|
||||
{
|
||||
return two;
|
||||
}
|
||||
else if (x == 3)
|
||||
{
|
||||
return three;
|
||||
}
|
||||
else if (x == 4)
|
||||
{
|
||||
return four;
|
||||
}
|
||||
else
|
||||
{
|
||||
return other;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user