check if building is training a unit?

rescue-hero

New Member
Reaction score
1
hi,

i want to ask if i can check if an building is training a unit atm?
cause i need this for one of my triggers and i cant find any solution :(
tried it with string order "train/upgrade" but that isnt working, because string orders are normally abilities...

please help,
rescue
 

Necrach

You can change this now in User CP.
Reaction score
62
maybe you could set all units starting to train units in a unit group, and remove them from the unit group when they finish.. then check when you need if the unit is in the unit group!

Trigger:
  • t1
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from unitgrouptraining


Trigger:
  • t2
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from unitgrouptraining


Trigger:
  • t3
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
    • Actions
      • Unit Group - Add (Triggering unit) to unitgrouptraining


I am not SURE this will work if the unit is training several units in a row..
 

rescue-hero

New Member
Reaction score
1
ive one problem...

is there a way to add only units which build specific units to this group?

cause i cant find any reference that is working :/

its the problem i described in my other post...

if:
trained unit? or what else? is unit "example" then add triggering unit into unit group

see what i mean?
 

Necrach

You can change this now in User CP.
Reaction score
62
Use the condition Unit-Type comparison

Trigger:
  • Conditions
    • (Unit-type of (Trained unit)) Equal to your unit


EDIT: make or/ conditions if you have several unit types that should fit into the trigger.
 

rescue-hero

New Member
Reaction score
1
xD you think im a mapping noob^^

thats funny ;)

i will see if i can implement these simple triggers into my trigger...

thanks...
 

rescue-hero

New Member
Reaction score
1
now, in my worldeditor trained unit isnt working with the "a unit starts to train a unit" :(

Trigger:
  • eg1
    • Ereignisse
      • Einheit - A unit Fängt an, eine Einheit auszubilden
    • Bedingungen
      • Or - Any (Conditions) are true
        • Bedingungen
          • (Unit-type of (Trained unit)) Gleich 001 HOLZ
          • (Unit-type of (Trained unit)) Gleich 002 STEIN
    • Aktionen
      • Wait 0.01 seconds
      • Einheitengruppe - Add (Triggering unit) to einheitrestart3
      • Spiel - Display to (All players) the text: +++



it isnt showing the + so it isnt adding it to the group...
the 0.01 secs delay start this trigger after the other 2 triggers, so that the unit is removed and added again if its building more units in a row...

I´m getting stupid, cause i tried everything!
:confused::banghead:

is it working in your WE?

without conditions it is working...

sry for german WE...
 

Necrach

You can change this now in User CP.
Reaction score
62
hmm.. seems that I was wrong, "Trained unit" is only for "Finish training a unit" event and it is impossible to check the unit type of a unit not yet in-game. :(

is it a specific unit training HOLZ and STEIN, and that isn't training any other units? because then a simple "unit type of triggering unit equal to (trainer of HOLZ and STEIN)" could work..

otherwise, (this would seem a little buggy, though) you could make a requirement for the HOLZ and STEIN units that is not enabled, so that you cannot click on them to train them. then add an ability to the unit, and its when you use that ability that the unit starts training (requirement is set for half a second, the unit starts training and then its disabled again). this way, the building training the units is acutally using an ability every time they start training the unit, and you can place it in the unit group! the bad side of this is that a disabled icon for training the unit will show, beside the ability icon (that also cannot show gold cost) :eek:
 

rescue-hero

New Member
Reaction score
1
yeah i already thought the first solution, but i need the reference for an unit, which has been started to build for another trigger, so im searching for this, in hope to get an answer to solve this problem...

maybe it could work with jass, anyone could explain me how?
could i just write an custom line or do i have to write a complete jass trigger :(

i will see...

thanks necrach for helping, i will chose the first solution for this trigger...
if anyone has an idea to have the reference, just tell me in this thread...

dont really knowing if i will get an soluion for this reference,
rescue

edit:
here is another one who have the same problem:
http://www.thehelper.net/forums/showthread.php?t=38732
 

SayNoToWar

Member
Reaction score
3
You can use:

"event reaction - trained unit type"

Thats the only way to react on a unit beeing trained (not on the trainer of course - the trainer is the triggering unit).

As said b4 you can not reference to a unit which does not yet exist.
 

rescue-hero

New Member
Reaction score
1
yeah, thanks, i didnt saw this reaction ;)

think it will work now, atm im trying if its working =)

i was really wondering if there wasn´t a chance to get the trained unit type =)

THANKS...

edit:
It`s working now =)
 

Necrach

You can change this now in User CP.
Reaction score
62
You can use:

"event reaction - trained unit type"

Thats the only way to react on a unit beeing trained (not on the trainer of course - the trainer is the triggering unit).

As said b4 you can not reference to a unit which does not yet exist.

Nice :thup: never noticed this either :rolleyes:
 

rescue-hero

New Member
Reaction score
1
theres only one problem...
i will have many units in this map and i dont want to set them all in this triggercondition...

theyre all have 3 numbers at the beginning of their name:
001 holz(wood)
002 stone
.
.
.

but this condition isnt working:
Trigger:
  • Or - Any (Conditions) are true
    • Bedingungen
      • (Trained unit-type) Gleich 001 HOLZ
      • (Trained unit-type) Gleich 002 STEIN
      • ((Integer((Substring((String((Trained unit-type))), 1, 3)))) / (Integer((Substring((String((Trained unit-type))), 1, 3))))) equal 1
      • ((Integer((Substring((String((Trained unit-type))), 2, 4)))) / (Integer((Substring((String((Trained unit-type))), 2, 4))))) equal 1

because the unit-type name is for example:
custom_h001
custom_h002

i could make it similar to this, but then i ve the problem, that i ve to delete all own units, which shouldnt be in this trigger...
If i make it with a loop i will have the same problem, except when i know everynumber of every specific unit, then i could make for each integer a from 1 to 4
from each integer a from 10 to 17

but i think thats no solution

a hashtable with reference to the unit type also wont work...
save 001 Wood as custom_h001 of 1(or sth else)
the problem is, that i only can save the string 001 Wood as "integer" of "integer"

is its possible to get the unit name of the unit which is trained?
problem:
the unit doesnt exist!
so i cant get the unitname so easy...

is its possible to get the unitname out of the unittype?

should be, because i set them in the object editor...

if its impossible, just say it ;)
then i will have much more work, but i think heres someone who can solve this problem ;)
 

SayNoToWar

Member
Reaction score
3
If you want to convert a unit type to a string use Convert (ger: Umwandlung) - Convert unit-type to string


I think you should avoid this:
Trigger:
  • Or - Any (Conditions) are true
    • Bedingungen
      • ((Integer((Substring((String((Trained unit-type))), 1, 3)))) / (Integer((Substring((String((Trained unit-type))), 1, 3))))) equal 1
      • ((Integer((Substring((String((Trained unit-type))), 2, 4)))) / (Integer((Substring((String((Trained unit-type))), 2, 4))))) equal 1
(Btw what does the second one do? Shouldnt one be enough?)

At last this looks like alot less cpu-work to be done...
Trigger:
  • Or - Any (Conditions) are true
    • Bedingungen
      • (Trained unit-type) Gleich 001 HOLZ
      • (Trained unit-type) Gleich 002 STEIN

But you should use global variables because I guess you will have to use your ressources again and again. Set one Integer to the number of unittypes you use as ressources (+1), and then set the unittypes as an array. Then to check if the trained unit type is one of the ressources use a loop going through all ressources.
 

rescue-hero

New Member
Reaction score
1
rescue-hero said:
i could make it similar to this, but then i ve the problem, that i ve to delete all own units, which shouldnt be in this trigger...
If i make it with a loop i will have the same problem, except when i know everynumber of every specific unit, then i could make for each integer a from 1 to 4
from each integer a from 10 to 17

-.-
thats what i mean with loop...
and of course i would set a variable-.-

why you think my condition costs cpu power?

there are 2, because i have one unit called 001 wood
and S001 Wood
k?^^
please accept that im no mapping noob, just because im asking this simple question!?

i just want to know if theres ANOTHER way to do that...
 

SayNoToWar

Member
Reaction score
3
well doesnt matter ;) it was just a suggestion, not a debug. I hope you solved the problems. :)

Edit: doesnt your if leak strings?
 

rescue-hero

New Member
Reaction score
1
yeah i dont think so too...

the problem exists atm...

unitname: 001 wood
unittype: custom_ h001

the 001 doesnt belong to each other, could be 001 and 010...

i want to know, if i can load the unitnamestring if the unit doesnt exist, only the unit type...
because the triggering unit starts to train a unit...

please help,
rescue
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
i am not really getting your problem, could you maybe try to clarify what exactly you want your trigger to do?

as far as i got i believe what you are looking for is a trigger which runs when any unit (generic event) begins the training of a unit whichs type is equal to "whatever1" or "whatever2".
if thats it your problem has already been solved...
 

rescue-hero

New Member
Reaction score
1
thats the first problem and its solved, my second problem is, that it will be much work, cause it will be a economy map and i will have to put MANY units in there...
but i think i would handle it, now i ve another problem that ive a hashtable where are the current amounts of the ressources are saved, when a unit beings to train a unit, i want to reduce the specific line in the table for an specific number...

my system:
001 wood-needs for example 000 test

if a unit begins to train a unit

conditions:

actions:
save (the current amount-the amount produced) as integer(substring(unitname(trained unit)1,3))) of 1

thats an easy explanation of my system, dont want to explain it in detail, ive 2 other tables, which gives the numbers which have to be reduced...

got what i want?

edit:
so because theres no "unitname" only "name of unittype" its impossible to solve...
i need the unitname, in this example 001

it loads from hashtable 3 which number is reduced
it gets from hashtable 2 how high it is reduced?
and then my trigger saves the new value in hashtable 1 for example for item 000
 

SayNoToWar

Member
Reaction score
3
ok sry, forgot that strings cant leak.

But you can not load the name nor anything else of a unit who doesnt exist. But i think the name of the unittype should be same as the name of the unit exept if the unit is a hero.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top