Forum

> > CS2D > Scripts > Make NPC always know where player are.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Make NPC always know where player are.

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Make NPC always know where player are.

FishyFinThing
User Off Offline

Zitieren
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!

alt Re: Make NPC always know where player are.

TrialAndError
User Off Offline

Zitieren
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

alt Re: Make NPC always know where player are.

TrialAndError
User Off Offline

Zitieren
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.
1× editiert, zuletzt 21.01.20 12:25:04

alt Re: Make NPC always know where player are.

FishyFinThing
User Off Offline

Zitieren
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: !
1× editiert, zuletzt 22.01.20 01:52:43
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht