Forum

> > CS2D > Scripts > npc path
Forums overviewCS2D overview Scripts overviewLog in to reply

English npc path

6 replies
To the start Previous 1 Next To the start

old npc path

deividas270
User Off Offline

Quote
Hello, i want to make npcs, that follows path way and doesnt attack their team. how could i do this? Also it would be nice to make turrets with more hp.

old Re: npc path

Marcell
Super User Off Offline

Quote
i already asked this... but everybody say that.. it's possible with lua.. √

old Re: npc path

Suprise
BANNED Off Offline

Quote
Well, DC won't add scriptable Npcs so I think it's not possible.
Btw, You can make your own. I mean try with image.

old Re: npc path

Yates
Reviewer Off Offline

Quote
user deividas270 has written
Also it would be nice to make turrets with more hp.

Change building health with RCon.

old Re: npc path

Starkkz
Moderator Off Offline

Quote
Spoiler >


use it this way
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
startX = 0
startY = 0
goalX = 15
goalY = 30
path, i, x = FindPath(startX, startY, goalX, goalY)

function UpdateMovement()
	if path and path[i] then
		local node = path[i]
		local moveX = node.x
		local moveY = node.y

		-- check the distance of the NPC position and the tile position
		if (distance between npc and tile) < 32 then
			i = i + x
		else
			-- NPC must move to the position of the tile
		end
	else
		-- must use FindPath to find again the path
		path, i, x = FindPath(startX, startY, goalX, goalY)
	end
end

It's tile based path finding, uses A* algorithm.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview