OSP Code QoL Injury, stumbling, hardship & bleeding.

Currently Viewing (Users: 0, Guests: 1)

troycall

Squire
WB
Best answers
0
Damage consequences, injury effects, bleeding, stumbling & hardship.
Improvements to-do: Add traits gain-able by kill/damage, positive buffs.

This is NOT my best work, but I feel like maybe someone can make use out of it, good luck!

Code:
		("stumbling",[ #This script is to be called once every 1-2 seconds in module_mission_templates.
		
		#Add the subsequent enclosed assign commands below to game_start script in module_scripts:
		###Start game_start script
		#(assign, "$consequences_multiplier", 5), #Value_multiplier, should be divisible by 5
		#(assign, "$Modifiers_frequency", 5), #Frequency of the optimizer for stumbling, bleeding, etc. lower value = more likely (1 lowest)
		#(assign, "$minimum_health_for_lowest_speed_5x", 100), #Minimum health for lowest speed this should be 5x the value of the above global variable.
		#(assign, "$minimum_health_for_modifiers_2xp5_main_modifier", 50), #Minimum health for all consequences to scan, this should be 2.5x the consequences global variable value.
		#(assign, "$minimum_health_for_consequences", 20), #Minimum health for all consequences to scan
		#(assign, "$particle_size_bleed_minimum", 2), #Minimum bleed particle size (Default: 2)
		#(assign, "$particle_size_bleed_maximum", 5), #Maximum bleed particle size (Default: 5)
		#(assign, "$bleed_intensity_minimum", 1), #Bleed intensity, how much health agent should lose minimum value (Default: 1)
		#(assign, "$bleed_intensity_maximum", 10), #Bleed intensity, how much agent should lose maximum value (Default: 10)
                #(assign,  "$stumbling_enabled", 1), 
		###End game_start script


		(eq,  "$stumbling_enabled", 1), 
		(store_random_in_range, ":Optimizer", 0, "$Modifiers_frequency"), #Likelihood of script firing
		(eq, ":Optimizer", 0),
        (get_player_agent_no, ":agent_player"),
	    (try_for_agents,":agent"), #Check for all agents in template, this isn't necessary if triggering this script when agent is hit by another agent, rather than scanning every once in a while.
	    (neq, ":agent", -1), #Agent is actually an agent
		#(neq, ":agent", ":agent_player"), #(OPTIONAL) Agent is not a player
		(agent_is_alive, ":agent"),
		(agent_is_human, ":agent"),	
		(agent_is_active, ":agent"),
	  #(agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't fleeing the battle.
	  #Old check, is agent using a horse? -- No thanks.
	  #(agent_get_horse, ":var1", ":agent"), #Is the agent on a horse?
      #(eq, ":var1", -1), #Agent not using a horse 
	  #End old check
	  (store_agent_hit_points, ":hp", ":agent", 0), #Retrieve agent health (percentile rather than absolute)
	  (assign, ":hp_secondvar", ":hp"),
	  (le, ":hp_secondvar", "$minimum_health_for_consequences"), #Less or equal to 20 def
	  (val_mul, ":hp_secondvar", "$consequences_multiplier"),
	  
	  #Speed modifier
	  (try_begin),
	  (le, ":hp_secondvar", "$minimum_health_for_lowest_speed_5x"), 
	  (agent_set_speed_modifier, ":agent", 50), #Lowest speed possible
	  (agent_set_damage_modifier, ":agent", 50), #Lowest damage possible
	  (try_begin), #Bleeding modifier
	  (store_random_in_range, ":Chance_of_wound", 0, ":hp_secondvar"),
	  (lt, ":Chance_of_wound", 10), #Bleeding frequency, the higher this number is, the more likely to bleed.
	    (agent_get_position, pos7, ":agent"), #Get Agent Position
		#Extend to include horsemen
		(agent_get_horse, ":rider", ":agent"), #Retrieve weither agent is using a horse or not
	   (try_begin),
	   (eq, ":rider", -1), #If agent is not mounted on a horse
       (position_move_z, pos7, 120), #Up/Down
       (position_move_x, 3, 10), #Left/Right
       (position_move_y, pos7, 30), #Forward/Back 10 def
	   
	   (else_try), #If agent is riding a mount
	   (position_move_z, pos7, 188), #Up/Down
       (position_move_x, 3, 10), #Left/Right
       (position_move_y, pos7, 30), #Forward/Back 10 def
		(try_end),
		(store_random_in_range, ":psys_to_use", "psys_game_blood", "psys_game_hoof_dust"), #Randomize between these two
		(store_random_in_range, ":pick_one", 0, 2),
		(store_random_in_range, ":particle_size", "$particle_size_bleed_minimum", "$particle_size_bleed_maximum"), 
		(try_begin),
		(eq, ":pick_one", 0),
		(particle_system_burst, "psys_lanse_blood", pos7, ":particle_size"), #lanse_blood is a custom effect, just replace with game_blood.
		(else_try),
		(eq, ":pick_one", 1),
		(particle_system_burst, "psys_blood_decapitation", pos7, ":particle_size"),
		(try_end),
		(particle_system_burst, ":psys_to_use", pos7, ":particle_size"), 
	  (store_random_in_range, ":bleed_intensity", "$bleed_intensity_minimum", "$bleed_intensity_maximum"), 
	  (val_sub, ":hp", ":bleed_intensity"), 
	  (agent_set_hit_points, ":agent", ":hp",0),
	  (assign, ":hp_secondvar", ":hp"), #Agent lost health, so lets refresh to make it more likely for them to stumble.
	  (val_mul, ":hp_secondvar", "$consequences_multiplier"), #Hotfix
	  (try_end),	#Bleeding modifier end
	  
	  (gt, ":hp_secondvar", "$minimum_health_for_modifiers_2xp5_main_modifier"), #Lowest speed possible 50 default
	  (agent_is_alive, ":agent"),
	  (agent_set_speed_modifier, ":agent", ":hp_secondvar"), #Set speed defined on health * 5 (when below 20% health)
	  (agent_set_damage_modifier, ":agent", ":hp_secondvar"),
	  (try_end),
	  
	  #New horse check, only for stumbling
	  (agent_is_alive, ":agent"),
	  (agent_get_horse, ":var1", ":agent"), #Is the agent on a horse?
      (eq, ":var1", -1), #Agent not using a horse 
	  
      (store_skill_level, ":var2", "skl_athletics", ":agent"), #Retrieve player skill level of atheletics
	  (store_random_in_range, ":var3", 0, ":hp_secondvar"), #Randomize chance  #Debug
	  
	      #BEGIN DEBUG
          #(assign, reg10, ":var3"),
          #(str_clear, s10),
          #(str_store_string, s10, "@Randomizer value: {reg10}"),
		  #(display_message, s10),
          #END DEBUG
	  
        (val_mul, ":var2", 3), #Take atheletics to consideration by multiplaying it by 3 store as var2
        (store_sub, ":var4", 23, ":var2"), #Reduce 23 by var2, then put all into var4.
        (lt, ":var3", ":var4"), #If var3 is lower number than var4, continue the operations. 
		
		  #BEGIN DEBUG
          #(assign, reg10, ":var4"),
          #(str_clear, s10),
          #(str_store_string, s10, "@Store_sub final value: {reg10}"),
		  #(display_message, s10),
          #END DEBUG
		
		#Debug
		#(display_message, "@Oops, someone tripped!", 0x00FF0000),
		(store_random_in_range, ":animation_to_play", 0, 3),
		(store_random_in_range, ":Rarity", 0, 30),
		(try_begin),
		(eq, ":animation_to_play", 0),	
		(agent_set_animation, ":agent", "anim_strike_chest_front_stop"),
		(else_try),
		(eq, ":animation_to_play", 1),
		(eq, ":Rarity", 0),
		(agent_set_animation, ":agent", "anim_strike_fall_back_rise"), #Make me super rare
		(else_try),
		(eq, ":animation_to_play", 2),	
		(agent_set_animation, ":agent", "anim_strike_fall_back_rise_upper"),
		(try_end),
		
		(try_begin),
		(eq, ":agent", ":agent_player"), #If agent is player_agent
		(val_add, "$notify_stumble", 1),
		(try_begin),
		(gt, "$notify_stumble", 10),
		(assign, "$notify_stumble", 0),
		(try_end),
		(eq, "$notify_stumble", 1),
        (display_message, "@Your injury is too painful.", 0x00FF0000),
		(try_end),
		
		(store_random_in_range, ":sound_to_play", 0, 2),
        (try_begin),
          (eq, ":sound_to_play", 0),
          (agent_play_sound, ":agent", "snd_body_fall_small"),
        (else_try),
          (eq, ":sound_to_play", 1),
          (agent_play_sound, ":agent", "snd_body_fall_big"),
        (try_end),
	  (try_end), 
	]), 
 

troycall

Squire
WB
Best answers
0
HarryPham123 said:
this is used for mission_template ??
Up to you, I just made it as a script and call it every 1-2 seconds with call_script in module_mission_templates.