• 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.

Custom Item System

Status
Not open for further replies.
Level 3
Joined
Jan 15, 2010
Messages
47
Hey all :)

Now that I have my custom stat system, I am working on a custom item system to work with it. I am using a struct to hold item data, and making an array of the struct for each item type. Maybe I am not familiar enough with the syntax involved with looping through an array of structs, but for some reason, when I use my add function to add an item to the array, it fills up the array. I think. I made a test function to list the contents of the array, and it makes like 2940 of the only item I have added.

I realize that the struct for this purpose is overkill, and i could just use parallel arrays at most, but I plan to add more variables to the data at some point in the future.

I am initializing my struct and array like this:

JASS:
struct itemData
   string name
   integer itemCode
endstruct

JASS:
globals
   itemData array OneHandSlashing
endglobals

And then my add function looks like:

JASS:
function addOneHandSlashing takes string n, integer i returns nothing
   local integer z = 0
   loop
      exitwhen (OneHandSlashing[z].name == null)
      set z = z + 1
   endloop
   set OneHandSlashing[z].name = n
   set OneHandSlashing[z].itemCode = i
endfunction

And then finally I have an item initiation trigger (the previous code is all in my map header) with the following function call:

JASS:
scope Items initializer init
private function init takes nothing returns nothing
   call addOneHandSlashing("Test Sword", 'I000')
endfunction
endscope

I am thinking that I am just adding the item incorrectly with my add function. If someone happens to see something incorrect in my code, or could suggest a better solution to my system, I would really appreciate it :)

Thanks!
-enyeas
 
Level 3
Joined
Jan 15, 2010
Messages
47
I have no experience with multi-board systems, yet :) What would you suggest i use for item codes?

I have read up on the idea of using different item types (campaign, permanent, etc) for different slots and limiting it that way, but i would like to eventually work my system into a multi-board system at some point, very far in the future.
 
Level 3
Joined
Jan 15, 2010
Messages
47
I want it to store item IDs mostly, so I can do a isOneHandSword(integer itemCode) type function when an item is picked up. Figured it wouldn't hurt to store the item name with it.

Also I just caught on to what you said with the multiboard system items. My items that I am using are just items with a name and id and the stats are blank. Then I will do a function that adds to my custom stat system.

so like:
1. hero picks up item
2. trigger identifies item (loop through the struct array to find the itemcode of item just picked up)
3. trigger checks if slot is open
4. if slot is open, add stats
5. if slot is full, drop item
 
Level 9
Joined
Aug 21, 2008
Messages
533
Hmm so you just want to store additional datas which you cant save at the item itself(like you already said how many hands are needed to wear it ;) )? Well thats clever :thumbs_up:
but i dont find to much needs for this. one thing i my think of is for set items. Hmm well that really could help to make set items:grin:
 
Level 3
Joined
Jan 15, 2010
Messages
47
yeah, like i will have a struct holding 2 handed weapons, and when a unit picks up the two handed weapon, it checks if the mainhand and offhand slots are empty. but yeah, it would allow for item sets to be made rather easily :) just need to get this working, and then maybe i can make it look pretty and upload it :)

I guess the main issue I am having is looping through the struct array and adding to the last part.

Would anyone know the correct way to loop through an array of structs?
 
Last edited:
Status
Not open for further replies.
Top