WB Coding Fix bots in a battle scene (anim_stand_staff) Singleplayer

Users who are viewing this thread

Mauromagno Patriota

Sergeant Knight
WBNWVC
Hi everyone,
I wanted to put some cannons to a scene of my new historical battles, just as decoration, in addition to that, some gunner soldiers on each side of them and fix them in stand_staff position.
I have tried many things, but they do not work very well, other people have helped me, but I cannot do it well.
I have tested these 3 triggers in the new Historical Battles mission (which is a copy of lead_charge), one at a time and also combined. I put the bots through a script (a modified copy of prepare_town_to_fight), then I put the soldiers through direct, group and individual entry points.
The first trigger works well, but you have to remove the category of soldier, that is, if he is an ally or an enemy (mtef_team_0), in addition, you have to add an item, which does not work as a weapon, only as decoration (part of the code dedal_tavern_animations) So even if the battle ends, whoever the victor is, they will still be alive because they cannot be killed.
The second trigger, I freeze the soldiers in the place I put them, but they move a lot, they want to run, they move to the left, right, it's as if they were dancing.
The third, simply, does not work, the gunners behave like any of the other soldiers and advance to the side, in front of the gun and it does not look good, because the idea is that they are in their positions, handling the artillery.
Anyone who has an idea of how to solve this problem and can help me with this, I would greatly appreciate it.

First Triggers
Code:
bt_gunners_animations = (
            ti_on_agent_spawn,1,0,[
                (store_trigger_param_1,":agent"),
                (agent_get_troop_id,":troop",":agent"),
                (try_begin),
                    (is_between,":troop",artillero_inicio,artillero_fin),
                    (try_begin),
                        (agent_has_item_equipped,":agent","itm_dedal_ramrod"),
                        (agent_set_stand_animation, ":agent", "anim_stand_staff"),
                        (agent_set_animation, ":agent", "anim_stand_staff"),
                    (try_end),
                    (store_random_in_range,":r",0,120),
                    (agent_set_animation_progress,":agent",":r"),
                (try_end),
            ],[])
Second Triggers
Code:
##################### fix gunners #########################
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (agent_get_troop_id, ":troop_no", ":agent_no"),
         (try_begin),
           (is_between, ":troop_no", artillero_inicio, artillero_fin),
           (agent_set_no_dynamics, ":agent_no", 1),
           (try_begin),
               (agent_set_stand_animation, ":agent_no", "anim_stand_staff"),
               (agent_set_animation, ":agent_no", "anim_stand_staff"),
             (try_end),
         (try_end),
         ]),
Third Triggers
Code:
(0, 0, 0, [],
  [
(try_for_agents, ":agent"),
    (agent_is_alive, ":agent"),
    (agent_is_human, ":agent"),
    (agent_get_troop_id, ":troop", ":agent"),
   (try_begin),
        (eq, ":troop", "trp_artillero1"),
        (entry_point_get_position, pos2, 45),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
   (else_try),
           (eq, ":troop", "trp_artillero2"),
        (entry_point_get_position, pos2, 46),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
   (else_try),
           (eq, ":troop", "trp_artillero3"),
        (entry_point_get_position, pos2, 47),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
   (else_try),
           (eq, ":troop", "trp_artillero4"),
        (entry_point_get_position, pos2, 48),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
   (else_try),
           (eq, ":troop", "trp_artillero5"),
        (entry_point_get_position, pos2, 49),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
   (else_try),
           (eq, ":troop", "trp_artillero6"),
        (entry_point_get_position, pos2, 50),
        (agent_set_scripted_destination_no_attack, ":agent", pos2, 1),
(try_end),
]),
 

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Just that the conversation is complete:
Useful Lesbian:

you need to have specific attributes for animation in module_animations for it to rewrite moving animations, like enforce_all or something also make sure you are setting animation to both lower and upper part of body of agent


other way is using running away command and set look target position command so he wont move and will look at position you want
Mauromagno Patriota:

Hello, I have this that a friend gave me

Code:
["stand_staff_cyclic", 0, amf_client_prediction,   [2.0, "staff_cstance_new", 0, 120, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25], ],

