Author Topic: bank specific loadouts  (Read 4025 times)

0 Members and 1 Guest are viewing this topic.

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
bank specific loadouts
I have just completed the first version of bank specific loadouts, to enable this feature simply seperate an other list of weapons by a :
so for example

$Allowed PBanks:  ( "42mm Plasma" "40mm Pulse" ) : ( "42mm Plasma"  )

will yeild a ship that can have ether 42mm Plasma, or 40mm Pulse in the first bank, but only 42mm Plasma in the second bank
this should work for primary and secondary, normal and dogfight weapons (but I have only tested primary weapons)

I was also trying to fix a bug I had missed with the fighter beams, but my sister is nagging me so I have to get off the computer and I may have in fact made the problem worse
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline IceFire

  • GTVI Section 3
  • 212
    • http://www.3dap.com/hlp/hosted/ce
Beyond cool...this is great!
- IceFire
BlackWater Ops, Cold Element
"Burn the land, boil the sea, you can't take the sky from me..."

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
should I add this in for the imenent 3.5 relese?
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Knight Templar

  • Stealth
  • 212
  • I'm a magic man, I've got magic hands.
Si senor, por favor.
Copyright ©1976, 2003, KT Enterprises. All rights reserved

"I don't want to get laid right now. I want to get drunk."- Mars

Too Long, Didn't Read

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
well I was realy asking Inquisitor, seeing as he proclaimed a code freize for fixing all bugs and not adding any new functionality and i could be bringing in new bugs just before a new relese, though all the code involved only comes into play dureing table parseing and weapon select
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
well as I seem to have fixed the beam bug it might get commited anyway
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Great job! :yes:

I'd suggest changing the ":" to a "," before releasing it.  It fits in a lot better with the rest of the tbl syntax.
-C

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
*groan*

Sorry, Bobboau, it looks like this produced a whole slew of bugs.  Default weapons aren't working, some secondary stuff doesn't work, and some weapon mods aren't showing up. :doubt:

Which files did you change for this?

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
what bugs specificly?
I did test this, so I would like to know were it is failing

MissionUI/MissionWeaponChoice.cpp
ships table parseing code (in ships.cpp, specificly the stuff dealing with parseing alowwed weapons) and the allowed_weapons member of the ship_info structure

OK, I think I've got the bug fixed(about to test), but I'm not sure if I've added anything over the last day or two that might be a problem
« Last Edit: March 02, 2003, 10:52:41 pm by 57 »
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
ok, I'm realy realy sure I fixed it
Code: [Select]
int wl_swap_slot_slot(int from_bank, int to_bank, int ship_slot, int *sound)
{
wss_unit *slot;
slot = &Wss_slots[ship_slot];

if ( slot->ship_class == -1 ) {
Int3(); // should not be possible
return 0;
}

// do nothing if swapping with self
if ( from_bank == to_bank ) {
*sound=SND_ICON_DROP_ON_WING;
return 0; // no update
}

// ensure that source bank exists and has something to pick from
if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
return 0;
}

// ensure that the dest bank exists
if ( slot->wep_count[to_bank] < 0 ) {
return 0;
}
int tobank = to_bank, frombank = from_bank;
if(IS_BANK_SECONDARY(tobank))tobank -= 3;
if(IS_BANK_SECONDARY(frombank))frombank -=3;
//ensure that the two banks are both compatable types-Bobboau
if(!weapon_allowed_for_game_type(Ship_info[slot->ship_class].allowed_weapons[slot->wep[from_bank]][tobank])){
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "A %s can not carry %s weaponry in bank %d", Ship_info[slot->ship_class].name, Weapon_info[slot->wep[from_bank]].name, tobank+1);
return 0;
}
if(!weapon_allowed_for_game_type(Ship_info[slot->ship_class].allowed_weapons[slot->wep[to_bank]][frombank])){
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "A %s can not carry %s weaponry in bank %d", Ship_info[slot->ship_class].name, Weapon_info[slot->wep[to_bank]].name, frombank+1);
return 0;
}
//Warning(LOCATION,"slot slot");

// ensure that the banks are both of the same class
if ( (IS_BANK_PRIMARY(from_bank) && IS_BANK_SECONDARY(to_bank)) || (IS_BANK_SECONDARY(from_bank) && IS_BANK_PRIMARY(to_bank)) ) {
// put from_bank back into list
Wl_pool[slot->wep[from_bank]] += slot->wep_count[from_bank];; // return to list
slot->wep[from_bank] = -1; // remove from slot
slot->wep_count[from_bank] = 0;
*sound=SND_ICON_DROP;
return 1;
}

// case 1: primaries (easy, even with ballistics, because ammo is always maximized)
if ( IS_BANK_PRIMARY(from_bank) && IS_BANK_PRIMARY(to_bank) )
{
wl_swap_weapons(ship_slot, from_bank, to_bank);
*sound=SND_ICON_DROP_ON_WING;
return 1;
}

// case 2: secondaries (harder)
if ( IS_BANK_SECONDARY(from_bank) && IS_BANK_SECONDARY(to_bank) )
{
// case 2a: secondaries are the same type
if ( slot->wep[from_bank] == slot->wep[to_bank] ) {
int dest_max, dest_can_fit, source_can_give;
dest_max = wl_calc_missile_fit(slot->wep[to_bank], Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-3]);

dest_can_fit = dest_max - slot->wep_count[to_bank];

if ( dest_can_fit <= 0 ) {
// dest bank is already full.. nothing to do here
return 0;
}

// see how much source can give
source_can_give = min(dest_can_fit, slot->wep_count[from_bank]);

if ( source_can_give > 0 ) {
slot->wep_count[to_bank] += source_can_give; // add to dest
slot->wep_count[from_bank] -= source_can_give; // take from source
*sound=SND_ICON_DROP_ON_WING;
return 1;
} else {
return 0;
}
}

// case 2b: secondaries are different types
if ( slot->wep[from_bank] != slot->wep[to_bank] )
{
// swap 'em
wl_swap_weapons(ship_slot, from_bank, to_bank);

// put back some on list if required
wl_saturate_bank(ship_slot, from_bank);
wl_saturate_bank(ship_slot, to_bank);
*sound=SND_ICON_DROP_ON_WING;
return 1;
}
}

Int3(); // should never get here
return 0;
}

// exit: 0 -> no data changed
// 1 -> data changed
//       sound => gets filled with sound id to play
int wl_dump_to_list(int from_bank, int to_list, int ship_slot, int *sound)
{
wss_unit *slot;
slot = &Wss_slots[ship_slot];

// ensure that source bank exists and has something to pick from
if ( slot->wep[from_bank] == -1 || slot->wep_count[from_bank] <= 0 ) {
return 0;
}

// put weapon bank to the list
Wl_pool[to_list] += slot->wep_count[from_bank]; // return to list
slot->wep[from_bank] = -1; // remove from slot
slot->wep_count[from_bank] = 0;
*sound=SND_ICON_DROP;

return 1;
}

// exit: 0 -> no data changed
// 1 -> data changed
//       sound => gets filled with sound id to play
int wl_grab_from_list(int from_list, int to_bank, int ship_slot, int *sound)
{
wss_unit *slot;
slot = &Wss_slots[ship_slot];
int max_fit;

// ensure that the banks are both of the same class
if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) )
{
// do nothing
*sound=SND_ICON_DROP;
return 0;
}

// ensure that dest bank exists
if ( slot->wep_count[to_bank] < 0 ) {
*sound=SND_ICON_DROP;
return 0;
}

// bank should be empty:
Assert(slot->wep_count[to_bank] == 0);
Assert(slot->wep[to_bank] < 0);

// ensure that pool has weapon
if ( Wl_pool[from_list] <= 0 ) {
return 0;
}

int tobank = to_bank;
if(IS_BANK_SECONDARY(tobank))tobank -= 3;
//ensure that this bank can have this weapon-Bobboau
if(!weapon_allowed_for_game_type(Ship_info[slot->ship_class].allowed_weapons[Carried_wl_icon.weapon_class][tobank])){
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "A %s can not carry %s weaponry in bank %d", Ship_info[slot->ship_class].name, Weapon_info[Carried_wl_icon.weapon_class].name, tobank+1);
return 0;
}
//Warning(LOCATION,"list");
// find how much dest bank can fit
if ( to_bank < MAX_WL_PRIMARY )
{
max_fit = 1;
}
else
{
max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
}

// take weapon from list
if ( Wl_pool[from_list] < max_fit ) {
max_fit = Wl_pool[from_list];
}
Wl_pool[from_list] -= max_fit;

// put on the slot
slot->wep[to_bank] = from_list;
slot->wep_count[to_bank] = max_fit;

*sound=SND_ICON_DROP_ON_WING;
return 1;
}

