AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get xyz coords as for RadiusDamage (https://forums.alliedmods.net/showthread.php?t=271753)

Al3 09-19-2015 00:23

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

http://softwarecns.herobo.com/syntax.png

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. 


fysiks 09-19-2015 02:20

Re: Get xyz coords as for RadiusDamage
 
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.

Al3 09-19-2015 02:24

Re: Get xyz coords as for RadiusDamage
 
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 :)

Al3 09-19-2015 02:42

Re: Get xyz coords as for RadiusDamage
 
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?

klippy 09-19-2015 03:33

Re: Get xyz coords as for RadiusDamage
 
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.

Al3 09-19-2015 03:47

Re: Get xyz coords as for RadiusDamage
 
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...

klippy 09-19-2015 06:47

Re: Get xyz coords as for RadiusDamage
 
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.

Al3 09-19-2015 06:49

Re: Get xyz coords as for RadiusDamage
 
What if the "victim" is breakable object?
That surely won't affect it.

And do you mean fakedamage() ?

klippy 09-19-2015 06:58

Re: Get xyz coords as for RadiusDamage
 
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.

Al3 09-19-2015 07:10

Re: Get xyz coords as for RadiusDamage
 
Silly me I didn't noticed that I was calling it pev after the post-calculation.

Yes I have been using Damage event as well as Ham_TakeDamage ham
the problem is that the player isn't attacking. Think of it as if I were to re-create c4.
I thought Ham_TakeDamage doesn't execute on anything else but when damage has been received from someone/to someone.


All times are GMT -4. The time now is 22:11.

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