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);
}
Modifié par ffbj, 29 août 2010 - 04:42 .