• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[JASS] AddingUnitToStock bug...

Status
Not open for further replies.
Level 12
Joined
Aug 7, 2004
Messages
875
Hey I have the following code that repicks a player's hero...

JASS:
function RemoveHeroIcon takes player who returns nothing
local player p = who
local integer i = GetConvertedPlayerId(p)
if(i <= 5) then
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 2 ), "" )
else
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 3 ), "" )
endif
set p = null
endfunction

JASS:
function Repick takes player who returns nothing
local player p = who
local integer i = GetConvertedPlayerId(p)
local location l = GetUnitLoc(udg_heroselector[i])
call RemoveHeroIcon(p)
call DisplayTextToForce(GetPlayersAll(), GetPlayerNameColoured(p) +" has repicked |c001398F4" + GetHeroProperName(udg_dead[i]) + ".")
call SetUnitOwner(udg_heroselector[i], p, true)
call AddUnitToStockBJ(GetUnitTypeId(udg_dead[i]), GetUnitBelongsToTavern(udg_dead[i]), 1, 1) 
call PanCameraToTimedLocForPlayer(p,l,0)
call RemoveUnit(udg_dead[i])
set udg_dead[i] = null 
call RemoveLocation(l)
set p = null
set l = null
endfunction


Everything works fine except for one thing... whenever the unit is added to the tavern one other unit disappears from the stock and it keeps happening everytime this repick action gets called... I don't know how to fix this...

Anyone got a shot?:spell_breaker:
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I don't know why that bug occurs, but you do know you can do this this way, right ?

JASS:
function RemoveHeroIcon takes player who returns nothing
local integer i = GetConvertedPlayerId(who)
if(i <= 5) then
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 2 ), "" )
else
call MultiboardSetItemIconBJ( udg_Multiboard, 1, ( i + 3 ), "" )
endif
endfunction
function Repick takes player who returns nothing
local integer i = GetConvertedPlayerId(who)
local location l = GetUnitLoc(udg_heroselector[i])
call RemoveHeroIcon(who)
call DisplayTextToForce(GetPlayersAll(), GetPlayerNameColoured(who) +" has repicked |c001398F4" + GetHeroProperName(udg_dead[i]) + ".")
call SetUnitOwner(udg_heroselector[i], who, true)
call AddUnitToStockBJ(GetUnitTypeId(udg_dead[i]), GetUnitBelongsToTavern(udg_dead[i]), 1, 1) 
call PanCameraToTimedLocForPlayer(who,l,0)
call RemoveUnit(udg_dead[i])
set udg_dead[i] = null 
call RemoveLocation(l)
set l = null
endfunction

Since you already took the player, you don't need to declare him.
 
Status
Not open for further replies.
Top