HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Giving an item to a hero in a specific slot?

08-12-2004, 08:58 PM#1
-={tWiStÄr}=-
I want it so that when a hero picks up an item it is moved to a certain slot. i tried one thing but it crashed the game.. which isnt good..
this is the part that crashed the game. If someone could tell me whats crashing the game or an alternate way to do this tell me
Note: im using the voodoo doll item as a spacesaver and will make it disapear.
Code:
Untitled Trigger 002
	Events
		Unit - A unit Acquires an item
	Conditions
		(Item-class of (Item being manipulated)) Equal to Permanent
	Actions
		If (All Conditions are True) then do (Then Actions) else do (Else Actions)
			If - Conditions
				(Item carried by (Hero manipulating item) in slot 3) Equal to No item
			Then - Actions
				For each (Integer A) from 1 to 6, do (Actions)
					Loop - Actions
						If (All Conditions are True) then do (Then Actions) else do (Else Actions)
							If - Conditions
								(Item carried by (Hero manipulating item) in slot (Integer A)) Equal to No item
							Then - Actions
								Hero - Create Voodoo Doll and give it to (Hero manipulating item)
							Else - Actions
						Hero - Drop the item from slot 3 of (Hero manipulating item)
						Hero - Give (Item being manipulated) to (Hero manipulating item)
			Else - Actions
				Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: You can only have 1...
08-12-2004, 10:10 PM#2
weaaddar
This function will add an item to a specified slot:
http://www.wc3campaigns.com/showthread.php?t=61667
This function will move an item present in the inventory to a specified slot:
http://www.wc3campaigns.com/showthread.php?t=61378

Doesn't get much easier then this. Simple clean functions.
08-12-2004, 11:48 PM#3
-={tWiStÄr}=-
The game still crashes
Code:
Untitled Trigger 001
	Events
		Unit - A unit Acquires an item
	Conditions
	Actions
		Hero - Drop (Item being manipulated) from (Hero manipulating item)
		If (All Conditions are True) then do (Then Actions) else do (Else Actions)
			If - Conditions
				(Item carried by (Hero manipulating item) in slot 3) Equal to No item
			Then - Actions
				Custom script: call UnitAddItemToSlot(GetManipulatingUnit(), GetManipulatedItem(), 2) 
			Else - Actions
				Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: You can only have 1...
and as it apears in the header:
Code:
function UnitMoveItemToSlot takes unit hero, item it, integer slot returns boolean
	local boolean b
	if(slot>5 or slot<0 )then
	 return false
	endif
	return IssueTargetOrderById(hero ,852002+slot,it )
endfunction
function UnitAddItemToSlot takes unit hero, item it,integer slot returns boolean
local boolean b=UnitAddItem(hero,it)
local boolean c= UnitMoveItemToSlot(hero,it,slot)
return (b and c)
endfunction

edit: i tried giving the item to the hero normaly (Hero - Give item to hero) and then just using UnitMoveItemToSlot.. and the game crashed.. but not when i disabled the give item to hero. I think theres a prob with Give Manipulated Item to Manipulating Hero. OH.. ok i just got it. the prob was give manipulated item to manipulating hero. so i just rearanged my trig a lil and now it works.
08-13-2004, 12:55 AM#4
weaaddar
ofcourse you can't add the item if its already in its inventory...
08-13-2004, 08:12 AM#5
Thrall_89
Well heres another way of going about that SHOULD work.

Code:
 asdf
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Tome of Experience
    Actions
        Hero - Drop (Item being manipulated) from (Hero manipulating item)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item carried by (Hero manipulating item) in slot 1) Not equal to No item
            Then - Actions
                Hero - Create Empty Slot and give it to (Triggering unit)
                Set Slot1FakeItem[1] = (Last created item)
            Else - Actions
                Do nothing
        Hero - Give (Item being manipulated) to (Hero manipulating item)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item carried by (Hero manipulating item) in slot 1) Not equal to Slot1FakeItem[1]
            Then - Actions
                Item - Remove Slot1FakeItem[1]
            Else - Actions
                Do nothing

    

Ok, now where you see that "Empty Slot", that is actually an item that does absoultely nothing. So the trigger is checking to see if the slot is empty, and if it it is filling the slot with a fake item, then giving the Tome of Experiance [whatever the item you want to give to him] back to the hero and destroying the "Empty Slot" if it was created. (make the Slot1FakeItem and Item Array if theres more than one player.) If you wanted it in like slot 6 you just simply create variables for each of the slots and just addon to the "Empty Slot" creation part. Hope this helps! :god_help_us:
08-14-2004, 01:35 AM#6
-={tWiStÄr}=-
Well.. i got it to work.
08-15-2004, 02:16 PM#7
-={tWiStÄr}=-
wow.. this sux
Code:
Unit - Order (Hero manipulating item) to drop (Item being manipulated) in 3
new GUI function in the beta thing. OH wait tho.. will this work for people not using the beta?
08-15-2004, 03:12 PM#8
Jeltz
I twill only work for people in the beta since this function is not only knew to the GUI, it's also new to common.j (and the game).