mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
fixed incorrect handling of projectiel and laser owner
This commit is contained in:
parent
9f7a6a04b0
commit
ac1aeab149
|
@ -322,7 +322,6 @@ void CHARACTER::fire_weapon()
|
|||
projectile_startpos,
|
||||
direction,
|
||||
(int)(server_tickspeed()*tuning.gun_lifetime),
|
||||
this,
|
||||
1, 0, 0, -1, WEAPON_GUN);
|
||||
|
||||
// pack the projectile and send it to the client directly
|
||||
|
@ -358,7 +357,6 @@ void CHARACTER::fire_weapon()
|
|||
projectile_startpos,
|
||||
vec2(cosf(a), sinf(a))*speed,
|
||||
(int)(server_tickspeed()*tuning.shotgun_lifetime),
|
||||
this,
|
||||
1, 0, 0, -1, WEAPON_SHOTGUN);
|
||||
|
||||
// pack the projectile and send it to the client directly
|
||||
|
@ -382,7 +380,6 @@ void CHARACTER::fire_weapon()
|
|||
projectile_startpos,
|
||||
direction,
|
||||
(int)(server_tickspeed()*tuning.grenade_lifetime),
|
||||
this,
|
||||
1, PROJECTILE::PROJECTILE_FLAGS_EXPLODE, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
|
||||
|
||||
// pack the projectile and send it to the client directly
|
||||
|
@ -401,7 +398,7 @@ void CHARACTER::fire_weapon()
|
|||
|
||||
case WEAPON_RIFLE:
|
||||
{
|
||||
new LASER(pos, direction, tuning.laser_reach, this);
|
||||
new LASER(pos, direction, tuning.laser_reach, player->client_id);
|
||||
game.create_sound(pos, SOUND_RIFLE_FIRE);
|
||||
} break;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//////////////////////////////////////////////////
|
||||
// laser
|
||||
//////////////////////////////////////////////////
|
||||
LASER::LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner)
|
||||
LASER::LASER(vec2 pos, vec2 direction, float start_energy, int owner)
|
||||
: ENTITY(NETOBJTYPE_LASER)
|
||||
{
|
||||
this->pos = pos;
|
||||
|
@ -24,14 +24,15 @@ LASER::LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner)
|
|||
bool LASER::hit_character(vec2 from, vec2 to)
|
||||
{
|
||||
vec2 at;
|
||||
CHARACTER *hit = game.world.intersect_character(pos, to, 0.0f, at, owner);
|
||||
CHARACTER *owner_char = game.get_player_char(owner);
|
||||
CHARACTER *hit = game.world.intersect_character(pos, to, 0.0f, at, owner_char);
|
||||
if(!hit)
|
||||
return false;
|
||||
|
||||
this->from = from;
|
||||
pos = at;
|
||||
energy = -1;
|
||||
hit->take_damage(vec2(0,0), tuning.laser_damage, owner->player->client_id, WEAPON_RIFLE);
|
||||
hit->take_damage(vec2(0,0), tuning.laser_damage, owner, WEAPON_RIFLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,14 @@ class LASER : public ENTITY
|
|||
float energy;
|
||||
int bounces;
|
||||
int eval_tick;
|
||||
CHARACTER *owner;
|
||||
int owner;
|
||||
|
||||
bool hit_character(vec2 from, vec2 to);
|
||||
void do_bounce();
|
||||
|
||||
public:
|
||||
|
||||
LASER(vec2 pos, vec2 direction, float start_energy, CHARACTER *owner);
|
||||
LASER(vec2 pos, vec2 direction, float start_energy, int owner);
|
||||
|
||||
virtual void reset();
|
||||
virtual void tick();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//////////////////////////////////////////////////
|
||||
// projectile
|
||||
//////////////////////////////////////////////////
|
||||
PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span, ENTITY* powner,
|
||||
PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span,
|
||||
int damage, int flags, float force, int sound_impact, int weapon)
|
||||
: ENTITY(NETOBJTYPE_PROJECTILE)
|
||||
{
|
||||
|
@ -16,7 +16,6 @@ PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span, ENTITY
|
|||
this->direction = dir;
|
||||
this->lifespan = span;
|
||||
this->owner = owner;
|
||||
this->powner = powner;
|
||||
this->flags = flags;
|
||||
this->force = force;
|
||||
this->damage = damage;
|
||||
|
@ -68,8 +67,8 @@ void PROJECTILE::tick()
|
|||
|
||||
int collide = col_intersect_line(prevpos, curpos, &curpos);
|
||||
//int collide = col_check_point((int)curpos.x, (int)curpos.y);
|
||||
|
||||
CHARACTER *targetchr = game.world.intersect_character(prevpos, curpos, 6.0f, curpos, powner);
|
||||
CHARACTER *ownerchar = game.get_player_char(owner);
|
||||
CHARACTER *targetchr = game.world.intersect_character(prevpos, curpos, 6.0f, curpos, ownerchar);
|
||||
if(targetchr || collide || lifespan < 0)
|
||||
{
|
||||
if(lifespan >= 0 || weapon == WEAPON_GRENADE)
|
||||
|
|
|
@ -12,7 +12,6 @@ public:
|
|||
};
|
||||
|
||||
vec2 direction;
|
||||
ENTITY *powner; // this is nasty, could be removed when client quits
|
||||
int lifespan;
|
||||
int owner;
|
||||
int type;
|
||||
|
@ -24,7 +23,7 @@ public:
|
|||
float force;
|
||||
int start_tick;
|
||||
|
||||
PROJECTILE(int type, int owner, vec2 pos, vec2 vel, int span, ENTITY* powner,
|
||||
PROJECTILE(int type, int owner, vec2 pos, vec2 vel, int span,
|
||||
int damage, int flags, float force, int sound_impact, int weapon);
|
||||
|
||||
vec2 get_pos(float time);
|
||||
|
|
|
@ -26,6 +26,13 @@ void GAMECONTEXT::clear()
|
|||
}
|
||||
|
||||
|
||||
class CHARACTER *GAMECONTEXT::get_player_char(int client_id)
|
||||
{
|
||||
if(client_id < 0 || client_id >= MAX_CLIENTS || !players[client_id])
|
||||
return 0;
|
||||
return players[client_id]->get_character();
|
||||
}
|
||||
|
||||
void GAMECONTEXT::create_damageind(vec2 p, float angle, int amount)
|
||||
{
|
||||
float a = 3 * 3.14159f / 2 + angle;
|
||||
|
|
|
@ -44,6 +44,9 @@ public:
|
|||
void tick();
|
||||
void snap(int client_id);
|
||||
|
||||
// helper functions
|
||||
class CHARACTER *get_player_char(int client_id);
|
||||
|
||||
// voting
|
||||
void start_vote(const char *desc, const char *command);
|
||||
void end_vote();
|
||||
|
|
Loading…
Reference in a new issue