Raised This Month: $ Target: $400
 0% 

Dealing damage with Hamsandwich


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 08-14-2007 , 05:01   Dealing damage with Hamsandwich
Reply With Quote #1

Yo hello, modders.

I haven't been on in a while - the mods coming along too smoothly.

I have the most part of it written, just having some trouble with damage atm ... (and graphical effects, but I'll leave those a while)

Currently I hook the takedamage event with RegisterHam(Ham_TakeDamage...) etc.
This means I can quite happily increase, decrease or cancel the damage being dealt.
But I can't seem to get ExecuteHam to work (for reflecting damage to the attacker - I can't just change the "attacker" parameter because I want to damage both)

I've seen people post "just call the Ham_TakeDamage event with ExecuteHam", which is all well and good but I get 3 tag mismatch warnings and nothing happening in-game.

So put simply:

Could someone post the snippet to execute the takedamage event?

(let's assume we have attacker (int) victim (int) and damage (float) )

And what does "this" refer to? victim? attacker?

Thanks, people.

-Pixie
purple_pixie is offline
sawce
The null pointer exception error and virtual machine bug
Join Date: Oct 2004
Old 08-14-2007 , 10:21   Re: Dealing damage with Hamsandwich
Reply With Quote #2

Ignore the tag mismatches for now, they use the new "any" tag that is implemented in 1.8.

To execute damage on the attacker, you would do something like this:

Code:
#include <amxmodx> #include <hamsandwich> public plugin_init() {   RegisterHam(Ham_TakeDamage, "player", "player_hurt", 1); } public player_hurt(this, inflictor, attacker, Float:damage, dmgtype) {   if (ShouldReflect(this))   {     ExecuteHam(Ham_TakeDamage, attacker, inflictor, attacker, damage * 0.1, dmgtype);   }   return HAM_HANDLED; }

(I just wrote that in the browser, haven't checked for syntax. You should get the idea).

And "this", in hamsandwich, is always the entity that the function is being called on. So in this case, it would be the entity that is taking damage.
__________________
fyren sucks

Last edited by sawce the snail; 08-14-2007 at 10:24.
sawce is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 08-14-2007 , 11:07   Re: Dealing damage with Hamsandwich
Reply With Quote #3

Spot the legend ;-)

Now you come to mention it I had figured out what "this" was ... I just renamed it victim so I got confused at seeing it again in the documentation ^^.

I assume the lack of damage was me forgetting to pass damage type into it ... that or passing in an integer for damage or smth silly like that.

Thanks for the help (not to mention the module - it's very handy)
purple_pixie is offline
Reply



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 22:48.


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