Author Topic: Asteroid Field Improvements Attempt (Images)  (Read 11938 times)

0 Members and 1 Guest are viewing this topic.

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
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

Quote

#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


Quote

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;
            }
         }
      }
   }
}



Quote

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 );
}


Quote

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);
   }
}







« Last Edit: July 12, 2002, 03:53:07 pm by 30 »
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Martinus

  • Aka Maeglamor
  • 210
    • Hard Light Productions
Asteroid Field Improvements Attempt (Images)
Wow it looks really dense and pretty atmospheric. i wouldn't like to escort a large ship through there. :)

Great work Kazan :nod:

 

Offline Redfang

  • 28
Asteroid Field Improvements Attempt (Images)
Nice. :yes:
 
At least when/if it will be fully functional.
 
Larger (huge) asteroids would be very nice. ;)
 
Edit: Huge asteroids... fighter cannons wouldn't do much, and you'd need beams or bombs to destroy them. Now that would be something I'd like. :nod:
« Last Edit: July 12, 2002, 04:11:38 pm by 665 »

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
ok, the larger asteroids ARE working, i just need to improve the odds for the COLOSSAL asteroid
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
hmm... that made it more interesting

collisions were working but i didn't change anything to make them work... weird - i'm tweaking the Colossal asteroid odds

weapons fire still borken - even the 10% damage cheat code was non functioning [after enabling cheats]



PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
OK, the collision detection/firing problems etc is just from the number of objects on the screen - the same problem you see with asteroid fields of size 256 with the existing executable, we need to figure out how to fix that
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Redfang

  • 28
Asteroid Field Improvements Attempt (Images)
:yes: Very nice. :yes2::yes:
 
Those seem to be pretty big now, but do they do more damage when they impact?
 
But what about destroyer (or so) sized asteroids?

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
Asteroid Field Improvements Attempt (Images)
i think there are too many objects on the screen for weapons fire to register. just my guess

code/object/object.h line 316

#define MAX_OBJECTS         1000
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline IceFire

  • GTVI Section 3
  • 212
    • http://www.3dap.com/hlp/hosted/ce
Asteroid Field Improvements Attempt (Images)
Perhaps thats sort of like when too many bitmaps are being rendered somewhere...the gun bitmaps stop showing up.

Happened in OTT with one of Venom's guns and a particular ship.  Too many bitmaps being rendered and they stoped being rendered.
- IceFire
BlackWater Ops, Cold Element
"Burn the land, boil the sea, you can't take the sky from me..."

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
that fixed it a bit phreak, but it quickly crashed
« Last Edit: July 12, 2002, 08:57:45 pm by 30 »
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline penguin

  • Eudyptes codus
  • 28
  • Still alive.
Asteroid Field Improvements Attempt (Images)
Quote
Originally posted by Kazan
that fixed it a bit freak, but it quickly crashed
Are you running a debug build?  Is it spewing out anything useful before it dies?  Try turning Log_debug_output_to_file on and see what gets dumped to fs.log, if anything...
your source code slave

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
no i was running a release, hoping for performance
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Ask me about GORT!
    • Steam
    • User page on the FreeSpace Wiki
Asteroid Field Improvements Attempt (Images)
Hmm... I'm looking for the smaller asteroids to be in there, too. We need humongous and smaller ones there.

We know the average asteroid speed is applied to every asteroid, right? Is there any way for larger asteroids to move slower while small ones zip around?
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Asteroid Field Improvements Attempt (Images)
I'm getting a buch of weird errors from osapi.h all of the sudden after trying to turn that Log_debug_output_to_file thing on (still getting it after I turn it off),
Code: [Select]

D:\Games\projects\freespace2_public\code\OsApi\OsApi.h(57) : error C2146: syntax error : missing ';' before identifier 'os_get_window'
D:\Games\projects\freespace2_public\code\OsApi\OsApi.h(57) : error C2501: 'uint' : missing storage-class or type specifiers
D:\Games\projects\freespace2_public\code\OsApi\OsApi.h(57) : fatal error C1004: unexpected end of file found


I haven't changed anything in here so why did this just start hapening

and this is the line it doesn't like

uint os_get_window();
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 Fineus

  • ...But you *have* heard of me.
  • Administrator
  • 212
    • Hard Light Productions
Asteroid Field Improvements Attempt (Images)
Impressive work! Nice one!

What are the chances of being about to do some small asteroids that spawn when the larger ones are destroyed? And by small I mean tiny. I know the game already makes slightly smaller asteroids when a large one is destroyed but it doesn't really feel like chunks of rock. I'd love to see about 50 something small (read, about a meter) large chunks of rock flying off away from destroyed asteroids. It'd make taking asteroids out a lot more interesting since those things can be bad for your shields if you let them hit you...

(I'm just getting heavily inspired from the asteroid field scene in SW2:AOTC).

 

Offline Vasudan Admiral

  • Member
  • 211
    • Twisted Infinities
Asteroid Field Improvements Attempt (Images)
mabey if the asteroids were far lower poly count, or a far away lod was 2d, it might be easier for the game to handle. that is definatly a more realistic asteroid field. lower polyed asteroids might make it work better. *guess*
Get the 2014 Media VPs and report any bugs you find in them to the FSU Mantis so that we may squish them. || Blender to POF model conversion guide
Twisted Infinities

 

Offline Hudzy

  • Apollo Pilot
  • 28
Asteroid Field Improvements Attempt (Images)
Quote
Originally posted by Thunder
Impressive work! Nice one!

What are the chances of being about to do some small asteroids that spawn when the larger ones are destroyed? And by small I mean tiny. I know the game already makes slightly smaller asteroids when a large one is destroyed but it doesn't really feel like chunks of rock. I'd love to see about 50 something small (read, about a meter) large chunks of rock flying off away from destroyed asteroids. It'd make taking asteroids out a lot more interesting since those things can be bad for your shields if you let them hit you...

(I'm just getting heavily inspired from the asteroid field scene in SW2:AOTC).


It always looked to me like the mass of the two smaller ones that spawned from the destroyed larger one was actually greater than the original larger one.

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
btw: if you want to make planetary rings instead of asteroid fields - it's kinda doable with this code - you just have to replace the POFs for the asteroids
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Asteroid Field Improvements Attempt (Images)
im still having problems with collision detection... ideas?
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Inquisitor

Asteroid Field Improvements Attempt (Images)
Did the crashes stop?
No signature.