From 13a99783b3454b6d700ee0ddfaebf0142c77cac8 Mon Sep 17 00:00:00 2001 From: Kiri Date: Sat, 9 Sep 2023 13:00:20 -0700 Subject: [PATCH] Cleanup and stuff. --- TODO.md | 1 + zscript/snektech.zs | 3 ++- zscript/spraycan.zs | 64 +++++++++++++++++++++++++++++---------------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/TODO.md b/TODO.md index ee8177e..3b56b7a 100644 --- a/TODO.md +++ b/TODO.md @@ -15,3 +15,4 @@ - ~~Frag counter in loadout starts with no battery~~ - ~~Organize source_data~~ +- Loadout code descriptions (hdweapon.loadoutcodes) diff --git a/zscript/snektech.zs b/zscript/snektech.zs index 8f67551..90213b5 100644 --- a/zscript/snektech.zs +++ b/zscript/snektech.zs @@ -9,7 +9,8 @@ enum SnekTechSpawnFlags { SNEKTECH_GRETCHENCOUNTER = 0, SNEKTECH_JUMPERCABLES = 1, - SNEKTECH_CACOPLUSHIE = 2 + SNEKTECH_CACOPLUSHIE = 2, + SNEKTECH_SPRAYCAN = 3 } class SnekTechEventHandler : EventHandler diff --git a/zscript/spraycan.zs b/zscript/spraycan.zs index 6e0e1ed..4ad5100 100644 --- a/zscript/spraycan.zs +++ b/zscript/spraycan.zs @@ -1,17 +1,19 @@ // FIXME: Make consts and enums consistent formatting. -const KIRI_SPRAYDISTANCE = 96; +const KIRI_SPRAY_DISTANCE = 96; const KIRI_SPRAY_SHAKEANIM_MAXANGLE = 20.0; const KIRI_SPRAY_MAXPAINT = 50; const KIRI_SPRAY_MAXPRESSURE = 100; const KIRI_SPRAY_PRESSUREBUILDSCALE = 20; const KIRI_SPRAY_PRESSURE_PER_USE = (KIRI_SPRAY_MAXPRESSURE / 2); +const HDLD_KIRI_SPRAYCAN = "ksp"; + enum KiriSprayerStatus { - KIRISPRAYER_PAINT = 1, - KIRISPRAYER_PRESSURE = 2 + KIRI_SPRAY_WS_PAINT = 1, + KIRI_SPRAY_WS_PRESSURE = 2 } class Sprayer : HDWeapon @@ -28,6 +30,14 @@ class Sprayer : HDWeapon +INVENTORY.PERSISTENTPOWER; +INVENTORY.INVBAR; + + // inventory.icon "KSPRB0"; + inventory.pickupsound "kiri/spraycan_rattle"; + inventory.pickupmessage "Picked up some spraypaint cans."; + // inventory.amount 1; + // inventory.maxamount 100; + + hdweapon.refid HDLD_KIRI_SPRAYCAN; } states @@ -57,20 +67,20 @@ class Sprayer : HDWeapon // Taper off pressure increase amount based on how much // pressure is in there already. float pressureIncreaseScale = 1.0 - ( - float(invoker.weaponstatus[KIRISPRAYER_PRESSURE]) / + float(invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE]) / float(KIRI_SPRAY_MAXPRESSURE)); pressureIncreaseScale *= pressureIncreaseScale; // Add pressure. - invoker.weaponstatus[KIRISPRAYER_PRESSURE] += + invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE] += random(0, KIRI_SPRAY_PRESSUREBUILDSCALE - * invoker.weaponstatus[KIRISPRAYER_PAINT] + * invoker.weaponstatus[KIRI_SPRAY_WS_PAINT] / KIRI_SPRAY_MAXPAINT); // Cap pressure amount. - if(invoker.weaponstatus[KIRISPRAYER_PRESSURE] > KIRI_SPRAY_MAXPRESSURE) { - invoker.weaponstatus[KIRISPRAYER_PRESSURE] = KIRI_SPRAY_MAXPRESSURE; + if(invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE] > KIRI_SPRAY_MAXPRESSURE) { + invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE] = KIRI_SPRAY_MAXPRESSURE; } } @@ -82,7 +92,7 @@ class Sprayer : HDWeapon fire: KSPR A 2 { - if(invoker.weaponstatus[KIRISPRAYER_PRESSURE] < KIRI_SPRAY_PRESSURE_PER_USE) { + if(invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE] < KIRI_SPRAY_PRESSURE_PER_USE) { invoker.owner.A_Log("Not enough pressure to spray."); @@ -117,7 +127,7 @@ class Sprayer : HDWeapon // Find a wall to spray on. bool traceHit = LineTrace( angle, - KIRI_SPRAYDISTANCE, + KIRI_SPRAY_DISTANCE, pitch, flags : TRF_THRUACTORS, offsetz : zOffset, @@ -141,8 +151,8 @@ class Sprayer : HDWeapon spawner.actualDecalName = actualDecalName; spawner.master = invoker.owner; - invoker.weaponstatus[KIRISPRAYER_PRESSURE] -= KIRI_SPRAY_PRESSURE_PER_USE; - invoker.weaponstatus[KIRISPRAYER_PAINT] -= 1; + invoker.weaponstatus[KIRI_SPRAY_WS_PRESSURE] -= KIRI_SPRAY_PRESSURE_PER_USE; + invoker.weaponstatus[KIRI_SPRAY_WS_PAINT] -= 1; } } else { @@ -175,15 +185,25 @@ class Sprayer : HDWeapon } + override bool AddSpareWeapon(actor newowner) + { + return AddSpareWeaponRegular(newowner); + } + + override HDWeapon GetSpareWeapon(actor newowner, bool reverse, bool doselect) + { + return GetSpareWeaponRegular(newowner, reverse, doselect); + } + override void InitializeWepStats(bool idfa) { super.InitializeWepStats(idfa); - weaponstatus[KIRISPRAYER_PRESSURE] = 0; + weaponstatus[KIRI_SPRAY_WS_PRESSURE] = 0; // Add a little bit of randomness to the amount of paint in // the can. - weaponstatus[KIRISPRAYER_PAINT] = + weaponstatus[KIRI_SPRAY_WS_PAINT] = KIRI_SPRAY_MAXPAINT - random(0, KIRI_SPRAY_MAXPAINT / 10); } @@ -194,9 +214,9 @@ class Sprayer : HDWeapon // Gradually decay pressure. if(random(0, 256) < 4) { - weaponstatus[KIRISPRAYER_PRESSURE] -= 1; - if(weaponstatus[KIRISPRAYER_PRESSURE] < 0) { - weaponstatus[KIRISPRAYER_PRESSURE] = 0; + weaponstatus[KIRI_SPRAY_WS_PRESSURE] -= 1; + if(weaponstatus[KIRI_SPRAY_WS_PRESSURE] < 0) { + weaponstatus[KIRI_SPRAY_WS_PRESSURE] = 0; } } } @@ -207,12 +227,12 @@ class Sprayer : HDWeapon { // Current pressure (top bar). statusBar.DrawWepNum( - weaponstatus[KIRISPRAYER_PRESSURE], + weaponstatus[KIRI_SPRAY_WS_PRESSURE], KIRI_SPRAY_MAXPRESSURE, posy:-10); // Total paint remaining (bottom bar). statusBar.DrawWepNum( - weaponstatus[KIRISPRAYER_PAINT], + weaponstatus[KIRI_SPRAY_WS_PAINT], KIRI_SPRAY_MAXPAINT); } @@ -247,7 +267,7 @@ class Sprayer : HDWeapon // Set the new CVar. CVar.GetCVar("snektech_spraypattern", owner.player).SetString(patternList[newIndex]); currentPattern = CVar.GetCVar("snektech_spraypattern", owner.player).GetString(); - invoker.owner.A_Log("Selected spray pattern: "..currentPattern); + owner.A_Log("Selected spray pattern: "..currentPattern); // Current pattern is referenced in the help text, so reset // it. @@ -297,7 +317,7 @@ class SprayerDecalSpawner : Actor override void PostBeginPlay() { Super.PostBeginPlay(); - A_SprayDecal(actualDecalName, KIRI_SPRAYDISTANCE); + A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE); // Figure out a new ID number. ThinkerIterator iter = ThinkerIterator.Create("SprayerDecalSpawner"); @@ -342,7 +362,7 @@ class SprayerDecalSpawner : Actor timeSinceLastSpray++; if(timeSinceLastSpray >= 35 * 60) { - A_SprayDecal(actualDecalName, KIRI_SPRAYDISTANCE); + A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE); timeSinceLastSpray = 0; } }