Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Ive set a faction to sfs_inactive at game start, yet i still get random lords of said faction on the map at the start of a game.
I instead wrote a trigger, though the same happens.
Is their anything else that needs doing to make all lords of the faction inactive too?


Also, is it possible to set a timer in dialogues? Ie, you cant speak to said person for 7 days. Anywhere in native where this is true so i can takea look at it?


Cheers all.
 
MadocComadrin said:
Is the extra trigger parameter (the collision type) in ti_on_missile_hit that's in WFAS available in native?
It's easy to check actually, took me mere few minutes to confirm that yes, it's available. :smile:

produno said:
Ive set a faction to sfs_inactive at game start, yet i still get random lords of said faction on the map at the start of a game.
I instead wrote a trigger, though the same happens.
Is their anything else that needs doing to make all lords of the faction inactive too?
You may have marked a faction as inactive, but code in "script_game_start" doesn't check for this flag, it just generates lords and their armies for 6 predefined factions. Similarly, merely marking a faction as inactive does not make lords and armies disappear (though it will prevent any lords joining this faction).

What are you trying to do anyway? Remove a faction from the game or make it dormant but potentially able to reappear? Steps you need to take are quite different in this two scenarios.

produno said:
Also, is it possible to set a timer in dialogues? Ie, you cant speak to said person for 7 days. Anywhere in native where this is true so i can takea look at it?
As far as I know there isn't such a situation anywhere so you'll have to code it from scratch.
 
produno said:
Ive set a faction to sfs_inactive at game start, yet i still get random lords of said faction on the map at the start of a game.
I instead wrote a trigger, though the same happens.
Is their anything else that needs doing to make all lords of the faction inactive too?


Also, is it possible to set a timer in dialogues? Ie, you cant speak to said person for 7 days. Anywhere in native where this is true so i can takea look at it?


