AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   Proper way to deal damage without extensions (https://forums.alliedmods.net/showthread.php?t=111684)

Dragonshadow 12-24-2009 15:48

Re: Proper way to deal damage without extensions
 
I wish the time based damages worked on tf2.

Downtown1 12-24-2009 16:39

Re: Proper way to deal damage without extensions
 
Is there a way to use something like this to -cancel- damage being given?

psychonic 12-24-2009 16:49

Re: Proper way to deal damage without extensions
 
Quote:

Originally Posted by Downtown1 (Post 1030033)
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.

meng 12-24-2009 17:29

Re: Proper way to deal damage without extensions
 
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?

Dragonshadow 12-24-2009 21:57

Re: Proper way to deal damage without extensions
 
Quote:

Originally Posted by meng (Post 1030098)
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.

CrancK 12-25-2009 11:49

Re: Proper way to deal damage without extensions
 
Quote:

Originally Posted by pimpinjuice (Post 1029955)
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?

Dragonshadow 12-25-2009 14:29

Re: Proper way to deal damage without extensions
 
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)

meng 12-25-2009 15:06

Re: Proper way to deal damage without extensions
 
yea, just teleport the point_hurt to the attacker position.

CrancK 12-28-2009 07:08

Re: Proper way to deal damage without extensions
 
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...

API 12-28-2009 15:05

Re: Proper way to deal damage without extensions
 
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.


All times are GMT -4. The time now is 18:42.

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