From 27818e92c7852487f12863e563862019f4eedeb8 Mon Sep 17 00:00:00 2001 From: maple Date: Mon, 8 Jun 2026 00:01:46 +0900 Subject: [PATCH] Fix turn combat facing and player movement --- Global/DefaultPlayer.model | 28 ++++++------- RootDesk/MyDesk/SlayDeckController.codeblock | 19 ++++++++- map/map01.map | 6 +-- map/map02.map | 4 +- map/map03.map | 4 +- map/map04.map | 4 +- map/map05.map | 4 +- map/map06.map | 4 +- map/map07.map | 4 +- map/map08.map | 4 +- map/map09.map | 4 +- map/map10.map | 4 +- map/map11.map | 4 +- tools/freeze-turn-monsters.mjs | 2 +- tools/freeze-turn-player.mjs | 20 ++++++++++ tools/gen-slaydeck.mjs | 42 +++++++++++++++++++- 16 files changed, 116 insertions(+), 41 deletions(-) create mode 100644 tools/freeze-turn-player.mjs diff --git a/Global/DefaultPlayer.model b/Global/DefaultPlayer.model index f12238e..b41b6e8 100644 --- a/Global/DefaultPlayer.model +++ b/Global/DefaultPlayer.model @@ -30,7 +30,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 0 }, { "TargetType": null, @@ -39,7 +39,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 0 }, { "TargetType": null, @@ -48,7 +48,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 0 }, { "TargetType": null, @@ -57,7 +57,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 1 }, { "TargetType": null, @@ -118,7 +118,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 0.0 + "Value": 0 }, { "TargetType": null, @@ -129,8 +129,8 @@ }, "Value": { "$type": "MOD.Core.MODVector2, MOD.Core", - "x": 0.0, - "y": 0.0 + "x": 0, + "y": 0 } }, { @@ -185,7 +185,7 @@ }, "Value": { "$type": "MOD.Core.MODVector2, MOD.Core", - "x": 0.0, + "x": 0, "y": 0.35 } }, @@ -198,7 +198,7 @@ }, "Value": { "$type": "MOD.Core.MODVector2, MOD.Core", - "x": 0.0, + "x": 0, "y": 0.35 } }, @@ -218,7 +218,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 500.0 + "Value": 500 }, { "TargetType": "script.PlayerHit", @@ -254,7 +254,7 @@ }, "Value": { "$type": "MOD.Core.MODVector2, MOD.Core", - "x": 0.0, + "x": 0, "y": 0.35 } }, @@ -265,7 +265,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 0 }, { "TargetType": "MOD.Core.MovementComponent", @@ -274,7 +274,7 @@ "$type": "MODNativeType", "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }, - "Value": 1.0 + "Value": 0 }, { "TargetType": "MOD.Core.PlayerComponent", @@ -302,4 +302,4 @@ "Children": [] } } -} \ No newline at end of file +} diff --git a/RootDesk/MyDesk/SlayDeckController.codeblock b/RootDesk/MyDesk/SlayDeckController.codeblock index 93e44ed..62a893d 100644 --- a/RootDesk/MyDesk/SlayDeckController.codeblock +++ b/RootDesk/MyDesk/SlayDeckController.codeblock @@ -148,7 +148,7 @@ "Name": null }, "Arguments": [], - "Code": "self:SetEntityEnabled(\"/ui/DefaultGroup/MainMenu\", false)\nself:SetEntityEnabled(\"/ui/DefaultGroup/CardHand\", true)\nself:SetEntityEnabled(\"/ui/DefaultGroup/DeckHud\", true)\nself:ConfigureTurnBasedMonsters()\nself:StartCombat()", + "Code": "self:SetEntityEnabled(\"/ui/DefaultGroup/MainMenu\", false)\nself:SetEntityEnabled(\"/ui/DefaultGroup/CardHand\", true)\nself:SetEntityEnabled(\"/ui/DefaultGroup/DeckHud\", true)\nself:ConfigureTurnBasedMonsters()\nself:ConfigureTurnBasedPlayer()\nself:StartCombat()", "Scope": 2, "ExecSpace": 6, "Attributes": [], @@ -201,12 +201,27 @@ "Name": "monster" } ], - "Code": "if monster == nil then\n\treturn\nend\nif monster.AIWanderComponent ~= nil then\n\tmonster.AIWanderComponent.Enable = false\nend\nif monster.AIChaseComponent ~= nil then\n\tmonster.AIChaseComponent.Enable = false\nend\nif monster.MovementComponent ~= nil then\n\tmonster.MovementComponent.Enable = false\nend\nif monster.RigidbodyComponent ~= nil then\n\tmonster.RigidbodyComponent.MoveVelocity = Vector2.zero\n\tmonster.RigidbodyComponent.RealMoveVelocity = Vector2.zero\nend\nif monster.TransformComponent ~= nil then\n\tlocal scale = monster.TransformComponent.Scale\n\tmonster.TransformComponent.Scale = Vector3(-math.abs(scale.x), math.abs(scale.y), scale.z)\nend\nif monster.StateAnimationComponent ~= nil and monster.SpriteRendererComponent ~= nil then\n\tlocal stand = monster.StateAnimationComponent.ActionSheet[\"stand\"]\n\tif stand ~= nil and stand ~= \"\" then\n\t\tmonster.SpriteRendererComponent.SpriteRUID = stand\n\tend\nend", + "Code": "if monster == nil then\n\treturn\nend\nif monster.AIWanderComponent ~= nil then\n\tmonster.AIWanderComponent.Enable = false\nend\nif monster.AIChaseComponent ~= nil then\n\tmonster.AIChaseComponent.Enable = false\nend\nif monster.MovementComponent ~= nil then\n\tmonster.MovementComponent.Enable = false\nend\nif monster.RigidbodyComponent ~= nil then\n\tmonster.RigidbodyComponent.MoveVelocity = Vector2.zero\n\tmonster.RigidbodyComponent.RealMoveVelocity = Vector2.zero\nend\nif monster.TransformComponent ~= nil then\n\tlocal scale = monster.TransformComponent.Scale\n\tmonster.TransformComponent.Scale = Vector3(math.abs(scale.x), math.abs(scale.y), scale.z)\nend\nif monster.StateAnimationComponent ~= nil and monster.SpriteRendererComponent ~= nil then\n\tlocal stand = monster.StateAnimationComponent.ActionSheet[\"stand\"]\n\tif stand ~= nil and stand ~= \"\" then\n\t\tmonster.SpriteRendererComponent.SpriteRUID = stand\n\tend\nend", "Scope": 2, "ExecSpace": 6, "Attributes": [], "Name": "ConfigureMonsterForTurnCombat" }, + { + "Return": { + "Type": "void", + "DefaultValue": null, + "SyncDirection": 0, + "Attributes": [], + "Name": null + }, + "Arguments": [], + "Code": "local player = nil\npcall(function()\n\tif _UserService ~= nil and _UserService.LocalPlayer ~= nil then\n\t\tplayer = _UserService.LocalPlayer\n\tend\nend)\npcall(function()\n\tif player == nil and _UserService ~= nil and _UserService.LocalPlayerEntity ~= nil then\n\t\tplayer = _UserService.LocalPlayerEntity\n\tend\nend)\npcall(function()\n\tif player == nil and _UserService ~= nil and _UserService.GetLocalPlayer ~= nil then\n\t\tplayer = _UserService:GetLocalPlayer()\n\tend\nend)\nif player ~= nil and player.Entity ~= nil then\n\tplayer = player.Entity\nend\nif player == nil then\n\treturn\nend\nif player.PlayerControllerComponent ~= nil then\n\tplayer.PlayerControllerComponent.Enable = false\n\tpcall(function() player.PlayerControllerComponent.LookDirectionX = 1 end)\nend\nif player.MovementComponent ~= nil then\n\tplayer.MovementComponent.Enable = false\n\tpcall(function() player.MovementComponent.InputSpeed = 0 end)\n\tpcall(function() player.MovementComponent.JumpForce = 0 end)\nend\nif player.RigidbodyComponent ~= nil then\n\tplayer.RigidbodyComponent.MoveVelocity = Vector2.zero\n\tplayer.RigidbodyComponent.RealMoveVelocity = Vector2.zero\nend\nif player.TransformComponent ~= nil then\n\tlocal scale = player.TransformComponent.Scale\n\tplayer.TransformComponent.Scale = Vector3(math.abs(scale.x), math.abs(scale.y), scale.z)\nend", + "Scope": 2, + "ExecSpace": 6, + "Attributes": [], + "Name": "ConfigureTurnBasedPlayer" + }, { "Return": { "Type": "void", diff --git a/map/map01.map b/map/map01.map index ec26d66..e5fa7af 100644 --- a/map/map01.map +++ b/map/map01.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6691,7 +6691,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map02.map b/map/map02.map index 063739d..c7e29d4 100644 --- a/map/map02.map +++ b/map/map02.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map03.map b/map/map03.map index 4c57001..85879b5 100644 --- a/map/map03.map +++ b/map/map03.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map04.map b/map/map04.map index 1242d53..8ac5533 100644 --- a/map/map04.map +++ b/map/map04.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map05.map b/map/map05.map index 7068536..6cc6324 100644 --- a/map/map05.map +++ b/map/map05.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map06.map b/map/map06.map index 1edc0e9..133d7c2 100644 --- a/map/map06.map +++ b/map/map06.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map07.map b/map/map07.map index 0ee83d2..a0eca09 100644 --- a/map/map07.map +++ b/map/map07.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map08.map b/map/map08.map index 311538f..ae92401 100644 --- a/map/map08.map +++ b/map/map08.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map09.map b/map/map09.map index 652c2cd..4cb304f 100644 --- a/map/map09.map +++ b/map/map09.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map10.map b/map/map10.map index 6a8aa5a..3e3f03c 100644 --- a/map/map10.map +++ b/map/map10.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/map/map11.map b/map/map11.map index f66c3b5..c2099d6 100644 --- a/map/map11.map +++ b/map/map11.map @@ -6392,7 +6392,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, @@ -6540,7 +6540,7 @@ "w": 1 }, "Scale": { - "x": -1, + "x": 1, "y": 1, "z": 1 }, diff --git a/tools/freeze-turn-monsters.mjs b/tools/freeze-turn-monsters.mjs index 579dd74..fb2d7a0 100644 --- a/tools/freeze-turn-monsters.mjs +++ b/tools/freeze-turn-monsters.mjs @@ -39,7 +39,7 @@ function patchMonsterEntity(entity) { const transform = component(entity, 'MOD.Core.TransformComponent'); if (transform?.Scale) { - transform.Scale.x = -Math.abs(transform.Scale.x || 1); + transform.Scale.x = Math.abs(transform.Scale.x || 1); transform.Scale.y = Math.abs(transform.Scale.y || 1); } diff --git a/tools/freeze-turn-player.mjs b/tools/freeze-turn-player.mjs new file mode 100644 index 0000000..e3cd08a --- /dev/null +++ b/tools/freeze-turn-player.mjs @@ -0,0 +1,20 @@ +import { readFileSync, writeFileSync } from 'node:fs'; + +const file = 'Global/DefaultPlayer.model'; +const data = JSON.parse(readFileSync(file, 'utf8')); +const values = data.ContentProto.Json.Values || []; + +for (const value of values) { + if (value.TargetType === null && ['speed', 'jumpForce', 'walkAcceleration'].includes(value.Name)) { + value.Value = 0; + } + if (value.TargetType === 'MOD.Core.MovementComponent' && ['InputSpeed', 'JumpForce'].includes(value.Name)) { + value.Value = 0; + } + if (value.TargetType === 'MOD.Core.RigidbodyComponent' && ['MoveVelocity', 'RealMoveVelocity'].includes(value.Name)) { + value.Value = { x: 0, y: 0 }; + } +} + +writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`, 'utf8'); +console.log('Turn-combat player movement disabled.'); diff --git a/tools/gen-slaydeck.mjs b/tools/gen-slaydeck.mjs index 8ee9137..d42de05 100644 --- a/tools/gen-slaydeck.mjs +++ b/tools/gen-slaydeck.mjs @@ -468,6 +468,7 @@ self.NewGameHandler = buttonEntity:ConnectEvent(ButtonClickEvent, self.StartNewG self:SetEntityEnabled("/ui/DefaultGroup/CardHand", true) self:SetEntityEnabled("/ui/DefaultGroup/DeckHud", true) self:ConfigureTurnBasedMonsters() +self:ConfigureTurnBasedPlayer() self:StartCombat()`), method('StartCombat', `self.MaxEnergy = 3 self.Turn = 0 @@ -505,7 +506,7 @@ if monster.RigidbodyComponent ~= nil then end if monster.TransformComponent ~= nil then \tlocal scale = monster.TransformComponent.Scale -\tmonster.TransformComponent.Scale = Vector3(-math.abs(scale.x), math.abs(scale.y), scale.z) +\tmonster.TransformComponent.Scale = Vector3(math.abs(scale.x), math.abs(scale.y), scale.z) end if monster.StateAnimationComponent ~= nil and monster.SpriteRendererComponent ~= nil then \tlocal stand = monster.StateAnimationComponent.ActionSheet["stand"] @@ -513,6 +514,45 @@ if monster.StateAnimationComponent ~= nil and monster.SpriteRendererComponent ~= \t\tmonster.SpriteRendererComponent.SpriteRUID = stand \tend end`, [{ Type: 'Entity', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'monster' }]), + method('ConfigureTurnBasedPlayer', `local player = nil +pcall(function() +\tif _UserService ~= nil and _UserService.LocalPlayer ~= nil then +\t\tplayer = _UserService.LocalPlayer +\tend +end) +pcall(function() +\tif player == nil and _UserService ~= nil and _UserService.LocalPlayerEntity ~= nil then +\t\tplayer = _UserService.LocalPlayerEntity +\tend +end) +pcall(function() +\tif player == nil and _UserService ~= nil and _UserService.GetLocalPlayer ~= nil then +\t\tplayer = _UserService:GetLocalPlayer() +\tend +end) +if player ~= nil and player.Entity ~= nil then +\tplayer = player.Entity +end +if player == nil then +\treturn +end +if player.PlayerControllerComponent ~= nil then +\tplayer.PlayerControllerComponent.Enable = false +\tpcall(function() player.PlayerControllerComponent.LookDirectionX = 1 end) +end +if player.MovementComponent ~= nil then +\tplayer.MovementComponent.Enable = false +\tpcall(function() player.MovementComponent.InputSpeed = 0 end) +\tpcall(function() player.MovementComponent.JumpForce = 0 end) +end +if player.RigidbodyComponent ~= nil then +\tplayer.RigidbodyComponent.MoveVelocity = Vector2.zero +\tplayer.RigidbodyComponent.RealMoveVelocity = Vector2.zero +end +if player.TransformComponent ~= nil then +\tlocal scale = player.TransformComponent.Scale +\tplayer.TransformComponent.Scale = Vector3(math.abs(scale.x), math.abs(scale.y), scale.z) +end`), method('Shuffle', `if list == nil then \treturn end