Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
@ Michadr, thank you, sir! I am in your debt!

**EDIT**

Now that I've solved that issue, I could really use help with solving another! I need to (Permanently) disable lords from upgrading the troops in their party and limit how many troops are distributed in their parties, I've noticed that vassals receive exactly three/four times the troops I want them to. I thought I had these out of the way, I was terribly mistaken.
 
  # script_decide_run_away_or_not
  # Input: none
  # Output: none
  ("decide_run_away_or_not",
    [
      (store_script_param, ":cur_agent", 1),
      (store_script_param, ":mission_time", 2),
     
      (assign, ":force_retreat", 0),
      (agent_get_team, ":agent_team", ":cur_agent"),
      (agent_get_division, ":agent_division", ":cur_agent"),
      (try_begin),
        (lt, ":agent_division", 9), #static classes
        (team_get_movement_order, ":agent_movement_order", ":agent_team", ":agent_division"),
        (eq, ":agent_movement_order", mordr_retreat),
        (assign, ":force_retreat", 1),
      (try_end),

      (agent_get_slot, ":is_cur_agent_running_away", ":cur_agent", slot_agent_is_running_away),
      (try_begin),
        (eq, ":is_cur_agent_running_away", 0),
        (try_begin),
          (eq, ":force_retreat", 1),
          (agent_start_running_away, ":cur_agent"),
          (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 1),
        (else_try),
          (ge, ":mission_time", 45), #first 45 seconds anyone does not run away whatever happens.
          (agent_get_slot, ":agent_courage_score", ":cur_agent",  slot_agent_courage_score),
          (store_agent_hit_points, ":agent_hit_points", ":cur_agent"),
          (val_mul, ":agent_hit_points", 4),
          (try_begin),
            (agent_is_ally, ":cur_agent"),
            (val_sub, ":agent_hit_points", 100), #ally agents will be more tend to run away, to make game more funnier/harder
          (try_end),
          (val_mul, ":agent_hit_points", 10),
          (store_sub, ":start_running_away_courage_score_limit", 3500, ":agent_hit_points"),
          (lt, ":agent_courage_score", ":start_running_away_courage_score_limit"), #if (courage score < 3500 - (agent hit points * 40)) and (agent is not running away) then start running away, average hit points : 50, average running away limit = 1500

          (agent_get_troop_id, ":troop_id", ":cur_agent"), #for now do not let heroes to run away from battle
          (neg|troop_is_hero, ":troop_id"),
                               
          (agent_start_running_away, ":cur_agent"),
          (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 1),
        (try_end),
      (else_try),
        (neq, ":force_retreat", 1),
        (agent_get_slot, ":agent_courage_score", ":cur_agent",  slot_agent_courage_score),
        (store_agent_hit_points, ":agent_hit_points", ":cur_agent"),     
        (val_mul, ":agent_hit_points", 4),
        (try_begin),
          (agent_is_ally, ":cur_agent"),
          (val_sub, ":agent_hit_points", 100), #ally agents will be more tend to run away, to make game more funnier/harder
        (try_end),
        (val_mul, ":agent_hit_points", 10),
        (store_sub, ":stop_running_away_courage_score_limit", 3700, ":agent_hit_points"),
        (ge, ":agent_courage_score", ":stop_running_away_courage_score_limit"), #if (courage score > 3700 - agent hit points) and (agent is running away) then stop running away, average hit points : 50, average running away limit = 1700
        (agent_stop_running_away, ":cur_agent"),
        (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 0),
      (try_end),     
  ]), #ozan
      (3, 0, 0, [
          (try_for_agents, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (agent_is_alive, ":agent_no"),         
            (store_mission_timer_a,":mission_time"),
            (ge,":mission_time",3),         
            (call_script, "script_decide_run_away_or_not", ":agent_no", ":mission_time"),
          (try_end),         
              ], []), #controlling courage score and if needed deciding to run away for each agent
castle_attack_walls_defenders_sally
castle_attack_walls_belfry
castle_attack_walls_ladder
quick_battle_battle
quick_battle_siege
But you might have to modify the script a bit to help agents find their way with minimal damage especially in sieges.
 
Dusk Voyager said:
  # script_decide_run_away_or_not
  # Input: none
  # Output: none
  ("decide_run_away_or_not",
    [
      (store_script_param, ":cur_agent", 1),
      (store_script_param, ":mission_time", 2),
     
      (assign, ":force_retreat", 0),
      (agent_get_team, ":agent_team", ":cur_agent"),
      (agent_get_division, ":agent_division", ":cur_agent"),
      (try_begin),
        (lt, ":agent_division", 9), #static classes
        (team_get_movement_order, ":agent_movement_order", ":agent_team", ":agent_division"),
        (eq, ":agent_movement_order", mordr_retreat),
        (assign, ":force_retreat", 1),
      (try_end),

      (agent_get_slot, ":is_cur_agent_running_away", ":cur_agent", slot_agent_is_running_away),
      (try_begin),
        (eq, ":is_cur_agent_running_away", 0),
        (try_begin),
          (eq, ":force_retreat", 1),
          (agent_start_running_away, ":cur_agent"),
          (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 1),
        (else_try),
          (ge, ":mission_time", 45), #first 45 seconds anyone does not run away whatever happens.
          (agent_get_slot, ":agent_courage_score", ":cur_agent",  slot_agent_courage_score),
          (store_agent_hit_points, ":agent_hit_points", ":cur_agent"),
          (val_mul, ":agent_hit_points", 4),
          (try_begin),
            (agent_is_ally, ":cur_agent"),
            (val_sub, ":agent_hit_points", 100), #ally agents will be more tend to run away, to make game more funnier/harder
          (try_end),
          (val_mul, ":agent_hit_points", 10),
          (store_sub, ":start_running_away_courage_score_limit", 3500, ":agent_hit_points"),
          (lt, ":agent_courage_score", ":start_running_away_courage_score_limit"), #if (courage score < 3500 - (agent hit points * 40)) and (agent is not running away) then start running away, average hit points : 50, average running away limit = 1500

          (agent_get_troop_id, ":troop_id", ":cur_agent"), #for now do not let heroes to run away from battle
          (neg|troop_is_hero, ":troop_id"),
                               
          (agent_start_running_away, ":cur_agent"),
          (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 1),
        (try_end),
      (else_try),
        (neq, ":force_retreat", 1),
        (agent_get_slot, ":agent_courage_score", ":cur_agent",  slot_agent_courage_score),
        (store_agent_hit_points, ":agent_hit_points", ":cur_agent"),     
        (val_mul, ":agent_hit_points", 4),
        (try_begin),
          (agent_is_ally, ":cur_agent"),
          (val_sub, ":agent_hit_points", 100), #ally agents will be more tend to run away, to make game more funnier/harder
        (try_end),
        (val_mul, ":agent_hit_points", 10),
        (store_sub, ":stop_running_away_courage_score_limit", 3700, ":agent_hit_points"),
        (ge, ":agent_courage_score", ":stop_running_away_courage_score_limit"), #if (courage score > 3700 - agent hit points) and (agent is running away) then stop running away, average hit points : 50, average running away limit = 1700
        (agent_stop_running_away, ":cur_agent"),
        (agent_set_slot, ":cur_agent",  slot_agent_is_running_away, 0),
      (try_end),     
  ]), #ozan
      (3, 0, 0, [
          (try_for_agents, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (agent_is_alive, ":agent_no"),         
            (store_mission_timer_a,":mission_time"),
            (ge,":mission_time",3),         
            (call_script, "script_decide_run_away_or_not", ":agent_no", ":mission_time"),
          (try_end),         
              ], []), #controlling courage score and if needed deciding to run away for each agent
castle_attack_walls_defenders_sally
castle_attack_walls_belfry
castle_attack_walls_ladder
quick_battle_battle
quick_battle_siege
But you might have to modify the script a bit to help agents find their way with minimal damage especially in sieges.

Works perfectly, thanks!

I had to add two other courage-related scripts from lead_charge though - otherwise the agents don't take their allies into account and think they're facing the enemy alone.
 
Has anyone tried using the spawn_agent operation for multiplayer?

It works fine on local servers, but on dedicated servers it appears to crash. I seem to recall this function being used for spawning horses though, but does it work only for horses then?

EDIT: spawn_horse is actually different operation, so scratch that. Still, looking to spawn an agent at a certain location, while also getting the spawned agent (spawn_agent stores it in reg0, add_visitors_to_current_scene does not)

EDIT2: wasn't spawn_agent causing the player-side crash, but player_control_agent. Moving the player_control agent from a ti_on_agent_spawn trigger to a timed loop with try_for_agents stopped the crash.
 
In my mission template, I want a troop on spawning to play a certain animation. This has worked so far, and now I am trying to loop this animation. I have applied different amf_* and arf_* flags on the animation, but I have yet to get the desired outcome. Is there someone who has some tips for me?

Code:
	["new_ani", 0, amf_play|amf_priority_die|amf_start_instantly,
	[14.2, "new_ani", 0, 177, arf_cyclic]],
Code:
      (ti_on_agent_spawn, 0, 0, [], 
      [	  
	  (store_trigger_param_1,":agent_no"),
	  (agent_get_troop_id, ":troop_no", ":agent_no"),
	  (try_begin),
	    (eq, ":troop_no", "trp_dancing_damsel"),
	    (agent_set_animation, ":agent_no", "anim_new_ani"),
	    (display_message, "@Debug: dancing animation started."),
	  (try_end),
       ]),
 
I added a nation chooser menu at character creation to wfas.
Could you help me to add items for the player before he sets the face of his character?
Choosing his nation happens in a monitor (?) called start_game_2. Wfas don't use start_character_ monitors.
I tryed to put the lines to some places but he remains naked or the converter reports bugs.

The shortened code:
Code:
      (try_begin),
        (eq,"$background_type",cb_belorussian),
        (troop_add_item, "trp_player","itm_mosk_armyak",0),
        (troop_add_item, "trp_player","itm_ukrine_prosta_shapka",0),
        (troop_add_item, "trp_player","itm_bread",0),
        (troop_add_item, "trp_player","itm_dried_meat",0),
        (troop_add_item, "trp_player","itm_cabbages",0),
        (troop_add_item, "trp_player","itm_cabbages",0),
      (else_try),
        (eq,"$background_type",cb_westerneu),
        (troop_add_item, "trp_player","itm_evropa_odejda_sela_b",0),
        (troop_add_item, "trp_player","itm_evropa_shlapa_b",0),
        (troop_add_item, "trp_player","itm_bread",0),
        (troop_add_item, "trp_player","itm_bread",0),
        (troop_add_item, "trp_player","itm_smoked_fish",0),
        (troop_add_item, "trp_player","itm_dried_meat",0),
      (try_end),

The following wfas lines after start_game_2:
Code:
  (
    "choose_skill",mnf_disable_all_keys,"You spot a battle-ready men in the distance.", 
    "none",
    [(assign,"$current_string_reg",10)],
    [
      ("begin_adventuring",[],"See what trouble is afoot.",[
           (set_show_messages, 0),
        ]),
    ]
  ),

 
I wonder why some variables need to be assigned as -1 before using it in a loop or something(especially in presentations).
Caba`drin said:
(assign, ":target_agent", -1),
(assign, ":close_dist", 999),
(agent_get_look_position, pos1, ":player"),
(try_for_agents, ":agent"),
  #add in checks for agent being alive, human, ally, whatever you need
  (agent_get_position, pos2, ":agent"),
  (neg|position_is_behind_position, pos2, pos1),
  (position_has_line_of_sight_to_position, pos2, pos1),
  (get_distance_between_positions, ":distance", pos2, pos1),
  (lt, ":distance", ":close_dist"),
  (assign, ":close_dist", ":distance"), #My bad. Forgot this obvious line originally.
  (assign, ":target_agent", ":agent"),
(try_end),

What would the difference be if this was not assigned as -1? And aren't unassigned variables -1 by default already?
 
Unassigned variables are 0 by default. They are -1 because if no agent is found, then agent_is_active operation (that will be somewhere in the code below) will fail 100%. If you would have 0 instead of -1, then there is a small possibility that agent id 0 would be active.
 
Lumos said:
I've successfully created looping animations using amf_use_cycle_period along with arf_cyclic on their sub-entries. Did you try with that?
Yes. The animation played in lighting speed and repeats itself. I could not find a way to slow the animation down though. Should I change settings in OpenBRF of the animation? Would that help? Else I can make a mt trigger that restarts the animation when it is finished, however that is quite some extra work.
 
minnakodunum said:
Is there any way to disable battle log in multiplayer? To make it only for chat?
They're hardcoded. You might be able to suppress them with (set_show_messages, 0) but it will probably suppress chat as well.
 
Question, is there any way to change the amount of villages castles and towns need? For example every castle needs one village, and towns seem to variate between 2-3 however sometimes they take only one village. If a castle doesn't have one village, you get a bunch of errors, atleast this is what I've experienced so far. So is there a way to change the amount? So I can either just remove it or have the towns/castles pick more villages automaticly instead of the amount it takes right now?

Any help would be greatly appreciated! If you see what I mean.  :oops:
 
@gokiller
The engine adds every village to a castle or town so you can add even 5 or 6 villages to a town.
You can add more villages to a castle via script.

Code in WFAS:
Code:
        (party_set_slot, "p_village_66", slot_village_bound_center, "p_town_13"),
        (store_faction_of_party, ":town_faction", "p_town_13"),
        (call_script, "script_give_center_to_faction_aux", "p_village_66", ":town_faction"),
 
Status
Not open for further replies.
Back
Top Bottom