OSP Code Combat Fatigue / Stamina System

Users who are viewing this thread

I like that players hate me, for that We did a fatigue / stamina system for Brytenwalda  :mrgreen:

However, it look that players dont hate me too, even they said that system like them (I did something bad then  :grin:)

Well, if somebody want use it in his / her mod, here is code for SP and MP. It is simple code, it should be difficult to add and it shouldnt cause conflicts.

Important, you will need change sounds, animations, constats for items and maybe some thing more in accordance your mod. You see that change when you copile.

FEATURES:
Fatigue/stamina system:
- New Staminabar
- You lose stamina when running, attacking or defending.
- Weight (armor and weapons) affect stamina, slowing you down.
- Athletic skill improves your stamina recovery each 4 seconds.
- If stamina is low, you get penalties and you can't fight.

As you can see the possibilities tactics on the battlefield are enormous, making it viable light infantry, trying to outflank with units faster and resistant to fatigue, using guerrilla...

....................................................................

SP:

Mission Template
Code:
#brytenwalda begin
sistema_fatiga = (ti_on_agent_spawn, 0, 0, [(eq, "$sp_fatigas", 1),
],[    #determina fatiga al principio de la batalla para todos
#    (get_player_agent_no, ":player_agent"),

        (store_trigger_param_1, ":agent_no"),

#    (try_for_agents, ":agent_no"),
        (agent_is_alive,":agent_no"), # 
      (agent_is_human, ":agent_no"),

        (store_agent_hit_points,":cur_agent_hp",":agent_no", 1), # stores the hp value of the alive and human players.
        (assign, ":basic_stamina",":cur_agent_hp"),
          (agent_get_troop_id, ":troop", ":agent_no"),
        (store_skill_level, ":fatigue",  "skl_athletics", ":troop"),
        (val_add, ":basic_stamina", ":fatigue"), #obtenemos total fatigue min 60 max 141
        (val_mul, ":basic_stamina", 3), #obtenemos total fatigue min 90 max 210
        (val_div, ":basic_stamina", 2), #obtenemos total fatigue min 90 max 210
        (agent_set_slot, ":agent_no", slot_agent_fatiga_inicial, ":basic_stamina"), #se la aplicamos al agente
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente

           (start_presentation, "prsnt_staminabar"),
##        (try_begin),
##            (eq, ":agent_no", ":player_agent"),
##            (assign, reg1, ":basic_stamina"),
##            (display_message, "@Stamina: {reg1}"),
##        (try_end),
    #(try_end),
    ])

recupera_fatiga = (1, 0, 0, [              
    (this_or_next|game_key_is_down, gk_move_forward),
   (this_or_next|game_key_is_down, gk_move_backward),
    (this_or_next|game_key_is_down, gk_move_left),
   (game_key_is_down, gk_move_right),
    ],[    #determina fatiga al principio de la batalla para todos
        (neg|is_presentation_active, "prsnt_staminabar_multi"),        
       (neg|is_presentation_active, "prsnt_battle"),
        (neg|is_presentation_active, "prsnt_order_display"),
    (neg|main_hero_fallen),

                                         (get_player_agent_no, ":player_no"),
        (agent_is_alive,":player_no"), # 
      (agent_is_human, ":player_no"),
           (start_presentation, "prsnt_staminabar"),
    ])

suma_fatigue = (4, 0, 0, [(eq, "$sp_fatigas", 1),(is_presentation_active, "prsnt_staminabar"),],[    #suma 1 mas agilidad cada 4 segundos
#    (get_player_agent_no, ":player_agent"),

    (try_for_agents, ":agent_no"),
        (agent_is_alive,":agent_no"), #  test for alive players.
      (agent_is_human, ":agent_no"),
        (agent_get_slot, ":basic_stamina", ":agent_no", slot_agent_fatiga),
        (agent_get_slot, ":basic_stamina_i", ":agent_no", slot_agent_fatiga_inicial),
        (lt, ":basic_stamina", ":basic_stamina_i"),

          (agent_get_troop_id, ":troop", ":agent_no"),
        (store_skill_level, ":fatigue",  "skl_athletics", ":troop"),
        (val_add, ":fatigue", 1), #suma agilidad un punto
        (val_add, ":basic_stamina", ":fatigue"), #suma agilidad cada dos segundos
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente
##        (try_begin), #text for testing
##            (eq, ":agent_no", ":player_agent"),
##            (assign, reg1, ":basic_stamina"),
##            (display_message, "@ Sumas Stamina: {reg1}"),
##        (try_end),

    (try_end),  

    ])

