- Joined
- Mar 24, 2011
- Messages
- 1,082
Hello hivers
I took a request about making a spell and started it in GUI... somehow it turned into my first ever attempt at JASS...
So I am done with teh spell but before I give it to the requester (is that a word ?) I would like to get some criticizm from JASS experienced people so... here is teh spell and atached you will find a test map.
Some parts of the spell are converted GUI so I do remember reading about some BJ which are better to be avoided and is better to use the native... and yea...
I took a request about making a spell and started it in GUI... somehow it turned into my first ever attempt at JASS...
So I am done with teh spell but before I give it to the requester (is that a word ?) I would like to get some criticizm from JASS experienced people so... here is teh spell and atached you will find a test map.
Some parts of the spell are converted GUI so I do remember reading about some BJ which are better to be avoided and is better to use the native... and yea...
JASS:
function ManaVamp takes integer MLevel returns nothing
local real Percentage
local real ReturnMana
local real TargetMana
set Percentage = ( udg_MVA_Base + ( udg_MVA_PerLevel * I2R(MLevel) ) )
set ReturnMana = ( Percentage * udg_PDD_amount )
set TargetMana = GetUnitStateSwap(UNIT_STATE_MANA, udg_PDD_target)
if ( TargetMana < ReturnMana ) then
set ReturnMana = TargetMana
endif
call SetUnitManaBJ( udg_PDD_source, ((GetUnitStateSwap(UNIT_STATE_MANA, udg_PDD_source)) + ReturnMana) )
call SetUnitManaBJ( udg_PDD_target, ((GetUnitStateSwap(UNIT_STATE_MANA, udg_PDD_target)) - ReturnMana) )
endfunction
function CheckSource takes nothing returns boolean
if ( GetUnitAbilityLevelSwapped(udg_MVA_Ability, GetFilterUnit()) > 0 ) then
if ( IsUnitAlly(GetFilterUnit(), GetOwningPlayer(udg_PDD_source)) == true ) then
return true
endif
else
return false
endif
endfunction
function CheckForAbility takes nothing returns boolean
return ( GetUnitAbilityLevelSwapped(udg_MVA_Ability, GetFilterUnit()) > 0 )
endfunction
function GetMaxLevel takes nothing returns integer
local integer array LevelMax
local integer LoopInt
local unit AuraSource
local group SourceGroup
local location TempPoint
local integer NumUnits
local integer MaxLevel
set TempPoint = GetUnitLoc(udg_PDD_source)
set SourceGroup = GetUnitsInRangeOfLocMatching(udg_MVA_Range, TempPoint, Condition(function CheckSource))
call RemoveLocation(TempPoint)
set NumUnits = CountUnitsInGroup(SourceGroup)
call DisplayTextToForce( GetPlayersAll(), I2S(NumUnits) )
if ((NumUnits > 0)==true)then
set LoopInt = 0
loop
exitwhen LoopInt > NumUnits
set AuraSource = GroupPickRandomUnit(SourceGroup)
set LevelMax[LoopInt] = GetUnitAbilityLevelSwapped(udg_MVA_Ability, AuraSource)
call GroupRemoveUnitSimple( AuraSource, udg_TempUnitGroup )
if (LoopInt == 0) then
set MaxLevel = LevelMax[LoopInt]
else
set MaxLevel = IMaxBJ(MaxLevel,LevelMax[LoopInt])
endif
set LoopInt = LoopInt + 1
endloop
endif
call DestroyGroup(SourceGroup)
return MaxLevel
endfunction
function Trig_SVADetection_Func001C takes nothing returns boolean
if ( udg_PDD_damageType != udg_PDD_PHYSICAL ) then
return false
endif
if ( UnitHasBuffBJ(udg_PDD_source, udg_MVA_Buff) != true ) then
return false
endif
return true
endfunction
function Trig_SVADetection_Actions takes nothing returns nothing
if ( Trig_SVADetection_Func001C() ) then
set udg_TempInt = GetMaxLevel()
call ManaVamp(udg_TempInt)
else
endif
endfunction
//===========================================================================
function InitTrig_SVAActivation takes nothing returns nothing
set gg_trg_SVAActivation = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_SVAActivation, "udg_PDD_damageEventTrigger", EQUAL, 1.00 )
call TriggerAddAction( gg_trg_SVAActivation, function Trig_SVADetection_Actions )
endfunction