mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
129 lines
4.2 KiB
Java
Executable File
129 lines
4.2 KiB
Java
Executable File
package script.theme_park.warren;
|
|
|
|
import script.ai.ai;
|
|
import script.library.ai_lib;
|
|
import script.library.chat;
|
|
import script.library.utils;
|
|
import script.modifiable_float;
|
|
import script.obj_id;
|
|
import script.string_id;
|
|
|
|
public class trooper extends script.base_script
|
|
{
|
|
public trooper()
|
|
{
|
|
}
|
|
public static final String CONVO_FILE = "theme_park/warren/warren";
|
|
public static final String ALERT_VOLUME_NAME = "alertVolume";
|
|
public static final String ACTION_ALERT = "alert";
|
|
public static final String ACTION_THREATEN = "threaten";
|
|
private static final boolean AI_TRIGGER_VOLUMES_DISABLED = utils.checkConfigFlag("GameServer", "disableAITriggerVolumes");
|
|
private static final boolean AI_COMBAT_DISABLED = utils.checkConfigFlag("GameServer", "disableAICombat");
|
|
|
|
public int OnAttach(obj_id self) throws InterruptedException
|
|
{
|
|
if (!hasObjVar(self, "ai.diction"))
|
|
{
|
|
setObjVar(self, "ai.diction", "military");
|
|
}
|
|
if (!AI_TRIGGER_VOLUMES_DISABLED)
|
|
{
|
|
createTriggerVolume(ALERT_VOLUME_NAME, 15.0f, true);
|
|
}
|
|
setObjVar(self, "ai.rangedOnly", true);
|
|
if (!hasObjVar(self, "ai.grenadeType"))
|
|
{
|
|
setObjVar(self, "ai.grenadeType", "object/weapon/ranged/grenade/grenade_fragmentation");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnTriggerVolumeEntered(obj_id self, String volumeName, obj_id breacher) throws InterruptedException
|
|
{
|
|
if (hasObjVar(breacher, "gm"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (ai_lib.isInCombat(self) || ai_lib.isInCombat(breacher))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (breacher == self)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (isIncapacitated(self) || ai_lib.isAiDead(breacher))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (!isPlayer(breacher))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (utils.hasScriptVar(breacher, "warren.flaggedImperial"))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (volumeName.equals(ALERT_VOLUME_NAME) && !ai_lib.isInCombat(self))
|
|
{
|
|
if (rand(1, 10) == 1)
|
|
{
|
|
if (getGender(breacher) == Gender.MALE)
|
|
{
|
|
chat.chat(self, new string_id(CONVO_FILE, "trooper_greeting_m"));
|
|
}
|
|
else
|
|
{
|
|
chat.chat(self, new string_id(CONVO_FILE, "trooper_greeting_f"));
|
|
}
|
|
}
|
|
startCombat(self, breacher);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnSawAttack(obj_id self, obj_id defender, obj_id[] attackers) throws InterruptedException
|
|
{
|
|
if (AI_COMBAT_DISABLED)
|
|
{
|
|
setWantSawAttackTriggers(self, false);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (ai_lib.isAiDead(self) || isInvulnerable(self))
|
|
{
|
|
setWantSawAttackTriggers(self, false);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
if (ai_lib.isInCombat(self))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (hasScript(defender, "theme_park.warren.trooper"))
|
|
{
|
|
startCombat(self, attackers[rand(0, attackers.length - 1)]);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
for (obj_id attacker : attackers) {
|
|
if (hasScript(attacker, "theme_park.warren.trooper")) {
|
|
startCombat(self, defender);
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnMoveMoving(obj_id self) throws InterruptedException
|
|
{
|
|
aiEquipPrimaryWeapon(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnMovePathComplete(obj_id self) throws InterruptedException
|
|
{
|
|
aiEquipPrimaryWeapon(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int OnLoiterWaiting(obj_id self, modifiable_float time) throws InterruptedException
|
|
{
|
|
aiEquipPrimaryWeapon(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|