Forum

> > CS2D > Scripts > Know with what NPC you're dealing..?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Know with what NPC you're dealing..?

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Know with what NPC you're dealing..?

Alistaire
User Off Offline

Zitieren
> Working on a dungeoncrawler mod
> No I'm not promising it's gonna be released

----

So, how do you know with what NPC you're dealing AFTER you've spawned it yourself with Lua;

1
2
3
function spawnSoldier(x, y, rot)
	parse('spawnnpc 5 '..x..' '..y..' '..rot)
end

1
2
3
4
5
6
7
8
9
function _objDmgFunc(dynid, dmg, id)
	if object(dynid, 'type') >= 30 and object(dynid, 'type') <= 35 then
		_targetHudFunc(dynid, dmg, id, object(dynid, 'type'))
	end
end

function _targetHudFunc(dynid, dmg, id, npctype)
	parse('hudtxt2 '..id..' 49 "©255255255'..npcNames[npctype-29]..': '..object(dynid, 'health')..' health left" 320 5 1')
end

It's pretty much about line 8; npcNames[npctype-29]. I searched the forums and found people saying a zombie is npc type 30, and headcrab npc type 31. But it is not.

Now, how do I find out what npc type/id I've just damaged?

alt Re: Know with what NPC you're dealing..?

BetaM
User Off Offline

Zitieren
Try object(x,"player"). (it returns the NPC type)

For some reason the NPC's with the same type as the player ID (so only 1-5) break when the player leaves the server (regardless of the mp_killbuildings value), so it's a bit tricky to put into multiplayer.
1× editiert, zuletzt 03.11.12 21:14:25

alt Re: Know with what NPC you're dealing..?

Alistaire
User Off Offline

Zitieren
How I solved this:

- rotation can be enhanced when spawning an NPC with Lua
- rootrot is an object(id, 'value') value
- there are 5 NPC ID's

1
local NPC ID = ((rootrot / 5) - math.floor(rootrot / 5)) * 5

----

To spawn an NPC you have to put in the NPC ID, and the rotation you actually want. The script enhances the rotation a bit so that if it goes through said function, the NPC ID will be retrieved.

It's a terrible way of doing this, but it works.

alt Re: Know with what NPC you're dealing..?

Alistaire
User Off Offline

Zitieren
user Starkkz hat geschrieben
You should try the modulus lua function.
1
local npcid = rootrot % 5
It's the same thing you did there.


I found out it's easier to use object(id, 'player'). Rootrot isn't set if you spawn an NPC with Lua.

The downside of the player value is that, according to some people, NPC's die when you leave the server or something. Maybe it's a myth, just like object(id, 'type') = 30 to 35.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht