- Joined
- Jul 26, 2008
- Messages
- 1,009
Hi, T4co Bell created a skill for me to damage an enemy and steal the life of the damage unit. He then told me how it worked and I decided to convert it to JASS and try it out. It works, but how can I make it better? And also make it MUI or at least MPI.
I'm getting better at vJASS as well, thanks to the tutorials and nudge in the right direction from users
Thanks. But I didn't really know how to apply the vJASS when a lot of the code is calling Triggers.
Also neither the texttags nor graphics will show.
Anyways, here is the code:
I'm getting better at vJASS as well, thanks to the tutorials and nudge in the right direction from users
Also neither the texttags nor graphics will show.
Anyways, here is the code:
JASS:
scope Rend initializer Init
globals
private unit array LearningHero
private unit array AcquiredUnit
private constant integer SPELLID = 'rend'
endglobals
private function ThirdActions takes nothing returns nothing
local integer i = GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
local texttag tag = CreateTextTag()
call SetTextTagText(tag, R2S(GetEventDamage()), 0)
call SetTextTagPosUnit(tag, AcquiredUnit[i], 0)
call SetTextTagColor(tag, 255,0,0,255)
call SetTextTagVelocity(tag, 64, 90)
call SetTextTagLifespan(tag, 2.0)
call SetWidgetLife(LearningHero[i], GetWidgetLife(LearningHero[i]) + (GetEventDamage() * (0.25+0.25*GetUnitAbilityLevel(LearningHero[i], SPELLID))) )
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", LearningHero[i], "origin"))
endfunction
private function ThirdConditions takes nothing returns boolean
local integer i = GetRandomInt(1,10)
local integer p = GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
return GetEventDamageSource() == LearningHero// and i == 10
endfunction
private function SecondActions takes nothing returns nothing
local trigger t = CreateTrigger()
set AcquiredUnit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = GetEventTargetUnit()
call TriggerRegisterUnitEvent( t, AcquiredUnit[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))], EVENT_UNIT_DAMAGED )
call TriggerAddCondition(t, function ThirdConditions)
call TriggerAddAction(t, function ThirdActions)
endfunction
private function Trig_Meow_1_Conditions takes nothing returns boolean
return GetLearnedSkill() == SPELLID
endfunction
private function FirstActions takes nothing returns nothing
local trigger t
local unit L = GetLearningUnit()
call DisableTrigger(GetTriggeringTrigger())
set LearningHero[GetPlayerId(GetOwningPlayer(L))] = L
set t = CreateTrigger()
call TriggerRegisterUnitEvent( t, LearningHero[GetPlayerId(GetOwningPlayer(L))], EVENT_UNIT_ACQUIRED_TARGET )
call TriggerAddAction(t, function SecondActions)
set L = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( t, Condition( function Trig_Meow_1_Conditions ) )
call TriggerAddAction( t, function FirstActions )
endfunction
private function InitTrig_Rend takes nothing returns nothing
endfunction
endscope