Made Max_used_objects an absolute defined value; Made num_objects globally available; Restricted Weapon drops to MAX_USED_OBJECTS; When dropping Secondary weapon, drop 4-pack if possible

This commit is contained in:
zicodxx 2009-02-17 11:34:16 +00:00
parent 084295bf96
commit 03db82be7d
4 changed files with 54 additions and 16 deletions

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20090217
--------
main/object.c, main/object.h, main/weapon.c: Made Max_used_objects an absolute defined value; Made num_objects globally available; Restricted Weapon drops to MAX_USED_OBJECTS; When dropping Secondary weapon, drop 4-pack if possible
20090215
--------
main/network.c, main/noloss.c, main/noloss.h: Added list to keep trace of received PDATA packets so receiver won't interpret them several times

View file

@ -2010,8 +2010,6 @@ void object_move_one( object * obj )
#endif //DEMO_ONLY
}
int Max_used_objects = MAX_OBJECTS - 20;
//--------------------------------------------------------------------
//move all objects for the current frame
void object_move_all()
@ -2019,8 +2017,8 @@ void object_move_all()
int i;
object *objp;
if (Highest_object_index > Max_used_objects)
free_object_slots(Max_used_objects); // Free all possible object slots.
if (Highest_object_index > MAX_USED_OBJECTS)
free_object_slots(MAX_USED_OBJECTS); // Free all possible object slots.
obj_delete_all_that_should_be_dead();

View file

@ -34,6 +34,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
#define MAX_OBJECTS 350 // increased on 01/24/95 for multiplayer. --MK; total number of objects in world
#define MAX_USED_OBJECTS (MAX_OBJECTS-20)
// Object types
#define OBJ_NONE 255 // unused object
@ -292,6 +293,7 @@ extern ubyte CollisionResult[MAX_OBJECT_TYPES][MAX_OBJECT_TYPES];
extern object Objects[];
extern int Highest_object_index; // highest objnum
extern int num_objects;
extern char *robot_names[]; // name of each robot

View file

@ -1084,6 +1084,9 @@ void DropCurrentWeapon ()
{
int objnum,ammo=0,seed;
if (num_objects >= MAX_USED_OBJECTS)
return;
if (Primary_weapon==0)
{
HUD_init_message("You cannot drop your base weapon!");
@ -1132,23 +1135,58 @@ void DropCurrentWeapon ()
auto_select_weapon (0);
}
void DropSecondaryWeapon ()
{
int objnum,seed;
ubyte weapon_drop_id=-1;
ushort sub_ammo=0;
if (num_objects >= MAX_USED_OBJECTS)
return;
if (Players[Player_num].secondary_ammo[Secondary_weapon] ==0)
{
HUD_init_message("No secondary weapon to drop!");
return;
}
weapon_drop_id = Secondary_weapon_to_powerup[Secondary_weapon];
if ((Secondary_weapon_to_powerup[Secondary_weapon]==POW_PROXIMITY_WEAPON ||
Secondary_weapon_to_powerup[Secondary_weapon]==POW_SMART_MINE) &&
Players[Player_num].secondary_ammo[Secondary_weapon]<4)
// see if we drop single or 4-pack
switch (Secondary_weapon_to_powerup[Secondary_weapon])
{
HUD_init_message("You need at least 4 to drop!");
return;
case POW_MISSILE_1:
case POW_HOMING_AMMO_1:
case POW_SMISSILE1_1:
case POW_GUIDED_MISSILE_1:
case POW_MERCURY_MISSILE_1:
if (Players[Player_num].secondary_ammo[Secondary_weapon]<4)
{
sub_ammo = 1;
}
else
{
sub_ammo = 4;
weapon_drop_id++; //4-pack always is next index
}
break;
case POW_PROXIMITY_WEAPON:
case POW_SMART_MINE:
if (Players[Player_num].secondary_ammo[Secondary_weapon]<4)
{
HUD_init_message("You need at least 4 to drop!");
return;
}
else
{
sub_ammo = 4;
}
break;
case POW_SMARTBOMB_WEAPON:
case POW_MEGA_WEAPON:
case POW_EARTHSHAKER_MISSILE:
sub_ammo = 1;
break;
}
HUD_init_message("%s dropped!",SECONDARY_WEAPON_NAMES(Secondary_weapon));
@ -1156,7 +1194,7 @@ void DropSecondaryWeapon ()
seed = d_rand();
objnum = spit_powerup(ConsoleObject,Secondary_weapon_to_powerup[Secondary_weapon],seed);
objnum = spit_powerup(ConsoleObject,weapon_drop_id,seed);
if (objnum<0)
return;
@ -1167,11 +1205,7 @@ void DropSecondaryWeapon ()
multi_send_drop_weapon(objnum,seed);
#endif
if (Secondary_weapon_to_powerup[Secondary_weapon]==POW_PROXIMITY_WEAPON ||
Secondary_weapon_to_powerup[Secondary_weapon]==POW_SMART_MINE)
Players[Player_num].secondary_ammo[Secondary_weapon]-=4;
else
Players[Player_num].secondary_ammo[Secondary_weapon]--;
Players[Player_num].secondary_ammo[Secondary_weapon]-=sub_ammo;
if (Players[Player_num].secondary_ammo[Secondary_weapon]==0)
{