yeah pretty good.
This commit is contained in:
parent
48c1a3af7a
commit
9cdac2b47e
4 changed files with 45 additions and 13 deletions
|
@ -1,19 +1,43 @@
|
|||
global.weapons = {};
|
||||
#macro wp global.weapons
|
||||
function weapon(name_, description_, statmods) constructor {
|
||||
function weapon(name_, description_, type_, statmods=[]) constructor {
|
||||
name = name_;
|
||||
description = description_;
|
||||
modifiers = {};
|
||||
type = WPTYPE.SWORD;
|
||||
var i;
|
||||
for (i=0; i<array_length(statmods); i++) {
|
||||
modifiers[$statmods[i].name] = statmods[i];
|
||||
}
|
||||
global.weapons[$name] = self;
|
||||
}
|
||||
|
||||
function c_addweapon(target, weapon_) {
|
||||
array_push(target.inventory, deep_copy(weapon_));
|
||||
enum WPTYPE {
|
||||
NULL,
|
||||
SWORD,
|
||||
LEAF,
|
||||
GUN,
|
||||
}
|
||||
|
||||
function c_addweapon(target, weapon_, equip=false) {
|
||||
//array_push(target.inventory, deep_copy(weapon_));
|
||||
array_push(target.inventory, weapon_);
|
||||
if equip {
|
||||
target.equippedweapon = array_length(target.inventory)-1;
|
||||
c_equipweapon(target, target.inventory[target.equippedweapon]);
|
||||
}
|
||||
}
|
||||
|
||||
function c_equipweapon(target, weapon_) {
|
||||
log(target.data.str.val);
|
||||
c_modifierreset(target);
|
||||
log(target.data.str.val);
|
||||
c_wpeval(target, weapon_);
|
||||
log(target.data.str.val);
|
||||
}
|
||||
nu weapon("nothing", "it's literally nothing", WPTYPE.NULL);
|
||||
nu weapon("knife", "bleed, bleed", WPTYPE.SWORD, [new statmod(st.str, 20, add)]);
|
||||
|
||||
function c_modifierreset(target) {
|
||||
var dudes = variable_struct_get_names(target.data);
|
||||
var lads = variable_struct_get_names(st);
|
||||
|
@ -21,8 +45,9 @@ function c_modifierreset(target) {
|
|||
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;
|
||||
}
|
||||
if i > array_length(dudes) break;
|
||||
if i >= array_length(dudes) break;
|
||||
target.data[$dudes[i]].val = target.data[$dudes[i]].cap;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +58,10 @@ function c_wpeval(target, weapon_) {
|
|||
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);
|
||||
target.data[$dudes[i]].val = weapon_.modifiers[$dudes[i]].operation(
|
||||
target.data[$dudes[i]].val,
|
||||
weapon_.modifiers[$dudes[i]].val
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue