Posted: Mon Jan 28, 2013 4:15 am Post subject:
Near perfect sub-factions
Got the final things ironed out from a method that allows you to have sub-factions in TS, without making the player take all sorts of weird actions. The only input required from the player is doing the sub-faction selection in the sidebar. Here is an animation showing how it works.
You are required to do a few things in order for this logic to work:
1. Can't have starting units, other than the MCV.
2. Bases setting needs to be on.
Let's start in rules.ini with a few tweaks:
Code:
[General]
TeamDelays=800,800,800 ; So AI builds the sub-faction HQ as the first unit
AIHateDelays=900,1100,2000 ; So AI chooses enemy faster
[CombatDamage]
MinDamage=0 ; Helps get rid of some odd EVA comments
[MultiplayerDefaults]
Bases=yes ; Needs to be yes for sub-factions to work
UnitCount=2 ; Needs to be exactly 2 for sub-factions to work
[Difficult]
BuildSlowdown=no ; So AI chooses sub-faction quickly
[Normal]
BuildSlowdown=no ; So AI chooses sub-faction quickly
[Easy]
BuildSlowdown=no ; So AI chooses sub-faction quickly
Now go through all your vehicle and infantry units, and give them AllowedToStartInMultiplayer=no. By default it's set to Yes, so you need to give this line for every unit.
Now let's add the required vehicles, buildings, animations and warheads into the lists:
Code:
[VehicleTypes]
...
xx=HELPER ; Little extra vehicle required for logic to work
xx=GDISUBF ; GDI sub-faction factory (vehicle)
xx=NODSUBF ; Nod sub-faction factory (vehicle)
xx=GDISUB1 ; GDI sub-faction vehicle 1
xx=GDISUB2 ; GDI sub-faction vehicle 2
xx=GDISUB3 ; GDI sub-faction vehicle 3
[Animations]
...
xxx=SUBBEACONMK ; Sub-faction factory buildup anim
xxx=INVISANIM ; Invisible anim
xxx=SUICIDE1A ; Used to suicide the Helper vehicle, part 1
xxx=SUICIDE1B ; Used to suicide the Helper vehicle, part 2
xxx=SPAWNER1 ; Debris anims to suicide the sub-faction factories
xxx=SPAWNER2
xxx=DEBRIS1
xxx=DEBRIS2
[Warheads]
...
xx=DeployWeaponWH ; Used by all the sub-faction logic weapons
xx=DoNothingWH ; Used by helper vehicle (so it won't attack anything else but concrete)
xx=KillerDebrisWH ; Used by the suicide debris
Now let's just define all the things we put in the lists above. I've put comments for some of the keys of interest. Vehicles first:
; GDI Subfaction Factory Vehicle
[GDISUBF]
Name=-
Owner=GDI
Image=INVISVEH
Prerequisite=CABHUT
Category=AFV
Primary=DeployWeapon
DeployToFire=yes
GuardRange=255
Selectable=no
Strength=1000
Armor=concrete
TechLevel=1
AllowedToStartInMultiplayer=yes ; You start with this and MCV
CrateGoodie=no
Sight=5
Speed=16
Cost=5000 ; Very specific cost to make MCV and this appear at start
Points=0
ROT=30
Crusher=no
Crewed=no
MaxDebris=0
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
MovementZone=Normal
DeploysInto=GASUBF
ThreatPosed=0
Weight=1.0
; Nod Subfaction Factory Vehicle
[NODSUBF]
Name=-
Owner=Nod
Image=INVISVEH
Prerequisite=CABHUT
Category=AFV
Primary=DeployWeapon
DeployToFire=yes
GuardRange=255
Selectable=no
Strength=1000
Armor=concrete
TechLevel=1
AllowedToStartInMultiplayer=yes ; You start with this and MCV
CrateGoodie=no
Sight=5
Speed=16
Cost=5000 ; Very specific cost to make MCV and this appear at start
Points=0
ROT=30
Crusher=no
Crewed=no
MaxDebris=0
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
MovementZone=Normal
DeploysInto=NASUBF
ThreatPosed=0
Weight=1.0
; GDI Subfaction Vehicle 1
[GDISUB1]
Name=Tank Faction
Owner=GDI
Image=GDISUB1
Prerequisite=GASUBF
Category=AFV
Primary=DeployWeapon
DeployToFire=yes
GuardRange=255
Strength=9999
Armor=concrete
TechLevel=1
AllowedToStartInMultiplayer=no
CrateGoodie=no
Sight=5
Speed=16
Cost=200 ; So player can have some time to cancel their choice
Points=0
ROT=30
Crusher=no
Crewed=no
MaxDebris=0
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
MovementZone=Normal
DeploysInto=GASUB1
ThreatPosed=0
Weight=1.0
BuildLimit=-1 ; So you can't order multiple copies of them in the sidebar
; GDI Subfaction Vehicle 2
[GDISUB2]
Name=Air Faction
Owner=GDI
Image=GDISUB2
Prerequisite=GASUBF
Category=AFV
Primary=DeployWeapon
DeployToFire=yes
GuardRange=255
Strength=9999
Armor=concrete
TechLevel=1
AllowedToStartInMultiplayer=no
CrateGoodie=no
Sight=5
Speed=16
Cost=200 ; So player can have some time to cancel their choice
Points=0
ROT=30
Crusher=no
Crewed=no
MaxDebris=0
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
MovementZone=Normal
DeploysInto=GASUB2
ThreatPosed=0
Weight=1.0
BuildLimit=-1 ; So you can't order multiple copies of them in the sidebar
; GDI Subfaction Vehicle 3
[GDISUB3]
Name=Special Faction
Owner=GDI
Image=GDISUB3
Prerequisite=GASUBF
Category=AFV
Primary=DeployWeapon
DeployToFire=yes
GuardRange=255
Strength=9999
Armor=concrete
TechLevel=1
AllowedToStartInMultiplayer=no
CrateGoodie=no
Sight=5
Speed=16
Cost=200 ; So player can have some time to cancel their choice
Points=0
ROT=30
Crusher=no
Crewed=no
MaxDebris=0
Locomotor={4A582741-9839-11d1-B709-00A024DDAFD1}
MovementZone=Normal
DeploysInto=GASUB3
ThreatPosed=0
Weight=1.0
BuildLimit=-1 ; So you can't order multiple copies of them in the sidebar
Next up, buildings:
Code:
; GDI Subfaction Factory
[GASUBF]
Name=Choose your sub-faction
Owner=GDI
Image=SUBBEACON
Factory=UnitType
WeaponsFactory=no ; Want insta-spawning of vehicles built
Prerequisite=CABHUT
Strength=10 ; So it gets killed quickly
Armor=light ; Specific armor type required for suiciding
Selectable=no
TechLevel=1
Sight=6
Adjacent=2
Cost=0
Points=0
Power=0
TickTank=yes ; For correct deploying
BaseNormal=no
Capturable=no
Repairable=no
TogglePower=no
Unsellable=yes
Crewed=no
Bib=yes
Explosion=
MaxDebris=0
ThreatPosed=0
AIBuildThis=no
VoiceDie=BOOP ; Could use some fitting sound here
[DeployWeaponWH]
Spread=0
Verses=0%,0%,0%,0%,1% ; Target only Armor=concrete (helper vehicle, sub-faction related vehicles)
InfDeath=0
ProneDamage=0%
;Veinhole=yes ; This sometimes made AI MCV go mad, so disabled it.
That should be it. Now you do need to do one more thing before testing it. You need to place exactly one Helper vehicle to all of your maps. Place it near the center of the map. This Helper vehicle is absolutely required for the logic to work. You don't need to create any teams or scripts for it to work, simply placing one neutral owned Helper vehicle is enough.
If you have any questions of the logic, just ask. I've added descriptions of all the things at the start of the tutorial (where we added all the stuff into the lists in rules.ini). I've also included a RAR that contains all the necessary files to quick test this logic in TS / FS. Just extract it to your (unmodified) TS directory. Check the readme.txt for further details.
subfactions.gif
Description:
Filesize:
479.21 KB
Viewed:
14757 Time(s)
subfaction_files.rar
Description:
All the files required for a quick test of this logic in the original TS.
I'll post the ai.ini stuff required to make AI use this logic later. I've tested a very similar thing with the AI before, and I'm pretty sure this logic shouldn't cause the AI any problems. It should randomly choose one of the 3 factions. After that we can use the sub-faction HQ as the trigger condition for any sub-faction specific teams. Or we can use the sub-faction HQ as a prerequisite for some of the structures, and since the AI does follow prerequisites with structures, not having a sub-faction HQ will stop him from getting access to certain things. So basically:
Sub-faction HQ 1 is required for advanced helipad. Since AI doesn't have HQ 1, he can't build advanced helipad, and thus we can use advanced helipad as the trigger condition in ai.ini. _________________ QUICK_EDIT
Confirmed the AI works with this logic without any special hacks. It will randomly choose one of the factions. If you save before he makes the choice and load, he might make a different choice. So it is quite random. I couldn't get the sub-faction HQ to work as a building prerequisite (for the AI) for some reason. Dunno if it was due to the building being 0x0, or Insignificant=yes, or something else. I did try with 1x1 and it didn't help. Might need to look more into it. But the HQ does work as a trigger condition, so the AI can be made to fully utilize sub-factions. I've updated the subfaction_files.rar to include an edited ai.ini and a few more tweaks to rules.ini to make it work with the AI.
Anyway, here are quick instructions how to get it done. Start in rules.ini again:
Code:
[General]
UseMinDefenseRule=no ; So AI builds the sub-faction vehicle ASAP
AIHateDelays=1,1,1 ; So AI doesn't get mad at Neutral (due to the Helper vehicle)
If you don't disable MinDefenseRule, the AI will not build the sub-faction vehicle for quite a while, messing things up. Also noticed that the AI is hardcoded to build 1 extra harvester right away, even before the sub-faction vehicle. You could stop it by getting rid of the hardcoded harvester AI replacement logic (like I have in my mod). But overall the extra harvester building doesn't matter, right after that the AI will build one of the sub-faction vehicles.
Anyway, moving to ai.ini. Start with taskforces:
Code:
[TaskForces]
xxx=GDISUB1 ; GDI Tank Faction
xxx=GDISUB2 ; GDI Air Faction
xxx=GDISUB3 ; GDI Special Faction
xxx=GDITEST ; a "Special Faction only" test
[GDISUB1]
Name=GDI Tank Faction
0=1,GDISUB1
Group=-1
[GDISUB2]
Name=GDI Air Faction
0=1,GDISUB2
Group=-1
[GDISUB3]
Name=GDI Special Faction
0=1,GDISUB3
Group=-1
00001000-G=GDI Tank Faction,TGDISUB1,<all>,1,1,GASUBF,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
00001001-G=GDI Air Faction,TGDISUB2,<all>,1,1,GASUBF,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
00001002-G=GDI Special Faction,TGDISUB3,<all>,1,1,GASUBF,0100000003000000000000000000000000000000000000000000000000000000,5000.000000,5000.000000,5000.000000,1,0,1,0,<none>,1,1,1
If you see the AI build and deploy 3 sensor arrays, it means he chose the special sub-faction. I didn't put any other sub-faction specific things in here so this tutorial wouldn't get overly long and messy.
Btw something wrong with the forums, when I tried to update or remove the attached file my entire post disappeared. Had to go back and copy paste it into the message field before I could update the file. _________________ QUICK_EDIT
The code has a few suboptimal settings:
SUICIDE1A is using INVISO which has only 1 frame, yet wanting to play 1000 frames. Better use a lot less frames and the Rate key to exactly time the anim. (e.g. Start=0 End=1 Rate=1 for exactly 1 minute delay)
INVISBUILD can directly get the DEBRIS1 assigned on the activeanim. Since the debris is supposed to be spawned only once, there is no need to go over the intermediate step anim SPAWNER1. SPAWNER1 would also play 8 debris, which is quite redundant since 1 is already enough.
SPAWNER2 is quite useless imo. Why should DEBRIS1 spawn that, when debris1 destroyed already the dummy factory?
Right now you spawn something around 64 debris while 1 would be already enough.
I guess you did that since the faction vehicle is spawned a few cells away from the dummy factory and this way wanted to make sure the factory is really destroyed when the vehicle deploys.
Why don't you use the dooranim or productionanim to kill the faction warfactory?
What if you order all 3 factions to be build? It looks like the second could be ready before the warfactory destroys itself.
What if the helper isn't shooting on one of the dummy warfactories? This side would then don't have any subfaction.
For what is the DoNothing weapon on the HELPER? I guess you want to avoid that it keeps shooting on armor=concrete stuff.
But wouldn't it be better to give the HELPER a limited strength and do a suicide after a certain time? A building that constantly tries to attack something would be surely a (slight) cause of lags. _________________ SHP Artist of Twisted Insurrection: Nod buildings
SUICIDE1A is using INVISO which has only 1 frame, yet wanting to play 1000 frames. Better use a lot less frames and the Rate key to exactly time the anim. (e.g. Start=0 End=1 Rate=1 for exactly 1 minute delay)
This could probably be optimized like you said, I just put together something quickly to get it done.
Lin Kuei Ominae wrote:
I guess you did that since the faction vehicle is spawned a few cells away from the dummy factory and this way wanted to make sure the factory is really destroyed when the vehicle deploys.
Yes, at first I was using less debris and sometimes the warfactory didn't die. So I just made damn sure it does. Without SPAWNER2 I couldn't get the warfactory to die quickly enough. Now the number of debris spawned grows quickly since every debris that lands spawns more. At this point of the match I doubt this slowdown matters, and it only happens once.
Lin Kuei Ominae wrote:
Why don't you use the dooranim or productionanim to kill the faction warfactory?
I tried but both of those anims seem to require WeaponsFactory=yes set on the warfactory. WeaponsFactory=yes and 1x1 foundation together lead to a crash if you build something. I tried alot of the other special keys too, like ConstructionYard=yes, etc, but ultimately couldn't get anything to work. So I moved the self-destruction for the sub-faction HQ.
Lin Kuei Ominae wrote:
What if you order all 3 factions to be build? It looks like the second could be ready before the warfactory destroys itself.
There is not enough time to build another one. The debris will destroy it before that. Currently I've set the price of sub-factions to 200. Should it seem that's not enough, you could easily raise it to 300, or 400, and that wouldn't slow things too much. But in any of my tests I couldn't even get the 2nd one built half-way (with a a price of 200). Also the preview anim doesn't show, but I added BuildLimit=-1 to each of the sub-factions, it looks alot less messy now. And you can't order e.g. 10 tank factions anymore, only 1.
Lin Kuei Ominae wrote:
What if the helper isn't shooting on one of the dummy warfactories? This side would then don't have any subfaction.
It will shoot each of them in turns. It can only shoot at things with armor=concrete. When one of them deploys, it changes to the next concrete target.
One thing that might need to be better sorted out is what if the player doesn't choose a sub-faction for a long time. Then the Helper vehicle can die out from the suicide anim, before having the chance to make the sub-faction deploy. Though you can still select and deploy it manually, should that happen. Personally I think if someone doesn't make the selection in the first 1-2 minutes of the match they deserve what's coming to them Though maybe limited ammo on the Helper vehicle could work out better, than a timed suicide anim.
Also with this logic none of the factions early game buildings should use the concrete or light armor types (since the logic requires them for special uses). After the sub-faction choosing is done, the armor types can be used again. _________________ QUICK_EDIT
I guess I would be the first one delaying the faction-choosing as much as possible to see if I can get a strategical advantage out of it. E.g. scouting the enemy faction and then using the best counter faction. _________________ SHP Artist of Twisted Insurrection: Nod buildings
I guess I would be the first one delaying the faction-choosing as much as possible to see if I can get a strategical advantage out of it. E.g. scouting the enemy faction and then using the best counter faction.
You can tie the first or second building to the sub-faction HQs. In this tutorial I just didn't do that cause it would have required 3 separate power plants. In that case there would be very little you can do before choosing. Note that you can't stop the sub-faction factory from deploying, so the sub-faction selection becomes available even if you move out with the MCV.
If you really wanted to play it safe, give the Helper vehicle 5 mins to live, have the sub-faction HQs as prerequisites for the power plant, and don't use armor type concrete for early game stuff. If you were willing to dedicate armor type concrete for sub-factions only, then you could go without any time limits. But I wouldn't go as far as to waste an armor type for that. _________________ QUICK_EDIT
How about giving the conyard the dummy warfactory as FreeUnit?
Then you can keep using starting units and you can move your mcv around. _________________ SHP Artist of Twisted Insurrection: Nod buildings
Won't work cause the dummy warfactory needs to be a faction-specific unit. Or actually not completely sure it does... could it have Owner=GDI,Nod and then the sub-faction vehicles have only one of them as owner? Shared dummy warfactory, separate sub-faction vehicles. Would this give GDI only the GDI sub-factions in the sidebar, and Nod only the Nod ones?
As for giving it with a FreeUnit, I could see that leading to more problems. If you move your MCV to an area with cliffs and stuff nearby, the dummy warfactory might get stuck and not be able to deploy. If you wanted to make it obvious to the player he has to make a choice fast, you could have an active anim on the dummy warfactory, that displays a timer trickling down. If you don't choose the faction before timer runs out, the dummy warfactory self-destructs. You could still go on, but just lose all the sub-faction stuff.
EDIT: Could use the map trigger that displays a timer with a message for it too. Would probably look more professional than an active anim with a text and timer.
Btw got the AI to build the sub-faction vehicle as the very first unit by using the following:
Here's an updated version. There's a 2 minute timer now when the match starts. If you don't choose a sub-faction during these 2 minutes, the dummy warfactory self-destructs. The AI usually builds the sub-faction around 1 minute mark. It should be pretty obvious to players now what to do, even added a text trigger telling them to choose the sub-faction before the time runs out. It also works as a balancing factor, preventing you from delaying the choosing so you can see what the enemy chose.
Here's the final version of this logic. Added sub-factions for Nod too and made both GDI and Nod AI select a random sub-faction. Also adjusted some of the art.ini codes to match the new 2 minute timer thing, and added the new visual effects. You can look up the codes from the files.
I hate to be the one to Necrobump, but I'm getting a major issue after a few tests. It would seem for some reason after placing down the HELPER unit, after a successful test run of the map, the map will alter itself to erase the HELPER unit from it for no good reason!
EDIT - Scratch that, I got a different problem. You fix one, and ten more pop up -_-
Simply put, it's not obeying Build Prerequisites. If I set GDISUB1 as a Prerequisite, the game does not obey and simply makes the Unit buildable anyway. QUICK_EDIT
I hate to be the one to Necrobump, but I'm getting a major issue after a few tests. It would seem for some reason after placing down the HELPER unit, after a successful test run of the map, the map will alter itself to erase the HELPER unit from it for no good reason!
EDIT - Scratch that, I got a different problem. You fix one, and ten more pop up -_-
Simply put, it's not obeying Build Prerequisites. If I set GDISUB1 as a Prerequisite, the game does not obey and simply makes the Unit buildable anyway.
I can't really see a reason why GDISUB1 would not work as a prerequisite. Are you sure the prerequisite isn't overridden somewhere (in the map itself, or in firestrm.ini)?
Btw the HELPER unit and all the hassle related to it can be avoided with the hacks provided by AlexB (used here). The GDISUBF / NODSUBF units at start can be made to automatically deploy for both humans and AI with these hacks:
Go to offset 0x1DEE36. You should see 6A 0A there. Change it to 6A 0E. This hack will make AI starting units (GDISUBF / NODSUBF) in a match go into "Hunt" mode instead of "Area Guard". Will make them automatically deploy.
To do the same for human starting units (GDISUBF / NODSUBF), go to offset 0x1DEE45. You should see 6A 05 there. Change it to 6A 0E.
I'll update the tutorial at some point with these hacks. It will make the logic a lot cleaner. With some work I think the sub-faction logic could be combined with the multi-MCV/con.yard logic. _________________ QUICK_EDIT
I can't really see a reason why GDISUB1 would not work as a prerequisite. Are you sure the prerequisite isn't overridden somewhere (in the map itself, or in firestrm.ini)?
Btw the HELPER unit and all the hassle related to it can be avoided with the hacks provided by AlexB (used here). The GDISUBF / NODSUBF units at start can be made to automatically deploy for both humans and AI with these hacks:
Go to offset 0x1DEE36. You should see 6A 0A there. Change it to 6A 0E. This hack will make AI starting units (GDISUBF / NODSUBF) in a match go into "Hunt" mode instead of "Area Guard". Will make them automatically deploy.
To do the same for human starting units (GDISUBF / NODSUBF), go to offset 0x1DEE45. You should see 6A 05 there. Change it to 6A 0E.
I'll update the tutorial at some point with these hacks. It will make the logic a lot cleaner. With some work I think the sub-faction logic could be combined with the multi-MCV/con.yard logic.
Bleh, now I'm just getting Internal Errors from the logic. I think it's probably safer to just ignore me - code has a habit of imploding in the most spectacular manner possible around me. QUICK_EDIT
Why is the AI not attacking? It takes a long time for the AI to attack and nothing I do fixes the problem. I test this in both my mod and the other. Is there any way to make the AI attack faster. QUICK_EDIT
Original AI.ini was made specifically for GDI and Nod. If some buildings are not part of the new
factions/sub-factions, many AI trigger's precondition won't be met. AI scripts also use building
numbers from [BuildingTypes] which they may not find in the opponent's side. One has to change
ai.ini accordingly. Even making the base defense scripts to attack with exception to repair bot etc.
could be an option to make it aggressive as a quick fix.
Various factors like team size/cost, buildtime, support teams, credit availability, base defense
teams/count etc. can also make AI stagnant. QUICK_EDIT
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