MasterRofl
New Member
- Reaction score
- 8
Hey there. I just started learning JASS yesterday evening, and spent roughly 6 hours trying to duplicate a stifling dagger. However, I failed pretty hard. :thdown:
My attempt (warning your head will explode):
So now, I'd like to see how it's done by somebody more experienced. It would be good if it was in vJASS.
Thanks!
My attempt (warning your head will explode):
JASS:
scope ThrowKnife
function Actions takes nothing returns nothing
globals
unit TargetUnit = GetSpellTargetUnit()
unit Caster = GetTriggerUnit()
location CasterLocation = GetUnitLoc( GetTriggerUnit() )
integer SlowLevel = GetUnitAbilityLevelSwapped( 039;A01U039;, Caster )
endglobals
CreateUnitAtLoc( GetOwningPlayer( Caster ), 039;n00N039;, CasterLocation, 0.00 )
globals
unit Knife = GetLastCreatedUnit()
endglobals
call EnableTrigger( KnifeMovement )
endfunction
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A01U039;
endfunction
public function InitTrig takes nothing returns nothing
local trigger ThrowKnife = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( ThrowKnife, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( ThrowKnife, Condition( function Conditions ) )
call TriggerAddAction( ThrowKnife, function Actions )
endfunction
endscope
JASS:
scope KnifeMovement
private function Actions takes nothing returns nothing
local location TargetLocation = GetUnitLoc( TargetUnit )
local location KnifeLocation = GetUnitLoc( Knife )
SetUnitPositionLocFacingLocBJ( Knife, PolarProjectionBJ( KnifeLocation, 36, AngleBetweenPoints( KnifeLocation, TargetLocation ) ), TargetLocation )
if ( DistanceBetweenPoints( KnifeLocation, TargetLocation ) < 36 ) then
call SetUnitAbilityLevel( Knife, 039;A026039;, SlowLevel )
call IssueTargetOrder( Knife, "slow", TargetUnit )
call KillUnit( Knife )
call UnitDamageTargetBJ( Caster, TargetUnit, 300, ATTACK_TYPE_HERO, DAMAGE_TYPE_FIRE )
call DisableTrigger( KnifeMovement )
endif
endfunction
//===========================================================================
function InitTrig takes nothing returns nothing
globals
trigger KnifeMovement = CreateTrigger()
endglobals
call DisableTrigger( KnifeMovement )
call TriggerRegisterTimerEventPeriodic( KnifeMovement, 0.03 )
call TriggerAddAction( KnifeMovement, function Actions )
endfunction
endscope
So now, I'd like to see how it's done by somebody more experienced. It would be good if it was in vJASS.
Thanks!