Fit player/player collisions to not take damage from bump while remote player has possibly not aligned to the collision, yet; Added FORCE_DAMAGE_THRESHOLD for minimum force damage to receive from object bumps to not simply take damage from touching objects

This commit is contained in:
zicodxx 2012-05-26 13:28:43 +02:00
parent 4cfc516d56
commit 98f6ac2204
2 changed files with 40 additions and 16 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20120526
--------
main/collide.c: Fit player/player collisions to not take damage from bump while remote player has possibly not aligned to the collision, yet; Added FORCE_DAMAGE_THRESHOLD for minimum force damage to receive from object bumps to not simply take damage from touching objects
20120525
--------
main/cntrlcen.c, main/game.c, main/switch.c: Cancel out do_controlcen_dead_frame() when not playing and only check triggers for playing players for further host-authority stuff; Made GameProcessFrame not cause endless loop by closing kmatrix over and over again due to game_leave_menus(); Also only close menus when level ends and when we die only the automap will close - otherwise menus can stay (user request)

View file

@ -66,18 +66,19 @@ static char rcsid[] = "$Id: collide.c,v 1.1.1.1 2006/03/17 19:41:32 zicodxx Exp
#include "piggy.h"
#include "text.h"
#include "maths.h"
#ifdef EDITOR
#include "editor/editor.h"
#endif
#include "collide.h"
#ifdef SCRIPT
#include "script.h"
#endif
#define STANDARD_EXPL_DELAY (f1_0/4)
#define WALL_DAMAGE_SCALE (128) // Was 32 before 8:55 am on Thursday, September 15, changed by MK, walls were hurting me more than robots!
#define WALL_DAMAGE_THRESHOLD (F1_0/3)
#define WALL_LOUDNESS_SCALE (20)
#define FORCE_DAMAGE_THRESHOLD (F1_0/3)
#define STANDARD_EXPL_DELAY (F1_0/4)
int check_collision_delayfunc_exec()
{
@ -140,6 +141,9 @@ void apply_force_damage(object *obj,fix force,object *other_obj)
damage = fixdiv(force,obj->mtype.phys_info.mass) / 8;
if (damage < FORCE_DAMAGE_THRESHOLD)
return;
switch (obj->type) {
case OBJ_ROBOT:
@ -176,14 +180,14 @@ void apply_force_damage(object *obj,fix force,object *other_obj)
apply_damage_to_clutter(obj,damage);
break;
case OBJ_CNTRLCEN:
case OBJ_CNTRLCEN: // Never hits! Reactor does not have MT_PHYSICS - it's stationary! So no force damage here.
apply_damage_to_controlcen(obj,damage, other_obj-Objects);
break;
break;
case OBJ_WEAPON:
break; //weapons don't take damage
break; //weapons don't take damage
default:
@ -269,10 +273,6 @@ void bump_one_object(object *obj0, vms_vector *hit_dir, fix damage)
}
#define DAMAGE_SCALE 128 // Was 32 before 8:55 am on Thursday, September 15, changed by MK, walls were hurting me more than robots!
#define DAMAGE_THRESHOLD (F1_0/3)
#define WALL_LOUDNESS_SCALE (20)
void collide_player_and_wall( object * player, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
{
fix damage;
@ -288,11 +288,11 @@ void collide_player_and_wall( object * player, fix hitspeed, short hitseg, short
// ** Damage from hitting wall **
// If the player has less than 10% shields, don't take damage from bump
damage = hitspeed / DAMAGE_SCALE;
damage = hitspeed / WALL_DAMAGE_SCALE;
if (damage >= DAMAGE_THRESHOLD) {
if (damage >= WALL_DAMAGE_THRESHOLD) {
int volume;
volume = (hitspeed-(DAMAGE_SCALE*DAMAGE_THRESHOLD)) / WALL_LOUDNESS_SCALE ;
volume = (hitspeed-(WALL_DAMAGE_SCALE*WALL_DAMAGE_THRESHOLD)) / WALL_LOUDNESS_SCALE ;
create_awareness_event(player, PA_WEAPON_WALL_COLLISION);
@ -1041,11 +1041,31 @@ void collide_hostage_and_player( object * hostage, object * player, vms_vector *
//## return;
//##}
void collide_player_and_player( object * player1, object * player2, vms_vector *collision_point ) {
void collide_player_and_player( object * player1, object * player2, vms_vector *collision_point )
{
static fix64 last_player_bump[MAX_PLAYERS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int damage_flag = 1, otherpl = -1;
if (check_collision_delayfunc_exec())
digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player1->segnum, 0, collision_point, 0, F1_0 );
bump_two_objects(player1, player2, 1);
// Multi is special - as always. Clients do the bump damage locally but the remote players do their collision result (change velocity) on their own. So after our initial collision, ignore further collision damage till remote players (hopefully) react.
if (Game_mode & GM_MULTI)
{
damage_flag = 0;
if (!(player1->id == Player_num || player2->id == Player_num))
return;
if (player1->id < 0 || player1->id > MAX_PLAYERS || player2->id < 0 || player2->id > MAX_PLAYERS)
return;
otherpl = (player1->id==Player_num)?player2->id:player1->id;
if (last_player_bump[otherpl] + (F1_0/Netgame.PacketsPerSec) < GameTime64 || last_player_bump[otherpl] > GameTime64)
{
last_player_bump[otherpl] = GameTime64;
damage_flag = 1;
}
}
bump_two_objects(player1, player2, damage_flag);
return;
}