Raised This Month: $ Target: $400
 0% 

How to intercept amount of damage?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-13-2006 , 17:58   How to intercept amount of damage?
Reply With Quote #1

How do you intercept the amount of damage that is about to be substracted from the receivers health and modify it?
__________________
Become part of games development!
http://www.games-academy.de
Wolle is offline
Send a message via AIM to Wolle
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 04-13-2006 , 17:59  
Reply With Quote #2

you can modify bullet damage..

you can give players back the health they lose.

dont know if thats what you want..
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-13-2006 , 18:02  
Reply With Quote #3

Actually yes.
At the moment I dont care what inflicts damage and how.
I just want to intercept the amount of damage (caused by whatever) that is about to be substracted from the players health and modify it.
How would you do that?
__________________
Become part of games development!
http://www.games-academy.de
Wolle is offline
Send a message via AIM to Wolle
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 04-13-2006 , 19:07  
Reply With Quote #4

if u dont want to add health back later on (coz the player could die before that ), u can directly modify the damage:

Code:
register_message(get_user_msgid("Damage"), "hook_damage") .. public hook_damage(msg_id, msg_dest, entity) {     new dmg = get_msg_arg_int(2)     new type = get_msg_argtype(2)     set_msg_arg_int(2,type, dmg/3)     return PLUGIN_CONTINUE }

that should reduce the damage made to third of the original
__________________
plop
p3tsin is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-13-2006 , 19:24  
Reply With Quote #5

I see!!!
That gives me something to work with.
Thanks!

++karma ;
__________________
Become part of games development!
http://www.games-academy.de
Wolle is offline
Send a message via AIM to Wolle
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-13-2006 , 20:14  
Reply With Quote #6

I see 2 flaws.
1. Damage caused by something else than weapons (gravity) isn't indicated.
2. The new health has also already been set.
2.1. Your
Code:
set_msg_arg_int(2,type, dmg/3)
suggestion doesn't seem to work.

There doesn't seem to be a way to do what I want to do.
__________________
Become part of games development!
http://www.games-academy.de
Wolle is offline
Send a message via AIM to Wolle
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 04-14-2006 , 04:31  
Reply With Quote #7

hmm.. events registered with register_message() are called just before they occur, so i dont see why modifying the damage doesnt work
although changing damagetype to something else works

the function does get called for me when i fall, except when dmg >= health (the player dies, so thats another wrong assumption by me)

also seems that the event cant even be blocked with PLUGIN_HANDLED, which is even more weird..
i just thought hooking it with register_message() would be as simple as any other message, guess i was wrong, sry
__________________
plop
p3tsin is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 04-14-2006 , 05:14  
Reply With Quote #8

Quote:
also seems that the event cant even be blocked with PLUGIN_HANDLED
You can block Damage message which sends to the client but you can't block actual damage with that method. When Damage message is sent server already "damaged" a player.
VEN is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 04-14-2006 , 08:35  
Reply With Quote #9

Quote:
Originally Posted by p3tsin
...guess i was wrong, sry
Don't worry p3tsin you can keep the ++karma anyway!!
Just too bad that this isnt possible.
Is there a way to realize that through different module code?
I mean writing a module that allows to do what I want to do?
If yes, where am I gonna find a good introduction tutorial to module coding?
If no, where am I gonna find it anyway?

EDIT:
Nvm my last 2 questions.
Looks like the guide in the docs is pretty good.
__________________
Become part of games development!
http://www.games-academy.de
Wolle is offline
Send a message via AIM to Wolle
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 04-14-2006 , 10:45  
Reply With Quote #10

The only way I was able to intercept damage when I needed to was by setting every person's HP to 1024, and then working with their HP. This means that if you want them dead, you can just add some code that's basically like:

Code:
if(iDamage >= 100)      user_kill(id)

Or whatever. You can also reset their HP to 1024 every time they get hit. Or you can check if their HP is:

Code:
if(iHealth < 9024)      user_kill(id)

You'll have to use messages to let clients know that they didn't just suicide.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode