SphereCommunity
NPC AI Sphere vs RunUO - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: General Discussion (/Forum-General-Discussion)
+--- Forum: UO/Sphere Discussion (/Forum-UO-Sphere-Discussion)
+--- Thread: NPC AI Sphere vs RunUO (/Thread-NPC-AI-Sphere-vs-RunUO)

Pages: 1 2


RE: NPC AI Sphere vs RunUO - Anarch Cassius - 10-02-2012 06:19 AM

With NPC_AI_PATH|NPC_AI_ALWAYSINT my NPCs seem to have good enough pathfinding. Setting a very low moverate will reduce the delay in thinking and walking for NPCs in general. I tend only use higher values for undead and golems and such.

Could we get some video of bad sticking? Pathfinding is hard to fix with script but I can't pinpoint any glaring errors to ask the hardcoders to fix.


RE: NPC AI Sphere vs RunUO - Extreme - 10-02-2012 07:01 AM

My "Pathfinding" fix is a memory that on timer if "CONT" isn't where should be, call GOTO to location...


RE: NPC AI Sphere vs RunUO - Shaklaban - 10-02-2012 07:09 AM

NPC_AI_ALWAYSINT is not usable, cpu usage gone crazy after long uptime and wont reduce even on server with no players.


RE: NPC AI Sphere vs RunUO - Anarch Cassius - 10-02-2012 07:22 AM

Define long up time... if it's hours, that's a problem, though not one I've had (though my use of NPCs and maps is limited at the moment), if it's days or weeks then that's unpleasant but not an unreasonable interval for maintenance restarts. Either way worth looking in to.

You might try adjusting SECTORSLEEP and see if that helps.


RE: NPC AI Sphere vs RunUO - Extreme - 10-02-2012 07:23 AM

Shak, did you tried .SERV.SHRINKMEM ?


RE: NPC AI Sphere vs RunUO - Barnabus - 10-02-2012 07:26 AM

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..


RE: NPC AI Sphere vs RunUO - Barnabus - 10-02-2012 09:52 AM

aha MoveRate !!! the overide tag, i guess some of the mobs dont follow so well because they are slow !!!
Code:
[EVENTS e_NPCBrains]
ON=@NPCSeeNewPlayer
    TAG.LastLookedAt=<SRC.UID>
    IF <CheckLineOfSight <SRC.UID>>
        SAY I see <SRC.UID> and im gonna kill him
        NEWITEM i_RunLikeABastard, 1, <UID>
        ATTACK
        RETURN 0
    ELSE
        SAY I sense someone but i cannot see them
        IF <FINDID.i_runLikeABastard>
            FINDID.i_runLikeABastard.REMOVE
        ENDIF
        GO <HOME> // Go Home or Pathfind ????
        RETURN 1
    ENDIF

[ITEMDEF i_runLikeABastard]
DEFNAME=i_runLikeABastard
ID=i_memory
NAME=Run Like a Bastard
TYPE=t_eq_script

ON=@CREATE
    ATTR=ATTR_NEWBIE|ATTR_DECAY|ATTR_MOVE_NEVER
    TIMER=1
    MORE=1

ON=@TIMER
    LOCAL.CurrentMoveRate=<CONT.MOVERATE>
    LOCAL.CurrentMobUId=<CONT.UID>
    IF <MORE> > 6
        CONT.MANA=<EVAL <CONT.INT>> // Speed times out you can cast now have some mana
        CONT.TAG.OVERRIDE.MOVERATE=<LOCAL.CurrentMoveRate>
        REMOVE
        RETURN 1
    ELSE
        CONT.MANA=0  // Dont cast run
        CONT.TAG.OVERRIDE.MOVERATE=<EVAL <LOCAL.CurrentMoveRate>/3> // Run 3 times faster than usual
        MORE=<MORE>+1
        TIMER=1
        RETURN 1
    ENDIF
    RETURN 1

That helps the monsters stay on your tail. !


RE: NPC AI Sphere vs RunUO - Shaklaban - 10-03-2012 01:42 AM

(10-02-2012 07:23 AM)Extreme Wrote:  Shak, did you tried .SERV.SHRINKMEM ?

yeah im using it periodically on worldsaves.