Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
kalarhan said:
Khamukkamu said:
is there an operation that commands an agent to go in "charge mode"?

alarmed

Code:
agent_set_is_alarmed                     = 1807  # (agent_set_is_alarmed, <agent_id>, <value>),
                                                 # Sets agent's status as alarmed (value = 1) or peaceful (value = 0).

you can also set agents on special mode, disable movement speed, etc, to keep them behind.

Thanks kalarhan.

So for instance, I order a whole team to move + hold towards X position. Sometimes, not all team members get there in time, but when one of the agents does get there, if I set him to 'alarmed', it will override the 'hold' command and go into charge mode (i.e attack enemies wherever they may be)?
 
Khamukkamu said:
So for instance, I order a whole team to move + hold towards X position. Sometimes, not all team members get there in time, but when one of the agents does get there, if I set him to 'alarmed', it will override the 'hold' command and go into charge mode (i.e attack enemies wherever they may be)?

that is one way to do it, and what they use for the fugitive quest (turn one npc in the village hostile).

you can also use teams, teams relation, agents relations, custom AI (then go back to default AI), and so on.

A example of using teams is the tavern drunk
Code:
 ("activate_tavern_attackers",
    [
      (set_party_battle_mode),
      (try_for_agents, ":cur_agent"),
        (agent_get_troop_id, ":cur_agent_troop", ":cur_agent"),
        (this_or_next|eq, ":cur_agent_troop", "trp_fugitive"),
        (this_or_next|eq, ":cur_agent_troop", "trp_belligerent_drunk"),
        (eq, ":cur_agent_troop", "trp_hired_assassin"),
        (agent_set_team, ":cur_agent", 1),
        (assign, "$g_main_attacker_agent", ":cur_agent"),
        (agent_ai_set_aggressiveness, ":cur_agent", 199),
        (team_give_order, 1, grc_everyone, mordr_charge),
      (try_end),
  ]),
  
  ("deactivate_tavern_attackers",
    [
      (finish_party_battle_mode),
      (try_for_agents, ":cur_agent"),
        (agent_get_troop_id, ":cur_agent_troop", ":cur_agent"),
        (this_or_next|eq, ":cur_agent_troop", "trp_fugitive"),
        (this_or_next|eq, ":cur_agent_troop", "trp_belligerent_drunk"),
        (eq, ":cur_agent_troop", "trp_hired_assassin"),
        (agent_set_team, ":cur_agent", 0),
        (agent_ai_set_aggressiveness, ":cur_agent", 0),
      (try_end),
  ]),
-> note that this mission template starts as neutral, not in combat mode.



dlwnsdn4 said:
Fire_and_Blood said:
Would be easier to just use older warband version, if you don't want to import those scripts to new module system
thank you :grin:
Using 1.153 Warband may not be that easy, as it is possible you won`t be able to install the game depending on your serial key.
 
When I want to remove all information from a slot, do I use 0 or -1? Is there even a difference?

Code:
(party_set_slot, ":party_no", slot_xxx, 0),
(party_set_slot, ":party_no", slot_xxx, -1),
 
dlwnsdn4 said:
Fire_and_Blood said:
Would be easier to just use older warband version, if you don't want to import those scripts to new module system
thank you :grin:

i thought that download old version of warband game(from here :  https://forums.taleworlds.com/index.php/topic,326973.msg7722099.html#msg7722099)
and copy all old datas and paste to 1.172...maybe i better check whether that works or not..
Using 1.153 Warband may not be that easy, as it is possible you won`t be able to install the game depending on your serial key.
[/quote]
 
it's no good to mess with the versions.

Either:

Use Warband 1.153 and use your current mod, which works on 1.153

Or:

Use Warband 1.172, use MS for 1.172 and insert the scripts of your Diplomacy, PBOD, Freelancer into that MS.
 
Fire_and_Blood said:
When I want to remove all information from a slot, do I use 0 or -1? Is there even a difference?

Code:
(party_set_slot, ":party_no", slot_xxx, 0),
(party_set_slot, ":party_no", slot_xxx, -1),

Somebody said:
0 should be the default slot value.

0 (zero) is the engine default. Now you need to check your own game code, as it may use flags with 0 (zero) as a actual value, in which case you will see the use of "-1" to represent not defined.

