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.
58 #define EXPLOSION_SCALE (F1_0*5/2) //explosion is the obj size times this
61 //--unused-- ubyte Frame_processed[MAX_OBJECTS];
65 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 )
70 objnum = obj_create( OBJ_FIREBALL,vclip_type,segnum,position,&vmd_identity_matrix,size,
71 CT_EXPLOSION,MT_NONE,RT_FIREBALL);
74 mprintf((1, "Can't create object in object_create_explosion_sub.\n"));
78 obj = &Objects[objnum];
80 //mprintf( 0, "Fireball created at %d, %d, %d\n", obj->pos.x, obj->pos.y, obj->pos.z );
82 //now set explosion-specific data
84 obj->lifeleft = Vclip[vclip_type ].play_time;
85 obj->ctype.expl_info.spawn_time = -1;
86 obj->ctype.expl_info.delete_objnum = -1;
87 obj->ctype.expl_info.delete_time = -1;
91 vms_vector pos_hit, vforce;
94 object * obj0p = &Objects[0];
96 // -- now legal for badass explosions on a wall. Assert(objp != NULL);
98 for (i=0; i<=Highest_object_index; i++ ) {
99 // Weapons used to be affected by badass explosions, but this introduces serious problems.
100 // When a smart bomb blows up, if one of its children goes right towards a nearby wall, it will
101 // blow up, blowing up all the children. So I remove it. MK, 09/11/94
102 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))))) {
103 dist = vm_vec_dist_quick( &obj0p->pos, &obj->pos );
104 // Make damage be from 'maxdamage' to 0.0, where 0.0 is 'maxdistance' away;
105 if ( dist < maxdistance ) {
106 if (object_to_object_visibility(obj, obj0p, FQ_TRANSWALL)) {
108 damage = maxdamage - fixmuldiv( dist, maxdamage, maxdistance );
109 force = maxforce - fixmuldiv( dist, maxforce, maxdistance );
111 // Find the force vector on the object
112 vm_vec_normalized_dir_quick( &vforce, &obj0p->pos, &obj->pos );
113 vm_vec_scale(&vforce, force );
115 // Find where the point of impact is... ( pos_hit )
116 vm_vec_scale(vm_vec_sub(&pos_hit, &obj->pos, &obj0p->pos), fixdiv(obj0p->size, obj0p->size + dist));
118 switch ( obj0p->type ) {
120 phys_apply_force(obj0p,&vforce);
122 if (obj0p->id == PROXIMITY_ID || obj0p->id == SUPERPROX_ID) { //prox bombs have chance of blowing up
123 if (fixmul(dist,force) > i2f(8000)) {
124 obj0p->flags |= OF_SHOULD_BE_DEAD;
125 explode_badass_weapon(obj0p,&obj0p->pos);
132 phys_apply_force(obj0p,&vforce);
134 // If not a boss, stun for 2 seconds at 32 force, 1 second at 16 force
135 if ((objp != NULL) && (!Robot_info[obj0p->id].boss_flag) && (Weapon_info[objp->id].flash)) {
136 ai_static *aip = &obj0p->ctype.ai_info;
137 int force_val = f2i(fixdiv(vm_vec_mag_quick(&vforce) * Weapon_info[objp->id].flash, FrameTime)/128) + 2;
139 if (obj->ctype.ai_info.SKIP_AI_COUNT * FrameTime < F1_0) {
140 aip->SKIP_AI_COUNT += force_val;
141 obj0p->mtype.phys_info.rotthrust.x = ((d_rand() - 16384) * force_val)/16;
142 obj0p->mtype.phys_info.rotthrust.y = ((d_rand() - 16384) * force_val)/16;
143 obj0p->mtype.phys_info.rotthrust.z = ((d_rand() - 16384) * force_val)/16;
144 obj0p->mtype.phys_info.flags |= PF_USES_THRUST;
146 //@@if (Robot_info[obj0p->id].companion)
147 //@@ buddy_message("Daisy, Daisy, Give me...");
149 aip->SKIP_AI_COUNT--;
153 // When a robot gets whacked by a badass force, he looks towards it because robots tend to get blasted from behind.
155 vms_vector neg_vforce;
156 neg_vforce.x = vforce.x * -2 * (7 - Difficulty_level)/8;
157 neg_vforce.y = vforce.y * -2 * (7 - Difficulty_level)/8;
158 neg_vforce.z = vforce.z * -2 * (7 - Difficulty_level)/8;
159 phys_apply_rot(obj0p,&neg_vforce);
161 if ( obj0p->shields >= 0 ) {
162 if (Robot_info[obj0p->id].boss_flag)
163 if (Boss_invulnerable_matter[Robot_info[obj0p->id].boss_flag-BOSS_D2])
166 if (apply_damage_to_robot(obj0p, damage, parent))
167 if ((objp != NULL) && (parent == Players[Player_num].objnum))
168 add_points_to_score(Robot_info[obj0p->id].score_value);
171 if ((objp != NULL) && (Robot_info[obj0p->id].companion) && (!Weapon_info[objp->id].flash)) {
173 char ouch_str[6*4 + 2];
175 count = f2i(damage/8);
181 for (i=0; i<count; i++)
182 strcat(ouch_str, "ouch! ");
184 buddy_message(ouch_str);
189 if ( obj0p->shields >= 0 ) {
190 apply_damage_to_controlcen(obj0p, damage, parent );
194 object * killer=NULL;
197 // Hack! Warning! Test code!
198 if ((objp != NULL) && Weapon_info[objp->id].flash && obj0p->id==Player_num) {
201 fe = min(F1_0*4, force*Weapon_info[objp->id].flash/32); // For four seconds or less
203 if (objp->ctype.laser_info.parent_signature == ConsoleObject->signature) {
209 PALETTE_FLASH_ADD(PK1 + f2i(PK2*force), PK1 + f2i(PK2*force), PK1 + f2i(PK2*force));
210 mprintf((0, "force = %7.3f, adding %i\n", f2fl(force), PK1 + f2i(PK2*force)));
214 if ((objp != NULL) && (Game_mode & GM_MULTI) && (objp->type == OBJ_PLAYER)) {
219 killer = &Objects[parent];
220 if (killer != ConsoleObject) // if someone else whacks you, cut force by 2x
221 vforce2.x /= 2; vforce2.y /= 2; vforce2.z /= 2;
223 vforce2.x /= 2; vforce2.y /= 2; vforce2.z /= 2;
225 phys_apply_force(obj0p,&vforce);
226 phys_apply_rot(obj0p,&vforce2);
227 if (Difficulty_level == 0)
229 if ( obj0p->shields >= 0 )
230 apply_damage_to_player(obj0p, killer, damage );
235 Int3(); // Illegal object type
238 ; // mprintf((0, "No badass: robot=%2i, dist=%7.3f, maxdistance=%7.3f .\n", i, f2fl(dist), f2fl(maxdistance)));
239 } // end if (object_to_object_visibility...
240 } // end if (dist < maxdistance)
244 } // end if (maxdamage...
253 object *object_create_muzzle_flash(short segnum, vms_vector * position, fix size, int vclip_type )
255 return object_create_explosion_sub(NULL, segnum, position, size, vclip_type, 0, 0, 0, -1 );
258 object *object_create_explosion(short segnum, vms_vector * position, fix size, int vclip_type )
260 return object_create_explosion_sub(NULL, segnum, position, size, vclip_type, 0, 0, 0, -1 );
263 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 )
267 rval = object_create_explosion_sub(objp, segnum, position, size, vclip_type, maxdamage, maxdistance, maxforce, parent );
269 if ((objp != NULL) && (objp->type == OBJ_WEAPON))
270 create_smart_children(objp, NUM_SMART_CHILDREN);
272 // -- if (objp->type == OBJ_ROBOT)
273 // -- if (Robot_info[objp->id].smart_blobs)
274 // -- create_smart_children(objp, Robot_info[objp->id].smart_blobs);
279 //blows up a badass weapon, creating the badass explosion
280 //return the explosion object
281 object *explode_badass_weapon(object *obj,vms_vector *pos)
283 weapon_info *wi = &Weapon_info[obj->id];
285 Assert(wi->damage_radius);
287 if ((obj->id == EARTHSHAKER_ID) || (obj->id == ROBOT_EARTHSHAKER_ID))
290 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, obj-Objects, 0, F1_0);
292 return object_create_badass_explosion( obj, obj->segnum, pos,
295 wi->strength[Difficulty_level],
296 wi->damage_radius,wi->strength[Difficulty_level],
297 obj->ctype.laser_info.parent_num );
301 object *explode_badass_object(object *objp, fix damage, fix distance, fix force)
306 rval = object_create_badass_explosion(objp, objp->segnum, &objp->pos, objp->size,
307 get_explosion_vclip(objp, 0),
308 damage, distance, force,
311 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, rval-Objects, 0, F1_0);
317 //blows up the player with a badass explosion
318 //return the explosion object
319 object *explode_badass_player(object *objp)
321 return explode_badass_object(objp, F1_0*50, F1_0*40, F1_0*150);
325 #define DEBRIS_LIFE (f1_0 * 2) //lifespan in seconds
327 object *object_create_debris(object *parent, int subobj_num)
333 Assert((parent->type == OBJ_ROBOT) || (parent->type == OBJ_PLAYER) );
335 objnum = obj_create(OBJ_DEBRIS,0,parent->segnum,&parent->pos,
336 &parent->orient,Polygon_models[parent->rtype.pobj_info.model_num].submodel_rads[subobj_num],
337 CT_DEBRIS,MT_PHYSICS,RT_POLYOBJ);
339 if ((objnum < 0 ) && (Highest_object_index >= MAX_OBJECTS-1)) {
340 mprintf((1, "Can't create object in object_create_debris.\n"));
345 return NULL; // Not enough debris slots!
346 obj = &Objects[objnum];
348 Assert(subobj_num < 32);
350 //Set polygon-object-specific data
352 obj->rtype.pobj_info.model_num = parent->rtype.pobj_info.model_num;
353 obj->rtype.pobj_info.subobj_flags = 1<<subobj_num;
354 obj->rtype.pobj_info.tmap_override = parent->rtype.pobj_info.tmap_override;
356 //Set physics data for this object
358 po = &Polygon_models[obj->rtype.pobj_info.model_num];
360 obj->mtype.phys_info.velocity.x = RAND_MAX/2 - d_rand();
361 obj->mtype.phys_info.velocity.y = RAND_MAX/2 - d_rand();
362 obj->mtype.phys_info.velocity.z = RAND_MAX/2 - d_rand();
363 vm_vec_normalize_quick(&obj->mtype.phys_info.velocity);
364 vm_vec_scale(&obj->mtype.phys_info.velocity,i2f(10 + (30 * d_rand() / RAND_MAX)));
366 vm_vec_add2(&obj->mtype.phys_info.velocity,&parent->mtype.phys_info.velocity);
368 // -- used to be: Notice, not random! vm_vec_make(&obj->mtype.phys_info.rotvel,10*0x2000/3,10*0x4000/3,10*0x7000/3);
369 vm_vec_make(&obj->mtype.phys_info.rotvel, d_rand() + 0x1000, d_rand()*2 + 0x4000, d_rand()*3 + 0x2000);
370 vm_vec_zero(&obj->mtype.phys_info.rotthrust);
372 obj->lifeleft = 3*DEBRIS_LIFE/4 + fixmul(d_rand(), DEBRIS_LIFE); // Some randomness, so they don't all go away at the same time.
374 obj->mtype.phys_info.mass = fixmuldiv(parent->mtype.phys_info.mass,obj->size,parent->size);
375 obj->mtype.phys_info.drag = 0; //fl2f(0.2); //parent->mtype.phys_info.drag;
381 void draw_fireball(object *obj)
383 //mprintf( 0, "[Drawing obj %d type %d fireball size %x]\n", obj-Objects, obj->id, obj->size );
385 if ( obj->lifeleft > 0 )
386 draw_vclip_object(obj,obj->lifeleft,0, obj->id);
390 // --------------------------------------------------------------------------------------------------------------------
391 // Return true if there is a door here and it is openable
392 // It is assumed that the player has all keys.
393 int door_is_openable_by_player(segment *segp, int sidenum)
395 int wall_num, wall_type;
397 wall_num = segp->sides[sidenum].wall_num;
398 wall_type = Walls[wall_num].type;
401 return 0; // no wall here.
403 // Can't open locked doors.
404 if (((wall_type == WALL_DOOR) && (Walls[wall_num].flags & WALL_DOOR_LOCKED)) || (wall_type == WALL_CLOSED))
411 #define QUEUE_SIZE 64
413 // --------------------------------------------------------------------------------------------------------------------
414 // Return a segment %i segments away from initial segment.
415 // Returns -1 if can't find a segment that distance away.
416 int pick_connected_segment(object *objp, int max_depth)
422 int seg_queue[QUEUE_SIZE*2];
423 byte visited[MAX_SEGMENTS];
424 byte depth[MAX_SEGMENTS];
425 byte side_rand[MAX_SIDES_PER_SEGMENT];
427 // mprintf((0, "Finding a segment %i segments away from segment %i: ", max_depth, objp->segnum));
429 start_seg = objp->segnum;
432 seg_queue[head++] = start_seg;
434 memset(visited, 0, Highest_segment_index+1);
435 memset(depth, 0, Highest_segment_index+1);
438 for (i=0; i<MAX_SIDES_PER_SEGMENT; i++)
441 // Now, randomize a bit to start, so we don't always get started in the same direction.
442 for (i=0; i<4; i++) {
445 ind1 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
446 temp = side_rand[ind1];
447 side_rand[ind1] = side_rand[i];
452 while (tail != head) {
455 int ind1, ind2, temp;
457 if (cur_depth >= max_depth) {
458 // mprintf((0, "selected segment %i\n", seg_queue[tail]));
459 return seg_queue[tail];
462 segp = &Segments[seg_queue[tail++]];
463 tail &= QUEUE_SIZE-1;
465 // to make random, switch a pair of entries in side_rand.
466 ind1 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
467 ind2 = (d_rand() * MAX_SIDES_PER_SEGMENT) >> 15;
468 temp = side_rand[ind1];
469 side_rand[ind1] = side_rand[ind2];
470 side_rand[ind2] = temp;
473 for (sidenum=ind1; count<MAX_SIDES_PER_SEGMENT; count++) {
474 int snrand, wall_num;
476 if (sidenum == MAX_SIDES_PER_SEGMENT)
479 snrand = side_rand[sidenum];
480 wall_num = segp->sides[snrand].wall_num;
483 if (((wall_num == -1) && (segp->children[snrand] > -1)) || door_is_openable_by_player(segp, snrand)) {
484 if (visited[segp->children[snrand]] == 0) {
485 seg_queue[head++] = segp->children[snrand];
486 visited[segp->children[snrand]] = 1;
487 depth[segp->children[snrand]] = cur_depth+1;
488 head &= QUEUE_SIZE-1;
490 if (head == tail + QUEUE_SIZE-1)
491 Int3(); // queue overflow. Make it bigger!
493 if (head+QUEUE_SIZE == tail + QUEUE_SIZE-1)
494 Int3(); // queue overflow. Make it bigger!
498 if ((seg_queue[tail] < 0) || (seg_queue[tail] > Highest_segment_index)) {
499 // -- Int3(); // Something bad has happened. Queue is trashed. --MK, 12/13/94
502 cur_depth = depth[seg_queue[tail]];
505 mprintf((0, "...failed at depth %i, returning -1\n", cur_depth));
510 #define BASE_NET_DROP_DEPTH 8
512 // ------------------------------------------------------------------------------------------------------
513 // Choose segment to drop a powerup in.
514 // For all active net players, try to create a N segment path from the player. If possible, return that
515 // segment. If not possible, try another player. After a few tries, use a random segment.
516 // Don't drop if control center in segment.
517 int choose_drop_segment()
524 vms_vector tempv,*player_pos;
526 mprintf((0,"choose_drop_segment:"));
528 d_srand(timer_get_fixed_seconds());
530 cur_drop_depth = BASE_NET_DROP_DEPTH + ((d_rand() * BASE_NET_DROP_DEPTH*2) >> 15);
532 player_pos = &Objects[Players[Player_num].objnum].pos;
533 player_seg = Objects[Players[Player_num].objnum].segnum;
535 while ((segnum == -1) && (cur_drop_depth > BASE_NET_DROP_DEPTH/2)) {
536 pnum = (d_rand() * N_players) >> 15;
538 while ((count < N_players) && ((Players[pnum].connected == 0) || (pnum==Player_num) || ((Game_mode & (GM_TEAM|GM_CAPTURE)) && (get_team(pnum)==get_team(Player_num))))) {
539 pnum = (pnum+1)%N_players;
543 if (count == N_players) {
544 //if can't valid non-player person, use the player
547 //mprintf((1, "Warning: choose_drop_segment: Couldn't find legal drop segment because no connected players.\n"));
548 //return (d_rand() * Highest_segment_index) >> 15;
551 segnum = pick_connected_segment(&Objects[Players[pnum].objnum], cur_drop_depth);
552 mprintf((0," %d",segnum));
558 if (Segment2s[segnum].special == SEGMENT_IS_CONTROLCEN)
559 {segnum = -1; mprintf((0,"C")); }
560 else { //don't drop in any children of control centers
563 int ch = Segments[segnum].children[i];
564 if (IS_CHILD(ch) && Segment2s[ch].special == SEGMENT_IS_CONTROLCEN) {
572 //bail if not far enough from original position
574 compute_segment_center(&tempv, &Segments[segnum]);
575 if (find_connected_distance(player_pos,player_seg,&tempv,segnum,-1,WID_FLY_FLAG) < i2f(20)*cur_drop_depth) {
585 mprintf((0," dist=%x\n",find_connected_distance(player_pos,player_seg,&tempv,segnum,-1,WID_FLY_FLAG)));
588 mprintf((1, "Warning: Unable to find a connected segment. Picking a random one.\n"));
589 return (d_rand() * Highest_segment_index) >> 15;
597 // ------------------------------------------------------------------------------------------------------
598 // Drop cloak powerup if in a network game.
600 extern char PowerupsInMine[],MaxPowerupsAllowed[];
602 void maybe_drop_net_powerup(int powerup_type)
604 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) {
608 if (Game_mode & GM_NETWORK)
610 if (PowerupsInMine[powerup_type]>=MaxPowerupsAllowed[powerup_type])
615 if (Control_center_destroyed || Endlevel_sequence)
618 segnum = choose_drop_segment();
619 //--old-- segnum = (d_rand() * Highest_segment_index) >> 15;
620 //--old-- Assert((segnum >= 0) && (segnum <= Highest_segment_index));
621 //--old-- if (segnum < 0)
622 //--old-- segnum = -segnum;
623 //--old-- while (segnum > Highest_segment_index)
624 //--old-- segnum /= 2;
627 objnum = call_object_create_egg(&Objects[Players[Player_num].objnum], 1, OBJ_POWERUP, powerup_type);
632 pick_random_point_in_seg(&new_pos, segnum);
634 multi_send_create_powerup(powerup_type, segnum, objnum, &new_pos);
636 Objects[objnum].pos = new_pos;
637 vm_vec_zero(&Objects[objnum].mtype.phys_info.velocity);
638 obj_relink(objnum, segnum);
640 object_create_explosion(segnum, &new_pos, i2f(5), VCLIP_POWERUP_DISAPPEARANCE );
641 // 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));
646 // ------------------------------------------------------------------------------------------------------
647 // Return true if current segment contains some object.
648 int segment_contains_object(int obj_type, int obj_id, int segnum)
655 objnum = Segments[segnum].objects;
658 if ((Objects[objnum].type == obj_type) && (Objects[objnum].id == obj_id))
661 objnum = Objects[objnum].next;
666 // ------------------------------------------------------------------------------------------------------
667 int object_nearby_aux(int segnum, int object_type, int object_id, int depth)
674 if (segment_contains_object(object_type, object_id, segnum))
677 for (i=0; i<MAX_SIDES_PER_SEGMENT; i++) {
678 int seg2 = Segments[segnum].children[i];
681 if (object_nearby_aux(seg2, object_type, object_id, depth-1))
689 // ------------------------------------------------------------------------------------------------------
690 // Return true if some powerup is nearby (within 3 segments).
691 int weapon_nearby(object *objp, int weapon_id)
693 return object_nearby_aux(objp->segnum, OBJ_POWERUP, weapon_id, 3);
696 // ------------------------------------------------------------------------------------------------------
697 void maybe_replace_powerup_with_energy(object *del_obj)
701 if (del_obj->contains_type != OBJ_POWERUP)
704 if (del_obj->contains_id == POW_CLOAK) {
705 if (weapon_nearby(del_obj, del_obj->contains_id)) {
706 mprintf((0, "Bashing cloak into nothing because there's one nearby.\n"));
707 del_obj->contains_count = 0;
711 switch (del_obj->contains_id) {
712 case POW_VULCAN_WEAPON: weapon_index = VULCAN_INDEX; break;
713 case POW_GAUSS_WEAPON: weapon_index = GAUSS_INDEX; break;
714 case POW_SPREADFIRE_WEAPON: weapon_index = SPREADFIRE_INDEX; break;
715 case POW_PLASMA_WEAPON: weapon_index = PLASMA_INDEX; break;
716 case POW_FUSION_WEAPON: weapon_index = FUSION_INDEX; break;
718 case POW_HELIX_WEAPON: weapon_index = HELIX_INDEX; break;
719 case POW_PHOENIX_WEAPON: weapon_index = PHOENIX_INDEX; break;
720 case POW_OMEGA_WEAPON: weapon_index = OMEGA_INDEX; break;
724 // Don't drop vulcan ammo if player maxed out.
725 if (((weapon_index == VULCAN_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 == GAUSS_INDEX) || (del_obj->contains_id == POW_VULCAN_AMMO)) && (Players[Player_num].primary_ammo[VULCAN_INDEX] >= VULCAN_AMMO_MAX))
728 del_obj->contains_count = 0;
729 else if (weapon_index != -1) {
730 if ((player_has_weapon(weapon_index, 0) & HAS_WEAPON_FLAG) || weapon_nearby(del_obj, del_obj->contains_id)) {
731 if (d_rand() > 16384) {
732 del_obj->contains_type = OBJ_POWERUP;
733 if (weapon_index == VULCAN_INDEX) {
734 del_obj->contains_id = POW_VULCAN_AMMO;
735 } else if (weapon_index == GAUSS_INDEX) {
736 del_obj->contains_id = POW_VULCAN_AMMO;
738 del_obj->contains_id = POW_ENERGY;
741 del_obj->contains_type = OBJ_POWERUP;
742 del_obj->contains_id = POW_SHIELD_BOOST;
745 } else if (del_obj->contains_id == POW_QUAD_FIRE)
746 if ((Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS) || weapon_nearby(del_obj, del_obj->contains_id)) {
747 if (d_rand() > 16384) {
748 del_obj->contains_type = OBJ_POWERUP;
749 del_obj->contains_id = POW_ENERGY;
751 del_obj->contains_type = OBJ_POWERUP;
752 del_obj->contains_id = POW_SHIELD_BOOST;
756 // If this robot was gated in by the boss and it now contains energy, make it contain nothing,
757 // else the room gets full of energy.
758 if ( (del_obj->matcen_creator == BOSS_GATE_MATCEN_NUM) && (del_obj->contains_id == POW_ENERGY) && (del_obj->contains_type == OBJ_POWERUP) ) {
759 mprintf((0, "Converting energy powerup to nothing because robot %i gated in by boss.\n", del_obj-Objects));
760 del_obj->contains_count = 0;
763 // Change multiplayer extra-lives into invulnerability
764 if ((Game_mode & GM_MULTI) && (del_obj->contains_id == POW_EXTRA_LIFE))
766 del_obj->contains_id = POW_INVULNERABILITY;
770 int drop_powerup(int type, int id, int num, vms_vector *init_vel, vms_vector *pos, int segnum)
774 vms_vector new_velocity, new_pos;
780 for (count=0; count<num; count++) {
782 new_velocity = *init_vel;
783 old_mag = vm_vec_mag_quick(init_vel);
785 // We want powerups to move more in network mode.
786 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_ROBOTS)) {
788 // extra life powerups are converted to invulnerability in multiplayer, for what is an extra life, anyway?
789 if (id == POW_EXTRA_LIFE)
790 id = POW_INVULNERABILITY;
794 new_velocity.x += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
795 new_velocity.y += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
796 new_velocity.z += fixmul(old_mag+F1_0*32, d_rand()*rand_scale - 16384*rand_scale);
798 // Give keys zero velocity so they can be tracked better in multi
800 if ((Game_mode & GM_MULTI) && (id >= POW_KEY_BLUE) && (id <= POW_KEY_GOLD))
801 vm_vec_zero(&new_velocity);
804 // new_pos.x += (d_rand()-16384)*8;
805 // new_pos.y += (d_rand()-16384)*8;
806 // new_pos.z += (d_rand()-16384)*8;
809 if (Game_mode & GM_MULTI)
811 if (Net_create_loc >= MAX_NET_CREATE_OBJECTS)
813 mprintf( (1, "Not enough slots to drop all powerups!\n" ));
816 if ((Game_mode & GM_NETWORK) && Network_status == NETSTAT_ENDLEVEL)
820 objnum = obj_create( type, id, segnum, &new_pos, &vmd_identity_matrix, Powerup_info[id].size, CT_POWERUP, MT_PHYSICS, RT_POWERUP);
823 mprintf((1, "Can't create object in object_create_egg. Aborting.\n"));
829 if (Game_mode & GM_MULTI)
831 Net_create_objnums[Net_create_loc++] = objnum;
835 obj = &Objects[objnum];
837 obj->mtype.phys_info.velocity = new_velocity;
839 // 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));
840 // mprintf(0, " pos = x=%d y=%d z=%d\n", obj->pos.x, obj->pos.y, obj->pos.z);
842 obj->mtype.phys_info.drag = 512; //1024;
843 obj->mtype.phys_info.mass = F1_0;
845 obj->mtype.phys_info.flags = PF_BOUNCE;
847 obj->rtype.vclip_info.vclip_num = Powerup_info[obj->id].vclip_num;
848 obj->rtype.vclip_info.frametime = Vclip[obj->rtype.vclip_info.vclip_num].frame_time;
849 obj->rtype.vclip_info.framenum = 0;
854 case POW_SHIELD_BOOST:
856 obj->lifeleft = (d_rand() + F1_0*3) * 64; // Lives for 3 to 3.5 binary minutes (a binary minute is 64 seconds)
857 if (Game_mode & GM_MULTI)
861 // if (Game_mode & GM_MULTI)
862 // obj->lifeleft = (d_rand() + F1_0*3) * 64; // Lives for 5 to 5.5 binary minutes (a binary minute is 64 seconds)
869 for (count=0; count<num; count++) {
871 new_velocity = *init_vel;
872 old_mag = vm_vec_mag_quick(init_vel);
874 vm_vec_normalize_quick(&new_velocity);
876 // We want powerups to move more in network mode.
877 // if (Game_mode & GM_MULTI)
882 new_velocity.x += (d_rand()-16384)*2;
883 new_velocity.y += (d_rand()-16384)*2;
884 new_velocity.z += (d_rand()-16384)*2;
886 vm_vec_normalize_quick(&new_velocity);
887 vm_vec_scale(&new_velocity, (F1_0*32 + old_mag) * rand_scale);
889 // This is dangerous, could be outside mine.
890 // new_pos.x += (d_rand()-16384)*8;
891 // new_pos.y += (d_rand()-16384)*7;
892 // new_pos.z += (d_rand()-16384)*6;
894 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);
897 mprintf((1, "Can't create object in object_create_egg, robots. Aborting.\n"));
903 if (Game_mode & GM_MULTI)
905 Net_create_objnums[Net_create_loc++] = objnum;
909 obj = &Objects[objnum];
911 //@@Took out this ugly hack 1/12/96, because Mike has added code
912 //@@that should fix it in a better way.
913 //@@//this is a super-ugly hack. Since the baby stripe robots have
914 //@@//their firing point on their bounding sphere, the firing points
915 //@@//can poke through a wall if the robots are very close to it. So
916 //@@//we make their radii bigger so the guns can't get too close to
918 //@@if (Robot_info[obj->id].flags & RIF_BIG_RADIUS)
919 //@@ obj->size = (obj->size*3)/2;
921 //Set polygon-object-specific data
923 obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
924 obj->rtype.pobj_info.subobj_flags = 0;
928 obj->mtype.phys_info.velocity = new_velocity;
930 obj->mtype.phys_info.mass = Robot_info[obj->id].mass;
931 obj->mtype.phys_info.drag = Robot_info[obj->id].drag;
933 obj->mtype.phys_info.flags |= (PF_LEVELLING);
935 obj->shields = Robot_info[obj->id].strength;
937 obj->ctype.ai_info.behavior = AIB_NORMAL;
938 Ai_local_info[obj-Objects].player_awareness_type = PA_WEAPON_ROBOT_COLLISION;
939 Ai_local_info[obj-Objects].player_awareness_time = F1_0*3;
940 obj->ctype.ai_info.CURRENT_STATE = AIS_LOCK;
941 obj->ctype.ai_info.GOAL_STATE = AIS_LOCK;
942 obj->ctype.ai_info.REMOTE_OWNER = -1;
945 // At JasenW's request, robots which contain robots sometimes drop shields.
946 if (d_rand() > 16384)
947 drop_powerup(OBJ_POWERUP, POW_SHIELD_BOOST, 1, init_vel, pos, segnum);
952 Error("Error: Illegal type (%i) in object spawning.\n", type);
958 // ------------------------------------------------------------------------------------------------------
959 // Returns created object number.
960 // If object dropped by player, set flag.
961 int object_create_egg(object *objp)
965 if (!(Game_mode & GM_MULTI) & (objp->type != OBJ_PLAYER))
967 if (objp->contains_type == OBJ_POWERUP)
969 if (objp->contains_id == POW_SHIELD_BOOST) {
970 if (Players[Player_num].shields >= i2f(100)) {
971 if (d_rand() > 16384) {
972 mprintf((0, "Not dropping shield!\n"));
975 } else if (Players[Player_num].shields >= i2f(150)) {
976 if (d_rand() > 8192) {
977 mprintf((0, "Not dropping shield!\n"));
981 } else if (objp->contains_id == POW_ENERGY) {
982 if (Players[Player_num].energy >= i2f(100)) {
983 if (d_rand() > 16384) {
984 mprintf((0, "Not dropping energy!\n"));
987 } else if (Players[Player_num].energy >= i2f(150)) {
988 if (d_rand() > 8192) {
989 mprintf((0, "Not dropping energy!\n"));
997 rval = drop_powerup(objp->contains_type, objp->contains_id, objp->contains_count, &objp->mtype.phys_info.velocity, &objp->pos, objp->segnum);
1001 if ((objp->type == OBJ_PLAYER) && (objp->id == Player_num))
1002 Objects[rval].flags |= OF_PLAYER_DROPPED;
1004 if (objp->type == OBJ_ROBOT && objp->contains_type==OBJ_POWERUP)
1006 if (objp->contains_id==POW_VULCAN_WEAPON || objp->contains_id==POW_GAUSS_WEAPON)
1007 Objects[rval].ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT;
1008 else if (objp->contains_id==POW_OMEGA_WEAPON)
1009 Objects[rval].ctype.powerup_info.count = MAX_OMEGA_CHARGE;
1016 // -- extern int Items_destroyed;
1018 // -------------------------------------------------------------------------------------------------------
1019 // Put count objects of type type (eg, powerup), id = id (eg, energy) into *objp, then drop them! Yippee!
1020 // Returns created object number.
1021 int call_object_create_egg(object *objp, int count, int type, int id)
1023 // -- if (!(Game_mode & GM_MULTI) && (objp == ConsoleObject))
1024 // -- if (d_rand() < 32767/6) {
1025 // -- Items_destroyed++;
1030 objp->contains_count = count;
1031 objp->contains_type = type;
1032 objp->contains_id = id;
1033 return object_create_egg(objp);
1039 //what vclip does this explode with?
1040 int get_explosion_vclip(object *obj,int stage)
1042 if (obj->type==OBJ_ROBOT) {
1044 if (stage==0 && Robot_info[obj->id].exp1_vclip_num>-1)
1045 return Robot_info[obj->id].exp1_vclip_num;
1046 else if (stage==1 && Robot_info[obj->id].exp2_vclip_num>-1)
1047 return Robot_info[obj->id].exp2_vclip_num;
1050 else if (obj->type==OBJ_PLAYER && Player_ship->expl_vclip_num>-1)
1051 return Player_ship->expl_vclip_num;
1053 return VCLIP_SMALL_EXPLOSION; //default
1056 //blow up a polygon model
1057 void explode_model(object *obj)
1059 Assert(obj->render_type == RT_POLYOBJ);
1061 if (Dying_modelnums[obj->rtype.pobj_info.model_num] != -1)
1062 obj->rtype.pobj_info.model_num = Dying_modelnums[obj->rtype.pobj_info.model_num];
1064 if (Polygon_models[obj->rtype.pobj_info.model_num].n_models > 1) {
1067 for (i=1;i<Polygon_models[obj->rtype.pobj_info.model_num].n_models;i++)
1068 if (!(obj->type == OBJ_ROBOT && obj->id == 44 && i == 5)) //energy sucker energy part
1069 object_create_debris(obj,i);
1071 //make parent object only draw center part
1072 obj->rtype.pobj_info.subobj_flags=1;
1076 //if the object has a destroyed model, switch to it. Otherwise, delete it.
1077 void maybe_delete_object(object *del_obj)
1079 if (Dead_modelnums[del_obj->rtype.pobj_info.model_num] != -1) {
1080 del_obj->rtype.pobj_info.model_num = Dead_modelnums[del_obj->rtype.pobj_info.model_num];
1081 del_obj->flags |= OF_DESTROYED;
1083 else { //normal, multi-stage explosion
1084 if (del_obj->type == OBJ_PLAYER)
1085 del_obj->render_type = RT_NONE;
1087 del_obj->flags |= OF_SHOULD_BE_DEAD;
1091 // -------------------------------------------------------------------------------------------------------
1092 //blow up an object. Takes the object to destroy, and the point of impact
1093 void explode_object(object *hitobj,fix delay_time)
1095 if (hitobj->flags & OF_EXPLODING) return;
1097 if (delay_time) { //wait a little while before creating explosion
1101 //create a placeholder object to do the delay, with id==-1
1103 objnum = obj_create( OBJ_FIREBALL,-1,hitobj->segnum,&hitobj->pos,&vmd_identity_matrix,0,
1104 CT_EXPLOSION,MT_NONE,RT_NONE);
1107 maybe_delete_object(hitobj); //no explosion, die instantly
1108 mprintf((1,"Couldn't start explosion, deleting object now\n"));
1113 obj = &Objects[objnum];
1115 //now set explosion-specific data
1117 obj->lifeleft = delay_time;
1118 obj->ctype.expl_info.delete_objnum = hitobj-Objects;
1120 if (obj->ctype.expl_info.delete_objnum < 0)
1123 obj->ctype.expl_info.delete_time = -1;
1124 obj->ctype.expl_info.spawn_time = 0;
1131 vclip_num = get_explosion_vclip(hitobj,0);
1133 expl_obj = object_create_explosion(hitobj->segnum, &hitobj->pos, fixmul(hitobj->size,EXPLOSION_SCALE), vclip_num );
1136 maybe_delete_object(hitobj); //no explosion, die instantly
1137 mprintf((0,"Couldn't start explosion, deleting object now\n"));
1141 //don't make debris explosions have physics, because they often
1142 //happen when the debris has hit the wall, so the fireball is trying
1143 //to move into the wall, which shows off FVI problems.
1144 if (hitobj->type!=OBJ_DEBRIS && hitobj->movement_type==MT_PHYSICS) {
1145 expl_obj->movement_type = MT_PHYSICS;
1146 expl_obj->mtype.phys_info = hitobj->mtype.phys_info;
1149 if (hitobj->render_type==RT_POLYOBJ && hitobj->type!=OBJ_DEBRIS)
1150 explode_model(hitobj);
1152 maybe_delete_object(hitobj);
1155 hitobj->flags |= OF_EXPLODING; //say that this is blowing up
1156 hitobj->control_type = CT_NONE; //become inert while exploding
1161 //do whatever needs to be done for this piece of debris for this frame
1162 void do_debris_frame(object *obj)
1164 Assert(obj->control_type == CT_DEBRIS);
1166 if (obj->lifeleft < 0)
1167 explode_object(obj,0);
1171 extern void drop_stolen_items(object *objp);
1173 //do whatever needs to be done for this explosion for this frame
1174 void do_explosion_sequence(object *obj)
1176 Assert(obj->control_type == CT_EXPLOSION);
1178 //mprintf( 0, "Object %d life left is %d\n", obj-Objects, obj->lifeleft );
1180 //See if we should die of old age
1181 if (obj->lifeleft <= 0 ) { // We died of old age
1182 obj->flags |= OF_SHOULD_BE_DEAD;
1186 //See if we should create a secondary explosion
1187 if (obj->lifeleft <= obj->ctype.expl_info.spawn_time) {
1188 object *expl_obj,*del_obj;
1190 vms_vector *spawn_pos;
1192 if ((obj->ctype.expl_info.delete_objnum < 0) || (obj->ctype.expl_info.delete_objnum > Highest_object_index)) {
1193 mprintf((0, "Illegal value for delete_objnum in fireball.c\n"));
1194 Int3(); // get Rob, please... thanks
1198 del_obj = &Objects[obj->ctype.expl_info.delete_objnum];
1200 spawn_pos = &del_obj->pos;
1202 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))) {
1203 Int3(); //pretty bad
1207 vclip_num = get_explosion_vclip(del_obj,1);
1209 if (del_obj->type == OBJ_ROBOT && Robot_info[del_obj->id].badass)
1210 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 );
1212 expl_obj = object_create_explosion( del_obj->segnum, spawn_pos, fixmul(del_obj->size, EXPLOSION_SCALE), vclip_num );
1214 if ((del_obj->contains_count > 0) && !(Game_mode & GM_MULTI)) { // Multiplayer handled outside of this code!!
1215 // If dropping a weapon that the player has, drop energy instead, unless it's vulcan, in which case drop vulcan ammo.
1216 if (del_obj->contains_type == OBJ_POWERUP)
1217 maybe_replace_powerup_with_energy(del_obj);
1218 object_create_egg(del_obj);
1219 } else if ((del_obj->type == OBJ_ROBOT) && !(Game_mode & GM_MULTI)) { // Multiplayer handled outside this code!!
1220 robot_info *robptr = &Robot_info[del_obj->id];
1221 if (robptr->contains_count) {
1222 if (((d_rand() * 16) >> 15) < robptr->contains_prob) {
1223 del_obj->contains_count = ((d_rand() * robptr->contains_count) >> 15) + 1;
1224 del_obj->contains_type = robptr->contains_type;
1225 del_obj->contains_id = robptr->contains_id;
1226 maybe_replace_powerup_with_energy(del_obj);
1227 object_create_egg(del_obj);
1232 drop_stolen_items(del_obj);
1234 if (robptr->companion) {
1235 DropBuddyMarker(del_obj);
1239 if ( Robot_info[del_obj->id].exp2_sound_num > -1 )
1240 digi_link_sound_to_pos( Robot_info[del_obj->id].exp2_sound_num, del_obj->segnum, 0, spawn_pos, 0, F1_0 );
1241 //PLAY_SOUND_3D( Robot_info[del_obj->id].exp2_sound_num, spawn_pos, del_obj->segnum );
1243 // mprintf( 0, "Spawned an explosion of type %d\n", Robot_info[del_obj->id].exp2_vclip_num );
1245 //mprintf( 0, "Object %d spawned.\n", obj-Objects );
1246 //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z );
1247 //mprintf( 0, "Explosion at %d,%d,%d\n", obj->pos.x, obj->pos.y, obj->pos.z );
1248 //mprintf( 0, "Spawned exp at %d,%d,%d\n", expl_obj->pos.x, expl_obj->pos.y, expl_obj->pos.z );
1250 obj->ctype.expl_info.spawn_time = -1;
1253 if (del_obj->render_type==RT_POLYOBJ)
1254 explode_model(del_obj); //explode a polygon model
1256 //set some parm in explosion
1259 if (del_obj->movement_type == MT_PHYSICS) {
1260 expl_obj->movement_type = MT_PHYSICS;
1261 expl_obj->mtype.phys_info = del_obj->mtype.phys_info;
1264 expl_obj->ctype.expl_info.delete_time = expl_obj->lifeleft/2;
1265 expl_obj->ctype.expl_info.delete_objnum = del_obj-Objects;
1267 if (obj->ctype.expl_info.delete_objnum < 0)
1273 maybe_delete_object(del_obj);
1274 mprintf((0,"Couldn't create secondary explosion, deleting object now\n"));
1279 //See if we should delete an object
1280 if (obj->lifeleft <= obj->ctype.expl_info.delete_time) {
1281 object *del_obj = &Objects[obj->ctype.expl_info.delete_objnum];
1283 obj->ctype.expl_info.delete_time = -1;
1285 maybe_delete_object(del_obj);
1289 #define EXPL_WALL_TIME (f1_0)
1290 #define EXPL_WALL_TOTAL_FIREBALLS 32
1291 #define EXPL_WALL_FIREBALL_SIZE (0x48000*6/10) //smallest size
1293 expl_wall expl_wall_list[MAX_EXPLODING_WALLS];
1295 void init_exploding_walls()
1299 for (i=0;i<MAX_EXPLODING_WALLS;i++)
1300 expl_wall_list[i].segnum = -1;
1303 //explode the given wall
1304 void explode_wall(int segnum,int sidenum)
1311 for (i=0;i<MAX_EXPLODING_WALLS && expl_wall_list[i].segnum != -1;i++);
1313 if (i==MAX_EXPLODING_WALLS) { //didn't find slot.
1314 mprintf((0,"Couldn't find free slot for exploding wall!\n"));
1319 expl_wall_list[i].segnum = segnum;
1320 expl_wall_list[i].sidenum = sidenum;
1321 expl_wall_list[i].time = 0;
1323 //play one long sound for whole door wall explosion
1324 compute_center_point_on_side(&pos,&Segments[segnum],sidenum);
1325 digi_link_sound_to_pos( SOUND_EXPLODING_WALL,segnum, sidenum, &pos, 0, F1_0 );
1329 //handle walls for this frame
1330 //note: this wall code assumes the wall is not triangulated
1331 void do_exploding_wall_frame()
1335 for (i=0;i<MAX_EXPLODING_WALLS;i++) {
1336 int segnum = expl_wall_list[i].segnum;
1339 int sidenum = expl_wall_list[i].sidenum;
1340 fix oldfrac,newfrac;
1341 int old_count,new_count,e; //n,
1343 oldfrac = fixdiv(expl_wall_list[i].time,EXPL_WALL_TIME);
1345 expl_wall_list[i].time += FrameTime;
1346 if (expl_wall_list[i].time > EXPL_WALL_TIME)
1347 expl_wall_list[i].time = EXPL_WALL_TIME;
1349 if (expl_wall_list[i].time>(EXPL_WALL_TIME*3)/4) {
1350 segment *seg,*csegp;
1353 seg = &Segments[segnum];
1355 a = Walls[seg->sides[sidenum].wall_num].clip_num;
1356 n = WallAnims[a].num_frames;
1358 csegp = &Segments[seg->children[sidenum]];
1359 cside = find_connect_side(seg, csegp);
1361 wall_set_tmap_num(seg,sidenum,csegp,cside,a,n-1);
1363 Walls[seg->sides[sidenum].wall_num].flags |= WALL_BLASTED;
1364 Walls[csegp->sides[cside].wall_num].flags |= WALL_BLASTED;
1368 newfrac = fixdiv(expl_wall_list[i].time,EXPL_WALL_TIME);
1370 old_count = f2i(EXPL_WALL_TOTAL_FIREBALLS * fixmul(oldfrac,oldfrac));
1371 new_count = f2i(EXPL_WALL_TOTAL_FIREBALLS * fixmul(newfrac,newfrac));
1373 //n = new_count - old_count;
1375 // mprintf(0,"Creating %d new explosions\n",new_count-old_count);
1377 //now create all the next explosions
1379 for (e=old_count;e<new_count;e++) {
1380 short vertnum_list[4];
1381 vms_vector *v0,*v1,*v2;
1382 vms_vector vv0,vv1,pos;
1385 //calc expl position
1387 get_side_verts(vertnum_list,segnum,sidenum);
1389 v0 = &Vertices[vertnum_list[0]];
1390 v1 = &Vertices[vertnum_list[1]];
1391 v2 = &Vertices[vertnum_list[2]];
1393 vm_vec_sub(&vv0,v0,v1);
1394 vm_vec_sub(&vv1,v2,v1);
1396 vm_vec_scale_add(&pos,v1,&vv0,d_rand()*2);
1397 vm_vec_scale_add2(&pos,&vv1,d_rand()*2);
1399 size = EXPL_WALL_FIREBALL_SIZE + (2*EXPL_WALL_FIREBALL_SIZE * e / EXPL_WALL_TOTAL_FIREBALLS);
1401 //fireballs start away from door, with subsequent ones getting closer
1405 get_side_normal(&Segments[segnum], sidenum, 0, &_vn );
1406 vm_vec_scale_add2(&pos,&_vn,size*(EXPL_WALL_TOTAL_FIREBALLS-e)/EXPL_WALL_TOTAL_FIREBALLS);
1409 vm_vec_scale_add2(&pos,&Segments[segnum].sides[sidenum].normals[0],size*(EXPL_WALL_TOTAL_FIREBALLS-e)/EXPL_WALL_TOTAL_FIREBALLS);
1412 if (e & 3) //3 of 4 are normal
1413 object_create_explosion(expl_wall_list[i].segnum,&pos,size,VCLIP_SMALL_EXPLOSION);
1415 object_create_badass_explosion( NULL, expl_wall_list[i].segnum, &pos,
1417 VCLIP_SMALL_EXPLOSION,
1418 i2f(4), // damage strength
1419 i2f(20), // damage radius
1420 i2f(50), // damage force
1427 if (expl_wall_list[i].time >= EXPL_WALL_TIME)
1428 expl_wall_list[i].segnum = -1; //flag this slot as free
1436 //creates afterburner blobs behind the specified object
1437 void drop_afterburner_blobs(object *obj, int count, fix size_scale, fix lifetime)
1439 vms_vector pos_left,pos_right;
1442 vm_vec_scale_add(&pos_left, &obj->pos, &obj->orient.fvec, -obj->size);
1443 vm_vec_scale_add2(&pos_left, &obj->orient.rvec, -obj->size/4);
1444 vm_vec_scale_add(&pos_right, &pos_left, &obj->orient.rvec, obj->size/2);
1447 vm_vec_avg(&pos_left, &pos_left, &pos_right);
1449 segnum = find_point_seg(&pos_left, obj->segnum);
1451 object_create_explosion(segnum, &pos_left, size_scale, VCLIP_AFTERBURNER_BLOB );
1454 segnum = find_point_seg(&pos_right, obj->segnum);
1457 blob_obj = object_create_explosion(segnum, &pos_right, size_scale, VCLIP_AFTERBURNER_BLOB );
1459 blob_obj->lifeleft = lifetime;