I also tried it but it was the same
 
Upvote 0

Mauromagno Patriota

Sergeant Knight
WBNWVC
Setting agent_set_speed_limit to 0 can fix agent on one place.
well, I added that command, along with the others agent_set_scripted_destination_no_attack and agent_set_look_target_position and it worked perfect, even without the stand_staf animation and the bots stay in place, facing forward and in a firm position, they only turn around, when there is an enemy by behind, but then, they look back to the front ...
Thanks very much buddy....
So the resulting trigger is the following:

Code:
(ti_on_agent_spawn, 0, 0, [],
[
         (store_trigger_param_1, ":agent_no"),
         (agent_get_troop_id, ":troop_no", ":agent_no"),
     (try_begin),
            (eq, ":troop_no", "trp_artillero1"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 45),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
        (else_try),
            (eq, ":troop_no", "trp_artillero2"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 46),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
        (else_try),
            (eq, ":troop_no", "trp_artillero3"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 47),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
        (else_try),
            (eq, ":troop_no", "trp_artillero4"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 48),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
        (else_try),
            (eq, ":troop_no", "trp_artillero5"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 49),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
        (else_try),
            (eq, ":troop_no", "trp_artillero6"),
            (agent_set_speed_limit, ":agent_no", 0),
               (entry_point_get_position, pos2, 50),
            (agent_set_scripted_destination_no_attack, ":agent_no", pos2),
               (agent_set_look_target_position, ":agent_no", pos2),
    (try_end),
]),
 
Upvote 0

Vetrogor

Sergeant at Arms
Also agent_set_look_target_position works only short amount of time. You can exploit it to fix look position. Create a storage for agents in some troop then each frame use agent_set_look_target_position on agents. For example:
Python:
  (0,0,0,[],[
    (troop_get_slot, ":num", "trp_storage", 0),
    (val_add, ":num", 1),
    (try_for_range, ":slot", 1, ":num"),
      (troop_get_slot, ":agent", "trp_storage", ":slot"),
      (agent_get_slot, ":x", ":agent", slot_agent_look_x),
      (agent_get_slot, ":y", ":agent", slot_agent_look_y),
      (agent_get_slot, ":z", ":agent", slot_agent_look_z),
      (init_position, pos1),
      (position_set_x, pos1, ":x"),
      (position_set_y, pos1, ":y"),
      (position_set_z, pos1, ":z"),
      (agent_set_look_target_position, ":agent", pos1),
    (try_end),
  ]),

This is just an example. You need to store agents and look position slots.

p.s. It's not very efficient but I don't know any better way.
 
Upvote 0

Mauromagno Patriota

Sergeant Knight
WBNWVC
Also agent_set_look_target_position works only short amount of time. You can exploit it to fix look position. Create a storage for agents in some troop then each frame use agent_set_look_target_position on agents. For example:
Python:
  (0,0,0,[],[
    (troop_get_slot, ":num", "trp_storage", 0),
    (val_add, ":num", 1),
    (try_for_range, ":slot", 1, ":num"),
      (troop_get_slot, ":agent", "trp_storage", ":slot"),
      (agent_get_slot, ":x", ":agent", slot_agent_look_x),
      (agent_get_slot, ":y", ":agent", slot_agent_look_y),
      (agent_get_slot, ":z", ":agent", slot_agent_look_z),
      (init_position, pos1),
      (position_set_x, pos1, ":x"),
      (position_set_y, pos1, ":y"),
      (position_set_z, pos1, ":z"),
      (agent_set_look_target_position, ":agent", pos1),
    (try_end),
  ]),

This is just an example. You need to store agents and look position slots.

p.s. It's not very efficient but I don't know any better way.
Well, thanks, I'll see if there are any problems as time goes by, but I don't think since the scene is a scheduled battle, it is the re-enactment of a historical event and in the mission, there are all the orders to the friendly troops and enemies, every few seconds the infantry attacks, then cavalry, then riflemen and hunters, it lasts no more than 3 minutes and the cannons finish firing, when the riflemen attack ..., but thank you very much for your help :smile:
 
Upvote 0
Top Bottom