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

Unit price change

Status
Not open for further replies.
Level 6
Joined
Feb 6, 2008
Messages
166
How do you change a unit's gold and lumber cost with triggers? Here is what I would like to accomplish:

In normal ladder games, the first hero costs no gold or lumber. I would like to set all of the heroes' prices to 0 gold and 0 lumber at map initialization. Then, I use "A unit finishes training a unit" with actions set to "For each integer from 1 to 8" and "If-Then-Else" with "Or Conditions" checking that the unit trained was a hero and that the unit trained belonged to player [integer 1-8]. The Then list would include setting the gold and lumber cost of all the heroes in the game for said player to the normal cost.

Confused? Sure. In short, I want to set the cost of all heroes to 0 gold and lumber at map initialization, and then set them all to normal cost when the player has trained their first hero.

Worst case, I can just double-up all the heroes, and use the same fix I did here:
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/berserk-upgrade-help-156881/
... by making all the heroes free, and then replacing all the free heroes with... "un-free" ones once the first one has been trained.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
You can't change the cost of a unit. Just like tooltips, they are not dynamic.

The best approach would probably be for you to create many versions of the same hero, at different gold/lumber costs. When the first hero has been trained, then you'll want to remove the "free" heroes from the player's tech-tree (Player - Set Unit Availability or something) in addition to adding the more expensive heroes to the tech-tree.

Ochibi said:
and then replacing all the free heroes with... "un-free" ones once the first one has been trained.

I just read this now.
 
Level 6
Joined
Feb 6, 2008
Messages
166
Make an ability based from "Charge gold and lumber" and adjust the prices/levels. Have it levelup based on how many heroes you've boughten, and when you click that ability it charges you gold and then create the hero via triggers when that ability is cast.

The other people helping me probably know this by now, since they've read a lot of stuff from previous questions, but this is an 8 player map, and I'm not liking the idea of having to set more locations/points and such "for integers 1-8" and whatnot. ^^; I'm probably going to stick with unit availability.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Bribe said:
and then create the hero via triggers when that ability is cast.

Personally I don't like your way either, because it would be blatantly obvious to the user that its an ability being casted and then the hero is being created alternatively, rather than having the hero being "trained".

Bribe said:
no wonder you can't find a project team to work with.

If this is how you would have handled this problem then I wouldn't want to be on a project team with you.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Again, upgrades don't train units. The only way you're going to get the hero trained is by giving the unit to the "Units trained" list and then training him in-game. The only way to "remove" a unit from the "Units trained" list is by changing the settings of unit availability.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Oh I see what you're saying. Problem here is you can't change the gold cost of upgrades. You would be in the same boat you were with the hero. Sure upgrades can increase in gold/lumber costs, but that is only the one specific upgrade that was researched. What Ochibi wants is every hero to go up in price (and probably for the trained hero-type to be unavailable).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
JASS:
constant native SetPlayerTechResearched takes player whichPlayer, integer techid, integer setToLevel returns nothing

I forgot you can set the level of upgrades. Yea it looks like upgrades may actually be a better method for this since it would only require 1 upgrade-object per hero, rather than having several for each "tier" of the hero. After each upgrade is researched, disable the availability of the researched upgrade and increase the level of the others.
 
Level 6
Joined
Feb 6, 2008
Messages
166
I've got an idea. I'll put it up here once I finish making the triggers.

Also, Unit-type of Trained Unit refers to the unit being trained in A unit Finishes training a unit. Is there any way to refer to the unit being trained in A unit Begins training a unit?

And say for example Hero B (Free) becomes unavailable when Hero A (Free) is finished being trained.
If they begin training Hero A (Free), and it's not finished, couldn't they queue training Hero B (Free)?

On the idea of using upgrades or abilities, what happens if I cancel "training" the hero?

Edit: This is kind of what I'm talking about. The idea is still to use copied hero units, but I'm trying to work out a conflict between using duplicate heroes and Limit training of Hero X to 1.

When FreeA is trained, set availability of FreeA FreeB FreeC and FreeD to unavailable, set availability of HeroB HeroC and HeroD to available. Then limit training of HeroA-D to 1. Then you can't get any more free heroes.

The only problem is that the free heroes should be set to unavailable as soon as you BEGIN training the first free hero.


Edit 2: Started making this, didn't like it:
  • First Hero is Free
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • For each (Integer ForLoop_Temp_Integer) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Paladin (Free)
              • (Owner of (Trained unit)) Equal to PlayerIndex[ForLoop_Temp_Integer]
            • Then - Actions
              • Player - Make Paladin (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Archmage (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Mountain King (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Blood Mage (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Archmage Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Mountain King Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Blood Mage Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Archmage (Free)
              • (Owner of (Trained unit)) Equal to PlayerIndex[ForLoop_Temp_Integer]
            • Then - Actions
              • Player - Make Paladin (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Archmage (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Mountain King (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Blood Mage (Free) Unavailable for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Paladin Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Mountain King Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
              • Player - Make Blood Mage Available for training/construction by PlayerIndex[ForLoop_Temp_Integer]
            • Else - Actions
And that's only for 2 heroes... Imagine... 11 races, 4 heroes each, meaning 44 heroes.
 
Last edited:
Level 2
Joined
Mar 25, 2008
Messages
11
This a shorter version of the free/unfree replacing problem. (I didn't check this in the editor)

Make 1 Integer which counts your races as well as 2 unittype variables and put your heros in them.
  • Init Map
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Race 1 --------
      • Set FreeHeroType[0] = Paladin (Free)
      • Set FreeHeroType[1] = Archmage (Free)
      • Set FreeHeroType[2] = Mountain King (Free)
      • Set FreeHeroType[3] = Blood Mage (Free)
      • Set UnfreeHeroType[0] = Paladin
      • Set UnfreeHeroType[1] = Archmage
      • Set UnfreeHeroType[2] = Mountain King
      • Set UnfreeHeroType[3] = Blood Mage
      • Set NumberOfRaces = NumberOfRaces + 1
      • -------- Race 2 --------
      • Set FreeHeroType[4] = Blademaster (Free)
      • Set FreeHeroType[5] = Far Seer (Free)
      • Set FreeHeroType[6] = Tauren Chieftain (Free)
      • Set FreeHeroType[7] = Shadow Hunter (Free)
      • Set UnfreeHeroType[4] = Blademaster
      • Set UnfreeHeroType[5] = Far Seer
      • Set UnfreeHeroType[6] = Tauren Chieftain
      • Set UnfreeHeroType[7] = Shadow Hunter
      • Set NumberOfRaces = NumberOfRaces + 1
      • -------- and so on... --------
  • First Hero is Free
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • For each (Integer A) from 0 to (NumberOfRaces - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Trained unit)) Equal to FreeHeroType[((Integer A) x 4)]
                  • (Unit-type of (Trained unit)) Equal to FreeHeroType[(((Integer A) x 4) + 1)]
                  • (Unit-type of (Trained unit)) Equal to FreeHeroType[(((Integer A) x 4) + 2)]
                  • (Unit-type of (Trained unit)) Equal to FreeHeroType[(((Integer A) x 4) + 3)]
            • Then - Actions
              • For each (Integer B) from 0 to 3, do (Actions)
                • Loop - Actions
                  • Player - Make FreeHeroType[(Integer B)] Unavailable for training/construction by (Owner of (Trained unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Trained unit)) Not Equal to FreeHeroType[(((Integer A) x 4) + (Integer B))]
                    • Then - Actions
                      • Player - Make UnfreeHeroType[(Integer B)] Available for training/construction by (Owner of (Trained unit))
                    • Else - Actions
            • Else - Actions

Originally posted by Ochibi
Also, Unit-type of Trained Unit refers to the unit being trained in A unit Finishes training a unit. Is there any way to refer to the unit being trained in A unit Begins training a unit?
Thats the only problem about the solution. I think there is no way to refer the unit being trained in A unit Begins training a unit.

I hope i could help you a little bit. :cneut:
 
Level 2
Joined
Mar 25, 2008
Messages
11
Yeah, I forgot about that. :csmile:
But fortunately there is the
  • Unit - A unit Stops training a unit
function.
The third trigger would be the second one, just inverted.
(If you meant that.)

EDIT: All (Unit-type of (Trained Unit)) should be replaced with (Trained unit-type). This works for begins, cancels and finishs training a unit.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Yea, but you'll still want to disable the alter during the process of a hero being trained otherwise multiple train-queues will really screw it up. The "Unit - A unit stops training" is not prompted by units being removed from the queue even though "Unit - A unit begins training" is (if you can never queue two units of the same type then you don't need to).
 
Level 6
Joined
Feb 6, 2008
Messages
166
Bug free is the priority.
Accuracy is second. More accurate is better, but it's not worth it if it's at the cost of being bugged.

I need to go to a workshop in a bit. I decided that for now, the most bug-free way is to work with unit availability. I've been working on new triggers, though. Something that might fix it all once and for all. When I finish it, I will post it up and see if anyone can find any bugs in it.

Edit: While I do want the gameplay to remain true to ladder gameplay, if the system is bugged and doesn't fully work 100% of the time, then one player could be disadvantaged when it isn't his/her fault, which I can't be satisfied with.

Edit 2: I solved part of the puzzle. "Begins training a unit" isn't just when you click to train the unit. It's when the unit begins being made, whether that be training a unit with an empty queue, or moving up the queue into the "being built" spot.

Edit 3: Questions.
Is there an order string for constructing a specific unit?
and Is there a way to put a gold/lumber/food symbol in the a tooltip?

Edit 4: I also tried this to get the order string myself, and it returned (null).
  • Trigger
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • Set OrderThingy = (String((Issued order)))
      • Game - Display to (All players) for 30.00 seconds the text: OrderThingy
 
Last edited:
Level 2
Joined
Mar 25, 2008
Messages
11
Edit 3: Questions.
Is there an order string for constructing a specific unit?
and Is there a way to put a gold/lumber/food symbol in the a tooltip?
Yes, the order string is the unitname (in most cases).
The orderstring of custom units is custom_**** (**** = rawdata number e.g. 'h001')

No, i dont think there is a way to put a gold/lumber/food symbol in a tooltip (if you mean an ability tooltip).

Edit 4: I also tried this to get the order string myself, and it returned (null).
  • Trigger
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • Set OrderThingy = (String((Issued order)))
      • Game - Display to (All players) for 30.00 seconds the text: OrderThingy

You have to use Unit - Issue order with no target if you want to return the order string.

I attached a map which contains my system. I tested it with footmen and it worked bugfree for me.
It's not the best way, i could do it much better in Jass but it's just a beginning.
 

Attachments

  • Unit price change.w3x
    15 KB · Views: 78
Level 6
Joined
Feb 6, 2008
Messages
166
Thanks, XmmmX99.
Works great, it's definitely usable and bug-free.

The only difference I can spot is that when I train FreeA and queue UnfreeB, and then cancel FreeA, it cancels UnfreeB, too, and I get my refund. In normal games, when I train the free hero and queue the costing hero, and then cancel the free hero, the costing hero begins being trained, and I can once again train a free hero.

It's a very minor difference, and chances are, no one will wait until Tier 2 to train 2 heroes at once, :eekani: and then change their mind about the first hero, and then change their mind again. :hohum: I'll probably be using your system, or maybe modify it a little. If you decide to make any tweaks or changes to your system, keep me updated.
 
Level 2
Joined
Mar 25, 2008
Messages
11
You're welcome.

The difference is only to prevent bugs and keep it simple. If you want a version without that than feel free to ask. I could do it much better in Jass if you want.

I found 2 small bugs in my current version:

(In the Start Training-Trigger)
  • Player - Make UnitTypeFree[((Integer A) + (Integer B))] Unavailable for training/construction by (Owner of (Triggering unit))
should be
  • Player - Make UnitTypeFree[(((Integer A) x 4) + (Integer B))] Unavailable for training/construction by (Owner of (Triggering unit))
(In the Cancel Training-Trigger)
  • Player - Make UnitTypeFree[((Integer A) + (Integer B))] Available for training/construction by (Owner of (Triggering unit))
should be
  • Player - Make UnitTypeFree[(((Integer A) x 4) + (Integer B))] Available for training/construction by (Owner of (Triggering unit))
That's because i was in a hurry. :csmile:
You would only notice the bugs if you add another race.
 
Level 6
Joined
Feb 6, 2008
Messages
166
Actually, if you don't mind, could you work on it in Jass? I really ought to start learning Jass, and I find that I learn best if I start off with examples relevant to my project, rather than those in tutorials. That's exactly how I started learning GUI. I was very lost when I read the tutorials, but when Maker started showering me with finished triggers, I pushed myself and managed to read his finished code to understand what did what. Thanks in advance.

I'm going to use the GUI version for now, so I can begin testing. By the way, you have credit for the hero training system.
 
Level 2
Joined
Mar 25, 2008
Messages
11
Ok, the Jass version is ready.
I tried to make it userfriendly and document it a little bit.
In the Init Map-Trigger is an explanation what each global variable stands for.
If you have any questions, feel free to ask me.
Thanks for the credits by the way. :csmile:

PS: Although I tested it about 10 times and it worked fine, if there are any bugs please message me.
 

Attachments

  • Unit price change.w3x
    16.5 KB · Views: 50
Status
Not open for further replies.
Top