OSP - RAGE

Users who are viewing this thread

A rage osp that basicly gives you a one time rage giving minor benefits till you die, made to strengthen heroism.
Im planning to make it hp percentage based in the future but im very busy at the moment

Code:
common_battle_prepare = (
  ti_once, 0, 0, [],
  [
  (assign, "$rage", 0), #reset every battle
  (assign, "$kill", 0), #reset first blood
  ])
	
common_battle_rage = (
  ti_on_agent_hit, 0, 0, [],
  [
	(get_player_agent_no, ":player"),
	(store_trigger_param_1, ":hit_agent"),
	(eq, ":hit_agent", ":player"), #when player is hit
	(store_agent_hit_points, ":playerhp", ":player"),
	(try_begin),
		(ge, ":playerhp", 51), 
		# do nothing YET
	(else_try),
	    (ge, ":playerhp", 38),
		(display_message, "@You feel a rage coming up!"),
	(else_try),
		(gt, ":playerhp", 0),
		(display_message, "@When on the edge of dead real hero's awake!", 0x6495ed),
		(val_add, ":playerhp", 17),
		(agent_set_hit_points, ":player", ":playerhp"),
		(agent_set_invulnerable_shield, ":player"),
		(agent_refill_ammo, ":player"),
        (agent_set_damage_modifier, ":player", 170), #damage = damage x 1.7
		(agent_set_accuracy_modifier, ":player", 170), #damage = damage x 1.7
		(agent_set_speed_modifier, ":player", 130), #damage = damage x 1.7
		(agent_set_reload_speed_modifier, ":player", 170), #damage = damage x 1.7
		(agent_set_use_speed_modifier , ":player", 170), #damage = damage x 1.7
		(agent_set_ranged_damage_modifier , ":player", 170), #damage = damage x 1.7
		
		#taunting  
		(get_player_agent_no, ":player_agent"),
        (agent_get_position, pos1, ":player_agent"),
		(store_character_level,":level","trp_player"),
		(val_mul,":level",2),
		(val_add,":level",1),

		(try_for_agents,":agent"),
			(set_fixed_point_multiplier, 1),
			(agent_is_alive,":agent"),
			(agent_is_human,":agent"),
			(neg|agent_is_ally,":agent"),
			(agent_get_troop_id,":trp_agent", ":agent"),
			(store_character_level,":troop_level",":trp_agent"),
			(ge,":level",":troop_level"),
			(agent_get_position, pos2, ":agent"),
			(get_distance_between_positions,":distance",pos2,pos1),
			(lt,":distance",500),
			
			(set_fixed_point_multiplier, 10),
			
			(position_get_x,":player_x",pos1),
			(position_get_y,":player_y",pos1),
			(position_get_x,":enemy_x",pos2),
			(position_get_y,":enemy_y",pos2),

			(store_sub,":difference_x",":enemy_x",":player_x"),
			(val_mul,":difference_x",12),

			(store_sub,":difference_y",":enemy_y",":player_y"),
			(val_mul,":difference_y",12),
		 
			(val_add,":enemy_x",":difference_x"),
			(val_add,":enemy_y",":difference_y"),
		 
			(position_set_x,pos2,":enemy_x"),
			(position_set_y,pos2,":enemy_y"),
		 
			(agent_set_scripted_destination,":agent",pos2,1),
		(try_end),	

		(display_message,"@You unleash a fearsome cry!",0x6495ed),
        (set_fixed_point_multiplier, 1),   
		#taunting end
		
		#rallying
		(play_sound,"snd_man_warcry"),
		(try_begin),
			(agent_get_class ,":blah", ":player_agent"),
			(neq,":blah",grc_cavalry),
			#(agent_set_animation, ":player_agent", "anim_cheer"),
		(try_end),
		(store_skill_level,":leadership","skl_leadership","trp_player"),
		(val_mul,":leadership",3),
		(try_for_agents,":agent"),
			(agent_is_alive,":agent"),
			(agent_is_human,":agent"),
			(agent_is_ally,":agent"),
			(neg|eq,":agent",":player_agent"),
			(store_agent_hit_points,":life",":agent",0),
			(agent_get_class ,":blah", ":agent"),
			(neq,":blah",grc_cavalry),
			(agent_set_animation, ":agent", "anim_cheer"),
			(val_add,":life",":leadership"),
			(agent_set_hit_points,":agent",":life",0),	
			(agent_play_sound, ":agent", "snd_man_victory"),
		(try_end), 	 
		(display_message,"@You rally your men! (wounded troops recover {reg1} % hitpoints)",0x6495ed),		   
		#rallying end
	(try_end),
    ])

How to implent
"
Put the commons between the existing commons in module mission templates
put the common names in the mission templates you would like to use it in:
common_battle_rage,
common_battle_prepare,
 
Your code is yet pretty messy.
There is room for a couple of optimizations.

First off, when you check (within a condition block) if the agent's hp is greater than a certain amount, then you don't need to check for the opposite within the next Else block.
(try_begin),
(ge, ":playerhp", 51),
# do nothing YET
(else_try),
  (ge, ":playerhp", 3:cool:,
#(le, ":playerhp", 50), no need to ceck for... its allways less than 51 here
(display_message, "@You feel a rage coming up!"),
(else_try),
#(gt, ":playerhp", 0), thats the last else block, so no need to check for anything, its also less then 38 down here
#(lt, ":playerhp", 3:cool:, same here

Your two try_for_agent loops can be easily combined into a single loop.
There is also no real need to constantly change the fixed point multiplier, keeping it at 100 will just work fine. (requires a few changes to your values, though)
 
_Sebastian_ said:
Your code is yet pretty messy.
There is room for a couple of optimizations.

First off, when you check (within a condition block) if the agent's hp is greater than a certain amount, then you don't need to check for the opposite within the next Else block.
(try_begin),
(ge, ":playerhp", 51),
# do nothing YET
(else_try),
  (ge, ":playerhp", 3:cool:,
#(le, ":playerhp", 50), no need to ceck for... its allways less than 51 here
(display_message, "@You feel a rage coming up!"),
(else_try),
#(gt, ":playerhp", 0), thats the last else block, so no need to check for anything, its also less then 38 down here
#(lt, ":playerhp", 3:cool:, same here

Your two try_for_agent loops can be easily combined into a single loop.
There is also no real need to constantly change the fixed point multiplier, keeping it at 100 will just work fine. (requires a few changes to your values, though)

Thanks, i should have checked it first.
about the no condition in the last block thing, i dont agree about that as we need to check if agent is alive, otherwise we give boosts and penalties to nearby friends and enemies while whe should not.
could ofcourse also be done with (agent_is_alive, ":playeragent"), but
 
builder of the gods said:
about the no condition in the last block thing, i dont agree about that as we need to check if agent is alive, otherwise we give boosts and penalties to nearby friends and enemies while whe should not.
could ofcourse also be done with (agent_is_alive, ":playeragent"), but
The victim agent is allways alive when the hit trigger fires.
Actual damaging happens after this trigger, so the stored victim hp didn't get subtracted by the damage yet.
 
_Sebastian_ said:
builder of the gods said:
about the no condition in the last block thing, i dont agree about that as we need to check if agent is alive, otherwise we give boosts and penalties to nearby friends and enemies while whe should not.
could ofcourse also be done with (agent_is_alive, ":playeragent"), but
The victim agent is allways alive when the hit trigger fires.
Actual damaging happens after this trigger, so the stored victim hp didn't get subtracted by the damage yet.

Exactly the damage is not dealt yet
So if my player has 29 hp and will recieve 40 damage the code SHOULD NOT trigger

So that should be a condition then? Or not?
 
Then you need to check if the damage is less than the agent hp.
Code:
	(store_trigger_param, ":hit_agent", 1),
	(store_trigger_param, ":damage", 3),

	(get_player_agent_no, ":player"),
	(eq, ":hit_agent", ":player"), #when player is hit
	(store_agent_hit_points, ":playerhp", ":player", 1),#get the absolute hp value
	(lt, ":damage", ":playerhp"),#still alive

	(store_agent_hit_points, ":playerhp", ":player", 0),#now get the relative hp, for your percentage hp conditions
	(try_begin),
		(gt, ":playerhp", 50), 
		# do nothing YET
	(else_try),
		(gt, ":playerhp", 37),
		(display_message, "@You feel a rage coming up!"),
	(else_try),
		(display_message, "@When on the edge of dead real hero's awake!", 0x6495ed),
 
builder of the gods said:
So that should be a condition then? Or not?

not just a condition, but you also need to guarantee the call order. If you have other triggers (for hit detection) after yours, they may change the damage and mess with your code.

imagine you have a trigger for critical damage (double/triple/etc), among other effects.

you could also use the current trigger just to detect the hit event, and a normal trigger to execute it (that way you can check player hp outside the hit event).
 
Back
Top Bottom