Raised This Month: $51 Target: $400
 12% 

Increasing Spell Dmg via another attribute


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Recluse
Junior Member
Join Date: Jul 2021
Location: Braap
Old 12-19-2021 , 19:50   Increasing Spell Dmg via another attribute
Reply With Quote #1

I've been trying to increase the damage of a spell by multiplying it whenever there's a change in the value of another attribute. So far, the only thing I was able to get working is the default damage of the spell.

Here's what I have

Code:
public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public OnClientDisconnect(client)
{
    if(IsClientInGame(client))
    {
        SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
    }
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
    new String:classname[128]; 
    GetEdictClassname(inflictor, classname, sizeof(classname));
    if(!strcmp("tf_projectile_spellfireball", classname))
    {
	new Address:DMGBonus=TF2Attrib_GetByName(weapon,"damage bonus");
        damage = 2000000.0;
        damagetype |= DMG_PREVENT_PHYSICS_FORCE;
	if(DMGBonus !=Address_Null)
	{
	   damage*=0+(1.25*1.2);
	}
    }
    return Plugin_Changed;
}
I'm pretty new to coding and any assistance would be greatly appreciated.
Recluse is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-20-2021 , 04:53   Re: Increasing Spell Dmg via another attribute
Reply With Quote #2

You can read the damage modifier via the individual weapon and the reduction of it (sum / product depending on the specific attribute) from the player.
As-is, the code suggests that it'll apply to the Spellbook, assuming the fireball isn't spawned by a plugin, which may not be what you want.

You may want to consider using the TF2Attrib_HookValueFloat function in my fork of tf2attributes:

Code:
// this provides the total damage multiplier on an attacker
float flDamageBonus = TF2Attrib_HookValueFloat(1.0, "mult_dmg", attacker);
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Recluse
Junior Member
Join Date: Jul 2021
Location: Braap
Old 12-20-2021 , 13:24   Re: Increasing Spell Dmg via another attribute
Reply With Quote #3

How would i go about implementing that? I've tried replacing the entire thing with just
Code:
float flDamageBonus = TF2Attrib_HookValueFloat(1.0, "mult_dmg", attacker);
	damage*= flDamageBonus;
after the initial if statement that assigns the fireball to do something if it is in fact a fireball but still haven't gotten anything to happen.
I know I'm most likely overcomplicating this or just am not doing this correctly.
Recluse is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 12-20-2021 , 20:17   Re: Increasing Spell Dmg via another attribute
Reply With Quote #4

Here's what I use to increase spell damage caused by the Jedi Knight in my 'Be the Jedi Knight' plugin. It adjusts damage by the person inflicting the damage and damage type.

You can debug to find the right damage type for fireball. If I remember right lightning spell is damage type '8' and fireball is '64' but I could be wrong.

Link to Valve damage types. Note that spell damage may be a combination of damage types: https://developer.valvesoftware.com/wiki/Damage_types

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3], damagecustom)
{
    if( !
IsValidClient(victim) || !IsValidClient(attacker) || !g_bIsJedi[attacker] || g_bIsJedi[attacker] == g_bIsJedi[victim] )
    return 
Plugin_Continue;

    if(
g_bIsJedi[attacker] && damagetype == 8)
    {
        
damage damage 15;
    }
    if(
g_bIsJedi[attacker] && damagetype == 64 )
    {
        
damage damage 15;    
    }
    
    
//next line is for debugging
    //    PrintToChat(attacker, "Weapon: %d, Damage type: %d",weapon, damagetype);
    
return Plugin_Changed;


Last edited by PC Gamer; 12-20-2021 at 20:39.
PC Gamer is offline
Recluse
Junior Member
Join Date: Jul 2021
Location: Braap
Old 12-23-2021 , 12:08   Re: Increasing Spell Dmg via another attribute
Reply With Quote #5

I finally got it working, turns out I needed to actually get the weapon slot for the entire thing to work.

Here's the code
Code:
new primary=GetPlayerWeaponSlot(attacker,0);
	if(IsValidEntity(primary))
	{
		new Address:FireballMult=TF2Attrib_GetByName(primary,"damage bonus");
		new Address:FireballMult1=TF2Attrib_GetByName(primary,"damage penalty");
		new Address:FireballMult2=TF2Attrib_GetByName(primary,"Blast radius increased");
		new Address:FireballMult3=TF2Attrib_GetByName(primary,"mod rage damage boost");
		new Address:FireballMult4=TF2Attrib_GetByName(primary,"dmg falloff increased");
		if(FireballMult!=Address_Null)
		{
			damage*=Pow(TF2Attrib_GetValue(FireballMult),0.50);
		}
		if(FireballMult1!=Address_Null)
		{
			damage*=Pow(TF2Attrib_GetValue(FireballMult1),0.77);
		}
		if(FireballMult2!=Address_Null)
		{
			damage*=Pow(TF2Attrib_GetValue(FireballMult2),0.60);
		}
		if(FireballMult3!=Address_Null)
		{
			damage*=Pow(TF2Attrib_GetValue(FireballMult3),0.80);
		}
		if(FireballMult4!=Address_Null)
		{
			damage*=Pow(TF2Attrib_GetValue(FireballMult4),0.66);
		}
	}
Best part is is that it's infinitely expandable so I could use this for other spells aswell
Recluse 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 05:28.


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