diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/client/game_client.cpp | 67 | ||||
| -rw-r--r-- | src/game/game_protocol.h | 7 | ||||
| -rw-r--r-- | src/game/game_variables.h | 3 | ||||
| -rw-r--r-- | src/game/server/game_server.cpp | 72 | ||||
| -rw-r--r-- | src/game/server/srv_common.h | 14 |
5 files changed, 155 insertions, 8 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index 301a1166..55c98bc1 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -58,6 +58,45 @@ struct client_data player_core predicted; } 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); } void snd_play_random(int chn, int setid, float vol, vec2 pos) @@ -804,8 +843,8 @@ static void render_projectile(const obj_projectile *prev, const obj_projectile * // TODO: do this, but nice //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_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_weapon3)) input.wanted_weapon = 3; 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 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 - if(inp_key_pressed('M')) + if(inp_key_pressed('M') || zoom > 3.01f) { gfx_clear_mask(0); @@ -2054,7 +2099,12 @@ void render_game() gfx_quads_begin(); 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; @@ -2138,6 +2188,10 @@ void render_game() // render cursor 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); float cursorsize = 64; 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_begin(); 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); for (int i = 0; i < local_player->ammocount; i++) gfx_quads_drawTL(10+i*12,34,10,10); + gfx_quads_end(); gfx_texture_set(data->images[IMAGE_GAME].id); diff --git a/src/game/game_protocol.h b/src/game/game_protocol.h index 0300c88a..c6fb28c7 100644 --- a/src/game/game_protocol.h +++ b/src/game/game_protocol.h @@ -70,9 +70,9 @@ enum STATE_IN_MENU, STATE_CHATTING, - GAMETYPE_DM=0, - GAMETYPE_TDM, - GAMETYPE_CTF, + //GAMETYPE_DM=0, + //GAMETYPE_TDM, + //GAMETYPE_CTF, }; struct player_input @@ -181,6 +181,7 @@ struct obj_player : public obj_player_core int health; int armor; int ammocount; + int weaponstage; int weapon; // current active weapon diff --git a/src/game/game_variables.h b/src/game/game_variables.h index 7be4c86b..a72f79dc 100644 --- a/src/game/game_variables.h +++ b/src/game/game_variables.h @@ -7,6 +7,9 @@ MACRO_CONFIG_INT(key_weapon1, '1', 32, 512) MACRO_CONFIG_INT(key_weapon2, '2', 32, 512) MACRO_CONFIG_INT(key_weapon3, '3', 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_prev_weapon, 383, 32, 512) diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 9821c87f..13ea42de 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -489,6 +489,8 @@ void player::try_respawn() weapons[WEAPON_HAMMER].ammo = -1; weapons[WEAPON_GUN].got = true; weapons[WEAPON_GUN].ammo = data->weapons[WEAPON_GUN].maxammo; + + active_weapon = WEAPON_GUN; last_weapon = WEAPON_HAMMER; @@ -626,6 +628,68 @@ static input_count count_input(int prev, int cur) 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() { vec2 direction = normalize(vec2(input.target_x, input.target_y)); @@ -686,6 +750,12 @@ int player::handle_weapons() active_weapon = new_weapon; } } + + 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)) { @@ -881,7 +951,6 @@ void player::tick() core.input = input; core.tick(); - // handle weapons handle_weapons(); /* @@ -1042,6 +1111,7 @@ void player::snap(int snaping_client) player->latency_flux = latency_max-latency_min; player->ammocount = weapons[active_weapon].ammo; + player->weaponstage = weapons[active_weapon].weaponstage; player->health = 0; player->armor = 0; player->local = 0; diff --git a/src/game/server/srv_common.h b/src/game/server/srv_common.h index 8cef2cf8..1e544753 100644 --- a/src/game/server/srv_common.h +++ b/src/game/server/srv_common.h @@ -166,6 +166,11 @@ public: enum { PROJECTILE_FLAGS_EXPLODE = 1 << 0, + + WEAPON_PROJECTILETYPE_GUN = 0, + WEAPON_PROJECTILETYPE_ROCKET = 1, + WEAPON_PROJECTILETYPE_SHOTGUN = 2, + WEAPON_PROJECTILETYPE_SNIPER = 6, }; vec2 vel; @@ -198,6 +203,12 @@ public: MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY = 1 << 0, MODIFIER_RETURNFLAGS_OVERRIDEPOSITION = 1 << 1, MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY = 1 << 2, + + MODIFIER_RETURNFLAGS_NOHOOK = 1 << 3, + + + WEAPONSTAGE_SNIPER_NEUTRAL = 0, + WEAPONSTAGE_SNIPER_CHARGING = 1, }; // weapon info @@ -208,6 +219,8 @@ public: int ammoregenstart; int ammo; int ammocost; + int weaponstage; + int chargetick; bool got; } weapons[NUM_WEAPONS]; int active_weapon; @@ -281,6 +294,7 @@ public: int handle_weapons(); int handle_ninja(); + int handle_sniper(); virtual void tick(); virtual void tick_defered(); |