Hi, sorry for the late reply but thanks a ton to all of you for the tips. It's really helping. GhostofGod's function from Lightfoot is working pretty good for stationary NPCs.
I altered it a bit to make it like this:
int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc);int GetIsFacingTarget(object oSelf, object oTarget, int nViewArc){location lSelf = GetLocation(oSelf);location lTarget = GetLocation(oTarget);
float AngleOffset = VectorToAngle( GetPosition(oTarget) - GetPosition(oSelf)) - GetFacing(oSelf) ;
return (abs(FloatToInt(AngleOffset)) < nViewArc/2);}
void PseudoHeartBeat(){ object oSelf = OBJECT_SELF; object oTarget = GetFirstPC();
int inView = 0;
if (GetIsFacingTarget(oSelf, oTarget, 120)) { inView = 1;
if(inView == 1) { AssignCommand(oSelf, SpeakString("5"));
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectCutsceneParalyze(), oTarget, 0.5);
AssignCommand(oTarget,ClearAllActions());
AssignCommand(oSelf,ClearAllActions());
AssignCommand(oTarget, ActionJumpToObject(GetWaypointByTag("home")));
} }
if(TRUE) {
DelayCommand(0.5, PseudoHeartBeat()); }}
Now, the only problem I seem to have is when I make the NPC patrol. The character seen will become stuck at the start and be unable to move forward, as if the "ActionJumpToObject" function keeps getting called. I think it only happens if the character is in the radius of view, which means the enemy can see through walls.
Is there something I can do here? I tried it with LineOfSight but that didn't work out.
Modifié par Sturmdolch, 24 février 2011 - 03:49 .