I have noticed that when the PC escapes from enemies following a
straight line, the enemies with melee weapon can't hit him, even if they
are more fast.I have tried to fix this, but I have not found a solution. Any idea?
Bad AI when npc chases pc.
Débuté par
Uther78
, août 14 2010 11:56
#1
Posté 14 août 2010 - 11:56
#2
Posté 14 août 2010 - 02:45
You could try something like if the PC is farther than 2 meters from the npc the npc will switch to their missile weapon and use that to attack the PC. I use a little more complexity than that for some creatures, such as scouts, who will go into stealth and sometimes track the PC. That has been quite a surprise to some people.
#3
Posté 14 août 2010 - 04:42
Missle weapons = Lag though right?
#4
Posté 14 août 2010 - 07:04
Genisys wrote...
Missle weapons = Lag though right?
Really?
#5
Posté 15 août 2010 - 09:37
Uther78 wrote...
Genisys wrote...
Missle weapons = Lag though right?
Really?
I thought I actually got around lag by giving some of my NPCs ranged weapons. Instead of having to pathfind their way across a bridge or around buildings, they just start shooting. Seems simple.
#6
Posté 16 août 2010 - 12:31
Actually this guy posted such not too long ago on nwvault...
http://nwvault.ign.c....Detail&id=3761
Might help ^^;
http://nwvault.ign.c....Detail&id=3761
Might help ^^;
#7
Posté 16 août 2010 - 06:30
Daybringer wrote...
Actually this guy posted such not too long ago on nwvault...
http://nwvault.ign.c....Detail&id=3761
Might help ^^;
That guy is myself, I have tried to fix the problem with a speed penalty for the PC, but I dont like that solution, i prefer a fix for the npc A.I.
#8
Posté 25 août 2010 - 01:04
I have made this script: it seems work
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
ClearAllActions();
if (GetDistanceToObject(oPC) < 8.0f)
if (GetDistanceToObject(oPC) > 3.0f)
{
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
ActionAttack(oPC);
}
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
ClearAllActions();
if (GetDistanceToObject(oPC) < 8.0f)
if (GetDistanceToObject(oPC) > 3.0f)
{
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
ActionAttack(oPC);
}
#9
Posté 29 août 2010 - 01:55
Nobody has an opinion?
#10
Posté 29 août 2010 - 04:14
There are a number of problems with that script. So there you have an opinion. Here is a little doctoring off the top of my head with some hopefully helpful comments or additions:
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
//effect eSpeed = EffectMovementSpeedIncrease(125);
//change number to change speed. added for possible temporary speed increase.
ClearAllActions();
// you probably want to use the TRUE parameter here as this is likely to occur
// in combat otherwise the ClearAllActions call will have no effect.
if (GetDistanceToObject(oPC) < 8.0f)
//so do what if this condition exists, do nothing? Maybe you wanted a return
//here or better switch to a ranged weapon if creature has one. If not just
// go into stealth and move away.
//Or maybe you are saying if the PC is within a certain range >3 and <8 meters
// do the following. If so then write it as one statement:
//if ((GetDistanceToObject(oPC) >= 3.0f) && (GetDistanceToObject(oPC) <= 8.0f))
// do this the chase stuff, else do something else. Condition not met PC is not
// between 3.0 and 8.0 meters, changed to or equal too.
if (GetDistanceToObject(oPC) > 3.0f)
{
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
//not sure that you need to keep repeating this.
//maybe use a delay command of a few seconds if the chasing
//npc seems to be losing it's target
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
//if (GetDistanceToObject(oPC) < 1.0f)
// added this in. So no point attacking unless you are actually there in contact
ActionAttack(oPC);
//else ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSpeed, OBJECT_SELF, 3.0);
ActionAttack(oPC);
}
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
//effect eSpeed = EffectMovementSpeedIncrease(125);
//change number to change speed. added for possible temporary speed increase.
ClearAllActions();
// you probably want to use the TRUE parameter here as this is likely to occur
// in combat otherwise the ClearAllActions call will have no effect.
if (GetDistanceToObject(oPC) < 8.0f)
//so do what if this condition exists, do nothing? Maybe you wanted a return
//here or better switch to a ranged weapon if creature has one. If not just
// go into stealth and move away.
//Or maybe you are saying if the PC is within a certain range >3 and <8 meters
// do the following. If so then write it as one statement:
//if ((GetDistanceToObject(oPC) >= 3.0f) && (GetDistanceToObject(oPC) <= 8.0f))
// do this the chase stuff, else do something else. Condition not met PC is not
// between 3.0 and 8.0 meters, changed to or equal too.
if (GetDistanceToObject(oPC) > 3.0f)
{
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
//not sure that you need to keep repeating this.
//maybe use a delay command of a few seconds if the chasing
//npc seems to be losing it's target
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
//if (GetDistanceToObject(oPC) < 1.0f)
// added this in. So no point attacking unless you are actually there in contact
ActionAttack(oPC);
//else ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSpeed, OBJECT_SELF, 3.0);
ActionAttack(oPC);
}
Modifié par ffbj, 29 août 2010 - 04:42 .
#11
Posté 30 août 2010 - 09:46
ffbj wrote...
There are a number of problems with that script. So there you have an opinion.Etc...
Thank you very much.
Yes, I want the NPC charges the PC when is distance is between 3 and 8 meters. Your advice are helpful.
Your idea of a speed improvement during the charge is good.
I have repeated the ActionMoveToLocation because in this way the npc's charge seems more accurate and for the PC is more difficult to escape. I dont think that a delay will be useful.
The clearallactions without the TRUE attribute are uneffective, but the script worked all the same: then maybe is unnecessary to clear the actions.
here are the last part you added:
(//if (GetDistanceToObject(oPC) < 1.0f)
// added this in. So no point attacking unless you are actually there in contact
ActionAttack(oPC)
that part seems now unnecessary because if the npc is already fighting null part of my script stop him (if we remove the clearallactions command).
Modifié par Uther78, 30 août 2010 - 12:20 .
#12
Posté 30 août 2010 - 05:59
Errata corrige:
the clearallactions is necessary. It works even without "TRUE" because when the enemy chase NPC is not consedered "combat"
the clearallactions is necessary. It works even without "TRUE" because when the enemy chase NPC is not consedered "combat"
#13
Posté 30 août 2010 - 10:39
It's just good practice to do a Clear All Actions call before you proceed to other activities. I recommend using the TRUE parameter since these actions are likely to occur around combat, thus the combatant being directed by them may still be flagged as being in combat. But, that is along the lines of what I would do. Just play with it and find out what works most closely to the sort of effects you are going for. Clear All Actions presuppose that there is something to clear. Not really knowing what these npc might be doing otherwise. For instance I have many monsters, creatures that will be just going about their busy, so following some activity. Then if they spot an enemy there is a Clear All Action before going into combat, and also vice-versa. The other way around when a creature has ended combat and goes back to doing some activity. Of course you don't have to use it at all and may still get what you want. This is just the approach I use, along a number of others who have advocated this use of the function.
#14
Posté 01 septembre 2010 - 07:39
Thx, if someone has an idea for improving the script, please post here.
#15
Posté 01 septembre 2010 - 09:03
Here is the updated script:
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (oPC != OBJECT_INVALID && GetIsEnemy(oPC))
if ((GetDistanceToObject(oPC) >= 3.0f) && (GetDistanceToObject(oPC) <= 8.0f))
{
ClearAllActions(TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
ActionAttack(oPC);
}
Note that the command "clearallactions" are applied only if the npc-PC distance is between 3 and 8: then if the npc is already fighting with a near PC the script dont stop him.
#include "x0_i0_position"
void main()
{
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN);
if (oPC != OBJECT_INVALID && GetIsEnemy(oPC))
if ((GetDistanceToObject(oPC) >= 3.0f) && (GetDistanceToObject(oPC) <= 8.0f))
{
ClearAllActions(TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
ActionMoveToLocation(GetAheadLocation(oPC), TRUE);
}
ActionAttack(oPC);
}
Note that the command "clearallactions" are applied only if the npc-PC distance is between 3 and 8: then if the npc is already fighting with a near PC the script dont stop him.
#16
Posté 02 septembre 2010 - 07:56
How i can make the script applies twice per round?
#17
Posté 10 septembre 2010 - 06:31
I can make that the script dont applies if PC and npc are facing opposite directions?
#18
Posté 03 avril 2011 - 05:58
I have found another solution:
If the PC escapes, the melee weaponed enemy npc uses ranged weapons without losing the chase:
http://nwvault.ign.c....Detail&id=3779
But it is not good for animals....
If the PC escapes, the melee weaponed enemy npc uses ranged weapons without losing the chase:
http://nwvault.ign.c....Detail&id=3779
But it is not good for animals....





Retour en haut






