Author Topic: capital+ flag for primary weapons  (Read 6287 times)

0 Members and 1 Guest are viewing this topic.

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
capital+ flag for primary weapons
As per the BP teams' request, I have gone forth and implemented a new flag for primary weapons. It is called "capital+", and it causes the AI to use the flagged weapon against capships only.

Patch: http://www.mediafire.com/?lmzgjgm2iww

Test builds: (Inferno SSE2 only) http://www.mediafire.com/?jnlmonm0vwt
« Last Edit: February 02, 2010, 06:02:47 am by The E »
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: capital+ flag for primary weapons
cool, now i can make the maelstrom not fire its 105mm gatling-howitzers at fighters.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: capital+ flag for primary weapons
Capital meaning destroyer and up?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: capital+ flag for primary weapons
Ships tagged as Cruiser, Capital or Supercap.

EDIT: Just realized that that was a stupid idea. The patch has been altered to use the SIF_BIG_SHIP and SIF_HUGE_SHIP tags.

http://www.mediafire.com/?lmzgjgm2iww
« Last Edit: February 02, 2010, 06:02:25 am by The E »
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: capital+ flag for primary weapons
Ehh ... doesn't the "huge" flag do more or less the same thing?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: capital+ flag for primary weapons
Huge is for secondaries. It has no effect on primary weapon selection.

A bit of background: WiH has a few fighter-mounted primaries that are intended to be used against big ships, and which are rather ineffective against fighters and bombers. The AI didn't know this, and based on the weapon stats, thought that it was a mighty fine idea to use these weapons on small targets anyway. In other words, they were not behaving as smartly as a human would in the same situation.
With this flag, they use their dogfight weapons, making them much more effective.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Fury

  • The Curmudgeon
  • 213
Re: capital+ flag for primary weapons
Ehh ... doesn't the "huge" flag do more or less the same thing?
"huge" flag as far as targeting goes, only affects turrets and secondaries. Like The E explained, AI still attempts to use "huge" fighter primaries against other fighters/bombers.

 

Offline Sushi

  • Art Critic
  • 211
Re: capital+ flag for primary weapons
Ehh ... doesn't the "huge" flag do more or less the same thing?
"huge" flag as far as targeting goes, only affects turrets and secondaries. Like The E explained, AI still attempts to use "huge" fighter primaries against other fighters/bombers.

So, the reason why we use a new flag (capital+) instead of modifying the behavior of the existing one (huge) is for backwards compatibility?

Maybe it would be simpler for modders to just have the huge flag, and add an AI Profiles option that makes the AI respect it for primaries (defaulted to NO)?

 

Offline Fury

  • The Curmudgeon
  • 213
Re: capital+ flag for primary weapons
FUBAR wanted to control it per-weapon.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: capital+ flag for primary weapons
I think you mean The E, unless it was originally FUBAR's idea and The E just happened to implement it.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: capital+ flag for primary weapons
Like The E explained, AI still attempts to use "huge" fighter primaries against other fighters/bombers.

I thought this had to do with "$Smart Secondary Weapon Selection:" ...

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: capital+ flag for primary weapons
Yes, it does. HOWEVER, as mentioned already, the "huge" flag HAS NO EFFECT when the AI tries to choose which _primary_ to use on an enemy.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Fury

  • The Curmudgeon
  • 213
Re: capital+ flag for primary weapons
I think you mean The E, unless it was originally FUBAR's idea and The E just happened to implement it.
No, I mean FUBAR. He took part in discussion on irc.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: capital+ flag for primary weapons
Committed 5894.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline TrashMan

  • T-tower Avenger. srsly.
  • 213
  • God-Emperor of your kind!
    • FLAMES OF WAR
Re: capital+ flag for primary weapons
Oww...YES. I needed this. I was getting sick of Claymores using wasting Redeemer ammo on fighters.
Nobody dies as a virgin - the life ****s us all!

You're a wrongularity from which no right can escape!

 

Offline TrashMan

  • T-tower Avenger. srsly.
  • 213
  • God-Emperor of your kind!
    • FLAMES OF WAR
Re: capital+ flag for primary weapons
So...is this now in the 3.6.12 RC?
Nobody dies as a virgin - the life ****s us all!

You're a wrongularity from which no right can escape!

 

Offline Fury

  • The Curmudgeon
  • 213
Re: capital+ flag for primary weapons
Yes

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: capital+ flag for primary weapons
 :bump:

Expanded capital+ to cover secondaries as well. Yes, this might seem redundant. Still, I think it can be useful.

Code: [Select]
Index: code/ai/aicode.cpp
===================================================================
--- code/ai/aicode.cpp (revision 6005)
+++ code/ai/aicode.cpp (working copy)
@@ -5849,7 +5849,7 @@
 // Favor aspect seekers when attacking small ships faraway.
 // Favor rapid fire dumbfire when attacking a large ship.
 // Ignore heat seekers because we're not sure how they'll work.
-void ai_select_secondary_weapon(object *objp, ship_weapon *swp, int priority1 = -1, int priority2 = -1)
+void ai_select_secondary_weapon(object *objp, ship_weapon *swp, int priority1 = -1, int priority2 = -1, int wif2_priority1 = -1, int wif2_priority2 = -1)
 {
  int num_weapon_types;
  int weapon_id_list[MAX_WEAPON_TYPES], weapon_bank_list[MAX_WEAPON_TYPES];
@@ -5869,6 +5869,11 @@
  ignore_mask |= WIF_HUGE;
  }
 
+ // Ignore capital+ unless one of the priorities asks for it.
+ if (!(WIF2_CAPITAL_PLUS & (wif2_priority1 | wif2_priority2))) {
+ ignore_mask |= WIF2_CAPITAL_PLUS;
+ }
+
  // Ignore bomber+ unless one of the priorities asks for them to be selected
  if (!(WIF_BOMBER_PLUS & (priority1 | priority2))) {
  ignore_mask |= WIF_BOMBER_PLUS;
@@ -5895,6 +5900,7 @@
 
  for (i=0; i<num_weapon_types; i++) {
  int wi_flags = Weapon_info[swp->secondary_bank_weapons[weapon_bank_list[i]]].wi_flags;
+ int wi_flags2 = Weapon_info[swp->secondary_bank_weapons[weapon_bank_list[i]]].wi_flags2;
  int ignore_mask_to_use = ((aip->ai_profile_flags & AIPF_SMART_SECONDARY_WEAPON_SELECTION) && (wi_flags & WIF_BOMBER_PLUS)) ? ignore_mask_without_huge : ignore_mask;
 
  if (!(wi_flags & ignore_mask_to_use)) { // Maybe bombs are illegal.
@@ -5904,6 +5910,13 @@
  } else if (wi_flags & priority2)
  priority2_index = weapon_bank_list[i]; // Found second priority, but might still find first priority.
  }
+ if (!(wi_flags2 & ignore_mask_to_use)) { // Maybe bombs are illegal.
+ if (wi_flags2 & wif2_priority1) {
+ swp->current_secondary_bank = weapon_bank_list[i]; // Found first priority, return it.
+ break;
+ } else if (wi_flags2 & wif2_priority2)
+ priority2_index = weapon_bank_list[i]; // Found second priority, but might still find first priority.
+ }
  }
 
  // Ignore homing weapons if we didn't specify a flag - for priority 2
@@ -7719,7 +7732,7 @@
 void ai_choose_secondary_weapon(object *objp, ai_info *aip, object *en_objp)
 {
  float subsystem_strength = 0.0f;
- int is_big_ship, priority1, priority2;
+ int is_big_ship, wif_priority1, wif_priority2, wif2_priority1, wif2_priority2;
  ship_weapon *swp;
  ship_info *esip;
 
@@ -7761,31 +7774,41 @@
 
  if (is_big_ship)
  {
- priority1 = WIF_HUGE;
- priority2 = (aip->ai_profile_flags & AIPF_SMART_SECONDARY_WEAPON_SELECTION) ? WIF_BOMBER_PLUS : WIF_HOMING;
+ wif_priority1 = WIF_HUGE;
+ wif_priority2 = (aip->ai_profile_flags & AIPF_SMART_SECONDARY_WEAPON_SELECTION) ? WIF_BOMBER_PLUS : WIF_HOMING;
+ wif2_priority1 = WIF2_CAPITAL_PLUS;
+ wif2_priority2 = 0;
  }
  else if ( (esip != NULL) && (esip->flags & SIF_BOMBER) )
  {
- priority1 = WIF_BOMBER_PLUS;
- priority2 = WIF_HOMING;
+ wif_priority1 = WIF_BOMBER_PLUS;
+ wif_priority2 = WIF_HOMING;
+ wif2_priority1 = 0;
+ wif2_priority2 = 0;
  }
  else if (subsystem_strength > 100.0f)
  {
- priority1 = WIF_PUNCTURE;
- priority2 = WIF_HOMING;
+ wif_priority1 = WIF_PUNCTURE;
+ wif_priority2 = WIF_HOMING;
+ wif2_priority1 = 0;
+ wif2_priority2 = 0;
  }
  else if ((aip->ai_profile_flags & AIPF_SMART_SECONDARY_WEAPON_SELECTION) && (en_objp->type == OBJ_ASTEROID)) //prefer dumbfires if its an asteroid
  {
- priority1 = 0;
- priority2 = 0;
+ wif_priority1 = 0;
+ wif_priority2 = 0;
+ wif2_priority1 = 0;
+ wif2_priority2 = 0;
  }
  else
  {
- priority1 = WIF_HOMING;
- priority2 = 0;
+ wif_priority1 = WIF_HOMING;
+ wif_priority2 = 0;
+ wif2_priority1 = 0;
+ wif2_priority2 = 0;
  }
 
- ai_select_secondary_weapon(objp, swp, priority1, priority2);
+ ai_select_secondary_weapon(objp, swp, wif_priority1, wif_priority2, wif2_priority1, wif2_priority2);
  }
 
  // nprintf(("AI", "Frame %i: Chose secondary %s\n", Framecount, Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]].name));
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: capital+ flag for primary weapons
Patch looks good.