Zackreaver
New Member
- Reaction score
- 2
Hello everyone, I just got the hang of making a trigger entirely with jass, and I made a trigger that works perfectly, no flaws what so ever.
But, I'm still new to using jass, so I want to make a quick check, is there anything wrong or rather is there anything I could do better in the following pieces of code?
What the code does, is it check's to see if theres a "Volcano Guard" in a Volcano when the ability eruption is used, if there isnt, it stops the spell, gives an error message, and gives back the mana. If there is a volcano guard garrisoned, it gets removed, and the Eruption spell, made from inferno, launches the volcano guard where the spell was cast.
I'm still catching on to alot of this, so I'm not sure if anything im doing in there is either inefficient/slower/difficult than what I could be doing.
Thank you
ps. also HiveWorkshop is down so I cant get that program JassCraft, which I hear would be really helpful >.<, anyone know any external links for that program?
But, I'm still new to using jass, so I want to make a quick check, is there anything wrong or rather is there anything I could do better in the following pieces of code?
Code:
function Trig_Volcano_Occupy_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'h005' ) ) then
return false
endif
if ( not ( GetUnitTypeId(GetTransportUnitBJ()) == 'h007' ) ) then
return false
endif
return true
endfunction
function Trig_Volcano_Occupy_Actions takes nothing returns nothing
local unit vguard = GetTriggerUnit()
local unit volcano = GetTransportUnitBJ()
local integer count = udg_VolcanoGuardCounter
local group vgroup = udg_VolcanoGuardLaunchGroup
call SetUnitUserData(vguard, count)
call SetUnitUserData(volcano, count)
call GroupAddUnitSimple(vguard, vgroup)
set udg_VolcanoGuardCounter = udg_VolcanoGuardCounter + 1
set vguard = null
set volcano = null
endfunction
//===========================================================================
function InitTrig_Volcano_Occupy takes nothing returns nothing
set gg_trg_Volcano_Occupy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Volcano_Occupy, EVENT_PLAYER_UNIT_LOADED )
call TriggerAddCondition( gg_trg_Volcano_Occupy, Condition( function Trig_Volcano_Occupy_Conditions ) )
call TriggerAddAction( gg_trg_Volcano_Occupy, function Trig_Volcano_Occupy_Actions )
endfunction
Code:
function Trig_Volcano_Guard_Launch_2_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A005' ) ) then
return false
endif
return true
endfunction
function Trig_Volcano_Guard_Launch_2_Func001C takes nothing returns boolean
return true
endfunction
function VolcanoGuardGroup takes nothing returns nothing
local unit pickedguard
local unit volcano = GetTriggerUnit()
set pickedguard = GetEnumUnit()
if (GetUnitUserData(volcano) == GetUnitUserData(pickedguard)) then
set udg_TempUnit = pickedguard
else
endif
set pickedguard = null
set volcano = null
endfunction
function Trig_Volcano_Guard_Launch_2_Actions takes nothing returns nothing
local group vgroup = udg_VolcanoGuardLaunchGroup
local unit volcano = GetTriggerUnit()
set udg_TempUnit = null
if ( Trig_Volcano_Guard_Launch_2_Func001C() ) then
call ForGroupBJ( vgroup, function VolcanoGuardGroup )
if ( IsUnitInTransportBJ(udg_TempUnit, volcano) == true ) then
if (not (udg_TempUnit == null)) then
call RemoveUnit(udg_TempUnit)
call DisplayTextToForce( GetPlayersAll(), ( GetPlayerName(GetTriggerPlayer()) + " is launching a Volcano Guard." ) )
call PlaySoundBJ( gg_snd_GoodJob )
else
call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), "TRIGSTR_1268" )
call PolledWait( 0.01 )
call SetUnitManaBJ( GetTriggerUnit(), 100.00 )
endif
else
call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), "TRIGSTR_1268" )
call PolledWait( 0.01 )
call SetUnitManaBJ( GetTriggerUnit(), 100.00 )
endif
else
endif
set udg_TempUnit = null
endfunction
//===========================================================================
function InitTrig_Volcano_Guard_Launch_2 takes nothing returns nothing
set gg_trg_Volcano_Guard_Launch_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Volcano_Guard_Launch_2, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Volcano_Guard_Launch_2, Condition( function Trig_Volcano_Guard_Launch_2_Conditions ) )
call TriggerAddAction( gg_trg_Volcano_Guard_Launch_2, function Trig_Volcano_Guard_Launch_2_Actions )
endfunction
What the code does, is it check's to see if theres a "Volcano Guard" in a Volcano when the ability eruption is used, if there isnt, it stops the spell, gives an error message, and gives back the mana. If there is a volcano guard garrisoned, it gets removed, and the Eruption spell, made from inferno, launches the volcano guard where the spell was cast.
I'm still catching on to alot of this, so I'm not sure if anything im doing in there is either inefficient/slower/difficult than what I could be doing.
Thank you
ps. also HiveWorkshop is down so I cant get that program JassCraft, which I hear would be really helpful >.<, anyone know any external links for that program?