From 8079c70ebd640c48b4d491c65947565ea3742830 Mon Sep 17 00:00:00 2001 From: Kiri Date: Wed, 22 Mar 2023 23:36:04 -0700 Subject: [PATCH] Added help text and did some other TODO stuff. --- TODO.md | 7 +++++-- zscript.zs | 55 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/TODO.md b/TODO.md index df6a32e..5aaa709 100644 --- a/TODO.md +++ b/TODO.md @@ -10,6 +10,9 @@ x Sparks x Debris when destroyed x Show remaining batteries as ammo x Switching to mag manager goes to batteries screen +x Empty batteries disappear +x Add (or make sure) loadout code in loadout editor +x Help screen - Pickup sprites for every angle - Spool of wire, a tool, and some electical tape @@ -17,7 +20,7 @@ x Switching to mag manager goes to batteries screen - 1st-person sprites - Wire cutters and electrical tape -- Help screen -- Add (or make sure) loadout code in loadout editor + + diff --git a/zscript.zs b/zscript.zs index d5973aa..bbef16d 100644 --- a/zscript.zs +++ b/zscript.zs @@ -140,6 +140,7 @@ class JumperCablesDeployed : HDUPK charges -= 1; Console.printf("battery used, now: %d", charges); if(charges <= 0) { + charges = 0; DespawnToBattery(); } @@ -186,6 +187,8 @@ class JumperCablesDeployed : HDUPK void SpawnSpark() { + float sparkSpeed = 5.0; + float sparkOffset = 2.0; A_StartSound("misc/arccrackle", CHAN_AUTO); A_SpawnParticle( "white", @@ -194,13 +197,13 @@ class JumperCablesDeployed : HDUPK frandom(1, 7), // size 0, // angle // offset... - frandom(-1.0, 1.0), - frandom(-1.0, 1.0), - frandom(-1.0, 1.0), + frandom(-sparkOffset, sparkOffset), + frandom(-sparkOffset, sparkOffset), + frandom(-sparkOffset, sparkOffset), // vel... - frandom(-1.0, 1.0), - frandom(-1.0, 1.0), - frandom(-1.0, 1.0)); + frandom(-sparkSpeed, sparkSpeed), + frandom(-sparkSpeed, sparkSpeed), + frandom(-sparkSpeed, sparkSpeed)); } override void Tick() @@ -208,7 +211,6 @@ class JumperCablesDeployed : HDUPK if(frandom(0.0, 1.0) < 0.02) { SpawnSpark(); } - } // TODO: Tick function (or whatever) where we set the sprite to indicate the charge level. @@ -484,23 +486,32 @@ class JumperCablesUsable : HDWeapon int batteryCharges = batteryAmmo.TakeMag(true); Console.printf("batteryCharges: %d", batteryCharges); - JumperCablesDeployed deployed = JumperCablesDeployed( - Spawn( - "JumperCablesDeployed", - linetraceData.hitLocation - linetraceData.hitDir * 4)); + if(batteryCharges < 1) { - deployed.lineDefIndex = brokenLine.index(); - deployed.bNoGravity = true; - deployed.charges = batteryCharges; + // Handle getting an empty battery. Just give it back. + invoker.owner.A_Log("No charged batteries available to use."); + batteryAmmo.AddAMag(batteryCharges); - if(linetraceData.hitType == TRACE_HitFloor || linetraceData.hitType == TRACE_HitCeiling) { - deployed.SetFlatSprite(invoker.owner.angle); } else { - Vector2 lineDir = linetraceData.hitLine.v2.p - linetraceData.hitLine.v1.p; - deployed.SetWallSprite(lineDir); - } - brokenLine.special = originalSpecial; + JumperCablesDeployed deployed = JumperCablesDeployed( + Spawn( + "JumperCablesDeployed", + linetraceData.hitLocation - linetraceData.hitDir * 4)); + + deployed.lineDefIndex = brokenLine.index(); + deployed.bNoGravity = true; + deployed.charges = batteryCharges; + + if(linetraceData.hitType == TRACE_HitFloor || linetraceData.hitType == TRACE_HitCeiling) { + deployed.SetFlatSprite(invoker.owner.angle); + } else { + Vector2 lineDir = linetraceData.hitLine.v2.p - linetraceData.hitLine.v1.p; + deployed.SetWallSprite(lineDir); + } + + brokenLine.special = originalSpecial; + } } } } @@ -521,5 +532,9 @@ class JumperCablesUsable : HDWeapon } } + override String GetHelpText() + { + return WEPHELP_FIRE.." Deploy\n"; + } }