Raised This Month: $32 Target: $400
 8% 

Proper way to deal damage without extensions


Post New Thread Reply   
 
Thread Tools Display Modes
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-24-2009 , 15:48   Re: Proper way to deal damage without extensions
Reply With Quote #21

I wish the time based damages worked on tf2.
Dragonshadow is offline
Downtown1
Veteran Member
Join Date: Mar 2004
Old 12-24-2009 , 16:39   Re: Proper way to deal damage without extensions
Reply With Quote #22

Is there a way to use something like this to -cancel- damage being given?
Downtown1 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-24-2009 , 16:49   Re: Proper way to deal damage without extensions
Reply With Quote #23

Quote:
Originally Posted by Downtown1 View Post
Is there a way to use something like this to -cancel- damage being given?
No. You would need to hook and block the damage with an extension.
psychonic is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 12-24-2009 , 17:29   Re: Proper way to deal damage without extensions
Reply With Quote #24

one thing worth mentioning, a while ago i tried something like this to "modify" damage. you cant use it inside a player_hurt event and try and deal damage with the weapon used by the attacker, since it fires the same event before handling the first one. i hope that makes sense . maybe you guys know a way around this?
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.

Last edited by meng; 12-24-2009 at 19:40.
meng is offline
Send a message via Yahoo to meng
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-24-2009 , 21:57   Re: Proper way to deal damage without extensions
Reply With Quote #25

Quote:
Originally Posted by meng View Post
one thing worth mentioning, a while ago i tried something like this to "modify" damage. you cant use it inside a player_hurt event and try and deal damage with the weapon used by the attacker, since it fires the same event before handling the first one. i hope that makes sense . maybe you guys know a way around this?
You'd need a hook to block the damage and then use this to give the kind you want.
Dragonshadow is offline
CrancK
Senior Member
Join Date: Jan 2009
Location: Netherlands
Old 12-25-2009 , 11:49   Re: Proper way to deal damage without extensions
Reply With Quote #26

Quote:
Originally Posted by pimpinjuice View Post
Yes, with this function proper death messages occur, as well as stat plugin compatibility.
DealDamage(victim_index,50,attacker_index,DMG _BULLET,"weapon_ak47");

That would make the engine think victim_index was shot for 50 damage (armor distribution works too) with an AK47 used by attacker_index. You can have alot of fun experimenting with Damage type as well.
ok, thx...

erm, quick question though, that means i need a weapon name, which i can easily find... but, what if i want to make like a new weapon, then use this code to make it do damage?

of course, i can make it use a weapon name thats already used, but then people will get confused as to which weapon actually killed/hurt/whatevered them...

so, i guess my question(s) is/are:

are there unused weapons? if so, how to find them? (tf2 this case)

or

can i somehow extend the list of possible choices?
CrancK is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 12-25-2009 , 14:29   Re: Proper way to deal damage without extensions
Reply With Quote #27

Is there a way to change the origin or direction the damage is delt from? When I kill someone with this they always fly a certain direction, its never random (like its always north->south damage, making their body fly south)
Dragonshadow is offline
meng
Veteran Member
Join Date: Oct 2005
Location: us
Old 12-25-2009 , 15:06   Re: Proper way to deal damage without extensions
Reply With Quote #28

yea, just teleport the point_hurt to the attacker position.
__________________
.
[ 1 Dumerils Boa | 1 Cali King ]...
.
I'm a lil' spirituous.
meng is offline
Send a message via Yahoo to meng
CrancK
Senior Member
Join Date: Jan 2009
Location: Netherlands
Old 12-28-2009 , 07:08   Re: Proper way to deal damage without extensions
Reply With Quote #29

i've slightly altered it so i could use it on multiple people at the same time,
but it seems to not be working as in it doesn't damage people.

it doesn't error out however as server console logthingy is clean

can anyone spot where i've gone wrong?

