Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
I noticed a number of servers (especially in NW) have a feature where you can type something into chat e.g. /help and it will do a particular command. How would you go about creating something like this? Would it have to be connected to a webserver or something? And how would you be able to check if a particular word like /help was written in the chat?
Thanks
 
pete99 said:
Would it have to be connected to a webserver or something? And how would you be able to check if a particular word like /help was written in the chat?

Native Warband doesnt have operations to handle strings (text), so you need to hack around it using a direct comparison with the numerical value (letter a = xx, letter b = xx, etc). You can find tutorials on how to do that to create new console options. What you do is capture each typed key and then check if it matches a full word from your list, at which point you fire some event (be for SP or MP).

WSE includes operations for that, so should be easier to handle. So first check if you want to use it or a Native-only resource.

There should be admin tools ready for use if you check the released mods section like https://forums.taleworlds.com/index.php/topic,142989.msg3434199.html#msg3434199. Or someone that mods MP can link newer stuff here.
 
Thanks. Is there a way to check if general/team chat window is open? I seem to only be able to find a presentation for the admin chat...not any of the others.

Edit: Also, I've been looking into using operations such as key_clicked for some time, but was wondering if these can be done server-side alone? In NW they have added the whole custom keys thing, where a trigger fires checking if a key is clicked, then using a constant from module_constants  e.g (player_action_key_b)  you could create a script based off it in module scripts. I tried to create my own, exactly the same, but using a different key, but I didn't get a response. Is this something that requires a client side modification?
 
WilhelmKohle1992 said:
Hey, so I got a question - you know those 4 free attribute points you get when creating a new character. Is it possible to get rid of them?

we dont have operations for complete troop stats manipulation, as the UI for character is hardcoded inside the engine (and not a presentation on the modsys). You could go around it with some hacks and create your own UI, but that is advanced stuff.

experiment with stuff you can do like creating a troop of higher level, changing the module.ini stats config, negative XP, giving stats on a secondary screen (like a dialog or game menu), etc, and see if you can find a solution that fits close to your design.
 
pete99 said:
Thanks. Is there a way to check if general/team chat window is open? I seem to only be able to find a presentation for the admin chat...not any of the others.

Edit: Also, I've been looking into using operations such as key_clicked for some time, but was wondering if these can be done server-side alone? In NW they have added the whole custom keys thing, where a trigger fires checking if a key is clicked, then using a constant from module_constants  e.g (player_action_key_b)  you could create a script based off it in module scripts. I tried to create my own, exactly the same, but using a different key, but I didn't get a response. Is this something that requires a client side modification?



You can catch new added "chats" only  with client-side mod.


But you can also  catch default chats  without client-side mod using WSE Serverside.
 
How to disable bots spawning as cavalry on certain scene(s) in team deathmatch, deathmatch and battle modes in NW and in Warband?

I've added to my scene spr_mm_spawn_restrictions with var1=1 - but bots still spawn as infantry and cavalry (the same happens if var1=2, but in the same time it affects me as player, in second case I can't spawn as infantry). I tried to figure out what should I change in mission_templates (as I was advised before) so bots won't spawn as cavalry. I need to disable cavalry only on certain scenes, so I don't want to change list of available bots, excluding cavalry. I guess it can be done by adding code which will say something like this:
Code:
     (try_begin),
        CURRENT MAP IS INFANTRY_MAP_1
        (try_for_range, ":cur_ai_troop", LIST OF INFANTRY UINITS),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),
     (else_try),
      (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),

But I don't know how to say in MBScript "CURRENT MAP IS ...". Can someone help me with this?

UPD. I tried to do it myself, but no luck. It seems that in mission_templates it can't be done because mission_templates doesn't import from module_scenes. So, I guess, it must be done in module_scripts. Please help me someone, you are my only hope :smile: Those cavalry bots are very out of place in scene of assault on field fortifications.
 
Ivkolya said:
How to disable bots spawning as cavalry on certain scene(s) in team deathmatch, deathmatch and battle modes in NW and in Warband?

I've added to my scene spr_mm_spawn_restrictions with var1=1 - but bots still spawn as infantry and cavalry (the same happens if var1=2, but in the same time it affects me as player, in second case I can't spawn as infantry). I tried to figure out what should I change in mission_templates (as I was advised before) so bots won't spawn as cavalry. I need to disable cavalry only on certain scenes, so I don't want to change list of available bots, excluding cavalry. I guess it can be done by adding code which will say something like this:
Code:
     (try_begin),
        CURRENT MAP IS INFANTRY_MAP_1
        (try_for_range, ":cur_ai_troop", LIST OF INFANTRY UINITS),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),
     (else_try),
      (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),

But I don't know how to say in MBScript "CURRENT MAP IS ...". Can someone help me with this?

UPD. I tried to do it myself, but no luck. It seems that in mission_templates it can't be done because mission_templates doesn't import from module_scenes. So, I guess, it must be done in module_scripts. Please help me someone, you are my only hope :smile: Those cavalry bots are very out of place in scene of assault on field fortifications.

For singleplayer, in Warband's module_mission_templates.py look at the first mission "town_default". You'll see that the spawn records are flagged af_override_horse so troops will spawn dismounted.

I don't code multiplayer, but if you look in Warband's module_mission_templates.py at multiplayer_ccoop you'll see the same thing is down by a trigger:

Code:
(ti_before_mission_start, 0, 0, [],
		[
			(assign, "$g_multiplayer_game_type", multiplayer_game_type_captain_coop),	
            
            
            (store_current_scene, ":cur_scene"),
            (scene_get_slot, "$g_ccoop_disallow_horses", ":cur_scene", slot_scene_ccoop_disallow_horses),
            (try_begin),
              (eq, "$g_ccoop_disallow_horses", 1),
              (try_for_range, ":cur_entry", 0, 100),
                (mission_tpl_entry_set_override_flags, "mt_multiplayer_ccoop", ":cur_entry", af_override_horse),
              (try_end),

etc. However, here it only appears to disallow horses conditionally.
 
NPC99 said:
For singleplayer, in Warband's module_mission_templates.py look at the first mission "town_default". You'll see that the spawn records are flagged af_override_horse so troops will spawn dismounted.

Thank you for your answer, but in this case it will be just dismounted cavalry, and I need infantry only
 
Ivkolya said:
Thank you for your answer, but in this case it will be just dismounted cavalry, and I need infantry only
iirc you can't spawn cavalry troops as infantry group. You can either spawn them dismounted, or not spawn them at all. For the latter try this as the spawn condition:
Code:
(agent_get_troop_id, <destination>, <agent_id>),
(neg|troop_is_guarantee_horse, <troop_id>),
 
UndeadDuke said:
iirc you can't spawn cavalry troops as infantry group. You can either spawn them dismounted, or not spawn them at all. For the latter try this as the spawn condition:
Code:
(agent_get_troop_id, <destination>, <agent_id>),
(neg|troop_is_guarantee_horse, <troop_id>),

Thank you for answer, UndeadDuke, that's what I need - no cavalry units (players and bots, mounted and dismounted) on certain scenes of my mod (for now I'm talking about team deathmatch in NW, but later I'll need no cavalry on some singleplayer scenes), so your code is what I need. But I am no coder, I slowly learn myself, so sorry for maybe dumb question - where should I add this spawn condition? Should I write new script (as I understand, it should be at the bottom of module_scripts.py so it won't break order of scripts)? Or maybe there is a script I could change by adding these lines?


PitchPL said:
If you need only that its

Code:
    (store_current_scene, ":cur_scene"),
   (eq, ":cur_scene", "scn_mp_old_castle"),

etc

Thank you, PitchPL!
 
Ivkolya said:
But I am no coder, I slowly learn myself
Sadly this is an accurate description for us both, so not much I can help here  :sad: I never tried to prevent some troops from spawning, and I'm not sure if it can be done setting trigger result of ti_on_agent_spawn to 0 or -1. You can always make cavalry agents fade out after spawn but thats not the best solution. Hopefully someone here with bigger experience wil help you more...
 
Meanwhile I tried to find solution by changing mission templates (I added import from module_scenes at the beginning of file to have ability to specify scene)

Code:
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
	  (store_current_scene, ":cur_scene"),  #my new script

      (try_begin),                                                                                                               
	   (eq, ":cur_scene", "scn_assault_on_malakoff_test"), #if map is my new map
	   (eq, "$g_multiplayer_game_type", multiplayer_game_type_team_deathmatch),#and gamemode is deathmatch
       (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),#troops which can be spawned
	   (neg|tf_mounted, ":cur_ai_troop"),     #but not troops with flag "tf_mounted"
         (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
         (eq, ":ai_troop_faction", ":team_faction"),
         (val_add, ":num_ai_troops", 1),
	  (try_end),
	  
      (else_try),
	   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end), [color=green]#original script[/color]
         (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
         (eq, ":ai_troop_faction", ":team_faction"),
         (val_add, ":num_ai_troops", 1),
      (try_end),

this is final variant for now, but all variants are leading to bots not spawn at all (they are in the list of players on server, but they all are dead). What can be wrong with this code?

UPD. I've changed code a bit
Code:
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
	  (store_current_scene, ":cur_scene"),
      (try_begin),
	   (eq, ":cur_scene", "scn_assault_on_malakoff_test"),
	   (eq, "$g_multiplayer_game_type", multiplayer_game_type_team_deathmatch),
       (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
	   (neg|troop_select_type_cavalry, ":cur_ai_troop"),        #exclude troop type cavalry
         (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
         (eq, ":ai_troop_faction", ":team_faction"),
         (val_add, ":num_ai_troops", 1),
	  (try_end),
	  
      (else_try),
	   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
         (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
         (eq, ":ai_troop_faction", ":team_faction"),
         (val_add, ":num_ai_troops", 1),
      (try_end),

But now when I add bots to the game in team deathmatch mode on my map - game crashes with error "Invalide opcode -2147483646"

So this code works, but now I need right code, how to exclude AI cavalry from spawning
 
(call_script, "script_multiplayer_find_bot_
troop_and_group_for_spawn", ":selected_
team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),
      (team_get_faction, ":team_faction",
":selected_team"),
      (assign, ":num_ai_troops", 0),
(store_current_scene, ":cur_
scene"),  #my new script

Hi, you can try changing from troops to agents. Then using (agent_get_horse, ":value", ":agent_id"), where value is -1 to allow unmounted to spawn and an else_try option that uses (remove_agent, ":agent_id"), to remove mounted agents.

This is a brute force method that may lead to the need for a count of the total combatants and if less, spawn more agents after setting a spawn point - (set_spawn_position, posX). Hope this helps.
 
Status
Not open for further replies.
Back
Top Bottom