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

[General] Complete control of custom object ids

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Assuming we can give our custom objects any id value, what advantages would this confer in simplifying managing said objects?

Apologies if this is too general (having trouble wording my question).

I am planning on making all my custom objects portable with the lua object generation, and I'd like to know if I should pick clever object IDs which I could take advantage of in the logic of the map.
 
By being able to change the ids you can make groups of items have closely related values.

You can also change the ids to correspond to something like item ability corresponding to a unit. Or have it correspond to a trap on your map through the id.

There are many things that you can do when changing the ids of items / units / whatever else you change.
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Could you give an example that uses this to cleverly do something, e.g. with your items example? Like actual JASS code that takes advantage of knowing that say the IDS of the custom items are consecutive.
 
I'm on my phone atm. I could try to explain better.
Think about an item restriction system. You can't have more than one shield or weapon on your unit.
If you set all the items of that type ( shield) in a row. You can then use an ITE to check for those items very fast. Example: lets say 10 shields are available. Id is 100000 to start and 100009 to end. All 10 items are there. so use an ITE to check if the id is in that range. Then loop through the unit to check if that unit has any other items in that range.
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
JNGP allows it when making a new object. It allows you to position sets of objects in consecutive id values which can greatly improve the efficiency of some trigger systems, eg for bonus attributes.

Sorry to be so repetitive, but could you explain how it would improve efficiency? Are you referring to the binary system used to give arbitrary values of attack speed, etc.?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You can line ids up. For example have the first (zeroth index) attack speed bonus (0.01) on 'A000', the second on 'A001', third on 'A002' etc., then you can regain them from 'A000'+index. Dunno what's so efficient about that though, you replace array reads by int arithmetics. Far more worthwhile it is to have the bonus systems as slk and the lining up of ids helps debugging ingame.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Dunno what's so efficient about that though, you replace array reads by int arithmetics.
Well in pipelining array reads are slow as they form a bottleneck where as mathematics is fast as it can be run in parallel in the pipe line. This is because memory reads are slow compared to register operations, especially addition.

JASS abstracts this away as it is interpreted anyway. It is faster though because the addition compiles into byte code and the constants into values where as the array needs a name resolution to locate. This means that the array methods needs 2 name resolutions where as the arithmetic approach needs only 1 with 1 more native addition operation (much faster than 2 name resolutions).
 
Status
Not open for further replies.
Top