blades-engine read creature data
This commit is contained in:
187
projects/blades-engine/source/data/CreatureData.hx
Normal file
187
projects/blades-engine/source/data/CreatureData.hx
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
package data;
|
||||||
|
|
||||||
|
using Type;
|
||||||
|
using Reflect;
|
||||||
|
import kiss.Prelude;
|
||||||
|
|
||||||
|
enum MeleeAbility {
|
||||||
|
Poison;
|
||||||
|
Slow;
|
||||||
|
Disease;
|
||||||
|
Sleep;
|
||||||
|
Paralyze;
|
||||||
|
Acid;
|
||||||
|
Fire;
|
||||||
|
Cold;
|
||||||
|
DrainXP;
|
||||||
|
ColdDrainXP;
|
||||||
|
Web;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RayAbility {
|
||||||
|
CurseAndWeaken;
|
||||||
|
TurnToStone;
|
||||||
|
Charm;
|
||||||
|
Sleep;
|
||||||
|
Paralyze;
|
||||||
|
DrainSP;
|
||||||
|
Confuse;
|
||||||
|
Terrify;
|
||||||
|
Fire;
|
||||||
|
MagicDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ThrowAbility {
|
||||||
|
Web4; // range 4
|
||||||
|
Rocks;
|
||||||
|
Spines; // damage and paralysis
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FieldAbility {
|
||||||
|
Fire;
|
||||||
|
Cold;
|
||||||
|
AntiMagic;
|
||||||
|
Sleep;
|
||||||
|
Stink;
|
||||||
|
Blade;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BreathAbility {
|
||||||
|
Fire;
|
||||||
|
Cold;
|
||||||
|
Acid;
|
||||||
|
Darkness;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SpecialAbility {
|
||||||
|
None;
|
||||||
|
Melee(a: MeleeAbility);
|
||||||
|
Ray(a: RayAbility);
|
||||||
|
Throw(a: ThrowAbility);
|
||||||
|
Radiate(a: FieldAbility);
|
||||||
|
Breath(a: BreathAbility);
|
||||||
|
Invisible;
|
||||||
|
SplitsWhenHit;
|
||||||
|
ForceCage;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Attitude {
|
||||||
|
Friendly;
|
||||||
|
Neutral;
|
||||||
|
HostileA;
|
||||||
|
HostileB;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Species {
|
||||||
|
Human;
|
||||||
|
Humanoid;
|
||||||
|
Nephil; // bonus missle weapons and dexterity
|
||||||
|
Slith; // bonus pole weapons and fire resistance
|
||||||
|
Giant;
|
||||||
|
Reptile; // won't pick up or use items
|
||||||
|
Beast; // same
|
||||||
|
Demon; // same + vulnerable to Repel Spirit at high levels + immune to mental spells
|
||||||
|
Undead; // same + vulnerable to Repel Spirit + same
|
||||||
|
Insect; // same + immune to mental spells + immune to webs
|
||||||
|
SlimeOrPlant; // same + same + immune to assassination
|
||||||
|
StoneOrGolem; // same + same + immune to beams
|
||||||
|
Special; // immune to assassination and lethal blow. Immune to simulacrum. Immune to webs.
|
||||||
|
Vahnatai;
|
||||||
|
Other;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AttackType {
|
||||||
|
Strike;
|
||||||
|
Claw;
|
||||||
|
Bite;
|
||||||
|
Slimes;
|
||||||
|
Punches;
|
||||||
|
Stings;
|
||||||
|
Clubs;
|
||||||
|
Burns;
|
||||||
|
Harms;
|
||||||
|
Stabs;
|
||||||
|
Kicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum StrategyType {
|
||||||
|
Default;
|
||||||
|
ArcherOrCaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef Strategy = {
|
||||||
|
type: StrategyType,
|
||||||
|
persistentTarget: Bool
|
||||||
|
};
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class CreatureData {
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function clone():CreatureData {
|
||||||
|
var cd = new CreatureData();
|
||||||
|
for (field in CreatureData.getInstanceFields()) {
|
||||||
|
cd.setField(field, this.field(field));
|
||||||
|
}
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public var name:String = "";
|
||||||
|
public var default_script:String = "basicnpc";
|
||||||
|
public var level = 2;
|
||||||
|
public var hp_bonus = 0;
|
||||||
|
public var sp_bonus = 0;
|
||||||
|
private var special_abil = 0;
|
||||||
|
// specialAbility() defined in kiss file
|
||||||
|
|
||||||
|
private var default_attitude = 2;
|
||||||
|
public function defaultAttitude() {
|
||||||
|
return Attitude.createEnumIndex(default_attitude - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private var species = 0;
|
||||||
|
public function getSpecies() {
|
||||||
|
return Species.createEnumIndex(species);
|
||||||
|
}
|
||||||
|
public var natural_armor = 0;
|
||||||
|
public var attack_1 = 0;
|
||||||
|
public var attack_2 = 0;
|
||||||
|
public var attack_3 = 0;
|
||||||
|
private var attack_1_type = 0;
|
||||||
|
public function attack1Type() {
|
||||||
|
return AttackType.createEnumIndex(attack_1_type);
|
||||||
|
}
|
||||||
|
private var attack_23_type = 0;
|
||||||
|
public function attack23Type() {
|
||||||
|
return AttackType.createEnumIndex(attack_23_type);
|
||||||
|
}
|
||||||
|
public var ap_bonus = 0;
|
||||||
|
private var default_strategy = 0;
|
||||||
|
public function defaultStrategy():Strategy {
|
||||||
|
return {
|
||||||
|
type: StrategyType.createEnumIndex(default_strategy % 10),
|
||||||
|
persistentTarget: default_strategy >= 10
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private var default_aggression = 100;
|
||||||
|
public function defaultAggression() {
|
||||||
|
return default_aggression / 100.0;
|
||||||
|
}
|
||||||
|
private var default_courage = 100;
|
||||||
|
public function defaultCourage() {
|
||||||
|
return default_courage / 100.0;
|
||||||
|
}
|
||||||
|
public var which_sheet = 0;
|
||||||
|
public var icon_adjust = 0;
|
||||||
|
private var small_or_large_template = 0;
|
||||||
|
public var which_sheet_upper = -1;
|
||||||
|
public var summon_class = -1;
|
||||||
|
private var what_stat_adjust:Array<Int> = [];
|
||||||
|
private var amount_stat_adjust:Array<Int> = [];
|
||||||
|
private var start_item:Array<Int> = [];
|
||||||
|
private var start_item_chance:Array<Int> = [];
|
||||||
|
private var immunities:Array<Int> = [];
|
||||||
|
|
||||||
|
// TODO public functions that return and contextualize the array variables
|
||||||
|
}
|
41
projects/blades-engine/source/data/CreatureData.kiss
Normal file
41
projects/blades-engine/source/data/CreatureData.kiss
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
(method specialAbility []
|
||||||
|
(case special_abil
|
||||||
|
(0 None)
|
||||||
|
(1 (Melee Poison))
|
||||||
|
(2 (Ray CurseAndWeaken))
|
||||||
|
(3 (Ray TurnToStone))
|
||||||
|
(4 (Melee Slow))
|
||||||
|
(5 (Throw Web4))
|
||||||
|
(6 (Melee Disease))
|
||||||
|
(7 (Ray Charm))
|
||||||
|
(8 (Melee Sleep))
|
||||||
|
(9 (Ray Sleep))
|
||||||
|
(10 (Melee Paralyze))
|
||||||
|
(11 (Ray Paralyze))
|
||||||
|
(12 (Melee Acid))
|
||||||
|
(13 (Ray DrainSP))
|
||||||
|
(14 (Ray Confuse))
|
||||||
|
(15 (Ray Terrify))
|
||||||
|
(16 (Throw Rocks))
|
||||||
|
(17 (Breath Fire))
|
||||||
|
(18 (Breath Cold))
|
||||||
|
(19 (Breath Acid))
|
||||||
|
(20 (Melee Fire))
|
||||||
|
(21 (Melee Cold))
|
||||||
|
(22 (Melee DrainXP))
|
||||||
|
(23 (Melee ColdDrainXP))
|
||||||
|
(24 Invisible)
|
||||||
|
(26 (Radiate Fire))
|
||||||
|
(27 (Radiate Cold))
|
||||||
|
(28 (Radiate AntiMagic))
|
||||||
|
(29 SplitsWhenHit)
|
||||||
|
(30 (Ray Fire))
|
||||||
|
(32 (Ray MagicDamage))
|
||||||
|
(33 (Breath Darkness))
|
||||||
|
(34 (Throw Spines))
|
||||||
|
(35 ForceCage)
|
||||||
|
(36 (Melee Web))
|
||||||
|
(37 (Radiate Sleep))
|
||||||
|
(38 (Radiate Stink))
|
||||||
|
(39 (Radiate Blade))
|
||||||
|
(otherwise (throw "undefined special_abil"))))
|
@@ -4,6 +4,7 @@ import hscript.Parser;
|
|||||||
import hscript.Interp;
|
import hscript.Interp;
|
||||||
import sys.io.File;
|
import sys.io.File;
|
||||||
|
|
||||||
|
using Reflect;
|
||||||
using StringTools;
|
using StringTools;
|
||||||
|
|
||||||
class ScenData {
|
class ScenData {
|
||||||
@@ -11,6 +12,7 @@ class ScenData {
|
|||||||
|
|
||||||
public var floorData:Map<Int, FloorData> = [];
|
public var floorData:Map<Int, FloorData> = [];
|
||||||
public var terrainData:Map<Int, TerrainData> = [];
|
public var terrainData:Map<Int, TerrainData> = [];
|
||||||
|
public var creatureData:Map<Int, CreatureData> = [];
|
||||||
|
|
||||||
static var failed:Array<String> = [];
|
static var failed:Array<String> = [];
|
||||||
static var passed = 0;
|
static var passed = 0;
|
||||||
@@ -33,6 +35,10 @@ class ScenData {
|
|||||||
assert(floorData[129].which_sheet == 704, "floors can import other floors' data");
|
assert(floorData[129].which_sheet == 704, "floors can import other floors' data");
|
||||||
assert(floorData[129].specialProperty() == BlockedToNPCs, "blocked special property becomes enum");
|
assert(floorData[129].specialProperty() == BlockedToNPCs, "blocked special property becomes enum");
|
||||||
assert(terrainData[12].name == "Door", "door is door");
|
assert(terrainData[12].name == "Door", "door is door");
|
||||||
|
assert(terrainData[404].name == "Hitching Post", "multi-token name string");
|
||||||
|
|
||||||
|
assert(creatureData[23].field("start_item")[2] == 55, "array properties (nephil starter item)");
|
||||||
|
assert(creatureData[23].field("start_item_chance")[2] == 100, "array properties (nephil starter item)");
|
||||||
|
|
||||||
trace('$passed assertions passed');
|
trace('$passed assertions passed');
|
||||||
if (failed.length > 0) {
|
if (failed.length > 0) {
|
||||||
@@ -59,6 +65,8 @@ class ScenData {
|
|||||||
floorData;
|
floorData;
|
||||||
case "terrain":
|
case "terrain":
|
||||||
terrainData;
|
terrainData;
|
||||||
|
case "creature":
|
||||||
|
creatureData;
|
||||||
default:
|
default:
|
||||||
null;
|
null;
|
||||||
};
|
};
|
||||||
@@ -80,6 +88,8 @@ class ScenData {
|
|||||||
new FloorData();
|
new FloorData();
|
||||||
case "terrain":
|
case "terrain":
|
||||||
new TerrainData();
|
new TerrainData();
|
||||||
|
case "creature":
|
||||||
|
new CreatureData();
|
||||||
default:
|
default:
|
||||||
null;
|
null;
|
||||||
};
|
};
|
||||||
@@ -120,11 +130,28 @@ class ScenData {
|
|||||||
line = "data." + line.substr(3);
|
line = "data." + line.substr(3);
|
||||||
} else if (line.startsWith("te_")) {
|
} else if (line.startsWith("te_")) {
|
||||||
line = "data." + line.substr(3);
|
line = "data." + line.substr(3);
|
||||||
|
} else if (line.startsWith("cr_")) {
|
||||||
|
line = "data." + line.substr(3);
|
||||||
} else if (line == "clear;") {
|
} else if (line == "clear;") {
|
||||||
line = "clear();";
|
line = "clear();";
|
||||||
} else if (line.startsWith("import =")) {
|
} else if (line.startsWith("import =")) {
|
||||||
line = "_" + line.replace("=", "(").replace(";", ");");
|
line = "_" + line.replace("=", "(").replace(";", ");");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wrap array assignments:
|
||||||
|
if (line.startsWith("data.")) {
|
||||||
|
var tokens = line.split(" ");
|
||||||
|
var isString = false;
|
||||||
|
for (token in tokens) {
|
||||||
|
if (token.indexOf('"') != -1)
|
||||||
|
isString = true;
|
||||||
|
}
|
||||||
|
// <thing> = <value> or <thing> <index> = <value>
|
||||||
|
if (!isString && tokens.length > 3) {
|
||||||
|
line = tokens[0] + '[${tokens[1]}] = ' + tokens[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
interp.execute(parser.parseString(line));
|
interp.execute(parser.parseString(line));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user