Lets have a look then... Ill start ....
Anyhow, so we would need a line of sight check ..... something simple like below, this is because NPC trigger See New Player, can see through walls, meaning if there is a wall between, the NPC will most likely run into it before it trys get around it.
( If i remeber correctly )
Code:
[FUNCTION CheckLineOfSight]
IF <ARGV[0]>
REF1=<SERV.UID.<ARGV[0]>>
ENDIF
IF (<CANSEELOS <REF1.P.X>,<REF1.P.Y>,<REF1.P.Z>,<REF1.P.M>>)
RETURN 0
ELSE
RETURN 1
ENDIF
so we could go ahead with the trigger NPCSeeNewPlayer
Code:
ON=@NPCSeeNewPlayer
TAG.LastLookedAt=<SRC.UID>
IF <CheckLineOfSight <SRC.UID>>
SAY I see <SRC.UID> and im gonna kill him
ATTACK
RETURN 0
ELSE
SAY I sense someone but i cannot see them
GO <HOME> // Go Home or Pathfind ????
RETURN 1
ENDIF
The next trigger we have is ACTFOLLOW
Code:
ON=@NPCActFollow
IF (<REGION.UID>=<SRC.REGION.UID>)
RETURN 2
ELSE
FINDID.i_memory.REMOVE // This is dirty not being specific
RETURN 1
ENDIF
Above basically means if the player you are following leaves the region you are in dont follow anymore (Return 1) , Return 2 means follow.
Now I guess we can improvise on this, pathfinding someone would have to test this act follow to find out how clever it really is.
Because if there is no way around we really dont wanna follow, but if there is a way around we do want to follow.
^^ Its a start lets make something out of it !|
Scrambles through revisions to see whats been done on it -
20-08-2006, Nazghul (Changes only for servers with EF_NewPositionCheck on)
- Fixed #304: NPCs are dumber in pathfinding with EF_DiagonalWalkCheck on
(fixed only with EF_NewPositionCheck and EF_WalkCheck on).
21-01-2008, MrSugarCube
- Fixed #1311: NPC Pathfinding failing when EF_DiagonalWalkCheck is enabled.
28-04-2008, MrSugarCube
- Fixed #1394: Advanced pathfinding (NPC_AI_PATH) allowing NPCs to make invalid movements
(for example walking whilst paralyzed). Some other adjustments have also been made,
allowing NPCs to properly assess characters that may be blocking the way (to walk around
them), negotiate corners with EF_DiagonalWalkCheck enabled, and attempt to compensate
when new obstacles block a previously valid path.
09-09-2008, MrSugarCube
- Fixed #1516: NPCs unable to use pathfinding when trying to follow or walk up to another character.
^^ Quite alot of fixed there,
EF_DiagonalWalkCheck and EF_NewPositionCheck and EF_WalkCheck ,,,, looks like a good start
Im gonna have a little test myself
OK, check this out guys as far as im concerned it works fine, I couldnt shake that vampire bat, it just chased me all over.
I did this in sphere.ini...
NPCAI = 0001|0002|0004|0008|0010|0040|00100|00200
Experimental = 01|08|040|080|0100|0400|02000|010000
then i made the event ....
Code:
[EVENTS e_NPCBrains]
ON=@NPCSeeNewPlayer
TAG.LastLookedAt=<SRC.UID>
IF <CheckLineOfSight <SRC.UID>>
SAY I see <SRC.UID> and im gonna kill him
ATTACK
RETURN 0
ELSE
SAY I sense someone but i cannot see them
GO <HOME> // Go Home or Pathfind ????
RETURN 1
ENDIF
ON=@NPCActFollow
IF (<REGION.UID>=<SRC.REGION.UID>)
RETURN 2
ELSE
FINDID.i_memory.REMOVE // This is dirty not being specific
RETURN 1
ENDIF
I put it on a bat then ran for my life.... I think the NPCAI in sphere ini is good myself..