Files
grass-cutters/Assets/Scripts/Core/DemoBot.Fix.cs
NiemandKG 36e4bb2a10 Round 6 fixes: held tools, headlamp glare, ladder openings, level horizon, roof hulls, rain hits, idle motion, belt packs, meadow variety
- Held tools sit lower and further right; the hammer faces forward and strikes about the camera's right
- Headlamp leaves held items, treats and vending machines alone (rendering layer NoLamp); other lights keep lighting them
- Hay grounded on the floor in world space (it floated)
- Deck fence opens at each ladder, rail colliders split around it; ladders moved to 2 m off the edge middle, clear of the intakes; climbing goes over a rail only if one is in the way
- Crew stand to the soil's up (Planet.Level): flat round the base, the ball's up past it, so the horizon stays level on a small planet
- Convex roof hulls for the crew cabin, garage, pitched roof and windmill tower; cabin box lowered to the eaves
- Rain and acid rain hits differ by surface: soil, grass, wood, metal
- Idle motion: dishes pan, sways sway, sensors turn, eyes blink, windmill turns in the breeze, reels and parked rotors tick over
- Belt: take tools off at the supply wall; hold E at a vending machine for a pack of 3 on the belt, LMB has one
- New meadow pieces: boulders, slab stones, crystals, mushrooms, stump, bulb plants
- -demofix checks for all of the above; loc rows in all 11 tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 22:52:05 +06:00

156 lines
7.8 KiB
C#

