Added some efficiencies to the city scripts.

This commit is contained in:
Cekis
2016-03-31 04:23:06 +01:00
parent f2e639238b
commit 92da2e416c
11 changed files with 192 additions and 400 deletions
+27 -33
View File
@@ -1,12 +1,7 @@
package script.city;
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.dictionary;
import script.obj_id;
public class bestine_wander extends script.base_script
{
@@ -40,45 +35,44 @@ public class bestine_wander extends script.base_script
public String pickDestination() throws InterruptedException
{
String waypoint = "exit";
int whichWay = rand(1, 12);
switch (whichWay)
switch (rand(1, 12))
{
case 1:
waypoint = "square";
break;
waypoint = "square";
break;
case 2:
waypoint = "cafe1";
break;
waypoint = "cafe1";
break;
case 3:
waypoint = "cafe2";
break;
waypoint = "cafe2";
break;
case 4:
waypoint = "cafe3";
break;
waypoint = "cafe3";
break;
case 5:
waypoint = "cafe4";
break;
waypoint = "cafe4";
break;
case 6:
waypoint = "hotel";
break;
waypoint = "hotel";
break;
case 7:
waypoint = "capitol";
break;
waypoint = "capitol";
break;
case 8:
waypoint = "mission1";
break;
waypoint = "mission1";
break;
case 9:
waypoint = "mission2";
break;
waypoint = "mission2";
break;
case 10:
waypoint = "installation";
break;
waypoint = "installation";
break;
case 11:
waypoint = "exit";
break;
waypoint = "exit";
break;
case 12:
waypoint = "gate1";
break;
waypoint = "gate1";
break;
}
return waypoint;
}
+41 -75
View File
@@ -1,18 +1,13 @@
package script.city;
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.dictionary;
import script.library.create;
import script.obj_id;
public class city_convo extends script.base_script
{
private final float[][] offsets = new float[][]{{1.1f, 0},{1.1f, 1.1f},{0f,1.1f},{0f,0f}};
public city_convo()
{
}
@@ -51,82 +46,53 @@ public class city_convo extends script.base_script
setAnimationMood(guy4, "conversation");
return SCRIPT_CONTINUE;
}
public int handleGuyOneKilled(obj_id self, dictionary params) throws InterruptedException
public int handleGuyKilled(obj_id self, dictionary params) throws InterruptedException
{
spawnGuyOne(self);
spawnGuy(self, getStringObjVar(self, "name"));
return SCRIPT_CONTINUE;
}
public int handleGuyTwoKilled(obj_id self, dictionary params) throws InterruptedException
public void spawnGuy(obj_id baseObject, String name) throws InterruptedException
{
spawnGuyTwo(self);
return SCRIPT_CONTINUE;
}
public int handleGuyThreeKilled(obj_id self, dictionary params) throws InterruptedException
{
spawnGuyThree(self);
return SCRIPT_CONTINUE;
}
public int handleGuyFourKilled(obj_id self, dictionary params) throws InterruptedException
{
spawnGuyFour(self);
return SCRIPT_CONTINUE;
}
public void spawnGuyOne(obj_id baseObject) throws InterruptedException
{
obj_id guy1 = create.themeParkObject(getRandomGuy(), 1.3f, 0, "handleGuyOneKilled", 0);
setObjVar(baseObject, "guy1", guy1);
setCreatureStatic(guy1, true);
}
public void spawnGuyTwo(obj_id baseObject) throws InterruptedException
{
obj_id guy2 = create.themeParkObject(getRandomGuy(), 1.3f, 1.3f, "handleGuyTwoKilled", 0);
setObjVar(baseObject, "guy2", guy2);
setCreatureStatic(guy2, true);
}
public void spawnGuyThree(obj_id baseObject) throws InterruptedException
{
obj_id guy3 = create.themeParkObject(getRandomGuy(), 0, 1.3f, "handleGuyThreeKilled", 0);
setObjVar(baseObject, "guy3", guy3);
setCreatureStatic(guy3, true);
}
public void spawnGuyFour(obj_id baseObject) throws InterruptedException
{
obj_id guy4 = create.themeParkObject(getRandomGuy(), 0, 0, "handleGuyFourKilled", 0);
setObjVar(baseObject, "guy4", guy4);
setCreatureStatic(guy4, true);
obj_id guy = null;
switch(name){
case "guy1":
guy = create.themeParkObject(getRandomGuy(), offsets[0][0], offsets[0][1], "handleGuyKilled", 0);
break;
case "guy2":
guy = create.themeParkObject(getRandomGuy(), offsets[1][0], offsets[1][1], "handleGuyKilled", 0);
break;
case "guy3":
guy = create.themeParkObject(getRandomGuy(), offsets[2][0], offsets[2][1], "handleGuyKilled", 0);
break;
case "guy4":
guy = create.themeParkObject(getRandomGuy(), offsets[3][0], offsets[3][1], "handleGuyKilled", 0);
break;
}
if(guy != null) {
setObjVar(baseObject, name, guy);
setCreatureStatic(guy, true);
}
}
public String getRandomGuy() throws InterruptedException
{
location here = getLocation(getSelf());
String planet = here.area;
String[] npcList = dataTableGetStringColumnNoDefaults(npcTable, planet);
int npcNum = rand(0, npcList.length - 1);
String npc = npcList[npcNum];
return npc;
String[] npcList = dataTableGetStringColumnNoDefaults(npcTable, getLocation(getSelf()).area);
return npcList[rand(0, npcList.length - 1)];
}
public void beginSpawning(obj_id self) throws InterruptedException
{
int num = rand(1, 10);
if (num < 5)
{
spawnGuyOne(self);
spawnGuyTwo(self);
return;
}
if (num < 8)
{
spawnGuyOne(self);
spawnGuyTwo(self);
spawnGuyThree(self);
return;
}
else
{
spawnGuyOne(self);
spawnGuyTwo(self);
spawnGuyThree(self);
spawnGuyFour(self);
return;
if(!getBooleanObjVar(self, "spawned") || !getBooleanObjVar(self, "spawnInProgress")) {
setObjVar(self, "spawnInProgress", true);
int num = rand(1, 10);
spawnGuy(self, "guy1");
spawnGuy(self, "guy2");
if (num >= 5) {
spawnGuy(self, "guy3");
}
if (num >= 8) {
spawnGuy(self, "guy4");
}
setObjVar(self, "spawnInProgress", false);
setObjVar(self, "spawned", true);
}
}
public int checkForScripts(obj_id self, dictionary params) throws InterruptedException
+2 -7
View File
@@ -1,12 +1,7 @@
package script.city;
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.dictionary;
import script.obj_id;
public class city_mob_death_msg extends script.base_script
{
+4 -12
View File
@@ -1,15 +1,9 @@
package script.city;
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.dictionary;
import script.library.create;
import script.library.utils;
import script.obj_id;
public class city_pathing extends script.base_script
{
@@ -23,9 +17,7 @@ public class city_pathing extends script.base_script
}
public int handleNpcRespawn(obj_id self, dictionary params) throws InterruptedException
{
obj_id messageFrom = params.getObjId("object");
obj_id lastSpawned = getObjIdObjVar(self, "pathing.lastSpawned");
if (messageFrom != lastSpawned)
if (params.getObjId("object") != getObjIdObjVar(self, "pathing.lastSpawned"))
{
return SCRIPT_CONTINUE;
}
+19 -31
View File
@@ -1,14 +1,8 @@
package script.city;
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.dictionary;
import script.library.utils;
import script.obj_id;
public class city_pathing_npc extends script.base_script
{
@@ -54,22 +48,22 @@ public class city_pathing_npc extends script.base_script
switch (lastAction)
{
case NEXT_ACTION_NONE:
pathTo(npc, getHomeLocation(npc));
obj_id homeStop = utils.getObjIdScriptVar(npc, "pathing.homeStop");
utils.setScriptVar(npc, "pathing.currentStop", homeStop);
return;
case NEXT_ACTION_FACETO:
if (hasObjVar(currentStop, "faceto"))
{
doFacingAction(npc, currentStop);
pathTo(npc, getHomeLocation(npc));
obj_id homeStop = utils.getObjIdScriptVar(npc, "pathing.homeStop");
utils.setScriptVar(npc, "pathing.currentStop", homeStop);
return;
}
case NEXT_ACTION_FACETO:
if (hasObjVar(currentStop, "faceto"))
{
doFacingAction(npc, currentStop);
return;
}
case NEXT_ACTION_DOANIM:
executeAnimation(npc, currentStop);
return;
executeAnimation(npc, currentStop);
return;
case NEXT_ACTION_PATHTONEXT:
pathToNext(npc, currentStop);
return;
pathToNext(npc, currentStop);
return;
}
lastAction++;
if (lastAction > LAST_POSSIBLE_ACTION)
@@ -86,8 +80,7 @@ public class city_pathing_npc extends script.base_script
}
public void doFacingAction(obj_id npc, obj_id currentStop) throws InterruptedException
{
int intThingToFace = getIntObjVar(currentStop, "faceto");
obj_id objThingToFace = utils.stringToObjId("" + intThingToFace);
obj_id objThingToFace = utils.stringToObjId("" + getIntObjVar(currentStop, "faceto"));
if (isIdValid(objThingToFace))
{
faceTo(npc, objThingToFace);
@@ -116,8 +109,7 @@ public class city_pathing_npc extends script.base_script
{
if (hasObjVar(currentStop, "destination"))
{
int destination = getIntObjVar(currentStop, "destination");
obj_id dest = utils.stringToObjId("" + destination);
obj_id dest = utils.stringToObjId("" + getIntObjVar(currentStop, "destination"));
utils.setScriptVar(npc, "pathing.currentStop", dest);
pathTo(npc, getLocation(dest));
}
@@ -128,16 +120,12 @@ public class city_pathing_npc extends script.base_script
}
public void checkForFeetGluedToFloor(obj_id self) throws InterruptedException
{
location here = getLocation(self);
setObjVar(self, "mightBeStuck", here);
setObjVar(self, "mightBeStuck", getLocation(self));
messageTo(self, "amIStuck", null, 300, false);
return;
}
public int amIStuck(obj_id self, dictionary params) throws InterruptedException
{
location now = getLocation(self);
location here = getLocationObjVar(self, "mightBeStuck");
if (now.equals(here))
if (getLocation(self).equals(getLocationObjVar(self, "mightBeStuck")))
{
destroyObject(self);
}
+1 -12
View File
@@ -1,17 +1,6 @@
package script.city;
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;
import script.library.locations;
import script.library.factions;
import script.obj_id;
public class city_spawner extends script.base_script
{
+16 -111
View File
@@ -1,123 +1,28 @@
package script.city;
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.dictionary;
import script.obj_id;
import script.library.ai_lib;
public class city_wander extends script.base_script
public class city_wander extends script.city.base.base_wander
{
public String[] patrolPoints =
{
"city1",
"city2",
"city3",
"city4",
"city5",
"city6"
};
public city_wander()
{
}
public static final String[] patrolPoints =
{
"city1",
"city2",
"city3",
"city4",
"city5",
"city6"
};
public int OnAttach(obj_id self) throws InterruptedException
{
ai_lib.setDefaultCalmBehavior(self, ai_lib.BEHAVIOR_SENTINEL);
messageTo(self, "pathRandom", null, 1, false);
return SCRIPT_CONTINUE;
}
public int OnInitialize(obj_id self) throws InterruptedException
{
messageTo(self, "pathRandom", null, 1, false);
return SCRIPT_CONTINUE;
}
public int pathRandom(obj_id self, dictionary params) throws InterruptedException
{
ai_lib.setPatrolRandomNamedPath(self, patrolPoints);
return SCRIPT_CONTINUE;
}
public int OnLoiterMoving(obj_id self) throws InterruptedException
{
stop(self);
messageTo(self, "pathRandom", null, 2, false);
return SCRIPT_OVERRIDE;
}
public int OnMovePathComplete(obj_id self) throws InterruptedException
{
messageTo(self, "pathRandom", null, rand(30, 60), false);
return SCRIPT_CONTINUE;
}
public int OnMovePathNotFound(obj_id self) throws InterruptedException
{
if (hasObjVar(self, "checkingFeet"))
{
int checked = getIntObjVar(self, "checkingFeet");
if (checked > 10)
{
return SCRIPT_CONTINUE;
}
}
messageTo(self, "pathRandom", null, rand(30, 60), false);
checkForFeetGluedToFloor(self);
return SCRIPT_CONTINUE;
}
public void checkForFeetGluedToFloor(obj_id self) throws InterruptedException
{
if (!hasObjVar(self, "checkingFeet"))
{
setObjVar(self, "checkingFeet", 1);
location here = getLocation(self);
setObjVar(self, "mightBeStuck", here);
messageTo(self, "amIStuck", null, 180, false);
return;
}
else
{
int checked = getIntObjVar(self, "checkingFeet");
checked = checked + 1;
setObjVar(self, "checkingFeet", checked);
if (checked > 10)
{
return;
}
location here = getLocation(self);
setObjVar(self, "mightBeStuck", here);
messageTo(self, "amIStuck", null, 180, false);
return;
}
}
public int amIStuck(obj_id self, dictionary params) throws InterruptedException
{
location now = getLocation(self);
location here = getLocationObjVar(self, "mightBeStuck");
if (now == null || now.equals(here))
{
messageTo(self, "killIt", null, 3, false);
}
else
{
messageTo(self, "cleanUpChecks", null, 10, false);
}
return SCRIPT_CONTINUE;
super.patrolPoints = patrolPoints;
}
public int killIt(obj_id self, dictionary params) throws InterruptedException
{
LOG("NPC_Cleanup", "NPC: " + self + " at " + getLocation(self) + " has cleaned itself up because it couldn't find anyplace to go, according to the City_Wander script.");
destroyObject(self);
return SCRIPT_CONTINUE;
}
public int cleanUpChecks(obj_id self, dictionary params) throws InterruptedException
{
int checks = getIntObjVar(self, "checkingFeet");
if (checks > 0)
{
checks = checks - 1;
setObjVar(self, "checkingFeet", checks);
}
return SCRIPT_CONTINUE;
return super.killIt(self, params);
}
}
+25 -46
View File
@@ -1,16 +1,9 @@
package script.city;
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.dictionary;
import script.library.create;
import script.library.utils;
import script.library.locations;
import script.obj_id;
public class droid_spawner extends script.base_script
{
@@ -41,12 +34,9 @@ public class droid_spawner extends script.base_script
{
return SCRIPT_OVERRIDE;
}
int stringCheck = text.indexOf("max");
String population = text.substring(text.indexOf(" ") + 1, text.length());
int maxPop = utils.stringToInt(population);
if (stringCheck > -1)
if (text.contains("max"))
{
setObjVar(self, "pop", maxPop);
setObjVar(self, "pop", utils.stringToInt(text.substring(text.indexOf(" ") + 1, text.length())));
}
if (text.equals("killall"))
{
@@ -74,8 +64,6 @@ public class droid_spawner extends script.base_script
}
public int startSpawning(obj_id self, dictionary params) throws InterruptedException
{
obj_id spawner = getSelf();
int maxPop = getIntObjVar(self, "pop");
if (!hasObjVar(self, "current"))
{
setObjVar(self, "current", 1);
@@ -83,39 +71,32 @@ public class droid_spawner extends script.base_script
}
else
{
int currentPop = getIntObjVar(self, "current");
if (currentPop <= maxPop)
if (getIntObjVar(self, "current") <= getIntObjVar(self, "pop"))
{
doSpawn(self);
}
else
{
return SCRIPT_OVERRIDE;
}
}
return SCRIPT_CONTINUE;
}
public void doSpawn(obj_id self) throws InterruptedException
{
int currentPop = getIntObjVar(self, "current");
int maxPop = getIntObjVar(self, "pop");
location me = getLocation(self);
String spawn = npcToSpawn();
obj_id npc = create.object(spawn, me);
obj_id npc = create.object(spawn, getLocation(self));
attachScript(npc, "city.droid_wander");
setInvulnerable(npc, true);
setObjVar(self, "spawn." + currentPop, npc);
setObjVar(npc, "spawnNum", "spawn." + currentPop);
currentPop = currentPop + 1;
setObjVar(self, "current", currentPop);
setObjVar(self, "current", ++currentPop);
messageTo(self, "startSpawning", null, 10, true);
return;
}
public void killAll(obj_id self) throws InterruptedException
{
int increment = 1;
int totalBodies = getIntObjVar(self, "pop");
while (increment <= totalBodies)
while (increment <= getIntObjVar(self, "pop"))
{
obj_id npcToKill = getObjIdObjVar(self, "spawn." + increment);
if (npcToKill != null)
@@ -123,36 +104,34 @@ public class droid_spawner extends script.base_script
destroyObject(npcToKill);
removeObjVar(self, "spawn." + increment);
}
increment = increment + 1;
increment++;
}
removeObjVar(self, "current");
removeObjVar(self, "spawn");
return;
}
public String npcToSpawn() throws InterruptedException
{
int choice = rand(1, 6);
String spawn = "commoner";
switch (choice)
switch (rand(1, 6))
{
case 1:
spawn = "cll8_binary_load_lifter";
break;
spawn = "cll8_binary_load_lifter";
break;
case 2:
spawn = "eg6_power_droid";
break;
spawn = "eg6_power_droid";
break;
case 3:
spawn = "r2";
break;
spawn = "r2";
break;
case 4:
spawn = "r3";
break;
spawn = "r3";
break;
case 5:
spawn = "r4";
break;
spawn = "r4";
break;
case 6:
spawn = "r5";
break;
spawn = "r5";
break;
}
return spawn;
}
+33 -35
View File
@@ -1,22 +1,18 @@
package script.city;
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.dictionary;
import script.library.ai_lib;
import script.library.utils;
import script.location;
import script.obj_id;
public class droid_wander extends script.base_script
public class droid_wander extends script.city.base.base_wander
{
public droid_wander()
{
super.patrolPoints = patrolPoints;
}
public static final String[] patrolPoints =
public final String[] patrolPoints =
{
"droid1",
"droid2",
@@ -29,31 +25,26 @@ public class droid_wander extends script.base_script
public static final int PATH_FAILURES_MAXIMUM = 5;
public int OnAttach(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnAttach enter");
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.OnAttach enter");
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
ai_lib.setDefaultCalmBehavior(self, ai_lib.BEHAVIOR_SENTINEL);
messageTo(self, "pathRandom", null, 1, false);
return SCRIPT_CONTINUE;
return super.OnAttach(self);
}
public int OnInitialize(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnInitialize enter name: " + getName(self));
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.OnInitialize enter name: " + getName(self));
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
messageTo(self, "pathRandom", null, 1, false);
return SCRIPT_CONTINUE;
return super.OnAttach(self);
}
public int OnLoiterMoving(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnLoiterMoving enter name: " + getName(self));
stop(self);
messageTo(self, "pathRandom", null, 2, false);
return SCRIPT_OVERRIDE;
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.OnLoiterMoving enter name: " + getName(self));
return super.OnLoiterMoving(self);
}
public int pathRandom(obj_id self, dictionary params) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.pathRandom enter name: " + getName(self));
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.pathRandom enter name: " + getName(self));
params = new dictionary();
params.put("pathVerifyTime", getGameTime());
messageTo(self, "pathVerify", params, PATH_VERIFICATION_TIME - 1, false);
@@ -63,7 +54,7 @@ public class droid_wander extends script.base_script
}
else
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.pathRandom setting patrol points");
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.pathRandom setting patrol points");
ai_lib.setPatrolRandomNamedPath(self, patrolPoints);
}
return SCRIPT_CONTINUE;
@@ -77,38 +68,46 @@ public class droid_wander extends script.base_script
int timeCompleted = utils.getIntScriptVar(self, "path.timeCompleted");
int lastVerify = utils.getIntScriptVar(self, "path.pathVerifyTime");
int pathFailures = utils.getIntScriptVar(self, "path.pathFailures");
location lastPathLocation = utils.getLocationScriptVar(self, "path.lastLocation");
int gameTime = getGameTime();
int pathVerifyTime = params.getInt("pathVerifyTime");
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.pathVerify enter name: " + getName(self));
String name = getName(self);
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.pathVerify enter - name: " + name);
if (lastVerify > pathVerifyTime)
{
return SCRIPT_CONTINUE;
}
utils.setScriptVar(self, "path.pathVerifyTime", pathVerifyTime);
params = new dictionary();
params.put("pathVerifyTime", gameTime);
if (timeCompleted + PATH_VERIFICATION_TIME > gameTime)
{
messageTo(self, "pathVerify", params, PATH_VERIFICATION_TIME - 1, false);
return SCRIPT_CONTINUE;
}
float distance = utils.getDistance2D(getLocation(self), lastPathLocation);
utils.setScriptVar(self, "path.lastLocation", getLocation(self));
if (distance > 1.0f)
{
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.pathVerify() found the distance between now and last check to be " + distance + " meters. name: " + getName(self));
utils.setScriptVar(self, "path.timeCompleted", gameTime);
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.pathVerify() found the distance between now and last check to be " + distance + " meters. name: " + name);
messageTo(self, "pathVerify", params, PATH_VERIFICATION_TIME - 1, false);
return SCRIPT_CONTINUE;
}
if (pathFailures > PATH_FAILURES_MAXIMUM)
{
LOG("guard_wander", "Patrol pathfinding failures exceeded (5). Stopping self: " + self + " getName: " + getName(self) + " at " + getLocation(self));
LOG("droid_wander", "Patrol pathfinding failures exceeded (5). Stopping self: " + self + " getName: " + name + " at " + getLocation(self));
stop(self);
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
messageTo(self, "pathRandom", params, 600, false);
return SCRIPT_CONTINUE;
}
@@ -117,23 +116,22 @@ public class droid_wander extends script.base_script
ai_lib.resumeFormationFollowing(self);
return SCRIPT_CONTINUE;
}
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.pathVerify() messaging pathRandom() for " + getName(self) + " pathFailures: " + pathFailures);
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.pathVerify() messaging pathRandom() for " + name + " pathFailures: " + pathFailures);
pathFailures++;
utils.setScriptVar(self, "path.pathFailures", pathFailures);
messageTo(self, "pathRandom", params, 3, false);
return SCRIPT_CONTINUE;
}
public int OnMovePathComplete(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnMovePathComplete enter name: " + getName(self));
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.OnMovePathComplete enter name: " + getName(self));
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
messageTo(self, "pathRandom", null, rand(30, 60), false);
return SCRIPT_CONTINUE;
return super.OnMovePathComplete(self);
}
public int OnMovePathNotFound(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnMovePathNotFound enter name: " + getName(self));
LOGC(aiLoggingEnabled(self), "debug_ai", "droid_wander.OnMovePathNotFound enter name: " + getName(self));
messageTo(self, "pathRandom", null, rand(30, 60), false);
return SCRIPT_CONTINUE;
}
+6 -12
View File
@@ -1,18 +1,11 @@
package script.city;
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.dictionary;
import script.library.*;
import script.location;
import script.obj_id;
import script.library.ai_lib;
import script.library.create;
import script.library.utils;
import script.library.locations;
import script.library.gcw;
import java.util.Vector;
public class guard_spawner extends script.base_script
{
@@ -318,6 +311,7 @@ public class guard_spawner extends script.base_script
}
}
}
float imp_r = gcw.getImperialPercentileByRegion(self);
float reb_r = gcw.getRebelPercentileByRegion(self);
if (imp_r >= reb_r)
+18 -26
View File
@@ -1,30 +1,27 @@
package script.city;
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.dictionary;
import script.library.ai_lib;
import script.library.utils;
import script.location;
import script.obj_id;
public class guard_wander extends script.base_script
public class guard_wander extends script.city.base.base_wander
{
public static final String[] patrolPoints =
{
"patrol1",
"patrol2",
"patrol3",
"patrol4",
"patrol5",
"patrol6"
};
public guard_wander()
{
super.patrolPoints = patrolPoints;
}
public static final String[] patrolPoints =
{
"patrol1",
"patrol2",
"patrol3",
"patrol4",
"patrol5",
"patrol6"
};
public static final int PATH_VERIFICATION_TIME = 30;
public static final int PATH_FAILURES_MAXIMUM = 5;
public int OnAttach(obj_id self) throws InterruptedException
@@ -32,25 +29,20 @@ public class guard_wander extends script.base_script
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnAttach enter");
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
ai_lib.setDefaultCalmBehavior(self, ai_lib.BEHAVIOR_SENTINEL);
messageTo(self, "pathRandom", null, 1, false);
removeObjVar(self, "combat.intCombatXP");
return SCRIPT_CONTINUE;
return super.OnAttach(self);
}
public int OnInitialize(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnInitialize enter name: " + getName(self));
utils.setScriptVar(self, "path.timeCompleted", getGameTime());
utils.setScriptVar(self, "path.pathFailures", 0);
messageTo(self, "pathRandom", null, 1, false);
return SCRIPT_CONTINUE;
return super.OnInitialize(self);
}
public int OnLoiterMoving(obj_id self) throws InterruptedException
{
LOGC(aiLoggingEnabled(self), "debug_ai", "guard_wander.OnLoiterMoving enter name: " + getName(self));
stop(self);
messageTo(self, "pathRandom", null, 2, false);
return SCRIPT_OVERRIDE;
return super.OnLoiterMoving(self);
}
public int pathRandom(obj_id self, dictionary params) throws InterruptedException
{