Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
You could just give the troop the 'scn_x|entry(x)' flag. It still works in Warband despite not being used. It should replace the first zero in '0,reserved,' or '0,0,'.

I guess that won't work if you want it to only appear if a certain faction owns the centre. Your script may need the 'modify_visitors_at_site' operation to work. All of the native ones seem to have it.
 
DanyEle said:
I used another piece of code's syntax for creating scene props' instances and thus making them disappear. Can i replace that try_for_range with another check that limits the object taken into consideration to the box?
The "unclosed try_for_range" refers to a very serious error where you used a try_for_* operation without adding a corresponding try_end at the end of the block that should be looped over: missing it out could mean that the entire rest of the operations block (and other calling scripts if a can fail type) will be disabled or wrong, causing many bugs, some not noticed until much later. You should also increase the indentation level after any try_begin or try_for_* operation, only decreasing for the corresponding try_end or else_try.

Without knowing how the rest of your script works, it's hard to suggest a method to select the right scene prop instance id: if your presentation should act on the closest ammo box prop in the scene, you would need to loop over all of them checking the distances between their position and the player, updating the closest instance id and distance values every iteration and using the result after the loop; but if your presentation is triggered in some way with the relevant scene prop (a ti_on_scene_prop_use trigger, for instance), you should get or keep the instance id in some way.
 
DanyEle said:
All right, this is what i've got so far:
The thing is that the first time i pick up the box, it works perfectly, whereas the second or third time you do it after deploying the box on the ground, a second box is spawned in your character's inventory  :shock:

Code:
(else_try),
		(eq, ":object", "$g_presentation_ammobox_4"),
		(set_fixed_point_multiplier, 1000),
		(presentation_set_duration, 0),
		(scene_prop_get_num_instances, ":end_cond", "spr_ammobox"),
		(try_for_range,":cur_instance",0,":end_cond"),
		(scene_prop_get_instance, ":instance_id", "spr_ammobox", ":cur_instance"),
		(prop_instance_get_position, pos16, ":instance_id"),
		(position_move_z, pos16, -100),
		(prop_instance_animate_to_position,":instance_id", pos16, 30),

		(agent_equip_item,":agent_id","itm_ammobox"),
                (agent_set_wielded_item,":agent_id","itm_ammobox"),
(else_try),


Got it working at this way

Code:
(else_try),
			(eq, ":object", "$g_presentation_ammobox_4"),
			(set_fixed_point_multiplier, 1000),
			(presentation_set_duration, 0),
			(scene_prop_get_num_instances, ":end_cond", "spr_ammobox"),
				(try_for_range,":cur_instance",0,":end_cond"),
					(scene_prop_get_instance, ":instance_id", "spr_ammobox", ":cur_instance"),
					(prop_instance_get_position, pos16, ":instance_id"),
					(position_move_z, pos16, -100),
					(prop_instance_animate_to_position,":instance_id", pos16, 30),
					(agent_get_wielded_item, ":item_id", ":agent_id"),
				    (neq, ":item_id", "itm_ammobox"),
					
					(neg|agent_has_item_equipped, ":agent_id", "itm_ammobox"),
					#(neq, ":item_equip", "itm_ammobox"),
					
					(agent_equip_item,":agent_id","itm_ammobox"),
					(agent_set_wielded_item,":agent_id","itm_ammobox"),
				(try_end),
		(else_try),
 
That code will go through all the ammo boxes on the scene and keep animating them further down until they loop over on top of your head or something. Try to be more specific with your operations, and don't forget that if you have a collision box it's best practices to disable physics so you can't glitch players/other props with them. Do some proper cleanup, and restore the fixed number of ammo boxes between rounds, etc so you stop accumulating scene props in the same positions. Keep track of whichever ones have been used (and thus have been moved underground) - you can do some creative effects using hit points (via triggers, cleanup operations) or scale to store data for each prop instance.
 
Somebody said:
That code will go through all the ammo boxes on the scene and keep animating them further down until they loop over on top of your head or something. Try to be more specific with your operations, and don't forget that if you have a collision box it's best practices to disable physics so you can't glitch players/other props with them. Do some proper cleanup, and restore the fixed number of ammo boxes between rounds, etc so you stop accumulating scene props in the same positions. Keep track of whichever ones have been used (and thus have been moved underground) - you can do some creative effects using hit points (via triggers, cleanup operations) or scale to store data for each prop instance.

