Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
kalarhan said:
troycall said:
however I want to make it so that the player does not force to crouch, only the AI crouches.

that is a old OSP, you should check the new operations from 1.153

Code:
agent_ai_set_can_crouch                  = 2083  # (agent_ai_set_can_crouch, <agent_id>, <value>),
                                                 # Version 1.153+. Allows or forbids the agent to crouch. 0 to forbid, 1 to allow.
agent_get_crouch_mode                    = 2097  # (agent_ai_get_crouch_mode, <destination>, <agent_id>),
                                                 # Version 1.153+. Retrieves agent's crouch status (1 = crouching, 0 = standing).
agent_set_crouch_mode                    = 2098  # (agent_ai_set_crouch_mode, <agent_id>, <value>),
                                                 # Version 1.153+. Sets agent's crouch status (1 = crouch, 0 = stand up).

My apologies, I'm still new to modding and I understand this question might be noobish, however, can you provide me with an example on how to use those operations or guide me the right way on using those operations?

Regards,
 
kalarhan said:
troycall said:
an example on how to use those operations

check VC module source. Crouch is used (with those operations) for stealth in a hunting mission.

https://forums.taleworlds.com/index.php/topic,349080.0.html
I've taken a look at it, I added the following to my header operations file under lhs_operations = [ agent_get_crouch_mode, agent_ai_set_can_crouch, agent_set_crouch_mode (Rest are in here, I put the new operations in the end rather than the start).

And I took the following code from VC:

Code:
 (
  ti_on_agent_spawn, 0, 0, [ ],
  [
    (store_trigger_param_1, ":agent_no"),
    (agent_ai_set_can_crouch, ":agent_no", 1),	#for VC-1886
]),
     
      #Player can creep
      (0, 0, 0,
        [
          (key_clicked, key_caps_lock),
        ],
        [
          (get_player_agent_no, ":player_agent"),
          (try_begin),
            (eq, "$player_is_creeping", 1),
            (assign, "$player_is_creeping", 0),
            (call_script, "script_advanced_agent_set_speed_modifier", ":player_agent", 100),
            (agent_set_accuracy_modifier, ":player_agent", 100),
            (agent_set_crouch_mode, ":player_agent", 0),
            # (agent_set_animation, ":player_agent", "anim_crouch_to_stand", 0),
            (agent_set_stand_animation, ":player_agent", "anim_stand"),
            (agent_set_walk_forward_animation, ":player_agent", "anim_walk_forward"),
          (else_try),
            (assign, "$player_is_creeping", 1),
            #(agent_set_wielded_item, ":player_agent", -1),
            (call_script, "script_advanced_agent_set_speed_modifier", ":player_agent", 40),
            (agent_set_accuracy_modifier, ":player_agent", 125),
            (agent_set_crouch_mode, ":player_agent", 1),
            # (agent_set_animation, ":player_agent", "anim_stand_to_crouch", 0),
            (agent_set_stand_animation, ":player_agent", "anim_crouch_unarmed"),
            (agent_set_walk_forward_animation, ":player_agent", "anim_walk_forward_crouch"),
          (end_try),
      ]),
      
      #Go back to crouch after walk
      (0, 0, 0,
        [
          (eq, "$player_is_creeping", 1),
          (neg|game_key_is_down, gk_move_forward),
          (neg|game_key_is_down, gk_move_backward),
          (neg|game_key_is_down, gk_move_left),
          (neg|game_key_is_down, gk_move_right),
          (neg|game_key_is_down, gk_jump),
          (neg|game_key_is_down, gk_attack),
          (neg|game_key_is_down, gk_defend),
          (neg|game_key_is_down, gk_kick),
          (get_player_agent_no, ":player_agent"),
          (agent_get_crouch_mode, reg1, ":player_agent"),
          (eq, reg1, 0),
        ],
        [
          (get_player_agent_no, ":player_agent"),
          (agent_set_crouch_mode, ":player_agent", 1),
          #(agent_set_wielded_item, ":player_agent", itm_practice_bow_2),
      ]),
      
      #Remove weapon on walking
      (0, 0, 0,
        [
          (eq, "$player_is_creeping", 1),
          (game_key_is_down, gk_move_forward),
          (get_player_agent_no, ":player_agent"),
          (agent_get_wielded_item, reg1, ":player_agent", 0),
          (gt, reg1, 0),
          
        ],
        [
          (get_player_agent_no, ":player_agent"),
          (agent_set_wielded_item, ":player_agent", -1),
      ]),
      
      
      # Info
      (1, 0, ti_once, [],
        [
          # (scene_prop_get_instance, reg1, "spr_inventory", 0),
          # (prop_instance_set_scale, reg1, 1, 1, 1),
          
          (tutorial_message_set_size, 20, 20),
          (tutorial_message_set_position, 500, 650),
          (tutorial_message_set_center_justify, 1),
          (tutorial_message_set_background, 1),
          (tutorial_message, "@You can click ' T ' to toggle creeping.", 0xFFd6d3ce, 7),
          #(tutorial_message, s1, 0xFFd6d3ce, 20),
      ]),
      
      # End


