This commit is contained in:
Olle Rosenquist 2007-10-14 13:54:02 +00:00
parent 20680df032
commit eba83b7e19
10 changed files with 241 additions and 8 deletions

View file

@ -120,3 +120,4 @@ const array:int image = images.*
const array:int sprite = sprites.*.* const array:int sprite = sprites.*.*
const array:int anim = animations.* const array:int anim = animations.*
const array:int powerup = powerups.* const array:int powerup = powerups.*
const array:int gametype = playerstats.*

View file

@ -1,6 +1,7 @@
const array:int sound = sounds.* const array:int sound = sounds.*
const array:int weapon = weapons.* const array:int weapon = weapons.*
const array:int powerup = powerups.* const array:int powerup = powerups.*
const array:int gametype = playerstats.*
struct weapon { struct weapon {
int firedelay = firedelay@1 int firedelay = firedelay@1
@ -12,6 +13,8 @@ struct weapon {
int duration = duration@1 int duration = duration@1
int movetime = movetime@1 int movetime = movetime@1
int velocity = velocity@1 int velocity = velocity@1
float chargetime = chargetime@1
float overchargetime = overchargetime@1
} }
struct powerupinf { struct powerupinf {

View file

@ -11,6 +11,12 @@ sounds {
"data/audio/wp_shotty_fire-03.wv" "data/audio/wp_shotty_fire-03.wv"
} }
sniper_fire {
"data/audio/wp_shotty_fire-01.wv"
"data/audio/wp_shotty_fire-02.wv"
"data/audio/wp_shotty_fire-03.wv"
}
rocket_fire { rocket_fire {
"data/audio/wp_flump_launch-01.wv" "data/audio/wp_flump_launch-01.wv"
"data/audio/wp_flump_launch-02.wv" "data/audio/wp_flump_launch-02.wv"
@ -321,6 +327,41 @@ projectileparticles {
particlesize 16.0 particlesize 16.0
particlelife 0.8 particlelife 0.8
} }
empty1 {
particlespersecond 300
particlesize 8.0
particlelife 0.8
}
empty2 {
particlespersecond 300
particlesize 8.0
particlelife 0.8
}
empty3 {
particlespersecond 300
particlesize 8.0
particlelife 0.8
}
sniper {
particlespersecond 300
particlesize 8.0
particlelife 0.8
}
}
playerstats {
dm {
maxhealth 10
maxarmor 10
}
tdm {
maxhealth 10
maxarmor 10
}
ctf {
maxhealth 10
maxarmor 10
}
} }
weapons { weapons {
@ -348,6 +389,8 @@ weapons {
duration -1 duration -1
movetime 0 movetime 0
velocity 0 velocity 0
chargetime 0.0
overchargetime 0.0
} }
gun { gun {
@ -377,6 +420,8 @@ weapons {
duration -1 duration -1
movetime 0 movetime 0
velocity 0 velocity 0
chargetime 0.0
overchargetime 0.0
} }
shotgun { shotgun {
@ -406,6 +451,8 @@ weapons {
duration -1 duration -1
movetime 0 movetime 0
velocity 0 velocity 0
chargetime 0.0
overchargetime 0.0
} }
rocket { rocket {
@ -432,6 +479,8 @@ weapons {
duration -1 duration -1
movetime 0 movetime 0
velocity 0 velocity 0
chargetime 0.0
overchargetime 0.0
} }
ninja { ninja {
@ -461,6 +510,39 @@ weapons {
duration 15000 duration 15000
movetime 200 movetime 200
velocity 50 velocity 50
chargetime 0.0
overchargetime 0.0
}
sniper {
sprite_body sprites.game.weapon_rocket_body
sprite_cursor sprites.game.weapon_rocket_cursor
sprite_proj sprites.game.weapon_rocket_proj
sprite_muzzles {
sprites.game.weapon_shotgun_muzzle1
sprites.game.weapon_shotgun_muzzle2
sprites.game.weapon_shotgun_muzzle3
}
nummuzzlesprites 3
muzzleoffsetx 0.0
muzzleoffsety 0.0
maxammo 10
costammo 1
recoil 10
firedelay 600
muzzleduration 0
visual_size 96
offsetx 24.0
offsety -2.0
meleedamage 0
meleereach 0
ammoregentime 0
duration -1
movetime 0
velocity 0
chargetime 0.5
overchargetime 10.0
} }
} }

View file

@ -58,6 +58,45 @@ struct client_data
player_core predicted; player_core predicted;
} client_datas[MAX_CLIENTS]; } client_datas[MAX_CLIENTS];
class client_effects
{
public:
float zoom;
float currentzoom;
float stage;
int lastzoomin;
int lastincrease;
client_effects()
{
currentzoom = zoom = 3.0f;
stage = 0.0f;
}
float getorgzoom() { return zoom; }
float getzoom(int tick, float intratick, obj_player* player)
{
float currentstage = ((float)player->weaponstage) * 0.1f;
if (currentstage < stage)
{
if ((tick - lastincrease) > (client_tickspeed() / 2))
stage = currentstage;
}
else
{
lastincrease = tick;
stage = currentstage;
}
float targetzoom = 3.0f + stage;
currentzoom = LERP(currentzoom, targetzoom, 0.1);
return currentzoom;
}
};
client_effects cl_effects;
inline float frandom() { return rand()/(float)(RAND_MAX); } inline float frandom() { return rand()/(float)(RAND_MAX); }
void snd_play_random(int chn, int setid, float vol, vec2 pos) void snd_play_random(int chn, int setid, float vol, vec2 pos)
@ -805,7 +844,7 @@ static void render_projectile(const obj_projectile *prev, const obj_projectile *
// TODO: do this, but nice // TODO: do this, but nice
//temp_system.new_particle(pos, vec2(0,0), 0.3f, 14.0f, 0, 0.95f); //temp_system.new_particle(pos, vec2(0,0), 0.3f, 14.0f, 0, 0.95f);
gfx_quads_draw(pos.x, pos.y,32,32); gfx_quads_draw(pos.x, pos.y, 32, 32);
gfx_quads_setrotation(0); gfx_quads_setrotation(0);
gfx_quads_end(); gfx_quads_end();
} }
@ -1990,6 +2029,8 @@ void render_game()
if(inp_key_presses(config.key_weapon2)) input.wanted_weapon = 2; if(inp_key_presses(config.key_weapon2)) input.wanted_weapon = 2;
if(inp_key_presses(config.key_weapon3)) input.wanted_weapon = 3; if(inp_key_presses(config.key_weapon3)) input.wanted_weapon = 3;
if(inp_key_presses(config.key_weapon4)) input.wanted_weapon = 4; if(inp_key_presses(config.key_weapon4)) input.wanted_weapon = 4;
if(inp_key_presses(config.key_weapon5)) input.wanted_weapon = 5;
if(inp_key_presses(config.key_weapon6)) input.wanted_weapon = 6;
} }
} }
@ -2041,8 +2082,12 @@ void render_game()
else else
render_world(local_player_pos.x+offx, local_player_pos.y+offy, 1.0f); render_world(local_player_pos.x+offx, local_player_pos.y+offy, 1.0f);
// pseudo format
// ZOOM ZOOM
float zoom = cl_effects.getzoom(client_tick(), client_intratick(), local_player);//orgzoom + ((float)local_player->weaponstage) * 0.1f;
// DEBUG TESTING // DEBUG TESTING
if(inp_key_pressed('M')) if(inp_key_pressed('M') || zoom > 3.01f)
{ {
gfx_clear_mask(0); gfx_clear_mask(0);
@ -2054,7 +2099,12 @@ void render_game()
gfx_quads_begin(); gfx_quads_begin();
gfx_setcolor(0.65f,0.78f,0.9f,1.0f); gfx_setcolor(0.65f,0.78f,0.9f,1.0f);
float fov = pi/6.0f; float fov;
if (zoom > 3.01f)
fov = pi * (zoom - 3.0f) / 6.0f;
else
fov = pi / 6.0f;
float fade = 0.7f; float fade = 0.7f;
@ -2138,6 +2188,10 @@ void render_game()
// render cursor // render cursor
if (!menu_active && (!emoticon_selector_active || emoticon_selector_inactive_override)) if (!menu_active && (!emoticon_selector_active || emoticon_selector_inactive_override))
{ {
//float width = 400 * cl_effects.getorgzoom();
//float height = 300 * cl_effects.getorgzoom();
//gfx_mapscreen(screen_x-width/2, screen_y-height/2, screen_x+width/2, screen_y+height/2);
select_sprite(data->weapons[local_player->weapon%data->num_weapons].sprite_cursor); select_sprite(data->weapons[local_player->weapon%data->num_weapons].sprite_cursor);
float cursorsize = 64; float cursorsize = 64;
draw_sprite(local_player_pos.x+mouse_pos.x, local_player_pos.y+mouse_pos.y, cursorsize); draw_sprite(local_player_pos.x+mouse_pos.x, local_player_pos.y+mouse_pos.y, cursorsize);
@ -2148,9 +2202,14 @@ void render_game()
gfx_quads_end(); gfx_quads_end();
gfx_quads_begin(); gfx_quads_begin();
gfx_mapscreen(0,0,400,300); gfx_mapscreen(0,0,400,300);
// if weaponstage is active, put a "glow" around the stage ammo
select_sprite(SPRITE_TEE_BODY);
for (int i = 0; i < local_player->weaponstage; i++)
gfx_quads_drawTL(local_player->ammocount * 12 -i*12, 32, 11, 11);
select_sprite(data->weapons[local_player->weapon%data->num_weapons].sprite_proj); select_sprite(data->weapons[local_player->weapon%data->num_weapons].sprite_proj);
for (int i = 0; i < local_player->ammocount; i++) for (int i = 0; i < local_player->ammocount; i++)
gfx_quads_drawTL(10+i*12,34,10,10); gfx_quads_drawTL(10+i*12,34,10,10);
gfx_quads_end(); gfx_quads_end();
gfx_texture_set(data->images[IMAGE_GAME].id); gfx_texture_set(data->images[IMAGE_GAME].id);

View file

@ -70,9 +70,9 @@ enum
STATE_IN_MENU, STATE_IN_MENU,
STATE_CHATTING, STATE_CHATTING,
GAMETYPE_DM=0, //GAMETYPE_DM=0,
GAMETYPE_TDM, //GAMETYPE_TDM,
GAMETYPE_CTF, //GAMETYPE_CTF,
}; };
struct player_input struct player_input
@ -181,6 +181,7 @@ struct obj_player : public obj_player_core
int health; int health;
int armor; int armor;
int ammocount; int ammocount;
int weaponstage;
int weapon; // current active weapon int weapon; // current active weapon

View file

@ -7,6 +7,9 @@ MACRO_CONFIG_INT(key_weapon1, '1', 32, 512)
MACRO_CONFIG_INT(key_weapon2, '2', 32, 512) MACRO_CONFIG_INT(key_weapon2, '2', 32, 512)
MACRO_CONFIG_INT(key_weapon3, '3', 32, 512) MACRO_CONFIG_INT(key_weapon3, '3', 32, 512)
MACRO_CONFIG_INT(key_weapon4, '4', 32, 512) MACRO_CONFIG_INT(key_weapon4, '4', 32, 512)
MACRO_CONFIG_INT(key_weapon5, '5', 32, 512)
MACRO_CONFIG_INT(key_weapon6, '6', 32, 512)
MACRO_CONFIG_INT(key_weapon7, '7', 32, 512)
MACRO_CONFIG_INT(key_next_weapon, 382, 32, 512) MACRO_CONFIG_INT(key_next_weapon, 382, 32, 512)
MACRO_CONFIG_INT(key_prev_weapon, 383, 32, 512) MACRO_CONFIG_INT(key_prev_weapon, 383, 32, 512)

View file

@ -490,6 +490,8 @@ void player::try_respawn()
weapons[WEAPON_GUN].got = true; weapons[WEAPON_GUN].got = true;
weapons[WEAPON_GUN].ammo = data->weapons[WEAPON_GUN].maxammo; weapons[WEAPON_GUN].ammo = data->weapons[WEAPON_GUN].maxammo;
active_weapon = WEAPON_GUN; active_weapon = WEAPON_GUN;
last_weapon = WEAPON_HAMMER; last_weapon = WEAPON_HAMMER;
@ -626,6 +628,68 @@ static input_count count_input(int prev, int cur)
return c; return c;
} }
int player::handle_sniper()
{
struct input_count button = count_input(previnput.fire, input.fire);
if (button.releases)
{
vec2 direction = normalize(vec2(input.target_x, input.target_y));
// Check if we were charging, if so fire
if (weapons[WEAPON_SNIPER].weaponstage >= WEAPONSTAGE_SNIPER_CHARGING)
{
new projectile(projectile::WEAPON_PROJECTILETYPE_SNIPER,
client_id, pos+vec2(0,0), direction*50.0f,
100 + weapons[WEAPON_SNIPER].weaponstage * 20,this, weapons[WEAPON_SNIPER].weaponstage, 0, 0, -1, WEAPON_SNIPER);
create_sound(pos, SOUND_SNIPER_FIRE);
}
// Add blowback
core.vel = -direction * 10.0f * weapons[WEAPON_SNIPER].weaponstage;
// update ammo and stuff
weapons[WEAPON_SNIPER].ammo = max(0,weapons[WEAPON_SNIPER].ammo - weapons[WEAPON_SNIPER].weaponstage);
weapons[WEAPON_SNIPER].weaponstage = WEAPONSTAGE_SNIPER_NEUTRAL;
weapons[WEAPON_SNIPER].chargetick = 0;
}
else if (input.fire & 1)
{
// Charge!! (if we are on the ground)
if (is_grounded() && weapons[WEAPON_SNIPER].ammo > 0)
{
if (!weapons[WEAPON_SNIPER].chargetick)
{
weapons[WEAPON_SNIPER].chargetick = server_tick();
dbg_msg("game", "Chargetick='%d:'", server_tick());
}
if ((server_tick() - weapons[WEAPON_SNIPER].chargetick) > server_tickspeed() * data->weapons[active_weapon].chargetime)
{
if (weapons[WEAPON_SNIPER].ammo > weapons[WEAPON_SNIPER].weaponstage)
{
weapons[WEAPON_SNIPER].weaponstage++;
weapons[WEAPON_SNIPER].chargetick = server_tick();
}
else if ((server_tick() - weapons[WEAPON_SNIPER].chargetick) > server_tickspeed() * data->weapons[active_weapon].overchargetime)
{
// Ooopsie, weapon exploded
create_explosion(pos, client_id, WEAPON_SNIPER, false);
create_sound(pos, SOUND_ROCKET_EXPLODE);
// remove this weapon and change weapon to gun
weapons[WEAPON_SNIPER].got = false;
weapons[WEAPON_SNIPER].ammo = 0;
last_weapon = active_weapon;
active_weapon = WEAPON_GUN;
return 0;
}
}
// While charging, don't move
return MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY|MODIFIER_RETURNFLAGS_NOHOOK;
}
else if (weapons[WEAPON_SNIPER].weaponstage)
weapons[WEAPON_SNIPER].weaponstage = WEAPONSTAGE_SNIPER_NEUTRAL;
}
return 0;
}
int player::handle_weapons() int player::handle_weapons()
{ {
vec2 direction = normalize(vec2(input.target_x, input.target_y)); vec2 direction = normalize(vec2(input.target_x, input.target_y));
@ -687,6 +751,12 @@ int player::handle_weapons()
} }
} }
if (active_weapon == WEAPON_SNIPER)
{
// don't update other weapons while sniper is active
return handle_sniper();
}
if(count_input(previnput.fire, input.fire).presses) //previnput.fire != input.fire && (input.fire&1)) if(count_input(previnput.fire, input.fire).presses) //previnput.fire != input.fire && (input.fire&1))
{ {
if(reload_timer == 0) if(reload_timer == 0)
@ -881,7 +951,6 @@ void player::tick()
core.input = input; core.input = input;
core.tick(); core.tick();
// handle weapons // handle weapons
handle_weapons(); handle_weapons();
/* /*
@ -1042,6 +1111,7 @@ void player::snap(int snaping_client)
player->latency_flux = latency_max-latency_min; player->latency_flux = latency_max-latency_min;
player->ammocount = weapons[active_weapon].ammo; player->ammocount = weapons[active_weapon].ammo;
player->weaponstage = weapons[active_weapon].weaponstage;
player->health = 0; player->health = 0;
player->armor = 0; player->armor = 0;
player->local = 0; player->local = 0;

View file

@ -166,6 +166,11 @@ public:
enum enum
{ {
PROJECTILE_FLAGS_EXPLODE = 1 << 0, PROJECTILE_FLAGS_EXPLODE = 1 << 0,
WEAPON_PROJECTILETYPE_GUN = 0,
WEAPON_PROJECTILETYPE_ROCKET = 1,
WEAPON_PROJECTILETYPE_SHOTGUN = 2,
WEAPON_PROJECTILETYPE_SNIPER = 6,
}; };
vec2 vel; vec2 vel;
@ -198,6 +203,12 @@ public:
MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY = 1 << 0, MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY = 1 << 0,
MODIFIER_RETURNFLAGS_OVERRIDEPOSITION = 1 << 1, MODIFIER_RETURNFLAGS_OVERRIDEPOSITION = 1 << 1,
MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY = 1 << 2, MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY = 1 << 2,
MODIFIER_RETURNFLAGS_NOHOOK = 1 << 3,
WEAPONSTAGE_SNIPER_NEUTRAL = 0,
WEAPONSTAGE_SNIPER_CHARGING = 1,
}; };
// weapon info // weapon info
@ -208,6 +219,8 @@ public:
int ammoregenstart; int ammoregenstart;
int ammo; int ammo;
int ammocost; int ammocost;
int weaponstage;
int chargetick;
bool got; bool got;
} weapons[NUM_WEAPONS]; } weapons[NUM_WEAPONS];
int active_weapon; int active_weapon;
@ -281,6 +294,7 @@ public:
int handle_weapons(); int handle_weapons();
int handle_ninja(); int handle_ninja();
int handle_sniper();
virtual void tick(); virtual void tick();
virtual void tick_defered(); virtual void tick_defered();

Binary file not shown.

Binary file not shown.