Doesn't that object relocated a -100 on the Z axis stop at that position? Anyways, converting words into codes isn't so easy the first times you code new features(i'm working on an ammo carrier class for Iron Europe, mod for Napoleonic Wars). Since it's a NW mod, i'm gonna add the item to the "Reset" botton so that once the server is resetted, all the ammo boxes disappear.

Somebody said:
or scale to store data for each prop instance.

Is it possible to scale a prop to a negative or 0 level to make it disappear?

Okay, noticed one thing. I had placed 2 ammo boxes in the map and, as you had predicted, all the ammo boxes disappeared once i picked one up. How can i assign unique instances to each ammobox placed?
 
Docm30 said:
You could just give the troop the 'scn_x|entry(x)' flag. It still works in Warband despite not being used. It should replace the first zero in '0,reserved,' or '0,0,'.

Doesn't appear to work for villages though.

Popped the them inside a tavern instead, but talking to them, they just give me the default hired mercenary response.
 
DanyEle said:
Is it possible to scale a prop to a negative or 0 level to make it disappear?
I personally wouldn't do that, since I have heard that scaling to props to 0 in a dimension can cause crashes. In any case, prop scale is not automatically synchronized with clients as position is, so if you were to send messages to all clients to adjust the scale, you might as well just set the visibility to 0 (setting the position underground is still an easier and more efficient solution).
DanyEle said:
Okay, noticed one thing. I had placed 2 ammo boxes in the map and, as you had predicted, all the ammo boxes disappeared once i picked one up. How can i assign unique instances to each ammobox placed?
What exactly did you do to "pick one up"? Presumably they are not items, though you could probably use spawn_item and ti_on_item_picked_up (mission template trigger) for your purpose. Did you "pick it up" with a scene prop use trigger, or did you just click a presentation overlay when nearby?
 
I have the same items on the same troops for warband but they seem to run now for some reason, does anyone know why. The items have alot of weight and that weight made them encumbrance so they couldn't run but only walk.

 
Hi
I've made a garrison for the training camps

with training
module_simple_triggers
 
  (24,
  [
    (try_for_range, ":training_camp_no", training_grounds_begin, training_grounds_end),
    (party_get_num_companions, ":num_troops", ":training_camp_no"),
    (store_mul, ":mad:p_gain", ":num_troops", 200),
    (party_upgrade_with_xp, ":training_camp_no", ":mad:p_gain", 0),
    (try_end),
      ]),

module_game_menus
    ("training_garrison_troops",
      [
      (store_troop_gold,":player_gold", "trp_player"),  
      (ge, ":player_gold", 100), 
          ],
      "Manage the garrison ",
      [
        (troop_remove_gold,"trp_player",100),         
        (change_screen_exchange_members,1),
      ]),

But where is the srcipt for the pay day when we have troops in garrison please ? like for the castles/towns garrison...
 
Vornne said:
DanyEle said:
Is it possible to scale a prop to a negative or 0 level to make it disappear?
I personally wouldn't do that, since I have heard that scaling to props to 0 in a dimension can cause crashes. In any case, prop scale is not automatically synchronized with clients as position is, so if you were to send messages to all clients to adjust the scale, you might as well just set the visibility to 0 (setting the position underground is still an easier and more efficient solution).
DanyEle said:
Okay, noticed one thing. I had placed 2 ammo boxes in the map and, as you had predicted, all the ammo boxes disappeared once i picked one up. How can i assign unique instances to each ammobox placed?
What exactly did you do to "pick one up"? Presumably they are not items, though you could probably use spawn_item and ti_on_item_picked_up (mission template trigger) for your purpose. Did you "pick it up" with a scene prop use trigger, or did you just click a presentation overlay when nearby?

I selected the object $g_presentation_ammobox_4 string "Pick up ammo box", of the presentation which is activated when using the Ammobox with the F key with the trigger you presumed.
 
DanyEle said:
I selected the object $g_presentation_ammobox_4 string "Pick up ammo box", of the presentation which is activated when using the Ammobox with the F key with the trigger you presumed.
Hmm, have you tested properly with a dedicated server, or are you just testing in client hosted mode? As I keep saying in this thread: only test MP scripts with a dedicated server, with rare exceptions for people that thoroughly know what the differences are.

The ti_on_scene_prop_use trigger only runs on servers, not clients, and presentations run only on clients, not servers; so you probably need to add extra network messages back and forth for your system. Are there any other uses of an ammo box besides picking up to restore ammo to the player's equipment? If not, you should discard your presentation, change the use string on the client to suit (script game_get_use_string), and put your prop movement and agent equipping operations directly in the ti_on_scene_prop_use trigger, using param 1 for the instance id and param 2 for the agent id; otherwise, you would need to create a new network message triggering the display of the ammo presentation, sending params 1 and 2 to the client where they are stored as global variables, then in the presentation trigger send a return message back from the client to the server passing the global variables back as parameters for the server to move the prop and equip the ammo (if you run those operations on an actual client, not a client / server, it will cause errors or a crash).

Why don't you simply spawn normal ammo box items for players to pick up? It would be much simpler.
 
I'm getting this:
Code:
Exporting party_template data...
Traceback (most recent call last):
  File "process_party_tmps.py", line 46, in <module>
    save_party_templates()
  File "process_party_tmps.py", line 25, in save_party_templates
    file.write("pt_%s %s %d %d %d %d "%(convert_to_identifier(party_template[0]),replace_spaces(party_template[1]),party_template[2],party_template[3], party_template[4], party_template[5]))
TypeError: %d format: a number is required, not list

Anyone know what that means?

Edit: Had an error in party_templates. Fixed.
 
FantasyWarrior said:
But where is the srcipt for the pay day when we have troops in garrison please ? like for the castles/towns garrison...
You might want to look into script_calculate_player_faction_wage. There is also a simple_trigger that calls prsnt_budget_report, you could find that useful too.
 
Vornne said:
DanyEle said:
I selected the object $g_presentation_ammobox_4 string "Pick up ammo box", of the presentation which is activated when using the Ammobox with the F key with the trigger you presumed.
Hmm, have you tested properly with a dedicated server, or are you just testing in client hosted mode? As I keep saying in this thread: only test MP scripts with a dedicated server, with rare exceptions for people that thoroughly know what the differences are.

The ti_on_scene_prop_use trigger only runs on servers, not clients, and presentations run only on clients, not servers; so you probably need to add extra network messages back and forth for your system. Are there any other uses of an ammo box besides picking up to restore ammo to the player's equipment? If not, you should discard your presentation, change the use string on the client to suit (script game_get_use_string), and put your prop movement and agent equipping operations directly in the ti_on_scene_prop_use trigger, using param 1 for the instance id and param 2 for the agent id; otherwise, you would need to create a new network message triggering the display of the ammo presentation, sending params 1 and 2 to the client where they are stored as global variables, then in the presentation trigger send a return message back from the client to the server passing the global variables back as parameters for the server to move the prop and equip the ammo (if you run those operations on an actual client, not a client / server, it will cause errors or a crash).

Why don't you simply spawn normal ammo box items for players to pick up? It would be much simpler.

Well, i tested it earlier in a dedicated server, and the presentation didn't pop up. I'll have to re-write it all probably . Anyways, i'll be away for 1 week, so i am not going to bother you for this time :grin:
 
Lumos said:
FantasyWarrior said:
But where is the srcipt for the pay day when we have troops in garrison please ? like for the castles/towns garrison...
You might want to look into script_calculate_player_faction_wage. There is also a simple_trigger that calls prsnt_budget_report, you could find that useful too.

Thank you,thank you,thank you !  :grin:


The_dragon said:
is there any way to force the game keys (on the sp map) to start a presentation, and not to open the inventory, the party window, etc ?

mnf_disable_all_keys

  (
    "choose_skill",mnf_disable_all_keys,
    "{s13}",
    "none",
    [(assign,"$current_string_reg",10),
(assign, ":difficulty", 0),

(try_begin),
(eq, "$character_gender", tf_female),
(str_store_string, s14, "str_woman"),
(val_add, ":difficulty", 1),
(else_try),
(str_store_string, s14, "str_man"),
(try_end),
ect...


it is what you need ?

Or on a scene ?

Use a condition in the mission templates

    (ti_tab_pressed, 0, 0,
      [
        (try_begin),
      (eq, "$combat_is_finished", 1),
        (jump_to_menu, "mnu_town"),# or other
        (finish_mission),
        (else_try),
          (display_message, "str_cannot_leave_now"),
        (try_end),
        ],
      []),

      (ti_inventory_key_pressed, 0, 0,
      [
        (try_begin),
      (eq, "$combat_is_finished", 1),
        (set_trigger_result,1)
        (else_try),
          (display_message, "str_cant_use_inventory_now"),
        (try_end),
      ], []),


and

      (1, 3, ti_once, [(main_hero_fallen,0)],
      [
        (assign, "$combat_is_finished", 1),
        (change_screen_return),
      (jump_to_menu,"mnu_..."),#  or other
        (finish_mission),
        ]),
      (1, 3, ti_once,
      [


        (store_mission_timer_a, reg1),     
        (ge, reg1, 3),
        (num_active_teams_le, 1),
        (neg|main_hero_fallen),
         
        ],
      [
        (assign, "$combat_is_finished", 1),
        (change_screen_return),
      (jump_to_menu,"mnu_..."),#  or other
        (finish_mission),
        ]),
 
How to recognize whether an agent just crouched a lance or kick? By getting the animation?
 
Somebody said:
The_dragon said:
is there any way to force the game keys (on the sp map) to start a presentation, and not to open the inventory, the party window, etc ?
Jump to a menu which starts a presentation.

the thing is that if i do this , it will still open the inventory, and the trigger will not be triggered...
Code:
(0,0,0,[(game_key_clicked,gk_inventory_window)],
[
	(start_presentation, "prsnt_blahblahblah"),
]),

i want to force the player to can't open the game windows(inventory,party,quests, etc..)
 
Status
Not open for further replies.
Back
Top Bottom