Hiding a Bulding's Ability to Train a Unit

S

Setreal

Guest
I searched but couldn't find anyone who even asked this question so hopefully it's possible. For the trigger "Unit - Issue Train Order" a building must already be able to train a certain unit for you to be able to order it to do so through triggers. The problem with this is I want to only be able to order buildings to train units via triggers and not let players train units on their own. So the either I need to be able to...

1) Be able to order a building to train a unit via. triggers despite not normally being able to train that unit.

OR

2) Completely hide the ability for a building to train a certain unit (i.e. player doesn't see an icon for the unit and can't click anything to manually train the unit). This would allow me to order the building to train the unit via triggers but not allow the player to see the ability to train the unit or be able to manually train the unit.

Thanks in advance.
 

zll7

New Member
Reaction score
17
So you want the player to be able to see the unit train?

It may be passable to make it so that if a player try to click on the icon that it cancels the training... however I have tried to find a way to remove training and there is no trigger as far as i last know.... So you would have to be creative and find a way...
 

TheCrystal

New Member
Reaction score
36
Theres a trigger which sets the max

Set trainable max number of UNIT for PLAYER to X
or something. I know I've seen it.
 

mikevisoni

New Member
Reaction score
3
Ok If i get what ur saying this shud work. USING AN ORC WARCHEIF AS EXAMPLE

Code:
Event-
Unit - A unit owned by Player 1 (Red) Finishes training a unit

Condition-

Action-
If ((Unit-type of (Trained unit)) Equal to Orc Warchief) then do (Player - Make (Unit-type of (Trained unit)) Unavailable for training/construction by (Owner of (Trained unit))) else do (Do nothing)
 
S

Setreal

Guest
I currently have it so that at game initialization it sets the limit for training the unit to 0. The problem is when it's at 0 you can't train the unit via triggers either. So what I've done is have it so that when I want to train the unit via trigger I set the limit to 1 and then give the order and then when the unit completes set the limit back to 0. The only problem with this is if the player cancels the unit (which I want the player to be able to do). There's an event to detect when a player cancels a unit but there's no corresponding name to use for setting the limit back.

For example:
Player 1 finishes training a unit.
If trained unit is equal to "unit type" then set limit for "unit type" to 0.

When it comes to canceling a unit though there's nothing to replace 'trained unit' with. Is it something odd like triggering unit or some such?
 
S

Setreal

Guest
Basically I figured out a simple way to be able to order a building to train units without the player being able to see or train them. See below if you're interested though alot of stuff is cut out so it's more clear. The units/spells here are just examples so it's easier to understand.

Code:
Initialization (The actions here should be part of whatever your start of the game trigger is.)
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Player - Limit training of Footmen to 0 for (Player((Integer A)))
                Player - Limit training of Riflemen to 0 for (Player((Integer A)))
                You can keep doing this for as many units as you want that you  only want a building to train via. triggers.

Code:
Spell Reactions (This is an example of a trigger where something happens that makes you want to order the building to train one of the aforementioned units).
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to Firebolt 
                (Level of Firebolt for (Casting unit)) Equal to 1
            Then - Actions
                Limit training of Footmen to 1 for (Owner of (Casting unit))
                Unit - Order (Casting unit) to train/upgrade to a Footman
                *Limit training of Footmen to 0 for (Owner of (Casting unit))*
             Else - Actions
                Do nothing

Before now I didn't have the line that I asterisked but rather was trying to detect when the unit finished or was canceled to set the limit back to 0 as seen below.

Code:
Unit Finishes
    Events
        Unit - A unit Finishes training a unit
    Conditions
        (Unit-type of (Trained unit)) Equal to Footmen
        Insert all the unit types you mentioned in the initialization trigger
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Player - Limit training of Footmen to 0 for (Player((Integer A)))
                Insert all the unit types you mentioned in the initialization trigger

The issue I was having in my last post was what to put in place of 'triggering unit' in the trigger below to detect whatever the canceled unit was. This isn't important anymore since I figured out another way to do it (see top of post) though if someone knows I'd be interesting in knowing what to do if for some reason I needed to detect a canceled unit sometime in the future.

Code:
Cancels Unit
    Events
        Unit - A unit Cancels training a unit
    Conditions
        (Unit-type of (Triggering unit)) Equal to Footmen
    Actions
        Player - Limit training of Footmen to 0 for (Owner of (Triggering unit))
 
R

Ricky

Guest
Hi

Hi~Ricky

Righty-ho! I can sort out what i believe to be your problam though i might have got what you want completely wrong lol!:D Right do you want it so a building can create (a) unit(s) but the player cannot see that it can? Well if that be what you want i have 2 solutions: 1. well baisically you could just make it create the unit next to the barracks/training building. or 2. You could make an ability based off the item ability armour bonus make it into the ability to build things and uncheck the item ability box, after taking off the effects of armour bonus. The giving it to the barracks/training building, so then you could simply order it to make a unit and the player has no control over it!

I hope this helps:eek:
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Or you could make the barrack be owned by another player, and when the unit is finished it changes control to you. Then you need a dummy unit which is selected when you select the barracks. This unit has dummy abilities to order the barrack to train different units.
 
S

Setreal

Guest
I guess I'm being confusing again. My last post was the solution I found, so the problem is solved. Thanks for trying to help though.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Adding "Ward" in "Stats - Unit classification" hides the command card.
As such, you can't order anything (obviously, there's no button to push).
No, hotkeys don't work either.
Though, yes, a trigger can still order whatever.

But, you can't cancel anything either...


On a related note:

Event:
- A unit is issued an order with no target
Conditions:
- (Issued order) equal to Order(Footman)
Actions:
- Unit - Set custom value of (Triggering unit) to 1

Event:
- A unit is issued an order with no target
Conditions:
Actions:
Custom script: if GetUnitUserData(GetTriggerUnit()) == 1 and GetIssuedOrderId() == 851976 then
Game - Display to (All players) the text: "We canceled a Footman"
Unit - Set custom value of (Triggering unit) to 0
Custom script: endif

Event:
- A unit finishes training a unit
Conditions:
Actions:
- Unit - Set custom value of (Triggering unit) to 0


Unverified, but should do it :p

Note:
This will fail if you try to queue several build orders...
But, since you're doing all the training by triggers anyway, you have the custom value to check.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top