cwr
How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
It will work, I use similar method for multiple buttons with similar functions for different objects like that, but usually I use trp_temp_array_a's slots to save the overlay Id. Using directly item slots is a nice idea.Duh said:Finally have the time to do some modding again and i wanted to set up an automated creation of buttons for a range of items in a presentation. Havent done this before and im on a laptop that cant run warband for anywhere from 2 weeks to 2 months so i wanted to know if the general idea of the following would work:
Code:presentation start, clear all purchase and sale slots for all trade items (i.e. set to 0), (assign, ":pos_x", 500), (assign, ":pos_x_2", 600), (assign, ":pos_y", 900), (try_for_range, ":item_no", "itm_trade_smoked_fish", "itm_items_end"), (create_game_button_overlay, reg0, "@_Buy_"), (position_set_x, pos1, ":pos_x"), (position_set_y, pos1, ":pos_y"), (overlay_set_position, reg0, pos1), (position_set_x, pos1, 100), (position_set_y, pos1, 15), (overlay_set_size, reg0, pos1), (item_set_slot, ":item_no", slot_purchase, reg0), (create_game_button_overlay, reg0, "@_Sell_"), (position_set_x, pos1, ":pos_x_2"), (position_set_y, pos1, ":pos_y"), (overlay_set_position, reg0, pos1), (position_set_x, pos1, 100), (position_set_y, pos1, 15), (overlay_set_size, reg0, pos1), (item_set_slot, ":item_no", slot_sale, reg0), (val_sub, ":pos_y", 20), (try_end), presentation trigger (ti_on_presentation_event_state_change, [ (store_trigger_param_1, ":object"), (assign, ":break", 0), (try_begin), (eq, ":object", whatever), (else_try), [...] (else_try), (try_for_range, ":item_no", "itm_trade_smoked_fish", "itm_items_end"), (item_get_slot, ":buy_id", ":item_no", slot_purchase), (item_get_slot, ":sell_id", ":item_no", slot_sale), (this_or_next|eq, ":object", ":buy_id"), (eq, ":object", ":sell_id"), (assign, ":break", ":item_no"), (try_end), (neq, ":break", 0), do consequences (try_end),
Im quite aware that there are some glaring inefficiencies (like having to figure out whether its sell or buy again for the consequences of the button). I suppose i should probably also utilize the value parameter, but well i wanted to know whether the general idea works.
Any input is appreciated.
Custom reinforcements - make an exception for him in script_cf_reinforce_party.cwr said:How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
first_blood = (
0, 0, ti_on_agent_killed_or_wounded, [],
[
(store_trigger_param_1, ":dead_agent"),
(store_trigger_param_2, ":killer_agent"),
(neq|agent_is_alive, ":dead_agent"),
(agent_get_player_id, ":killer_player", ":killer_agent"),
(player_get_kill_count, ":kill_count", ":killer_player"),
(assign, ":active_players", 0),
(try_begin),
(get_max_players, ":max_players"),
(try_for_range, ":player_no", 0, ":max_players"),
(player_is_active, ":player_no"),
#(val_add, ":active_players", 1),
(try_end),
(player_get_kill_count, ":o_kill_count", ":player_no"),
(try_begin),
(gt, ":num_active_players", 0),
(eq, ":kill_count", 1),
(eq, ":o_kill_count", 0),
(display_message, "@First blood!"),
(end_try),
])
Thanks!MadVader said:Custom reinforcements - make an exception for him in script_cf_reinforce_party.cwr said:How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
You can write special reinf. party templates for him, or simply add a few of those troops to his party. But do it in that script.
("cf_reinforce_party",
[
(store_script_param_1, ":party_no"),
(store_faction_of_party, ":party_faction", ":party_no"),
##diplomacy start+ The party faction may be changed for culture, but we still need the original
(assign, ":real_party_faction", ":party_faction"),
##diplomacy end+
(party_get_slot, ":party_type",":party_no", slot_party_type),
#Rebellion changes begin:
(try_begin),
(eq, ":party_type", spt_kingdom_hero_party),
(party_stack_get_troop_id, ":leader", ":party_no"),
(troop_get_slot, ":party_faction", ":leader", slot_troop_original_faction),
##diplomacy start+ Use player culture for companions and spouse (and any hypothetical non-hero mercenaries)
(eq, ":real_party_faction", "fac_player_supporters_faction"),
(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
(this_or_next|is_between, ":leader", companions_begin, companions_end),
(this_or_next|troop_slot_eq, "trp_player", slot_troop_spouse, ":leader"),
(neg|is_between, ":leader", heroes_begin, heroes_end),
(assign, ":party_faction", "$g_player_culture"),
##diplomacy end+
(try_end),
#Rebellion changes end
(try_begin),
(eq, ":party_faction", "fac_player_supporters_faction"),
(party_get_slot, ":town_lord", ":party_no", slot_town_lord),
(try_begin),
##diplomacy begin
(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
(assign, ":party_faction", "$g_player_culture"),
(try_begin), #debug
(eq, "$cheat_mode", 1),
(str_store_party_name, s11, ":party_no"),
(display_message, "@pt in {s11}"),
(try_end),
(else_try),
##diplomacy end
(gt, ":town_lord", 0),
(troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction),
(else_try),
(party_get_slot, ":party_faction", ":party_no", slot_center_original_faction),
(try_end),
(try_end),
##diplomacy start+ Player culture cleanup (do this once here, instead of separately for each type)
(try_begin),
(gt, ":real_party_faction", "fac_commoners"),
(this_or_next|eq, ":real_party_faction", "fac_player_faction"),
(this_or_next|eq, ":real_party_faction", "fac_player_supporters_faction"),
(eq, ":real_party_faction", "$players_kingdom"),
(neg|is_between, ":party_faction", npc_kingdoms_begin, npc_kingdoms_end),
(is_between, "$g_player_culture", npc_kingdoms_begin, npc_kingdoms_end),
(assign, ":party_faction", "$g_player_culture"),
(try_end),
##diplomacy end+
(faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a),
(faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b),
(faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c),
(assign, ":party_template", 0),
(store_random_in_range, ":rand", 0, 100),
##diplomacy start+
#Implement "quality vs. quantity" in a way that is visible in player battles
#(previously, quantity increased party size, but quality only had an effect
#in autocalc battles)
(try_begin),
(is_between, ":real_party_faction", kingdoms_begin, kingdoms_end),
(faction_get_slot, ":dplmc_quality", ":real_party_faction", dplmc_slot_faction_quality),
(val_clamp, ":dplmc_quality", -3, 4),
(val_add, ":rand", ":dplmc_quality"),
(val_clamp, ":rand", 0, 101),
(try_end),
##diplomacy end+
(try_begin),
(this_or_next|eq, ":party_type", spt_town),
(eq, ":party_type", spt_castle), #CASTLE OR TOWN
(try_begin),
(lt, ":rand", 65),
(assign, ":party_template", ":party_template_a"),
(else_try),
(assign, ":party_template", ":party_template_b"),
(try_end),
(else_try),
(eq, "pt_kingdom_6_lord"),
(assign, ":party_template", ":hakim_party_template"),
(else_try),
(eq, ":party_type", spt_kingdom_hero_party),
(try_begin),
(lt, ":rand", 50),
(assign, ":party_template", ":party_template_a"),
(else_try),
(lt, ":rand", 75),
(assign, ":party_template", ":party_template_b"),
(else_try),
(assign, ":party_template", ":party_template_c"),
(try_end),
(else_try),
##diplomacy start+ Reinforcements for patrols
(eq, ":party_type", spt_patrol),
(try_begin),
(lt, ":rand", 65),
(assign, ":party_template", ":party_template_a"),
(else_try),
(assign, ":party_template", ":party_template_b"),
(try_end),
##diplomacy end+
(try_end),
(try_begin),
(gt, ":party_template", 0),
(party_add_template, ":party_no", ":party_template"),
(try_end),
]),
("hakim_party_template","{!}hakim_party_template",icon_gray_knight|pf_show_faction,0,fac_commoners,soldier_personality,[(trp_sarranid_strongman,5,10)]),
Exporting scripts...
Error: Unrecognized tag:kingdomin object:kingdom_6_lord
ERROR: Illegal Identifier:kingdom_6_lord
Error: Unrecognized tag:hakimin object:hakim_party_template
ERROR: Illegal Identifier:hakim_party_template
I didn't even read your code, but the error is obvious: Error: Unrecognized tag:hakim. Party templates are referenced with the pt_ identifier. pt_hakim_party_template.cwr said:And this is the error that I'm getting:
Code:Exporting scripts... Error: Unrecognized tag:kingdomin object:kingdom_6_lord ERROR: Illegal Identifier:kingdom_6_lord Error: Unrecognized tag:hakim in object:hakim_party_template ERROR: Illegal Identifier:hakim_party_template
Lumos said:I didn't even read your code, but the error is obvious: Error: Unrecognized tag:hakim. Party templates are ferenced with the pt_ identifier. pt_hakim_party_template.cwr said:And this is the error that I'm getting:
Code:Exporting scripts... Error: Unrecognized tag:kingdomin object:kingdom_6_lord ERROR: Illegal Identifier:kingdom_6_lord Error: Unrecognized tag:hakim in object:hakim_party_template ERROR: Illegal Identifier:hakim_party_template
Exporting item data...
Traceback (most recent call last):
File "process_items.py", line 72, in (module)
write_items(variables,variable_uses,tag_uses,quick_strings)
File "process_items.py", line 48, in write_items
ofile.write(" %d"%item_faction)
TypeError: %d format: a number is required, not str
This means what it says. You have a string instead of a number in the last field (list of factions, internally numbers). Possibly deleted the last ] of an item line that made it merge with the next item.ofile.write(" %d"%item_faction)
TypeError: %d format: a number is required, not str
MadVader said:Paste sample item lines where you removed the faction field.
This means what it says. You have a string instead of a number in the last field (list of factions, internally numbers). Possibly deleted the last ] of an item line that made it merge with the next item.ofile.write(" %d"%item_faction)
TypeError: %d format: a number is required, not str