PHP Code:
SetupPointHurt()
{
    for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        
pointHurt[i] = CreateEntityByName("point_hurt");
        
DispatchSpawn(pointHurt[i]);
        
TeleportEntity(pointHurt[i], gHoldingAreaNULL_VECTORNULL_VECTOR);
    }
}

DealDamage(victim,damage,attacker=0,dmg_type=DMG_GENERIC,String:weapon[]="")
{
    if(
victim>&& IsValidEdict(victim) && IsClientInGame(victim) && IsPlayerAlive(victim) && damage>0)
    {
        new 
String:dmg_str[16];
        
IntToString(damage,dmg_str,16);
        new 
String:dmg_type_str[32];
        
IntToString(dmg_type,dmg_type_str,32);
        
//new pointHurt=CreateEntityByName("point_hurt");
        
if(pointHurt[victim])
        {
            new 
Float:vicOri[3];
            
GetClientAbsOrigin(victimvicOri);
            
TeleportEntity(pointHurt[victim], vicOriNULL_VECTORNULL_VECTOR);
            
DispatchKeyValue(victim,"targetname","hurtme");
            
DispatchKeyValue(pointHurt[victim],"DamageTarget","hurtme");
            
DispatchKeyValue(pointHurt[victim],"Damage",dmg_str);
            
DispatchKeyValue(pointHurt[victim],"DamageType",dmg_type_str);
            if(!
StrEqual(weapon,""))
            {
                
DispatchKeyValue(pointHurt[victim],"classname",weapon);
            }
            
//DispatchSpawn(pointHurt);
            
AcceptEntityInput(pointHurt[victim],"Hurt",(attacker>0)?attacker:-1);
            
DispatchKeyValue(pointHurt[victim],"classname","point_hurt");
            
DispatchKeyValue(victim,"targetname","donthurtme");
            
CreateTimer(0.01TPHurtvictim);
            
//RemoveEdict(pointHurt);
        
}
    }
}

public 
Action:TPHurt(Handle:timerany:client)
{
    
TeleportEntity(pointHurt[client], gHoldingAreaNULL_VECTORNULL_VECTOR);

SetupPointHurt is called at mapstart, and makes all the point hurts i'll ever need (probably too many, but for the moment it'll do)
TPHurt is probably not needed, since i don't think its possible to see point hurts ingame, but ahwell..
also a slight change in DealDamage aswell, as i teleport it to the victim, so it should damage it from the right direction(?)

and i call the DealDamage with:

PHP Code:
DealDamage(jdamageclientDMG_GENERIC"n_rocketlauncher"); 
so... where have i gone wrong?

edit: also, slight sidequestion, can this also damage buildings? or destroyable entities?

edit2: it is! possible to see point hurts...(i tried it without the TPHurt function) so yes, the point hurt is even teleported to the right position... it still doesn't do damage though...

Last edited by CrancK; 12-28-2009 at 07:33.
CrancK is offline
API
Veteran Member
Join Date: May 2006
Old 12-28-2009 , 15:05   Re: Proper way to deal damage without extensions
Reply With Quote #30

You could do this:

Code:
stock MultiDealDamage(Handle:hVictims,victimCount,damage,attacker=0,dmg_type=DMG_GENERIC,String:weapon[]="")
{
    ResetPack(hVictims);
    for(new x=0;x<victimCount;x++)
    {
        new victim=ReadPackCell(hVictims);
        DealDamage(victim,damage,attacker,dmg_type,weapon);
    }
}
You'd call it like this:
Code:
new Handle:hPack=CreateDataPack();
WritePackCell(hPack,victim1);
WritePackCell(hPack,victim2);
MultiDealDamage(hPack,2,70,attacker,DMG_BULLET,"weapon_rocket");
CloseHandle(hPack);
Thats using datapacks, you can use an array if you want.
__________________
API is offline
Send a message via AIM to API
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 08:55.


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