How to add troop non spawn as testing bot?

Users who are viewing this thread

You can customize which troops the testing bots are chosen from in script_check_spawn_bots (about line 10641 of module_scripts.py); the current behavior is to select randomly between the constants playable_troops_begin and playable_troops_end, which are defined in module_constants.py. You could shift your new troops to a section after all the current pw troops but before playable_troops_end, then add a new constant defined like this:
Code:
testing_bot_troops_end = "trp_godlike_hero"
Then change the store_random_in_range line of script_check_spawn_bots to choose between playable_troops_begin and testing_bot_troops_end.
 
and i have another question how to set commoner begin troop? and i want testing bots not kill Them self [i mean testing bots not kill testing bot]

ps.sorry for my english
 
I am currently working away from home for another day, so don't have access to a proper environment for searching, writing, and testing code: I could probably answer better later.

To set the troop players initially join as, the easiest way would be to change the stats of the commoner entry without changing the identifier (you can change the visible name in the second field - not the first field, or search the module system for occurrences of playable_troops_begin and "trp_commoner", replacing when relevant (use "git grep" from the command line for extremely fast searching of the entire repository - you can also search in any commit).

To make bots not attack each other, set them in a different hard coded team from 3 - 7 and set the team relations to be friendly to each other but hostile to the player team 1 (human players can only use teams 0 and 1, hard coded into the multiplayer part of the engine); you could either set the relevant parameter of add_visitors_to_current_scene (see header_operations) or use agent_set_team from inside ti_on_agent_spawned.
 
Thank you for your answer agian :grin: but idon't understand this

To make bots not attack each other, set them in a different hard coded team from 3 - 7 and set the team relations to be friendly to each other but hostile to the player team 1 (human players can only use teams 0 and 1, hard coded into the multiplayer part of the engine); you could either set the relevant parameter of add_visitors_to_current_scene (see header_operations) or use agent_set_team from inside ti_on_agent_spawned.
 
After testing the team_no parameter of add_visitors_to_current_scene, it seems that it only works for the hard coded multiplayer teams, 0 and 1; so you would need to use the agent_set_team method on spawn (which I know works, for bots). First define a label for the team number you want to use in header_common.py, after the current "team_default", "team_spawn_invulnerable", "team_spectators" lines:
Code:
team_bots                                       = 3
Then set the relations in a mission start trigger, like the one named before_mission_start_setup in PW:
Code:
    (team_set_relation, team_bots, team_bots, 1), # make bots allied to each other
    (team_set_relation, team_bots, team_default, -1), # make bots enemies with the default player team
    (team_set_relation, team_default, team_bots, -1),
    (team_set_relation, team_bots, team_spawn_invulnerable, 0), # prevent bots from attacking players while protected for 10 seconds after spawn
    (team_set_relation, team_spawn_invulnerable, team_bots, 0),
Then add this block either at the start or the end of script_on_agent_spawned (which is called by the mission template trigger ti_on_agent_spawn):
Code:
    (try_begin), 
      (agent_is_non_player, ":agent_id"),
      (agent_set_team, ":agent_id", team_bots),
    (try_end),
And then you get an unending rabble surrounding and constantly attacking you, like the sallies against castle sieging in single player...
 
Vornne said:
After testing the team_no parameter of add_visitors_to_current_scene, it seems that it only works for the hard coded multiplayer teams, 0 and 1; so you would need to use the agent_set_team method on spawn (which I know works, for bots). First define a label for the team number you want to use in header_common.py, after the current "team_default", "team_spawn_invulnerable", "team_spectators" lines:
Code:
team_bots                                       = 3
Then set the relations in a mission start trigger, like the one named before_mission_start_setup in PW:
Code:
    (team_set_relation, team_bots, team_bots, 1), # make bots allied to each other
    (team_set_relation, team_bots, team_default, -1), # make bots enemies with the default player team
    (team_set_relation, team_default, team_bots, -1),
    (team_set_relation, team_bots, team_spawn_invulnerable, 0), # prevent bots from attacking players while protected for 10 seconds after spawn
    (team_set_relation, team_spawn_invulnerable, team_bots, 0),
Then add this block either at the start or the end of script_on_agent_spawned (which is called by the mission template trigger ti_on_agent_spawn):
Code:
    (try_begin), 
      (agent_is_non_player, ":agent_id"),
      (agent_set_team, ":agent_id", team_bots),
    (try_end),
And then you get an unending rabble surrounding and constantly attacking you, like the sallies against castle sieging in single player...

Where do I put this stuff for Persistent World?
 
Back
Top Bottom