Now the issue here is, I can't creep (crouch) nor can my army crouch, All I really want to do is for all AI to be able to crouch rather than just the crossbowmen, and if possible make it so that I can tell my army to crouch/stand/etc as the OSP i showed you a while ago however it crouches my troop as well so its not perfect, as a result the new operations may be a better choice.

Any ideas on how to pull that off?

That is all I found on the code segments in VC and - I'm not sure what im doing wrong.
 
troycall said:
That is all I found on the code segments in VC and - I'm not sure what im doing wrong.

Troycall you need to read the guides on "how to mod", so you can learn how to write your own code and understand it (and how to fix issues). Just copying+pasting stuff is not the way to go. Which ones have you read so far?

Remember that copying code from VC implies you MUST add the DLC on your credits (if you make it public).

And you need this on your module.ini
Code:
can_crouch                              = 1

What you need to do is combine that old OSP with the new operations (to create a better version), or make the old one work (just follow the instructions). And be very specific about what is not working, we can't help if all you say is: "it does not work". VC code is just for the player, its a example on how to use the operations, its not the same feature as the OSP you linked



which version of modules are you using? Those operations are from 1.153, you shouldn't need to include them on your header_operations.py unless you are using a VERY old one.
 
kalarhan said:
troycall said:
That is all I found on the code segments in VC and - I'm not sure what im doing wrong.

Troycall you need to read the guides on "how to mod", so you can learn how to write your own code and understand it (and how to fix issues). Just copying+pasting stuff is not the way to go. Which ones have you read so far?

Remember that copying code from VC implies you MUST add the DLC on your credits (if you make it public).

And you need this on your module.ini
Code:
can_crouch                              = 1

What you need to do is combine that old OSP with the new operations (to create a better version), or make the old one work (just follow the instructions). And be very specific about what is not working, we can't help if all you say is: "it does not work". VC code is just for the player, its a example on how to use the operations, its not the same feature as the OSP you linked



which version of modules are you using? Those operations are from 1.153, you shouldn't need to include them on your header_operations.py unless you are using a VERY old one.
I was able to implement the crouching system from that OSP correctly, however as stated it crouches the player too regardless during movement, perhaps its due to the new animations set by it, if I can prevent the player from crouching when they move sideways (NW, NE, SW, SE) then it'll be just perfect.

I've added "can_crouch = 1" before in module.ini, the source code im working on is under 1.153 but the operations were not included in 1hs operations (header_operations) however were included in the header_operations themselves (so they exist, but don't execute under 1hs operations), they just weren't executable.

From looking at the VC Code I assumed when its added to mission_templates, you would be able to "creep" as in crouch and your army would do same thing by pressing a specified key,

You are right about copying and pasting isn't the right way to do things, I've only read one guide so far and that is how to setup the module system, the rest I improvised myself through skimming through the source codes.

Do you have any guides you wish to recommend?
 
ZektorSK said:
How do I make vassals hate each other in faction ?

you can use "script_troop_change_relation_with_troop" insde a loop filtered by faction. Keep in mind that script also generates controversy, so you may want to avoid that part.



