Posted: Sun Jan 29, 2012 8:32 am Post subject:
Allying with the AI (****)
This tutorial will allow you to ally with AI players in TS (without possible crashes). Though there are some limitations:
1. Can only ever ally with 1 AI player
2. Only opposing sides can ally, GDI + GDI and Nod + Nod alliances won't work. This could be corrected with AI only sides for GDI and Nod, but I won't cover that here.
3. Has to be enabled for each map specifically. Though this could be considered a good thing since the logic might force human players to ally with each other, so I would leave it for skirmish only maps or figure something else out.
Let's begin in rules.ini. Create this new infantry first:
Code:
; Informant
[INFORM]
Name=
Image=E1 ; Should use an invisible infantry SHP here
Category=Support
Prerequisite=CABHUT
Primary=none
Crushable=no
Immune=yes
Insignificant=yes
Strength=100
Armor=none
TechLevel=1
Sight=0
Speed=5
Owner=GDI,Nod
AllowedToStartInMultiplayer=no
Cost=0
Points=0
PhysicalSize=1
JumpJet=yes
Locomotor={92612C46-F71F-11d1-AC9F-006008055BB5}
MovementZone=Fly
ThreatPosed=0
ImmuneToVeins=yes
Then search for [VariableNames] and add these to the bottom:
Code:
...
12=GDI Exists
13=Nod Exists
Next up ai.ini. First we need to define a taskforce. Just as a reminder, remember to add each taskforce, script and teamtype to their respective index lists.
Code:
[00000001-G]
Name=Inform
0=1,INFORM
Group=-1
Then a few triggers.
Code:
[00000002-G]
Name=GDI Exists
0=12,12 ; Set "GDI exists" global variable "true"
1=3,97 ; Move to waypoint 97 to get out of the way
[00000003-G]
Name=Nod Exists
0=12,13 ; Set "Nod exists" global variable "true"
1=3,97 ; Move to waypoint 97 to get out of the way
Get's bit messier here, need to add a bunch of teamtypes. They are pretty much copies of each other, only the side and scripts are changed.
;GDI set self
00000010-G=GDI 1,00000004-G,<all>,1,1,GAPILE,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
;GDI set GDI
00000011-G=GDI 2,00000005-G,<all>,1,0,GAPILE,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
;GDI set Nod
00000012-G=GDI 3,00000006-G,<all>,1,0,NAHAND,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
;Nod set self
00000013-G=Nod 1,00000007-G,<all>,1,1,NAHAND,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,2,0,<none>,1,1,1
;Nod set Nod
00000014-G=Nod 2,00000008-G,<all>,1,0,NAHAND,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,2,0,<none>,1,1,1
;Nod set GDI
00000015-G=Nod 3,00000009-G,<all>,1,0,GAPILE,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,2,0,<none>,1,1,1
If you haven't been scared away yet, I will explain what the idea is here. Normally alliances can't be formed on multiplayer maps cause we don't know which factions are actually participating in the match. Trying to ally with a faction that doesn't exist in the match would result in a crash. Since there's no apparent way to check if a certain faction exists (since the check itself would crash if that faction didn't exists), we let the AI do the work. Each AI will first look if they own a GDI Barracks or Hand of Nod, and if so set each faction's global variable enabled. E.g. Nod AI sees that he has a Hand of Nod, thus we can assume Nod is present in the match, and set the global variable true. Then the AI does the same check on their enemy, checking if they have a GDI Barracks or Hand of Nod, and again set the global variable true. This is needed because human players wouldn't be setting any global variables, so the AI needs to do it instead. After this ai.ini stuff, we now know which factions are present in the mission.
P.S. That new fake infantry is needed so the AI will only do these checks once. If the infantry could be killed the AI would keep replacing it.
Final part is to make use of all this in the map file. Open FinalSun and open the Trigger Editor. You need to add 2 new triggers, one for GDI and one for Nod. Below shows the GDI trigger details:
Nothing special here...
Here you need to add another event in addition to the one shown in the pic. Event 1 should be exactly the same as the one here, just change the Parameter value to 13.
...
Now add the trigger for Nod. Just clone this one and change every GDI value to Nod, and vice versa. Finally, add the special waypoint 97 to your map to make the AI send out their fake infantry away from blocking base construction. Should be placed somewhere remote.
That should cover it, if you run into any problems just ask here. There are a few instances where no alliances are made:
1. All players are of the same faction. Since GDI can't ally with GDI, nothing will happen.
2. A really small chance that the human player is the only one playing a certain faction (e.g. Nod) while all the AI are playing GDI, AND none of the AI's consider the player an enemy. Thus Nod's existence would never be set true, at least not until one of the AI's got mad at the Nod human player.
Made few fixes to the code, especially to the infantry. Also this
1. Can only ever ally with 1 AI player
Is only half true. You can only ally with 1 AI player of a faction type. So if you had 3 factions in your mod (e.g. GDI, Nod, Forgotten), a GDI human player could ally with 1 Nod AI and 1 Forgotten AI. I have no idea if those 2 AI players would then be allied too. _________________ QUICK_EDIT
Joined: 16 Feb 2005 Location: North America Posts: You cannot comprehend...
Posted: Fri May 03, 2013 11:10 pm Post subject:
The AI gets soft though when allied to humans. They just don't attack as aggressively as enemy AIs. _________________ Destroy to create. All for the hunt to dominate!
I think what you're referring to is the AI an allied human player turns into after that human player has left the game. That AI is indeed less competent, but that's not because it's allied to another human player (it'll be just as incompetent if it's not allied to anyone) and thus this doesn't say anything about how the AI will play after it allies with a human player via Super Joe's method. _________________ QUICK_EDIT
Joined: 16 Feb 2005 Location: North America Posts: You cannot comprehend...
Posted: Sun May 05, 2013 12:14 am Post subject:
OK
In Yuri's Revenge, when setting up AI team players before the match starts - in game, that team AI is definitely less competent when it is allied to humans. They just never seem to have the same aggression level as enemy AIs.
I presumed this was the same deal in TS/FS (less aggresive Allied AIs), and, when people presume, they make the president outta u & me _________________ Destroy to create. All for the hunt to dominate!
Why can't you ally AI in TS? In the latest patch to RA95 Westwood disabled allying AI in a hacky way with a special check that always fails, after removing that check you can ally the AI but the AI won't ally you back.
So I had to patch the game to make the AI ally you back when you allied them in Skirmish.
And not so long ago I made it so you can create alliances, select spawn locations, select colours, select handicaps and select countries for human and AI players when configured in a special INI file and the game launched with a special command line argument (-SPAWN) as part of hifi's spawner code for RA95. QUICK_EDIT
What map did you used as a basis? Also how or when did you learn all of this? With your permission, may I post this tutorial somewhere? I'll give you a credit. QUICK_EDIT
Joined: 16 Feb 2005 Location: North America Posts: You cannot comprehend...
Posted: Sun Jul 07, 2013 5:23 am Post subject:
I just tried this, did a single run through, added unit, added ai shit, added map stuff.
I made the map's shroud revealed, selected my unit, and hovered the cursor over all 7 other AI unit's, every one of them triggered an attack cursor.
So.. I fucked up.
For the [Inform] unit, it's image is still E1. How can I get an invisible unit image?
I Saw the little dude flying, lolz. Awesome. he flew to the waypoint, but attack cursors all around. All seven AI's sent their little emissaries to the way point at the top north end of the map. Then the AI situated at that starting point started shooting at him.
I'm using Twisted Insurrection. There was already a unit named [INFORM], so I made [INFORM2]. Plus, in TI, theres GDIA,B and NodA,B.
Not sure if I just fucked up, or if TI needs more to it than stock TS for this thing to work. _________________ Destroy to create. All for the hunt to dominate!
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum