Campaign AI and defense

User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Campaign AI and defense

Post by IskatuMesk »

Does anyone know how to get the Campaign AI to defend itself when it's being attacked? The flag in units doesn't seem to do anything/be enough to make it use units for defense, and I see nothing in triggers.
User avatar
Taeradun
Protoss Khalai Missionary
Protoss Khalai Missionary
Posts: 1028
Joined: Thu Sep 07, 2006 6:08 pm
Location: AU
Contact:

Re: Campaign AI and defense

Post by Taeradun »

are you working on a SC2 project? Image
Image
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

If you call getting the Campaign AI to actually defend itself a project.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

So, this is totally uncharted territory, then. Maybe Gna knows, if he wasn't dead in a ditch somewhere. All these pro-sc2 guys don't even know if a basic, fundamental feature of making any kind of a campaign is even possible. Mapster, as useless as always, doubly so with its disgustingly bad forum search. SEN, lol.

Because I recall sc2's campaign AI never defending in WoL it may just be entirely impossible to do the proper way. Very Blizzard. Maybe it's possible to tony melee galaxy code into the campaign galaxy code, but this is a huge tumble down the bucket outside of my job description, so I probably wouldn't know if it's even possible just by looking at those tremendous heaps of smoldering lard. The way melee AI handles defenses is probably very silly if it's not enabled on the campaign by default.

I have a few theories on how you could make a super hackish kind of defense trigger, but they are all too abusable, and I'd rather stuff not be abusable or annoying to trigger.

Now, there is a unit flag that is supposedly related to defense. But it doesn't do anything, or at least on its own.
User avatar
Vetraeus
Terran Goliath Dome Polisher
Terran Goliath Dome Polisher
Posts: 109
Joined: Tue Mar 22, 2011 1:21 pm
Location: South Carolina: Underwater
Contact:

Re: Campaign AI and defense

Post by Vetraeus »

AI <SetFlag_VarC0_00_DefendBase_Fortify>SwapHeadFileDatabase+MEXAuxillaryIdentityAI-Counter

Enter the Variable if all else fails.
Do not argue with an idiot; He will drag you down to his level and beat you with experience.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

Is this in the galaxy file or somewhere else?
User avatar
Vetraeus
Terran Goliath Dome Polisher
Terran Goliath Dome Polisher
Posts: 109
Joined: Tue Mar 22, 2011 1:21 pm
Location: South Carolina: Underwater
Contact:

Re: Campaign AI and defense

Post by Vetraeus »

This is not even in the galaxy file, Its a carry over from WC3's AI Editor.
Do not argue with an idiot; He will drag you down to his level and beat you with experience.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

Well, I doubt jass commands would remain the same inside Galaxy, if it was even built off of jass syntax to begin with... but it might give me something to look for.
User avatar
Xenon
Zerg Queen's Nest Slave Trainee
Zerg Queen's Nest Slave Trainee
Posts: 771
Joined: Mon Oct 23, 2006 3:29 pm

Re: Campaign AI and defense

Post by Xenon »

Managed to recreate the splitting missiles with the method used by the internal Phase Mine spell (and the Aegis). Shouldn't desync, I think it was the backwards mover on the Aegis shot that caused that.
You do not have the required permissions to view the files attached to this post.
User avatar
Mucky
Protoss Khalai Missionary
Protoss Khalai Missionary
Posts: 1014
Joined: Thu Aug 24, 2006 10:35 pm

Re: Campaign AI and defense

Post by Mucky »

SC2 crashed as I killed the last of the warp prisms.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

Much <3 Q.

Not worried about desyncing, I wouldn't touch battle.net 0.2 with a 69 foot stick.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

Right. With no response from Gna, and no real idea of where to go next, I'll chalk this up to impossibility for the time being. So, here's some "workarounds" I have hypothesized and tested to a limited degree.

Pre-placed units and Bullies

Bullies are a very misleadingly termed flag for units. Basically, "Bullies" are just a way of saying "Rebuild this or not". I have successfully rigged triggers and preplaced buildings with bullies to make computer players build "prebuilt" bases. Like most things Blizzard, Bullies are kind of buggy, and you need to constantly deactivate/reactivate them to get stable builds going along.

I have successfully tested that the AI seems to know that a PF comes from a CC, and you can get them to build a PF from nothing anywhere you want using bullies. Likewise, they'll bring tanks over and siege them on locations, though those tanks sometimes end up in weird places. Changing the PF tech to an individual building didn't break the AI, either. So, this part is a bit lenient for you.

However, Bullies are not defenders or anything of the sort. At most, it's a way to encourage the AI to keep units in a spot. You can specify those pre-placed units to be available for attack waves or not. Thus, you can "fake" defenses by having the AI, through a needlessly complex network of triggers to detect player unit movement or (my preferred method), just sticking units places until the waves want them, make the AI "defend" by just having units stand in strategic places.

Bullies do NOT seem to work with transporting stuff to islands or whatever. I had to use an entirely new player for that.

+ Wave Waypoints

The next part of the workaround strategy is to have an attack wave setup that uses waypoints going through all of the player's base. For some bases that take up 1/4 of a 256x256 map, this leads to a needlessly long path for attacks to go through until they start actually attacking, but it's the only sure-fire method to put a sizable AI force in a location that threatens the player's attacking forces. The major drawbacks of here are, of course, the player simply moving away and then moving back in when the AI wave progresses onwards. At most, this helps stem problems of AI vs AI fights, but does little to save the player vs a human.