troycall said:
Do you have any guides you wish to recommend?
1) Learn to use display_message to print debug messages. That way you can see what is going on with your code
https://forums.taleworlds.com/index.php/topic,347990.msg8335287.html#msg8335287

2) Read on mission_template modding. You need to check how triggers work on a scene/mission
2.1) Check the comments on the file itself. It explains how things are roughly organized
2.2) This old guide on triggers https://forums.taleworlds.com/index.php/topic,14272.0.html
2.3) Read the header_triggers.py (Lav's version) for the types of triggers used on a mission

3) I scanned the OSP code. It has specific code for AI and the player, so you should not crouch when giving a order for bots. Unless you modified it, so you will need to show what/where/how/why once you did a bit of debbuging yourself (1)

Not sure why you are using a old version for your base game, but that is up to you (1.153). Also consider using Sublime API and WRECK (find them on the tools sections).
 
I've assigned a global variable properly, made a checkbox for it, checkbox and text (module_presentations) (That variable assigned in module_presentations changes the value of a variable in module_scripts)
I'm trying to figure out how to use the global variable now (The one in module_scripts), for example I want it so that when the variable is set to -1,

The following code would go from:
Code:
     (agent_get_speed, pos6, ":agent"),
     (set_fixed_point_multiplier, 100),
To:
Code:
     (agent_get_speed, pos6, ":agent"),
     (set_fixed_point_multiplier, 1000),

and when set to 0 it remains at its default value (100), if set to 1 it goes to a value of 0.
How can I achieve that, I can use the global variable so that its alter-able from mod options, but how do I fit in the global variable in that code?

Also, I'd like to be able to hide certain menus during encounters, here is an example of one I'd like to hide by using global variable $battle_time which I assigned under mod options, and scripts.

Code:
	#COOP BEGIN Join battle#############################		  
      ("coop_setup",[
        (call_script, "script_coop_get_battle_state", 1), #sets coop_battle_state
        (this_or_next|ge, "$cheat_mode", 1),
        (eq, "$coop_battle_state", coop_battle_state_none),
      ],"Setup multiplayer battle.", 
      [
        (assign, "$coop_battle_type", coop_battle_type_field_battle),
        (assign, "$coop_encountered_party", "$g_enemy_party"),
        (call_script, "script_coop_copy_parties_to_file_sp"),
        (try_begin),
          (eq, "$coop_skip_menu", 1),
          (change_screen_quit), 
        (try_end),
      ]),
 
Greetings to all modmakers.
Is there any possibility to add a Companion(Borcha for example) into  starting party? So when you would appear on a world map, there will be acompanion into your army.
 
TRCY_Maresal said:
erennuman_mb said:
kalarhan said:
TRCY_Maresal said:
How I can add a navy? These navies must be controlled by any faction.

OSP section has a pack or two to add navigation. You can also check VC source for another approach.
I think he wants to add a national navy for each faction. Not specific navies for lords or the player.

Yes, I want this

I spawned mine like bandit parties
 
homicuda said:
Greetings to all modmakers.
Is there any possibility to add a Companion(Borcha for example) into  starting party? So when you would appear on a world map, there will be acompanion into your army.
Easy. In module_scripts.py, the first script is game_start. Add this to the end of the script: (party_add_members, "p_main_party", "trp_npc1", 1), or simply (troop_join, "trp_npc1"),
 
erennuman_mb said:
homicuda said:
Greetings to all modmakers.
Is there any possibility to add a Companion(Borcha for example) into  starting party? So when you would appear on a world map, there will be acompanion into your army.
Easy. In module_scripts.py, the first script is game_start. Add this to the end of the script: (party_add_members, "p_main_party", "trp_npc1", 1), or simply (troop_join, "trp_npc1"),
ty much!
 
homicuda said:
erennuman_mb said:
homicuda said:
Greetings to all modmakers.
Is there any possibility to add a Companion(Borcha for example) into  starting party? So when you would appear on a world map, there will be acompanion into your army.
Easy. In module_scripts.py, the first script is game_start. Add this to the end of the script: (party_add_members, "p_main_party", "trp_npc1", 1), or simply (troop_join, "trp_npc1"),
ty much!

