Removed the previously used homers code and instead used old one to keep good ol' Gameplay; Removed FrameCount steps from track_track_goal() and scaled homing vector accordingly to this change, including properly scaling it to FrameTime; Made code more similar between D1X and D2X; Introduced different turn rates for different difficulty levels
This commit is contained in:
parent
c6bb443c63
commit
3e96a3185b
|
@ -3,6 +3,7 @@ D1X-Rebirth Changelog
|
||||||
20100615
|
20100615
|
||||||
--------
|
--------
|
||||||
main/game.c, main/gameseq.c: Resetting GameTime, Next/Last_flare/laser/missile_time in reset_time() together so GameTime-rollover-fallbacks will not create a massive delay when starting a new level
|
main/game.c, main/gameseq.c: Resetting GameTime, Next/Last_flare/laser/missile_time in reset_time() together so GameTime-rollover-fallbacks will not create a massive delay when starting a new level
|
||||||
|
main/laser.c: Removed the previously homers code and instead used old one to keep good ol' Gameplay; Removed FrameCount steps from track_track_goal() and scaled homing vector accordingly to this change, including properly scaling it to FrameTime; Made code more similar between D1X and D2X; Introduced different turn rates for different difficulty levels
|
||||||
|
|
||||||
20100614
|
20100614
|
||||||
--------
|
--------
|
||||||
|
|
88
main/laser.c
88
main/laser.c
|
@ -45,10 +45,9 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include "powerup.h"
|
#include "powerup.h"
|
||||||
#include "multi.h"
|
#include "multi.h"
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
|
|
||||||
|
|
||||||
#include "hudmsg.h"
|
#include "hudmsg.h"
|
||||||
|
|
||||||
|
#define NEWHOMER
|
||||||
|
|
||||||
int Laser_rapid_fire = 0;
|
int Laser_rapid_fire = 0;
|
||||||
|
|
||||||
|
@ -483,9 +482,8 @@ fix Min_trackable_dot = 3*(F1_0 - MIN_TRACKABLE_DOT)/4 + MIN_TRACKABLE_DOT; //MI
|
||||||
// Return true if weapon *tracker is able to track object Objects[track_goal], else return false.
|
// Return true if weapon *tracker is able to track object Objects[track_goal], else return false.
|
||||||
// In order for the object to be trackable, it must be within a reasonable turning radius for the missile
|
// In order for the object to be trackable, it must be within a reasonable turning radius for the missile
|
||||||
// and it must not be obstructed by a wall.
|
// and it must not be obstructed by a wall.
|
||||||
int object_is_trackable(int track_goal, object *tracker)
|
int object_is_trackable(int track_goal, object *tracker, fix *dot)
|
||||||
{
|
{
|
||||||
fix dot; //, dist_to_goal;
|
|
||||||
vms_vector vector_to_goal;
|
vms_vector vector_to_goal;
|
||||||
object *objp;
|
object *objp;
|
||||||
|
|
||||||
|
@ -508,9 +506,14 @@ int object_is_trackable(int track_goal, object *tracker)
|
||||||
|
|
||||||
vm_vec_sub(&vector_to_goal, &objp->pos, &tracker->pos);
|
vm_vec_sub(&vector_to_goal, &objp->pos, &tracker->pos);
|
||||||
vm_vec_normalize_quick(&vector_to_goal);
|
vm_vec_normalize_quick(&vector_to_goal);
|
||||||
dot = vm_vec_dot(&vector_to_goal, &tracker->orient.fvec);
|
*dot = vm_vec_dot(&vector_to_goal, &tracker->orient.fvec);
|
||||||
|
|
||||||
if (dot >= Min_trackable_dot) {
|
if ((*dot < Min_trackable_dot) && (*dot > F1_0*9/10)) {
|
||||||
|
vm_vec_normalize(&vector_to_goal);
|
||||||
|
*dot = vm_vec_dot(&vector_to_goal, &tracker->orient.fvec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*dot >= Min_trackable_dot) {
|
||||||
int rval;
|
int rval;
|
||||||
// dot is in legal range, now see if object is visible
|
// dot is in legal range, now see if object is visible
|
||||||
rval = object_to_object_visibility(tracker, objp, FQ_TRANSWALL);
|
rval = object_to_object_visibility(tracker, objp, FQ_TRANSWALL);
|
||||||
|
@ -518,7 +521,6 @@ int object_is_trackable(int track_goal, object *tracker)
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
@ -682,11 +684,19 @@ int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_o
|
||||||
// ------------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------------
|
||||||
// See if legal to keep tracking currently tracked object. If not, see if another object is trackable. If not, return -1,
|
// See if legal to keep tracking currently tracked object. If not, see if another object is trackable. If not, return -1,
|
||||||
// else return object number of tracking object.
|
// else return object number of tracking object.
|
||||||
int track_track_goal(int track_goal, object *tracker)
|
int track_track_goal(int track_goal, object *tracker, fix *dot)
|
||||||
{
|
{
|
||||||
if (object_is_trackable(track_goal, tracker))
|
#ifdef NEWHOMER
|
||||||
|
if (object_is_trackable(track_goal, tracker, dot) && (tracker-Objects)) {
|
||||||
return track_goal;
|
return track_goal;
|
||||||
else if ((((tracker-Objects) ^ FrameCount) % 4) == 0) {
|
} else if (tracker-Objects)
|
||||||
|
#else
|
||||||
|
// Every 8 frames for each object, scan all objects.
|
||||||
|
if (object_is_trackable(track_goal, tracker, dot) && ((((tracker-Objects) ^ FrameCount) % 8) != 0)) {
|
||||||
|
return track_goal;
|
||||||
|
} else if ((((tracker-Objects) ^ FrameCount) % 4) == 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
int rval = -2;
|
int rval = -2;
|
||||||
|
|
||||||
// If player fired missile, then search for an object, if not, then give up.
|
// If player fired missile, then search for an object, if not, then give up.
|
||||||
|
@ -953,6 +963,10 @@ void Laser_TurnSpeedLimit(vms_vector* vec_forward, vms_vector* vec_to_target, fi
|
||||||
*vec_forward = *vec_to_target;
|
*vec_forward = *vec_to_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NEWHOMER
|
||||||
|
fix homing_turn_base[NDL] = { 20, 30, 40, 50, 60 };
|
||||||
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------
|
||||||
//sequence this laser object for this _frame_ (underscores added here to aid MK in his searching!)
|
//sequence this laser object for this _frame_ (underscores added here to aid MK in his searching!)
|
||||||
void Laser_do_weapon_sequence(object *obj)
|
void Laser_do_weapon_sequence(object *obj)
|
||||||
|
@ -985,7 +999,7 @@ void Laser_do_weapon_sequence(object *obj)
|
||||||
// For homing missiles, turn towards target.
|
// For homing missiles, turn towards target.
|
||||||
if (Weapon_info[obj->id].homing_flag) {
|
if (Weapon_info[obj->id].homing_flag) {
|
||||||
vms_vector vector_to_object, temp_vec;
|
vms_vector vector_to_object, temp_vec;
|
||||||
fix dot;
|
fix dot=F1_0;
|
||||||
fix speed, max_speed;
|
fix speed, max_speed;
|
||||||
|
|
||||||
// For first 1/2 second of life, missile flies straight.
|
// For first 1/2 second of life, missile flies straight.
|
||||||
|
@ -999,7 +1013,7 @@ void Laser_do_weapon_sequence(object *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the object we are tracking is still trackable.
|
// Make sure the object we are tracking is still trackable.
|
||||||
track_goal = track_track_goal(track_goal, obj);
|
track_goal = track_track_goal(track_goal, obj, &dot);
|
||||||
|
|
||||||
if (track_goal == Players[Player_num].objnum) {
|
if (track_goal == Players[Player_num].objnum) {
|
||||||
fix dist_to_player;
|
fix dist_to_player;
|
||||||
|
@ -1011,38 +1025,31 @@ void Laser_do_weapon_sequence(object *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_goal != -1) {
|
if (track_goal != -1) {
|
||||||
fix turn_radius;
|
#ifdef NEWHOMER
|
||||||
|
|
||||||
turn_radius = 0x0024 * F1_0;
|
|
||||||
|
|
||||||
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
||||||
|
|
||||||
// we need normalized exact vectors here
|
vm_vec_normalize_quick(&vector_to_object);
|
||||||
vm_vec_normalize (&vector_to_object);
|
|
||||||
temp_vec = obj->mtype.phys_info.velocity;
|
temp_vec = obj->mtype.phys_info.velocity;
|
||||||
// gives magnitude
|
speed = vm_vec_normalize(&temp_vec);
|
||||||
speed = vm_vec_normalize (&temp_vec);
|
|
||||||
// homing missile speeds : insane - 0x005a
|
|
||||||
max_speed = Weapon_info[obj->id].speed[Difficulty_level];
|
max_speed = Weapon_info[obj->id].speed[Difficulty_level];
|
||||||
|
if (speed+F1_0 < max_speed) {
|
||||||
if (speed+F1_0 < max_speed)
|
|
||||||
{
|
|
||||||
speed += fixmul(max_speed, FrameTime/2);
|
speed += fixmul(max_speed, FrameTime/2);
|
||||||
if (speed > max_speed)
|
if (speed > max_speed)
|
||||||
speed = max_speed;
|
speed = max_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
dot = vm_vec_dot(&temp_vec, &vector_to_object);
|
// Old homers only get valid track_goal every 8 frames. That was changed so scale vector to object accordingly.
|
||||||
|
vm_vec_scale(&vector_to_object, F1_0/4);
|
||||||
|
// Scale vector to object to current FrameTime.
|
||||||
|
vm_vec_scale(&vector_to_object, F1_0/((float)(F1_0/homing_turn_base[Difficulty_level])/FrameTime));
|
||||||
|
|
||||||
Laser_TurnSpeedLimit(&temp_vec, &vector_to_object, speed, turn_radius);
|
vm_vec_add2(&temp_vec, &vector_to_object);
|
||||||
|
// The boss' smart children track better...
|
||||||
|
if (Weapon_info[obj->id].render_type != WEAPON_RENDER_POLYMODEL)
|
||||||
|
vm_vec_add2(&temp_vec, &vector_to_object);
|
||||||
|
vm_vec_normalize(&temp_vec);
|
||||||
|
vm_vec_scale(&temp_vec, speed);
|
||||||
obj->mtype.phys_info.velocity = temp_vec;
|
obj->mtype.phys_info.velocity = temp_vec;
|
||||||
// orient it directly by movement vector
|
|
||||||
if (Weapon_info[obj->id].render_type == WEAPON_RENDER_POLYMODEL)
|
|
||||||
vm_vector_2_matrix (&obj->orient, &temp_vec, NULL, NULL);
|
|
||||||
// apply speed
|
|
||||||
vm_vec_scale (&temp_vec, speed);
|
|
||||||
obj->mtype.phys_info.velocity = temp_vec;
|
|
||||||
|
|
||||||
|
|
||||||
// Subtract off life proportional to amount turned.
|
// Subtract off life proportional to amount turned.
|
||||||
// For hardest turn, it will lose 2 seconds per second.
|
// For hardest turn, it will lose 2 seconds per second.
|
||||||
|
@ -1051,17 +1058,14 @@ void Laser_do_weapon_sequence(object *obj)
|
||||||
|
|
||||||
absdot = abs(F1_0 - dot);
|
absdot = abs(F1_0 - dot);
|
||||||
|
|
||||||
if (absdot > F1_0/8) {
|
lifelost = fixmul(absdot*32, FrameTime);
|
||||||
if (absdot > F1_0/4)
|
|
||||||
absdot = F1_0/4;
|
|
||||||
lifelost = fixmul(absdot*16, FrameTime);
|
|
||||||
obj->lifeleft -= lifelost;
|
obj->lifeleft -= lifelost;
|
||||||
}
|
}
|
||||||
//added 8/14/98 by Victor Rachels to make homers lose life while going straight, too
|
|
||||||
obj->lifeleft -= fixmul(F1_0, FrameTime);
|
// Only polygon objects have visible orientation, so only they should turn.
|
||||||
//end addition - Victor Rachels
|
if (Weapon_info[obj->id].render_type == WEAPON_RENDER_POLYMODEL)
|
||||||
}
|
homing_missile_turn_towards_velocity(obj, &temp_vec); // temp_vec is normalized velocity.
|
||||||
#if 0 // OLD - ORIGINAL - MISSILE TRACKING CODE
|
#else // OLD - ORIGINAL - MISSILE TRACKING CODE
|
||||||
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
||||||
|
|
||||||
vm_vec_normalize_quick(&vector_to_object);
|
vm_vec_normalize_quick(&vector_to_object);
|
||||||
|
|
Loading…
Reference in a new issue