yeah pretty good.
This commit is contained in:
		
							parent
							
								
									48c1a3af7a
								
							
						
					
					
						commit
						9cdac2b47e
					
				
					 4 changed files with 45 additions and 13 deletions
				
			
		|  | @ -3,6 +3,7 @@ var i; | |||
| /*for (i=0; i<array_length(global.units[ARMY.US]); i++) { | ||||
| 	c_inheritunit(2+i, 2, un.chara); | ||||
| }*/ | ||||
| c_inheritunit(2, 2, un.chara); | ||||
| var chara = c_inheritunit(2, 2, un.chara); | ||||
| c_addweapon(chara, wp.knife, true); | ||||
| c_inheritunit(3, 2, un.kris); | ||||
| selectedunit = noone; | ||||
|  | @ -8,6 +8,9 @@ returnpos = new vec2(0, 0); | |||
| dir = DIR.NONE; | ||||
| attacks = 0; | ||||
| attacked = 0; | ||||
| inventory = []; | ||||
| c_addweapon(id, wp.nothing); | ||||
| equippedweapon = noone; | ||||
| 
 | ||||
| continuecombat = function(me, them) { | ||||
| 	//if stamina returnable = true stamina-- return true | ||||
|  |  | |||
|  | @ -18,27 +18,27 @@ function unitstat(val_, name_, fullname_, desc_, replacements_) : stat(name_, fu | |||
| 	modifier = 0; | ||||
| } | ||||
| 
 | ||||
| function statmod(stat__, amount_, operation_=add) { | ||||
| function statmod(stat__, val_, operation_=add) constructor { | ||||
| 	name = stat__.name; | ||||
| 	stat_ = stat__; | ||||
| 	amount = amount_; | ||||
| 	val = val_; | ||||
| 	operation = operation_; | ||||
| } | ||||
| 
 | ||||
| function add(val1, val2) { | ||||
| 	return val1*val2; | ||||
| 	return val1 + val2; | ||||
| } | ||||
| function sub(val1, val2) { | ||||
| 	return val1*val2; | ||||
| 	return val1 - val2; | ||||
| } | ||||
| function mult(val1, val2) { | ||||
| 	return val1*val2; | ||||
| 	return val1 * val2; | ||||
| } | ||||
| function divide(val1, val2) { | ||||
| 	return val1*val2; | ||||
| 	return val1 / val2; | ||||
| } | ||||
| function modulo(val1, val2) { | ||||
| 	return val1*val2; | ||||
| 	return val1 % val2; | ||||
| } | ||||
| 
 | ||||
| nu stat("hp", "health", "vitality"); | ||||
|  |  | |||
|  | @ -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