I dont know whats up, but whenever i do anything with hashtables they don't work. example
used to work but now does nothing
doesnt do anything. (yes, the hashtable is initialized i just didnt put the initialization trigger inside of it
JASS:
library CustomDrop initializer init
globals
private hashtable Hash_t = InitHashtable()
private location SendToItem = Location(0,0)
endglobals
private function OnDeath takes nothing returns nothing
local unit u = GetDyingUnit()
local integer unitId = GetUnitTypeId(u)
local integer count = LoadInteger(Hash_t,unitId,0) // if the unit type was not registred for drop it will be equal to 0, else it will be > 0
local real random
local integer i
local item drop
loop // loop on all dropable item for unitID
exitwhen count == 0
set i = 0
loop // player loop
exitwhen i == 11
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER then
set random = GetRandomReal(0,100)
if random < LoadReal(Hash_t,unitId,count) then
set drop = CreateItem(LoadInteger(Hash_t,unitId,count),GetUnitX(u),GetUnitY(u))
call SetItemVisible(drop,GetLocalPlayer()==Player(i))// the item will be visible only for Player(i)
endif
endif
set i = i+1
endloop
set count = count-1
endloop
set u = null
set drop = null
endfunction
private function RegisterDrop takes integer unitId , integer itemId, real chanceToDrop returns nothing // chanceToDrop in percent
local integer n = LoadInteger(Hash_t,unitId,0)
/* integer : unitId ; 0 -> number of possible item drop for the unit type unitId
integer : unitId ; x -> rawcode of the item to drop ; x > 0
real : unitId ; x -> chance of the item x to drop
*/
set n = n+1
call SaveInteger(Hash_t,unitId,0,n)
call SaveInteger(Hash_t,unitId,n,itemId)
call SaveReal(Hash_t,unitId,n,chanceToDrop)
endfunction
private function onItemPickup takes nothing returns nothing
local item it = GetOrderTargetItem()
local unit u = GetTriggerUnit()
local boolean b
local integer i = 0
local integer i2 = i2i.convert(GetItemTypeId(GetOrderTargetItem()))
// if i2 < 5 then
call SetItemVisible(it, true)
call print(I2S(i2))
// call RemoveItem(it)
// call print("Item " + R2S(GetHandleId(it)) + " With the name of " + GetItemName(it) + " was destroyed.")
// call UnitAddItemById(u, 'rat6')
// endif
// call SetItemPosition(i, GetItemX(i), GetItemY(i))
//// call TriggerSleepAction(0.01)
/* /// call UnitAddItem(u , i)
loop
set b = UnitItemInSlot(u, i) == null
exitwhen b == true
set i = i + 1
exitwhen i == 5
endloop
if b == true then
call UnitAddItem(u, it)
else
set u = udg_Backpack[GetConvertedPlayerId(GetTriggerPlayer())]
set i = 0
loop
set b = UnitItemInSlot(u, i) == null
exitwhen b == true
set i = i + 1
exitwhen i == 6
endloop
if b == true then
call UnitAddItem(u, it)
call print("The item has been sent to your backpack")
else
call print("You do not have enough room for that item")
endif
endif
// call TriggerSleepAction(0)
// call IssueImmediateOrder(u, "stop")
// call IssueInstantPointOrder(u, "move", GetUnitX(u), GetUnitY(u), null)
// call print("Full Inventory")
// elseif it != null then
// call TriggerSleepAction(0)
// call IssueImmediateOrder(u, "stop")
// call SetUnitPositionLoc(u, GetUnitLoc(u))
// call SetItemVisible(it, true)
// call UnitAddItem(u, it)
// endif
*/
endfunction
private function init takes nothing returns nothing
local trigger trig = CreateTrigger()
local trigger trig2 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
call TriggerRegisterAnyUnitEventBJ(trig2, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddAction(trig,function OnDeath)
call TriggerAddAction(trig2, function onItemPickup)
call RegisterDrop('n000','I000',99)
endfunction
endlibrary
used to work but now does nothing
-
UnitIndex
-
Events
-
Game - UnitIndexEvent becomes Equal to 1.00
-
-
Conditions
-
Actions
-
Custom script: local unit u = udg_UDexUnits[udg_UDex]
-
Custom script: call SaveReal(udg_CreepTable, udg_UDex, 1, GetUnitX(u))
-
Custom script: call SaveReal(udg_CreepTable, udg_UDex, 2, GetUnitY(u))
-
Custom script: call SaveReal(udg_CreepTable, udg_UDex, 3, GetUnitFacing(u))
-
Custom script: set u = null
-
-
-
Respawn
-
Events
-
Unit - A unit owned by Neutral Hostile Dies
-
-
Conditions
-
Actions
-
Custom script: local unit u = GetDyingUnit()
-
Custom script: local integer id = GetUnitTypeId(u)
-
Custom script: local integer lv = GetHeroLevel(u)
-
Custom script: local integer cv = GetUnitUserData(u)
-
Custom script: local real x = LoadReal(udg_CreepTable, cv, 1)
-
Custom script: local real y = LoadReal(udg_CreepTable, cv, 2)
-
Custom script: local real ang = LoadReal(udg_CreepTable, cv, 3)
-
Custom script: call RemoveUnit( u )
-
Custom script: set u = CreateUnit(GetTriggerPlayer(),id,x,y,ang)
-
Custom script: if lv > 1 then
-
Custom script: call SetHeroLevel(u,lv,false)
-
Custom script: endif
-
Custom script: set u = null
-
-