// exit: 0 -> no data changed
// 1 -> data changed
//       sound => gets filled with sound id to play
int wl_swap_list_slot(int from_list, int to_bank, int ship_slot, int *sound)
{
wss_unit *slot;
slot = &Wss_slots[ship_slot];
int max_fit;

// ensure that the banks are both of the same class
if ( (IS_LIST_PRIMARY(from_list) && IS_BANK_SECONDARY(to_bank)) || (IS_LIST_SECONDARY(from_list) && IS_BANK_PRIMARY(to_bank)) ) {
// do nothing
*sound=SND_ICON_DROP;
return 0;
}

// ensure that dest bank exists
if ( slot->wep_count[to_bank] < 0 ) {
return 0;
}

// bank should have something in it
Assert(slot->wep_count[to_bank] > 0);
Assert(slot->wep[to_bank] >= 0);

// ensure that pool has weapon
if ( Wl_pool[from_list] <= 0 ) {
return 0;
}

//ensure that this bank can have this weapon-Bobboau
int tobank = to_bank;
if(IS_BANK_SECONDARY(tobank))tobank -= 3;
if(!weapon_allowed_for_game_type(Ship_info[slot->ship_class].allowed_weapons[Carried_wl_icon.weapon_class][tobank])){
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "A %s can not carry %s weaponry in bank %d", Ship_info[slot->ship_class].name, Weapon_info[Carried_wl_icon.weapon_class].name, tobank+1);
return 0;
}
//Warning(LOCATION,"list slot");
// dump slot weapon back into list
Wl_pool[slot->wep[to_bank]] += slot->wep_count[to_bank];
slot->wep_count[to_bank] = 0;
slot->wep[to_bank] = -1;

// put weapon on ship from list

// find how much dest bank can fit
if ( to_bank < MAX_WL_PRIMARY )
{
max_fit = 1;
}
else
{
max_fit = wl_calc_missile_fit(from_list, Ship_info[slot->ship_class].secondary_bank_ammo_capacity[to_bank-MAX_WL_PRIMARY]);
}

// take weapon from list
if ( Wl_pool[from_list] < max_fit ) {
max_fit = Wl_pool[from_list];
}
Wl_pool[from_list] -= max_fit;

// put on the slot
slot->wep[to_bank] = from_list;
slot->wep_count[to_bank] = max_fit;

*sound=SND_ICON_DROP_ON_WING;
return 1;
}


that is code from MissionUI/MissionWeaponChoice.cpp for four functions (one of wich (wl_dump_to_list) I did nothing to, but it was inbetween the others) this version of the code should work, I had forgoten that secondary banks are banknum - num_of_primary_banks

I'm not sure if I have other suprizes in my current code so I probly shouldn't commit it for fixing 3.5
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Well, commit your fix, since the bug is already in CVS.

Perhaps you should avoid punctuation altogether for your bank specific weapon table entry: just do

Code: [Select]
( "weapon 1" "weapon 2" "weapon 3" ) ( "weapon 1" )

instead of

Code: [Select]
( "weapon 1" "weapon 2" "weapon 3" ) : ( "weapon 1" )

to conform more with the table standard - all you have to do is check for the presence of another (...

Commit your fix, and I'll have a look at the code myself tomorrow.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
well if I check for a ( then the stuff int list thingy screws up, I need some sort of charicter or string to check for,

and ok I'll commit but there may be bugs in things that I can't think of, as I have played a little..
you know, why don't I just get a clean copy and fix it,
that... is something I should have done anyway, my mind is slipping:shaking:
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Parselo.cpp is your friend. :)

This function is what you want...
Code: [Select]
// similar to optional_string, but just checks if next token is a match.
// It doesn't advance Mp.
//
int check_for_string(char *pstr)
{
ignore_white_space();

if (!strnicmp(pstr, Mp, strlen(pstr)))
return 1;

return 0;
}


It will look for the parenthesis without eating it. :)


EDIT: So you do
Code: [Select]
if (check_for_string("("))
{
   z = stuff_string_list(...);      // find additional weapon lists
   ...
}

// continue as normal
« Last Edit: March 03, 2003, 02:23:39 am by 561 »

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
so it will work like optional_string but it won't move the file pointer?
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Right, that's what it should do.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
K, I removed the ":" requirement.  I'll look at the code more later.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Ugh.  Still bugs.  Bobboau, I tried PMming you, but your mailbox was full.  Can I try to take a look at rewriting it?  I think I could make it so that it's both mod-friendly and bug-free... :nervous:

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
go ahead, I have been short on time the last few days so I haven't been able to sit down and think
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Rewrite finished.  I'll post a thread on it momentarily.