Little problem with addin - gold.

Ritmas

New Member
Reaction score
0
So basicly what I want to do is aaahm... I don't know how to explain. I'll give an example.

I have a unit [citizen] and he has a spell, when he activates he runs to townhall and gets replaced with Worker. But to cast the spell you pay 20g.
So everything works when only one citizen is selected, but when 2citizen are selected and cast it cost me not 40gold but 60gold, and if 3citizen it costs 120g or w/e.

I hope you get what I say. ;)
Here is my code:

Trigger:
  • Player - Add ((Number of units in Become_a_worker) x -20) to Player 1 (Red) Current gold


If you need whole trigger, ask. ;)
 

Ritmas

New Member
Reaction score
0
Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Become a worker
    • Actions
      • Unit - Change ownership of (Casting unit) to Player 2 (Blue) and Retain color
      • Unit Group - To Become_a_worker add units of player Player 2 (Blue) matching ((Unit-type of (Casting unit)) Equal to (==) Citizen (Male))
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 1 (Red) Current gold) Greater than or equal to (>=) ((Number of units in Become_a_worker) x 20)
          • Then - Actions
            • Player - Add ((Number of units in Become_a_worker) x -20) to Player 1 (Red) Current gold
            • Unit Group - Pick every unit in Become_a_worker and do (Actions)
              • Loop - Actions
                • Unit - Turn collision for (Casting unit) Off
                • Unit - Order (Casting unit) to Move To (Position of (First unit of group townhall))
          • Else - Actions
            • Unit - Change ownership of (Casting unit) to Player 1 (Red) and Change color
            • Quest - Display to (All players controlled by a ((Owner of (Casting unit)) controller) player) the Quest Update message: Not enough gold.
            • Sound - Play Error <gen>
            • Unit Group - Remove all units of Become_a_worker from Become_a_worker


second trigger:

Trigger:
  • Untitled Trigger 001 Copy
    • Events
      • Unit - A unit comes within 100.00 of Encampment 0000 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to (==) Citizen (Male)
      • (Owner of (Triggering unit)) Equal to (==) Player 2 (Blue)
    • Actions
      • Unit - Replace (Triggering unit) with a Worker using The new unit's max life and mana
      • Unit - Change ownership of (Last replaced unit) to Player 1 (Red) and Change color
      • Unit Group - Remove all units of Become_a_worker from Become_a_worker




It's just for testing, so it could have leaks and look fugly, but nvm.

P.S Any tip for making it better would be grateful. ;)
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
I have no idea... What's the relationship between selecting and casting?
 

Ritmas

New Member
Reaction score
0
I have no idea... What's the relationship between selecting and casting?

I mean I have 2citizens selected and make them cast same spell [like having multiple Footmen to cast defend] and insteed of costing 40g it cost 60g and w/e
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Ah. I know the problem. The spell is actually not casted together, at the same time. What warcraft is actually doing is casting the spell for unit 1, then casting for unit 2. If you look closely, the values are simple.

1 unit = 1unit gold
2 unit = 1 unit + 2 unit gold
3 unit = 1 unit + 2 unit + 3 unit gold

In other words, while the trigger is running for the first unit, 20 gold is already deducted, but before it is removed from the unit group, the spell cast from the other unit already deducted 40 gold, because there were 2 units in the unit group.


Edit: Okay, after further analysing, I'm wrong. The problem is, you're doing this ONLY in the else part, you're supposed to also do this in the then part.

Trigger:
  • Unit Group - Remove all units of Become_a_worker from Become_a_worker


Which means the trigger ran twice, first unit deducted, but first unit was not removed from the unit group, and trigger ran for the second time, counting 2 units, thus 60 gold.
 

Ritmas

New Member
Reaction score
0
Thanks for quick replies.
But where to put that action?
Anyway your suggestion doesn't work with my logic, but I can't explain it.
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Okay I posted a whole lot of useless junk there. Now what you're doing is:

Adding the unit to a unit group, removing the unit only if you have not enough money. If you have enough money, do not remove the unit from the unit group.

So the solution would be to remove the units from the unit group even if you have the money.

Now this line, it removes the units from the unit group, am I right?
Trigger:
  • Unit Group - Remove all units of Become_a_worker from Become_a_worker


Put this in the "If/Then/Else" part of trigger, so that when you ahve the gold, your unit is also remvoed from the unit group.

The final trigger should be this:

Trigger:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Become a worker
    • Actions
      • Unit - Change ownership of (Casting unit) to Player 2 (Blue) and Retain color
      • Unit Group - To Become_a_worker add units of player Player 2 (Blue) matching ((Unit-type of (Casting unit)) Equal to (==) Citizen (Male))
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Player 1 (Red) Current gold) Greater than or equal to (>=) ((Number of units in Become_a_worker) x 20)
          • Then - Actions
            • Player - Add ((Number of units in Become_a_worker) x -20) to Player 1 (Red) Current gold
            • Unit Group - Pick every unit in Become_a_worker and do (Actions)
              • Loop - Actions
                • Unit - Turn collision for (Casting unit) Off
                • Unit - Order (Casting unit) to Move To (Position of (First unit of group townhall))
            • Unit Group - Remove all units of Become_a_worker from Become_a_worker
          • Else - Actions
            • Unit - Change ownership of (Casting unit) to Player 1 (Red) and Change color
            • Quest - Display to (All players controlled by a ((Owner of (Casting unit)) controller) player) the Quest Update message: Not enough gold.
            • Sound - Play Error <gen>
            • Unit Group - Remove all units of Become_a_worker from Become_a_worker
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
If you don't mind, could you upload your map? Though you can try removing casting unit from the unit group instead, first.
 

Ayanami

칼리
Reaction score
288
Firstly, you could use "Starts the effect of an ability" rather than "Beings casting an ability". From what I understand, you basically want the ability to cost 20 gold on-use. And if there is insufficient gold, you won't be able to cast it. Then, just use this:

Trigger:
  • Become Worker
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Become a worker
    • 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 20
        • Then - Actions
          • Player - Set (Owner of (Triggering unit)) Current gold to (((Owner of (Triggering unit)) Current gold) - 20)
          • Unit - Change ownership of (Triggering unit) to Player 2 (Blue) and Retain color
          • Unit - Turn collision for (Triggering unit) Off
          • Set TempPoint = (Position of (First unit of group townhall))
          • Unit - Order (Triggering unit) to Move To TempPoint
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
          • Player Group - Add (Owner of (Triggering unit)) to TempForce
          • Quest - Display to TempForce the Quest Update message: Not enough gold.
          • Sound - Play Error <gen>
          • Player Group - Remove (Owner of (Triggering unit)) from TempForce


Although an ability is cast at the same time, the trigger runs separately for both units. So if you were to put a message "Hi" in the trigger, you would see that the message "Hi" is displayed twice even though you seemingly cast the ability for 2 units simultaneously.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top