diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-09 15:56:56 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-12-09 15:56:56 +0000 |
| commit | b7cbe51313409ce1b31a1a931c5508385af4696c (patch) | |
| tree | 95df1c9c077195b6e30cafd9a1cd37c05f977a8c | |
| parent | 02e34399139c756b16ac8ab0bc7f5066b270d6b3 (diff) | |
| download | zcatch-b7cbe51313409ce1b31a1a931c5508385af4696c.tar.gz zcatch-b7cbe51313409ce1b31a1a931c5508385af4696c.zip | |
fixed so that the hook is released after 2 seconds
| -rw-r--r-- | src/game/game.cpp | 15 | ||||
| -rw-r--r-- | src/game/game_protocol.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index bbeb5940..6e91f06c 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -174,7 +174,7 @@ void player_core::tick() hook_pos = pos; hook_dir = direction; hooked_player = -1; - hook_tick = -1; + hook_tick = 0; triggered_events |= COREEVENT_HOOK_LAUNCH; } else if(hook_state == HOOK_FLYING) @@ -244,7 +244,7 @@ void player_core::tick() hook_state = HOOK_IDLE; hook_pos = pos; } - + if(hook_state == HOOK_GRABBED) { if(hooked_player != -1) @@ -281,6 +281,15 @@ void player_core::tick() vel = new_vel; // no problem. apply } + + // release hook + hook_tick++; + if(hook_tick > SERVER_TICK_SPEED*2) + { + hooked_player = -1; + hook_state = HOOK_RETRACTED; + hook_pos = pos; + } } MACRO_CHECK_VELOCITY @@ -336,6 +345,7 @@ void player_core::write(obj_player_core *obj_core) obj_core->vx = (int)(vel.x*256.0f); obj_core->vy = (int)(vel.y*256.0f); obj_core->hook_state = hook_state; + obj_core->hook_tick = hook_tick; obj_core->hook_x = (int)hook_pos.x; obj_core->hook_y = (int)hook_pos.y; obj_core->hook_dx = (int)(hook_dir.x*256.0f); @@ -362,6 +372,7 @@ void player_core::read(const obj_player_core *obj_core) vel.x = obj_core->vx/256.0f; vel.y = obj_core->vy/256.0f; hook_state = obj_core->hook_state; + hook_tick = obj_core->hook_tick; hook_pos.x = obj_core->hook_x; hook_pos.y = obj_core->hook_y; hook_dir.x = obj_core->hook_dx/256.0f; diff --git a/src/game/game_protocol.h b/src/game/game_protocol.h index b89eb239..fea8b066 100644 --- a/src/game/game_protocol.h +++ b/src/game/game_protocol.h @@ -179,6 +179,7 @@ struct obj_player_core int hooked_player; int hook_state; + int hook_tick; int hook_x, hook_y; int hook_dx, hook_dy; }; |