OSP Code QoL Code dump - new notifications, first blood, heroism, city buildings

Users who are viewing this thread

builder of the gods

Sergeant at Arms
First blood
Code:
first_blood = (
   ti_on_agent_killed_or_wounded, 0, 0, [],
   [
		(try_begin),
			(eq, "$kill", 0), #no kills yet
			(set_show_messages, 1),
			(display_message, "@First blood!", 0xff0000),
			(set_show_messages, 0),
			(assign, "$kill", 1),
		(try_end),
   ])

Rage mode
Code:
common_battle_rage = (
  ti_on_agent_hit, 0, 0, [],
  [
	#general gore
	#(particle_system_burst, "psys_decap_blood", pos0, 5),
	#(particle_system_burst, "psys_decap_blood", pos0, 5),
	#actual rage code
	(set_show_messages, 0),
	(get_player_agent_no, ":player"),
		(store_trigger_param_1, ":hit_agent"),
	(eq, ":hit_agent", ":player"), #when player is hit
	(neq, "$rageused", 1),
	(store_trigger_param, ":damage", 3),
	(store_agent_hit_points, ":playerhp", ":player"),
	(try_begin),
		(ge, ":playerhp", 51), 
		(lt, ":damage", ":playerhp"),
		# do nothing YET
	(else_try),
	    (ge, ":playerhp", 38),
		(le, ":playerhp", 50),
		(lt, ":damage", ":playerhp"),
		(set_show_messages, 1),
		(display_message, "@Heavily wounded, you take one last look at the sky!",0x6495ed),
		(display_message, "@Inspired by the air you breathe,",0x6495ed),
		(display_message, "@The pain rushing trough your body,",0x6495ed),
		(display_message, "@You feel a power coming up from the depths of your body.",0x6495ed),
		(set_show_messages, 0),
	(else_try),
		(assign, "$rageused", 1),
		(set_show_messages, 1),
		(display_message, "@Adrenaline rushes trough your body, nearby death inspires you to heroics", 0x6495ed),
		(set_show_messages, 0),
		(val_add, ":playerhp", 27),
		(agent_set_hit_points, ":player", ":playerhp"),
		(agent_set_invulnerable_shield, ":player"),
        (agent_set_damage_modifier, ":player", 175), #damage = damage x 1.7
		(agent_set_accuracy_modifier, ":player", 175), #damage = damage x 1.7
		(agent_set_speed_modifier, ":player", 137), #damage = damage x 1.37
		(agent_set_reload_speed_modifier, ":player", 175), #damage = damage x 1.7
		(agent_set_use_speed_modifier , ":player", 175), #damage = damage x 1.7
		(agent_set_ranged_damage_modifier , ":player", 175), #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),	

        (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"),
			(assign, reg1, ":leadership"),
			(agent_set_hit_points,":agent",":life",0),	
			(agent_play_sound, ":agent", "snd_man_victory"),
		(try_end), 	 
		(set_show_messages, 1),
		#(display_message,"@You rally your men! (wounded troops recover {reg1} % hitpoints)",0x6495ed),
		(set_show_messages, 0),		
		(set_trigger_result, 0),
		#rallying end
	(try_end),
    ])

Notification system
Code:
common_battle_prepare = (
  ti_once, 0, 0, [],
  [
  (assign, "$rageused", 0), #reset every battle
  (assign, "$kill", 0), #reset first blood
  (assign, "$g_stop_ballista_fire", 0),
  (assign, "$notificationmode", 0),
  (assign, "$refill", 0),
  (assign, "$dead_enemies", 0),
  (assign, "$dead_enemiest", 0),
  (assign, "$dead_friendlies", 0),
  (assign, "$dead_friendliest", 0),
  ])

common_battle_notifications = (
  20, 0, 0, [],
	[
	(assign, reg1, "$dead_friendlies"),
	(assign, reg2, "$dead_enemies"),	
	(assign, reg3, "$dead_friendliest"),
	(assign, reg4, "$dead_enemiest"),	
	(set_show_messages, 1),
	(display_message, "@fresh casualties: {reg1}",0xC85D46),
	(display_message, "@fresh killed hostiles: {reg2}",0x85C846),
		(try_begin),
		(gt, "$dead_friendlies", "$dead_enemies"),
		(assign, ":difference", "$dead_friendlies"),
		(val_sub, ":difference", "$dead_enemies"), 
		(try_begin),
			(gt, ":difference", 10),
			(display_message, "@We are taking serious losses",0xC85D46),
		(else_try),  #smaller then 10
			(gt, ":difference", 5),
			(display_message, "@We are taking losses",0xC85D46),
		(else_try),  
			(display_message, "@We are taking slight losses",0xC85D46),
		(try_end),
	(else_try),
		(eq, "$dead_friendlies", "$dead_enemies"),
		(display_message, "@The balance of powers is equal",0xDFD848),
	(else_try),
		(lt, "$dead_friendlies", "$dead_enemies"),
		(assign, ":difference", "$dead_enemies"),
		(val_sub, ":difference", "$dead_friendlies"), 
		(try_begin),
			(gt, ":difference", 10),
			(display_message, "@We are taking enemy lives rapidly",0x85C846),
		(else_try),  #smaller then 10
			(gt, ":difference", 5),
			(display_message, "@We are taking enemy lives",0x85C846),
		(else_try),
			(display_message, "@We are taking enemy lives slowly",0x85C846),
		(try_end),
	(try_end),
	(display_message, "@Total balance: {reg3} losses, {reg4} kills",0xDFD848),
	(set_show_messages, 0),
	(assign, "$dead_friendlies", 0), #reset values
	(assign, "$dead_enemies", 0),
    ])

common_bearer_down = ( #also functions to check how many death hostiles and friendlies
  ti_on_agent_killed_or_wounded, 0, 0, [],
  [
	(store_trigger_param, ":dead", 1),
	(agent_is_human, ":dead"),
	(try_begin),
		(agent_is_ally, ":dead"),
		(val_add, "$dead_friendlies", 1),
		(val_add, "$dead_friendliest", 1),
	(else_try),
		(agent_get_troop_id, ":troop", ":dead"),
		(val_add, "$dead_enemies", 1),
		(val_add, "$dead_enemiest", 1),
	(try_end),
  ])

Photos
Notification system (left bottom)
mb67.jpg

More things
I made a functional building system with certain buffs and debuffs and even pre battle building notifications, the code is to much to drop here tho, so send me a message if interested
WILL BE EXPANDED UPON
 

builder of the gods

Sergeant at Arms
for the people who asked about the building system, here is the code

the system works as following
- you can build new buildings for money in the game menu
- they will add defender bonuses (extra defenders/small battle advantages/morale boosts etc etc)
- there is a display at the begin of a battle showing the defenders extra bonuses
- you can give certain cities extra defences before the game starts with this
 
Top Bottom