resta_fatigue_porcorrer = (3, 0, 0, [(eq, "$sp_fatigas", 1),
    (this_or_next|game_key_is_down, gk_move_forward),
    (this_or_next|game_key_is_down, gk_move_left),
   (game_key_is_down, gk_move_right),
	(neg|key_is_down,key_left_shift), #not walking
                                     ],[

    (neg|main_hero_fallen),
                                         (get_player_agent_no, ":player"),
        (agent_is_alive,":player"), #  test for alive players.
       (agent_is_human, ":player"),
       (agent_get_horse,":agent_mounted",":player"),
           (eq,":agent_mounted",-1),

        (assign, ":stamina_coste", 2),

           (agent_get_item_slot, ":cur_armor", ":player", ek_body),#Here we are getting body armor
            (try_begin),
                (is_between, ":cur_armor", armadura_pesada_begin, armadura_pesada3_end),
               (val_add, ":stamina_coste", 4),
            (else_try),
                (is_between, ":cur_armor", armadura_media_begin, armadura_media_end),
                (val_add, ":stamina_coste", 2),
##           (else_try),
##                (eq, ":cur_armor", itm_no_item), #ni suma ni resta, no tiene nada
           (else_try),
                (is_between, ":cur_armor", desnudos_begin, desnudos_end), #es equipamiento ritual
                (val_sub, ":stamina_coste", 1),
            (try_end),

           (agent_get_item_slot, ":cur_armor", ":player", ek_head),#Here we are getting head armor
                 (try_begin),
                    (is_between, ":cur_armor", yelmos_pesados2_begin, yelmos_pesados2_end),
                    (val_add, ":stamina_coste", 1),
                 (try_end),

             (agent_get_item_slot, ":cur_armor", ":player", ek_foot),#Here we are getting leg armor
             (try_begin),
                 (is_between, ":cur_armor", calzado_pesados_begin, calzado_pesados_end),
                 (val_add, ":stamina_coste", 1),
             (try_end),

             #no heavy gloves in Brytenwalda.
            # (agent_get_item_slot, ":cur_armor", ":agent_no", ek_gloves),#Here we are getting arm armor
            # (try_begin),
                # (is_between, ":cur_armor", guantes_pesados_begin, guantes_pesados_end),
                # (val_add, ":stamina_coste", 1),
            # (try_end),

            #Now for the four armaments every agent may carry
            (agent_get_item_slot,":cur_arma",":player",ek_item_0),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":player",ek_item_1),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":player",ek_item_2),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":player",ek_item_3),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),
   
        (agent_get_slot, ":basic_stamina", ":player", slot_agent_fatiga),
        (val_sub, ":basic_stamina", ":stamina_coste"), #maximo 8 para un hombre totalmente equipado, y minimo 1 para un picto desnudo

        (val_max, ":basic_stamina", 1), #siempre va a restar un minimo de 1
        (agent_set_slot, ":player", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente

        (try_begin), 

        (le, ":basic_stamina", 4),
                                          (agent_set_animation, ":player","anim_strike_fall_back_rise"),
        (agent_play_sound, ":player", "snd_breathing_heavy"), # if the value is one then play death sound.
            (display_message, "@ You're so tired you can barely move a muscle."),
        (try_end),    

    ])


