Author Topic: Probably a very simple question....  (Read 453 times)

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Probably a very simple question....
« on: December 16, 2015, 09:02:08 PM »
Hi guys,

I'm looking to modify a damage, but only if the damage type is a specific type...

Code: [Select]
public OnW3TakeDmgAllPre(victim,attacker,Float:damage)
{
if (W3GetDamageType() & DMG_CRUSH)
{
War3_DamageModPercent(2.0)
}
}

So, this will effectively double my damage if the damage type is DMG_CRUSH...
What I'd like to do, is double my damage for any type EXCEPT for crush....
How would i do this?

Or, in terms of the actual output i'm after...
If attack someone with a knife, then do double damage.  But if i deal damage by any other means, then don't change it all.

I've tried using:
Code: [Select]
new String:weapon[32];
GetClientWeapon(attacker,weapon,32);
if(StrEqual(weapon,"weapon_knife"))

However this only looks at what weapon that im actually holding - so in the event where i use a spell (think Chain Lightning for instance), it still sees me as holding a knife, so it doubles the damage...  Although in this instance, i don't want it to double the damage unless i physically slash them with my knife....

What's the easiest way to do this please?

Cheers :)


Revan

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Probably a very simple question....
« Reply #1 on: December 17, 2015, 06:28:58 AM »
so in the event where i use a spell (think Chain Lightning for instance), it still sees me as holding a knife, so it doubles the damage...  Although in this instance, i don't want it to double the damage unless i physically slash them with my knife....
You can control whether or not War3_DealDamage(which is used by Chain Lightning) should trigger any W3S damage hooks(like OnW3TakeDMgAllPre), by default it does not.

native bool:War3_DealDamage(victim,damage,attacker=0,damage_type=DMG_GENERIC|DMG_PREVENT_PHYSICS_FORCE,String:weaponNameStr[], War3DamageOrigin:W3DMGORIGIN=W3DMGORIGIN_UNDEFINED , War3DamageType:W3DMGTYPE=W3DMGTYPE_MAGIC , bool:respectVictimImmunity=true , bool:countAsFirstDamageRetriggered=false, bool:noWarning=false)

You can also use something like this so you support different games(not just CS:S):
Code: [Select]
new wpnent = W3GetCurrentWeaponEnt(attacker);
if(War3_IsMeleeWeapon(wpnent)){
  // knife damage
}
« Last Edit: December 17, 2015, 06:54:27 AM by Revan »
#war3source on gamesurge

abgar

  • Full Member
  • ***
  • Posts: 114
    • View Profile
Re: Probably a very simple question....
« Reply #2 on: December 22, 2015, 12:53:50 AM »
Awesome - thanks Revan :)