2022-08-16 02:04:23 +00:00
|
|
|
global.weapons = {};
|
|
|
|
#macro wp global.weapons
|
2022-08-16 02:58:13 +00:00
|
|
|
function weapon(name_, description_, statmods) constructor {
|
2022-08-16 02:04:23 +00:00
|
|
|
name = name_;
|
|
|
|
description = description_;
|
2022-08-16 02:58:13 +00:00
|
|
|
modifiers = {};
|
|
|
|
var i;
|
|
|
|
for (i=0; i<array_length(statmods); i++) {
|
|
|
|
modifiers[$statmods[i].name] = statmods[i];
|
|
|
|
}
|
2022-08-16 02:04:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function c_addweapon(target, weapon_) {
|
|
|
|
array_push(target.inventory, deep_copy(weapon_));
|
|
|
|
}
|
|
|
|
|
|
|
|
function c_modifierreset(target) {
|
|
|
|
var dudes = variable_struct_get_names(target.data);
|
|
|
|
var lads = variable_struct_get_names(st);
|
|
|
|
var i;
|
|
|
|
for (i=0; i<array_length(dudes); i++) {
|
|
|
|
while !array_contains(lads, dudes[i]) || dudes[i] == "hp" {
|
|
|
|
array_delete(dudes, i, 1);
|
|
|
|
}
|
|
|
|
if i > array_length(dudes) break;
|
|
|
|
target.data[$dudes[i]].val = target.data[$dudes[i]].cap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function c_wpeval(target, weapon_) {
|
2022-08-16 02:58:13 +00:00
|
|
|
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);
|
2022-08-16 02:04:23 +00:00
|
|
|
}
|