resta_fatigue = (ti_on_agent_hit, 0, 0, [(eq, "$sp_fatigas", 1),],[
    (store_trigger_param_1, ":inflicted_agent"),
    (store_trigger_param_2, ":dealer_agent"),

        (agent_is_alive,":dealer_agent"), #  test for alive players.
   (agent_is_human, ":dealer_agent"),
    (set_trigger_result, -1),
    (get_player_agent_no, ":player_agent"),
    (try_begin),
        (agent_is_alive,":inflicted_agent"), #  test for alive players.
        (agent_is_human, ":inflicted_agent"),    

            (agent_get_wielded_item, ":wielded",":dealer_agent", 0),
        (try_begin),
            (this_or_next|is_between, ":wielded", "itm_wooden_stick", "itm_spatha"), #armas pequenas
            (is_between, ":wielded", "itm_irish_sword", "itm_pictish_longsword"),
            (assign, ":stamina_cost", 1), #pierde fatiga cada golpe.
        (else_try),
            (this_or_next|is_between, ":wielded", "itm_spatha", "itm_irish_sword"),
            (this_or_next|is_between, ":wielded", "itm_staff", "itm_roman_spear_2"),
            (this_or_next|is_between, ":wielded", "itm_sarranid_two_handed_axe_b", "itm_twohand_spear"),
            (this_or_next|is_between, ":wielded", "itm_spear_5", "itm_wessexbanner1"),
            (this_or_next|is_between, ":wielded", "itm_darts", "itm_lyre"),
            (is_between, ":wielded", "itm_pictish_longsword", "itm_battle_axe"),
            (assign, ":stamina_cost", 2), #pierde fatiga cada golpe.
        (else_try),
            (this_or_next|is_between, ":wielded", "itm_battle_axe", "itm_staff"),
            (this_or_next|is_between, ":wielded", "itm_twohand_spear", "itm_sarranid_axe_a"),
            (is_between, ":wielded", "itm_spear_7", "itm_sarranid_two_handed_axe_b"),
            (assign, ":stamina_cost", 4), #pierde fatiga cada golpe.
        (else_try),
            (assign, ":stamina_cost", 2), #pierde fatiga cada golpe.
        (try_end),
##        (try_begin), #integrado en el peso por correr
##            (this_or_next|is_between, ":wielded", "itm_celtic_shield_small_round_a", "itm_h_shield"),
##            (is_between, ":wielded", "itm_tarcze_celtyckie", "itm_tab_shield_small_round_c"),
##            (val_add, ":stamina_cost", 1), #pierde fatiga cada golpe.
##        (try_end),
           (agent_get_slot, ":dealer_stamina", ":dealer_agent", slot_agent_fatiga),
        (val_sub, ":dealer_stamina", ":stamina_cost"),
        (val_max, ":dealer_stamina", 1),
        (agent_set_slot, ":dealer_agent", slot_agent_fatiga, ":dealer_stamina"), #se la aplicamos al agente
        (agent_get_slot, ":inflicted_stamina", ":inflicted_agent", slot_agent_fatiga),
        (val_sub, ":inflicted_stamina", ":stamina_cost"),
        (val_max, ":inflicted_stamina", 1),
        (agent_set_slot, ":inflicted_agent", slot_agent_fatiga, ":inflicted_stamina"), #se la aplicamos al agente

##       (try_begin),
##            (eq, ":dealer_agent", ":player_agent"),
##            (assign, reg1, ":dealer_stamina"),
##            (display_message, "@ restas Stamina: {reg1}"),
##        (else_try),
##            (eq, ":inflicted_agent", ":player_agent"),
##            (assign, reg1, ":inflicted_stamina"),
##            (display_message, "@ restas Stamina por golpe recibido: {reg1}"),
##        (try_end),
    (try_end),

    (agent_get_slot, ":basic_stamina", ":dealer_agent", slot_agent_fatiga),
    (agent_get_slot, ":basic_stamina_i", ":dealer_agent", slot_agent_fatiga_inicial),
    (store_div, ":qua_stamina_i", ":basic_stamina_i", 4),
  #  (store_div, ":half_stamina_i", ":basic_stamina_i", 2),

    (try_begin),
        (lt, ":basic_stamina", 6),
			(agent_set_animation, ":dealer_agent","anim_stand_to_crouch"),
              (agent_play_sound, ":dealer_agent", "snd_breathing_heavy"),
        (try_begin),
            (eq, ":dealer_agent", ":player_agent"),
           (display_message, "@You are exhausted and have no strength to strike!", 0xFF0000),
        (try_end),
   (else_try),
        (lt, ":basic_stamina", ":qua_stamina_i"),
       (eq, ":dealer_agent", ":player_agent"),
       (display_message, "@Your stamina is low. You must rest.", 0xFF0000),
    (try_end),
    ])
#brytenwalda end

In mission template, you need apply this to mt where you want run stamina:

Code:
#brytenwalda begin
sistema_fatiga,
recupera_fatiga,
suma_fatigue,
resta_fatigue_porcorrer,
resta_fatigue,

#brytenwalda end



In Presentations:

Code:
  
#brytenwalda begin
   ("staminabar", prsntf_read_only, 0, [
           (ti_on_presentation_load, [  
        (set_fixed_point_multiplier, 1000),
        (create_mesh_overlay, "$stamina_bar", "mesh_white_plane", "mesh_white_plane"),
        (overlay_set_color, "$stamina_bar", 0x0000bb),

        (get_player_agent_no,":player_agent"),
        (agent_is_active, ":player_agent"),
        (agent_is_alive,":player_agent"), #  test for alive players.
       (agent_is_human, ":player_agent"),
        (agent_get_slot, ":basic_stamina", ":player_agent", slot_agent_fatiga),
        (val_mul,":basic_stamina",52),
        (position_set_x,pos1,":basic_stamina"),
        (position_set_y,pos1,360),
        (overlay_set_size, "$stamina_bar", pos1),
        (position_set_x,pos1,869),
        (position_set_y,pos1,58),
        (overlay_set_position, "$stamina_bar", pos1),

      (presentation_set_duration, 999999),
      ]),
  
    (ti_on_presentation_run, [
      (set_fixed_point_multiplier, 1000),

    (get_player_agent_no, ":player_agent"),    
        (agent_is_active, ":player_agent"),
        (agent_is_alive,":player_agent"), #  test for alive players.
       (agent_is_human, ":player_agent"),
        (agent_get_slot, ":basic_stamina", ":player_agent", slot_agent_fatiga),
        (try_begin),
        (gt, ":basic_stamina", 1),
        (val_mul,":basic_stamina",52),
        (else_try),
        (assign, ":basic_stamina", 1),
        (val_mul,":basic_stamina",52),
        (try_end),
        (position_set_x,pos1,":basic_stamina"),
        (position_set_y,pos1,360),
        (overlay_set_size, "$stamina_bar", pos1),
      ]),
    ]),
