Creating units using triggers

Dangime

New Member
Reaction score
1
Hello, I am new to the forums. I apologize if what I am asking is covered in another thread or in a tutorial I missed.

Thanks to the numerous tutorials on this site I've made alot of head way into making my first map. Right now I've hit a stumbling block on my triggers for creating units.

I had planned to create units by checking for the continued existance of serveral buildings (one for each player) inside the base. If the existance was confimed, then a set of units is produced for the allied AI, then I hoped to send them off to fight the enemy. 5 upgrades are available, so I can give more and better units after the upgrade.

I felt like I made a trigger than would successfully work, for the first level of the building. I used a boolean comparison to check to see if the particular building was still alive, then had the even make the units I want. (I still need to figure out how to force the AI to send them out to die, but that's not my only problem right now).

But then I thought, what about when the player upgrades the building? There's not a way for me to check for a building being alive if it doesn't exist yet (to my knowlegde).

I struggled looking for a condition that would work like, if unit is upgraded to X, but I didn't find any option like that.

Any advice you can provide is appreicated
 
Well, for that you need to use variables. If you haven't yet, read this tutorial:
http://www.world-editor-tutorials.thehelper.net/variables.php

You need a trigger that fires whenever a unit upgrades. Then you can set the new upgraded unit to the variable, and check if it is alive later using that variable. As for the AI, I'm not quite sure.

If you have any more trouble, post your trigger here. You can right-click the trigger and do "Copy as text" and paste it here.

(Hi, welcome to the forums. I'm happy! Another new person that uses correct spelling and punctuation! :D )
 
Code:
Spawning
    Events
        Time - Periodic event - every 30.00 seconds of the game
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Peasant 0001 <gen> is alive) Equal to True
                    Then - Actions
                        Unit - Create 4 Footman for (Owner of Peasant 0001 <gen>) at (Position of Peasant 0001 <gen>) facing Default building facing degrees
                        Unit Group - Pick every unit in (Last created unit group) and do (Unit - Order (Picked unit) to Attack-Move To (Player 12 (Brown) start location))
                        Unit - Create 2 Rifleman for (Owner of Peasant 0001 <gen>) at (Position of Peasant 0001 <gen>) facing Default building facing degrees
                        Unit Group - Pick every unit in (Last created unit group) and do (Unit - Order (Picked unit) to Attack-Move To (Player 12 (Brown) start location))
                        Unit - Create 1 Knight for (Owner of Peasant 0001 <gen>) at (Position of Peasant 0001 <gen>) facing Default building facing degrees
                        Unit Group - Pick every unit in (Last created unit group) and do (Unit - Order (Picked unit) to Attack-Move To (Player 12 (Brown) start location))
                    Else - Actions
                        Do nothing
[Note: To use code use
Code:
 and [COLOR=Black][/co[/color][COLOR=Black]de][/COLOR] tags]

You will need to replace Peasant with a variable [with an index size of 10, for 10 players, also change the for each integer 1-10 to 1-<number of players>]
Also, when you check if the unit is alive you may want to check its owner to. If its ownedby player 1 then attack player 12, if owned by player 12 attack player 1 etc.

Other than the missing fields, you just need to either get this to work per player [remove for each integer part] or get a system to work with variables [for using for each integer]

NOTE: For each integer is a basic loop, if its 1-8 it runs 8 times, 1-12 is 12 times, 5-12 is 7 times etc. You can also refer to the current loop as 'For integer A' in integer fields. Also use integer B if you need an integer within an integer.
 
For the computer to die i think you mean for it to move and attack your base kinda like dota, to me thats not really an Ai i think thats more of a trigger.

Event: periodic event- Every 200secs of the game
Condition:
Action:Units-Create 5 footmen at the center of region "footmanspawn"

Now for the the computer to move to get killed or kill

Event: Periodic event- every 200.1 secs
Condition:Triggering Unit = footman
Action: Unit Group- make every unit in region "footmanspawn" move/attack to region "attackzone".

Sometimes they might go another path to the "attack Zone then you want so you just make like points like a 1/2 point or 1/4 and keep making the units that enter that region to go to the next region and to the next until they get to the "attackzone"

Some of the things in the trigger you might have to modify like instead of having footman you wanted idk uhh.. Zombie switch the unit to zombie instead of footman and you might want to midffy the # of units cause i only put 5 but for all I know you might want 10 to spawn and the region could be named differtly.

Hope this helps with the coomputer attacking you. Talk to me again cause i was a little bit confused with your post.
 
Dangime said:
I struggled looking for a condition that would work like, if unit is upgraded to X, but I didn't find any option like that.
You mean, like a Boolean Comparision? Like how the existing ones are for alive, dead, etc., you just want one along the lines of "<town hall> is upgraded to Keep"? Unless I'm misunderstanding, you can use Unit-Type Comparision and check "(Unit-type of <town hall>) Equal to Keep"...
 
Thanks for all the help so far. I think it will definately help. Let me explain a little better. I think most of you got what I was asking for, but I'll try to clear it up more.

You are right that it is a DOTA or TOB style map.

My plan is to have the existance of a building, one belonging to each player, activate a trigger if it is still alive that will produce units for the allied AI.

The problem occurs when the player upgrades the building. I'm not sure how to write the trigger to make the better units after the upgrade is done, since it doesn't exist yet.

I think the answer does lie with the variables and a trigger that goes off on every upgrade. I'm going to investigate that now.


The moving problem is secondary since if I can't make the units properly there's no need to move them, but thanks for the help there because I'll want to move them if I ever get that far.
 
Heptameron said:
You mean, like a Boolean Comparision? Like how the existing ones are for alive, dead, etc., you just want one along the lines of "<town hall> is upgraded to Keep"? Unless I'm misunderstanding, you can use Unit-Type Comparision and check "(Unit-type of <town hall>) Equal to Keep"...

Yes, but this particular building I've made isn't a town hall. I just based it off a farm, then changed the arts for 5 different upgrades to represent a better capacity to make units. I guess I could change the buildings and do it that way, but only having 3 levels would limit my options.
 
Instead of changing the model of the farm for each upgrade, replace the farm with its upgraded version. You'll want a different structure for each upgrade, but they can all be based on farm if you wanted. Give them all different names, and refer to them for the correct spawnage. GL
 
Make all your spawning triggers, like this:

Code:
Spawning Trigger 1
Events:
Every 55 seconds of game time
Conditions:
Actions:
For each integer from 1 to 3 do actions
Unit - create 1 footman at <your region>
Unit - order last created unit to attack-move to <enemy region>
For each integer from 1 to 1 do actions
Unit - create 1 rifleman at <your region>
Unit - order last created unit to attack-move to <enemy region>

That trigger represents your first level spawn, so the building hasnt been upgraded.

Code:
Spawning Trigger 2
Events:
Every 55 seconds of game time
Conditions:
Actions:
For each integer from 1 to 3 do actions
Unit - create 1 knight at <your region>
Unit - order last created unit to attack-move to <enemy region>
For each integer from 1 to 1 do actions
Unit - create 1 mortar team at <your region>
Unit - order last created unit to attack-move to <enemy region>

That trigger represents your second level spawn, so the building has been upgraded once. This trigger is initially off, as are all other spawning triggers except for the level 1 spawning trigger


Then you would need something like this

Code:
Events:
Unit - Unit finishes upgrade
Conditions:
Unit - Upgrading unit equal to spawning farm  - [I]Here, you may need an 'Or - Multiple Conditions' and then put in all of the types of spawning buildings you have for this team.[/I]
Actions:
Set UpgradeLevel to UpgradeLevel + 1
Trigger - Turn off SpawningTriggers[(UpgradeLevel)- 1]
Trigger - Turn on SpawningTriggers[(UpgradeLevel)]

You would then need to make a trigger that stops units spawning when the building is killed:

Code:
Events:
Unit - A unit is killed
Conditions:
Unit - Dying unit equal to Spawning Farm  - [I]You may also need to put in a 'Or - Multiple Conditions' in here, with all the types of spawning buildings for this team[/I]
Actions:
For each integer from 1 to 12 do actions
Turn off SpawningTriggers[(Integer A)]

You would need 2 variables for this to work:

UpgradeLevel an - Integer variable.

SpawningTriggers - a Trigger variable with an array the size of how many spawning levels you want.

Also note:

Iif you have more than one spawning building then you would need to have more sets of these triggers. i.e if you had 3 spawning buildings, you would have to have 3 sets of the above triggers, with modified conditions, and spawned units.

'For each integer from 1 to __' For action in the spawning triggers, change the blank number to how many of that unit you want to spawn.

I don't have WE on here right now, so this is slightly inaccurate information, but im 99.9% sure it can be done.
 
If you have a "Unit - a unit Finishes an upgrade" event, what do you use to get the upgraded unit? :confused: There is no "Event Response - Upgraded unit".

EDIT: 200th post! :D
 
Well I am not an expert but I solved the problem in a roundabout way. The only reason that it worked was the fact that each player character only had one structure of his or her own, the upgrade building.

I made 10 values called player1basevalue, etc.

I used a player specific "unit finishes an upgrade" command to itterate the base value, then I was able to condition the various levels of spawns I wanted based on the basevalue. I used the fact that the players only had one building to use a player owned unit dies command with a condition that it was a building. In that case, the value is set to 0, and no new units come out.

I made a more complicated set of triggers using player1base as a unit variable, and the same techinque to reassign the variable (player last constructed building), but in the end I didn't use it for anything.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    Luckily I live in an age with electricity so it's way fucking faster, but when I was just a boy trying to find my place I had some hardcore chefs that made use do things like that by hand. It is WAY easier to get right by hand because you control it and can feel it, but it takes soooooo much longer. And on the scale a modern kitchen requires... I serve 400-500 guests on average per day right now, if I had 100 then we could do things way better
  • Varine Varine:
    But we can't do that. In the winter yeah, but I HAVE to get people through here right now so I can afford the staff that we CAN do that. We have about 100 days of summer, and if that summer doesn't make us what it will, then I can't operate the other most of the year with my staff. The owner is talking about closing two days a week to cut down on labor, I told him he should cut down on vacations and it did not go great. I do think I won though, I have to keep my fucking core staff and they have to be gainfully employed
  • Varine Varine:
    Sure some of them might take a second job, but I can't just cut my entire staff to unlivable hours, nor can I can cut them off all winter if I want them to come back.
  • Varine Varine:
    And also, there is no fucking way I'm pulling these hours come september. I only do this right now because I have to, the second I don't have to be the one doing it I won't be
  • Varine Varine:
    I have a 5 person core staff in the kitchen, not including me or Chef Ben
  • Varine Varine:
    Though two of those people are likely not making it this year. One of them has been replaced, the other I am kind of trying to. He's being a giant bitch, today I had to get onto him because in the three hours before I left he had taken like thirty minutes for cigarette breaks
  • Varine Varine:
    And he was also complaining to me the other day that he was out of weed so couldn't smoke any before work that day, and was confused about why I was annoyed he was telling me, his boss, that he is smoking weed everyday before work.
    +1
  • Varine Varine:
    Like yeah I can tell. I don't need to fucking know.
  • Varine Varine:
    So now he's getting scrutinized and will not be top of the list. I know I don't have the smartest people but I do expect them to have some common fucking sense
  • Varine Varine:
    I did do a rare thing for me and hire a girl last month without warning. Everyone was made at me because I started her at like 21, but she worked with me before and I was like don't care. She made 19 at her old job and I wanted her to come work with me, she is the best
    +1
  • Varine Varine:
    I'm going to get her a raise at the end of the summer. She wants to go to school again, but I want her to still work with me so.... she kind of can just tell me what the price is. I can go to 25 if she keeps up. I need to get her onto line more, that's what she wants, but I need her where she is and it's not fair that she doesn't get the little bit of raise that comes with it. She can do it no problem, I've worked with her there.
  • Varine Varine:
    It's just hard to move and train people unnecessarily right now. And also the line fucking sucks, it's not any more fun. This is turn and burn so I have the bankroll, and everyone suffers for it
  • Varine Varine:
    Eventually we'll get it balanced, we'
  • Varine Varine:
    we're starting online orders and stuff, but I also turn that off all the time because I barely keep up trying to be the best at Sysco shit
  • Varine Varine:
    I think it's gonna be a good fall and winter though. We're going to have a good staff, they will get along, they will be able to manage the workload and the complications, they know how to really cook this year, like every person on line knows their steak temps. Some of them use thermometers a lot and they don't always use them right, but they do know how to do it. Failure, especially in this field, is the only way to get better. They'll get it
  • Varine Varine:
    They won't get feel down while they do the thermometer, but we didn't have an instant read probe when I was learning. Like they did but god knows how off it is, you HAD to do it by feel. Even if the chef was fine with me bringing my own, it takes too long. Poke and know
  • The Helper The Helper:
    420 threads in the Artificial Intelligence forum :)
  • The Helper The Helper:
    Happy Monday!
    +1
  • The Helper The Helper:
    and then it was Tuesday!
    +1
  • The Helper The Helper:
    fyi I am going out of town to lake somewhere in bfe texas for the weekend will be gone Friday morning to sunday afternoon for a paranormal thing and some rest peace
  • jonas jonas:
    cool take it easy
  • jonas jonas:
    I recently had an experience with a waiter that really brought down @Varine's point about them being in sales. The first waiter just asked "anything else? deserts?" and when the table shook their head said "ok" and left. Then the other waiter came in and started going off describing the deserts and you could see the heads turning, and they finally got a bunch of deserts
  • jonas jonas:
    makes sense if you consider that the tip is basically a commission on sales

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top