• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Certain Items go in Certain Inventory Slots

Status
Not open for further replies.
Level 8
Joined
Sep 23, 2007
Messages
357
I need a trigger that classifies certain items as a certain item type (I.E. armor, weapon, helm, shield, ect.), and places that item in an inventory slot dedicated to that item type. Help is greatly appreciated. Thanks.

Edit: I'm sure a thread about this exists somewhere on these forums, but I couldn't find it. If there is a thread about how to do this a link would be appreciated.
 
Last edited by a moderator:
Level 13
Joined
May 11, 2008
Messages
1,198
although i guess your problem can be solved and possibly has been solved in gui it might be a little better in jass, or at least part of it being jass...
if you want i can show you some custom functions you could use to compare with.
if you use gui and can use custom script then i could write the jass functions which you could call in your custom script.

just one question do you have an editor that supports vjass, cjass, or just regular editor and regular jass?

each item type you have will be one of the regular item classifications/types. as long as you don't use this sort of functions somewhere else it should work fine.

another option which also works just fine is to classify your items by item level. this might be preferable for obvious and not so obvious reasons.

but yes, if you need those item levels for something else, it won't work for you. afaik most people don't use item levels, and even if you have some sort of item drop lists reliant on levels, you can manually set those yourself and it might work out better that way, anyway...

edit: actually on further examination it will take further examination to find out how to do this...
edit2: i think the easiest way to code up some function for this is if you give all the units this would apply to(there can be exceptions if you need them, like to make selling items easier you can make a dummy unit or whatever other unit be an exception) some original items. this could potentially be awkward or intuitive. a basic weapon, shield, helm, armor items would all need to be equipped at all times. if you want to be able to empty a unit's inventory, this idea wouldn't work perhaps, because players would have to acquire the equipment types for slots 0-2 before acquiring an eqiuipment type 3, which is why i suggested implementing original items for units. since you're restricting the item slots to specific slots anyways i think this idea might work out ok for you.

an extension to this idea i had was that it would be simple to code a way to make it so you needn't drop items before picking one up. a swap would be made automatically for you. this would be a streamlined interface for the player, but would be potentially bothersome for the map designer, as they would have to make a lot more objects, since they would be replacing items with dummy items(powerups) or vice versa everytime you would drop or pick up an item.
 
Last edited:
Level 13
Joined
May 11, 2008
Messages
1,198
i figure you might need regular jass...let me know if it doesn't compile properly.
so you need to put the two functions in your jass library for your map, wherever that is...
if you don't use vjass/cjass or whatever, i guess that's perhaps your map header...idk. i haven't used gui in ages.

if you end up needing to rename the functions for some reason don't forget to edit the custom script to make sure you are calling the function name correctly
JASS:
/////////////////the two functions
function CheckItemSlot takes unit z, item x integer y returns integer
if y<4 and UnitItemInSlot(z,y)==x then
return y
elseif y==4 and UnitItemInSlot(z,4)==x then
return 4
elseif y==4 and UnitItemInSlot(z,5)==x then
return 5
else
call UnitDropItemSlot(z,x,y)
return 6
endif
endfunction
function CheckItemClass takes unit x, item y returns boolean
if CheckItemSlot(x, y, GetItemLevel(y)) !=6 then
return false
endif
call BJDebugMsg("Error: Invalid Equipment Pickup")
return false
endfunction
////////////////
//this is an example of how to use the functions in regular jass...
//i'm hoping it gives you good enough idea how to make a gui trigger with the functions
//the line you're most concerned with is the one that starts with 'call CheckItemClass('
//
//basically the way i set up the functions they work automatically and you don't have to code anything else.
//but you still have to edit the item properties in object editor.
//you might need to edit the code if your item needs are unusual.
//how it is set up now item levels 0-3 are for slots 0-3.
//item level 4 is for slots 4-5(perishable/miscellaneous item slots)
//also you can edit the debug message freely and even add a different message for different kinds of armors if you like.
//let me know if you have any trouble doing coding customizations like how i mentioned above.
function Trig_itemclasses_Conditions takes nothing returns boolean
call CheckItemClass(GetManipulatingUnit(),GetManipulatedItem())
return false
endfunction
private function InitTrig_itemclasses takes nothing returns nothing
set gg_trg_itemclasses = CreateTrigger(  )
call TriggerRegisterPlayerUnitEvent(t,Player(2),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(t,Player(3),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(t,Player(4),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
call TriggerRegisterPlayerUnitEvent(t,Player(5),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
//repeat the above with every valid player(player(0) is red, player(1) blue, 2 teal, and so on)
call TriggerAddCondition( t, Condition(function triggeritemclassescallfunc) )
endfunction

and here is the example again, in gui format, in case you couldn't figure it out.
  • itemclassesgui
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to (!=) Footman
    • Actions
      • -------- the event is generic. if you would like to have player exceptions you could use a different event but this might work if you want the trigger for all players --------
      • Custom script: call CheckItemClass(GetManipulatingUnit(),GetManipulatedItem())
      • -------- take note these jass function calls are like event response - Triggering Unit and event response - Item being manipulated --------
      • -------- so you can use those for other custom scripts you might need to write...and remember... --------
      • -------- there's the convert to custom text feature of the editor so you can always see what gui looks like in custom text/jass --------
Use item levels to create categories.
This way you can split them into 10000+ groups.

he only has 6 item slots...

at any rate the code i wrote is for item levels 0-4. if item levels is awkward for you that's fine we can use item types/classifications. there are 7 total item types so there's plenty of that to go around, and it's probably something you'll use anyway...but who knows.
 
Last edited:
Level 8
Joined
Sep 23, 2007
Messages
357
@SanKaKu

Can you please implement this system into a test map? I am sorry if I am asking for a bit much, but I would definitely be able to understand this system better if it was used in a test map.

Also, this part is not necessary, but I would like only certain item types to be allowed to be in a certain inventory slot. I.E. only helms go in slot 1, armor in slot 2, weapon in slot 3, and shield in slot 4.

Edit:
Use item levels to create categories.
This way you can split them into 10000+ groups.

btw.
ur avatar.
i have that game.
lol.
 
Last edited by a moderator:
Level 8
Joined
Sep 23, 2007
Messages
357
Link Please :D

210027-bonk_s_adventure_large.jpg


Bonk's Adventure.

dnt worry i wont expose u XD
 
Level 13
Joined
May 11, 2008
Messages
1,198
ya i'll make a test map...hmm...ya it's almost done...looks like i found a bug i'll need to fix with it...hang on for a bit.

ok, here it is...looks like one of the functions was the wrong one...
hope you appreciate the test map...it all seems to work ok and i added comments.

if you have a problem with editing item levels then you can use classifications instead(weapons=permanent, armors=miscellaneous, shields=purchasable, helms=artifacts, perishables=charged...something like that). it should be easy to rewrite it if that's what you like.
 

Attachments

  • itemslotequipment.w3x
    21.4 KB · Views: 87
Last edited:
Status
Not open for further replies.
Top