#brytenwalda end

.....................................................................

Multiplayer:

Mission template:

Code:
#brytenwalda begin
sistema_fatiga_multi = (ti_on_agent_spawn, 0, 0, [              

    ],[    #determina fatiga al principio de la batalla para todos
        (store_trigger_param_1, ":agent_no"),
		(multiplayer_get_my_player,":player_no"),
           (player_is_active, ":player_no"),
           (neg|player_is_busy_with_menus, ":player_no"),
           # (neg|is_presentation_active, "prsnt_staminabar"),

             (player_get_agent_id, ":my_agent_id",":player_no"),
           (eq, ":agent_no", ":my_agent_id"),
        
        (agent_is_alive,":agent_no"), # 
      (agent_is_human, ":agent_no"),
     #    (neg|agent_is_non_player, ":agent_no"),
        
        (store_agent_hit_points,":cur_agent_hp",":agent_no", 1), # stores the hp value of the alive and human players.
        (assign, ":basic_stamina",":cur_agent_hp"),
        (val_add, ":basic_stamina", 16), #obtenemos total fatigue min 60 max 141
        (agent_set_slot, ":agent_no", slot_agent_fatiga_inicial, ":basic_stamina"), #se la aplicamos al agente
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente
    
           (start_presentation, "prsnt_staminabar_multi"),
        #    (try_end),
#    (try_end),
    ])

recupera_fatiga_multi = (0, 0, 3, [
(game_key_clicked, gk_attack),
 #(game_key_is_down, gk_attack),
       # (key_clicked, gk_attack),
            ],[    #determina fatiga al principio de la batalla para todos
 
	  (multiplayer_get_my_player, ":my_player"),
           (neg|player_is_busy_with_menus, ":my_player"),
           (player_is_active, ":my_player"),
	  (player_get_agent_id, ":my_agent", ":my_player"),
      (try_for_agents, ":agent"),
	    (agent_is_human, ":agent"),
		(agent_is_alive, ":agent"),
		(try_begin),
	    (eq, ":agent", ":my_agent"),
          (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
         (neg|is_presentation_active, "prsnt_multiplayer_stats_chart_deathmatch"),
         (neg|is_presentation_active,        "prsnt_staminabar_multi"),
	(start_presentation, "prsnt_staminabar_multi"),
		(else_try),
			#(display_message,"@ "),
		(try_end),
		(try_end),
    ])

suma_fatigue_multi = (4, 0, 0, [(is_presentation_active, "prsnt_staminabar_multi"),
],[    

    (try_for_agents, ":agent_no"),

        (agent_is_alive,":agent_no"), #  test for alive players.
      (agent_is_human, ":agent_no"),
##            (try_begin),
##        (is_presentation_active, "prsnt_staminabar_multi"),
        (agent_get_slot, ":basic_stamina", ":agent_no", slot_agent_fatiga),
        (agent_get_slot, ":basic_stamina_i", ":agent_no", slot_agent_fatiga_inicial),
        (lt, ":basic_stamina", ":basic_stamina_i"),

        (val_add, ":basic_stamina", 6), #siempre va a sumar un minimo de 1
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente
##            (else_try),
##           (start_presentation, "prsnt_staminabar_multi"),
##    (try_end),  
    (try_end),    
    ])

resta_fatigue_porcorrer_multi = (3, 0, 0, [         (is_presentation_active, "prsnt_staminabar_multi"),
    (this_or_next|game_key_is_down, gk_move_forward),
   (this_or_next|game_key_is_down, gk_move_backward),
    (this_or_next|game_key_is_down, gk_move_left),
   (game_key_is_down, gk_move_right),
                                                    (neg|key_is_down,key_left_shift), #Don't trip if walking
       # (neg|main_hero_fallen),
                                     ],[   

		(multiplayer_get_my_player,":player"),

              (player_get_agent_id, ":agent_no",":player"),
        (agent_is_alive,":agent_no"), #  test for alive players.
      (agent_is_human, ":agent_no"),
       (agent_get_horse,":agent_mounted",":agent_no"),
           (eq,":agent_mounted",-1),

        (assign, ":stamina_coste", 2),

           (agent_get_item_slot, ":cur_armor", ":agent_no", ek_body),#Here we are getting body armor
            (try_begin),
                (is_between, ":cur_armor", armadura_pesada_begin, armadura_pesada3_end),
               (val_add, ":stamina_coste", 4),
            (else_try),
                (is_between, ":cur_armor", armadura_media_begin, armadura_media_end),
                (val_add, ":stamina_coste", 2),
##           (else_try),
##                (eq, ":cur_armor", itm_no_item), #ni suma ni resta, no tiene nada
           (else_try),
                (is_between, ":cur_armor", desnudos_begin, desnudos_end), #es equipamiento ritual
                (val_sub, ":stamina_coste", 1),
            (try_end),

           (agent_get_item_slot, ":cur_armor", ":agent_no", ek_head),#Here we are getting head armor
                 (try_begin),
                    (is_between, ":cur_armor", yelmos_pesados2_begin, yelmos_pesados2_end),
                    (val_add, ":stamina_coste", 1),
                 (try_end),

             (agent_get_item_slot, ":cur_armor", ":agent_no", ek_foot),#Here we are getting leg armor
             (try_begin),
                 (is_between, ":cur_armor", calzado_pesados_begin, calzado_pesados_end),
                 (val_add, ":stamina_coste", 1),
             (try_end),

             #no heavy gloves in Brytenwalda.
            # (agent_get_item_slot, ":cur_armor", ":agent_no", ek_gloves),#Here we are getting arm armor
            # (try_begin),
                # (is_between, ":cur_armor", guantes_pesados_begin, guantes_pesados_end),
                # (val_add, ":stamina_coste", 1),
            # (try_end),

            #Now for the four armaments every agent may carry
            (agent_get_item_slot,":cur_arma",":agent_no",ek_item_0),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":agent_no",ek_item_1),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":agent_no",ek_item_2),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),

            (agent_get_item_slot,":cur_arma",":agent_no",ek_item_3),
            (try_begin),
                # (this_or_next|is_between, ":cur_arma", armas_pesadas_begin, armas_pesadas_end), #un arma es mas comoda de llevar, por ahora no quitamos stamina
                 (this_or_next|is_between, ":cur_arma", escudos_pesados_begin, escudos_pesados_end),
                (is_between, ":cur_arma", escudos_pesados2_begin, escudos_pesados2_end),
                (val_add, ":stamina_coste", 1), #un escudo de 70-90 cm es bastante pesado, en torno a 4-6 kg.
            (try_end),
              (try_begin), 
        (game_key_clicked, gk_jump),#por saltar
         (val_add, ":stamina_coste", 4),
            (try_end),
                (agent_get_slot, ":basic_stamina", ":agent_no", slot_agent_fatiga),

            (try_begin),
        (le, ":basic_stamina", 4),
