feat(candy-survival): toggle-and-walk knock mode, unified animations, score rewards, RPC fix

- Changed knock from instant-ambush to toggle-and-walk: press Q to toggle Knock Mode ON, walk into target to execute, consumed on use
- Unified knock animation with other game modes (attack_mode SFX, bump, 3-tile knockback, stagger)
- Added +100 score rewards for completing goals, KNOCK, and GHOST
- Fixed RPC unknown peer ID crash for AI bots in ghost/candy stack sync
- Bots auto-toggle is_charged_strike when they have knock charges
- Fixed profile panel username update on connected peers
- Added SafeNakamaMultiplayerBridge for match state crash prevention
This commit is contained in:
2026-07-09 18:03:26 +08:00
parent 00c9e85527
commit 2b4c9d9dcb
8 changed files with 116 additions and 68 deletions
+6 -15
View File
@@ -215,16 +215,7 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
NotificationManager.send_message(player, "Target is Immune!", NotificationManager.MessageType.WARNING)
return false
# Candy Survival: check if attacker has knock charges
var has_knock = false
var main_for_knock = player.get_tree().root.get_node_or_null("Main")
var gm_for_knock = main_for_knock.get("candy_survival_manager") if main_for_knock else null
if gm_for_knock and gm_for_knock.active:
var att_pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
var charges = gm_for_knock.player_knocks.get(att_pid, 0) if gm_for_knock.player_knocks else 0
has_knock = charges > 0
if (not player.get("is_charged_strike") and not has_knock) or player.get("is_invisible"):
if not player.get("is_charged_strike") or player.get("is_invisible"):
# Standard bumping effect (Visual only)
print("[Move] Push blocked: Not charged or is Ghost (%s trying to push %s)" % [player.name, other_player.name])
if _can_rpc():
@@ -258,12 +249,12 @@ func try_push(target_pos: Vector2i, direction: Vector2i) -> bool:
if gm and gm.active and gm.has_method("try_knock"):
var pid = player.get("peer_id") if "peer_id" in player else player.name.to_int()
var other_pid = other_player.get("peer_id") if "peer_id" in other_player else other_player.name.to_int()
if gm.try_knock(pid, other_pid):
print("[CandySurvival] Player %d knocked %d, stole candies!" % [pid, other_pid])
if multiplayer.is_server():
gm.try_knock(pid, other_pid)
else:
print("[CandySurvival] Player %d tried to knock %d (backfire or no charges)" % [pid, other_pid])
if _can_rpc():
player.rpc("sync_bump", target_pos, false)
gm.rpc_id(1, "try_knock", pid, other_pid)
# Consume knock mode after use (toggle off)
player.is_charged_strike = false
return false
# === SUPER PUSH (Attack Mode) ===