Further research

Further research indicates that the majority of AI options in regards to danger maps, front line whatever, and stuff don't seem to actually do anything, at least not with Campaign AI. Posts on sc2mapster confirm this.

- Transports forced into an attack wave won't transport. Thus, the best way to force building transports is bullyspam. You can set up the bullies to only include transports if your setup demands this. Forced Transport waypoints may cause headaches if you don't have transports already available (e.g. they may never actually attempt to attack you or make units if it "fails" to find transports.)

- AI "stock" doesn't seem to do anything with Campaign AI. In fact, this trigger selection seems incomplete.

- Using "Build" commands for Campaign AI is very unreliable, thus the necessity to use Bullies.

- The AI won't always build units in attack waves. If the wait period is not around double that of the unit's buildtime, it probably won't try to make the unit at all. Sounds like a bug.

- Bully-enabled buildings won't be built very fast unless the AI has a huge stock of resources (at least 1k+). Probably some internal check to refuse commands if they are low on money. Be prepared to feed them cash for the best results. Luckily, difficulty for sc2 AI in regards to how they spend money is much easier to control than SC1 simply due to triggered attack waves.

- Targets for waves set to "Enemy of Player *" prioritize ground targets regardless of distance. If there is no ground targets, they'll use whatever transports available to drop. Drop AI seems much better than sc1/wc3 in that they won't "panic drop" stuff in a waypoint unless their transports are < a threshold of hp. Thus, you can totally doom drop with waypoints.

- Not entirely obvious, but all spell usage seems to be handled through the cryptic Tactical AI system. Spell usage for existing spells like Blink is disabled for AI by default through a Campaign AI flag in one of the data entries associated for any given spell. Further research required.
User avatar
Ricky_Honejasi
Xel'naga Solar Moderator
Xel'naga Solar Moderator
Posts: 2011
Joined: Wed Aug 16, 2006 3:50 pm

Re: Campaign AI and defense

Post by Ricky_Honejasi »

Considering how it's always a pain to use the AI in a melee-like setting, at times it would be insanely useful if you were very good with triggers to be able to just softcode some AI so you can ignore everything else Blizzard has to offer AI-wise. In a campaign situation, it's ... situational so you don't have to trigger such AI into being super flexible with everything.

Although, would be still a considerable amount of work.
User avatar
IskatuMesk
Xel'naga World Shaper
Xel'naga World Shaper
Posts: 8328
Joined: Sat Feb 07, 2009 1:40 pm
Location: M͈̙̞͍͞ͅE̹H̨͇̰͈͕͇̫Ì̩̳CO̼̩̤͖͘ జ్ఞ‌ా

Re: Campaign AI and defense

Post by IskatuMesk »

I may have a solution.

I was talking with Jademus last night and the ultimate conclusion (I think) was that the code exists inside the AI but the Campaign AI simply doesn't access it. He ended up slapping together a library for me to test.

Although hardly conclusive, I think it works. I'll explain my observations so far.

The library in question introduces a trigger that gives the AI the Defend priority for attack waves, supposedly the same thing the Melee AI has. Now, this is where the testing needs a lot of really close observation work, but so far it seems to function properly.

Example A -

In my major tests with AI defense, there's a guy in the middle of a map with a lot of factories and supply depots. He gets attacked from all sides, but he makes the strongest single army. In my previous tests, he'd often lose 1/2 or more of his base to enemy attacks because he didn't defend. 3-4 wraiths were sufficient to level around 20 supply depots and ~10 factories. It sucked.

My initial response was to waypoint every single attack through his entire base.

In my first series of tests with the new system, the AI followed those waypoints but then turned around to engage the air attackers with his entire army. This is indicative of melee behavior. I tested this many times to be sure it wasn't somehow by chance, but I've never seen the AI turn around to engage units, only buildings (usually based on proximity).

This also indicates that waypoints hold a priority over all targeting data. As it should be, I suppose, but something very important to note in future AI setups is that waves won't be able to defend until they do all of their waypoints.

Example B -

In my second series of tests I completely disabled my waypointing. This map becomes difficult to check if it works or not, because there's many instances where the attack wave will run into attackers anyways. But my overall observations went very positively.

The AI can only defend when its Attack Wave is actually launched. The trigger/function is telling the Attack Wave to defend. So, only when the units have actually started to move to attack do they become available to defend. This is very important to note. In an effort to encourage defensive behavior, I reduce the heavy units this fellow needed to build and increased the frequency of attacks. As a result, he was able to confidently survive all attacks up to the intended game-ending Major Waves from your prime opponent. I ran this scenario many times.

- The AI didn't care to defend if units were being attacked, only buildings. The response wasn't always immediate, but I witnessed them turning away from the enemy base and going back to kill enemy units near their base attacking them. This is very good.
- When told to "defend", the wave moved as a single body and not per-unit (e.g. anti-ground units joined the defense). This is also very very good since it keeps the entire attack together, even if they lose some units unnecessarily.
- The AI returns to attacking after a short time but can turn back around.

Again, this is inconclusive until I am 100% sure the defense protocol is doing this, but I'm very excited by my observations so far. This will be the last piece of the puzzle for functional B&D.
User avatar
Eredalis
Zerg Larva Herder
Zerg Larva Herder
Posts: 311
Joined: Mon Jan 08, 2007 12:01 pm
Location: Germany
Contact:

Re: Campaign AI and defense

Post by Eredalis »

Man, thank you for sharing your valuable insights with us. That is really very useful. :]
Post Reply