Dealing Damage Based On Range

Crazy_Dead

New Member
Reaction score
24
._.

._.

Thanks.

After been working with the f*c*i*g dummy for 1.5 hours.. ._.

Sine, i love that smiley. Displays my face perfectly now..
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
What's all this nonsense about custom projectile systems?

Just make a spell based on Cold Arrows, use damage detection for an event when a unit takes damage, check whether it has the buff from your Cold Arrows spell, remove the buff and deal damage based on the distance between the damage source and triggering unit.

Note, this will also count distance that the attacker moved during projectile flight, not just the path of the projectile, but I believe this is also true for DotA's Impetus.
 

Bribe

vJass errors are legion
Reaction score
67
However J4L's system works, you still have to import that library. I stopped trusting his libraries when Benchmark returns different results depending on what day of the week it is.
 

Crazy_Dead

New Member
Reaction score
24
What's all this nonsense about custom projectile systems?

Just make a spell based on Cold Arrows, use damage detection for an event when a unit takes damage, check whether it has the buff from your Cold Arrows spell, remove the buff and deal damage based on the distance between the damage source and triggering unit.

Note, this will also count distance that the attacker moved during projectile flight, not just the path of the projectile, but I believe this is also true for DotA's Impetus.

The link you gave me for the JASS "snippet", how would i use that as damage?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Here you go :
JASS:
library Impetus requires Damage, T32

    globals
        private constant integer BUFF_ID = 'B000'
        private constant integer DUMMY_ID = 'u000'
        private constant player DUMMY_OWNER = Player(15)
        private constant string MISSLE_MODEL = "abilities\\weapons\\WyvernSpear\\WyvernSpearMissile.mdl"
        private constant real MISSLE_SPEED = 1000. //Range per second.
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
        private constant string ON_COLLIDE_EFFECT = "Abilities\\Spells\\NightElf\\ThornsAura\\ThornsAuraDamage.mdl"
    endglobals
    
    private function DamagePercent takes integer lv returns real
        return 30. + (5. * lv)
    endfunction
    
    private struct Data
        unit cs
        effect eff
        unit target
        unit dummy
        real percent
        real speed
        real x
        real y
        
        private method periodic takes nothing returns nothing
            local real cx = GetUnitX(.cs)
            local real cy = GetUnitY(.cs)
            
            local real tx = GetUnitX(.target)
            local real ty = GetUnitY(.target)
            
            local real dx = tx - cx
            local real dy = ty - cy
            
            local real angle
            
            if not IsUnitInRangeXY(.dummy,tx,ty,32.) then
            
                set angle = Atan2(dy,dx)
                set .x = .x + .speed * Cos(angle)
                set .y = .y + .speed * Sin(angle)
                
                call SetUnitX(.dummy,.x)
                call SetUnitY(.dummy,.y)
                
            else
    
                if UnitDamageTargetEx(.cs,.target,SquareRoot(dx * dx + dy * dy) * .percent ,false,false,ATTACK_TYPE,DAMAGE_TYPE,null) then
                    call DestroyEffect(AddSpecialEffectTarget(ON_COLLIDE_EFFECT,.target,"overhead"))
                endif
                
                call DestroyEffect(.eff)
                call RemoveUnit(.dummy)
                call .stopPeriodic()
                call .destroy()
                
            endif
        endmethod
        
        implement T32x
        
        private static method act takes nothing returns nothing
            local thistype this = .allocate()
            local real cx
            local real cy
            local real tx
            local real ty
            local real dx
            local real dy
            
            set .cs = GetEventDamageSource()
            set .target = GetTriggerUnit()
            set .percent = DamagePercent(GetUnitAbilityLevel(.target,BUFF_ID)) * .01
            
            set cx = GetUnitX(.cs)
            set cy = GetUnitY(.cs)
            
            set tx = GetUnitX(.target)
            set ty = GetUnitY(.target)
            
            set dx = tx - cx
            set dy = ty - cy
            
            set .dummy = CreateUnit(DUMMY_OWNER,DUMMY_ID,cx,cy,Atan2(dy,dx) * bj_RADTODEG)
            set .eff = AddSpecialEffectTarget(MISSLE_MODEL,.dummy,"origin")
            
            set .speed = MISSLE_SPEED * T32_PERIOD
            set .x = cx
            set .y = cy
            
            call UnitRemoveAbility(.target,BUFF_ID)
            
            call .startPeriodic()
        endmethod
        
        private static method cond takes nothing returns boolean
            if Damage_IsAttack() and GetUnitAbilityLevel(GetTriggerUnit(),BUFF_ID) > 0 then
                call act()
            endif
            return false
        endmethod
        
        private static method onInit takes nothing returns nothing
            local trigger trig = CreateTrigger()
            call Damage_RegisterEvent(trig)
            call TriggerAddCondition(trig,Condition(function thistype.cond))
        endmethod
    endstruct
    
endlibrary
 

Crazy_Dead

New Member
Reaction score
24
Thanks Kinking. Will see if i can give rep to you and Weep.

Thanks! :thup:

EDIT:
EDITEDIT:

The buff, should it be on the target or not?
 

Crazy_Dead

New Member
Reaction score
24
Geez, Laiev, sorry for explaining bad.

Which buff should i choose?

The Info Buff,
The Stacking Buff,
The Non-Stacking Buff?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
In the ability, just make them all the same buff. Then, there's only one possibility. :D
 

Laiev

Hey Listen!!
Reaction score
188
Geez, Laiev, sorry for explaining bad.

Which buff should i choose?

The Info Buff,
The Stacking Buff,
The Non-Stacking Buff?

In the ability, just make them all the same buff. Then, there's only one possibility. :D
/\
:p

put the same buff (example: B000) in all the choice, so it will be... B000, B000, B000

in trigger B000 :rolleyes:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top