• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

Crafting system & other item related stuff

Status
Not open for further replies.
Level 14
Joined
Sep 27, 2009
Messages
1,547
So, it's possible to create inventory system and items in sc2, then how could I make item related triggers? Eg. Unit can't enter region X without item Y, or, with item Z and V, player can use ability "crafting" and create new item A. And btw, I am not currently able to use Galaxy editor, I just wanted to know if it's possible. Thanks.
 
Level 14
Joined
Sep 27, 2009
Messages
1,547
Great, well, can You give me an example of item related trigger (maybe like that unit can not enter region thing)? Because I don't know much about them, and I can' try by myself right now.

  • This is what I mean by "making an example"
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
There is a fully functioning inventory and item system built into the game. Just there are no examples of it being used outside of custom maps. Notice the item related catalogs in the data editor.

Here are the natives I found for item interaction.
native void OrderSetTargetItem (order inOrder, unit inItem);
native unit OrderGetTargetItem (order inOrder);

// Unit inventory
const int c_unitInventoryCountCarried = 0;
const int c_unitInventoryCountEmpty = 1;
const int c_unitInventoryCountTotal = 2;

native int UnitInventoryContainer (unit inUnit);
native int UnitInventoryCount (unit inUnit, int inCountType);
native unit UnitInventoryCreate (unit inUnit, string itemType);
native unitgroup UnitInventoryGroup (unit inUnit);
native int UnitInventoryIndex (unit inItem);
native unit UnitInventoryItem (unit inUnit, int inIndex);
native unit UnitInventoryLastCreated ();
native void UnitInventoryMove (unit inItem, int inContainer, int inSlot);
native void UnitInventoryRemove (unit inItem);
native int UnitInventorySlot (unit inItem);
native unit UnitInventoryUnit (unit inItem);
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Sadly I have no idea, I have yet to try out items in SC2 myself (only played maps which used them).

You can however make inventories with more than 6 slots. This means you can make dedicated slots. Eg Crafting only slots which would make triggering a system easier (can ignore all items not in the crafting area).
 
Level 27
Joined
Jul 6, 2008
Messages
11,325
Yesterday I spent some time thinking how to make a Minecraftish crafting system in SC2, so I got some idea how it could work (Still, I'm not good with trrigers so my idea might be pretty much unefficient and there can be an easier way).

See, it appears to me now that you can't really make a Data-only crafting system in SC2, because you can't make items interact in different ways with each other. You can do that only with triggers.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Then the problem is to make an efficient item crafting system using triggers.

Firstly the set of crafting rules needs to be difined. Then a system needs to be designed that can execute these rules using source data.
Once a suitable design is found, you must try and test it etc. Finally is the trivial task of setting up the data for it to use (probably arrays).

The problem is getting its execution complexity as close to O(1) as possible. The lack of dynamic structures in SC2 make this task more difficult but it should still be possible.
 
Status
Not open for further replies.
Top