Merge branch 'quality_assurance' of bitbucket.org:projectswg/holocore into quality_assurance

This commit is contained in:
Obique PSWG
2017-05-05 09:14:40 -05:00
5 changed files with 6673 additions and 6892 deletions
File diff suppressed because one or more lines are too long
+5 -5
View File
@@ -1,5 +1,5 @@
npc_id attackable difficulty combat_level npc_name stf_name niche comment iff_template planet offers_mission social_group faction spec_force scale_min scale_max hue ignore_player attack_speed movement_speed primary_weapon primary_weapon_speed primary_weapon_specials secondary_weapon secondary_weapon_speed secondary_weapon_specials aggressive assist stalker herd death_blow skillmods Damagelevelmodifier StatLevelModifier ToHitLevelModifier ArmorLevelModifier armor_blast armor_stun armor_kinetic armor_energy armor_heat armor_cold armor_electric armor_acid immune_mez immune_root immune_snare immune_stun immune_taunt canNotPunish minDrainModifier maxDrainModifier minFaucetModifier maxFaucetModifier min_cash max_cash loot_rolls loot_table1_chance loot_table1 loot_table2_chance loot_table2 loot_table3_chance loot_table3 collectionRoll collectionLoot col_faction chronicleLootChance chronicleLootCategory resources milk_type meat_amount meat_type hide_amount hide_type bone_amount bone_type extractable_dna geneProfile canTame wildAbilityList
TEXT PRIMARY KEY TEXT NOT NULL TEXT NOT NULL INTEGER NOT NULL TEXT TEXT TEXT TEXT TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL REAL NOT NULL REAL NOT NULL INTEGER TEXT NOT NULL REAL REAL TEXT REAL NOT NULL TEXT TEXT REAL TEXT INTEGER INTEGER TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER REAL INTEGER REAL REAL INTEGER INTEGER INTEGER INTEGER TEXT INTEGER TEXT INTEGER TEXT INTEGER TEXT TEXT INTEGER TEXT TEXT NOT NULL TEXT NOT NULL INTEGER TEXT NOT NULL INTEGER TEXT NOT NULL INTEGER TEXT NOT NULL TEXT NOT NULL TEXT REAL TEXT
npc_creature.sdb TRUE
npc_droid.sdb TRUE
npc_humanoid.sdb TRUE
npc_id attackable difficulty combat_level npc_name stf_name niche comment iff_template planet offers_mission social_group faction spec_force scale_min scale_max hue grant_skill ignore_player attack_speed movement_speed primary_weapon primary_weapon_speed primary_weapon_specials secondary_weapon secondary_weapon_speed secondary_weapon_specials aggressive assist stalker herd death_blow skillmods Damagelevelmodifier StatLevelModifier ToHitLevelModifier ArmorLevelModifier armor_blast armor_stun armor_kinetic armor_energy armor_heat armor_cold armor_electric armor_acid immune_mez immune_root immune_snare immune_stun immune_taunt canNotPunish minDrainModifier maxDrainModifier minFaucetModifier maxFaucetModifier min_cash max_cash loot_rolls loot_table1_chance loot_table1 loot_table2_chance loot_table2 loot_table3_chance loot_table3 collectionRoll collectionLoot col_faction chronicleLootChance chronicleLootCategory resources milk_type meat_amount meat_type hide_amount hide_type bone_amount bone_type extractable_dna geneProfile canTame wildAbilityList
TEXT PRIMARY KEY TEXT NOT NULL TEXT NOT NULL INTEGER NOT NULL TEXT TEXT TEXT TEXT TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL REAL NOT NULL REAL NOT NULL INTEGER TEXT TEXT NOT NULL REAL REAL TEXT REAL NOT NULL TEXT TEXT REAL TEXT INTEGER INTEGER TEXT NOT NULL TEXT NOT NULL TEXT NOT NULL TEXT INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER REAL INTEGER REAL REAL INTEGER INTEGER INTEGER INTEGER TEXT INTEGER TEXT INTEGER TEXT INTEGER TEXT TEXT INTEGER TEXT TEXT NOT NULL TEXT NOT NULL INTEGER TEXT NOT NULL INTEGER TEXT NOT NULL INTEGER TEXT NOT NULL TEXT NOT NULL TEXT REAL TEXT
npc_creature.sdb TRUE
npc_droid.sdb TRUE
npc_humanoid.sdb TRUE
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+40 -1
View File
@@ -43,9 +43,12 @@ import com.projectswg.common.data.location.Terrain;
import com.projectswg.common.data.swgfile.ClientFactory;
import com.projectswg.common.debug.Log;
import java.util.Random;
import intents.object.DestroyObjectIntent;
import intents.object.ObjectCreatedIntent;
import intents.server.ConfigChangedIntent;
import resources.PvpFlag;
import resources.config.ConfigFile;
import resources.containers.ContainerPermissionsType;
@@ -80,11 +83,13 @@ public final class SpawnerService extends Service {
private final ObjectManager objectManager;
private final Map<Long, Spawner> spawnerMap;
private final ScheduledExecutorService executorService;
private final Random random;
public SpawnerService(ObjectManager objectManager) {
this.objectManager = objectManager;
executorService = Executors.newSingleThreadScheduledExecutor(ThreadUtilities.newThreadFactory("spawner-service"));
spawnerMap = new HashMap<>();
random = new Random();
registerForIntent(ConfigChangedIntent.class, cci -> handleConfigChangedIntent(cci));
registerForIntent(DestroyObjectIntent.class, doi -> handleDestroyObjectIntent(doi));
@@ -284,7 +289,7 @@ public final class SpawnerService extends Service {
private long createNPC(Spawner spawner) {
DefaultAIObject object = ObjectCreator.createObjectFromTemplate(spawner.getRandomIffTemplate(), DefaultAIObject.class);
object.setLocation(spawner.getLocation());
object.setLocation(behaviorLocation(spawner));
object.setObjectName(spawner.getCreatureName());
object.setLevel(spawner.getCombatLevel());
object.setDifficulty(spawner.getCreatureDifficulty());
@@ -329,4 +334,38 @@ public final class SpawnerService extends Service {
spawnerMap.values().forEach(spawner -> new DestroyObjectIntent(spawner.getSpawnerObject()).broadcast());
spawnerMap.clear();
}
private Location behaviorLocation(Spawner spawner) {
Location aiLocation = new Location(spawner.getLocation());
switch (spawner.getAIBehavior()) {
case FLOAT:
// Random location within float radius of spawner and
int floatRadius = spawner.getFloatRadius();
int offsetX = randomBetween(0, floatRadius);
int offsetZ = randomBetween(0, floatRadius);
spawner.setFloatRadius(floatRadius);
aiLocation.setPosition(aiLocation.getX() + offsetX, aiLocation.getY(), aiLocation.getZ() + offsetZ);
// Doesn't break here - FLOAT NPCs also have GUARD behavior
case GUARD:
// Random heading when spawned
int randomHeading = randomBetween(0, 360); // Can't use negative numbers as minimum
aiLocation.setHeading(randomHeading); // -180 to 180
break;
}
return aiLocation;
}
/**
* Generates a random number between from (inclusive) and to (inclusive)
* @param from a positive minimum value
* @param to maximum value, which is larger than the minimum value
* @return a random number between the two, both inclusive
*/
private int randomBetween(int from, int to) {
return random.nextInt((to - from) + 1) + from;
}
}