using System.Collections;
using UnityEngine;
namespace GrassCutter
{
public partial class DemoBot
{
/// <summary>
/// -demofix: close looks at the base furniture people asked about: a deck ladder where it meets the railing, the hay
/// bale on the deck, the foot of the loading ramp and the back of the upgrade console.
/// </summary>
/// <summary>The second round: intakes beside the ladders, a body dropped on the roofs, the new meadow pieces, a pack on
/// the belt, acid rain on the deck and the meadow, and the headlamp at night on a tool in hand and on a vending machine.</summary>
IEnumerator FixMore()
{
// the north side from the meadow: ladders in their openings, intakes clear of them
Me.Teleport(new Vector3(-4f, 1.4f - 1.6f, 16f));
yield return new WaitForSeconds(0.6f);
Me.LookAt(new Vector3(-4f, 0.4f, 9.5f));
yield return new WaitForSeconds(0.6f);
yield return Shot("fix_intakes_n");
Me.Teleport(new Vector3(12f, 1.4f - 1.6f, -14f));
yield return new WaitForSeconds(0.6f);
Me.LookAt(new Vector3(4f, 0.4f, -9.5f));
yield return new WaitForSeconds(0.6f);
yield return Shot("fix_intakes_s");
// dropped from above the crew cabin's ridge: where does the body come to rest?
Me.SetFlying(false);
foreach (var probe in new[] { new Vector3(-6f, 9f, 7f), new Vector3(-6.8f, 9f, 6.2f) })
{
Me.Teleport(probe);
yield return new WaitForSeconds(3f);
Log($"roof probe from {probe}: rests at y {Me.transform.position.y:0.00}, grounded {Me.Grounded}");
foreach (var h in Physics.RaycastAll(probe + Vector3.up * 5f, Vector3.down, 20f, ~0, QueryTriggerInteraction.Ignore))
Log($" ray hits {h.collider.name} ({h.collider.GetType().Name}, layer {h.collider.gameObject.layer}, enabled {h.collider.enabled}) at y {h.point.y:0.00}");
}
Me.SetFlying(true);
// the new meadow pieces, the nearest of each
var ground = FindAnyObjectByType<Ground>();
if (ground)
{
foreach (var kind in new[] { "SM_Boulders", "SM_SlabStones", "SM_Crystals", "SM_Shrooms", "SM_Stump", "SM_BulbPlants" })
{
Transform best = null;
float bd = float.MaxValue;
foreach (var t in ground.GetComponentsInChildren<Transform>(true))
{
if (!t.name.StartsWith(kind) || t.parent == null || t.parent.name.StartsWith("SM_")) continue;
float d = (t.position - Me.transform.position).sqrMagnitude;
if (d < bd) { bd = d; best = t; }
}
if (!best) { Log($"no {kind} on the ball"); continue; }
var up = Planet.Up(best.position);
var side = Vector3.Cross(up, Vector3.forward).normalized;
Me.Teleport(best.position + side * 7f + up * 1.2f);
yield return new WaitForSeconds(1.2f);
Me.LookAt(best.position + up * 1f);
yield return new WaitForSeconds(0.8f);
yield return Shot("fix_decor_" + kind.Substring(3).ToLowerInvariant());
}
}
// a pack on the belt, in hand, and one had from it
Me.BeltSlots.Value = 4;
Cheats.Run("tool all");
yield return new WaitForSeconds(0.5f);
Me.Tools.Unequip(ToolId.Hammer);
Me.Tools.Unequip(ToolId.LongScythe);
Me.Tools.AddPack(TreatId.Beer, Treats.PackSize);
Me.Teleport(new Vector3(2f, 0.05f, 2f));
yield return new WaitForSeconds(0.5f);
Me.LookAt(new Vector3(2f, 1.2f, 12f));
Me.Tools.Select(ToolId.BeerPack);
yield return new WaitForSeconds(0.6f);
yield return Shot("fix_pack_belt");
Ctl.BotUsePressed = true;
yield return null;
Ctl.BotUsePressed = false;
yield return new WaitForSeconds(1.4f);
yield return Shot("fix_pack_drink");
Log($"pack: {Me.Tools.PackLeft(TreatId.Beer)} left, belt {string.Join(", ", Me.Tools.Belt)}");
yield return new WaitForSeconds(3f);
// acid rain on the deck rail, a machine and the meadow
Cheats.Run("weather acidrain 5");
yield return new WaitForSeconds(9f);
Me.Teleport(new Vector3(-2f, 0.05f, 6f));
yield return new WaitForSeconds(0.5f);
Me.LookAt(new Vector3(-2f, -0.4f, 11f));
yield return new WaitForSeconds(1.5f);
yield return Shot("fix_acid_edge");
Me.LookAt(new Vector3(0f, 0f, 3f));
yield return new WaitForSeconds(1.5f);
yield return Shot("fix_acid_deck");
Cheats.Run("weather clear");
// night: the headlamp on the tool in hand, and on a vending machine's own lights
float pinned = Sun.Pinned;
Sun.Pinned = Mathf.Repeat(pinned + 0.5f, 1f);
yield return new WaitForSeconds(4f);
Me.Tools.Select(ToolId.Scythe);
Me.LookAt(Me.transform.position + Me.transform.forward * 5f - Me.transform.up * 1.5f);
yield return new WaitForSeconds(1f);
yield return Shot("fix_night_tool");
var vm = VendingMachine.All.Count > 0 ? VendingMachine.All[0] : null;
if (vm)
{
Me.Teleport(vm.transform.position + vm.transform.forward * 1.6f + Vector3.up * 0.05f);
yield return new WaitForSeconds(0.6f);
Me.LookAt(vm.transform.position + Vector3.up * 1.1f);
yield return new WaitForSeconds(1f);
yield return Shot("fix_night_vending");
}
Sun.Pinned = pinned;
}
IEnumerator FixLook()
{
BotCapture.From = null;
yield return new WaitForSeconds(2f);
TeamState.DeleteSave();
NetSession.Instance.HostLocal();
while (!Me || !Ts) yield return null;
yield return new WaitForSeconds(4f);
Me.SetFlying(true);
var spots = new (string name, Vector3 eye, Vector3 at)[]
{
("fix_ladder_a", new Vector3(-2f, 1.2f, 0f), new Vector3(-2f, 0.2f, 9f)),
("fix_ladder_b", new Vector3(-1f, 0.6f, 12f), new Vector3(-2f, 0.3f, 9f)),
("fix_ladder_c", new Vector3(-4f, 1.8f, 11.5f), new Vector3(-2f, 0f, 9f)),
("fix_ladder_d", new Vector3(-2f, -0.6f, 10.5f), new Vector3(-2f, 0.9f, 9f)),
("fix_hay", new Vector3(5.5f, 1.4f, -5.2f), new Vector3(7.8f, 0.2f, -7.6f)),
("fix_hay_side", new Vector3(10.5f, 0.3f, -7.6f), new Vector3(7.8f, 0.1f, -7.6f)),
("fix_yard", new Vector3(0f, 2.2f, -9f), new Vector3(0f, -1.2f, -20f)),
("fix_yard_low", new Vector3(-6f, 0f, -14f), new Vector3(0f, -1.2f, -20f)),
("fix_console_back", new Vector3(8.0f, 1.6f, -1.5f), new Vector3(6.2f, 1.4f, -1.5f)),
("fix_console_back2", new Vector3(7.8f, 1.9f, -0.2f), new Vector3(6.2f, 1.5f, -1.5f)),
("fix_console_front", new Vector3(4.4f, 1.6f, -1.5f), new Vector3(6.2f, 1.3f, -1.5f)),
};
foreach (var s in spots)
{
Me.Teleport(s.eye - Vector3.up * 1.6f);
yield return new WaitForSeconds(0.6f);
Me.LookAt(s.at);
yield return new WaitForSeconds(0.6f);
yield return Shot(s.name);
}
yield return FixMore();
Log("demofix done");
Application.Quit();
}
}
}