diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-15 12:04:48 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-15 12:04:48 +0000 |
| commit | 1ba4e8d4ef42c26ce1dd496658bf6e48893ca4f4 (patch) | |
| tree | f74f4387841e3f24e24b7aee602aa4afb7d3043c | |
| parent | a3c5960ffedccf31ba2f133c88ed1533038e7f92 (diff) | |
| download | zcatch-1ba4e8d4ef42c26ce1dd496658bf6e48893ca4f4.tar.gz zcatch-1ba4e8d4ef42c26ce1dd496658bf6e48893ca4f4.zip | |
some renames and sniper stuff
| -rw-r--r-- | datasrc/teewars.ds | 61 | ||||
| -rw-r--r-- | src/game/server/gs_common.h | 5 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 83 |
3 files changed, 106 insertions, 43 deletions
diff --git a/datasrc/teewars.ds b/datasrc/teewars.ds index 8c0f70c4..65a426c4 100644 --- a/datasrc/teewars.ds +++ b/datasrc/teewars.ds @@ -486,6 +486,37 @@ weapons { 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 + } + ninja { sprite_body sprites.game.weapon_ninja_body sprite_cursor sprites.game.weapon_ninja_cursor @@ -516,37 +547,7 @@ weapons { 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 - } } sprites { diff --git a/src/game/server/gs_common.h b/src/game/server/gs_common.h index 93264f9f..7df0a9c4 100644 --- a/src/game/server/gs_common.h +++ b/src/game/server/gs_common.h @@ -234,7 +234,6 @@ public: int ammo; int ammocost; int weaponstage; - int chargetick; bool got; } weapons[NUM_WEAPONS]; int active_weapon; @@ -243,6 +242,8 @@ public: int reload_timer; int attack_tick; + int sniper_chargetick; + int damage_taken; int emote_type; @@ -270,7 +271,7 @@ public: // ninja vec2 activationdir; - int ninjaactivationtick; + int ninja_activationtick; int extrapowerflags; int currentcooldown; int currentactivation; diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 65985371..f7c2f005 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -389,7 +389,8 @@ void player::reset() damage_taken_tick = 0; attack_tick = 0; numobjectshit = 0; - ninjaactivationtick = 0; + ninja_activationtick = 0; + sniper_chargetick = -1; currentmovetime = 0; active_weapon = WEAPON_GUN; @@ -481,6 +482,10 @@ void player::try_respawn() health = 10; armor = 0; jumped = 0; + + ninja_activationtick = 0; + sniper_chargetick = -1; + dead = false; set_flag(entity::FLAG_PHYSICS); state = STATE_PLAYING; @@ -549,7 +554,7 @@ int player::handle_ninja() { vec2 direction = normalize(vec2(input.target_x, input.target_y)); - if ((server_tick() - ninjaactivationtick) > (data->weapons[WEAPON_NINJA].duration * server_tickspeed() / 1000)) + if ((server_tick() - ninja_activationtick) > (data->weapons[WEAPON_NINJA].duration * server_tickspeed() / 1000)) { // time's up, return weapons[WEAPON_NINJA].got = false; @@ -643,10 +648,48 @@ int player::handle_ninja() int player::handle_sniper() { - return 0; - + /* struct input_count button = count_input(previnput.fire, input.fire); - if (button.releases) + + bool must_release = false; + int current_load = (server_tick()-sniper_chargetick) / server_tickspeed() + 1; + + if(input.fire&1) + { + if(sniper_chargetick == -1) + { + // start charge + sniper_chargetick = server_tick(); + } + else + { + if(current_load > weapons[WEAPON_SNIPER].ammo+3) + must_release = true; + } + } + + if(button.releases || must_release) + { + vec2 direction = normalize(vec2(input.target_x, input.target_y)); + + // released + sniper_chargetick = -1; + + if(current_load > weapons[WEAPON_SNIPER].ammo) + current_load = weapons[WEAPON_SNIPER].ammo; + + weapons[WEAPON_SNIPER].ammo -= current_load; + + new projectile(projectile::WEAPON_PROJECTILETYPE_SNIPER, + client_id, pos+vec2(0,0), direction*50.0f, + 100, this, current_load, 0, 0, -1, WEAPON_SNIPER); + create_sound(pos, SOUND_SNIPER_FIRE); + + } + */ + + /* + if(button.releases) { vec2 direction = normalize(vec2(input.target_x, input.target_y)); // Check if we were charging, if so fire @@ -697,11 +740,11 @@ int player::handle_sniper() } // While charging, don't move - return MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY|MODIFIER_RETURNFLAGS_NOHOOK; + return 0; } else if (weapons[WEAPON_SNIPER].weaponstage) weapons[WEAPON_SNIPER].weaponstage = WEAPONSTAGE_SNIPER_NEUTRAL; - } + }*/ return 0; } @@ -776,11 +819,11 @@ int player::handle_weapons() } } + // don't update other weapons while sniper is active + /* 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)) { @@ -792,12 +835,15 @@ int player::handle_weapons() switch(active_weapon) { case WEAPON_HAMMER: + { // reset objects hit numobjectshit = 0; create_sound(pos, SOUND_HAMMER_FIRE); break; + } case WEAPON_GUN: + { new projectile(WEAPON_GUN, client_id, pos+vec2(0,0), @@ -807,6 +853,7 @@ int player::handle_weapons() 1, 0, 0, -1, WEAPON_GUN); create_sound(pos, SOUND_GUN_FIRE); break; + } case WEAPON_ROCKET: { new projectile(WEAPON_ROCKET, @@ -840,6 +887,20 @@ int player::handle_weapons() create_sound(pos, SOUND_SHOTGUN_FIRE); break; } + + case WEAPON_SNIPER: + { + new projectile(WEAPON_SNIPER, + client_id, + pos+vec2(0,0), + direction*300.0f, + 100, + this, + 1, 0, 0, -1, WEAPON_SNIPER); + create_sound(pos, SOUND_SNIPER_FIRE); + break; + } + } weapons[active_weapon].ammo--; @@ -1324,7 +1385,7 @@ void powerup::tick() case POWERUP_NINJA: { // activate ninja on target player - pplayer->ninjaactivationtick = server_tick(); + pplayer->ninja_activationtick = server_tick(); pplayer->weapons[WEAPON_NINJA].got = true; pplayer->last_weapon = pplayer->active_weapon; pplayer->active_weapon = WEAPON_NINJA; |