Forum

> > CS2D > Scripts > Make NPC always know where player are.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Make NPC always know where player are.

4 replies
To the start Previous 1 Next To the start

old Make NPC always know where player are.

FishyFinThing
User Off Offline

Quote
Hi everyone!

I'm currently experimenting on these NPC packs:
Starkkz's NPC Pack
2Gen's Extension for Starkkz's NPC Pack

However, I'm not very experience in deconstructing such complex scripts. Therefore, I may not be able to understand their scripts enough do what I want.

I'm thinking on letting NPC know all player's locations and going after players instead of them waiting for player to enter their vision range.

If anyone can help me know how, please let me know. Thank you!

old Re: Make NPC always know where player are.

TrialAndError
User Off Offline

Quote
There is a
npc_class:checkVisual(x, y)
function that is in server.lua, try to see where it's called and try commenting it out. There's also some 'viewdist' properties for the classes that you can try tweaking

old Re: Make NPC always know where player are.

TrialAndError
User Off Offline

Quote
If I remember, there's a freeline function in there somewhere, try searching for 'freeline' and see where it's used. Freeline is just checking if the line between 2 points has a wall blocking or not.
edited 1×, last 21.01.20 12:25:04 pm

old Re: Make NPC always know where player are.

FishyFinThing
User Off Offline

Quote
After disable some freeline() function it seems I almost there.

When see player, the NPC will remember and chasing player till the end. Unless I go to a room, hit the switch to close the room with a dynamic wall and break vision with NPC. Strangely enough, the dynamic wall isn't count as a vision block and the NPC can walk through it if they still see me through the dynamic wall. But it's ok, I don't mind that minor detail.

I think there is one problem left:
When the player spawn with a wall between him/her and the NPC, the NPC can't see even if they are within the same screen. This is strange because it happen even without freeline(). Is it because the NPC have no target registered on spawn?

PS: Never mind! If NPC can't see player through wall, I can just script it so that they will go to some random entities like spawn, teleport and bot node. Hopefully while doing so they will encounter players. Thanks @user TrialAndError: !
edited 1×, last 22.01.20 01:52:43 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview