• 🏆 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!

Custom gold carry help

Status
Not open for further replies.
Level 12
Joined
Dec 17, 2009
Messages
951
How can i create a custom gold carryed for different heroes, each hero got his own gold carryed insted of use "player" owner real gold to buy stuffs
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Index each hero by it's custom value and use that value with an array to keep each hero gold (Gold[Custom Value of Unit])
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. Create an Integer Variable called "HeroIndex"
2. Create the next trigger
  • Trigger
  • Event
    • A unit enters Playable Map Area
  • Conditions
    • (Triggering Unit) is a Hero Equal to True
    • Custom value of (Triggering Unit) equal to 0
  • Actions
    • Set HeroIndex = HeroIndex+1
    • Unit - Set Custom Value of (Triggering Unit) equal to HeroIndex
3. Create an Integer Variable Array called "Gold"
4. From now on, you can access each hero gold by it's custom value. You just access the saved gold with "Gold[Custom value of Unit]". Unit refers to the Triggering Unit, or Killing Unit, or Buying Unit, or whatever, depending on the event.
 
Level 12
Joined
Dec 17, 2009
Messages
951
ok, how can set a bounty range gold share for killing monsters, the killer got a real gold bounty by killing him, and assist heroes will get only half of his gold :x

and... can you give me a example hmmm about how can i do this with the shop thing?
thats all i need for complete a old project :x
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
To share gold with triggers you have to, manually set the gold bounty for each unit or detect the bounty received by the killing unit from the object editor (by detecting the difference between his gold before and after the kill, then dividing it by 2, and giving it to everyone in range).

Chaosy is up to help you If you can't do it by yourself.
 
Level 12
Joined
Dec 17, 2009
Messages
951
simply check if the gold variable [heroIndex] is higher than the price of item bougjt. and then remove the ammout from the variable.

if you need the whole trigger done tell me and i can post it here

would be very very very helpful to me!

To share gold with triggers you have to, manually set the gold bounty for each unit or detect the bounty received by the killing unit from the object editor (by detecting the difference between his gold before and after the kill, then dividing it by 2, and giving it to everyone in range).

Chaosy is up to help you If you can't do it by yourself.

ok thank you :)


oh and can i make a event that my heroes can deposit a amounth of their gold on their own guild (the building that trained him), to a tax collector, collect all these gold carryed by building, and than transform it in real mana of 'palace unit' (yeah i triggered my castle building to the mana be the real player 1 gold)
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
one integer variable (non array) used
one integer variable (with array) used

  • Index units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Custom value of (Triggering unit)) Equal to 0
    • Actions
      • Set Unit_index = (Unit_index + 1)
      • Unit - Set the custom value of (Triggering unit) to Unit_index
  • Obtain custom gold
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
    • Actions
      • -------- Here you got two choises, make every unit give the same ammout of custom gold or not. --------
      • -------- This does not include the gold share but just lower the prices a little and thats fine --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Footman
        • Then - Actions
          • Set CustomGold_value[(Custom value of (Dying unit))] = (CustomGold_value[(Custom value of (Dying unit))] + 10)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Knight
        • Then - Actions
          • Set CustomGold_value[(Custom value of (Dying unit))] = (CustomGold_value[(Custom value of (Dying unit))] + 15)
        • Else - Actions
  • Use custom gold
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • -------- Make sure that items available in the shop got the gold cost 0 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Tome of Experience
          • CustomGold_value[(Custom value of (Buying unit))] Greater than or equal to 150
        • Then - Actions
          • Set CustomGold_value[(Custom value of (Buying unit))] = (CustomGold_value[(Custom value of (Buying unit))] - 150)
        • Else - Actions
          • Item - Remove (Sold Item)
      • -------- -- --------
      • -------- And so on for every item, very simple --------
      • -------- -- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Sold Item)) Equal to Keg of Thunderwater
          • CustomGold_value[(Custom value of (Buying unit))] Greater than or equal to 75
        • Then - Actions
          • Set CustomGold_value[(Custom value of (Buying unit))] = (CustomGold_value[(Custom value of (Buying unit))] - 75)
        • Else - Actions
          • Item - Remove (Sold Item)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I would store in a Hashtable every creep and unit bounty, and every item price, and use that hashtable data instead of long If/then/Else statements for items and creeps :)

You also have to remove the sold item if the gold isn't enough.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Huge setup trigger happens once. This will happen every time a unit dies or an item is bought... Anyway, lets wait for .VTZ. and see what he thinks about.

Really fast triggering BDW, congrats.
 
Level 12
Joined
Dec 17, 2009
Messages
951
Level 12
Joined
Dec 17, 2009
Messages
951
ok, so as you guys can see on that GUI AI spell, there is a buy iten function, how can i implement this, there
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The same way the trigger compares the current gold with the required gold to buy an item. Do the same comparison before ordering the computer to go and buy the item.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
  • AI Item Buy
  • Events
  • Conditions
  • ((Owner of (Triggering unit)) is in AI_Players) Equal to True
  • ((Triggering unit) is A Hero) Equal to True
  • Actions
  • For each (Integer A) from 1 to Configure_Max_Item, do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • ((Owner of (Triggering unit)) Current gold) Greater than or equal to AI_ItemCost[(Integer A)]
  • (Item-type of (Item carried by (Triggering unit) of type AI_Item[(Integer A)])) Not equal to AI_Item[(Integer A)]
  • Then - Actions
  • Hero - Create AI_Item[(Integer A)] and give it to (Triggering unit)
  • Player - Add (0 - AI_ItemCost[(Integer A)]) to (Owner of (Triggering unit)) Current gold
  • Else - Actions
this is the real trigger we just replace the gold with our custom value of unit

it will look like this

  • AI Item Buy
  • Events
  • Conditions
  • ((Owner of (Triggering unit)) is in AI_Players) Equal to True
  • ((Triggering unit) is A Hero) Equal to True
  • Actions
  • For each (Integer A) from 1 to Configure_Max_Item, do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • custom value of unit is greater or equal to item cost here
  • (Item-type of (Item carried by (Triggering unit) of type AI_Item[(Integer A)])) Not equal to AI_Item[(Integer A)]
  • Then - Actions
  • Hero - Create AI_Item[(Integer A)] and give it to (Triggering unit)
  • Set customgold_value = custom value of triggering unit - gold cost here
  • Else - Actions

there is alot more to edit if you want to remove unneeded memory but I'm way to tired atm
 
Level 12
Joined
Dec 17, 2009
Messages
951
oh ok guys, yeha im tired too
hmm can you guys still help me, maybe tomorrow, or further?

i ask you about the project thing, guys this is basicly the map core, so you guys need way more than +rep as thanks, credits on it whould be greath for you guys :)
 
Status
Not open for further replies.
Top