##                        (multiplayer_send_int_to_server,multiplayer_event_sound_at_player, "snd_breathing_heavy"),
			(multiplayer_send_int_to_server,multiplayer_event_animation_at_player, "anim_strike_fall_back_rise"),
        (agent_play_sound, ":agent_no", "snd_breathing_heavy"), # if the value is one then play death sound.
                                         # (multiplayer_send_2_int_to_server,multiplayer_event_message_server, 3, ":player"), ### 1 ist the number of healing
            #(display_message, "@ no puedes con el alma para correr mas"),
    (try_end),


        (val_sub, ":basic_stamina", ":stamina_coste"), #maximo 10 para un hombre totalmente equipado, y minimo 1 para un picto desnudo

        (val_max, ":basic_stamina", 1), #siempre va a restar un minimo de 1
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":basic_stamina"), #se la aplicamos al agente
#    (try_end),
# (try_end),    

    ])


resta_fatigue_multi= (1, 0, 0, [      (is_presentation_active, "prsnt_staminabar_multi"),
                                      (this_or_next|game_key_is_down, gk_defend),
        (game_key_is_down, gk_attack),
],[
		(multiplayer_get_my_player,":player"),
           (player_is_active, ":player"),
           (neg|player_is_busy_with_menus, ":player"),
              (player_get_agent_id, ":agent_no",":player"),

        (agent_is_alive,":agent_no"), #  test for alive players.
   (agent_is_human, ":agent_no"),
       (agent_get_horse,":agent_mounted",":agent_no"),
           (eq,":agent_mounted",-1),
    (set_trigger_result, -1),
    (try_begin),
            (agent_get_wielded_item, ":wielded",":agent_no", 0),
            (assign, ":stamina_cost", 1), #pierde fatiga cada golpe.
        (try_begin),
            (this_or_next|is_between, ":wielded", "itm_wooden_stick", "itm_spatha"), #armas pequenas
            (is_between, ":wielded", "itm_irish_sword", "itm_pictish_longsword"),
            (val_add, ":stamina_cost", 1), #pierde fatiga cada golpe.
        (else_try),
            (this_or_next|is_between, ":wielded", "itm_spatha", "itm_irish_sword"),
            (this_or_next|is_between, ":wielded", "itm_staff", "itm_roman_spear_2"),
            (this_or_next|is_between, ":wielded", "itm_sarranid_two_handed_axe_b", "itm_twohand_spear"),
            (this_or_next|is_between, ":wielded", "itm_spear_5", "itm_wessexbanner1"),
            (this_or_next|is_between, ":wielded", "itm_darts", "itm_lyre"),
            (is_between, ":wielded", "itm_pictish_longsword", "itm_battle_axe"),
            (val_add, ":stamina_cost", 2), #pierde fatiga cada golpe.
        (else_try),
            (this_or_next|is_between, ":wielded", "itm_battle_axe", "itm_staff"),
            (this_or_next|is_between, ":wielded", "itm_twohand_spear", "itm_sarranid_axe_a"),
            (is_between, ":wielded", "itm_spear_7", "itm_sarranid_two_handed_axe_b"),
            (val_add, ":stamina_cost", 4), #pierde fatiga cada golpe.
        (try_end),
##        (try_begin), #player pierde stamina por correr yet
##            (this_or_next|is_between, ":wielded", "itm_celtic_shield_small_round_a", "itm_h_shield"),
##            (is_between, ":wielded", "itm_tarcze_celtyckie", "itm_tab_shield_small_round_c"),
##            (val_add, ":stamina_cost", 1), #pierde fatiga cada golpe.
##        (try_end),
        (agent_get_slot, ":inflicted_stamina", ":agent_no", slot_agent_fatiga),
        (val_sub, ":inflicted_stamina", ":stamina_cost"),
        (val_max, ":inflicted_stamina", 1),
        (agent_set_slot, ":agent_no", slot_agent_fatiga, ":inflicted_stamina"), #se la aplicamos al agente

    (try_end),

##    (store_trigger_param_3, ":damage"),
##   (gt, ":damage", 0),

    (agent_get_slot, ":basic_stamina", ":agent_no", slot_agent_fatiga),
    
    (try_begin),
##        (le, ":basic_stamina", 10), #animacion y sonido aplicados en correr ya
##			(multiplayer_send_int_to_server,multiplayer_event_animation_at_player, "anim_fatigues1"),
##                                          (multiplayer_send_2_int_to_server,multiplayer_event_message_server2, 3, ":player"), ### 1 ist the number of healing
#    (else_try),
        (lt, ":basic_stamina", 6),
			(multiplayer_send_int_to_server,multiplayer_event_animation_at_player, "anim_stand_to_crouch"),
                                      #   (multiplayer_send_2_int_to_server,multiplayer_event_message_server, 3, ":player"), ### 1 ist the number of healing
##   (else_try), #puesto off chief para no saturar
##        (lt, ":basic_stamina", 25),
##                                         (multiplayer_send_2_int_to_server,multiplayer_event_message_server2, 1, ":player"), ### 1 ist the number of healing
    (try_end),





                       # (multiplayer_send_int_to_server,multiplayer_event_sound_at_player, "snd_corazon_late2"),

    ])
#brytenwalda end


In each mutilplayer mission template:

Code:
#brytenwalda begin
sistema_fatiga_multi,
recupera_fatiga_multi,
suma_fatigue_multi,
resta_fatigue_porcorrer_multi,
resta_fatigue_multi,
#brytenwalda end



In Presentations

Code:
   
#brytenwalda begin
   ("staminabar_multi", prsntf_read_only, 0, [
           (ti_on_presentation_load, [  
        (set_fixed_point_multiplier, 1000),
        (create_mesh_overlay, "$stamina_bar", "mesh_white_plane", "mesh_white_plane"),
        (overlay_set_color, "$stamina_bar", 0x0000bb),
       
	  (multiplayer_get_my_player, ":my_player"),
		(player_get_agent_id, ":agent", ":my_player"),
		(agent_is_active, ":agent"),
##	  (player_get_agent_id, ":my_agent", ":my_player"),
##      (try_for_agents, ":agent"),
	    (agent_is_human, ":agent"),
		(agent_is_alive, ":agent"),
##	    (eq, ":agent", ":my_agent"),
                    #(get_player_agent_no, ":player_agent"),
                (agent_get_slot, ":basic_stamina", ":agent", slot_agent_fatiga),
                (val_mul,":basic_stamina",52),
                (position_set_x,pos1,":basic_stamina"),
                (position_set_y,pos1,360),
                (overlay_set_size, "$stamina_bar", pos1),
                (position_set_x,pos1,869),
                (position_set_y,pos1,58),
                (overlay_set_position, "$stamina_bar", pos1),
	  #(try_end),
              (presentation_set_duration, 999999),
              ]),
          
            (ti_on_presentation_run, [
              (set_fixed_point_multiplier, 1000),

	  (multiplayer_get_my_player, ":my_player"),
		(player_get_agent_id, ":agent", ":my_player"),
		(agent_is_active, ":agent"),
#	  (player_get_agent_id, ":my_agent", ":my_player"),
#      (try_for_agents, ":agent"),
	    (agent_is_human, ":agent"),
		(agent_is_alive, ":agent"),
	#    (eq, ":agent", ":my_agent"),
                (agent_get_slot, ":basic_stamina", ":agent", slot_agent_fatiga),
                (try_begin),
        (gt, ":basic_stamina", 1),
        (val_mul,":basic_stamina",52),
        (else_try),
        (assign, ":basic_stamina", 1),
        (val_mul,":basic_stamina",52),
        (try_end),
        (position_set_x,pos1,":basic_stamina"),
        (position_set_y,pos1,360),
        (overlay_set_size, "$stamina_bar", pos1),
	  #(try_end),
      ]),
    ]),
#brytenwalda end
 
I can see a couple of problems with the code:
  • The presentation doesn't need an agent loop - you already got the player's own agent number
  • (agent_get_wielded_item, ":wielded",":agent_no", 0), will not get the shield- last parameter has to be 1. I'm not sure what set_trigger_result does here
  • You can use a loop for agent_get_item_slot.
  • You can't store the skill level of an agent - it has to be a troop.
 
The presentation doesn't need an agent loop - you already got the player's own agent number

-There are issues when we dont apply it, specially in multiplayer, because game call presentation a lot of times in battle.

(agent_get_wielded_item, ":wielded",":agent_no", 0), will not get the shield- last parameter has to be 1. I'm not sure what set_trigger_result does here
You can use a loop for agent_get_item_slot.

-(agent_get_wielded_item, ":wielded",":agent_no", 0), -< you mean that 0 need be change 1 for shield? In testing it look that shield work, but maybe it is using other variable.

You can't store the skill level of an agent - it has to be a troop.

Yes, sorry, I forgot change that. I will fix in this night or tomorrow, litte time now.
 
Idibil said:
The presentation doesn't need an agent loop - you already got the player's own agent number

-There are issues when we dont apply it, specially in multiplayer, because game call presentation a lot of times in battle.

Still, you don't need to loop through all agents. Getting player agent + agent_is_active check + agent_is_alive check should be enough. Looping through all agents on battlefield give's you nothing.

 
Very interesting idea. I am curious, could it be made so instead of 'not being able to fight', you simply get increasing (and severe) damage and maybe movement penalties?

 
Slawomir of Aaarrghh said:
Idibil said:
The presentation doesn't need an agent loop - you already got the player's own agent number

-There are issues when we dont apply it, specially in multiplayer, because game call presentation a lot of times in battle.

Still, you don't need to loop through all agents. Getting player agent + agent_is_active check + agent_is_alive check should be enough. Looping through all agents on battlefield give's you nothing.

You mean delete try_for_agents in multiplayer code

  (multiplayer_get_my_player, ":my_player"),
      (agent_get_horse,":agent_mounted",":my_player"),
          (eq,":agent_mounted",-1),

  (player_get_agent_id, ":my_agent", ":my_player"),
    (agent_is_human, ":my_agent"),
(agent_is_alive, ":my_agent"),

But there are issues in multiplayer game when player finish round. Game need read: (eq, ":agent", ":my_agent"),
Multiplayer isnt my strong, sorry, and I dont know well all process for this issue.


Somebody said:
Also, the ritual equipment range (desnudos) won't give a bonus since the else_try block before it is empty, so it will never apply the range check.

Thank you. Fixed.

Sahran said:
Very interesting idea. I am curious, could it be made so instead of 'not being able to fight', you simply get increasing (and severe) damage and maybe movement penalties?

actually, animation dont let to player atack or move. He is so tired he is unable to do anything.
You are free of change it like you wish  :grin:
 
God must be ****ing around with me. I just completed my own system for TBS.... :mrgreen:
I logged in to ask how can I interrupt player attacks/defence if his stamina falls to 0, cause agent_set_attack_action doesn't seem to allow me to set it to nothing.
Oh well, I'll steal your way of doing that. :wink: (I'll check out how you did it anyway, even if I don't steal anything.)
 
Idibil said:
Thank you. Fixed.
not quite said:
          (agent_get_item_slot, ":cur_armor", ":player", ek_body),#Here we are getting body armor
            (try_begin),
                (is_between, ":cur_armor", armadura_pesada_begin, armadura_pesada3_end),
              (val_add, ":stamina_coste", 4),
            (else_try),
            (else_try),

                (is_between, ":cur_armor", armadura_media_begin, armadura_media_end),
                (val_add, ":stamina_coste", 2),
          (else_try),
                (is_between, ":cur_armor", desnudos_begin, desnudos_end), #es equipamiento ritual
                (val_sub, ":stamina_coste", 1),
            (try_end),
 
