- Joined
- Sep 29, 2006
- Messages
- 447
In my map you control normal units (NOT HEROES) and they can buy items. I want to make it so that when your unit dies and a new one spawns for you, it has any items the old unit has when it died.
These triggers pass all items dropped on death to a dummy unit and then when a new unit is created (in the revive trigger) the items are passed to the newly created unit. The items just stay on the ground when the original unit dies and they are never passed to the dummy. Why?
This initializes the item holder dummy unit
This stores items to the item holder on death
This revives the unit (creates a new unit) and then the
These triggers pass all items dropped on death to a dummy unit and then when a new unit is created (in the revive trigger) the items are passed to the newly created unit. The items just stay on the ground when the original unit dies and they are never passed to the dummy. Why?
This initializes the item holder dummy unit
-
random shit
-
Events
-
Map initialization
-
-
Conditions
-
Actions
-
-------- Create Item holders --------
-
Set TempPoint = (Center of DwarfItemHolderSpawn <gen>)
-
Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
-
Loop - Actions
-
Unit - Create 1 Item Holder for (Picked player) at TempPoint facing 270.00 degrees
-
Set ItemHolder[(Player number of (Picked player))] = (Last created unit)
-
-
-
Custom script: call RemoveLocation(udg_TempPoint)
-
Set TempPoint = (Center of GoblinItemHolderSpawn <gen>)
-
Player Group - Pick every player in (All enemies of Player 1 (Red)) and do (Actions)
-
Loop - Actions
-
Unit - Create 1 Item Holder for (Picked player) at TempPoint facing 270.00 degrees
-
Set ItemHolder[(Player number of (Picked player))] = (Last created unit)
-
-
-
Custom script: call RemoveLocation(udg_TempPoint)
-
-
This stores items to the item holder on death
-
dont drop items on death
-
Events
-
Unit - A unit Loses an item
-
-
Conditions
-
((Triggering unit) is dead) Equal to True
-
Or - Any (Conditions) are true
-
Conditions
-
(Unit-type of (Triggering unit)) Equal to Dwarven Mortar Team (Custom)
-
(Unit-type of (Triggering unit)) Equal to Goblin Mortar Team (Custom)
-
-
-
-
Actions
-
Hero - Give (Item being manipulated) to ItemHolder[(Player number of (Owner of (Triggering unit)))]
-
-
This revives the unit (creates a new unit) and then the
loop
is what gives the items back.
JASS:
function reviveConditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h004' or GetUnitTypeId(GetTriggerUnit()) == 'h005'
endfunction
function reviveActions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit u2
local player p = GetOwningPlayer(u)
local integer i = GetUnitTypeId(u)
local timerdialog w
local timer t = CreateTimer()
local location l
local real r = 8.00
local integer j = 1
call TimerStart(t, r, false, null)
call CreateTimerDialogBJ(t, GetPlayerName(p))
set w = GetLastCreatedTimerDialogBJ()
call TimerDialogDisplay( w, false )
call TimerDialogDisplayForPlayerBJ(true, w, p)
call PolledWait(r)
if ( IsPlayerAlly(p, Player(0)) ) then
set l = GetRandomLocInRect(gg_rct_DwarfReviveZone)
set u2 = CreateUnitAtLoc(p, i, l, 270.00)
call SelectUnitForPlayerSingle(u2, p)
endif
if ( IsPlayerEnemy(p, Player(0)) ) then
set l = GetRandomLocInRect(gg_rct_GoblinReviveZone)
set u2 = CreateUnitAtLoc(p, i, l, 270.00)
call SelectUnitForPlayerSingle(u2, p)
endif
loop
exitwhen j == 4
call UnitRemoveItemFromSlot( udg_ItemHolder[GetConvertedPlayerId(p)], j )
call UnitAddItem( u2, GetLastRemovedItem() )
set j = j + 1
endloop
call PanCameraToTimedLocForPlayer(p,l,0.60)
call DestroyTimerDialog(w)
call RemoveLocation(l)
set u = null
set u2 = null
set t = null
endfunction
//===========================================================================
function InitTrig_revive takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( t, Condition( function reviveConditions ) )
call TriggerAddAction( t, function reviveActions )
endfunction