spawning enemies in a scene

Currently viewing this thread:

jik

Knight
OK.  I've seen 2 ways to spawn troops during a battle.  First, I looked at the way it's done in the melee fights:
  (0.2, 0, 0,
  [
      (eq, "$g_mt_mode", abm_training),
      (assign, ":num_active_fighters", 0),
      (try_for_agents, ":agent_no"),
        (agent_is_human, ":agent_no"),
        (agent_is_alive, ":agent_no"),
        (agent_get_team, ":team_no", ":agent_no"),
        (is_between, ":team_no", 0 ,7),
        (val_add, ":num_active_fighters", 1),
      (try_end),
      (lt, ":num_active_fighters", 7),
      (neg|main_hero_fallen),
      (store_mission_timer_a, ":cur_time"),
      (this_or_next|ge, ":cur_time", "$g_arena_training_next_spawn_time"),
      (this_or_next|lt, "$g_arena_training_num_agents_spawned", 6),
      (num_active_teams_le, 1),
      (lt, "$g_arena_training_num_agents_spawned", "$g_arena_training_max_opponents"),
      ],
    [
      (assign, ":added_troop", "$g_arena_training_num_agents_spawned"),
      (store_div,  ":added_troop", "$g_arena_training_num_agents_spawned", 6),
      (assign, ":added_troop_sequence", "$g_arena_training_num_agents_spawned"),
      (val_mod, ":added_troop_sequence", 6),
      (val_add, ":added_troop", ":added_troop_sequence"),
      (val_min, ":added_troop", 9),
      (val_add, ":added_troop", "trp_arena_training_fighter_1"),
      (assign, ":end_cond", 10000),
      (get_player_agent_no, ":player_agent"),
      (agent_get_position, pos5, ":player_agent"),
      (try_for_range, ":unused", 0, ":end_cond"),
        (store_random_in_range, ":random_entry_point", 32, 40),
        (neq, ":random_entry_point", "$g_player_entry_point"), # make sure we don't overwrite player
        (entry_point_get_position, pos1, ":random_entry_point"),
        (get_distance_between_positions, ":dist", pos5, pos1),
        (gt, ":dist", 1200), #must be at least 12 meters away from the player
        (assign, ":end_cond", 0),
      (try_end),
      (add_visitors_to_current_scene, ":random_entry_point", ":added_troop", 1),

      (store_add, ":new_spawned_count", "$g_arena_training_num_agents_spawned", 1),
      (store_mission_timer_a, ":cur_time"),
      (store_add, "$g_arena_training_next_spawn_time", ":cur_time", 14),
      (store_div, ":time_reduction", ":new_spawned_count", 3),
      (val_sub, "$g_arena_training_next_spawn_time", ":time_reduction"),
      ]),

the gist is they use this : (add_visitors_to_current_scene, ":random_entry_point", ":added_troop", 1),

The only issue I see with this is it's hard to set the teams as you need to know the agents, so you'd have to check each one.  This is what they do in the melee fights and it's not bad since the numbers only get up to 7.  In my mission template, I hope to get up to around 65 (including the player team) agents, and I don't want to do more overhead than needed.

I did see something similar to this posted:
(store_random_in_range,":spawn_here",35,46),  ##use entry_points 35-45 for random out of the back spawns
(entry_point_get_position,pos2,":spawn_here"),
(set_spawn_position, pos2),
(spawn_agent,"trp_novice_fighter"),    ##This operation spawns the agent ID to reg0
(assign,":cur_agent",reg0),
(agent_set_team, ":cur_agent", 1),  ##Player' group should be team 0, enemies are team 1
(val_add,"$total_spawned",1),        ##Up the count of spawned
(display_message,"@enemy Spawned"),

I did this but it doesn't seem to do anything.  I ran to each spawn (entry) point and found no one.  Am I doing something wrong?  Which way is better?
 

Meneldur

Sergeant Knight
VCWB
Hey Jik!
I´m stil struggling with that! An coppied mt with the:

  (add_visitors_to_current_scene, ":random_entry_point", ":added_troop", 1),
gave me compile error about unassigned added_troop. This was all the same whatever I pasted to substitute "added_troop" e.g. trp_zombie or whatever.

What do you think about Wickedshots script?? Isn´t that usable with that call scipt trigger in almost every mt/ scene?
Asswell it seems to be similar to your second spoiler


 

jik

Knight
The code that I posted can easily be in a script.  One thing I noticed (but didn't seem to help) is that you need to define the visitors spawns at the beginning (as the native tournament does).  But something is still missing.  In both cases nothing spawns...
 

Meneldur

Sergeant Knight
VCWB
Thats silly i´ve got some spawns. must still figure out about limitation and stuff but it works somehow.
 

jik

Knight
Meneldur said:
Thats silly i´ve got some spawns. must still figure out about limitation and stuff but it works somehow.

You mean you used his exact script and it works?  Maybe it has to be a script and not a trigger?  Don't see how that makes sense, but I can move it to a script no problem.  I though I code block was a code block.

Do you have entry points set up?  how about setting the visitor spawns?  Did you do that?
 

Meneldur

Sergeant Knight
VCWB
Sorry here is my module scripts py at the bottom:
  ("cf_random_encounter_bandits",
[(get_player_agent_no,":player_agent"),
(agent_get_position,pos1,":player_agent"),
(entry_point_get_position, pos2, 10),
(set_spawn_position, pos2),        
(spawn_agent,"trp_looter"),
(entry_point_get_position, pos3, 4),
(set_spawn_position, pos3),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos4, 5),
(set_spawn_position, pos4),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos5, 6),
(set_spawn_position, pos5),        
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos6, 7),
(set_spawn_position, pos6),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos7, :cool:,
(set_spawn_position, pos7),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos8, 9),
(set_spawn_position, pos:cool:,        
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos9, 11),
(set_spawn_position, pos9 ),        
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos10, 12),
(set_spawn_position, pos10),        
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos12, 14),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
   (entry_point_get_position, pos13, 15),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
   (entry_point_get_position, pos14, 16),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
    (entry_point_get_position, pos15, 17),
(set_spawn_position, pos15),        
(spawn_agent,"trp_guardian"),
]),
]# the very end

