weapons probably work
This commit is contained in:
parent
a537ea5cf2
commit
48c1a3af7a
|
@ -18,6 +18,29 @@ function unitstat(val_, name_, fullname_, desc_, replacements_) : stat(name_, fu
|
||||||
modifier = 0;
|
modifier = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function statmod(stat__, amount_, operation_=add) {
|
||||||
|
name = stat__.name;
|
||||||
|
stat_ = stat__;
|
||||||
|
amount = amount_;
|
||||||
|
operation = operation_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add(val1, val2) {
|
||||||
|
return val1*val2;
|
||||||
|
}
|
||||||
|
function sub(val1, val2) {
|
||||||
|
return val1*val2;
|
||||||
|
}
|
||||||
|
function mult(val1, val2) {
|
||||||
|
return val1*val2;
|
||||||
|
}
|
||||||
|
function divide(val1, val2) {
|
||||||
|
return val1*val2;
|
||||||
|
}
|
||||||
|
function modulo(val1, val2) {
|
||||||
|
return val1*val2;
|
||||||
|
}
|
||||||
|
|
||||||
nu stat("hp", "health", "vitality");
|
nu stat("hp", "health", "vitality");
|
||||||
nu stat("str", "strength", "physical power");
|
nu stat("str", "strength", "physical power");
|
||||||
nu stat("def", "defense", "physical defense");
|
nu stat("def", "defense", "physical defense");
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
global.weapons = {};
|
global.weapons = {};
|
||||||
#macro wp global.weapons
|
#macro wp global.weapons
|
||||||
function weapon(name_, description_, statmod_) constructor {
|
function weapon(name_, description_, statmods) constructor {
|
||||||
name = name_;
|
name = name_;
|
||||||
description = description_;
|
description = description_;
|
||||||
statmod = statmod_;
|
modifiers = {};
|
||||||
|
var i;
|
||||||
|
for (i=0; i<array_length(statmods); i++) {
|
||||||
|
modifiers[$statmods[i].name] = statmods[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function c_addweapon(target, weapon_) {
|
function c_addweapon(target, weapon_) {
|
||||||
|
@ -24,5 +28,17 @@ function c_modifierreset(target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function c_wpeval(target, weapon_) {
|
function c_wpeval(target, weapon_) {
|
||||||
|
var lads = variable_struct_get_names(target.data);
|
||||||
|
var dudes = variable_struct_get_names(weapon_.modifiers);
|
||||||
|
var i;
|
||||||
|
for (i=0; i<array_length(dudes); i++) {
|
||||||
|
if array_contains(lads, dudes[i]) {
|
||||||
|
target.data[$dudes[i]].val = weapon_[$dudes[i]].operation(target.data[$dudes[i]].val, weapon_[$dudes[i]].val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function c_statexists(target, statstring) {
|
||||||
|
var dudes = variable_struct_get_names(target.data);
|
||||||
|
return array_contains(dudes, statstring);
|
||||||
}
|
}
|
Loading…
Reference in New Issue