Kahsm
Recruit
Disclaimer: I just read the module documentation to start scripting 2 days ago.
Alrighty, I've been reading troop tuples, scripts, game menus, and mission templates for hours now and I still don't quite understand how agents are spawned on their entry points. I feel like I should know, but my experimentation doesn't work out the way I expect, so I hope someone can fill me in on what I'm missing.
If you want to quickly explain the process from creating a single hero agent troop (like an arena master) and spawning him in a single castle, please do. However, if you're more of a reader, i've 'spoiler-ed' my experiments and some of what I already believe I know, and you can comment directly on that.
However, one last thing. This question is not about how to get my code to work. I am more interested in why it doesn't work, and how the system works in whole. Given that, I can extrapolate future answers.
This means the answer I do not want is: If in Sargoth... (set_visitor, 1, :dude),
I know how to do that already.
Unless of course that's the ONLY way, but obviously there are many agents that don't get added that way.
Edit: Added self-deprecating humour
Alrighty, I've been reading troop tuples, scripts, game menus, and mission templates for hours now and I still don't quite understand how agents are spawned on their entry points. I feel like I should know, but my experimentation doesn't work out the way I expect, so I hope someone can fill me in on what I'm missing.
If you want to quickly explain the process from creating a single hero agent troop (like an arena master) and spawning him in a single castle, please do. However, if you're more of a reader, i've 'spoiler-ed' my experiments and some of what I already believe I know, and you can comment directly on that.
However, one last thing. This question is not about how to get my code to work. I am more interested in why it doesn't work, and how the system works in whole. Given that, I can extrapolate future answers.
This means the answer I do not want is: If in Sargoth... (set_visitor, 1, :dude),
I know how to do that already.
Unless of course that's the ONLY way, but obviously there are many agents that don't get added that way.
To make my unique, yet static, agent.. he needs to be a hero troop. So I made the dude, and he's the very last entry in the troop list.
As you can see, I want him to spawn in town #1's castle, entry point #1. Sargoth's castle doesn't actually have an entry point 1 defined in the scenes, so I made one. That was pretty easy. The "visit_town_castle" mission template, however, already has the a spawn record for entry_point 1 defined.
I see that it's a scene_source, and I saw in another thread during my pre-question-searching that scene_source is what you want for agents with defined locations like my 'Dude'. Just so you know, I've also tried spawning him at existing entry points in various scenes (like the arena and tavern).
At this point I originally thought that the game engine would just say, "alright he wants that guy in that scene at that point, and we know that point exists, so just do it!" Well it obviously doesn't work that way. So where do I look next? Well, I went to the closest working actor to the one I'm trying to emulate, and that's the Arena Master.
First though, why not the merchants or the tavern keeper? Well because they don't have pre-set locations. The Arena Master does. If someone wants to explain why that is, please do. I can see in the scripts that Armorer, Tavernkeeper, Weaponsmith, and Merchant all get added in the Town Loop. I still haven't found the exact moment they are created at their spawn points, but I can imagine how that process works once you have all the troop IDs saved in the town's Party slots via the following from module_scripts: (not that my imagination has been right yet)
At the arrowed line, you can see one of the town's party slots is given the troopID for their particular tavernkeeper's troop, but Arena Masters are not managed this way, despite having an arena master in every town, just like innkeepers. So then I decided to look at the game_menu for entering the arena to see if he's manually inserted:
At arrow 1, I can see that it uses the melee fight mission_template to define the entry points. But then at arrow 2 it resets the visitors -- I'm not sure what this does. Does it remove all the default spawned ones? That would explain a lot if it did. Actually, let me try removing that to see what it does, give me a moment........ nothing changes, figured -- continuing on! So at arrow 3, I can see the demo combatants are added in the arena, then at arrow 4 it seems to jump the spawn iterator to 50?
Originally I thought the entry jump was so that anyone spawned after this point would be "upstairs" since the Arena Master is on entry_point 52, but 53 is actually back down in the arena, so I'm not sure what the point of that is. Furthermore, I see no place where the arena master himself is spawned.
But then, of course he's not spawned explicitly like the combatants, it would be silly to have defined the exact location in the troop file, just to then manually assign that troop to that entry point again in the game_menu -- doesn't make sense.
I ran some multi-file searches to find some other place in maybe scripts or triggers that mention "arena" or "arena master" or something of that ilk in *.py to no success. So I have no idea where he's spawned. I assume it's hidden in some trigger somewhere.
I'm just creating more questions than I'm getting answers to, and getting away from my original purpose. And that's perfectly fine, I'm learning the system very thoroughly as I go through all these pieces, scripts, and files. But my main question still remains: If I define a scene_location|entry(#) for a hero troop, why doesn't that troop get created at that entry_point in that scene?
So to see how important that location definition is I removed it from the Arena Master in Sargoth only.
(btw his name is "Bobby II" because I change his name eveyr time i change something so I know the new compile is actually in, if you were wondering if that might be the problem -- it's not)
I think a rational person would expect him to disappear, since he no longer has a location defined. Guess what? he doesn't! Nor does he spawn in some random spot, or in entry_point 50 where I thought the jump moved some sort of spawning iterator. He's right at #52. So now I'm wondering if this whole scene_location|entry(#) thing is depreciated? I know the module documentation is pretty old. And if that's the case, is adding my hero within a conditional in the mission_template or menu_dialog for entering the Sargoth Court the best(only) way to do it?
Of course, that then brings me back to... how the hell does the arena master get spawned? My head hurts. I hope I've done my due diligence, and I'd love some advice.
Code:
["town_1_dude","Dude","{!}Dude",tf_hero|tf_randomize_face, scn_town_1_castle|entry(1), reserved, fac_commoners,[itm_leather_jerkin,itm_hide_boots],def_attrib|level(2),wp(20),knows_common,0x0000000d0d1030c74ae8d661b651c6840000000000000e220000000000000000],
As you can see, I want him to spawn in town #1's castle, entry point #1. Sargoth's castle doesn't actually have an entry point 1 defined in the scenes, so I made one. That was pretty easy. The "visit_town_castle" mission template, however, already has the a spawn record for entry_point 1 defined.
Code:
(1,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
I see that it's a scene_source, and I saw in another thread during my pre-question-searching that scene_source is what you want for agents with defined locations like my 'Dude'. Just so you know, I've also tried spawning him at existing entry points in various scenes (like the arena and tavern).
At this point I originally thought that the game engine would just say, "alright he wants that guy in that scene at that point, and we know that point exists, so just do it!" Well it obviously doesn't work that way. So where do I look next? Well, I went to the closest working actor to the one I'm trying to emulate, and that's the Arena Master.
First though, why not the merchants or the tavern keeper? Well because they don't have pre-set locations. The Arena Master does. If someone wants to explain why that is, please do. I can see in the scripts that Armorer, Tavernkeeper, Weaponsmith, and Merchant all get added in the Town Loop. I still haven't found the exact moment they are created at their spawn points, but I can imagine how that process works once you have all the troop IDs saved in the town's Party slots via the following from module_scripts: (not that my imagination has been right yet)
Code:
# Towns (loop)
(try_for_range, ":town_no", towns_begin, towns_end),
(store_sub, ":offset", ":town_no", towns_begin),
(party_set_slot,":town_no", slot_party_type, spt_town),
#[... removed some code to keep this shorter ...]
(store_add, ":cur_object_no", "trp_town_1_mayor", ":offset"),
(party_set_slot,":town_no", slot_town_elder, ":cur_object_no"),
(store_add, ":cur_object_no", "trp_town_1_tavernkeeper", ":offset"),
(party_set_slot,":town_no", slot_town_tavernkeeper, ":cur_object_no"), <---
(store_add, ":cur_object_no", "trp_town_1_weaponsmith", ":offset"),
(party_set_slot,":town_no", slot_town_weaponsmith, ":cur_object_no"),
(store_add, ":cur_object_no", "trp_town_1_armorer", ":offset"),
(party_set_slot,":town_no", slot_town_armorer, ":cur_object_no"),
(store_add, ":cur_object_no", "trp_town_1_merchant", ":offset"),
(party_set_slot,":town_no", slot_town_merchant, ":cur_object_no"),
(store_add, ":cur_object_no", "trp_town_1_horse_merchant", ":offset"),
(party_set_slot,":town_no", slot_town_horse_merchant, ":cur_object_no"),
(store_add, ":cur_object_no", "scn_town_1_center", ":offset"),
(party_set_slot,":town_no", slot_town_center, ":cur_object_no"),
(party_set_slot,":town_no", slot_town_reinforcement_party_template, "pt_center_reinforcements"),
(try_end),
At the arrowed line, you can see one of the town's party slots is given the troopID for their particular tavernkeeper's troop, but Arena Masters are not managed this way, despite having an arena master in every town, just like innkeepers. So then I decided to look at the game_menu for entering the arena to see if he's manually inserted:
Code:
"Enter the arena.",
[
(try_begin),
(this_or_next|eq,"$all_doors_locked",1),
(eq,"$town_nighttime",1),
(display_message,"str_door_locked",0xFFFFAAAA),
(else_try),
(assign, "$g_mt_mode", abm_visit),
(assign, "$town_entered", 1),
(set_jump_mission, "mt_arena_melee_fight"), <---- 1
(party_get_slot, ":arena_scene", "$current_town", slot_town_arena),
(modify_visitors_at_site, ":arena_scene"),
(reset_visitors), <----- 2
(set_visitor, 43, "trp_veteran_fighter"), <---- 3
(set_visitor, 44, "trp_hired_blade"),
(set_jump_entry, 50), <----- 4
(jump_to_scene, ":arena_scene"),
(scene_set_slot, ":arena_scene", slot_scene_visited, 1),
(change_screen_mission),
(try_end),
],"Door to the arena."),
At arrow 1, I can see that it uses the melee fight mission_template to define the entry points. But then at arrow 2 it resets the visitors -- I'm not sure what this does. Does it remove all the default spawned ones? That would explain a lot if it did. Actually, let me try removing that to see what it does, give me a moment........ nothing changes, figured -- continuing on! So at arrow 3, I can see the demo combatants are added in the arena, then at arrow 4 it seems to jump the spawn iterator to 50?
Originally I thought the entry jump was so that anyone spawned after this point would be "upstairs" since the Arena Master is on entry_point 52, but 53 is actually back down in the arena, so I'm not sure what the point of that is. Furthermore, I see no place where the arena master himself is spawned.
But then, of course he's not spawned explicitly like the combatants, it would be silly to have defined the exact location in the troop file, just to then manually assign that troop to that entry point again in the game_menu -- doesn't make sense.
I ran some multi-file searches to find some other place in maybe scripts or triggers that mention "arena" or "arena master" or something of that ilk in *.py to no success. So I have no idea where he's spawned. I assume it's hidden in some trigger somewhere.
I'm just creating more questions than I'm getting answers to, and getting away from my original purpose. And that's perfectly fine, I'm learning the system very thoroughly as I go through all these pieces, scripts, and files. But my main question still remains: If I define a scene_location|entry(#) for a hero troop, why doesn't that troop get created at that entry_point in that scene?
So to see how important that location definition is I removed it from the Arena Master in Sargoth only.
Code:
["town_1_arena_master", "Bobby II ","{!}Tournament Master",tf_hero|tf_randomize_face, 0 ,reserved, fac_commoners, ...
["town_2_arena_master", "Tournament Master","{!}Tournament Master",tf_hero|tf_randomize_face, scn_town_2_arena|entry(52),reserved, fac_commoners ...
["town_3_arena_master", "Tournament Master","{!}Tournament Master",tf_hero|tf_randomize_face, scn_town_3_arena|entry(52),reserved, fac_commoners ...
(btw his name is "Bobby II" because I change his name eveyr time i change something so I know the new compile is actually in, if you were wondering if that might be the problem -- it's not)
I think a rational person would expect him to disappear, since he no longer has a location defined. Guess what? he doesn't! Nor does he spawn in some random spot, or in entry_point 50 where I thought the jump moved some sort of spawning iterator. He's right at #52. So now I'm wondering if this whole scene_location|entry(#) thing is depreciated? I know the module documentation is pretty old. And if that's the case, is adding my hero within a conditional in the mission_template or menu_dialog for entering the Sargoth Court the best(only) way to do it?
Of course, that then brings me back to... how the hell does the arena master get spawned? My head hurts. I hope I've done my due diligence, and I'd love some advice.
Edit: Added self-deprecating humour