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!
How to set x,y card position of Building Upgrades to...?
Is there a way to remove Building Upgrades to for a specific building and not all buildings by that player? Or... Do I have to create buildings just to replace that building in order to prevent the upgrade? There are 4 upgrading options (A, B, C and D) so if a building already previously have upgraded to into A I would have to replace with a unit that can only upgrade to B, C and D etc. for every possible outcome...
One simple solution would be to order the building to cancel when it starts to upgrade, but I don't know how to do that.
You forgot to mention that the hotkey to recruit the unit is removed?
I made a stab at it. It isnt working properly and is a really horrible way of doing this for sure, but this is the idea:
- When a blacksmith dies, finish construction or starts upgrading every blacksmith in the that town is picked and updated.
JASS:
private function UpdateBlacksmith takes integer city returns nothing
local group g1 = CreateGroup()
local group g2 = CreateGroup()
local unit u
local integer array count
local integer load
local integer i = 1
call GroupAddGroup(CityGroup[city], g1)
loop
set u = FirstOfGroup(g1)
exitwhen u == null
if (GetUnitState(u, UNIT_STATE_LIFE) > 0) then
set load = LoadInteger(hash, GetUnitTypeId(u), 'hbla')
if (load > 0 or GetUnitTypeId(u) == 'hbla') then
set count[load] = count[load] + 1
call GroupAddUnit(g2,u)
endif
endif
call GroupRemoveUnit(g1,u)
endloop
call BJDebugMsg("----------")
call BJDebugMsg(I2S(count[0]))
loop
exitwhen blacksmith[i] == null
call BJDebugMsg(I2S(count[i]))
set i = i + 1
endloop
call BJDebugMsg("----------")
loop
set u = FirstOfGroup(g2)
exitwhen u == null
if (GetUnitTypeId(u) == 'hbla') then // Basic Blacksmith
if (count[1] > 0 or count[2] > 0 or count[3] > 0) then // Check for Any Upgraded Blacksmiths: Meele Weapons Upg
call RemoveUnitFromStock(u,'blm0')
else
call AddUnitToStock(u,'blm0',1,1)
endif
if (count[4] > 0 or count[5] > 0 or count[6] > 0) then // Check for Any Upgraded Blacksmiths: Meele Armor Upg
call RemoveUnitFromStock(u,'blm1')
else
call AddUnitToStock(u,'blm1',1,1)
endif
if (count[7] > 0 or count[8] > 0 or count[9] > 0) then // Check for Any Upgraded Blacksmiths: Ranged Weapons Upg
call RemoveUnitFromStock(u,'blm2')
else
call AddUnitToStock(u,'blm2',1,1)
endif
if (count[10] > 0 or count[11] > 0 or count[12] > 0) then // Check for Any Upgraded Blacksmiths: Ranged Armor Upg
call RemoveUnitFromStock(u,'blm3')
else
call AddUnitToStock(u,'blm3',1,1)
endif
// Then it continues for all types of blacksmith (Only 1 if-else here)
elseif (GetUnitTypeId(u) == blacksmith[1]) then // LVL 1 Meele Weapons Upgrade (Blacksmith)
if (count[2] > 0 or count[3] > 0) then
else
endif
elseif (GetUnitTypeId(u) == blacksmith[2]) then // LVL 2 Meele Weapons Upgrade (Blacksmith)
if (count[3] > 0) then
else
endif
elseif (GetUnitTypeId(u) == blacksmith[4]) then // LVL 1 Meele Armor Upgrade (Blacksmith)
elseif (GetUnitTypeId(u) == blacksmith[5]) then // LVL 2 Meele Armor Upgrade (Blacksmith)
elseif (GetUnitTypeId(u) == blacksmith[7]) then // LVL 1 Ranged Weapons Upgrade (Blacksmith)
elseif (GetUnitTypeId(u) == blacksmith[8]) then // LVL 2 Ranged Weapons Upgrade (Blacksmith)
elseif (GetUnitTypeId(u) == blacksmith[10]) then // LVL 1 Ranged Armor Upgrade (Blacksmith)
elseif (GetUnitTypeId(u) == blacksmith[11]) then // LVL 2 Ranged Armor Upgrade (Blacksmith)
endif
endloop
set u = null
endfunction
JASS:
// Blacksmith
set BuildingType[3] = 'hbla'
call SaveInteger(hash, 0, String2OrderIdBJ("blacksmith"), 3)
call SaveInteger(hash, 1, 'hbla', 3)
set blacksmith[1] = 'h00B' // Blacksmith MeleeDmgUpg
set upgradeType[1] = "mw"
set upgradeLvl[1] = 1
call SaveInteger(hash, blacksmith[1], 'hbla', 1)
set blacksmith[2] = 'h00A'
set upgradeType[2] = "mw"
set upgradeLvl[2] = 2
call SaveInteger(hash, blacksmith[2], 'hbla', 2)
set blacksmith[3] = 'h00C'
set upgradeType[3] = "mw"
set upgradeLvl[3] = 3
call SaveInteger(hash, blacksmith[3], 'hbla', 3)
set blacksmith[4] = 'h00E' // Blacksmith MeleeArmUpg
set upgradeType[4] = "ma"
set upgradeLvl[4] = 1
call SaveInteger(hash, blacksmith[4], 'hbla', 4)
set blacksmith[5] = 'h00D'
set upgradeType[5] = "ma"
set upgradeLvl[5] = 2
call SaveInteger(hash, blacksmith[5], 'hbla', 5)
set blacksmith[6] = 'h00F'
set upgradeType[6] = "ma"
set upgradeLvl[6] = 3
call SaveInteger(hash, blacksmith[6], 'hbla', 6)
set blacksmith[7] = 'h00G' // Blacksmith RangedDmgUpg
set upgradeType[7] = "rw"
set upgradeLvl[7] = 1
call SaveInteger(hash, blacksmith[7], 'hbla', 7)
set blacksmith[8] = 'h00H'
set upgradeType[8] = "rw"
set upgradeLvl[8] = 2
call SaveInteger(hash, blacksmith[8], 'hbla', 8)
set blacksmith[9] = 'h00I'
set upgradeType[9] = "rw"
set upgradeLvl[9] = 3
call SaveInteger(hash, blacksmith[9], 'hbla', 9)
set blacksmith[10] = 'h00K' // Blacksmith RangedArmUpg
set upgradeType[10] = "ra"
set upgradeLvl[10] = 1
call SaveInteger(hash, blacksmith[10], 'hbla', 10)
set blacksmith[11] = 'h00L'
set upgradeType[11] = "ra"
set upgradeLvl[11] = 2
call SaveInteger(hash, blacksmith[11], 'hbla', 11)
set blacksmith[12] = 'h00M'
set upgradeType[12] = "ra"
set upgradeLvl[12] = 3
Any suggestions as how to optimize this garbage?
It wasn't as easy as I thought! ^^
Think im doing it like this:
1,2,3,4,5,6,7,8,9,10,11 and 12 are counted units of a specific type count[1], count[2] etc... 0 is the count and '0000' or '1000' etc. are unit types returned. Can you compress the following into a loop? or something more mechanical then a bunch of ifs?
IF: 1,2,3 > 0 and 4,5,6 > 0 and 7,8,9 > 0 and 10,11,12 > 0 return 0000
IF: 1,2,3 > 0 and 4,5,6 = 0 and 7,8,9 = 0 and 10,11,12 = 0 return 1000
IF: 1,2,3 = 0 and 4,5,6 > 0 and 7,8,9 = 0 and 10,11,12 = 0 return 0100
IF: 1,2,3 = 0 and 4,5,6 = 0 and 7,8,9 > 0 and 10,11,12 = 0 return 0010
IF: 1,2,3 = 0 and 4,5,6 = 0 and 7,8,9 = 0 and 10,11,12 > 0 return 0001
IF: 1,2,3 > 0 and 4,5,6 > 0 and 7,8,9 = 0 and 10,11,12 = 0 return 1100
IF: 1,2,3 = 0 and 4,5,6 > 0 and 7,8,9 > 0 and 10,11,12 = 0 return 0110
IF: 1,2,3 = 0 and 4,5,6 = 0 and 7,8,9 > 0 and 10,11,12 > 0 return 0011
IF: 1,2,3 > 0 and 4,5,6 = 0 and 7,8,9 > = and 10,11,12 = 0 return 1010
IF: 1,2,3 = 0 and 4,5,6 > 0 and 7,8,9 = 0 and 10,11,12 > 0 return 0101
IF: 1,2,3 > 0 and 4,5,6 > 0 and 7,8,9 > 0 and 10,11,12 = 0 return 1110
IF: 1,2,3 = 0 and 4,5,6 > 0 and 7,8,9 > 0 and 10,11,12 > 0 return 0111
IF: 1,2,3 > 0 and 4,5,6 = 0 and 7,8,9 > 0 and 10,11,12 > 0 return 1011
IF: 1,2,3 > 0 and 4,5,6 > 0 and 7,8,9 = 0 and 10,11,12 > 0 return 1101
IF: 1,2,3 > 0 and 4,5,6 > 0 and 7,8,9 > 0 and 10,11,12 > 0 return 1111
Perhaps something like this...
JASS:
if ((1 or 2 or 3) > 0) then
set s = "1"
else
set s = "0"
endif
if ((4 or 5 or 6) > 0) then
set s = s + "1"
else
set s = s + "0"
endif
if ((7 or 8 or 9) > 0) then
set s = s + "1"
else
set s = s + "0"
endif
if ((10 or 11 or 12) > 0) then
set s = s + "1"
else
set s = s + "0"
endif
set utype = LoadInteger(hash, 0, s)
set u = CreateUnit(SomePlayer, utype,x,y,f)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.