Page 1 of 2

AI Weapon Linking

Posted: Wed Apr 30, 2014 7:05 pm
by Vadam
Just curious to know if there is a more reliable way to get the AI firing multiple weapons at the same time, other than fidgeting with the aiNames in the odf files.

Usually I just put in RocketTankFriend/Enemy in the Ai name but that isn't very reliable. I tried mashing all of the weapons into one weapon slot, and that worked, but its one big ugly mess that I'd rather avoid.

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 7:15 pm
by Red Devil
from pb4 changelog:


- Added support for explicitly specifying weapon groups (mantis #513):

[GameObjectClass]
weaponGroup<#> = <group> // group number, -1 for automatic

Hardpoints with automatic grouping join the group of the most recently
assigned similar hardpoint, regardless of how that hardpoint got there.

Mixed-type groups act like permanent multi-selection, though the weapon
status indicator only lists the last weapon in the group. [Ken]

example:


weaponMask = 00011

weaponGroup1 = 0
weaponHard1 = "HP_ROCKET_1"
weaponName1 = "gshadow_c"
weaponAssault1 = 0

weaponGroup2 = 1
weaponHard2 = "HP_ROCKET_3"
weaponName2 = ""
weaponAssault2 = 0

weaponGroup3 = 0
weaponHard3 = "HP_ROCKET_2"
weaponName3 = "gshadow_c"
weaponAssault3 = 0

weaponGroup4 = 2
weaponHard4 = "HP_SPECIAL_1"
weaponName4 = "gproxmin"
weaponAssault4 = 0

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 7:36 pm
by Vadam
Well that was easy.

I usually avoid the changelogs because of how confusing they can be to understand sometimes.
Thanks for slipping that edit with the example in

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 10:15 pm
by General BlackDragon
There is a new, better way, that doesnt force the ships weapons all into one group.

[CraftClass]
UseSelectWeapon = 1 // If > 0, enable SelectWeapon

Disabling SelectWeapon restores the original weapon selection and firing
logic that carried over from BZ1. The unit aims with a representative
weapon and fires every weapon in its weaponMask. [Ken]


So, under craftclass you set that to 0, or false, and then the ship will respect weaponmask, no matter the AI type.

This way, the ships weapons remain normal so if a player hops in, they can still use them properly.

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 10:57 pm
by Vadam
What does weaponMask even do? I have yet to figure that out on my own.

Also is it possible to have a ship selectively fire two weapons and then switch to a third assault weapon when facing an assault enemy?

Say I had a ship with a combat cannon, a combat rocket, and an assault rocket. I want to know if it can be made to fire its combat cannon and combat rocket at normal units and then switch to the assault rocket when appropriate. Preferably retaining the weapon status indicator when a player hops in so if the player just wants to use the cannon that would work too, otherwise I would just use the first method.

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 11:04 pm
by Zero Angel
WeaponMask is a feature that was previously only available on a few AI types (e.g. MorphTankFriend/Enemy, RocketTankFriend/Enemy, GuntowerFriend/Enemy). Setting this will specify what weapon hardpoints the AI will use when attacking.

For example:
11111 means use all 5 available hardpoints
00011 means use first 2 available weapons hardponts
11110 means use the second, third, fourth and fifth available hardpoints.

Most AI types ignore weaponmask, unless you set useSelectWeapon to 1.

However, the AI will now completely disregard switching to combat/assault weapons depedent on the target and will simply use whatever weapons you specify it to use in the weaponMask. This can be used to counter some unpleasant side effects of the combat/assault weapon setup such as assault tanks which attack combat targets with mortars (if so equipped) instead of their cannon.

Re: AI Weapon Linking

Posted: Wed Apr 30, 2014 11:47 pm
by MrTwosheds
Is there a way to force combat/assault switching in units that don't traditionally use it? eg a tank.

Re: AI Weapon Linking

Posted: Thu May 01, 2014 12:31 am
by Zero Angel
To my knowledge, no. This would be a nice feature to integrate into MPI. For example having a blast/chain tank attack an extractor with its chaingun, while it uses blast against combat vehicles, but even if you could -- it would require some kind of workaround that's heavily DLL driven, or you must fudge around with combat/assault hardpoints which can make things behave a bit strangely if a human ever gets his hands on an AI unit and tries to drop powerups.

I had at one point proposed a system whereas weapon selection was based on ODF flags, for example

gblast_c.odf

Code: Select all

combatPriority = 90
assaultPriority = 5
weaponBlastDist = 155
gchain_c.odf

Code: Select all

combatPriority = 60
assaultPriority = 80
weaponBlastDist = 80
Of course an overhaul like this is a rather big thing to request, and probably even bigger to implement in DLL. I'll have to wait for word from Blackdragon to see if something like this is even possible in DLL.

Re: AI Weapon Linking

Posted: Thu May 01, 2014 1:27 am
by Red Devil
for AIP's, in pb2:

- Added some new AIP plan chunk parameters

[Plan#]
planType = "Attacker" // for this type only
attackMode = -1 // -1 = auto, 0 = combat, 1 = assault

If this is specified, and the attacker is a deployable (not just a
morphtank), it will force the mode. If the unit is stolen by another
task or the idle dispatcher, the mode may stick. [NM]

Re: AI Weapon Linking

Posted: Thu May 01, 2014 8:19 am
by Zero Angel
Interesting find, RD.

Re: AI Weapon Linking

Posted: Thu May 01, 2014 10:00 am
by Ded10c
Horrendously simplified, but would something like this do the trick? You'd probably need a few new callbacks, I'm not up-to-date on what's available to DLL.

Code: Select all

if(target.isAssault == 1 && weapon.isAssault == 1) 
{
    //use the weapon
}

Re: AI Weapon Linking

Posted: Thu May 01, 2014 8:41 pm
by Vadam
How do units switch from combat to assault normally?

How does something like an assault tank know to use its assault weapon when you can't just slap an assault weapon on a sabre and expect it to do the same

Re: AI Weapon Linking

Posted: Thu May 01, 2014 9:30 pm
by Red Devil
that's due to the isAssault = true/false setting in the unit's ODF and in the weapon's ODF. the one in the weapon ODF is for determining which slot it matches up with in the unit.

Re: AI Weapon Linking

Posted: Thu May 01, 2014 10:08 pm
by Vadam
Okay, so to recap

In order to have a unit fire its assault weapon I have to set the unit itself and the weapon as assault.

Going back to the previous topic, then I would have to tie the combat and assault rocket into one group so the combat rocket would fire along with the assault rocket.

Which would allow a player to switch between just using the cannon or using both rockets while not having the AI fire all of the weapons, as opposed to using the weaponMask method instead.

However that would permanently fuse the rockets so it would be impossible to use the combat or assault one individually.

What did I miss?

Re: AI Weapon Linking

Posted: Thu May 01, 2014 10:40 pm
by Red Devil
the isAssault = true in the weapon ODF is just so that it "knows" to go in the slot when a powerup crate is picked up by that unit.

a player can use weapon linking to temporarily link multiple weapons to the fire action.