• 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.

Removing Purchasable Units from Nuetral Buildings

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Hi, I was wondering how I could use a trigger to make a unit no longer purchasable at night from a nuetral building that sells them.

I just dont' want a certain unit from being purchasable during the Night, but available during the day. Also I want all of it's type to be removed from the map. Here is what I've done so far, which hasn't worked.

JASS:
//Night Trigger
function RemoveDamned takes nothing returns boolean
    if GetUnitTypeId(GetEnumUnit()) == 'uC02' then
        call KillUnit(GetEnumUnit())
    endif
return false
endfunction

function Trig_Slowtime_Actions takes nothing returns nothing
 local group g = CreateGroup()
    call SetMapFlag(MAP_LOCK_SPEED, true)
    call GroupEnumUnitsInRect(g, GetPlayableMapRect(), function RemoveDamned)
    if IsPlayerInForce(GetLocalPlayer(), udg_BloodPackPlayer) then
        call DisplayTextToPlayer(GetLocalPlayer(), 0,0, "Damned Souls are no longer available")
        call SetPlayerTechMaxAllowed(GetLocalPlayer(), 'uC02', 0)
    endif
    if udg_EasyMode == 1 then
    else
    endif
    call DestroyGroup(g)
 set g = null
endfunction

//===========================================================================
function InitTrig_Slowtime takes nothing returns nothing
    set gg_trg_Slowtime = CreateTrigger(  )
    call TriggerRegisterGameStateEvent(gg_trg_Slowtime, GAME_STATE_TIME_OF_DAY, EQUAL, 18.10)
    call TriggerAddAction( gg_trg_Slowtime, function Trig_Slowtime_Actions )
endfunction

JASS:
//Day Trigger
function Trig_Skiptime_Actions takes nothing returns nothing
    if IsPlayerInForce(GetLocalPlayer(), udg_BloodPackPlayer) then
        call SetPlayerTechMaxAllowed(GetLocalPlayer(), 'uC02', -1)
    endif
    if udg_EasyMode == 1 then
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 7.10)
        call SetTimeOfDayScale(1.15)
    else
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 8.10)
        call SetTimeOfDayScale(1.25)
    endif
endfunction

//===========================================================================
function InitTrig_Skiptime takes nothing returns nothing
    set gg_trg_Skiptime = CreateTrigger(  )
    call TriggerRegisterGameStateEvent(gg_trg_Skiptime, GAME_STATE_TIME_OF_DAY, EQUAL, 6.10)
    call TriggerAddAction( gg_trg_Skiptime, function Trig_Skiptime_Actions )
endfunction
 
Level 9
Joined
Nov 4, 2007
Messages
933
I'd be more wary of using GetLocalPlayer() when concerning changing the tech status, that will most certainly cause desyncs if used in multiplayer, and why is there an if then else in your slow time actions that has no script inside?
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
That so that I can test the map without it crashing. Any time I input the following script:

call SetTimeOfDayScale(0.8)

The game will crash. It's currently a holder.

As for setting tech status for Local Player, I was trying to do it for the BloodPack Players. However I could just run a loop and do it for player 0-12
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Nope, doesn't work :\ Not even when I do this:

JASS:
  scope SpeedTimer initializer Init

private function Actions takes nothing returns nothing
 local integer i = 0
    loop
    exitwhen i == 13
        call SetPlayerTechMaxAllowed(Player(i), 'uC02', -1)
        set i = i + 1
    endloop
    if udg_EasyMode == 1 then
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 7.10)
        call SetTimeOfDayScale(1.15)
    elseif udg_EasyMode != 1 then
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 8.10)
        call SetTimeOfDayScale(1.25)
    endif
endfunction

//===========================================================================
private function Init takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerRegisterGameStateEvent(t, GAME_STATE_TIME_OF_DAY, EQUAL, 6.10)
    call TriggerAddAction(t, function Actions )
endfunction

endscope

JASS:
scope SlowTime initializer Init

