Ok, i started screwing around with the asteroid code today.. met it with mixed success
I tried adding two new asteroid types and increased the max number of asteroids.
The test is set to 1500 asteroids, collisions were broken, weapon sounds would play but nothing would come out. The increased number of asteroid types prevented it from crashing with the new table, but i didn't see any instances in which the larger asteroids where used
I could definantly use your help dave with the collision thing if you're reading
my changes to the header
#define MAX_ASTEROIDS 16384
// DEBRIS TYPES
#define MAX_DEBRIS_TYPES 14
#define ASTEROID_TYPE_SMALL 0
#define ASTEROID_TYPE_MEDIUM 1
#define ASTEROID_TYPE_BIG 2
#define ASTEROID_TYPE_HUGE 3
#define ASTEROID_TYPE_COLOSSAL 4
//
#define DEBRIS_TERRAN_SMALL 5
#define DEBRIS_TERRAN_MEDIUM 6
#define DEBRIS_TERRAN_LARGE 7
//
#define DEBRIS_VASUDAN_SMALL 8
#define DEBRIS_VASUDAN_MEDIUM 9
#define DEBRIS_VASUDAN_LARGE 10
//
#define DEBRIS_SHIVAN_SMALL 11
#define DEBRIS_SHIVAN_MEDIUM 12
#define DEBRIS_SHIVAN_LARGE 13
// END DEBRIS TYPES
from what it origionally was
and in the asteroid.cpp
void asteroid_create_all()
{
int i, idx;
// ship_debris_odds_table keeps track of debris type of the next debris piece
// each different type (size) of debris piece has a diffenent weight, smaller weighted more heavily than larger.
// choose next type from table ship_debris_odds_table by rand()%max_weighted_range,
// the first column in ship_debris_odds_table random number *below* which the debris type in the second column is selected.
int ship_debris_odds_table[3][2];
int max_weighted_range = 0;
if (!Asteroids_enabled)
return;
if (Asteroid_field.num_initial_asteroids <= 0 ) {
return;
}
int max_asteroids = Asteroid_field.num_initial_asteroids; // * (1.0f - 0.1f*(MAX_DETAIL_LEVEL-Detail.asteroid_density)));
int num_debris_types = 0;
// get number of ship debris types
if (Asteroid_field.debris_genre == DG_SHIP) {
for (idx=0; idx<3; idx++) {
if (Asteroid_field.field_debris_type[idx] != -1) {
num_debris_types++;
}
}
// Calculate the odds table
for (idx=0; idx int debris_weight = get_debris_weight(Asteroid_field.field_debris_type[idx]);
ship_debris_odds_table[idx][0] = max_weighted_range + debris_weight;
ship_debris_odds_table[idx][1] = Asteroid_field.field_debris_type[idx];
max_weighted_range += debris_weight;
}
}
// Load Asteroid/ship models
if (Asteroid_field.debris_genre == DG_SHIP) {
for (idx=0; idx asteroid_load(Asteroid_field.field_debris_type[idx], 0);
}
} else {
if (Asteroid_field.field_debris_type[0] != -1) {
asteroid_load(ASTEROID_TYPE_SMALL, 0);
asteroid_load(ASTEROID_TYPE_MEDIUM, 0);
asteroid_load(ASTEROID_TYPE_BIG, 0);
asteroid_load(ASTEROID_TYPE_HUGE, 0);
asteroid_load(ASTEROID_TYPE_COLOSSAL, 0);
}
if (Asteroid_field.field_debris_type[1] != -1) {
asteroid_load(ASTEROID_TYPE_SMALL, 1);
asteroid_load(ASTEROID_TYPE_MEDIUM, 1);
asteroid_load(ASTEROID_TYPE_BIG, 1);
asteroid_load(ASTEROID_TYPE_HUGE, 1);
asteroid_load(ASTEROID_TYPE_COLOSSAL, 1);
}
if (Asteroid_field.field_debris_type[2] != -1) {
asteroid_load(ASTEROID_TYPE_SMALL, 2);
asteroid_load(ASTEROID_TYPE_MEDIUM, 2);
asteroid_load(ASTEROID_TYPE_BIG, 2);
asteroid_load(ASTEROID_TYPE_HUGE, 2);
asteroid_load(ASTEROID_TYPE_COLOSSAL, 2);
}
}
// load all the asteroid/debris pieces
for (i=0; i if (Asteroid_field.debris_genre == DG_ASTEROID) {
// For asteroid, load only large asteroids
// the above comment was depricated by Kazan's changes, now selects between BIG [probably], HUGE [kinda probable], Colossal [unlikely]
int MainType = rand() % 9;
// get a valid subtype
int subtype = rand() % 3;
while (Asteroid_field.field_debris_type[subtype] == -1) {
subtype = (subtype + 1) % 3;
}
switch (MainType)
{
case 9:
asteroid_create(&Asteroid_field, ASTEROID_TYPE_COLOSSAL, subtype);
break;
case 8:
case 7:
asteroid_create(&Asteroid_field, ASTEROID_TYPE_HUGE, subtype);
break;
default:
asteroid_create(&Asteroid_field, ASTEROID_TYPE_BIG, subtype);
break;
}
} else {
Assert(num_debris_types > 0);
int rand_choice = rand() % max_weighted_range;
for (idx=0; idx<3; idx++) {
// for ship debris, choose type according to odds table
if (rand_choice < ship_debris_odds_table[idx][0]) {
asteroid_create(&Asteroid_field, ship_debris_odds_table[idx][1], 0);
break;
}
}
}
}
}
void asteriod_explode_sound(object *objp, int type, int play_loud)
{
int sound_index = -1;
float range_factor = 1.0f; // how many times sound should traver farther than normal
switch (type) {
case ASTEROID_TYPE_SMALL:
case ASTEROID_TYPE_MEDIUM:
case DEBRIS_TERRAN_SMALL:
case DEBRIS_TERRAN_MEDIUM:
case DEBRIS_VASUDAN_SMALL:
case DEBRIS_VASUDAN_MEDIUM:
case DEBRIS_SHIVAN_SMALL:
case DEBRIS_SHIVAN_MEDIUM:
sound_index = SND_ASTEROID_EXPLODE_SMALL;
range_factor = 5.0f;
break;
case ASTEROID_TYPE_BIG:
case ASTEROID_TYPE_HUGE:
case ASTEROID_TYPE_COLOSSAL:
case DEBRIS_TERRAN_LARGE:
case DEBRIS_VASUDAN_LARGE:
case DEBRIS_SHIVAN_LARGE:
sound_index = SND_ASTEROID_EXPLODE_BIG;
range_factor = 10.0f;
break;
default:
Int3();
return;
}
Assert(sound_index != -1);
if ( !play_loud ) {
range_factor = 1.0f;
}
snd_play_3d( &Snds[sound_index], &objp->pos, &Eye_position, objp->radius, NULL, 0, 1.0f, SND_PRIORITY_MUST_PLAY, NULL, range_factor );
}
void asteroid_maybe_break_up(object *asteroid_obj)
{
asteroid *asp;
asp = &Asteroids[asteroid_obj->instance];
if ( timestamp_elapsed(asp->final_death_time) ) {
vector relvec, vfh, tvec;
asteroid_obj->flags |= OF_SHOULD_BE_DEAD;
// multiplayer clients won't go through the following code. asteroid_sub_create will send
// a create packet to the client in the above named function
if ( !MULTIPLAYER_CLIENT ) {
switch (asp->type) {
case ASTEROID_TYPE_SMALL:
break;
case ASTEROID_TYPE_MEDIUM:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &tvec);
break;
case ASTEROID_TYPE_BIG:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &tvec);
while (frand() > 0.6f) {
vector rvec, tvec2;
vm_vec_rand_vec_quick(&rvec);
vm_vec_scale_add(&tvec2, &vfh, &rvec, 0.75f);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &tvec2);
}
case ASTEROID_TYPE_HUGE:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_BIG, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_BIG, &tvec);
while (frand() > 0.6f) {
vector rvec, tvec2;
vm_vec_rand_vec_quick(&rvec);
vm_vec_scale_add(&tvec2, &vfh, &rvec, 0.75f);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &tvec2);
}
case ASTEROID_TYPE_COLOSSAL:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_HUGE, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_HUGE, &tvec);
while (frand() > 0.6f) {
vector rvec, tvec2;
vm_vec_rand_vec_quick(&rvec);
vm_vec_scale_add(&tvec2, &vfh, &rvec, 0.75f);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_BIG, &tvec2);
}
break;
// ship debris does not break up
case DEBRIS_TERRAN_SMALL:
case DEBRIS_TERRAN_MEDIUM:
case DEBRIS_TERRAN_LARGE:
case DEBRIS_VASUDAN_SMALL:
case DEBRIS_VASUDAN_MEDIUM:
case DEBRIS_VASUDAN_LARGE:
case DEBRIS_SHIVAN_SMALL:
case DEBRIS_SHIVAN_MEDIUM:
case DEBRIS_SHIVAN_LARGE:
break;
default:
Int3();
}
}
asp->final_death_time = timestamp(-1);
}
}





