2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
56 #define EXPLOSION_SCALE (F1_0*5/2) //explosion is the obj size times this
59 //--unused-- ubyte Frame_processed[MAX_OBJECTS];
63 object *object_create_explosion_sub(object *objp, short segnum, vms_vector * position, fix size, int vclip_type, fix maxdamage, fix maxdistance, fix maxforce, int parent )
68 objnum = obj_create( OBJ_FIREBALL,vclip_type,segnum,position,&vmd_identity_matrix,size,
69 CT_EXPLOSION,MT_NONE,RT_FIREBALL);
72 mprintf((1, "Can't create object in object_create_explosion_sub.\n"));
76 obj = &Objects[objnum];
78 //mprintf( 0, "Fireball created at %d, %d, %d\n", obj->pos.x, obj->pos.y, obj->pos.z );
80 //now set explosion-specific data
82 obj->lifeleft = Vclip[vclip_type ].play_time;
83 obj->ctype.expl_info.spawn_time = -1;
84 obj->ctype.expl_info.delete_objnum = -1;
85 obj->ctype.expl_info.delete_time = -1;
89 vms_vector pos_hit, vforce;
92 object * obj0p = &Objects[0];
94 // -- now legal for badass explosions on a wall. Assert(objp != NULL);
96 for (i=0; i<=Highest_object_index; i++ ) {
97 // Weapons used to be affected by badass explosions, but this introduces serious problems.
98 // When a smart bomb blows up, if one of its children goes right towards a nearby wall, it will
99 // blow up, blowing up all the children. So I remove it. MK, 09/11/94
100 if ( (obj0p!=objp) && !(obj0p->flags&OF_SHOULD_BE_DEAD) && ((obj0p->type==OBJ_WEAPON && (obj0p->id==PROXIMITY_ID || obj0p->id==SUPERPROX_ID || obj0p->id==PMINE_ID)) || (obj0p->type == OBJ_CNTRLCEN) || (obj0p->type==OBJ_PLAYER) || ((obj0p->type==OBJ_ROBOT) && ((Objects[parent].type != OBJ_ROBOT) || (Objects[parent].id != obj0p->id))))) {
101 dist = vm_vec_dist_quick( &obj0p->pos, &obj->pos );
102 // Make damage be from 'maxdamage' to 0.0, where 0.0 is 'maxdistance' away;
103 if ( dist < maxdistance ) {
104 if (object_to_object_visibility(obj, obj0p, FQ_TRANSWALL)) {
106 damage = maxdamage - fixmuldiv( dist, maxdamage, maxdistance );
107 force = maxforce - fixmuldiv( dist, maxforce, maxdistance );
109 // Find the force vector on the object
110 vm_vec_normalized_dir_quick( &vforce, &obj0p->pos, &obj->pos );
111 vm_vec_scale(&vforce, force );
113 // Find where the point of impact is... ( pos_hit )
114 vm_vec_scale(vm_vec_sub(&pos_hit, &obj->pos, &obj0p->pos), fixdiv(obj0p->size, obj0p->size + dist));
116 switch ( obj0p->type ) {
118 phys_apply_force(obj0p,&vforce);
120 if (obj0p->id == PROXIMITY_ID || obj0p->id == SUPERPROX_ID) { //prox bombs have chance of blowing up
121 if (fixmul(dist,force) > i2f(8000)) {
122 obj0p->flags |= OF_SHOULD_BE_DEAD;
123 explode_badass_weapon(obj0p,&obj0p->pos);
130 phys_apply_force(obj0p,&vforce);
132 // If not a boss, stun for 2 seconds at 32 force, 1 second at 16 force
133 if ((objp != NULL) && (!Robot_info[obj0p->id].boss_flag) && (Weapon_info[objp->id].flash)) {
134 ai_static *aip = &obj0p->ctype.ai_info;
135 int force_val = f2i(fixdiv(vm_vec_mag_quick(&vforce) * Weapon_info[objp->id].flash, FrameTime)/128) + 2;
137 if (obj->ctype.ai_info.SKIP_AI_COUNT * FrameTime < F1_0) {
138 aip->SKIP_AI_COUNT += force_val;
139 obj0p->mtype.phys_info.rotthrust.x = ((d_rand() - 16384) * force_val)/16;
140 obj0p->mtype.phys_info.rotthrust.y = ((d_rand() - 16384) * force_val)/16;
141 obj0p->mtype.phys_info.rotthrust.z = ((d_rand() - 16384) * force_val)/16;
142 obj0p->mtype.phys_info.flags |= PF_USES_THRUST;
144 //@@if (Robot_info[obj0p->id].companion)
145 //@@ buddy_message("Daisy, Daisy, Give me...");
147 aip->SKIP_AI_COUNT--;
151 // When a robot gets whacked by a badass force, he looks towards it because robots tend to get blasted from behind.
153 vms_vector neg_vforce;
154 neg_vforce.x = vforce.x * -2 * (7 - Difficulty_level)/8;
155 neg_vforce.y = vforce.y * -2 * (7 - Difficulty_level)/8;
156 neg_vforce.z = vforce.z * -2 * (7 - Difficulty_level)/8;
157 phys_apply_rot(obj0p,&neg_vforce);
159 if ( obj0p->shields >= 0 ) {
160 if (Robot_info[obj0p->id].boss_flag)
161 if (Boss_invulnerable_matter[Robot_info[obj0p->id].boss_flag-BOSS_D2])
164 if (apply_damage_to_robot(obj0p, damage, parent))
165 if ((objp != NULL) && (parent == Players[Player_num].objnum))
166 add_points_to_score(Robot_info[obj0p->id].score_value);
169 if ((objp != NULL) && (Robot_info[obj0p->id].companion) && (!Weapon_info[objp->id].flash)) {
171 char ouch_str[6*4 + 2];
173 count = f2i(damage/8);
179 for (i=0; i<count; i++)
180 strcat(ouch_str, "ouch! ");
182 buddy_message(ouch_str);
187 if ( obj0p->shields >= 0 ) {
188 apply_damage_to_controlcen(obj0p, damage, parent );
192 object * killer=NULL;
195 // Hack! Warning! Test code!
196 if ((objp != NULL) && Weapon_info[objp->id].flash && obj0p->id==Player_num) {
199 fe = min(F1_0*4, force*Weapon_info[objp->id].flash/32); // For four seconds or less
201 if (objp->ctype.laser_info.parent_signature == ConsoleObject->signature) {
207 PALETTE_FLASH_ADD(PK1 + f2i(PK2*force), PK1 + f2i(PK2*force), PK1 + f2i(PK2*force));
208 mprintf((0, "force = %7.3f, adding %i\n", f2fl(force), PK1 + f2i(PK2*force)));
212 if ((objp != NULL) && (Game_mode & GM_MULTI) && (objp->type == OBJ_PLAYER)) {
217 killer = &Objects[parent];
218 if (killer != ConsoleObject) // if someone else whacks you, cut force by 2x
219 vforce2.x /= 2; vforce2.y /= 2; vforce2.z /= 2;
221 vforce2.x /= 2; vforce2.y /= 2; vforce2.z /= 2;
223 phys_apply_force(obj0p,&vforce);
224 phys_apply_rot(obj0p,&vforce2);
225 if (Difficulty_level == 0)
227 if ( obj0p->shields >= 0 )
228 apply_damage_to_player(obj0p, killer, damage );
233 Int3(); // Illegal object type
236 ; // mprintf((0, "No badass: robot=%2i, dist=%7.3f, maxdistance=%7.3f .\n", i, f2fl(dist), f2fl(maxdistance)));
237 } // end if (object_to_object_visibility...
238 } // end if (dist < maxdistance)
242 } // end if (maxdamage...
251 object *object_create_muzzle_flash(short segnum, vms_vector * position, fix size, int vclip_type )
253 return object_create_explosion_sub(NULL, segnum, position, size, vclip_type, 0, 0, 0, -1 );
256 object *object_create_explosion(short segnum, vms_vector * position, fix size, int vclip_type )
258 return object_create_explosion_sub(NULL, segnum, position, size, vclip_type, 0, 0, 0, -1 );
261 object *object_create_badass_explosion(object *objp, short segnum, vms_vector * position, fix size, int vclip_type, fix maxdamage, fix maxdistance, fix maxforce, int parent )
265 rval = object_create_explosion_sub(objp, segnum, position, size, vclip_type, maxdamage, maxdistance, maxforce, parent );
267 if ((objp != NULL) && (objp->type == OBJ_WEAPON))
268 create_smart_children(objp, NUM_SMART_CHILDREN);
270 // -- if (objp->type == OBJ_ROBOT)
271 // -- if (Robot_info[objp->id].smart_blobs)
272 // -- create_smart_children(objp, Robot_info[objp->id].smart_blobs);
277 //blows up a badass weapon, creating the badass explosion
278 //return the explosion object
279 object *explode_badass_weapon(object *obj,vms_vector *pos)
281 weapon_info *wi = &Weapon_info[obj->id];
283 Assert(wi->damage_radius);
285 if ((obj->id == EARTHSHAKER_ID) || (obj->id == ROBOT_EARTHSHAKER_ID))
288 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, obj-Objects, 0, F1_0);
290 return object_create_badass_explosion( obj, obj->segnum, pos,
293 wi->strength[Difficulty_level],
294 wi->damage_radius,wi->strength[Difficulty_level],
295 obj->ctype.laser_info.parent_num );
299 object *explode_badass_object(object *objp, fix damage, fix distance, fix force)
304 rval = object_create_badass_explosion(objp, objp->segnum, &objp->pos, objp->size,
305 get_explosion_vclip(objp, 0),
306 damage, distance, force,
309 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, rval-Objects, 0, F1_0);
315 //blows up the player with a badass explosion
316 //return the explosion object
317 object *explode_badass_player(object *objp)
319 return explode_badass_object(objp, F1_0*50, F1_0*40, F1_0*150);
323 #define DEBRIS_LIFE (f1_0 * 2) //lifespan in seconds
325 object *object_create_debris(object *parent, int subobj_num)
331 Assert((parent->type == OBJ_ROBOT) || (parent->type == OBJ_PLAYER) );
333 objnum = obj_create(OBJ_DEBRIS,0,parent->segnum,&parent->pos,
334 &parent->orient,Polygon_models[parent->rtype.pobj_info.model_num].submodel_rads[subobj_num],
335 CT_DEBRIS,MT_PHYSICS,RT_POLYOBJ);
337 if ((objnum < 0 ) && (Highest_object_index >= MAX_OBJECTS-1)) {
338 mprintf((1, "Can't create object in object_create_debris.\n"));
343 return NULL; // Not enough debris slots!
344 obj = &Objects[objnum];
346 Assert(subobj_num < 32);
348 //Set polygon-object-specific data
350 obj->rtype.pobj_info.model_num = parent->rtype.pobj_info.model_num;
351 obj->rtype.pobj_info.subobj_flags = 1<<subobj_num;
352 obj->rtype.pobj_info.tmap_override = parent->rtype.pobj_info.tmap_override;
354 //Set physics data for this object
356 po = &Polygon_models[obj->rtype.pobj_info.model_num];
358 obj->mtype.phys_info.velocity.x = RAND_MAX/2 - d_rand();
359 obj->mtype.phys_info.velocity.y = RAND_MAX/2 - d_rand();
360 obj->mtype.phys_info.velocity.z = RAND_MAX/2 - d_rand();
361 vm_vec_normalize_quick(&obj->mtype.phys_info.velocity);
362 vm_vec_scale(&obj->mtype.phys_info.velocity,i2f(10 + (30 * d_rand() / RAND_MAX)));
364 vm_vec_add2(&obj->mtype.phys_info.velocity,&parent->mtype.phys_info.velocity);
366 // -- used to be: Notice, not random! vm_vec_make(&obj->mtype.phys_info.rotvel,10*0x2000/3,10*0x4000/3,10*0x7000/3);
367 vm_vec_make(&obj->mtype.phys_info.rotvel, d_rand() + 0x1000, d_rand()*2 + 0x4000, d_rand()*3 + 0x2000);
368 vm_vec_zero(&obj->mtype.phys_info.rotthrust);
370 obj->lifeleft = 3*DEBRIS_LIFE/4 + fixmul(d_rand(), DEBRIS_LIFE); // Some randomness, so they don't all go away at the same time.
372 obj->mtype.phys_info.mass = fixmuldiv(parent->mtype.phys_info.mass,obj->size,parent->size);
373 obj->mtype.phys_info.drag = 0; //fl2f(0.2); //parent->mtype.phys_info.drag;
379 void draw_fireball(object *obj)
381 //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, obj->id, obj->size );
383 if ( obj->lifeleft > 0 )
384 draw_vclip_object(obj,obj->lifeleft,0, obj->id);
388 // --------------------------------------------------------------------------------------------------------------------
389 // Return true if there is a door here and it is openable
390 // It is assumed that the player has all keys.
391 int door_is_openable_by_player(segment *segp, int sidenum)
393 int wall_num, wall_type;
395 wall_num = segp->sides[sidenum].wall_num;
396 wall_type = Walls[wall_num].type;
399 return 0; // no wall here.
401 // Can't open locked doors.
402 if (((wall_type == WALL_DOOR) && (Walls[wall_num].flags & WALL_DOOR_LOCKED)) || (wall_type == WALL_CLOSED))
409 #define QUEUE_SIZE 64
411 // --------------------------------------------------------------------------------------------------------------------
412 // Return a segment %i segments away from initial segment.
413 // Returns -1 if can't find a segment that distance away.
414 int pick_connected_segment(object *objp, int max_depth)
420 int seg_queue[QUEUE_SIZE*2];
421 byte visited[MAX_SEGMENTS];
422 byte depth[MAX_SEGMENTS];
423 byte side_rand[MAX_SIDES_PER_SEGMENT];
425 // mprintf((0, "Finding a segment %i segments away from segment %i: ", max_depth, objp->segnum));
427 start_seg = objp->segnum;
430 seg_queue[head++] = start_seg;
432 memset(visited, 0, Highest_segment_index+1);
433 memset(depth, 0, Highest_segment_index+1);
436 for (i=0; i<MAX_SIDES_PER_SEGMENT; i++)
439 // Now, randomize a bit to start, so we don't always get started in the same direction.
440 for (i=0; i<4; i++) {
443 ind1 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
444 temp = side_rand[ind1];
445 side_rand[ind1] = side_rand[i];
450 while (tail != head) {
453 int ind1, ind2, temp;
455 if (cur_depth >= max_depth) {
456 // mprintf((0, "selected segment %i\n", seg_queue[tail]));
457 return seg_queue[tail];
460 segp = &Segments[seg_queue[tail++]];
461 tail &= QUEUE_SIZE-1;
463 // to make random, switch a pair of entries in side_rand.
464 ind1 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
465 ind2 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
466 temp = side_rand[ind1];
467 side_rand[ind1] = side_rand[ind2];
468 side_rand[ind2] = temp;
471 for (sidenum=ind1; count<MAX_SIDES_PER_SEGMENT; count++) {
472 int snrand, wall_num;
474 if (sidenum == MAX_SIDES_PER_SEGMENT)
477 snrand = side_rand[sidenum];
478 wall_num = segp->sides[snrand].wall_num;
481 if (((wall_num == -1) && (segp->children[snrand] > -1)) || door_is_openable_by_player(segp, snrand)) {
482 if (visited[segp->children[snrand]] == 0) {
483 seg_queue[head++] = segp->children[snrand];
484 visited[segp->children[snrand]] = 1;
485 depth[segp->children[snrand]] = cur_depth+1;
486 head &= QUEUE_SIZE-1;
488 if (head == tail + QUEUE_SIZE-1)
489 Int3(); // queue overflow. Make it bigger!
491 if (head+QUEUE_SIZE == tail + QUEUE_SIZE-1)
492 Int3(); // queue overflow. Make it bigger!
496 if ((seg_queue[tail] < 0) || (seg_queue[tail] > Highest_segment_index)) {
497 // -- Int3(); // Something bad has happened. Queue is trashed. --MK, 12/13/94
500 cur_depth = depth[seg_queue[tail]];
503 mprintf((0, "...failed at depth %i, returning -1\n", cur_depth));
508 #define BASE_NET_DROP_DEPTH 8
510 // ------------------------------------------------------------------------------------------------------
511 // Choose segment to drop a powerup in.
512 // For all active net players, try to create a N segment path from the player. If possible, return that
513 // segment. If not possible, try another player. After a few tries, use a random segment.
514 // Don't drop if control center in segment.
515 int choose_drop_segment()
522 vms_vector tempv,*player_pos;
524 mprintf((0,"choose_drop_segment:"));
526 d_srand(timer_get_fixed_seconds());
528 cur_drop_depth = BASE_NET_DROP_DEPTH + ((d_rand() * BASE_NET_DROP_DEPTH*2) >> 15);
530 player_pos = &Objects[Players[Player_num].objnum].pos;
531 player_seg = Objects[Players[Player_num].objnum].segnum;
533 while ((segnum == -1) && (cur_drop_depth > BASE_NET_DROP_DEPTH/2)) {
534 pnum = (d_rand() * N_players) >> 15;
536 while ((count < N_players) && ((Players[pnum].connected == 0) || (pnum==Player_num) || ((Game_mode & (GM_TEAM|GM_CAPTURE)) && (get_team(pnum)==get_team(Player_num))))) {
537 pnum = (pnum+1)%N_players;
541 if (count == N_players) {
542 //if can't valid non-player person, use the player
545 //mprintf((1, "Warning: choose_drop_segment: Couldn't find legal drop segment because no connected players.\n"));
546 //return (d_rand() * Highest_segment_index) >> 15;
549 segnum = pick_connected_segment(&Objects[Players[pnum].objnum], cur_drop_depth);
550 mprintf((0," %d",segnum));
556 if (Segment2s[segnum].special == SEGMENT_IS_CONTROLCEN)
557 {segnum = -1; mprintf((0,"C")); }
558 else { //don't drop in any children of control centers
561 int ch = Segments[segnum].children[i];
562 if (IS_CHILD(ch) && Segment2s[ch].special == SEGMENT_IS_CONTROLCEN) {
570 //bail if not far enough from original position
572 compute_segment_center(&tempv, &Segments[segnum]);
573 if (find_connected_distance(player_pos,player_seg,&tempv,segnum,-1,WID_FLY_FLAG) < i2f(20)*cur_drop_depth) {
583 mprintf((0," dist=%x\n",find_connected_distance(player_pos,player_seg,&tempv,segnum,-1,WID_FLY_FLAG)));
586 mprintf((1, "Warning: Unable to find a connected segment. Picking a random one.\n"));
587 return (d_rand() * Highest_segment_index) >> 15;
595 // ------------------------------------------------------------------------------------------------------
596 // Drop cloak powerup if in a network game.
598 extern char PowerupsInMine[],MaxPowerupsAllowed[];
600 void maybe_drop_net_powerup(int powerup_type)
602 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) {
606 if (Game_mode & GM_NETWORK)
608 if (PowerupsInMine[powerup_type]>=MaxPowerupsAllowed[powerup_type])
613 if (Control_center_destroyed || Endlevel_sequence)
616 segnum = choose_drop_segment();
617 //--old-- segnum = (d_rand() * Highest_segment_index) >> 15;
618 //--old-- Assert((segnum >= 0) && (segnum <= Highest_segment_index));
619 //--old-- if (segnum < 0)
620 //--old-- segnum = -segnum;
621 //--old-- while (segnum > Highest_segment_index)
622 //--old-- segnum /= 2;
625 objnum = call_object_create_egg(&Objects[Players[Player_num].objnum], 1, OBJ_POWERUP, powerup_type);
630 pick_random_point_in_seg(&new_pos, segnum);
632 multi_send_create_powerup(powerup_type, segnum, objnum, &new_pos);
634 Objects[objnum].pos = new_pos;
635 vm_vec_zero(&Objects[objnum].mtype.phys_info.velocity);
636 obj_relink(objnum, segnum);
638 object_create_explosion(segnum, &new_pos, i2f(5), VCLIP_POWERUP_DISAPPEARANCE );
639 // mprintf(0, "Creating net powerup in segment %i at %7.3f %7.3f %7.3f\n", segnum, f2fl(new_pos.x), f2fl(new_pos.y), f2fl(new_pos.z));
644 // ------------------------------------------------------------------------------------------------------
645 // Return true if current segment contains some object.
646 int segment_contains_object(int obj_type, int obj_id, int segnum)
653 objnum = Segments[segnum].objects;
656 if ((Objects[objnum].type == obj_type) && (Objects[objnum].id == obj_id))
659 objnum = Objects[objnum].next;
664 // ------------------------------------------------------------------------------------------------------
665 int object_nearby_aux(int segnum, int object_type, int object_id, int depth)
672 if (segment_contains_object(object_type, object_id, segnum))
675 for (i=0; i<MAX_SIDES_PER_SEGMENT; i++) {
676 int seg2 = Segments[segnum].children[i];
679 if (object_nearby_aux(seg2, object_type, object_id, depth-1))
687 // ------------------------------------------------------------------------------------------------------
688 // Return true if some powerup is nearby (within 3 segments).
689 int weapon_nearby(object *objp, int weapon_id)
691 return object_nearby_aux(objp->segnum, OBJ_POWERUP, weapon_id, 3);
694 // ------------------------------------------------------------------------------------------------------
695 void maybe_replace_powerup_with_energy(object *del_obj)
699 if (del_obj->contains_type != OBJ_POWERUP)
702 if (del_obj->contains_id == POW_CLOAK) {
703 if (weapon_nearby(del_obj, del_obj->contains_id)) {
704 mprintf((0, "Bashing cloak into nothing because there's one nearby.\n"));
705 del_obj->contains_count = 0;
709 switch (del_obj->contains_id) {
710 case POW_VULCAN_WEAPON: weapon_index = VULCAN_INDEX; break;
711 case POW_GAUSS_WEAPON: weapon_index = GAUSS_INDEX; break;
712 case POW_SPREADFIRE_WEAPON: weapon_index = SPREADFIRE_INDEX; break;
713 case POW_PLASMA_WEAPON: weapon_index = PLASMA_INDEX; break;
714 case POW_FUSION_WEAPON: weapon_index = FUSION_INDEX; break;
716 case POW_HELIX_WEAPON: weapon_index = HELIX_INDEX; break;
717 case POW_PHOENIX_WEAPON: weapon_index = PHOENIX_INDEX; break;
718 case POW_OMEGA_WEAPON: weapon_index = OMEGA_INDEX; break;
722 // Don't drop vulcan ammo if player maxed out.
723 if (((weapon_index == VULCAN_INDEX) || (del_obj->contains_id == POW_VULCAN_AMMO)) && (Players[Player_num].primary_ammo[VULCAN_INDEX] >= VULCAN_AMMO_MAX))
724 del_obj->contains_count = 0;
725 else if (((weapon_index == GAUSS_INDEX) || (del_obj->contains_id == POW_VULCAN_AMMO)) && (Players[Player_num].primary_ammo[VULCAN_INDEX] >= VULCAN_AMMO_MAX))
726 del_obj->contains_count = 0;
727 else if (weapon_index != -1) {
728 if ((player_has_weapon(weapon_index, 0) & HAS_WEAPON_FLAG) || weapon_nearby(del_obj, del_obj->contains_id)) {
729 if (d_rand() > 16384) {
730 del_obj->contains_type = OBJ_POWERUP;
731 if (weapon_index == VULCAN_INDEX) {
732 del_obj->contains_id = POW_VULCAN_AMMO;
733 } else if (weapon_index == GAUSS_INDEX) {
734 del_obj->contains_id = POW_VULCAN_AMMO;
736 del_obj->contains_id = POW_ENERGY;
739 del_obj->contains_type = OBJ_POWERUP;
740 del_obj->contains_id = POW_SHIELD_BOOST;
743 } else if (del_obj->contains_id == POW_QUAD_FIRE)
744 if ((Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) || weapon_nearby(del_obj, del_obj->contains_id)) {
745 if (d_rand() > 16384) {
746 del_obj->contains_type = OBJ_POWERUP;
747 del_obj->contains_id = POW_ENERGY;
749 del_obj->contains_type = OBJ_POWERUP;
750 del_obj->contains_id = POW_SHIELD_BOOST;
754 // If this robot was gated in by the boss and it now contains energy, make it contain nothing,
755 // else the room gets full of energy.
756 if ( (del_obj->matcen_creator == BOSS_GATE_MATCEN_NUM) && (del_obj->contains_id == POW_ENERGY) && (del_obj->contains_type == OBJ_POWERUP) ) {
757 mprintf((0, "Converting energy powerup to nothing because robot %i gated in by boss.\n", del_obj-Objects));
758 del_obj->contains_count = 0;
761 // Change multiplayer extra-lives into invulnerability
762 if ((Game_mode & GM_MULTI) && (del_obj->contains_id == POW_EXTRA_LIFE))
764 del_obj->contains_id = POW_INVULNERABILITY;
768 int drop_powerup(int type, int id, int num, vms_vector *init_vel, vms_vector *pos, int segnum)
772 vms_vector new_velocity, new_pos;
778 for (count=0; count<num; count++) {
780 new_velocity = *init_vel;
781 old_mag = vm_vec_mag_quick(init_vel);
783 // We want powerups to move more in network mode.
784 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_ROBOTS)) {
786 // extra life powerups are converted to invulnerability in multiplayer, for what is an extra life, anyway?
787 if (id == POW_EXTRA_LIFE)
788 id = POW_INVULNERABILITY;
792 new_velocity.x += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
793 new_velocity.y += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
794 new_velocity.z += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
796 // Give keys zero velocity so they can be tracked better in multi
798 if ((Game_mode & GM_MULTI) && (id >= POW_KEY_BLUE) && (id <= POW_KEY_GOLD))
799 vm_vec_zero(&new_velocity);
802 // new_pos.x += (d_rand()-16384)*8;
803 // new_pos.y += (d_rand()-16384)*8;
804 // new_pos.z += (d_rand()-16384)*8;
807 if (Game_mode & GM_MULTI)
809 if (Net_create_loc >= MAX_NET_CREATE_OBJECTS)
811 mprintf( (1, "Not enough slots to drop all powerups!\n" ));
814 if ((Game_mode & GM_NETWORK) && Network_status == NETSTAT_ENDLEVEL)
818 objnum = obj_create( type, id, segnum, &new_pos, &vmd_identity_matrix, Powerup_info[id].size, CT_POWERUP, MT_PHYSICS, RT_POWERUP);
821 mprintf((1, "Can't create object in object_create_egg. Aborting.\n"));
827 if (Game_mode & GM_MULTI)
829 Net_create_objnums[Net_create_loc++] = objnum;
833 obj = &Objects[objnum];
835 obj->mtype.phys_info.velocity = new_velocity;
837 // mprintf(0, "Created powerup, object #%i, velocity = %7.3f %7.3f %7.3f\n", objnum, f2fl(new_velocity.x), f2fl(new_velocity.y), f2fl(new_velocity.z));
838 // mprintf(0, " pos = x=%d y=%d z=%d\n", obj->pos.x, obj->pos.y, obj->pos.z);
840 obj->mtype.phys_info.drag = 512; //1024;
841 obj->mtype.phys_info.mass = F1_0;
843 obj->mtype.phys_info.flags = PF_BOUNCE;
845 obj->rtype.vclip_info.vclip_num = Powerup_info[obj->id].vclip_num;
846 obj->rtype.vclip_info.frametime = Vclip[obj->rtype.vclip_info.vclip_num].frame_time;
847 obj->rtype.vclip_info.framenum = 0;
852 case POW_SHIELD_BOOST:
854 obj->lifeleft = (d_rand() + F1_0*3) * 64; // Lives for 3 to 3.5 binary minutes (a binary minute is 64 seconds)
855 if (Game_mode & GM_MULTI)
859 // if (Game_mode & GM_MULTI)
860 // obj->lifeleft = (d_rand() + F1_0*3) * 64; // Lives for 5 to 5.5 binary minutes (a binary minute is 64 seconds)
867 for (count=0; count<num; count++) {
869 new_velocity = *init_vel;
870 old_mag = vm_vec_mag_quick(init_vel);
872 vm_vec_normalize_quick(&new_velocity);
874 // We want powerups to move more in network mode.
875 // if (Game_mode & GM_MULTI)
880 new_velocity.x += (d_rand()-16384)*2;
881 new_velocity.y += (d_rand()-16384)*2;
882 new_velocity.z += (d_rand()-16384)*2;
884 vm_vec_normalize_quick(&new_velocity);
885 vm_vec_scale(&new_velocity, (F1_0*32 + old_mag) * rand_scale);
887 // This is dangerous, could be outside mine.
888 // new_pos.x += (d_rand()-16384)*8;
889 // new_pos.y += (d_rand()-16384)*7;
890 // new_pos.z += (d_rand()-16384)*6;
892 objnum = obj_create(OBJ_ROBOT, id, segnum, &new_pos, &vmd_identity_matrix, Polygon_models[Robot_info[id].model_num].rad, CT_AI, MT_PHYSICS, RT_POLYOBJ);
895 mprintf((1, "Can't create object in object_create_egg, robots. Aborting.\n"));
901 if (Game_mode & GM_MULTI)
903 Net_create_objnums[Net_create_loc++] = objnum;
907 obj = &Objects[objnum];
909 //@@Took out this ugly hack 1/12/96, because Mike has added code
910 //@@that should fix it in a better way.
911 //@@//this is a super-ugly hack. Since the baby stripe robots have
912 //@@//their firing point on their bounding sphere, the firing points
913 //@@//can poke through a wall if the robots are very close to it. So
914 //@@//we make their radii bigger so the guns can't get too close to
916 //@@if (Robot_info[obj->id].flags & RIF_BIG_RADIUS)
917 //@@ obj->size = (obj->size*3)/2;
919 //Set polygon-object-specific data
921 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
922 obj->rtype.pobj_info.subobj_flags = 0;
926 obj->mtype.phys_info.velocity = new_velocity;
928 obj->mtype.phys_info.mass = Robot_info[obj->id].mass;
929 obj->mtype.phys_info.drag = Robot_info[obj->id].drag;
931 obj->mtype.phys_info.flags |= (PF_LEVELLING);
933 obj->shields = Robot_info[obj->id].strength;
935 obj->ctype.ai_info.behavior = AIB_NORMAL;
936 Ai_local_info[obj-Objects].player_awareness_type = PA_WEAPON_ROBOT_COLLISION;
937 Ai_local_info[obj-Objects].player_awareness_time = F1_0*3;
938 obj->ctype.ai_info.CURRENT_STATE = AIS_LOCK;
939 obj->ctype.ai_info.GOAL_STATE = AIS_LOCK;
940 obj->ctype.ai_info.REMOTE_OWNER = -1;
943 // At JasenW's request, robots which contain robots sometimes drop shields.
944 if (d_rand() > 16384)
945 drop_powerup(OBJ_POWERUP, POW_SHIELD_BOOST, 1, init_vel, pos, segnum);
950 Error("Error: Illegal type (%i) in object spawning.\n", type);
956 // ------------------------------------------------------------------------------------------------------
957 // Returns created object number.
958 // If object dropped by player, set flag.
959 int object_create_egg(object *objp)
963 if (!(Game_mode & GM_MULTI) & (objp->type != OBJ_PLAYER))
965 if (objp->contains_type == OBJ_POWERUP)
967 if (objp->contains_id == POW_SHIELD_BOOST) {
968 if (Players[Player_num].shields >= i2f(100)) {
969 if (d_rand() > 16384) {
970 mprintf((0, "Not dropping shield!\n"));
973 } else if (Players[Player_num].shields >= i2f(150)) {
974 if (d_rand() > 8192) {
975 mprintf((0, "Not dropping shield!\n"));
979 } else if (objp->contains_id == POW_ENERGY) {
980 if (Players[Player_num].energy >= i2f(100)) {
981 if (d_rand() > 16384) {
982 mprintf((0, "Not dropping energy!\n"));
985 } else if (Players[Player_num].energy >= i2f(150)) {
986 if (d_rand() > 8192) {
987 mprintf((0, "Not dropping energy!\n"));
995 rval = drop_powerup(objp->contains_type, objp->contains_id, objp->contains_count, &objp->mtype.phys_info.velocity, &objp->pos, objp->segnum);
999 if ((objp->type == OBJ_PLAYER) && (objp->id == Player_num))
1000 Objects[rval].flags |= OF_PLAYER_DROPPED;
1002 if (objp->type == OBJ_ROBOT && objp->contains_type==OBJ_POWERUP)
1004 if (objp->contains_id==POW_VULCAN_WEAPON || objp->contains_id==POW_GAUSS_WEAPON)
1005 Objects[rval].ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT;
1006 else if (objp->contains_id==POW_OMEGA_WEAPON)
1007 Objects[rval].ctype.powerup_info.count = MAX_OMEGA_CHARGE;
1014 // -- extern int Items_destroyed;
1016 // -------------------------------------------------------------------------------------------------------
1017 // Put count objects of type type (eg, powerup), id = id (eg, energy) into *objp, then drop them! Yippee!
1018 // Returns created object number.
1019 int call_object_create_egg(object *objp, int count, int type, int id)
1021 // -- if (!(Game_mode & GM_MULTI) && (objp == ConsoleObject))
1022 // -- if (d_rand() < 32767/6) {
1023 // -- Items_destroyed++;
1028 objp->contains_count = count;
1029 objp->contains_type = type;
1030 objp->contains_id = id;
1031 return object_create_egg(objp);
1037 //what vclip does this explode with?
1038 int get_explosion_vclip(object *obj,int stage)
1040 if (obj->type==OBJ_ROBOT) {
1042 if (stage==0 && Robot_info[obj->id].exp1_vclip_num>-1)
1043 return Robot_info[obj->id].exp1_vclip_num;
1044 else if (stage==1 && Robot_info[obj->id].exp2_vclip_num>-1)
1045 return Robot_info[obj->id].exp2_vclip_num;
1048 else if (obj->type==OBJ_PLAYER && Player_ship->expl_vclip_num>-1)
1049 return Player_ship->expl_vclip_num;
1051 return VCLIP_SMALL_EXPLOSION; //default
1054 //blow up a polygon model
1055 void explode_model(object *obj)
1057 Assert(obj->render_type == RT_POLYOBJ);
1059 if (Dying_modelnums[obj->rtype.pobj_info.model_num] != -1)
1060 obj->rtype.pobj_info.model_num = Dying_modelnums[obj->rtype.pobj_info.model_num];
1062 if (Polygon_models[obj->rtype.pobj_info.model_num].n_models > 1) {
1065 for (i=1;i<Polygon_models[obj->rtype.pobj_info.model_num].n_models;i++)
1066 if (!(obj->type == OBJ_ROBOT && obj->id == 44 && i == 5)) //energy sucker energy part
1067 object_create_debris(obj,i);
1069 //make parent object only draw center part
1070 obj->rtype.pobj_info.subobj_flags=1;
1074 //if the object has a destroyed model, switch to it. Otherwise, delete it.
1075 void maybe_delete_object(object *del_obj)
1077 if (Dead_modelnums[del_obj->rtype.pobj_info.model_num] != -1) {
1078 del_obj->rtype.pobj_info.model_num = Dead_modelnums[del_obj->rtype.pobj_info.model_num];
1079 del_obj->flags |= OF_DESTROYED;
1081 else { //normal, multi-stage explosion
1082 if (del_obj->type == OBJ_PLAYER)
1083 del_obj->render_type = RT_NONE;
1085 del_obj->flags |= OF_SHOULD_BE_DEAD;
1089 // -------------------------------------------------------------------------------------------------------
1090 //blow up an object. Takes the object to destroy, and the point of impact
1091 void explode_object(object *hitobj,fix delay_time)
1093 if (hitobj->flags & OF_EXPLODING) return;
1095 if (delay_time) { //wait a little while before creating explosion
1099 //create a placeholder object to do the delay, with id==-1
1101 objnum = obj_create( OBJ_FIREBALL,-1,hitobj->segnum,&hitobj->pos,&vmd_identity_matrix,0,
1102 CT_EXPLOSION,MT_NONE,RT_NONE);
1105 maybe_delete_object(hitobj); //no explosion, die instantly
1106 mprintf((1,"Couldn't start explosion, deleting object now\n"));
1111 obj = &Objects[objnum];
1113 //now set explosion-specific data
1115 obj->lifeleft = delay_time;
1116 obj->ctype.expl_info.delete_objnum = hitobj-Objects;
1118 if (obj->ctype.expl_info.delete_objnum < 0)
1121 obj->ctype.expl_info.delete_time = -1;
1122 obj->ctype.expl_info.spawn_time = 0;
1129 vclip_num = get_explosion_vclip(hitobj,0);
1131 expl_obj = object_create_explosion(hitobj->segnum, &hitobj->pos, fixmul(hitobj->size,EXPLOSION_SCALE), vclip_num );
1134 maybe_delete_object(hitobj); //no explosion, die instantly
1135 mprintf((0,"Couldn't start explosion, deleting object now\n"));
1139 //don't make debris explosions have physics, because they often
1140 //happen when the debris has hit the wall, so the fireball is trying
1141 //to move into the wall, which shows off FVI problems.
1142 if (hitobj->type!=OBJ_DEBRIS && hitobj->movement_type==MT_PHYSICS) {
1143 expl_obj->movement_type = MT_PHYSICS;
1144 expl_obj->mtype.phys_info = hitobj->mtype.phys_info;
1147 if (hitobj->render_type==RT_POLYOBJ && hitobj->type!=OBJ_DEBRIS)
1148 explode_model(hitobj);
1150 maybe_delete_object(hitobj);
1153 hitobj->flags |= OF_EXPLODING; //say that this is blowing up
1154 hitobj->control_type = CT_NONE; //become inert while exploding
1159 //do whatever needs to be done for this piece of debris for this frame
1160 void do_debris_frame(object *obj)
1162 Assert(obj->control_type == CT_DEBRIS);
1164 if (obj->lifeleft < 0)
1165 explode_object(obj,0);
1169 extern void drop_stolen_items(object *objp);
1171 //do whatever needs to be done for this explosion for this frame
1172 void do_explosion_sequence(object *obj)
1174 Assert(obj->control_type == CT_EXPLOSION);
1176 //mprintf( 0, "Object %d life left is %d\n", obj-Objects, obj->lifeleft );
1178 //See if we should die of old age
1179 if (obj->lifeleft <= 0 ) { // We died of old age
1180 obj->flags |= OF_SHOULD_BE_DEAD;
1184 //See if we should create a secondary explosion
1185 if (obj->lifeleft <= obj->ctype.expl_info.spawn_time) {
1186 object *expl_obj,*del_obj;
1188 vms_vector *spawn_pos;
1190 if ((obj->ctype.expl_info.delete_objnum < 0) || (obj->ctype.expl_info.delete_objnum > Highest_object_index)) {
1191 mprintf((0, "Illegal value for delete_objnum in fireball.c\n"));
1192 Int3(); // get Rob, please... thanks
1196 del_obj = &Objects[obj->ctype.expl_info.delete_objnum];
1198 spawn_pos = &del_obj->pos;
1200 if (!((del_obj->type==OBJ_ROBOT || del_obj->type==OBJ_CLUTTER || del_obj->type==OBJ_CNTRLCEN || del_obj->type == OBJ_PLAYER) && (del_obj->segnum != -1))) {
1201 Int3(); //pretty bad
1205 vclip_num = get_explosion_vclip(del_obj,1);
1207 if (del_obj->type == OBJ_ROBOT && Robot_info[del_obj->id].badass)
1208 expl_obj = object_create_badass_explosion( NULL, del_obj->segnum, spawn_pos, fixmul(del_obj->size, EXPLOSION_SCALE), vclip_num, F1_0*Robot_info[del_obj->id].badass, i2f(4)*Robot_info[del_obj->id].badass, i2f(35)*Robot_info[del_obj->id].badass, -1 );
1210 expl_obj = object_create_explosion( del_obj->segnum, spawn_pos, fixmul(del_obj->size, EXPLOSION_SCALE), vclip_num );
1212 if ((del_obj->contains_count > 0) && !(Game_mode & GM_MULTI)) { // Multiplayer handled outside of this code!!
1213 // If dropping a weapon that the player has, drop energy instead, unless it's vulcan, in which case drop vulcan ammo.
1214 if (del_obj->contains_type == OBJ_POWERUP)
1215 maybe_replace_powerup_with_energy(del_obj);
1216 object_create_egg(del_obj);
1217 } else if ((del_obj->type == OBJ_ROBOT) && !(Game_mode & GM_MULTI)) { // Multiplayer handled outside this code!!
1218 robot_info *robptr = &Robot_info[del_obj->id];
1219 if (robptr->contains_count) {
1220 if (((d_rand() * 16) >> 15) < robptr->contains_prob) {
1221 del_obj->contains_count = ((d_rand() * robptr->contains_count) >> 15) + 1;
1222 del_obj->contains_type = robptr->contains_type;
1223 del_obj->contains_id = robptr->contains_id;
1224 maybe_replace_powerup_with_energy(del_obj);
1225 object_create_egg(del_obj);
1230 drop_stolen_items(del_obj);
1232 if (robptr->companion) {
1233 DropBuddyMarker(del_obj);
1237 if ( Robot_info[del_obj->id].exp2_sound_num > -1 )
1238 digi_link_sound_to_pos( Robot_info[del_obj->id].exp2_sound_num, del_obj->segnum, 0, spawn_pos, 0, F1_0 );
1239 //PLAY_SOUND_3D( Robot_info[del_obj->id].exp2_sound_num, spawn_pos, del_obj->segnum );
1241 // mprintf( 0, "Spawned an explosion of type %d\n", Robot_info[del_obj->id].exp2_vclip_num );
1243 //mprintf( 0, "Object %d spawned.\n", obj-Objects );
1244 //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z );
1245 //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z );
1246 //mprintf( 0, "Spawned exp at %d,%d,%d\n", expl_obj->pos.x, expl_obj->pos.y, expl_obj->pos.z );
1248 obj->ctype.expl_info.spawn_time = -1;
1251 if (del_obj->render_type==RT_POLYOBJ)
1252 explode_model(del_obj); //explode a polygon model
1254 //set some parm in explosion
1257 if (del_obj->movement_type == MT_PHYSICS) {
1258 expl_obj->movement_type = MT_PHYSICS;
1259 expl_obj->mtype.phys_info = del_obj->mtype.phys_info;
1262 expl_obj->ctype.expl_info.delete_time = expl_obj->lifeleft/2;
1263 expl_obj->ctype.expl_info.delete_objnum = del_obj-Objects;
1265 if (obj->ctype.expl_info.delete_objnum < 0)
1271 maybe_delete_object(del_obj);
1272 mprintf((0,"Couldn't create secondary explosion, deleting object now\n"));
1277 //See if we should delete an object
1278 if (obj->lifeleft <= obj->ctype.expl_info.delete_time) {
1279 object *del_obj = &Objects[obj->ctype.expl_info.delete_objnum];
1281 obj->ctype.expl_info.delete_time = -1;
1283 maybe_delete_object(del_obj);
1287 #define EXPL_WALL_TIME (f1_0)
1288 #define EXPL_WALL_TOTAL_FIREBALLS 32
1289 #define EXPL_WALL_FIREBALL_SIZE (0x48000*6/10) //smallest size
1291 expl_wall expl_wall_list[MAX_EXPLODING_WALLS];
1293 void init_exploding_walls()
1297 for (i=0;i<MAX_EXPLODING_WALLS;i++)
1298 expl_wall_list[i].segnum = -1;
1301 //explode the given wall
1302 void explode_wall(int segnum,int sidenum)
1309 for (i=0;i<MAX_EXPLODING_WALLS && expl_wall_list[i].segnum != -1;i++);
1311 if (i==MAX_EXPLODING_WALLS) { //didn't find slot.
1312 mprintf((0,"Couldn't find free slot for exploding wall!\n"));
1317 expl_wall_list[i].segnum = segnum;
1318 expl_wall_list[i].sidenum = sidenum;
1319 expl_wall_list[i].time = 0;
1321 //play one long sound for whole door wall explosion
1322 compute_center_point_on_side(&pos,&Segments[segnum],sidenum);
1323 digi_link_sound_to_pos( SOUND_EXPLODING_WALL,segnum, sidenum, &pos, 0, F1_0 );
1327 //handle walls for this frame
1328 //note: this wall code assumes the wall is not triangulated
1329 void do_exploding_wall_frame()
1333 for (i=0;i<MAX_EXPLODING_WALLS;i++) {
1334 int segnum = expl_wall_list[i].segnum;
1337 int sidenum = expl_wall_list[i].sidenum;
1338 fix oldfrac,newfrac;
1339 int old_count,new_count,e; //n,
1341 oldfrac = fixdiv(expl_wall_list[i].time,EXPL_WALL_TIME);
1343 expl_wall_list[i].time += FrameTime;
1344 if (expl_wall_list[i].time > EXPL_WALL_TIME)
1345 expl_wall_list[i].time = EXPL_WALL_TIME;
1347 if (expl_wall_list[i].time>(EXPL_WALL_TIME*3)/4) {
1348 segment *seg,*csegp;
1351 seg = &Segments[segnum];
1353 a = Walls[seg->sides[sidenum].wall_num].clip_num;
1354 n = WallAnims[a].num_frames;
1356 csegp = &Segments[seg->children[sidenum]];
1357 cside = find_connect_side(seg, csegp);
1359 wall_set_tmap_num(seg,sidenum,csegp,cside,a,n-1);
1361 Walls[seg->sides[sidenum].wall_num].flags |= WALL_BLASTED;
1362 Walls[csegp->sides[cside].wall_num].flags |= WALL_BLASTED;
1366 newfrac = fixdiv(expl_wall_list[i].time,EXPL_WALL_TIME);
1368 old_count = f2i(EXPL_WALL_TOTAL_FIREBALLS * fixmul(oldfrac,oldfrac));
1369 new_count = f2i(EXPL_WALL_TOTAL_FIREBALLS * fixmul(newfrac,newfrac));
1371 //n = new_count - old_count;
1373 // mprintf(0,"Creating %d new explosions\n",new_count-old_count);
1375 //now create all the next explosions
1377 for (e=old_count;e<new_count;e++) {
1378 short vertnum_list[4];
1379 vms_vector *v0,*v1,*v2;
1380 vms_vector vv0,vv1,pos;
1383 //calc expl position
1385 get_side_verts(vertnum_list,segnum,sidenum);
1387 v0 = &Vertices[vertnum_list[0]];
1388 v1 = &Vertices[vertnum_list[1]];
1389 v2 = &Vertices[vertnum_list[2]];
1391 vm_vec_sub(&vv0,v0,v1);
1392 vm_vec_sub(&vv1,v2,v1);
1394 vm_vec_scale_add(&pos,v1,&vv0,d_rand()*2);
1395 vm_vec_scale_add2(&pos,&vv1,d_rand()*2);
1397 size = EXPL_WALL_FIREBALL_SIZE + (2*EXPL_WALL_FIREBALL_SIZE * e / EXPL_WALL_TOTAL_FIREBALLS);
1399 //fireballs start away from door, with subsequent ones getting closer
1403 get_side_normal(&Segments[segnum], sidenum, 0, &_vn );
1404 vm_vec_scale_add2(&pos,&_vn,size*(EXPL_WALL_TOTAL_FIREBALLS-e)/EXPL_WALL_TOTAL_FIREBALLS);
1407 vm_vec_scale_add2(&pos,&Segments[segnum].sides[sidenum].normals[0],size*(EXPL_WALL_TOTAL_FIREBALLS-e)/EXPL_WALL_TOTAL_FIREBALLS);
1410 if (e & 3) //3 of 4 are normal
1411 object_create_explosion(expl_wall_list[i].segnum,&pos,size,VCLIP_SMALL_EXPLOSION);
1413 object_create_badass_explosion( NULL, expl_wall_list[i].segnum, &pos,
1415 VCLIP_SMALL_EXPLOSION,
1416 i2f(4), // damage strength
1417 i2f(20), // damage radius
1418 i2f(50), // damage force
1425 if (expl_wall_list[i].time >= EXPL_WALL_TIME)
1426 expl_wall_list[i].segnum = -1; //flag this slot as free
1434 //creates afterburner blobs behind the specified object
1435 void drop_afterburner_blobs(object *obj, int count, fix size_scale, fix lifetime)
1437 vms_vector pos_left,pos_right;
1440 vm_vec_scale_add(&pos_left, &obj->pos, &obj->orient.fvec, -obj->size);
1441 vm_vec_scale_add2(&pos_left, &obj->orient.rvec, -obj->size/4);
1442 vm_vec_scale_add(&pos_right, &pos_left, &obj->orient.rvec, obj->size/2);
1445 vm_vec_avg(&pos_left, &pos_left, &pos_right);
1447 segnum = find_point_seg(&pos_left, obj->segnum);
1449 object_create_explosion(segnum, &pos_left, size_scale, VCLIP_AFTERBURNER_BLOB );
1452 segnum = find_point_seg(&pos_right, obj->segnum);
1455 blob_obj = object_create_explosion(segnum, &pos_right, size_scale, VCLIP_AFTERBURNER_BLOB );
1457 blob_obj->lifeleft = lifetime;