How can I make npc archers stand thier ground when the pc goes out of los.
I have a corridor where archers wil try to pin you down as you cross a trap field. There are a sereis of boltholes where you may take cover and heal (but not rest).
When you go out of los the AI causes the archer to run to you to get a shot at you. I want the npc to stay at the end of the corridor and only shoot when you reappear. Is this possible?
PJ
NPC archers standing ground
Débuté par
PJ156
, mai 06 2012 09:59
#1
Posté 06 mai 2012 - 09:59
#2
Posté 06 mai 2012 - 10:14
Properties/Behavior/Walk Rate, Then select Immobile. I beleive that's what your asking.
Modifié par Alupinu, 06 mai 2012 - 10:31 .
#3
Posté 06 mai 2012 - 10:16
There are several things to try.
User defined events may be a solution. At the end of the combat round you can check if the targeted object (GetAttackTarget) is in the line of sight(LineOfSightObject). If the player is not in the line of sight cycle through the faction members to check them too.
If the archer doesn't see anyone have them return to a waypoint to stand gaurd. A ClearAllActions and AIIgnoreCombat should be enough to reset them until the players comes back into a line of sight. The AI ignore function is part of the ginc_ai.
Or a defined area could run an on exit for the archers and have them hold their ground until the player returns.
User defined events may be a solution. At the end of the combat round you can check if the targeted object (GetAttackTarget) is in the line of sight(LineOfSightObject). If the player is not in the line of sight cycle through the faction members to check them too.
If the archer doesn't see anyone have them return to a waypoint to stand gaurd. A ClearAllActions and AIIgnoreCombat should be enough to reset them until the players comes back into a line of sight. The AI ignore function is part of the ginc_ai.
Or a defined area could run an on exit for the archers and have them hold their ground until the player returns.
Modifié par Shaughn78, 06 mai 2012 - 10:33 .
#4
Posté 06 mai 2012 - 10:30
If you want them never to move from their spot, then you can set their movement speed to 'immobile' in their Properties tab. However then they won't move away from a player who gets too close either.
#5
Posté 06 mai 2012 - 10:42
Thanks gents,
In this case I think immobile will do what I want. They can switch to melle weapons if it gets to close quarters.
Thanks for the script idea Shaughn I have another area where that may be useful (for a guard that must be snuck by).
PJ
In this case I think immobile will do what I want. They can switch to melle weapons if it gets to close quarters.
Thanks for the script idea Shaughn I have another area where that may be useful (for a guard that must be snuck by).
PJ
#6
Posté 06 mai 2012 - 11:06
Even though you have a solution, I forgot to mention this idea. I used this in Risen Hero.
A group of archers where behind a series of destroyable barricades. They had dynamic collisions so no one could walk through and start a melee battle. The archers either needed to be killed with range attacks or a tank has to endure the arrows, bash the barricades and then kill the archers. Being an evil designer, I however placed a few tangle traps to trip up the tank.
A group of archers where behind a series of destroyable barricades. They had dynamic collisions so no one could walk through and start a melee battle. The archers either needed to be killed with range attacks or a tank has to endure the arrows, bash the barricades and then kill the archers. Being an evil designer, I however placed a few tangle traps to trip up the tank.
#7
Posté 06 mai 2012 - 11:11
There are a few other ways you can script this without immobilizing the archers.
Basically, you have to insert a few checks in to the AI event scripts that either pre-empt the AI's attempt to chase down a fleeing PC, or stop the archer after the fact and force them to return back to their original position.
First of all, I would give each archer their own unique tag and then a POST waypoint. That way, you always know where the archer is supposed to go, you just look for the object with the tag "POST_" + GetTag(OBJECT_SELF).
Now you just have to check when the archer is out of place. You could do a trigger around the archers, that orders them to ClearAllActions(TRUE) and run back to their post when they exit the trigger (set a local int on the archers for the trigger to check). Alternatively, you could modify the HB or the end-combat-round script to check the distance between the archer and their post, and order them to break combat and return if need be.
Another option, which might suit your desired gameplay better, is to write a script that cycles through all the archers and tells them to break combat and return to post, and put that on the on-enter script of a trigger in each of your boltholes, to be set off by the PC when they run for cover.
An easier alternative would be just to cordon off the archer's location with some type of obstacle and a walkmesh cutter--if they can't pathfind to the PC, they won't move.
Basically, you have to insert a few checks in to the AI event scripts that either pre-empt the AI's attempt to chase down a fleeing PC, or stop the archer after the fact and force them to return back to their original position.
First of all, I would give each archer their own unique tag and then a POST waypoint. That way, you always know where the archer is supposed to go, you just look for the object with the tag "POST_" + GetTag(OBJECT_SELF).
Now you just have to check when the archer is out of place. You could do a trigger around the archers, that orders them to ClearAllActions(TRUE) and run back to their post when they exit the trigger (set a local int on the archers for the trigger to check). Alternatively, you could modify the HB or the end-combat-round script to check the distance between the archer and their post, and order them to break combat and return if need be.
Another option, which might suit your desired gameplay better, is to write a script that cycles through all the archers and tells them to break combat and return to post, and put that on the on-enter script of a trigger in each of your boltholes, to be set off by the PC when they run for cover.
An easier alternative would be just to cordon off the archer's location with some type of obstacle and a walkmesh cutter--if they can't pathfind to the PC, they won't move.
#8
Posté 07 mai 2012 - 07:25
You could also use EffectCutsceneImmobilize() then remove it if the PC closes to melee via trigger.
#9
Posté 07 mai 2012 - 08:05
Thanks again, I have been looking at this some more with your comments in mind.
I wondered after Morbanes comment that I might change the movement rate by script off a trigger as the player closes. I think I can but the script refers to a movement rate factor which is a float, does anyone know how the various walk states would be represented by that float?
Thanks for your assistance on this. I am trying to keep it simple since I am no scripter so the trigger option appeals to me.
PJ
I wondered after Morbanes comment that I might change the movement rate by script off a trigger as the player closes. I think I can but the script refers to a movement rate factor which is a float, does anyone know how the various walk states would be represented by that float?
Thanks for your assistance on this. I am trying to keep it simple since I am no scripter so the trigger option appeals to me.
PJ
#10
Posté 07 mai 2012 - 11:08
I think the default movement rate is 1.0. Immobilised would probably be 0.0.
#11
Posté 07 mai 2012 - 11:16
Great I will try that 
PJ
PJ





Retour en haut






