Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
 
Make him his own kingdom and give him kingdom reinforcments with his unique troops?
No doubt someone with more experience will post a better answer than me, but that's my take on it.
 
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 :razz: 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.
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.
 
cwr said:
How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
Custom reinforcements - make an exception for him in script_cf_reinforce_party.
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.
 
Hello Forge,

It has been a long time. Anyway, can you guys give me a hint about the idea of "Name of the player atop of his head"?

I was thinking something like getting pos of an agent, rearrange it by coords, attach it to agent, get the name of the player, and set it on the rearranged pos.



Check this out as well.

Edit: I was trying to create a "First Blood" feature. Basicly, when an agent dies...I was hoping this trigger scans all the active players in the server that time, gets their kill count and gets the killer agent's kill count. Makes the proper compares, if the conditions are true, apply the block. - Which is nothing but shows a debug message -. Ignore the unused local vars, and all other uncompleted stuff. What I am asking, does this trigger do the part I thickened? I am a newb in this part of coding sometimes.

Code:
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),
       
       
   ])

It should get the all other players' kill count -Should be zero- and get killer agent's count -Should be one-. I think I am having trouble with scaning the proper player groups. Help me out.
 
I'd recommend attaching it to script_multiplayer_server_on_agent_killed_or_wounded_common - note that player_get_kill_count can be negative with teamkills. You're also not checking for same team or human (that is, both non-horse and a valid player), the agent_is_alive is superfluous, the (try_end) is one line too high, and the total kill count can't be 0 if the current one is being counted with the same operation for the killer's player. Most of those can be resolved if you use the native script's framework. Also, if it's supposed to be every round instead of every map you'll probably want to use agent_get_kill_count instead (if it even works in MP).
 
MadVader said:
cwr said:
How can I make a troop that only one lord has? Not all lords of that faction, just one lord.
Custom reinforcements - make an exception for him in script_cf_reinforce_party.
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.
Thanks! :grin:
 
Hello

I am kinda new to modding, as in really really new  :lol:

Take a look at the image in the spoiler
dzk048.jpg

As you can see, each member of your team as their specific class represented by a small img. On the bottom of the screen, you can see the players equipment.

Basically I am wondering if anybody has seen the same or similar stuff in any mod and happen to have the source code so I could take a look into it, as I kinda want to try something like this myself. Any help is appreciated  :mrgreen:
 
Those icons look like recoloured versions of cb_ui_icon_horseman/infantry/archer. Use player_get_troop_id and troop_is_guarantee_ranged/troop_is_guarantee_horse to check which type of class it is (or the multi_troop_class_x values).

As for the equipment, you need to find the agent ID of the player being spectated (I assume that's how it works), and then iterate through agent_get_item_slot so as to fetch values for create_mesh_overlay_with_item_id.

This is all speculation though, you can probably ask whoever maintains the WNL mod for the source after the tournament's over.
 
Hello! I am very new to modding and wondering how to get equipment to show up in a troop customizer such as the one used for creating Kingdom troops in 16th Century. I already have the items in the module and working fine; they are just missing from the menu used for picking the items your troops use. I have Python and module system (very limited experience though). Any help would be greatly appreciated and have a great day!
 
I'm trying to get a special troop into Sultan Hakim's party.

This is my code:
Code:
("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),
  ]),

and the party template:
Code:
("hakim_party_template","{!}hakim_party_template",icon_gray_knight|pf_show_faction,0,fac_commoners,soldier_personality,[(trp_sarranid_strongman,5,10)]),

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:hakimin object:hakim_party_template
ERROR: Illegal Identifier:hakim_party_template


Can someone please help? :smile:
 
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
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.
 
Lumos said:
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
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.

Ahh, thanks! :grin: I will try that.


The reason for my current code is because I was trying to copy the code referencing the other party templates; so anyway, thank you. :grin:
 
Don't forget, if you use something in one file that is defined in another (in this instance used in scripts but defined in party templates) it has to be referenced.
This is so when it's scanning down the code it knows where to find that information to apply it to the current code/script. So it would jump to party templates, scan down for the correct part, then apply it and carry on down where it left off.
This is how I interpret it anyway. Whenever you add something or change something it's good to try and understand why and how.

If this is wrong or anyone wants to elaborate I would enjoy the read :smile:.
 
Hi everyone, (hope this is the correct place to ask this question xD)

I'm trying to create something of my own based on two of my favourite mods (I know there's permissions to be asked, but will ask them eventually, need to figure out first if I can actually do something since I'm new at this xD), I'm using the modmerger, and everything was working fine, fixed missing particles and such, all good... But now I'm getting this error...

Code:
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

I do understand he wants an integer value (I assume), but he is getting a String value, thing is as everyone here might agree the compiler is a cool guy when it comes to this (not...) he doesn't show what line is... So I went into a crazy rampart search mode, I noticed the faction related field is the last one, ironically an optional one apparently according to the header, there were some with the last fields as so ", [], []]," so I made them into simply "]," by that I mean I removed the last two fields in blank as they are optional and not required to have anything in there (again I assume)...

Still nothing, I still keep getting this error...
(Although I have mentioned it several times and there nobody said anythin' against it so I hope it's ok) I'm trying to for starters get some of TEATRC items into Floris (guns mostly, none of the uniques are in whatsoever, besides Redeemer and Elephant Gun), I deleted the field that controlled which factions sold what and made the .py into a modmerger compatible format (the little header-like at the end thing), I also took care of the three particles from TEATRC... So I have no idea what's missing.

Sorry for the wall of text...
And the possibility that some of the people might not remotely enjoy what I'm attempting to do x.x
 
Paste sample item lines where you removed the faction field.

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.
 
MadVader said:
Paste sample item lines where you removed the faction field.

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.

Tell me there's an easy way to figure out which item it is... O_O

PS: Just out of curiosity, when do you guys (modders) think that it's ok to release an Alpha?...
 
The ones you've changed.
The fastest way is to comment out half of them and build. If there's an error, comment out half of the rest of them and so on. If it builds, uncomment half of the commented ones and build, and so on.
Or do it one by one until you find which one.
 
Status
Not open for further replies.
Back
Top Bottom