Raised This Month: $ Target: $400
 0% 

Get xyz coords as for RadiusDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Al3
Member
Join Date: Sep 2015
Location: Bulgaria
Old 09-19-2015 , 00:23   Get xyz coords as for RadiusDamage
Reply With Quote #1

I assume RadiusDamage requires (as a first param) xyz coords for the "explosion".



So is there any way I can get them corresponding to an entity say "player" ( entity_get_vector ? ) ?

PHP Code:
RadiusDamageFloat:{FLOAT_XFLOAT_YFLOAT_Z}, INT_DAMAGEINT_RADIUS);
// Videlicet, FLOAT_X, FLOAT_Y and FLOAT_Z must all determine the location of an entity. 

Last edited by Al3; 09-19-2015 at 01:51.
Al3 is offline
Send a message via Skype™ to Al3
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-19-2015 , 02:20   Re: Get xyz coords as for RadiusDamage
Reply With Quote #2

get_user_origin() will get you the location of a player. You'll have to convert the coordinates into floating point values before using them in radius_damage().

Alternatively, if you are already using fakemeta, you can use pev(ent, pev_origin, fOrigin) where fOrigin is a floating point array with 3 elements.
__________________
fysiks is offline
Al3
Member
Join Date: Sep 2015
Location: Bulgaria
Old 09-19-2015 , 02:24   Re: Get xyz coords as for RadiusDamage
Reply With Quote #3

I am coding an exclusively large cs mod. All libraries I needed to include.
It appears that me using Pawn/amxmod is somehow easier than me using C, although I've been developing in C for years.

There are just a few things I cannot know unless they are referenced and so forth.
Or unless I get back to find and read the library implementations (which may direct me to other dependencies, a chain of library implementations) but why if already some of you may know the answer(s).

Thanks

Last edited by Al3; 09-19-2015 at 02:27.
Al3 is offline
Send a message via Skype™ to Al3
Al3
Member
Join Date: Sep 2015
Location: Bulgaria
Old 09-19-2015 , 02:42   Re: Get xyz coords as for RadiusDamage
Reply With Quote #4

Though why even if I

PHP Code:
        new Float:fOrigin [3];
        
test false;
        
fOrigin[0] += 5000;
        
fOrigin[1] += 5000;
        
fOrigin[2] += 5000;
        
pev(idpev_originfOrigin);
        
RadiusDamage(fOrigin11); 
it kills me? the damage multiplier is even 1 how is that even happening?

Last edited by Al3; 09-19-2015 at 02:44.
Al3 is offline
Send a message via Skype™ to Al3
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-19-2015 , 13:05   Re: Get xyz coords as for RadiusDamage
Reply With Quote #5

Quote:
Originally Posted by Al3 View Post
PHP Code:
        new Float:fOrigin [3];
        
fOrigin[0] += 5000;
        
fOrigin[1] += 5000;
        
fOrigin[2] += 5000
This add 5000 to 0 (the default value of a new variable is zero).

Quote:
Originally Posted by Al3 View Post
PHP Code:
        pev(idpev_originfOrigin); 
This overwrites the values in fOrigin with the entity's current origin. The definition of "overwrite" is "to replace the values", it is not related to rollover.
__________________

Last edited by fysiks; 09-19-2015 at 13:06.
fysiks is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-19-2015 , 03:33   Re: Get xyz coords as for RadiusDamage
Reply With Quote #6

What's the purpose of
PHP Code:
fOrigin[0] += 5000;
fOrigin[1] += 5000;
fOrigin[2] += 5000
?

Anyway, I've never used RadiusDamage() (radius_damage()), but looking at its code, its implementation is really bad in my opinion.
Code: https://mxr.alliedmods.net/amxmodx/s...engine.cpp#178
So, if you are standing really close to explosion origin (2 * radius multiplier), which does happen if you create an explosion at player's origin, it's going kill that player every time.

The best thing would probably be to create your own function to which you could pass explosion origin, damage and radius, and deal damage based on range. No multipliers involved, just raw values.

Last edited by klippy; 09-19-2015 at 03:33.
klippy is offline
Al3
Member
Join Date: Sep 2015
Location: Bulgaria
Old 09-19-2015 , 03:47   Re: Get xyz coords as for RadiusDamage
Reply With Quote #7

I thought that by that I'm gonna send it to completely different location, far from the player so it doesn't die.

I agree RadiusDamage() has awful implementation. Redundant and performance-irrational coding.

If I am to create my own function what should I use? fakemeta_stocks's fakedamage()?
That one isn't referenced as well. In http://www.amxmodx.org/ only its prototype is shown, like I cannot see it myself or use the amxx studio's autocomplete...

Last edited by Al3; 09-19-2015 at 03:54.
Al3 is offline
Send a message via Skype™ to Al3
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-19-2015 , 06:47   Re: Get xyz coords as for RadiusDamage
Reply With Quote #8

Here's the official documentation if you haven't found it by now: http://amxmodx.org/api/engine_stocks/fakedamage
If a function is a stock (has stock in front of the function name), it means it's implemented in PAWN. Just click the File link in the upper right corner of the page and find the function in there.
If it is a native however, like radius_damage() is (RadiusDamage() just calls radius_damage()), its implementation is found within the AMXX (or its modules). You can easily browse through the code at GitHub or Cross Reference.

To answer your question: you could call TakeDamage on victim
Code:
/**
  * Description:        Usually called whenever an entity takes any kind of damage.
  *                    Inflictor is the entity that caused the damage (such as a gun).
  *                    Attacker is the entity that tirggered the damage (such as the gun's owner).
  * Forward params:    function(this, idinflictor, idattacker, Float:damage, damagebits);
  * Return type:        Integer.
  * Execute params:    ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
  */
  Ham_TakeDamage
Just like so:
PHP Code:
ExecuteHamB(Ham_TakeDamageVictimInflictorAttackerFloatDamageDamageType); 
You could pass attacker ID to both inflictor and attacker, shouldn't matter. For DamageType DMG_GENERIC should do okay, but if you want to go more in-depth about damage types, here.

EDIT:
Sending the explosion to different location works the way you did it, but the thing is, you have overridden fOrigin[]'s value by calling pev() and saving its result into that array. You should take the execution order in account too.

Last edited by klippy; 09-19-2015 at 06:53.
klippy is offline
Al3
Member
Join Date: Sep 2015
Location: Bulgaria
Old 09-19-2015 , 06:49   Re: Get xyz coords as for RadiusDamage
Reply With Quote #9

What if the "victim" is breakable object?
That surely won't affect it.

And do you mean fakedamage() ?

Last edited by Al3; 09-19-2015 at 06:50.
Al3 is offline
Send a message via Skype™ to Al3
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-19-2015 , 06:58   Re: Get xyz coords as for RadiusDamage
Reply With Quote #10

I edited my previous post a bit, read through it again.

You should check if the victim is actually a player, by calling
PHP Code:
if(is_user_alive(victim))
{
    
// It's an alive player, deal damage to it

Even if victim was a breakable object ("func_breakable"), it shouldn't matter. TakeDamage can be executed on breakables.
klippy 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:11.


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