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
cac223991f
commit
ee53409d18
|
@ -3,6 +3,7 @@ D2X-Rebirth Changelog
|
|||
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/laser.c: 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
|
||||
|
||||
20100614
|
||||
--------
|
||||
|
|
54
main/laser.c
54
main/laser.c
|
@ -50,6 +50,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "physics.h"
|
||||
#include "multi.h"
|
||||
|
||||
#define NEWHOMER
|
||||
|
||||
int Laser_rapid_fire = 0;
|
||||
|
||||
object *Guided_missile[MAX_PLAYERS]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
|
@ -898,7 +900,6 @@ int object_is_trackable(int track_goal, object *tracker, fix *dot)
|
|||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern int Robots_kill_robots_cheat;
|
||||
|
@ -1131,10 +1132,17 @@ int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_o
|
|||
// Computes and returns a fairly precise dot product.
|
||||
int track_track_goal(int track_goal, object *tracker, fix *dot)
|
||||
{
|
||||
#ifdef NEWHOMER
|
||||
if (object_is_trackable(track_goal, tracker, dot) && (tracker-Objects)) {
|
||||
return track_goal;
|
||||
} 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) {
|
||||
} else if ((((tracker-Objects) ^ FrameCount) % 4) == 0)
|
||||
#endif
|
||||
{
|
||||
int rval = -2;
|
||||
|
||||
// If player fired missile, then search for an object, if not, then give up.
|
||||
|
@ -1431,6 +1439,10 @@ void Laser_TurnSpeedLimit(vms_vector* vec_forward, vms_vector* vec_to_target, fi
|
|||
*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!)
|
||||
void Laser_do_weapon_sequence(object *obj)
|
||||
|
@ -1500,39 +1512,32 @@ void Laser_do_weapon_sequence(object *obj)
|
|||
}
|
||||
|
||||
if (track_goal != -1) {
|
||||
fix turn_radius;
|
||||
|
||||
turn_radius = 0x0024 * F1_0;
|
||||
|
||||
#ifdef NEWHOMER
|
||||
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
||||
|
||||
// we need normalized exact vectors here
|
||||
vm_vec_normalize (&vector_to_object);
|
||||
vm_vec_normalize_quick(&vector_to_object);
|
||||
temp_vec = obj->mtype.phys_info.velocity;
|
||||
// gives magnitude
|
||||
speed = vm_vec_normalize(&temp_vec);
|
||||
// homing missile speeds : insane - 0x005a
|
||||
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);
|
||||
if (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);
|
||||
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_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;
|
||||
|
||||
|
||||
// Subtract off life proportional to amount turned.
|
||||
// For hardest turn, it will lose 2 seconds per second.
|
||||
{
|
||||
|
@ -1541,8 +1546,13 @@ void Laser_do_weapon_sequence(object *obj)
|
|||
absdot = abs(F1_0 - dot);
|
||||
|
||||
lifelost = fixmul(absdot*32, FrameTime);
|
||||
obj->lifeleft -= lifelost;
|
||||
}
|
||||
#if 0 // OLD - ORIGINAL - MISSILE TRACKING CODE
|
||||
|
||||
// Only polygon objects have visible orientation, so only they should turn.
|
||||
if (Weapon_info[obj->id].render_type == WEAPON_RENDER_POLYMODEL)
|
||||
homing_missile_turn_towards_velocity(obj, &temp_vec); // temp_vec is normalized velocity.
|
||||
#else // OLD - ORIGINAL - MISSILE TRACKING CODE
|
||||
vm_vec_sub(&vector_to_object, &Objects[track_goal].pos, &obj->pos);
|
||||
|
||||
vm_vec_normalize_quick(&vector_to_object);
|
||||
|
|
Loading…
Reference in a new issue