eastern-flames/eastern flames/scripts/weapon/weapon.gml

83 lines
3.3 KiB
Plaintext
Raw Normal View History

2022-08-16 02:04:23 +00:00
global.weapons = {};
#macro wp global.weapons
2022-08-16 03:25:26 +00:00
function weapon(name_, description_, type_, statmods=[]) constructor {
2022-08-16 02:04:23 +00:00
name = name_;
description = description_;
2022-08-16 03:25:26 +00:00
type = WPTYPE.SWORD;
2022-08-16 22:28:01 +00:00
modifiers = {};
2022-08-16 02:58:13 +00:00
var i;
for (i=0; i<array_length(statmods); i++) {
modifiers[$statmods[i].name] = statmods[i];
}
2022-08-16 03:25:26 +00:00
global.weapons[$name] = self;
2022-08-16 02:04:23 +00:00
}
2022-08-16 03:25:26 +00:00
enum WPTYPE {
NULL,
SWORD,
LEAF,
GUN,
2022-08-16 02:04:23 +00:00
}
2022-08-16 03:25:26 +00:00
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_) {
2022-08-16 22:39:22 +00:00
c_fulleval(target);
2022-08-16 03:25:26 +00:00
}
nu weapon("nothing", "it's literally nothing", WPTYPE.NULL);
2022-08-16 22:28:01 +00:00
nu weapon("knife", "bleed, bleed", WPTYPE.SWORD, [new statmod(st.str, 20, add), new statmod(st.hit, 100, add)]);
nu weapon("iron sword", "made of a cringe material", WPTYPE.SWORD, [new statmod(st.str, 6, add), new statmod(st.hit, 90, add)]);
nu weapon("Blade", "it's blade.", WPTYPE.SWORD, [new statmod(st.str, 6, add), new statmod(st.hit, 90, add)]);
nu weapon("Maple Leaf", "eh? not going for true end?", WPTYPE.SWORD, [new statmod(st.str, 5, add), new statmod(st.hit, 95, add)]);
nu weapon("Microlaser", "special science laser instead of magic!", WPTYPE.SWORD, [new statmod(st.str, 4, add), new statmod(st.hit, 90, add)]);
nu weapon("Wrench", "a wrench of a common material", WPTYPE.SWORD, [new statmod(st.str, 9, add), new statmod(st.hit, 60, add)]);
2022-08-22 23:13:28 +00:00
nu weapon("Healgun", "heal-ish gun", WPTYPE.SWORD, [new statmod(st.str, 0, add), new statmod(st.str, -1, mult), new statmod(st.hit, 100, add)]);
nu weapon("Bayonet", "it's out of ammo...", WPTYPE.SWORD, [new statmod(st.str, 9, add), new statmod(st.hit, 90, add)]);
nu weapon("Rifle", "it has ammo, i guess", WPTYPE.SWORD, [new statmod(st.str, 6, add), new statmod(st.hit, 80, add), new statmod(st.rng, 1, add)]);
nu weapon("Lunar Machete", "sick", WPTYPE.SWORD, [new statmod(st.str, 9, add), new statmod(st.hit, 90, add)]);
nu weapon("Glock", "gang shit", WPTYPE.SWORD, [new statmod(st.str, 4, add), new statmod(st.hit, 95, add)]);
nu weapon("Sniper Rifle", "gang shit", WPTYPE.SWORD, [new statmod(st.str, 11, add), new statmod(st.hit, 100, add)]);
2022-08-22 23:13:28 +00:00
2022-08-23 06:49:38 +00:00
nu weapon("Bottle", "it was full, just a minute ago...", WPTYPE.SWORD, [new statmod(st.str, 10, add), new statmod(st.hit, 33, add)]);
2022-08-16 03:25:26 +00:00
2022-08-16 02:04:23 +00:00
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);
2022-08-16 03:25:26 +00:00
if i >= array_length(dudes) break;
2022-08-16 02:04:23 +00:00
}
2022-08-16 03:25:26 +00:00
if i >= array_length(dudes) break;
2022-08-16 02:04:23 +00:00
target.data[$dudes[i]].val = target.data[$dudes[i]].cap;
}
}
2022-08-16 22:39:22 +00:00
function c_modeval(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]) {
2022-08-16 03:25:26 +00:00
target.data[$dudes[i]].val = weapon_.modifiers[$dudes[i]].operation(
target.data[$dudes[i]].val,
weapon_.modifiers[$dudes[i]].val
);
2022-08-16 02:58:13 +00:00
}
}
}
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
}