Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
The only problem I can see is if you are assigning village factions manually, after script_refresh_village_defenders gets called multiple times at the start of the game. In Native, this takes place after each village is automatically assigned to the closest centre but your experiences may vary.
 
Hello, I was trying to get a head start on using the new operations from 1.60, however I can't seem to get them to work.
I have pasted the operations into my header_operations file and the code compiles but the operation I'm trying to use isn't working as planned.
I haven't used strings before so that may be my downfall, this is the code simply want to change the material on creation (scene props could reference same mesh but have alt materials, example most of the Khergit and Sarranid scene props are identical except for material.

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1, ":scene_prop_id"),
    (str_store_string, s4,"@stucco_6"),
    (prop_instance_set_material, ":scene_prop_id", 0, s4),
]


Here is the code as written from header_operations

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1,<destination>),
    (str_store_string,<string_register>,<string_id>),
    (prop_instance_set_material, <prop_instance_no>, <sub_mesh_no>, <string_register>),
]


Any help would be great as these operations allow for huge variations in items and scene props.

I should note the objects material does change and on the correct part but is just white.
 
ShaunRemo said:
Hello, I was trying to get a head start on using the new operations from 1.60, however I can't seem to get them to work.
I have pasted the operations into my header_operations file and the code compiles but the operation I'm trying to use isn't working as planned.
I haven't used strings before so that may be my downfall, this is the code simply want to change the material on creation (scene props could reference same mesh but have alt materials, example most of the Khergit and Sarranid scene props are identical except for material.

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1, ":scene_prop_id"),
    (str_store_string, s4,"@stucco_6"),
    (prop_instance_set_material, ":scene_prop_id", 0, s4),
]


Here is the code as written from header_operations

(ti_on_scene_prop_init,
    [
    (store_trigger_param_1,<destination>),
    (str_store_string,<string_register>,<string_id>),
    (prop_instance_set_material, <prop_instance_no>, <sub_mesh_no>, <string_register>),
]


Any help would be great as these operations allow for huge variations in items and scene props.

I should note the objects material does change and on the correct part but is just white.
There are no errors in your code - almost identical test code works without a hitch for me:

Code:
  ("table_tavern",0,"table_tavern","botable_tavern", [
    (ti_on_init_scene_prop, [
      (store_trigger_param_1, ":prop"),
      (prop_instance_set_material, ":prop", -1, "@stucco_6"),
    ])
  ]),
Note I used -1 to apply the material to all meshes, and I used the material name directly instead of storing it in a register first, but I have actually used 0 for mesh #0 and intermediate string register and everything still worked without any issues.

So your problem is probably elsewhere. The operation works correctly, it's the material and/or texture that are not being shown for some reason.
 
@ShaunRemo, yeah they all work (as far as I can tell so far). Sounds obvious but you are using the most up to date version of warband, like your still not using the 1.158 .exe are you?
 
Jacobhinds, had 31 factions to do so it's much better this way, thank you for that.
Since the moving-while-raiding script removes a lot of risk I edited this to give the player the occasional little curve-ball:
Code:
(try_begin),
        (party_get_num_companions, ":party_size", ":village_no"),
        (lt, ":party_size", ":ideal_size"),
        (store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_a),
        (party_add_template, ":village_no", ":reinforcements"),
		(eq, ":party_size", 30),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_b),
        (party_add_template, ":village_no", ":reinforcements"),
		(eq, ":party_size", 61),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_c),
        (party_add_template, ":village_no", ":reinforcements"),
      (try_end),
  ]),
The maximum you can have and still get reinforcements is 49, and the maximum reinforcements_a is 12 guys, so the last one should be possible. Unless I'm missing something about how Warband party templates work?


Somebody, I did indeed have to move the initial calls for refresh_village_defenders to come after centres were assigned to lords/factions, cheers for the heads up.
 
That code's still quite messy, and I'm not sure what it's supposed to be doing -- you should only need to retrieve the slot for reinforcements once, and then put try blocks after that. But as i said I'm not sure what the purpose of the code is.

If you want certain settlements to have larger garrisons, you'll have to set a new slot -- be that binary (something along the lines of slot_party_has_large_garrison), or discrete and changeable (slot_party_garrison_size). This is because the code you're using runs several times, and checks for current garrison size once, so if you want variable garrison sizes between villages, you'll need to set a slot. If you need me to write an example I'll do so tomorrow when I'm on the computer.
 