Cheers all.
1.
  # script_create_kingdom_hero_party
  # Input: arg1 = troop_no, arg2 = center_no
  # Output: $pout_party = party_no
  ("create_kingdom_hero_party",
    [
      (store_script_param, ":troop_no", 1),
      (store_script_param, ":center_no", 2),
   
      (store_troop_faction, ":troop_faction_no", ":troop_no"),
     
      (assign, "$pout_party", -1),
      (try_begin),
        (eq, "$g_there_is_no_avaliable_centers", 0),
        (set_spawn_radius, 0),
  (else_try),
        (set_spawn_radius, 15),
      (try_end),
      (spawn_around_party, ":center_no", "pt_kingdom_hero_party"),
     
      (assign, "$pout_party", reg0),
     
      (party_set_faction, "$pout_party", ":troop_faction_no"),
      (party_set_slot, "$pout_party", slot_party_type, spt_kingdom_hero_party),
      (call_script, "script_party_set_ai_state", "$pout_party", spai_undefined, -1),
      (troop_set_slot, ":troop_no", slot_troop_leaded_party, "$pout_party"),
      (party_add_leader, "$pout_party", ":troop_no"),
      (str_store_troop_name, s5, ":troop_no"),
      (party_set_name, "$pout_party", "str_s5_s_party"),
     
      (party_set_slot, "$pout_party", slot_party_commander_party, -1), #we need this because 0 is player's party!

      #Setting the flag icon
      #normal_banner_begin
      (troop_get_slot, ":cur_banner", ":troop_no", slot_troop_banner_scene_prop),
      (try_begin),
        (gt, ":cur_banner", 0),
        (val_sub, ":cur_banner", banner_scene_props_begin),
        (val_add, ":cur_banner", banner_map_icons_begin),
        (party_set_banner_icon, "$pout_party", ":cur_banner"),
      #custom_banner_begin
      #(troop_get_slot, ":flag_icon", ":troop_no", slot_troop_custom_banner_map_flag_type),
      #(try_begin),
      #  (ge, ":flag_icon", 0),
      #  (val_add, ":flag_icon", custom_banner_map_icons_begin),
      #  (party_set_banner_icon, "$pout_party", ":flag_icon"),
      (try_end),

      (try_begin),
        #because of below two lines, lords can only hire more than one party_template(stack) at game start once a time during all game.
        (troop_slot_eq, ":troop_no", slot_troop_spawned_before, 0),
        (troop_set_slot, ":troop_no", slot_troop_spawned_before, 1),
        (assign, ":num_tries", 20),
        (try_begin),
          (store_troop_faction, ":troop_kingdom", ":troop_no"),
          (faction_slot_eq, ":troop_kingdom", slot_faction_leader, ":troop_no"),
          (assign, ":num_tries", 50),
        (try_end),

        #(str_store_troop_name, s0, ":troop_no"),
        #(display_message, "{!}str_debug__hiring_men_to_party_for_s0"),

        (try_for_range, ":unused", 0, ":num_tries"),
          (call_script, "script_hire_men_to_kingdom_hero_party", ":troop_no"),
        (try_end),
       
        (assign, ":mad:p_rounds", 0),

        (game_get_reduce_campaign_ai, ":reduce_campaign_ai"),
        (try_begin),
          (this_or_next|eq, ":troop_faction_no", "$players_kingdom"),
          (eq, ":troop_faction_no", "fac_player_supporters_faction"),
          (assign, ":mad:p_rounds", 0),
        (else_try),
          (eq, ":reduce_campaign_ai", 0), #hard
          (assign, ":mad:p_rounds", 2),
        (else_try),
          (eq, ":reduce_campaign_ai", 1), #moderate
          (assign, ":mad:p_rounds", 1),
        (else_try),                       
          (eq, ":reduce_campaign_ai", 2), #easy
          (assign, ":mad:p_rounds", 0),
        (try_end),         

        (troop_get_slot, ":renown", ":troop_no", slot_troop_renown),
        (store_div, ":renown_xp_rounds", ":renown", 100),
        (val_add, ":mad:p_rounds", ":renown_xp_rounds"),
        (try_for_range, ":unused", 0, ":mad:p_rounds"),
          (call_script, "script_upgrade_hero_party", "$pout_party", 4000),
        (try_end),
      (try_end),     
  ]),
 
  # script_create_kingdom_party_if_below_limit
  # Input: arg1 = faction_no, arg2 = party_type (variables beginning with spt_)
  # Output: reg0 = party_no
  ("create_kingdom_party_if_below_limit",
    [
      (store_script_param_1, ":faction_no"),
      (store_script_param_2, ":party_type"),

      (call_script, "script_count_parties_of_faction_and_party_type", ":faction_no", ":party_type"),
      (assign, ":party_count", reg0),
     
      (assign, ":party_count_limit", 0),

      (faction_get_slot, ":num_towns", ":faction_no", slot_faction_num_towns),

      (try_begin),
##        (eq, ":party_type", spt_forager),
##        (assign, ":party_count_limit", 1),
##      (else_try),
##        (eq, ":party_type", spt_scout),
##        (assign, ":party_count_limit", 1),
##      (else_try),
##        (eq, ":party_type", spt_patrol),
##        (assign, ":party_count_limit", 1),
##      (else_try),
##        (eq, ":party_type", spt_messenger),
##        (assign, ":party_count_limit", 1),
##      (else_try),
        (eq, ":party_type", spt_kingdom_caravan),
        (try_begin),
          (eq, ":num_towns", 0),
          (assign, ":party_count_limit", 0),
        (else_try),
          (eq, ":num_towns", 1),
          (assign, ":party_count_limit", 1),
        (else_try),
          (eq, ":num_towns", 2),
          (assign, ":party_count_limit", 3),
        (else_try),
          (assign, ":party_count_limit", 5),
        (try_end),
##      (else_try),
##        (eq, ":party_type", spt_prisoner_train),
##        (assign, ":party_count_limit", 1),
      (try_end),
     
      (assign, reg0, -1),
      (try_begin),
        (lt, ":party_count", ":party_count_limit"),
        (call_script,"script_cf_create_kingdom_party", ":faction_no", ":party_type"),
      (try_end),
  ]),
 
