Forum

> > CS2D > Scripts > Damage an NPC without explosions
Forums overviewCS2D overview Scripts overviewLog in to reply

English Damage an NPC without explosions

18 replies
To the start Previous 1 Next To the start

old Damage an NPC without explosions

Alistaire
User Off Offline

Quote
I'm working on a dungeoncrawler mod and it came to my attention that "there is no way to damage an NPC with Lua without explosions". It's really annoying to make a damage factor-ish stat on a player which causes "exploding bullets".

----

So how do you damage an NPC with Lua without explosions?

(I ask this because the script will be multiplayer, and if I just change like the weapondamage on some weapon, EVERYONE will have these changes, possibly. Maybe it's possible to ninja-edit the damage stats on a weapon, but that seems too much CPU for such scripting.

old Re: Damage an NPC without explosions

KimKat
GAME BANNED Off Offline

Quote
I am assuming it's possible to write a function handler for grenades on explode to cause damage to NPC that are within radius. But I don't know how to make that happen either because Lua is not my strongest side. What I do know is that it's possible to achieve somehow someway. Although it might require use of some really advanced Lua.

old Re: Damage an NPC without explosions

Alistaire
User Off Offline

Quote
With explosions I mean;

1
2
3
4
5
6
7
function _objDmgFunc(dynid, dmg, id)
	if id ~= 0 then
		if true then
			parse('explosion '..object(dynid, 'x')..' '..object(dynid, 'y')..' 1 '..(dmg * playerStats[player(id, 'usgn')][10])..' '..id)
		end
	end
end

a.k.a Whenever I hit an NPC an explosion will occur with my damagefactor.

old Re: Damage an NPC without explosions

KimKat
GAME BANNED Off Offline

Quote
1
2
3
4
5
6
7
addhook("objectdamage","obj_dmg")
function obj_dmg(id,damage,player)
	if id == 30 then
		parse('explosion '..object(dynid, 'x')..' '..object(dynid, 'y')..' 1 '..(dmg * playerStats[player(id, 'usgn')][10])..' '..id)
		return 1
	end
end
-Lua script by user Jynxxx, he told me to add it here.

I hope that helps.

old Re: Damage an NPC without explosions

EngiN33R
Moderator Off Offline

Quote
@user KimKat: That's basically answering to a question whether you can hurt NPCs without explosions with a script that hurts NPCs with explosions.
edited 1×, last 05.11.12 09:27:00 am

old Re: Damage an NPC without explosions

Alistaire
User Off Offline

Quote
user EngiN33R has written
That's basically answering to a question whether you can hurt NPCs without explosions with a script that hurts NPCs with explosions.


I want a way to damages NPC's without explosions, not with explosions, because they have an annoying sound and it looks stupid that everything blows up from a single shot.

old Re: Damage an NPC without explosions

KimKat
GAME BANNED Off Offline

Quote
Well, that's better than to leave a question unanswered.
And I assume this code works but someone should test it before saying anything more or less.

@user Alistaire you could assign normal damage aswell just fiddle with the script a bit and you'll have a result.
edited 1×, last 05.11.12 09:24:49 am

old Re: Damage an NPC without explosions

Alistaire
User Off Offline

Quote
user KimKat has written
Well, that's better than to leave a question unanswered.
And I assume this code works but someone should test it before saying anything more or less.


Dude. Please. I know what I'm doing. You just posted the exact same script as me, except it crashes if NPC's get damaged by themselves.

Also, the return 1 doesn't really add much damage, does it?

----

user KimKat has written
@user Alistaire you could assign normal damage aswell just fiddle with the script a bit and you'll have a result.


How could I assign normal damage, that's my question.

old Re: Damage an NPC without explosions

KimKat
GAME BANNED Off Offline

Quote
Well that's odd. I do not know why that occurs though, so don't blame anything on me user Jynxxx coded it.
If you just experiment with the script perhaps then you might come up with a solution else go read Lua tutorials it'll help you actually get somewhere.

old Re: Damage an NPC without explosions

Alistaire
User Off Offline

Quote
user KimKat has written
If you just experiment with the script perhaps then you might come up with a solution else go read Lua tutorials it'll help you actually get somewhere.


1. I don't know a way to damage NPC's other than with explosions.
2. Lua tutorials aren't that specific.
3. I am "somewhere". I just want to know a way to damage NPC's without explosions. Obviously.
edited 1×, last 05.11.12 09:29:17 am

old Re: Damage an NPC without explosions

KimKat
GAME BANNED Off Offline

Quote
Don't ask me PM him about it, maybe he just edited it to help you. Don't you think?
I did all I could to aid in this thread I have to go and I hope that someone else who knows Lua can give you further tips or solutions.
edited 1×, last 05.11.12 09:31:05 am

old Re: Damage an NPC without explosions

Alistaire
User Off Offline

Quote
user mafia_man has written
You can't decrease npc health without explosion or player attacking it.


Then is there a better way to make the explosions less annoying? (teleport the player away to stop the sound from playing, adding parse('effect ') to hide the yellow flash..)

old Re: Damage an NPC without explosions

EngiN33R
Moderator Off Offline

Quote
You can kill an NPC using the killobject console command if you have its ID (which isn't too hard to find out). I don't think actually decreasing health is possible though.

old Re: Damage an NPC without explosions

omg
User Off Offline

Quote
ive had the same problem a couple months ago. its not possible unless u make ur own npcs

also, the explosions dont do exactly the dmg listed to nearby npcs and they also hit other npcs by accident, so definitely make ur own npcs
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview