• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Advanced Building

Status
Not open for further replies.
Level 13
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?


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:
Level 6
Joined
Aug 27, 2008
Messages
210
For future reference, you should put JASS code in CODE tags. I would prefer to look at the object editor on this map to confirm, but it looks as if there are two different builder units for each race (those are the first four globals), which look identical ingame. One builds standard buildings, and the other builds advanced buildings. I'm guessing the actual build icon has been removed, and in its place have been created two "build" abilities for each race, standard and advanced, which are the last four globals.

If you remove the normal build icon (either in the Game Interface window or by replacing the icon with nothing) and create the four abilities and four units, you should be able to just put their IDs into the globals and it will work.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
EDIT: how do i add code tags?

[code=jass]paste it here[/code]

will look like this

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
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I had another look through these triggers, it's really quite simple: when you use an ability (advanced buildings ability), the worker is replaced with another worker unit that has advanced buildings in its build menu, and that unit is ordered to open up its build menu.

All you have to do is set these:
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

Open up your unit editor, and hit ctrl-d to see the IDs of the units and abilities, and set them here.
 
Status
Not open for further replies.
Top