EDT 09:27 CEST 15:27 KST 22:27

Streams: 91 live
68398 total viewers

Active: 8272
[WCS AM] Premier League Ro…
TI3 East Qualifier Preview
[WCS AM] Challenger Round …
StarLadder Season Six Prev…
[SPL] Round 5 Week 3 Previ…
TeamLiquid Map Contest Fin…
Liquid wins the Curse Invi…
mousesports defeats DD.Dot…
Dragon joins Clarity Gaming
Code S Group of Death, Par…
Axiom.Miya Retires
This Week in Starcraft 2: …
tradimo - $36,000 stock pi…
TL Advertising Features
[TV/BOOK] *SPOILERS* Gam…
[Manhwa/Manga] Tower of …
Rossi's energy catalyzer
Fountain Pens
Syrian Civil War
TL.net Ten Commandments
Barcraft @Marseille - WCS …
The Automated Ban List
Presenting Store 2.0
WCS EU Finals - Essex Barc…
The HelloKitty Fanclub
The Snute Fanclub
[Stream] ASL in Korea
[BW Stream] Sabas[AoV]
[G] Streaming with OBS (Op…
Buying a Desktop computer.…
Teamliquid Page Bug ?
Teamliquid freezing in Chr…
Computer Build Resource Th…
SPL - Appreciation Thread
Congratz to Nathanias fo…
[Series/Song] Unit Rap B…
GM / Master map hacker a…
SC2 HotS Global Ladder R…
Twitch.tv needs to impro…
[SPL] Team 8 vs. KT Rolste…
£400 SC2Improve Summer Lea…
Discover Your Energy StarL…
[ATC] ROOT vs MVP, Week 8
[SPL] Samsung KHAN vs. EG-…
[G] Analysing Replays
The HotS Protoss Help Me T…
The HotS Terran Help Me Th…
[H] ZvP 1gate expo into pr…
[H] ZvT problems with Mech
TeamLiquid Map Contest Fin…
TeamLiquid Mapping Contest…
[A] Starbow
Map Jam & Challenge #5
[R] HoTS YABOT
Liquid wins the Curse In…
TI3 East Qualifier Preview
General Discussion
Dota 2 QQ thread
Pick Your Lane - Dota2 m…
The International Intera…
[The International] Easter…
[TPL S5] Demon Edge Cup
Sticky Flames Weekly Dota …
[The International] Wester…
Perfect World's Dota 2 Su…
Simple Questions, Simple A…
A guide to Krobelus, the D…
Solo Mid - Who? What? How?
Newly ported Hero discussi…
[Guide] Storm Spirit by Bl…
Help running tournament
Better Server Registry F…
The Swedish Brood War In…
SC2 Player looking to le…
TeamLiquid Legacy Starle…
sAviOr vs NaDa
[TLS2] Qualifier #4
Torenhire Starleague II
Defiler Tour #57 [75$]
D Ranks Teamleague Season 4
[GC S3] Gambit's Cup Semif…
Simple Questions, Simple A…
Tips and tricks: Defilers …
Practice Partner Thread
Challenger map on Starcraf…
Steam Sales Thread
Star Wars - The Old Repu…
Magic: The Gathering Onl…
FINALLY! - The 2013 NHL …
RollPlay -- D&D Campaign…
[Patch 3.07: Nerf Everythi…
The Shikyo Memorial for QQ…
[LoL] [SFW] Random Pics & …
[OGN] Olympus The Champion…
[D] Pro Scene Evolution
[LPL] Tencent LoL ProLeagu…
[Champion] Nunu
[TL R&D] T.R.O.L.L.S.
[Guide] Montegomery's Supe…
The: What is my item worth?
D3 Hardcore Community
Witch Doctor Discussion
[M][N] Les Mafia
Carnival Cruise Mafia
[T] Bastard "Mini" Mafia!
Bodyweight Training
TL Health and Fitness Init…
Olympic Weightlifting Thread
Leta - Movie
Michael - skyline
Anytime - Beast
By.Hero - Shuttle
Anytime - Pusan

Website Feedback

Closed Threads

IRC Chat
irc.quakenet.org #teamliquid

IRC Web Client

TeamSpeak 3 (60 users)

Whats wrong with this trigger? [Simple AI Trigger]

Forum Index > StarCraft 2 Maps & Custom Games
 
 MatTaNg   United States. January 06 2013 11:33. Posts 21
Profile # 
So i'm trying to make an AI, who owns only one unit which is a ghost in this example. The ghost has standard abilities; Snipe and EMP. So I want the ghost to walk around and find an enemy. Once it has acquired an enemy if that unit has mana then I want the ghost to EMP once, then spend the rest of it's energy on snipe. If the enemy does not have energy just spend all energy on snipe. If the enemy has no energy nor is biological then the ghost shouldn't do anything but auto attack.

This is what i have so far:

Events
Timer - Every 1.0 seconds of Game Time
Local Variables
ClosestUnit = No Game Link <Game Link - Unit>
Conditions
Actions
Unit Group - Pick each unit in (Ghost units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Controller of player (Owner of (Picked unit))) == Computer
Then
Variable - Set ClosestUnit = (Unit type of (Closest unit to (Position of (Picked unit)) in (Any units in (Entire map) owned by player Any Player matching Excluded: Self, Ally, Robotic, Structure, Missile, Uncommandable, Stasis, Under Construction, Dead, Hidden, Summoned, with at most
UI - Display (Name of ClosestUnit) for (All players) to Subtitle area
UI - Display (Text((Owner of (Picked unit)))) for (All players) to Subtitle area
General - If (Conditions) then do (Actions) else do (Actions)
If
Or
Conditions
ClosestUnit == Ghost
ClosestUnit == High Templar
ClosestUnit == Raven
ClosestUnit == Sentry
ClosestUnit == Infestor (Spellcaster)
Then
UI - Display (Name of ClosestUnit) for (All players) to Subtitle area
Unit - Order (Picked unit) to (Ghost - EMP Round targeting (Position of (Closest unit to (Position of (Picked unit)) in (Any units in (Entire map) owned by player Any Player matching Excluded: Self, Ally, Structure, Missile, Uncommandable, Stasis, Dead, Hidden, Summoned, with at most (Replace Existing Orders)
Else
Unit - Order (Closest unit to (Position of (Picked unit)) in (Any units in (Entire map) owned by player Any Player matching Excluded: Self, Ally, Structure, Missile, Uncommandable, Stasis, Dead, Hidden, Summoned, with at most Any Amount)) to (Ghost - Sniper Round targeting (Closest unit to (Position of (Picked unit)) in (Any units in (Entire map) owned by player Any Player matching Excluded: Self, Structure, Missile, Uncommandable, Stasis, Under Construction, Dead, Hidden, Summoned, with at m (Replace Existing Orders)

I know it looks like a giant wall of text but most of it is just nonesense. The problem is that every time i try to find the closest unit it returns itself, which makes sense because the closest unit to the point of the position of your unit is your unit. But what doesn't make sense is when i says Excluding self in the unit filter it still returns itself. This problem persists with my Attack trigger also(which i didn't post). In my attack trigger i try to find the closest hostile unit to attack but it ends up A-attacking its own position even though I excluded self. I don't know why, please help!
Old Post

 
 Ahli   Germany. January 06 2013 12:25. Posts 107
Profile # 
"Self" doesn't do anything in triggers because there is no scope that you can throw into the function. So, you may ignore a few fields in the filter. I'm not entirely sure which work and which won't, but I only trust the ones that only rely on the found unit and no other info.

a few further comments:

1. Save the Ghost unit in a global variable. Global variables are added where the triggers are and can be used everywhere then.
2. You should save the received unit group in a variable.
3. Filter the units in the unit group for alliance. There are functions that give you all or at least some of the required functionality.
4. Avoid using the whole map when you try to find units. It depends how you want it to do, but a circular area around the ghost should be enough, I don't know how it is implemented, but I imagine having 5k units on the map might make this cost quite a lot performance compared to a smaller area.
Last edit: 2013-01-06 12:27:47
Try my Arcade map "Dia blo - Mortal Shroud" or "Temple Siege 2". :)
Old Post

 
 Xapti   Canada. January 07 2013 10:59. Posts 2178
Profile # 
Instead of "any units in (entire) map", you can and should use a better unit group. If you look at the list you can quite easily see there's many useful options to filter the type of unit you want, such as "units in region with alliance to player"
You'd want to set it to enemy of owner of the ghost unit.
Last edit: 2013-01-07 11:00:59
"Then he told me to tell you that he wouldn't piss on you if you were on fire" — "Well, you tell him that I said that I wouldn't piss on him if he was on Jeopardy!"
Old Post

 
 hobbidude   Canada. January 07 2013 15:45. Posts 166
Profile # 
Well for one thing this shouldn't even be done in a trigger; you should be using an threaded action definition or mostly likely 2 (all ai or multitasking require this to work properly). You then should be running a while loop check if the unit is alive. If there's only one unit then you should not be using a picked each unit loop but rather a global variable as suggested or better a parameter depending on how the unit is selected/built (a parameter will also solve a lot of your issues too).

You need to be more specific in what you want; for example do you just want the unit the move around randomly and then just engage any enemies that come into range or do you want to you specifically target a unit even if its not insight and engage it as long as its alive? The other issue you'll run into with your trigger in its current state is if the unit commits to an attack or not such as it switching targets when it shouldn't be. You should also be able to check the energy on the target unit and not have the mulitple conditions for all the different unit types.

Your debugging text is returning your unit because thats half of what you've asked it to do, but thats not necessarily means your unit is doing something wrong.

No worries around the wall of text; im an advanced trigger from mapster and understand it perfectly although there is a function in the editor that should also you to include the correct formating too.
Last edit: 2013-01-07 15:56:45
Old Post

 
 MatTaNg   United States. January 07 2013 16:26. Posts 21
Profile # 
I just want the unit to search around the map for a hostile unit and attack it, its an arena-based map so probably would want to prioritize the unit with the lowest health but thats not nessesary. Right now i have it so it attacks the closest unit.

I'm a newbie programmer and i've never done functions nor even ever heard of threading. Perhaps you can explain a little or if its too complicated direct me to a guide or something, i would greatly appreciate it!
Old Post

 
 hobbidude   Canada. January 07 2013 17:10. Posts 166
Profile # 
Yup sounds like your very very new but this is something you'll definitely need to know as you should actually be using as little triggers as possible. First there's two things function definitions and action definitions. You'll most likely only need action definitions for this part but functions are the same just with the ability to return information. Action definition are just added to a trigger just like any other regular action but they have to be create beforehand; they are basically just another trigger like thread without an event. Now the main thing is that unlike triggers, actions definitions can be multi-threaded (there is a checkbox inside the action to enable this); now it is this threading that not only allows the set of actions to act independently to any other set of actions but also allows it work at its own pace/time thus helping a lot of time with lagg. To compare the different, doing it in trigger the ai would have to move, stop moving, shoot, resume move, etc. Now you can see where this would be an issue in things like stutter step micro because you issue a lot of orders with a lot of waits; definitions on the other hand would allow you to have one whole mechanic for moving and another whole different one for shooting so the units would stead shoot and move at the same time simultaneously with the two threads working together. Granted you may not need this specific mechanic but the concept still applies.

Actions definitions use parameters to grab the information from the trigger they are in and use it within the set of actions within the definition. Like in a trigger you make need to use the triggering unit however since you do not have an event in a definition you use a parameter (kinda of like a variable); within the action defintion create a parameter like unit and then within the trigger with the definition you include the triggering unit within the action to specify that the parameter refers to.

Now the only other things you will have to get to know real well is loops such as "for each integer", "while", "repeat", etc.

Right now your going to have a lot of lag as with your periodic triggers what if you actions can't complete within the time of the next periodic event. Actions defintion will run without holding up anything and will run a whole lot smoother and faster. I hope this helps.
Last edit: 2013-01-07 17:13:59
Old Post

 
 ScorpSCII   Denmark. January 07 2013 23:30. Posts 293
Profile # 
You should take a screenshot and post that instead; it's much easier to read with proper syntax.
Author of Atlas | Dreamforge Mapmaking Team
Old Post

Please log in or register to reply.
 
Refresh
 << May '13 >> 
Mo Tu We Th Fr Sa Su
  12345
6789101112
13141516171819
20212223242526
2728293031  
FEATURED ON AIR:
[TI3] Group A - East…
ON AIR:
[ATC] ROOT vs. MVP
[TPL] S5W1 - Demon E…
[SPL] T8 vs. KT
Upcoming events:  [ More ]
1h 33mRSL gNations NA vs…
2h 33m[SL6]Group Stage
3h 33m[GC S3] Playoffs
3h 33mEMS Spring Playoffs
3h 33m[BW] ThSL Stage 1
Refresh
StarCraft: Brood War
StarCraft 2
Dota 2
Other Notable Streams
[ Show 70 non-featured ]

» Recent SC2 Results
» Premier SC2 Tournaments
Sidebar Settings...

The Little App Factory



The opinions expressed by our users do not reflect the official position of TeamLiquid.net or its staff.

Advertising | Jobs | Privacy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren. Ad tag: TF_US.
The contents of this webpage are copyright © 2002-2013 Teamliquid.net. All Rights Reserved