• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Simple Shop System

Status
Not open for further replies.
Level 9
Joined
May 21, 2014
Messages
580
Hello again, Hive.

I am planning to make a simple Shop System where items bought by a buyer will be automatically bought by other units surrounding the buyer with the corresponding costs.

I just don't know how to detect the unit that is targeted by the shop.

I also have a question of what is the proper way of doing this. Storing the buyer to a variable won't work, but there can be an instance where there are more than 1 players who are going to be in the shop, or one or more units of a player can go into different shops.

Thanks! :ogre_kawaii:
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
An array will do fine.

Setup:
set ItemType[1] = crown of kings
set ItemCost[1] = 500
set ItemType[2] = blades of attack
set ItemCost[2] = 200
set ItemMax = 2 (the highest array number from the list)

On purchase:
for loop Integer_A from 1 to ItemMax do:
if item type of item being manipulated equal to ItemType[Integer_A] then set temp_cost = ItemCost[IntegerA]
 
Level 9
Joined
May 21, 2014
Messages
580
Level 9
Joined
May 21, 2014
Messages
580
An array will do fine.

Setup:
set ItemType[1] = crown of kings
set ItemCost[1] = 500
set ItemType[2] = blades of attack
set ItemCost[2] = 200
set ItemMax = 2 (the highest array number from the list)

On purchase:
for loop Integer_A from 1 to ItemMax do:
if item type of item being manipulated equal to ItemType[Integer_A] then set temp_cost = ItemCost[IntegerA]

I have reimplemented my Bulk Buying System into Array format since my last hashtable had bugs due to lack of knowledge of hashtables.

Then, I suddenly realized that I have not implemented (even in hashtables) detecting the stock amount of the item. How do I get the remaining stock value of the item in shop?
 
Status
Not open for further replies.
Top