Idibil said:
Slawomir of Aaarrghh said:
Idibil said:
The presentation doesn't need an agent loop - you already got the player's own agent number

-There are issues when we dont apply it, specially in multiplayer, because game call presentation a lot of times in battle.

Still, you don't need to loop through all agents. Getting player agent + agent_is_active check + agent_is_alive check should be enough. Looping through all agents on battlefield give's you nothing.

You mean delete try_for_agents in multiplayer code

  (multiplayer_get_my_player, ":my_player"),
      (agent_get_horse,":agent_mounted",":my_player"),
          (eq,":agent_mounted",-1),

  (player_get_agent_id, ":my_agent", ":my_player"),
    (agent_is_human, ":my_agent"),
(agent_is_alive, ":my_agent"),

But there are issues in multiplayer game when player finish round. Game need read: (eq, ":agent", ":my_agent"),
Multiplayer isnt my strong, sorry, and I dont know well all process for this issue.


I mean something like this:

Code:
#brytenwalda begin
("staminabar_multi", prsntf_read_only, 0, [
           (ti_on_presentation_load, [  
		(set_fixed_point_multiplier, 1000),
		(create_mesh_overlay, "$stamina_bar", "mesh_white_plane", "mesh_white_plane"),
		(overlay_set_color, "$stamina_bar", 0x0000bb),

		(multiplayer_get_my_player, ":my_player"),
		(player_get_agent_id, ":agent", ":my_player"),
		(agent_is_active, ":agent"),
		(agent_is_alive, ":agent"),
                (agent_get_slot, ":basic_stamina", ":agent", slot_agent_fatiga),
                (val_mul,":basic_stamina",52),
                (position_set_x,pos1,":basic_stamina"),
                (position_set_y,pos1,360),
                (overlay_set_size, "$stamina_bar", pos1),
                (position_set_x,pos1,869),
                (position_set_y,pos1,58),
                (overlay_set_position, "$stamina_bar", pos1),
		(presentation_set_duration, 999999),
              ]),
          
            (ti_on_presentation_run, [
              (set_fixed_point_multiplier, 1000),

		(multiplayer_get_my_player, ":my_player"),
		(player_get_agent_id, ":agent", ":my_player"),
		(agent_is_active, ":agent"),
		(agent_is_alive, ":agent"),
		(agent_get_slot, ":basic_stamina", ":agent", slot_agent_fatiga),
		(try_begin),
		   (gt, ":basic_stamina", 1),
		   (val_mul,":basic_stamina",52),
		(else_try),
		   (assign, ":basic_stamina", 1),
		   (val_mul,":basic_stamina",52),
		(try_end),
		(position_set_x,pos1,":basic_stamina"),
		(position_set_y,pos1,360),
		(overlay_set_size, "$stamina_bar", pos1),
      ]),
    ]),
#brytenwalda end
 
Yes, but for some reason when player die (respawn time) give scripts issues in agent id. Maybe, we used keys in mission template for call presentation.

However, if we use (eq, ":agent", ":my_agent"),, presentation only affect to player call presentation.
 
Trust me, you don't need that agent loop. :wink: "player_get_agent_id" will always give you actual ID of player's agent. If the agent is dead, script will not get pass "agent_is_alive" check. If player has no agent, script will not pass through "agent_is_active". I'm almost sure that lack of "agent_is_active" check caused your previous script errors.
 
First off: very nice Idea!

I have two questions:
When I compile it tells me "that slot_agent_fatiga_intial" is not defined.
What could that mean?

The other thing is that I don't know where to put this:

Code:
#brytenwalda begin
sistema_fatiga,
recupera_fatiga,
suma_fatigue,
resta_fatigue_porcorrer,
resta_fatigue,

#brytenwalda end

I guess here:

Code:
    [
      common_battle_mission_start,
      common_battle_init_banner,

      (0, 0, ti_once,
       [
         (assign, "$defender_team", 0),
         (assign, "$attacker_team", 1),
         (assign, "$defender_team_2", 2),
         (assign, "$attacker_team_2", 3),
         ], []),

      (ti_before_mission_start, 0, 0, [],
       [
         (scene_set_day_time, 15),
         ]),

      common_custom_battle_tab_press,
      common_custom_battle_question_answered,
      common_inventory_not_available,
      common_custom_siege_init,
      common_music_situation_update,
      custom_battle_check_victory_condition,
      common_battle_victory_display,
      custom_battle_check_defeat_condition,
      common_siege_attacker_do_not_stall,
      common_siege_refill_ammo,
      common_siege_init_ai_and_belfry,
      common_siege_move_belfry,
      common_siege_rotate_belfry,
      common_siege_assign_men_to_belfry,
      common_siege_ai_trigger_init_2,
      ],
 
Back
Top Bottom