Item Carrying System

BlackNerubia

New Member
Reaction score
12
Alright, so im trying to make it when a hero gets 2 of the same item he drops it, mainly weapons so he cant carry 2, i know i can make a storage of the heros complete invintory and update it, but im hoping theres a easyer way to check this and compare the items. any ideas?
 
S

Sunny_D

Guest
check out the free trigger section - there should be an item-restriction trigger (or use search for "item restriction", im sure you will find sth as well)
 

Nestharus

o-o
Reaction score
84
Is that you slayer]blood? lol

oh well, there are many different ways to do this, all of them a lot easier than making a huge array of all the items and checking and so forth ><

Here is the very easiest way that gives you the absolute most freedom:

For this, you can either use life or custom value. Life can just be edited in the Object Editor, Custom value will have to be triggered. If you do life, you should use dummy units for the items that way players don't attack them ><

Ok, here we go:
In most games, items are given an item type. For example, EverQuest has many different item types, one for each slot. Now, let's say you have 6 item types, one for each slot. Right Hand Sword, Left Hand Sword, Shield, you can have both on one item (Left and Right hand), Two Hand Sword, Beastplate, and Helmet.

Now, let's say:
Right Hand = 1
Left Hand = 2
Shield = 3
Two Hand = 4
Breastplate = 5
Helmet = 6

Now you need an array for all the items. This array will contain all of the item's information, meaning its damage, attack range, weight, whatever you want, go wild.

(trust me, you want an array so you can have a lot more freedom to edit item attributes such as upgrades. Maybe even a new combat system? ^)^)

If you don't want that, you can just assign it a custom value or change its item life, like custom value 1 = weapon, 2 = shield, 3 = helmet, and so on. This will limit them for you. You can do it with life too.

Now back to the cooler system : P

Now, let's say an item drops

We do a for loop for our array of items checking those against the item typeof this item. When we find a match, we assign it a custom value based on that match (this is the item's stats).

Let's say it is:
Item Type: 102 (0 just means and in tnhis case. This means we have a sword that can either be used in the left hand or right hand)

Item Damage: 900

Item Attack Range: 100

Item Attack Radius: 90 degrees (small attack radius, maybe a dagger?)

Item Special Attributes: 3 (this in theory will access another array called Special Attributes. Let's say 3 in the special attributes gives the item ice attack).

Now, here's what we do for the custom value:
First, we define how long all of our values are.
102 = 3 characters
900 = 3 characters
100 = 3 characters
90 = 2 characters

Now we have 310239003100290 for a custom value

We assign that to the item. To check a stat, we break it up

Custom Value (substring 1,1)
it's a 3 so we go from 1+1 to 1+3, or 2 - 4

We get 1 0 2
since this is item type, we exlude the 0 and just check our 1 and 2. From here, we check what it's being used as (slot 1 or slot 2 / left hand or right hand)

now we do a for loop
for each item in inventory from 1 - 6 or w/e
if picked item custom value (get our item type) = new item custom value

drop new item and say you already have this

Now, since we have 1 and 2 for the item type, it'll be a lot more interesting.

For this, we need to see if we have 2 items, a 1, and a 2, or 2 1 2s or whatever, so we do a count:

btw, we also need to do shields

if item type of picked item = item type 1 of new item
set x = x + 1
if item type of picked item != item type 1 of new item (this'll just make sure we don't count a 102 item twice, lol)
then
if item type of picked item = item type 2 of new item
set x = x + 1
(and since we also have shields and we're shooting for realism)
if item type of picked item == 3 and item type of new item == 1 or item type of new item == 2 or item type of new item == 3
set x = x + 1

if x >= 2

drop new item

Now, obviously, for armor, this would be a lot easier. It would just go

pick every item
if item type of picked = item type of new

drop new item

it just gets more complex when we can switch around slots. Now, obviously this system is a little advanced and isn't very easy, but it allows you to do whatever you want to do.

Like I said, you can just assign like a custom value of 1, 2, and so forth and just allow 1 wep, 1 shield, and so on. Or you can assign item levels, like item level 1 = wep, item level 2, = w/e, but this will only give you 9 item types (level 0 to level 8)

or you can assign item life in the object editor and just do a for loop to pick all the items and compare their item lives, but to make it so the system doesn't bug up, you need to do something to either regenerate their life to full or use a dummy unit with invulnerable : P

Hope this helps! I told you just about every possible good way to do this ^_^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top