• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Trigger for damaging unit arbitrary amount

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

I'd like to make some spells that base their damage on other values (e.g. hero's strength, etc.). I looked into the way the old developer of the map did it (his ability was based on the hero's level, i.e. higher level = more damage), but it seems completely counter intuitive and almost ridiculous, but perhaps this is the norm for JASS.

Here is the trigger:

JASS:
globals
    constant integer DMY_ATTACK_MELEE = 'A03A'
    constant integer DMY_ATTACK_RANGED = 'A03B'
    constant integer DMY_ATTACK_ID = 'A03D'

    private unit caster
    private player owner
    private integer pid
    private integer sid
    private real x
    private real y
endglobals

private function main takes nothing returns boolean
    //Var Init
    set sid = GetSpellAbilityId()
    if sid == DMY_ATTACK_MELEE or sid == DMY_ATTACK_RANGED then
        //Var Setting
        set caster = GetTriggerUnit()
        set owner = GetOwningPlayer(caster)
        set pid = GetPlayerId(owner)
        set x = GetUnitX(caster)
        set y = GetUnitY(caster)

        //Main Action
        call SetUnitPosition(pDMY[pid], x, y)
        if sid == DMY_ATTACK_MELEE then
            call SetUnitAbilityLevel(pDMY[pid], DMY_ATTACK_ID, GetUnitLevel(caster))
        else
            call SetUnitAbilityLevel(pDMY[pid], DMY_ATTACK_ID, GetUnitLevel(caster) + 30)
        endif
        call IssueTargetOrder(pDMY[pid], "thunderbolt", GetSpellTargetUnit())

        //Clear
        set caster = null
        set owner = null
    endif

    //Return
    return false
endfunction

Now from my understanding, each player has some dummy unit which constantly follows them, but is completely undetectable. When a hero uses this ability, it actually forces the dummy to use the correct leveled version of stormbolt / thunderbolt which does the damage (he has about 60 levels of it for all possible cases).

Now this works, but I don't suppose there's a better way to do this? Obviously there is no general
JASS:
 native damageUnit
otherwise this would have been used, right? So is there a way to simply apply a buff/ability to the targeted unit, which then does the additional damage? Or am I going to need a non-intuitive dummy caster?
 
There is this.
JASS:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
or this
JASS:
native UnitDamagePoint takes unit whichUnit, real delay, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
There is this.
JASS:
native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
or this
JASS:
native UnitDamagePoint takes unit whichUnit, real delay, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

So how exactly do these natives work? They take a lot of parameters--ideally I'd just want to feed it the unit handle and then a real value representing the amount of damage.

Also, why would the developer not opt for something like that? But I guess do these damages get reduced by a unit's armor?
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Yes the different weapon types and damage types do different things.

Normally this is used for spells.

JASS:
call UnitDamageTarget( caster, target, amount, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)

change caster / target / amount to values you want.

Ah so it WILL take the target's armor value into account with respect to the damage. That's actually useful, though what is the work around if you want to ignore the unit's armor value?
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
ATTACK_TYPE_CHAOS is normally your answer to ignoring the values as chaos is preset to do 100 percent damage to the units they damage. Effectively ignoring armour.

You can however change these values in the gameplay constants or by use of a DDS. They can mess with ignoring values.

I thought Chaos damage just ignored the armor type (100% versus all armor types), but not the armor value?
 
Level 7
Joined
Mar 6, 2006
Messages
282
UnitDamagePoint is bugged and shouldn't be used, just use UnitDamageTarget and loop through the units.

These are the two common ways of doing it.

Reduced by armor:

call UnitDamageTarget( caster, target, realdamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)

Ignores armor:

call UnitDamageTarget( caster, target, realdamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)

Depending on the type of spell, you may want to consider spell immune targets and/or ethereal.

Here is the full details on damage and attack types. (condensed table at the bottom)

http://www.wc3c.net/showpost.php?p=1030046&postcount=19
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
UnitDamagePoint is bugged and shouldn't be used, just use UnitDamageTarget and loop through the units.

These are the two common ways of doing it.

Reduced by armor:

call UnitDamageTarget( caster, target, realdamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)

Ignores armor:

call UnitDamageTarget( caster, target, realdamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)

Depending on the type of spell, you may want to consider spell immune targets and/or ethereal.

Here is the full details on damage and attack types. (condensed table at the bottom)

http://www.wc3c.net/showpost.php?p=1030046&postcount=19

JASS:
Reduced by armor:

[icode=jass]call UnitDamageTarget( caster, target, realdamage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)

This typically shouldn't be used for spell damage because it will get reduced by armor types... I'd recommend spell damage so that it will be reduced by hero armor like normal spells and will be detectable as spell damage from damage engines
 
Status
Not open for further replies.
Top