Or just search for references to them in script and trigger files, and add the conditions there.

2. Whenever you speak to them, store the next day you can do it into a variable to check for it every time if it's already about time.
  [anyone|auto_proceed,"lord_request_mission_ask",
  [(eq, "$players_kingdom", 0),
    (ge, "$g_talk_troop_faction_relation", 0),
    (ge, "$g_talk_troop_relation", 0),
    (troop_slot_ge, "trp_player", slot_troop_renown, 30),
    (neg|faction_slot_eq, "$g_talk_troop_faction", slot_faction_leader, "$g_talk_troop"),
    (faction_get_slot, ":last_offer_time", "$g_talk_troop_faction", slot_faction_last_mercenary_offer_time),

    (assign, ":num_enemies", 0),
    (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
      (faction_slot_eq, "$g_talk_troop_faction", slot_faction_state, sfs_active),
      (store_relation, ":reln", "$g_talk_troop_faction", ":faction_no"),
      (lt, ":reln", 0),
      (val_add, ":num_enemies", 1),
    (try_end),
    (ge, ":num_enemies", 1),
    (store_current_hours, ":cur_hours"),
    (store_add,  ":week_past_last_offer_time", ":last_offer_time", 7 * 24),
    (val_add,  ":last_offer_time", 24),
    (ge, ":cur_hours", ":last_offer_time"),
    (store_random_in_range, ":rand", 0, 100),
    (this_or_next|lt, ":rand", 20),
(ge, ":cur_hours", ":week_past_last_offer_time"),



(troop_get_type, ":type", "trp_player"),
(this_or_next|eq, ":type", 0),
(this_or_next|troop_slot_eq, "$g_talk_troop", slot_lord_reputation_type, lrep_cunning),
(troop_slot_eq, "$g_talk_troop", slot_lord_reputation_type, lrep_goodnatured),
    ],
  "{!}Warning: This line should never display.", "lord_propose_mercenary",[(store_current_hours, ":cur_hours"),
                                  (faction_set_slot, "$g_talk_troop_faction", slot_faction_last_mercenary_offer_time,  ":cur_hours")
]],

 
 
 
 
  [anyone,"lord_propose_mercenary", [(call_script, "script_party_calculate_strength", "p_main_party", 0),
                                    (assign, ":eek:ffer_value", reg0),
                                    (val_add, ":eek:ffer_value", 100),
                                    (call_script, "script_round_value", ":eek:ffer_value"),
                                    (assign, ":eek:ffer_value", reg0),
                                    (assign, "$temp", ":eek:ffer_value"),
                                    (faction_get_slot, ":faction_leader", "$g_talk_troop_faction", slot_faction_leader),
                                    (neq, ":faction_leader", "$g_talk_troop"),
                                    (str_store_faction_name, s9, "$g_talk_troop_faction"),
                                    (str_store_troop_name, s10, ":faction_leader"),

(troop_get_type, ":is_female", "trp_player"),
(try_begin),
(eq, ":is_female", 3), #disabled
(troop_slot_eq, "$g_talk_troop", slot_lord_reputation_type, lrep_martial),
    (str_store_string, s11, "str_now_some_might_say_that_women_have_no_business_leading_mercenary_companies_but_i_suspect_that_you_would_prove_them_wrong_what_do_you_say"),
(else_try),
    (str_store_string, s11, "@What do you say to entering the service of {s9} as a mercenary captain?\
I have no doubt that you would be up to the task."),
(try_end)
],
Frenzied_Crocoduck_Herder said:
Hello! Does any one know a script that makes a sound and animation play every time a unit moves?
Is there supposed to be a bell or something on them?

Store their current position into an agent slot at the end to compare it with the one the next time the trigger fires. If there's a difference, have the agent play the sound.
 
@Lav

It made the faction disappear (i also set notes to 0), but as you say it doesnt make the lords and armies disappear  :grin: . Im trying to make the faction and all lords of that faction dormant, of which will be activated later in the game.

Everything works correct other than the lords and armies still being present.


Regarding dialogues. Thanks for the reply. At least i know not to waste my time searching :smile:.


Edit

@Dusk Voyager
Awesome! Cheers man, much appreciated! :smile:
 
Dang, my presentation for talking to any lord still comes with a sideissue. But I have no idea where I should look at, to fix stuff.

Situation:

There are lords active (each with a party) on the map that belong to a faction which does not own any fiefs anymore (I took their last castle before they could react). The faction itself is still active / not defeated.

Now, whenever something is happening like.
Enemy patrols spotted ...
Lord XYZ of FACTION ABC has been freed ...
Small bands of enemies spotted ...
Lord XYZ of FACTION ABC has been taken prisoner ... only occurs with a lord involved, not a great lord [king]
FGH castle has been besieged by Lord XYB of FACTION ABC.
Code:
SCRIPT ERROR ON OPCODE 2173: Invalid Troop ID: 13229; LINE NO: 3:
At Game Triggers trigger no: 32 conditions.
At Game Triggers trigger no: 32 conditions.

That error output remains until I have defeated all existing lords (I think, the great lord was the last I fought) of the faction w/o fiefs.

What check could I have missed? I don't even get why this error is shown actively on the map when the presentation only calls the scripts and checks when it's called from the menu.
 
Open up module_triggers and start counting up the triggers. The first trigger is 0, the second one is 1 and so on until you reach 32. Then you look at the 4th line (first line is 0, so the line with id 3 is the 4th) (it should be store_troop_faction or store_faction_of_troop), then you think how could that troop id possible end up there (look at how that troop id get there; from where).
 
Quintillius said:
Any way to get edited module_info_pages ingame?My ModuleSystem does not even transform it into .txt form.
Not sure what's wrong with your module system but vanilla module system compiler does process module_info_pages.py without any issues. Unless you've modified the processing or bat files, try downloading it from Taleworlds and replace build_module.bat and all process_*.py files.

Melphiz said:
Code:
SCRIPT ERROR ON OPCODE 2173: Invalid Troop ID: 13229; LINE NO: 3:
At Game Triggers trigger no: 32 conditions.
At Game Triggers trigger no: 32 conditions.

That error output remains until I have defeated all existing lords (I think, the great lord was the last I fought) of the faction w/o fiefs.

What check could I have missed? I don't even get why this error is shown actively on the map when the presentation only calls the scripts and checks when it's called from the menu.
Check your module_triggers.py file. You need trigger with ID 32, this is the 33rd trigger in the file (it may be easier to find it in triggers.txt file where all triggers occupy a single line - the first three numbers are the same as in trigger's header, so once you know them it becomes easier to find the trigger source in the module_triggers.py file).

Line 3 means operation #3 (again, they're numbered starting from zero, so it's actually the 4th operation in the trigger's condition block). OPCODE 2173 is store_troop_faction operation as you can find out in header_operations.py file.

This info should be enough to locate the problematic line, what remains is to find out why does it receive an illegal troop code (because 13229 is way too much to be an actual troop reference, most likely you've mixed up your arguments/slots/variables somewhere).
 
Hm, the last 6 triggers from the triggers.txt are not in the module_triggers.py.

The #32 is one of them

EDIT: Ah, wait, must be within freelancer triggers then (it's not my mod to begin with I only created a submod),
 
Is there a way of making the exterior (?or texture) of a scene prop green, without making custom stuffs for each scene prop (like custom textures or stuffs...I don't have any knowledge about graphics) using only scripts (I want to toggle it between having it's normal texture and being green)?  (like in edit mode, when you select it, it becomes green (yes, I want to try and make a multiplayer edit mode (yes, multiple people editing at the same time (yes, it has it's own limitation( like only the host can edit the ground or flora kind or variation ids or ground texture)))))
 
I feel like I'm missing something obvious there but here is:
Code:
raw_charge = (
    ti_on_order_issued, 0, 0, [
	(store_trigger_param_1, ":order_no"),
	(store_trigger_param_2, ":agent_no"),
	
    (get_player_agent_no, ":player_agent"),
    (agent_get_team, ":player_team", ":player_agent"),
    (this_or_next|team_get_movement_order, ":order_no", ":player_team", grc_everyone),
    (team_get_movement_order, ":order_no", ":player_team", grc_infantry),	
    (eq, ":order_no", mordr_charge),
	
  (try_for_agents, ":agent_no"),	
	(agent_is_human, ":agent_no"),
	(agent_is_alive, ":agent_no"),
	(agent_get_troop_id, ":id", ":agent_no"),	
	(display_message, "@Launch trigger."),
	    
	(try_begin), 
	    (eq, ":id", "trp_sp_roman_cornicem"),	
            (display_message, "@Agent found."),			
            (agent_get_wielded_item, ":cur_wielded_item", ":agent_no", 1), # Item is two handed so wielded in the left hand
            (neq, ":cur_wielded_item", "itm_f_cornu"),
            (agent_set_wielded_item, ":agent_no", "itm_f_cornu"),			
            (agent_set_animation, ":agent_no", "anim_cornu_play", 1),
            (agent_play_sound, ":agent_no", "snd_carnyx"),
	 (try_end),	
	],[])
The idea was to enforce an animation and sound on an agent once the charge order is issued, the trigger works but no effect on the agent itself (no anim/sound). I've tried different ways and simpler ones not checking for the wielded item and all (in case it was the one thing failing) but to no avail, I'd be grateful if someone could point to the error.
 
@ Dusk Voyager, haha, no, I intend to make musicians, hence the need for an animation and sound when they move. Hell, I'd settle for them just making a noise when they move.

Could you repeat that in greater detail simpler terms, please?
 
@Seek n Destroy
First, you don't need these two lines, because the trigger itself provides you with the order_no (see the first trigger param).
(this_or_next|team_get_movement_order, ":eek:rder_no", ":player_team", grc_everyone),
    (team_get_movement_order, ":eek:rder_no", ":player_team", grc_infantry),

Second, this one
(agent_get_wielded_item, ":cur_wielded_item", ":agent_no", 1), # Item is two handed so wielded in the left hand
I believe that in the left hand is only the shield, no matter if it is 2h or bow or xbow. So try and get rid of that 1 at the end, and see if it works.
 
According to the expanded header operations from Lav two handed weapons return the left hand and so do the ranged ones (bow and crossbow)
agent_get_wielded_item                  = 1726  # (agent_get_wielded_item, <destination>, <agent_id>, <hand_no>),
                                                # Retrieves the item reference that the agent is currently wielding in his right hand (hand_no = 0) or left hand (hand_no = 1). Warband assumes that weapons are wielded in right hand, and shields in left hand. Returns -1 when nothing is wielded, and also for left hand when wielding a two-handed or ranged weapon.

I tried both hands of course and your fixes but to no avail. Thanks anyway, I need to brainstorm this thing further.
 
Wow, that really is weird. The issue wasn't with the talk to any lord presentation but with this single menu-entry for talking to your spouse/husband/wife

Code:
("spouse_dialog",
		[
		 (try_begin),
		 	(troop_get_slot, "$spouse_betrothed", "trp_player", slot_troop_spouse),
			(ge, "$spouse_betrothed", 1),
			(try_begin),
				##diplomacy start+ Test gender with script
				#(troop_get_type, ":is_female", "trp_player"),#<- replaced
				(call_script, "script_cf_dplmc_troop_is_female", "trp_player"),
				#(eq, ":is_female", 1),#<- replaced
				##diplomacy end+
				(str_store_string, s8, "str_husband"),
			(else_try),
				(str_store_string, s8, "str_wife"),
			(try_end),
		 (else_try),
			(le, "$spouse_betrothed", 0),
			(troop_get_slot, "$spouse_betrothed", "trp_player", slot_troop_betrothed),
			(ge, "$spouse_betrothed", 1),
			(str_store_string, s8, "str_betrothed"),
		 (try_end),
			(ge, "$spouse_betrothed", 1),		
			(str_store_troop_name, s4, "$spouse_betrothed"),
		], "Talk to your {s8}, {s4}.",
		[	
			(store_troop_faction, "$g_encountered_party_faction", "$spouse_betrothed"),
			(store_relation, "$g_encountered_party_relation", "$g_encountered_party_faction", "fac_player_faction"),
			(call_script, "script_setup_troop_meeting", "$spouse_betrothed", -1),
		 ]
	  ),
That conflicted with the freelancer_triggers trigger
Code:
#  CHECKS IF PLAYER WON THE REVOLT

    (1.0, 0, 0, [
        (eq, "$freelancer_state", 0),
        (gt, "$enlisted_party", 0),
        (neg|party_is_active, "$enlisted_party"),

		(store_troop_faction, ":commander_faction", "$enlisted_lord"),
        (store_relation, ":relation", "fac_player_supporters_faction", ":commander_faction"),
        (lt, ":relation", 0),

        (party_get_attached_party_with_rank, ":attached_party", "p_main_party", 0),
        (eq, "p_temp_party_2", ":attached_party"),
    ],
    [
        (assign, "$enlisted_party", -1),
        (party_detach, "p_temp_party_2"),
        (store_skill_level, ":cur_leadership", "skl_leadership", "trp_player"),
        (store_skill_level, ":cur_persuasion", "skl_persuasion", "trp_player"),
        (store_add, ":chance", ":cur_persuasion", ":cur_leadership"),
        (val_add, ":chance", 10),
        (store_random_in_range, ":prisoner_state", 0, ":chance"),

        (try_begin),
            (is_between, ":prisoner_state", 0, 5),
            (call_script, "script_party_calculate_strength", "p_main_party", 0),
            (assign, ":main_strength", reg0),
            (call_script, "script_party_calculate_strength", "p_temp_party_2", 0),
            (assign, ":temp_strength", reg0),
            (ge, ":temp_strength", ":main_strength"),

            (party_get_num_prisoner_stacks, ":num_stacks", "p_temp_party_2"),
            (try_for_range, ":cur_stack", 0, ":num_stacks"),
                (party_prisoner_stack_get_troop_id, ":cur_troops", "p_temp_party_2", ":cur_stack"),
                (party_prisoner_stack_get_size, ":cur_size", "p_temp_party_2", ":cur_stack"),
                (party_remove_prisoners, "p_temp_party_2", ":cur_troops", ":cur_size"),
            (try_end),

            (tutorial_box, "@The released prisoners were not be trusted and they are preparing to attack you!", "@Warning!"),
            (start_encounter, "p_temp_party_2"),
            (change_screen_map),
        (else_try),
            (is_between, ":prisoner_state", 5, 10),
            (tutorial_box, "@The released prisoners scattered as soon as the battle finished. You will not be seeing them again.", "@Notice!"),
            (party_clear, "p_temp_party_2"),
        (else_try),
            (tutorial_box, "@The released prisoners have remained loyal and will join your party", "@Notice!"),
            (party_get_num_companion_stacks, ":num_stacks", "p_temp_party_2"),
            (try_for_range, ":cur_stack", 0, ":num_stacks"),
                (party_stack_get_troop_id, ":cur_troops", "p_temp_party_2", ":cur_stack"),
                (party_stack_get_size, ":cur_size", "p_temp_party_2", ":cur_stack"),
                (party_add_members, "p_main_party", ":cur_troops", ":cur_size"),
            (try_end),
            (party_clear, "p_temp_party_2"),
        (try_end),
    ]),
which is either totally weird or I have the rare case because my husband is originally (not currently) a lord of the faction that now has no fiefs (and is soon defeated).
The issue lies within the conditions block, I've tried to comment the consequences block w/o any positive result.
The global variable is only used in that single menu, if I am not mistaken a local variable from conditions doesn't work in the consequences, right?


EDIT: It seems it really was caused only because I used it as a global variable, using a local one doesn't give any errors ... ahaha ... what? Oh, well ... I don't understand why but ok, so I have to copy most of the conditions block into the consequences block.
 
Status
Not open for further replies.
Back
Top Bottom