- Joined
- Jul 2, 2008
- Messages
- 1,182
I need an advanced building system similar to wc2, bw or sc2.
Strategy Master from the old WC2 remake project told me i can use his triggers, but iam too stupid to implement it into my mod.
Can someone help me?
Strategy Master from the old WC2 remake project told me i can use his triggers, but iam too stupid to implement it into my mod.
Can someone help me?
JASS:
globals
constant integer cgm_ADVPEASANT = 'h002'
constant integer cgm_ADVPEON = 'o003'
constant integer cgm_PEASANT = 'h006'
constant integer cgm_PEON = 'o008'
constant integer cgm_HADVBUILD = 'A00K'
constant integer cgm_OADVBUILD = 'A00X'
constant integer cgm_OSTDBUILD = 'A01Q'
constant integer cgm_HSTDBUILD = 'A01D'
endglobals
function Advanced_Build takes unit caster, integer buildtype returns nothing
local integer new_builder_id = 0
local unit new_builder = null
local player p = GetOwningPlayer(caster)
if buildtype == cgm_HADVBUILD then
set new_builder_id = cgm_ADVPEASANT
elseif buildtype == cgm_OADVBUILD then
set new_builder_id = cgm_ADVPEON
elseif buildtype == cgm_HSTDBUILD then
set new_builder_id = cgm_PEASANT
else
set new_builder_id = cgm_PEON
endif
if GetUnitTypeId(caster) != new_builder_id then
set new_builder = ReplaceWorkerWJ( caster, new_builder_id )
call SelectUnitAddForPlayer( new_builder, p )
else
set new_builder = caster
//call TriggerSleepAction( 0.10 )
// call GroupAddUnitSimple( new_builder, udg_UNITGRPAdvancedBuildCommand )
endif
call IssueImmediateOrderBJ( new_builder, "build" )
set new_builder = null
set p = null
endfunction
function Trig_Worker_Advanced_Build_Conditions takes nothing returns boolean
return GetSpellAbilityId() == cgm_HADVBUILD or GetSpellAbilityId() == cgm_OADVBUILD or GetSpellAbilityId() == cgm_HSTDBUILD or GetSpellAbilityId() == cgm_OSTDBUILD
endfunction
function Trig_Worker_Advanced_Build_Actions takes nothing returns nothing
call Advanced_Build( GetSpellAbilityUnit(), GetSpellAbilityId() )
endfunction
//===========================================================================
function InitTrig_Worker_Advanced_Build takes nothing returns nothing
set gg_trg_Worker_Advanced_Build = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Worker_Advanced_Build, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Worker_Advanced_Build, Condition( function Trig_Worker_Advanced_Build_Conditions ) )
call TriggerAddAction( gg_trg_Worker_Advanced_Build, function Trig_Worker_Advanced_Build_Actions )
endfunction
Last edited: