View unanswered posts | View active topics It is currently Thu Mar 28, 2024 1:43 pm



Reply to topic  [ 12 posts ] 
 The CC B30 AI and mods (how to make the AI use your weapons) 
Author Message
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post The CC B30 AI and mods (how to make the AI use your weapons)
The AI and Groups
By adding your actors and weapons to certain groups in the ini-file you help the AI use them better.
Code:
AddToGroup = Light Infantry   // mobile AHumans
AddToGroup = Heavy Infantry   // less mobile AHumans
AddToGroup = Mecha    // crabs with offensive capability
AddToGroup = Anti-Air
AddToGroup = Crates    // drop-crates

AddToGroup = Grenades   // hand grenades
AddToGroup = Payloads   // bombs dropped from crafts
AddToGroup = Primary Weapons   // offensive weapons. the CPU-team actor's will select these if available in the actor's inventory
AddToGroup = Secondary Weapons   // self-defense weapons. very light sidearms
AddToGroup = Light Weapons       // primary weapons that does not restrict mobility much
AddToGroup = Sniper Weapons    // weapons with a high SharpLength and long range
AddToGroup = Heavy Weapons   // weapons that restrict mobility
AddToGroup = Explosive Weapons   // weapons with a blast radius

All groups except Primary Weapons and Secondary Weapons can be combined.
Example: a 10kg assault rifle should belong to both Primary Weapons and Light Weapons, but if it also have a huge SharpLength it may also be added to Sniper Weapons.


Weapons

Since v1.0 the AI looks at the projectile in the magazine and tries to calculate how to aim the weapon based on the projectile's properties. This means that if your weapon fires a null bullet (e.i. HitsMOs = 0) with a tiny life time, the AI will think that the weapon have a very short range. So if you make a lua-based weapons that does not use the projectile in the mag to do damage, you still have make the properties of the projectile in the mag similar to the properties of the lua-based attack.

The script look at the following properties:

Weapon.RateOfFire
Round.FireVel Override by setting AIFireVel (in m/s) on the Round.
Projectile.ClassName The AI may try to shoot through cover if MOPixel.
Projectile.Mass
Projectile.Sharpness
Projectile.GlobalAccScalar
Projectile.AirResistance
Projectile.AirThreshold
Projectile.Lifetime Override by setting AILifeTime (in ms) on the Round.

If your weapon have an area effect you can set AIBlastRadius (in pixels) on the Magazine.

Note that crabs still use the B29 AI scripts so they can only reliably use weapons with a flat trajectory.


Last edited by Abdul Alhazred on Wed May 14, 2014 8:24 am, edited 7 times in total.



Sat Nov 24, 2012 1:57 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: The CC v1.05 AI and mods
Regarding AI and Groups, do these various groups take priority over one-another, or should all the applicable groups be added?

For instance, if I have a compact assault rifle, would it be a Primary Light weapon, or just a Light weapon compared to an assault rifle that would be a Primary weapon? Is a rocket launcher a Primary Heavy Explosive weapon, or just an Explosive weapon? etc. etc.

Might be worth adding a 'Sniper Weapons' group as well, so actors know to switch to a different primary or a secondary if enemy actors are at very close range rather than trying to hit a close and mobile enemy with a slow-firing long-range weapon, unless they're scripted to do that already.

Also, a tip for weapons; remember you can make projectiles not hit MOs, and give them very low sharpness. That should avoid any weirdness with invisible bullets shredding terrain and enemy actors taking more damage than expected, without interfering with the range/target-finding scripts. I think.


Sat Nov 24, 2012 2:38 pm
Profile YIM
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: The CC v1.05 AI and mods
Thanks for the feedback Arcalane, I will update the OP to answer your questions better.

There actually is a Sniper Weapons group. I just forgot to add it. Unfortunately CC does not have any mechanisms to search the inventory exposed, so the AI can't reason all that much about when to use what weapon.


Sat Nov 24, 2012 2:55 pm
Profile
DRL Developer
DRL Developer
User avatar

Joined: Thu Jun 11, 2009 2:34 pm
Posts: 966
Location: Moscow, Russia
Reply with quote
Post Re: The CC v1.05 AI and mods
Thanks for the info about projectiles, I was just wondering why in the hell AI don't shoot my Lua-based weapons ))

To avoid any troubles with AI-code I've just attached all my scripts to actor's head, and then that scripts searched for it's parent actor during Create call.


Sat Nov 24, 2012 3:52 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: The CC v1.05 AI and mods
Good to hear, thanks for the heads up, and great job! Little question though, which properties does the AI look at when checking out the projectiles? LifeTime and FireVelocity are given, but what about GlobalAccScalar (for hitscan weapons)? I suppose it isn't that big a deal if you just up the FireVelocity enough, but it'd be nice to know.


Sat Nov 24, 2012 5:18 pm
Profile WWW

Joined: Fri Dec 30, 2011 3:33 am
Posts: 276
Reply with quote
Post Re: The CC v1.05 AI and mods
So, you guys basically copied the approach I used? Great, that's definitely the way to go. Has the load per AI thread decreased substantially?


Sat Nov 24, 2012 5:55 pm
Profile
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: The CC v1.05 AI and mods
The script look at the following properties:

Weapon.RateOfFire
Round.FireVel
Projectile.ClassName (if AEmitter: FireVel = max(FireVel, Sharpness) if MOPixel: the AI may try to shoot through cover)
Projectile.Mass
Projectile.Sharpness
Projectile.GlobalAccScalar
Projectile.AirResistance
Projectile.AirThreshold
Projectile.Lifetime


Sat Nov 24, 2012 6:35 pm
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: The CC v1.05 AI and mods
Oh wow, that's pretty extensive! Thanks for the list. So let me get this straight, if the projectile's an AEmitter, it takes Sharpness for a fire velocity if it's higher than the actual fire velocity? Because if it does, that pretty much eliminates any problems that could arise from using an AEmitter to bypass recoil and what not, which saves me a lot of work. Awesome.


Sat Nov 24, 2012 6:54 pm
Profile WWW
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: The CC v1.05 AI and mods
Yes that is right. The sharpness thing is a bit of a hack really. If you just want to circumvent recoil you can use RecoilTransmission = [0..1] in the ini-file instead.

The script is in the GetProjectileData function in HumanBehaviors.lua, by the way. Note that the ACrab-class does not have these functions exposed to lua (yet?) so crabs can only reliably use weapons with a flat trajectory.


Sat Nov 24, 2012 8:53 pm
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: The CC v1.05 AI and mods
Ugh, this thread should have been stickied long ago!

I didn't know why the AI wouldn't fire my AEmitter based weapons, but hopefuly I read this:
Abdul Alhazred wrote:
Projectile.ClassName (if AEmitter: FireVel = max(FireVel, Sharpness) if MOPixel: the AI may try to shoot through cover)


Tue Dec 18, 2012 4:23 am
Profile
User avatar

Joined: Thu Jun 21, 2012 3:38 pm
Posts: 122
Location: On a little island called Puerto Rico
Reply with quote
Post Re: The CC v1.05 AI and mods
I believe that this post should be bump up because it's pretty important. I just found it by mistake.

This post should be linked in the first one where it say's Everything you need to know about Modding CC

I already found so it doesn't matter to me but other people might not even Know about it. Just saying man, just saying.


Tue May 13, 2014 8:19 am
Profile
User avatar

Joined: Sun May 16, 2010 3:04 am
Posts: 52
Reply with quote
Post Re: The CC B30 AI and mods (how to make the AI use you weapons)
Yea this would have saved me hours last night.


Tue May 13, 2014 9:39 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.342s | 17 Queries | GZIP : Off ]