private function RemoveDamned takes nothing returns boolean
    if GetUnitTypeId(GetEnumUnit()) == 'uC02' then
        call KillUnit(GetEnumUnit())
    endif
return false
endfunction

private function Actions takes nothing returns nothing
 local integer i = 0
 local group g = CreateGroup()
    call GroupEnumUnitsInRect(g, GetPlayableMapRect(), function RemoveDamned)
    loop
    exitwhen i == 13
        call SetPlayerTechMaxAllowed(Player(i), 'uC02', 0)
        set i = i + 1
    endloop
    if udg_EasyMode == 1 then
       call SetTimeOfDayScale(0.5)
    elseif udg_EasyMode != 1 then
       call SetTimeOfDayScale(0.8)
    endif
    call DestroyGroup(g)
 set g = null
endfunction

//===========================================================================
function Init takes nothing returns nothing
 local trigger t = CreateTrigger()
    call TriggerRegisterGameStateEvent(t, GAME_STATE_TIME_OF_DAY, EQUAL, 18.10)
    call TriggerAddAction( t, function Actions )
endfunction

endscope
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
It also doesn't work in it's GUI Form o_O How unusual. Could someone point me out to the right way to do remove units from nuetral buildings for player?

  • Untitled Trigger 002
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player - Make |c00ff0000Damned Soul Unavailable for training/construction by Player 1 (Red)
 
Last edited:
Level 9
Joined
Nov 4, 2007
Messages
933
Yes that appears correct... the f**k is happening to the world editor... its been aggrivating me more each time I use it, sometimes crashing maps at random or just not doing what its told to do... used to work perfectly fine in 2009...
 

sPy

sPy

Level 22
Joined
Apr 10, 2009
Messages
380
How bout this:
  • Day
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Footman to -1 for (Picked player)
  • Night
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Footman to 0 for (Picked player)
 
Level 9
Joined
Nov 4, 2007
Messages
933
How bout this:
  • Day
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Footman to -1 for (Picked player)
  • Night
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Footman to 0 for (Picked player)

That doesn't work for purchasable units, tried that with Goblin Shredder.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Nope, doesn't work either. :\ Thanks for trying though. I'll give it some more extensive testing and see if I can't find out how to limit purchasability from nuetral taverns.

Any help in figuring this matter out is appreciated though.

Hero Taverns still have some method of making units you select no longer available, so there's gotta be a way.

The unit I'm using this for obviously isn't a Hero, but it is a unit.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
In GUI when you limit the availability of heroes, what you're really doing is:

JASS:
call SetPlayerTechMaxAllowed( forPlayer, 'HERO', howMany )

I find it really strange how 'HERO' speaks for all heroes. If you enter in a value like 'Hblm' which happens to be the Human Bloodmage it specifies the Bloodmage specifically. Heroes seem to have specific functionality.

For example, if you limit the "training" of the Bloodmage to one and have a unit that "sells" them, then regardless of whether or not you train/purchase a Bloodmage it will completely remove its availability from you. If you do the same thing with a Footman, then you'll be able to buy as many as you like but you will only be able to train one if you're below your limit. In other words, you cannot remove units from buildings that "sell" units, only from training. The only type of units that you can remove from buildings are heroes.
 

sPy

sPy

Level 22
Joined
Apr 10, 2009
Messages
380
Why don't you use the marketplace as the Mercenary Camp?
And then put this:
  • Untitled Trigger 001 Copy
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
    • Conditions
    • Actions
      • Neutral Building - Add Forest Troll Berserker to all marketplacs with 1 in stock and a max stock of 1
  • Untitled Trigger 001
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • Neutral Building - Remove Forest Troll Berserker from all marketplaces
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
What sPy said will work, but for some reason you can't remove units that are listed in the "Units sold" field. Player availability works perfectly when the units are trained, though it seems like they aren't functional at all for units that are sold.
 
Status
Not open for further replies.
Top