i had luck with my ignoration of the "40,mtef_visitor_source|mtef_team_1" things because scripted pos. entry seem to overwrite the visitor stuff.
But the player entry seemed to be   (0,mtef_scene_source|    because it was necessary to edit an entry_0 inscene to get clear and not random start points

It was possible to define a trp_player spawn agent in the script but this made him mounted!!!

Asswell i fear (without having tried that already) default mounted units like vaegir knights will spawn with their horses that way.

heres mt i copied from bandits at night and renamed "doom". Iadded the ti call script encouter and deleted music and

change banners and chests
(
    "doom",0,-1,
   "Default town visit",
    [(0,mtef_scene_source|mtef_team_0, af_override_horse, 0, 1, pilgrim_disguise),
     (1,mtef_scene_source|mtef_team_0,0,0,1,[]),
     (2,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
     (3,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
     (4,mtef_visitor_source|mtef_team_0, af_override_horse, aif_start_alarmed, 1, []),
     (5,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
     (6,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
     (7,mtef_scene_source|mtef_team_0,af_override_horse,0,1,[]),
    
     (8,mtef_scene_source,af_override_horse,0,1,[]),
     (9,mtef_visitor_source,af_override_horse,0,1,[]),(10,mtef_visitor_source,af_override_horse,0,1,[]),(11,mtef_visitor_source,af_override_horse,aif_start_alarmed,1,[]),(12,mtef_visitor_source,af_override_horse,0,1,[]),(13,mtef_scene_source,0,0,1,[]),(14,mtef_scene_source,0,0,1,[]),(15,mtef_scene_source,0,0,1,[]),
     (16,mtef_visitor_source,af_override_horse,0,1,[]),(17,mtef_visitor_source,af_override_horse,0,1,[]),(18,mtef_visitor_source,af_override_horse,0,1,[]),(19,mtef_visitor_source,af_override_horse,0,1,[]),(20,mtef_visitor_source,af_override_horse,0,1,[]),(21,mtef_visitor_source,af_override_horse,0,1,[]),(22,mtef_visitor_source,af_override_horse,0,1,[]),(23,mtef_visitor_source,af_override_horse,0,1,[]),
     (24,mtef_visitor_source,af_override_horse,0,1,[]),(25,mtef_visitor_source,af_override_horse,0,1,[]),(26,mtef_visitor_source,af_override_horse,0,1,[]),(27,mtef_visitor_source,af_override_horse,aif_start_alarmed,1,[]),(28,mtef_visitor_source,af_override_horse,aif_start_alarmed,1,[]),(29,mtef_visitor_source,af_override_horse,0,1,[]),(30,mtef_visitor_source,af_override_horse,0,1,[]),(31,mtef_visitor_source,af_override_horse,0,1,[]),
     (32,mtef_visitor_source,af_override_horse,0,1,[]),(33,mtef_visitor_source,af_override_horse,0,1,[]),(34,mtef_visitor_source,af_override_horse,0,1,[]),(35,mtef_visitor_source,af_override_horse,0,1,[]),(36,mtef_visitor_source,af_override_horse,0,1,[]),(37,mtef_visitor_source,af_override_horse,0,1,[]),(38,mtef_visitor_source,af_override_horse,0,1,[]),(39,mtef_visitor_source,af_override_horse,0,1,[]),
     (40,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(41,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(42,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(43,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
     (44,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(45,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(46,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),(47,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,1,[]),
     ],
     
[
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (agent_get_troop_id, ":troop_no", ":agent_no"),
         (neq, ":troop_no", "trp_player"),
         (agent_set_team, ":agent_no", 1),
         ]),

     
      common_inventory_not_available,
     
      (ti_tab_pressed, 0, 0,
       [
         (display_message, "@Cannot leave now."),
         ], []),
      (ti_on_leave_area, 0, 0,
       [
         (try_begin),
           (eq, "$g_defending_against_siege", 0),
           (assign,"$g_leave_town",1),
         (try_end),
         ], []),

      (0, 0, ti_once,[(call_script, "script_cf_random_encounter_bandits")],[]),

    (1, 4, ti_once,
       [
         (store_mission_timer_a,":cur_time"),
         (ge, ":cur_time", 5),
         (this_or_next|main_hero_fallen),
         (num_active_teams_le,1)
         ],
       [
         (try_begin),
           (main_hero_fallen),
           (jump_to_menu, "mnu_town_bandits_failed"),
         (else_try),
           (jump_to_menu, "mnu_town_bandits_succeeded"),
         (try_end),
         (finish_mission),
         ]),
      ],
    ),
Asswell i changed the last trigger " (1, 4, ti_once," with the easy perma death thingy Kolba once posted:



   (1, 4, ti_once, [(main_hero_fallen)],
          [
              (store_random_in_range, ":permanent_death", 1, 101), #
   (try_begin),
   (gt, ":permanent_death", 35), #this would give a 20% chance
   (jump_to_menu,"mnu_player_is_death"),
(try_end),
(finish_mission,0),          
         ]),
      ],
    ),

it works fine somehow either you die or you get kicked to campaign map instantly.

If you kill all enemies nothing may happen so i need to let the gamer leave area at a scene border press "F"
 

jik

Knight
Ok, I can try that.  I don't have a spawn check trigger, nice touch.  Good time to set the teams.

If you don't mind, I'm going to first steal your code exactly (well, maybe change the troop IDs spawned).
 

jik

Knight
Just curious about a few things.  First, in your script, you track the player agent position.  Nothing that you have here shows why.  Is there a reason (for spawning)?

In your mission_template, you call the script in the condition of the trigger, but not the consequence, which is usually the case.:

      (0, 0, ti_once,[(call_script, "script_cf_random_encounter_bandits")],[]),

Just curious.  Will be trying this now.  Also, the entry points used?  I'm using 31-46.  Does that matter?


 

Meneldur

Sergeant Knight
VCWB
script is from wickedshot. Reason for the player track is original script checks for distance from  player to position and suddenly spawns enemies:

http://forums.taleworlds.com/index.php/topic,54681.msg1415580.html#msg1415580

i did two things with that
("random_encounter_bandits",
[(get_player_agent_no,":player_agent"),
(agent_get_position,pos1,":player_agent"),
(entry_point_get_position, pos1, 0), #or whatever
(set_spawn_position, pos1),        
(spawn_agent,"trp_player"),# this gave me mounted trp_player
....................................),
]),

then i tried to mix my spawns by enter scene with those who appear if player comes in distance:
   ]),
  ("cf_random_encounter_bandits",
[(get_player_agent_no,":player_agent"),
(agent_get_position,pos1,":player_agent"),
(entry_point_get_position, pos2, 10),
(set_spawn_position, pos2),        
(spawn_agent,"trp_looter"),
(entry_point_get_position, pos3, 4),
(set_spawn_position, pos3),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos4, 5),
(set_spawn_position, pos4),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos5, 6),
(set_spawn_position, pos5),        
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos6, 7),
(set_spawn_position, pos6),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos7, :cool: ,
(set_spawn_position, pos7),        
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos8, 9),
(set_spawn_position, pos:cool:,        
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos9, 11),
(set_spawn_position, pos9 ),        
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos10, 12),
(set_spawn_position, pos10),        
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos11, 13),
(get_distance_between_positions,":temp_distance",pos1,pos11), # this gave me foremost an unlimited spawn of:
(lt, ":temp_distance", 200),                                                       #  (entry_point_get_position, pos2, 10),
(set_spawn_position, pos11),                                                     #  (set_spawn_position, pos2),        
(spawn_agent,"trp_hell_kinght"),                                               # (spawn_agent,"trp_looter"),
  (entry_point_get_position, pos12, 14),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
   (entry_point_get_position, pos13, 15),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos14, 16),
