• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] cancelconstruction thingy

Status
Not open for further replies.
Level 1
Joined
Jan 24, 2008
Messages
5
I have a trigger that when a unit starts construction of a windmill that it must just keep constructing it and deduct some values from variables but if they variable values arent high enough it should cancel the construction and remove the structure. Ingame, (the variables are high enough and it deducts them(i see that in multiboard) but when it starts building the unit dissapears its unselectable or anything but i put the builder in a unit groupt with ctrl+1 but if i select it it looks like its still constructing but in an inexisting building. Someone please help me, this is my trigger:

JASS:
function Trig_windmill_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetConstructingStructure()) == 'h002'
endfunction
function Trig_windmill_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetConstructingStructure())) + 1
    if udg_lumber[i] >= 60 and udg_stone[i] >= 40 and udg_iron[i] >= 30 and udg_clay[i] >= 20 and udg_food[i] >= 0 then
        set udg_lumber[i] = udg_lumber[i] - 60
        set udg_stone[i] = udg_stone[i] - 40
        set udg_iron[i] = udg_iron[i] - 30
        set udg_clay[i] = udg_clay[i] - 20
        set udg_food[i] = udg_food[i] - 0
    else
        call TriggerSleepAction(0)
        call KillUnit(GetConstructingStructure())
    endif
endfunction

//===========================================================================
function InitTrig_windmill takes nothing returns nothing
    set gg_trg_windmill = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_windmill, Condition( function Trig_windmill_Conditions))
    call TriggerAddAction( gg_trg_windmill, function Trig_windmill_Actions )
endfunction

Its converted GUI since it's for my roc map and I had to convert it to jass, so I know its weird coding like if (not (.... but that's not the problem.

Edit: Still a problem look my other post but updated tirgger
Thanks in advance!
 
Last edited:
Level 11
Joined
Feb 18, 2004
Messages
394
First of all...
JASS:
function Trig_windmill_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetConstructingStructure()) == 'h002'
endfunction

function Trig_windmill_Actions takes nothing returns nothing
    local integer i = GetPlayerId(GetOwningPlayer(GetConstructingStructure())) + 1
    if udg_lumber[i] >= 60 and udg_stone[i] >= 40 and udg_iron[i] >= 30 and udg_clay[i] >= 20 and udg_food[i] >= 0 then
        set udg_lumber[i] = udg_lumber[i] - 60
        set udg_stone[i] = udg_stone[i] - 40
        set udg_iron[i] = udg_iron[i] - 30
        set udg_clay[i] = udg_clay[i] - 20
        set udg_food[i] = udg_food[i] - 0
    else
        call RemoveUnit(GetConstructingStructure())
    endif
endfunction

//===========================================================================
function InitTrig_windmill takes nothing returns nothing
    set gg_trg_windmill = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_windmill, EVENT_PLAYER_UNIT_CONSTRUCT_START)
    call TriggerAddCondition(gg_trg_windmill, Condition(function Trig_windmill_Conditions))
    call TriggerAddAction(gg_trg_windmill, function Trig_windmill_Actions)
endfunction

Second of all... ... What exactly is your problem? From your post, I can only guess what problem you are describing...
im guessing your problem is that unit is an orc-type builder, and removing the structure its building is causes it to get stuck in limbo... in which case,
JASS:
    else
        call TriggerSleepAction(0)
        call KillUnit(GetConstructingStructure())
    endif
 
Level 1
Joined
Jan 24, 2008
Messages
5
Thanks for helping me and making my trigger a hell of alot shorter I'll try to explain what I want since there's a new problem now. When the player wants to build a windmill and he has enough "resources" (the variables are displayed in a multiboard so he knows when he has enough) when he has enough it does nothing he just builds it however when he doesnt got enough "resources" (for example: it needs 60 lumber but udg_lumber is only 50) it should kill the constructing building, so that it looks like they can only build buildings where they got enough "resources" for.

I edited my trigger the way you suggested and now the building doesnt disappear toghetter with the builder miracily but It does not substract the values from the "resources" even though it's in the trigger wich i dont get:S And when the player does not have enough "resources" it still builds the building like nothing has happened.
 
Status
Not open for further replies.
Top