Fix Repentance placeholder VFX: targets, colors, animation check
High: server now computes visual targets after resolution — prefers client-provided unit InstanceId or tile Coord, falls back to the first live opponent ArchSpirit so targetless/server-resolved effects always have a destination. Medium: source ArchSpirit fallback now looks up the actor's player in game state rather than get_my_player(), fixing opponent and spectator views. Medium: player color now uses teamIndex from the player DTO instead of deriving it from seatOrder, fixing team and multiplayer modes. Low: hasCustomAnimation check now scans all Active ability definitions for a non-empty AssetUrl, not just abilities[0]. Low: server no longer sends the push (or the HasCustomAnimation field) when a custom animation exists; client-side guard removed accordingly. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -20,16 +20,13 @@ var units_root : Node3D = null
|
||||
|
||||
## Called by game_screen when Game.repentance_placeholder_visual fires.
|
||||
func play(payload: Dictionary) -> void:
|
||||
if bool(payload.get("hasCustomAnimation", false)):
|
||||
return
|
||||
|
||||
var actor_id: String = str(payload.get("actorAccountId", ""))
|
||||
var arch_id: String = str(payload.get("sourceArchSpiritInstanceId", ""))
|
||||
var affinity: String = str(payload.get("affinity", ""))
|
||||
var targets_raw: Variant = payload.get("targets", [])
|
||||
var targets: Array = targets_raw as Array if targets_raw is Array else []
|
||||
|
||||
var src_pos: Vector3 = _resolve_arch_spirit_pos(arch_id)
|
||||
var src_pos: Vector3 = _resolve_arch_spirit_pos(arch_id, actor_id)
|
||||
var tgt_pos: Vector3 = _resolve_target_pos(targets, actor_id, src_pos)
|
||||
|
||||
var affinity_color: Color = GameConstants.AFFINITY_COLORS.get(affinity, Color(0.7, 0.55, 0.9))
|
||||
@@ -40,15 +37,17 @@ func play(payload: Dictionary) -> void:
|
||||
|
||||
# ── Position resolution ───────────────────────────────────────────────────────
|
||||
|
||||
func _resolve_arch_spirit_pos(arch_instance_id: String) -> Vector3:
|
||||
func _resolve_arch_spirit_pos(arch_instance_id: String, actor_id: String) -> Vector3:
|
||||
if not arch_instance_id.is_empty():
|
||||
var body: StaticBody3D = unit_bodies.get(arch_instance_id) as StaticBody3D
|
||||
if is_instance_valid(body):
|
||||
return body.global_position + Vector3(0, 0.5, 0)
|
||||
|
||||
# Fallback: my own ArchSpirit from game state.
|
||||
var my_arch: Dictionary = Game.get_my_player().get("archSpirit", {})
|
||||
var pos: Dictionary = my_arch.get("position", {})
|
||||
# Fallback: resolve the actor's ArchSpirit from game state (works for
|
||||
# opponent casts, spectators, and timing gaps during mesh rebuilds).
|
||||
var actor_player: Dictionary = _player_by_id(actor_id)
|
||||
var arch: Dictionary = actor_player.get("archSpirit", {})
|
||||
var pos: Dictionary = arch.get("position", {})
|
||||
if not pos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(int(pos.get("x", 0)), int(pos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
|
||||
@@ -82,50 +81,41 @@ func _resolve_target_pos(targets: Array, actor_id: String, fallback: Vector3) ->
|
||||
for t: Variant in targets:
|
||||
if not (t is Dictionary):
|
||||
continue
|
||||
var td: Dictionary = t as Dictionary
|
||||
var td: Dictionary = t as Dictionary
|
||||
var inst_id: String = str(td.get("instanceId", td.get("instance_id", "")))
|
||||
if inst_id.is_empty():
|
||||
continue
|
||||
# Try it as an account id — look for that player's arch spirit.
|
||||
var all_players: Array = []
|
||||
var state: Dictionary = Game.state
|
||||
for p: Variant in state.get("players", []):
|
||||
all_players.append(p)
|
||||
for p: Variant in all_players:
|
||||
if not (p is Dictionary):
|
||||
continue
|
||||
var pd: Dictionary = p as Dictionary
|
||||
var acc: String = str(pd.get("accountId", ""))
|
||||
if acc != inst_id:
|
||||
continue
|
||||
var arch: Dictionary = pd.get("archSpirit", {})
|
||||
var apos: Dictionary = arch.get("position", {})
|
||||
if not apos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(
|
||||
int(apos.get("x", 0)), int(apos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
# Try it as an account id and look up that player's ArchSpirit position.
|
||||
var pd: Dictionary = _player_by_id(inst_id)
|
||||
var arch: Dictionary = pd.get("archSpirit", {})
|
||||
var apos: Dictionary = arch.get("position", {})
|
||||
if not apos.is_empty() and pathfinder != null:
|
||||
return pathfinder.coord_to_world(
|
||||
int(apos.get("x", 0)), int(apos.get("y", 0))) + Vector3(0, 0.8, 0)
|
||||
|
||||
# 4. Fallback to source.
|
||||
return fallback
|
||||
|
||||
|
||||
func _resolve_player_color(actor_id: String) -> Color:
|
||||
var state: Dictionary = Game.state
|
||||
var team_colors: Dictionary = state.get("teamColors", {})
|
||||
# Find the actor's seat to get their team index.
|
||||
var seat_order: Array = []
|
||||
var so_raw: Variant = state.get("seatOrder", [])
|
||||
if so_raw is Array:
|
||||
seat_order = so_raw as Array
|
||||
for i: int in seat_order.size():
|
||||
if str(seat_order[i]) == actor_id:
|
||||
# teamColors keys are ints (team index); seat index maps 1:1 in non-team modes.
|
||||
var hex: String = str(team_colors.get(i, team_colors.get(str(i), "")))
|
||||
if hex.length() >= 6:
|
||||
return Color.html("#" + hex if not hex.begins_with("#") else hex)
|
||||
# Fallback.
|
||||
# Use the teamIndex on the player DTO — it is always set correctly for FFA,
|
||||
# Teams, and MultiTeam modes and directly keys into teamColors.
|
||||
var player: Dictionary = _player_by_id(actor_id)
|
||||
var team_idx: int = int(player.get("teamIndex", -1))
|
||||
var team_colors: Dictionary = Game.state.get("teamColors", {})
|
||||
var hex: String = str(team_colors.get(team_idx, team_colors.get(str(team_idx), "")))
|
||||
if hex.length() >= 6:
|
||||
return Color.html("#" + hex if not hex.begins_with("#") else hex)
|
||||
return Color(0.9, 0.7, 0.3)
|
||||
|
||||
|
||||
func _player_by_id(account_id: String) -> Dictionary:
|
||||
for p: Variant in Game.state.get("players", []):
|
||||
if p is Dictionary and str((p as Dictionary).get("accountId", "")).to_lower() == account_id.to_lower():
|
||||
return p as Dictionary
|
||||
return {}
|
||||
|
||||
|
||||
# ── Projectile spawning ───────────────────────────────────────────────────────
|
||||
|
||||
func _spawn_projectile(
|
||||
|
||||
Reference in New Issue
Block a user