Hey  La Grandmaster I'm using 1.165, I'm getting a warning that local variable :scene_prop_id is not being used and when I enter the game it tells me it can't find material Next_Page. so I made a material called Next_Page and it works, somehow I guess the quick string is being replaced even though I have copied Lav's code. Not sure if I've done something wrong.
 
Are there any checks in Native for the lords to have enough money before having feasts, starting military campaigns, etc.? Do lords have money as a concept at all? I can find nothing while searching troop_add_gold and troop_remove_gold.
 
The code's messy because I don't have much understanding of the system :smile:. I just kinda copy and paste,  mash it together, trial and error, see what happens. In this case it did mostly work, even with extraneous bits in there, but I'll have a go at restructuring it.

The aim here was to vary the composition of the village garrisons rather than the size. So if during a refresh the garrison happened to end up with exactly 30 men then it would add reinforcements_b (then later make up the rest of the 50 man garrison with reinforcements_a). Roughly 10% of villages had some reinforcements_b when I tested. The third bit with reinforcements_c didn't seem to work, even when a village had the listed number, don't know why. Will test more.




 
The Dark Robin said:
Are there any checks in Native for the lords to have enough money before having feasts, starting military campaigns, etc.? Do lords have money as a concept at all? I can find nothing while searching troop_add_gold and troop_remove_gold.
AFAIK slot_troop_wealth indicates how much money a lord has, but I don't know exactly in what cases it is checked.
 
Hello guy, can I ask a question? Where is the reward give for tournaments? I looked everywhere but I cannot find it. Also, the denars that you give to a lord to improve relation?

Thanks!
 
Thanks! And:
fladin said:
that exists? I know only  when player give money  to make peace ...

Yeah, it's when you go to a lady and say that you need to have a better relation with the lords of the realm. You give money for that.
 
Antonis said:
Yeah, it's when you go to a lady and say that you need to have a better relation with the lords of the realm. You give money for that.

Could it be this?
Code:
[anyone,"lady_restore_relation_3", [(str_store_troop_name, s10, "$troop_to_restore_relations_with"),
                                      (assign, "$lady_restore_cost_1", 1000),
                                      (assign, "$lady_restore_cost_2", 2000),
                                      (assign, "$lady_restore_cost_3", 3000),
                                      (assign, reg10, "$lady_restore_cost_1"),
                                      (assign, reg11, "$lady_restore_cost_2"),
                                      (assign, reg12, "$lady_restore_cost_3"),
                                      (troop_get_type, reg4, "$troop_to_restore_relations_with"),
                                      ],

From module_dialogs.
 
kraggrim said:
The code's messy because I don't have much understanding of the system :smile:. I just kinda copy and paste,  mash it together, trial and error, see what happens.

Hey, it's the best way to learn. :razz:



kraggrim said:
Jacobhinds, had 31 factions to do so it's much better this way, thank you for that.
Since the moving-while-raiding script removes a lot of risk I edited this to give the player the occasional little curve-ball:
Code:
(try_begin),
        (party_get_num_companions, ":party_size", ":village_no"),
        (lt, ":party_size", ":ideal_size"),
        (store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_a),
        (party_add_template, ":village_no", ":reinforcements"),
		(eq, ":party_size", 30),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_b),
        (party_add_template, ":village_no", ":reinforcements"),
		(eq, ":party_size", 61),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_c),
        (party_add_template, ":village_no", ":reinforcements"),
      (try_end),
  ]),
The maximum you can have and still get reinforcements is 49, and the maximum reinforcements_a is 12 guys, so the last one should be possible. Unless I'm missing something about how Warband party templates work?
Okay:

The main problem with the script is misuse of can_fail operations. Things like eq, ge or agent_is_routed will "fail" the script and nothing beyond that line will run. So glancing at your script, you've got three can_fail operations:

Code:
(lt, ":party_size", ":ideal_size"),
...
(eq, ":party_size", 30),
...
(eq, ":party_size", 61),

The script runs all in one go, and since none of these can be true at the same time, the script is bound to fail.

It takes a bit of common sense to determine whether an operation is can_fail or not; check this amazingly useful website to read what each operation does.

This is what try_blocks:

Code:
(try_begin),
    {stuff},
(else_try),
    {more_stuff},
(else_try),
    {even_more_stuff},
(try_end),

are for. can_fail operations within a try_block will only fail that block, not the whole script. The "else_try" means that if the first block fails, it continues to the next block, and so on.
You should use try_blocks when you want to apply different results depending on the constant (in your case this is ":party_size").

I've rewritten your script with the appropriate try_blocks:

Code:
        (party_get_num_companions, ":party_size", ":village_no"), #how many troops are in the current village?
		(store_faction_of_party, ":village_faction", ":village_no"), 

		(try_begin), #
			(lt, ":party_size", ":ideal_size"), #if there are fewer than the "ideal_size"... 
            (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_a), #...find reinforcement party a for this faction,...
			(party_add_template, ":village_no", ":reinforcements"), #...and then add reinforcement party a.
		(else_try), #if that failed...
			(eq, ":party_size", 30),   #and there are 30 troops in the village...
			(faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_b), #...find reinforcement party b for this faction,...
			(party_add_template, ":village_no", ":reinforcements"), #...and then add reinforcement party b.
		(else_try), #if both of the above failed...
			(eq, ":party_size", 61), #and the party size is equal to 61...
			(faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_c), #...find reinforcement party c for this faction,...
			(party_add_template, ":village_no", ":reinforcements"), #...and then add reinforcement party c.
		(try_end) #if none of the above worked, continue the rest of the script.
  ]),

Although this still has a few issues --  mainly the fact that a party is probably not going to have exactly 30 or 61 men, especially if the first thing it checks is whether it's below the ideal_size. What you'll have to do is set a slot somewhere in script_game_start and then call from that, but you'd have to rewrite entire scripts and it might end up being more trouble than it's worth if you're not fully confident with where stuff is in the module system.
 
I had my suspicions  about the else_try things, so it's good to have it spelled out, thanks. This is what I ended up with on my own, which wasn't too far off the mark :grin: :

Code:
(try_begin),
        (party_get_num_companions, ":party_size", ":village_no"),
		(eq, ":party_size", 30),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_b),
        (party_add_template, ":village_no", ":reinforcements"),
	  (else_try),
	    (eq, ":party_size", 55),
		(store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_c),
        (party_add_template, ":village_no", ":reinforcements"),
	  (else_try),
	    (lt, ":party_size", ":ideal_size"),
        (store_faction_of_party, ":village_faction", ":village_no"),      
        (faction_get_slot, ":reinforcements", ":village_faction", slot_faction_reinforcements_a),
        (party_add_template, ":village_no", ":reinforcements"),				
      (try_end),
  ]),

I've crossed it with your version and it performs exactly how I wanted, they fill up with reinforcements_a and have a roughly 10% chance of _b and 5% of _c.  I'm hoping this will balance out the loss of risk from implementing the run-away-while-raiding script.

Cheers for the help man, I appreciate it :smile:. Do you happen to know if there's an easy way to enable post-battle equipment looting  for the village defender fights? The lack of it could be kinda frustrating for the player when they're no longer fighting farmers with rocks.

 
Damian97 said:
AFAIK slot_troop_wealth indicates how much money a lord has, but I don't know exactly in what cases it is checked.
Thanks! Just what I needed.
 
kraggrim said:
Do you happen to know if there's an easy way to enable post-battle equipment looting  for the village defender fights?

I'm not sure. I've never looked into how loot worked. Anyway it shouldn't be too much of an issue just to leave it out -- you don't get physical loot for sieges and there are scripts that give you money anyway.



Whoa, how come nobody (not even the developers, apparently) makes use of the billboard shaders? They're great! They act like procedural .lods that aren't nearly as jarring as separate models (easier to keep track of, too). Are there any performance issues to worry about, like the shader being poorly optomised?

k-OoT.jpg

Can't really see it in this image but the leaves on trees slowly fade in to view when you're moving towards them.
 
How can ı add the open&close door to sp?
I am added this doors but its just destroyed, dont open or close.
Code:
(else_try), #opening/closing door
       (this_or_next|eq, ":effected_object", "spr_door_destructible"),
       (this_or_next|eq, ":effected_object", "spr_castle_f_door_b"),
       (this_or_next|eq, ":effected_object", "spr_castle_e_sally_door_a"),
       (this_or_next|eq, ":effected_object", "spr_castle_f_sally_door_a"),
       (this_or_next|eq, ":effected_object", "spr_earth_sally_gate_left"),
       (this_or_next|eq, ":effected_object", "spr_earth_sally_gate_right"),
       (this_or_next|eq, ":effected_object", "spr_viking_keep_destroy_sally_door_left"),
       (this_or_next|eq, ":effected_object", "spr_viking_keep_destroy_sally_door_right"),
       (eq, ":effected_object", "spr_castle_f_door_a"),
 
Status
Not open for further replies.
Back
Top Bottom