It is one of those cases where convention is important, but Native and mods don`t sticky to it and you have to pay attention to not end up using a value that represents something else.

Example: if this is the current convention on that piece of code
Code:
-1 => not defined
0  => False
1  => True

and you accidently use code to consider 0 as NOT DEFINED, you now have a logic bug  :iamamoron:


Another example are operations that return the value "-1" as NOT FOUND. That happens because the modsys and some of the engine uses 0 as a valid ID (like for troops where ID = 0 is the trp_player)
 
Cheers guys. Gonna be a nightmare to check that for all slots, but doable.

Another quick question:
I added a bunch of new settlements between village_110 and salt_mine, that are supposed to be hidden, but they are listed under Locations.

Here's the code used in script_game_start:
Code:
(try_for_range, ":new_fief", "p_new_fief_1", "p_salt_mine),
(disable_party, ":new_fief"),
(party_set_note_available, ":new_fief", 0),
(try_end),
 
Fire_and_Blood said:
I added a bunch of new settlements between village_110 and salt_mine, that are supposed to be hidden, but they are listed under Locations.

Look at the last lines on "game_start"

Code:
      (try_for_range, ":party_no", centers_begin, centers_end),
        (party_set_note_available, ":party_no", 1),
      (try_end),

where did you put your code?
 
Getting some weird slot problems.

When using: "Go to marketplace", there are no merchants for my new towns :cry:
In game_menus, only the following requirement exists, so somehow that is not met for new towns:
Code:
("trade_with_arms_merchant",[
(party_slot_ge, "$current_town", slot_town_weaponsmith, 1)],
       "Trade with the arms merchant.",
       [
           (party_get_slot, ":merchant_troop", "$current_town", slot_town_weaponsmith),
## Companions Overview, by Jedediah Q, modified by lazeras
	    (assign, "$jq_current_town", "$current_town"),
	    (assign, "$jq_current_shop", ":merchant_troop"),
##
           (change_screen_trade, ":merchant_troop"),
        ]),

The following code is used to set the scenes and slots for things like weaponsmith, etc.

Code:
# "script_set_town_scene"
    # Description: Here we set the scenes for a new town. Might make this terrain based, as for vilages, later on.
    # Input: party_id of town
    # Output: none
    ("set_town_scene",
     [
      (store_script_param_1, ":town_no"),
      ######## Here we assign all troops required for a town
      (assign, ":end_cond", mayors_end),
      
      (try_for_range, ":free_mayor", mayors_begin, ":end_cond"),
        (party_slot_eq, ":free_mayor", slot_trp_is_active, 0),        # Since we assign all troops at the same time, if mayor 25 is unused, all other 25th troops should be unused as well. Should be always true. So realistically, setting trp_is_active for other troops is not required, however, just do it for safety. Though we never check for it, yet.
        (store_sub, ":offset", ":free_mayor", mayors_begin),
        (store_add, ":cur_object_no", "trp_town_1_mayor", ":offset"),
        (party_set_slot,":town_no", slot_town_elder, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
        (store_add, ":cur_object_no", "trp_town_1_tavernkeeper", ":offset"),
        (party_set_slot,":town_no", slot_town_tavernkeeper, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
##############################################################
        (store_add, ":cur_object_no", "trp_town_1_weaponsmith", ":offset"),
        (party_set_slot,":town_no", slot_town_weaponsmith, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
##############################################################
        (store_add, ":cur_object_no", "trp_town_1_armorer", ":offset"),
        (party_set_slot,":town_no", slot_town_armorer, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
        (store_add, ":cur_object_no", "trp_town_1_merchant", ":offset"),
        (party_set_slot,":town_no", slot_town_merchant, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
        (store_add, ":cur_object_no", "trp_town_1_horse_merchant", ":offset"),
        (party_set_slot,":town_no", slot_town_horse_merchant, ":cur_object_no"),
        (party_set_slot, ":cur_object_no", slot_trp_is_active, 1),
        (store_add, ":cur_object_no", "scn_town_1_center", ":offset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),    #F&B Check Can we use this multiple times? 
        (assign, ":free_mayor", ":end_cond"),   #break
      (try_end),
      ######## Here we assign all scenes required for a town
     # (try_for_range, ":random_town", _begin, _end),
        (store_random_in_range, ":offset", 1, 22),  #22 towns, picks random scenes for now. Gonna improve later on
        
        (store_add, ":cur_object_no", "scn_town_1_center", ":offset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_castle", ":offset"),
        (party_set_slot,":town_no", slot_town_castle, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_prison", ":offset"),
        (party_set_slot,":town_no", slot_town_prison, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_walls", ":offset"),
        (party_set_slot,":town_no", slot_town_walls, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_tavern", ":offset"),
        (party_set_slot,":town_no", slot_town_tavern, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_store", ":offset"),
        (party_set_slot,":town_no", slot_town_store, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_arena", ":offset"),
        (party_set_slot,":town_no", slot_town_arena, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_alley", ":offset"),
        (party_set_slot,":town_no", slot_town_alley, ":cur_object_no"), 
      #(try_end),
        (party_set_slot,":town_no", slot_town_reinforcement_party_template, "pt_center_reinforcements"),  
        #Check, whether town needs to be besieged with belfry
        (try_begin),              #F&B check. If we messed up, we are off by 1 
          (this_or_next|eq, ":offset", 12),
          (eq, ":offset", 15),
          (party_set_slot, ":town_no", slot_center_siege_with_belfry, 1),
        (try_end),
        (try_for_range, ":walker_no", 0, num_town_walkers),
          (call_script, "script_center_set_walker_to_type", ":town_no", ":walker_no", walkert_default),
        (try_end),
     ]),
 
Fire_and_Blood said:
slots issues

check your slots (either after allocation or on the script itself). You can use MnBSaveGameEditor, a in-game presentation to see slots, use rgl_log.txt, etc.

A example would be
Code:
 (party_set_slot,":town_no", slot_town_weaponsmith, ":cur_object_no"), 

 (try_begin), #logging 
     (eq, 1, 1),    
     (assign, reg20, ":town_no"),
     (assign, reg21, ":cur_object_no"),

     (str_store_party_name, s20, reg20), 
     (str_store_troop_name, s21, reg21),

     (display_message, "@Weaponsmith: {reg21} | {s21} | Town: {reg20} | {s20}"), 
 (try_end),


then check your rgl_log.txt to see if all towns are getting a npc. If not, start to track the bug (you can use logging in other parts of the script)
 
Using the Debug OSP to get slot values, how can I convert the numbers to the slot_constants? Is it just a list going from top to bottom? Or do the numbers behind the slots mean anything?

For example, some numbers are used multiple times, e.g

spai_engaging_party = 10
slot_scene_belfry_props_begin = 10
slot_troop_leaded_party = 10

So if I get a value for slot 10, how can I relate that to a certain slot?
 
Fire_and_Blood said:
Using the Debug OSP to get slot values, how can I convert the numbers to the slot_constants? Is it just a list going from top to bottom? Or do the numbers behind the slots mean anything?

For example, some numbers are used multiple times, e.g

spai_engaging_party = 10
slot_scene_belfry_props_begin = 10
slot_troop_leaded_party = 10

So if I get a value for slot 10, how can I relate that to a certain slot?

slot_XXX means slot #10
spai_XXX means the value of that slot.

as a scene is a different thingy than a troop, their slots don't collide. If you don't know how databases work, you can think of a Spreadsheet (like Excel) where each sheet is a entity (Troop, Party, etc).

Same thingy with different types of the same entity. A lord and a soldier are types of Troops, but they don't share the same configuration (slots), so you can re-use the same slot id 

Download MnbSaveGameEditor and play with the database to learn more about how data is stored.
 
Oh man, the devil's in the detail.

trp_weaponsmith_1, requires the use of troop_get_slot, etc. not party_slot_eq, etc.

Edit:
1) How does one fix the error, where in every scene, multiple clones of the player spawn?

I know it's a common problem and there should be tons of posts about it, but couldn't find any...

2) store_distance_to_party_from_party:
does it measure actual ingame distance, or air travel distance?

3) How to fix invalid script parameter?
("build_village",
  [(store_script_param_1, ":eek:rig_center"),

Sometimes it is run with parameter, sometimes without.
call_script, "script_build_village, ":eek:rig_center"),
call_script, "script_build_village),
 
The clones spawn because there's no troop check when it fetches from the center's slots. If the slot is not set, it's 0, which leads to player clones being spawned. If you're talking about the center slots debug I implemented in Diplomacy you would have to generate a bunch of (contiguous) strings and use that instead of the register value. In that OSP if the slot's current value is 0 it gets skipped.
 
Hi all, noob question here: can I store a string in a global var?

If so, how do I call it when I want to use it?

(str_store_string, s7, "@$<global_var>")? or (str_store_string, s7, "$<global_var>")?
 
Khamukkamu said:
can I store a string in a global var?

String is a text. Global variable is a number. Not compatible.

What you can do is reserve some String registers as you have a bunch (s1, ..., s10, ..., s50, ...) to use for something.

You can also use module_strings.py to build the strings (even with parameters), and use the global to store the ID of that string.

You can use the global variable as a filter parameter in a script that builds your string from quick strings.

And so on.

If you need help post your user case (what are you are trying to do).

 
Status
Not open for further replies.
Back
Top Bottom