mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-14 23:07:51 -04:00
47 lines
1.7 KiB
Java
Executable File
47 lines
1.7 KiB
Java
Executable File
package script.systems.battlefield;
|
|
|
|
import script.dictionary;
|
|
import script.library.battlefield;
|
|
import script.obj_id;
|
|
import script.region;
|
|
|
|
public class battlefield_spawner extends script.base_script
|
|
{
|
|
public battlefield_spawner()
|
|
{
|
|
}
|
|
public static final String VAR_NUMBER_SPAWNS = "battlefield.number_spawns";
|
|
public int OnInitialize(obj_id self) throws InterruptedException
|
|
{
|
|
setObjVar(self, battlefield.VAR_SPAWNER_CURRENT_POPULATION, 0);
|
|
setObjVar(self, battlefield.VAR_SPAWNER_CURRENT, 0);
|
|
int pulse = getIntObjVar(self, battlefield.VAR_SPAWNER_PULSE);
|
|
messageTo(self, "msgBattlefieldSpawn", null, pulse, false);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public int msgBattlefieldSpawn(obj_id self, dictionary params) throws InterruptedException
|
|
{
|
|
LOG("LOG_CHANNEL", "battlefield_spawner::msgBattlefieldSpawn -- " + self);
|
|
int num_spawns = 0;
|
|
if (hasObjVar(self, VAR_NUMBER_SPAWNS))
|
|
{
|
|
num_spawns = getIntObjVar(self, VAR_NUMBER_SPAWNS);
|
|
}
|
|
int max_spawns = getIntObjVar(self, battlefield.VAR_SPAWNER_MAX);
|
|
int pulse = getIntObjVar(self, battlefield.VAR_SPAWNER_PULSE);
|
|
region bf = battlefield.getBattlefield(self);
|
|
if (bf == null)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id master_object = battlefield.getMasterObjectFromRegion(bf);
|
|
battlefield.createRandomSpawn(master_object, self);
|
|
num_spawns--;
|
|
if (num_spawns < max_spawns)
|
|
{
|
|
messageTo(self, "msgBattlefieldSpawn", null, pulse, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|