mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
various gameplay tweaks
This commit is contained in:
parent
1eadf9942a
commit
fc2c1286a6
|
@ -392,9 +392,9 @@ weapons {
|
||||||
muzzleoffsetx 70.0
|
muzzleoffsetx 70.0
|
||||||
muzzleoffsety 6.0
|
muzzleoffsety 6.0
|
||||||
maxammo 10
|
maxammo 10
|
||||||
costammo 2
|
costammo 1
|
||||||
recoil 10
|
recoil 10
|
||||||
firedelay 600
|
firedelay 400
|
||||||
muzzleduration 5
|
muzzleduration 5
|
||||||
visual_size 96
|
visual_size 96
|
||||||
offsetx 24.0
|
offsetx 24.0
|
||||||
|
@ -425,7 +425,7 @@ weapons {
|
||||||
visual_size 96
|
visual_size 96
|
||||||
offsetx 4.0
|
offsetx 4.0
|
||||||
offsety -20.0
|
offsety -20.0
|
||||||
meleedamage 1
|
meleedamage 3
|
||||||
meleereach 40
|
meleereach 40
|
||||||
ammoregentime 0
|
ammoregentime 0
|
||||||
duration -1
|
duration -1
|
||||||
|
|
|
@ -11,7 +11,7 @@ data_container *data = 0x0;
|
||||||
using namespace baselib;
|
using namespace baselib;
|
||||||
|
|
||||||
// --------- DEBUG STUFF ---------
|
// --------- DEBUG STUFF ---------
|
||||||
const int debug_bots = 0;
|
const int debug_bots = 4;
|
||||||
|
|
||||||
// --------- PHYSICS TWEAK! --------
|
// --------- PHYSICS TWEAK! --------
|
||||||
const float ground_control_speed = 7.0f;
|
const float ground_control_speed = 7.0f;
|
||||||
|
@ -60,6 +60,45 @@ T saturated_add(T min, T max, T current, T modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: rewrite this smarter!
|
||||||
|
void move_point(vec2 *inout_pos, vec2 *inout_vel, float elasticity, int *bounces)
|
||||||
|
{
|
||||||
|
if(bounces)
|
||||||
|
*bounces = 0;
|
||||||
|
|
||||||
|
vec2 pos = *inout_pos;
|
||||||
|
vec2 vel = *inout_vel;
|
||||||
|
if(col_check_point(pos + vel))
|
||||||
|
{
|
||||||
|
int affected = 0;
|
||||||
|
if(col_check_point(pos.x + vel.x, pos.y))
|
||||||
|
{
|
||||||
|
inout_vel->x *= -elasticity;
|
||||||
|
if(bounces)
|
||||||
|
(*bounces)++;
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(col_check_point(pos.x, pos.y + vel.y))
|
||||||
|
{
|
||||||
|
inout_vel->y *= -elasticity;
|
||||||
|
if(bounces)
|
||||||
|
(*bounces)++;
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(affected == 0)
|
||||||
|
{
|
||||||
|
inout_vel->x *= -elasticity;
|
||||||
|
inout_vel->y *= -elasticity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*inout_pos = pos + vel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: rewrite this smarter!
|
// TODO: rewrite this smarter!
|
||||||
void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity)
|
void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity)
|
||||||
{
|
{
|
||||||
|
@ -535,6 +574,7 @@ projectile::projectile(int type, int owner, vec2 pos, vec2 vel, int span, entity
|
||||||
this->damage = damage;
|
this->damage = damage;
|
||||||
this->sound_impact = sound_impact;
|
this->sound_impact = sound_impact;
|
||||||
this->weapon = weapon;
|
this->weapon = weapon;
|
||||||
|
this->bounce = 0;
|
||||||
world.insert_entity(this);
|
world.insert_entity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,14 +586,29 @@ void projectile::reset()
|
||||||
void projectile::tick()
|
void projectile::tick()
|
||||||
{
|
{
|
||||||
vec2 oldpos = pos;
|
vec2 oldpos = pos;
|
||||||
|
|
||||||
|
int collide = 0;
|
||||||
|
if(bounce)
|
||||||
|
{
|
||||||
|
int numbounces;
|
||||||
|
vel.y += 0.25f;
|
||||||
|
move_point(&pos, &vel, 0.9f, &numbounces);
|
||||||
|
bounce -= numbounces;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vel.y += 0.25f;
|
vel.y += 0.25f;
|
||||||
pos += vel;
|
pos += vel;
|
||||||
|
collide = col_check_point((int)pos.x, (int)pos.y);
|
||||||
|
}
|
||||||
|
|
||||||
lifespan--;
|
lifespan--;
|
||||||
|
|
||||||
// check player intersection as well
|
// check player intersection as well
|
||||||
vec2 new_pos;
|
vec2 new_pos;
|
||||||
entity *targetplayer = (entity*)intersect_player(oldpos, pos, new_pos, powner);
|
entity *targetplayer = (entity*)intersect_player(oldpos, pos, new_pos, powner);
|
||||||
if(targetplayer || lifespan < 0 || col_check_point((int)pos.x, (int)pos.y))
|
|
||||||
|
if(targetplayer || lifespan < 0 || collide || bounce < 0)
|
||||||
{
|
{
|
||||||
if (lifespan >= 0 || weapon == WEAPON_ROCKET)
|
if (lifespan >= 0 || weapon == WEAPON_ROCKET)
|
||||||
create_sound(pos, sound_impact);
|
create_sound(pos, sound_impact);
|
||||||
|
@ -920,15 +975,18 @@ int player::handle_weapons()
|
||||||
create_sound(pos, SOUND_GUN_FIRE);
|
create_sound(pos, SOUND_GUN_FIRE);
|
||||||
break;
|
break;
|
||||||
case WEAPON_ROCKET:
|
case WEAPON_ROCKET:
|
||||||
new projectile(projectile::WEAPON_PROJECTILETYPE_ROCKET,
|
{
|
||||||
|
projectile *p = new projectile(projectile::WEAPON_PROJECTILETYPE_ROCKET,
|
||||||
client_id,
|
client_id,
|
||||||
pos+vec2(0,0),
|
pos+vec2(0,0),
|
||||||
direction*15.0f,
|
direction*15.0f,
|
||||||
100,
|
100,
|
||||||
this,
|
this,
|
||||||
1, projectile::PROJECTILE_FLAGS_EXPLODE, 0, SOUND_ROCKET_EXPLODE, WEAPON_ROCKET);
|
1, projectile::PROJECTILE_FLAGS_EXPLODE, 0, SOUND_ROCKET_EXPLODE, WEAPON_ROCKET);
|
||||||
|
p->bounce = 1;
|
||||||
create_sound(pos, SOUND_ROCKET_FIRE);
|
create_sound(pos, SOUND_ROCKET_FIRE);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case WEAPON_SHOTGUN:
|
case WEAPON_SHOTGUN:
|
||||||
{
|
{
|
||||||
int shotspread = min(2, weapons[active_weapon].ammo);
|
int shotspread = min(2, weapons[active_weapon].ammo);
|
||||||
|
@ -936,15 +994,15 @@ int player::handle_weapons()
|
||||||
for(int i = -shotspread; i <= shotspread; i++)
|
for(int i = -shotspread; i <= shotspread; i++)
|
||||||
{
|
{
|
||||||
float a = get_angle(direction);
|
float a = get_angle(direction);
|
||||||
a += i*0.075f;
|
a += i*0.08f;
|
||||||
new projectile(projectile::WEAPON_PROJECTILETYPE_SHOTGUN,
|
new projectile(projectile::WEAPON_PROJECTILETYPE_SHOTGUN,
|
||||||
client_id,
|
client_id,
|
||||||
pos+vec2(0,0),
|
pos+vec2(0,0),
|
||||||
vec2(cosf(a), sinf(a))*25.0f,
|
vec2(cosf(a), sinf(a))*25.0f,
|
||||||
//vec2(cosf(a), sinf(a))*20.0f,
|
//vec2(cosf(a), sinf(a))*20.0f,
|
||||||
server_tickspeed()/3,
|
(int)(server_tickspeed()*0.4f),
|
||||||
this,
|
this,
|
||||||
2, 0, 0, -1, WEAPON_SHOTGUN);
|
1, 0, 0, -1, WEAPON_SHOTGUN);
|
||||||
}
|
}
|
||||||
create_sound(pos, SOUND_SHOTGUN_FIRE);
|
create_sound(pos, SOUND_SHOTGUN_FIRE);
|
||||||
break;
|
break;
|
||||||
|
@ -1005,19 +1063,20 @@ int player::handle_weapons()
|
||||||
// hit a player, give him damage and stuffs...
|
// hit a player, give him damage and stuffs...
|
||||||
// create sound for bash
|
// create sound for bash
|
||||||
//create_sound(ents[i]->pos, sound_impact);
|
//create_sound(ents[i]->pos, sound_impact);
|
||||||
|
vec2 fdir = normalize(ents[i]->pos- pos);
|
||||||
|
|
||||||
// set his velocity to fast upward (for now)
|
// set his velocity to fast upward (for now)
|
||||||
create_smoke(ents[i]->pos);
|
create_smoke(ents[i]->pos);
|
||||||
create_sound(pos, SOUND_HAMMER_HIT);
|
create_sound(pos, SOUND_HAMMER_HIT);
|
||||||
hitobjects[numobjectshit++] = ents[i];
|
hitobjects[numobjectshit++] = ents[i];
|
||||||
ents[i]->take_damage(vec2(0,10.0f), data->weapons[active_weapon].meleedamage, client_id, active_weapon);
|
ents[i]->take_damage(vec2(0,-1.0f), data->weapons[active_weapon].meleedamage, client_id, active_weapon);
|
||||||
player* target = (player*)ents[i];
|
player* target = (player*)ents[i];
|
||||||
vec2 dir;
|
vec2 dir;
|
||||||
if (length(target->pos - pos) > 0.0f)
|
if (length(target->pos - pos) > 0.0f)
|
||||||
dir = normalize(target->pos - pos);
|
dir = normalize(target->pos - pos);
|
||||||
else
|
else
|
||||||
dir = vec2(0,-1);
|
dir = vec2(0,-1);
|
||||||
target->vel += dir * 10.0f + vec2(0,-10.0f);
|
target->vel += dir * 25.0f + vec2(0,-5.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->weapons[active_weapon].ammoregentime)
|
if (data->weapons[active_weapon].ammoregentime)
|
||||||
|
@ -1302,6 +1361,10 @@ bool player::take_damage(vec2 force, int dmg, int from, int weapon)
|
||||||
{
|
{
|
||||||
vel += force;
|
vel += force;
|
||||||
|
|
||||||
|
// player only inflicts half damage on self
|
||||||
|
if(from == client_id)
|
||||||
|
dmg = max(1, dmg/2);
|
||||||
|
|
||||||
// create healthmod indicator
|
// create healthmod indicator
|
||||||
create_damageind(pos, normalize(force), dmg);
|
create_damageind(pos, normalize(force), dmg);
|
||||||
|
|
||||||
|
@ -1664,7 +1727,7 @@ void create_explosion(vec2 p, int owner, int weapon, bool bnodamage)
|
||||||
l = 1-clamp((l-innerradius)/(radius-innerradius), 0.0f, 1.0f);
|
l = 1-clamp((l-innerradius)/(radius-innerradius), 0.0f, 1.0f);
|
||||||
float dmg = 6 * l;
|
float dmg = 6 * l;
|
||||||
if((int)dmg)
|
if((int)dmg)
|
||||||
ents[i]->take_damage(forcedir*dmg*2, (int)dmg/2, owner, weapon);
|
ents[i]->take_damage(forcedir*dmg*2, (int)dmg, owner, weapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,7 @@ public:
|
||||||
int damage;
|
int damage;
|
||||||
int sound_impact;
|
int sound_impact;
|
||||||
int weapon;
|
int weapon;
|
||||||
|
int bounce;
|
||||||
float force;
|
float force;
|
||||||
|
|
||||||
projectile(int type, int owner, baselib::vec2 pos, baselib::vec2 vel, int span, entity* powner,
|
projectile(int type, int owner, baselib::vec2 pos, baselib::vec2 vel, int span, entity* powner,
|
||||||
|
|
Loading…
Reference in a new issue