• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Unit refer problem

Status
Not open for further replies.
Level 7
Joined
Mar 12, 2006
Messages
407
Ok Dudes i came up to a problem i cant solve on my own :(

The trigger i need should be something like this:

  • Event
  • Unit - A unit starts training a unit
  • Conditions
  • ...
  • Actions
  • set Unitvar = Unit being trained
Now the problem is there is no such function as Event Reaction - Unit being trained
theres only trained unit but trained unit only works if the trained unit finishes training
But i need to fire this trigger before the unit finishes :(

Anyone knows how i can get the trained units name ?
 
Level 7
Joined
Mar 12, 2006
Messages
407
I have a custom resource on my map and some units need this resource so i want to check which unit is trained so i can cancel training if the player doesnt have enough of the custom resource
It would be even better to just keep him from training that unit but i think thats not possible ?
 
Level 4
Joined
Sep 9, 2004
Messages
112
  • (Trained unit-type) Equal to YourUnit
then use this tho check your resource level
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (YourResource[Player]) Less than 350
    • Then - Actions
      • Actions if not enough
    • Else - Actions
      • Do nothing
 
Level 7
Joined
Mar 12, 2006
Messages
407
haha i was just about to freak out cuz my ui force player to hit esc didnt work and now u send this map
Thank you :D
I didnt use the wait ... annoying stuff :(

Ok here comes my next challenge :D

Now it cancels training if i dont have enough resources but if i click fast on build or if i click train and then really fast change the selected unit it will not cancel
Any solutions ?
 
Level 7
Joined
Mar 12, 2006
Messages
407
First of all thanks for your effort, i appreciate that :)
I already had a trigger pretty similar to what u did: (sorry for trigger tags :D )
  • unittable
    • Event
      • Map Initialisation
    • Conditions
    • Actions
      • Set trainedunittype[1]=Soldier
      • Set trainedunittype[2]=Knight
      • Set foodcost[1]=30
      • Set foodcost[2]=60
This sets the unittypes and its foodcosts

  • unittrain
    • Event
      • Unit - A unit starts training a unit
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Trained unit-type) equals trainedunittype[(Integer A)]
            • 'THEN'-Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • food[(Player number of (Owner of (Triggering unit)))] < foodcost[(Integer A)]
                • 'THEN'-Actions
                  • Wait 0.01 seconds
                  • Spiel - Force (Owner of (Triggering unit)) to press Escape/Cancel
                • 'ELSE'-Actions
                  • Set food[(Player number of (Owner of (Triggering unit)))] = (food[(Player number of (Owner of (Triggering unit)))] - foodcost[(Integer A)])
            • 'ELSE'-Actions
By pressing fast hotbuttons i could manage to build more units then i should
I tried the map u posted, your version was better but i have around 30 to 40 units so i prefer to do it as a loop. 6 is just a testnumber right now

I added this:
  • Player - Make (Trained unit-type) not available for training/construction by (Owner of (Triggering unit))
and of course reversed it at the end of the trigger
This prevented me from spamming one unit but i still can do it if i have 2 different units to train and press both hotkeys same time very fast
maybe most people wont discover these possibilities but you know it can ruin the game :(
 
Last edited:
Level 7
Joined
Mar 12, 2006
Messages
407
Ok after having tried different trigger types i discovered the ultimate cheat proof version.
It showed me that the whole direction of developement was wrong :)

Unit - Unit starts training isnt capable of doing what i wanna do
If you can afford to train the first unit but cant afford the following ones this event wont detect the ones that follow
You can only cancel units if it is the first to be trained
so... thx for your help, rep to everyone and now i have to find a way to make it work :/
 
Status
Not open for further replies.
Top