instead of that use the script to include a companion. Its not a simple troop, you need to set some other flags
Code:
script_recruit_troop_as_companion

otherwise you will have bugs with quests, dialogs, duplication, npc notes, etc
 
troycall said:
I'm trying to figure out how to use the global variable now

you can use it just like a local variable. Say its "$my_global"

Code:
(eq, "$my_global", 10),

(assign, "$my_global", 100),

and so on

Your menu already has a example of globals being used:
Code:
   (this_or_next|ge, "$cheat_mode", 1),
   (eq, "$coop_battle_state", coop_battle_state_none),

menu options have two blocks of code: condition and consequence. If condition fails at any line, the option won't be displayed.

Code:
 ("coop_setup",[

       (eq, "$my_global", 1), # only shows this if the global is 1

        (call_script, "script_coop_get_battle_state", 1), #sets coop_battle_state
        (this_or_next|ge, "$cheat_mode", 1),
        (eq, "$coop_battle_state", coop_battle_state_none),
      ],"Setup multiplayer battle.", 
      [
        (assign, "$coop_battle_type", coop_battle_type_field_battle),
        (assign, "$coop_encountered_party", "$g_enemy_party"),
        (call_script, "script_coop_copy_parties_to_file_sp"),
        (try_begin),
          (eq, "$coop_skip_menu", 1),
          (change_screen_quit), 
        (try_end),
      ]),
 
kalarhan said:
troycall said:
I'm trying to figure out how to use the global variable now

you can use it just like a local variable. Say its "$my_global"

Code:
(eq, "$my_global", 10),

(assign, "$my_global", 100),

and so on

Your menu already has a example of globals being used:
Code:
   (this_or_next|ge, "$cheat_mode", 1),
   (eq, "$coop_battle_state", coop_battle_state_none),

menu options have two blocks of code: condition and consequence. If condition fails at any line, the option won't be displayed.

Code:
 ("coop_setup",[

       (eq, "$my_global", 1), # only shows this if the global is 1

        (call_script, "script_coop_get_battle_state", 1), #sets coop_battle_state
        (this_or_next|ge, "$cheat_mode", 1),
        (eq, "$coop_battle_state", coop_battle_state_none),
      ],"Setup multiplayer battle.", 
      [
        (assign, "$coop_battle_type", coop_battle_type_field_battle),
        (assign, "$coop_encountered_party", "$g_enemy_party"),
        (call_script, "script_coop_copy_parties_to_file_sp"),
        (try_begin),
          (eq, "$coop_skip_menu", 1),
          (change_screen_quit), 
        (try_end),
      ]),

I figured out everything except this one part, where I want the fixed point multiplier to change the amount from the global variable.

So simplified: Usage is the global variable varies into 3 values (0, 1, 2) and I want it so that when its set to 1 & 2, the fixed point multiplier goes from 100 to 1000, while if the global variable value is set to 0, then the fixed point multiplier will remain untouched (100) the fixed point multiplier below in the code below that is.
Here is somewhat functional code, which does its purpose if value is set to 0 as far as I am aware

Somewhat functional code (Does its purpose for value 0 but Idk how to add more values to it (if value is 1 or 2 from the global variable):

Code:
	 	 (agent_get_speed, pos6, ":agent"),
                         (eq, "$ai_crouch_mode", 0),
			(assign, ":valuecr", 100),
                         (try_begin), #Added as failsafe to not touch other values latter in the code
			(set_fixed_point_multiplier, ":valuecr"),
			 (try_end), #Added as failsafe

Default Code:
Code:
     (agent_get_speed, pos6, ":agent"),
     (set_fixed_point_multiplier, 100),
     (position_get_y,":speed",pos6), (store_mul, ":speed2", ":speed",2), (val_abs, ":speed2"),
     (position_get_x,":drift",pos6), (assign, ":abs_drift", ":drift"), (val_abs, ":abs_drift"),
 
Status
Not open for further replies.
Back
Top Bottom