• 🏆 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!

WC2: 2ndGen Script

Status
Not open for further replies.
Level 1
Joined
Sep 7, 2010
Messages
3
Hi, i need help with this script (Warcraft 2: 2nd Generation -Strategy Master)
Because the Mod is not be worked on any more and i want to play it in Lan, without this bug:

When Player1 open the "Build Structure"-Button, the construction-menu is also open for allied Player 2.

Does anyone have a solution for this or a better script ?

JASS:
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, spg_UNITGRPAdvancedBuildCommand )
    endif
    call IssueImmediateOrderBJ(new_builder, "build")
    set new_builder=null
    set p=null

endfunction

function Trgs_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 Trgs_Worker_Advanced_Build_Actions takes nothing returns nothing
    call Advanced_Build(GetSpellAbilityUnit() , GetSpellAbilityId())
endfunction

//===========================================================================
function InitTrgs_Worker_Advanced_Build takes nothing returns nothing
    set trg_Worker_Advanced_Build=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trg_Worker_Advanced_Build, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(trg_Worker_Advanced_Build, Condition(function Trgs_Worker_Advanced_Build_Conditions))
    call TriggerAddAction(trg_Worker_Advanced_Build, function Trgs_Worker_Advanced_Build_Actions)
endfunction
 
Status
Not open for further replies.
Top