(set_spawn_position, pos12),        
(spawn_agent,"trp_guardian"),
    (entry_point_get_position, pos15, 17),
(set_spawn_position, pos15),        
(spawn_agent,"trp_guardian"),
]),

Just curious.     Jik i´m not advanced anyway.I Read your wonderful tut but not exercited it all. what i know about it is mostly what i can find there.


Most times i do not exactly know what i´m doing, but implementing scripts and stuff other people have created :oops: 
the rest is try and error

 

jik

Knight
Meneldur said:
script is from wickedshot. Reason for the player track is original script checks for distance from  player to position and suddenly spawns enemies:

http://forums.taleworlds.com/index.php/topic,54681.msg1415580.html#msg1415580

i did two things with that
("random_encounter_bandits",
[(get_player_agent_no,":player_agent"),
(agent_get_position,pos1,":player_agent"),
(entry_point_get_position, pos1, 0), #or whatever
(set_spawn_position, pos1),       
(spawn_agent,"trp_player"),# this gave me mounted trp_player
....................................),
]),

then i tried to mix my spawns by enter scene with those who appear if player comes in distance:
  ]),
  ("cf_random_encounter_bandits",
[(get_player_agent_no,":player_agent"),
(agent_get_position,pos1,":player_agent"),
(entry_point_get_position, pos2, 10),
(set_spawn_position, pos2),       
(spawn_agent,"trp_looter"),
(entry_point_get_position, pos3, 4),
(set_spawn_position, pos3),       
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos4, 5),
(set_spawn_position, pos4),       
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos5, 6),
(set_spawn_position, pos5),       
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos6, 7),
(set_spawn_position, pos6),       
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos7, :cool: ,
(set_spawn_position, pos7),       
(spawn_agent,"trp_zombie"),
(entry_point_get_position, pos8, 9),
(set_spawn_position, pos:cool:,       
(spawn_agent,"trp_zombie"),
  (entry_point_get_position, pos9, 11),
(set_spawn_position, pos9 ),       
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos10, 12),
(set_spawn_position, pos10),       
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos11, 13),
(get_distance_between_positions,":temp_distance",pos1,pos11), # this gave me foremost an unlimited spawn of:
(lt, ":temp_distance", 200),                                                      #  (entry_point_get_position, pos2, 10),
(set_spawn_position, pos11),                                                    #  (set_spawn_position, pos2),       
(spawn_agent,"trp_hell_kinght"),                                              # (spawn_agent,"trp_looter"),
  (entry_point_get_position, pos12, 14),
(set_spawn_position, pos12),       
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos13, 15),
(set_spawn_position, pos12),       
(spawn_agent,"trp_guardian"),
  (entry_point_get_position, pos14, 16),
(set_spawn_position, pos12),       
(spawn_agent,"trp_guardian"),
    (entry_point_get_position, pos15, 17),
(set_spawn_position, pos15),       
(spawn_agent,"trp_guardian"),
]),

Just curious.    Jik i´m not advanced anyway.I Read your wonderful tut but not exercited it all. what i know about it is mostly what i can find there.


Most times i do not exactly know what i´m doing, but implementing scripts and stuff other people have created :oops: 
the rest is try and error

Well, you are doing very well.  I tried that out and it works.  I may track the player and make sure the spawns (I will be randomizing it) are not too close to where the player is.  Not sure why what I did is not working, but hey, I'm no expert either.  Trial and error (and trying before asking) is the best way to understand things.  That's how I got to where I am.  One issue is not knowing all the operations or what they do exactly.  The comments are only basics in the MS, and that makes things harder.

In any case, thanks for your help.  I wanted to use the other operation (the visitor one) since I could then add more than one at a time.  I worry about overlaping people on the spawn points, but I can check that now that they are actually spawning.
 
Top Bottom