diff --git a/decaldef.txt b/decaldef.txt new file mode 100644 index 0000000..e76514a --- /dev/null +++ b/decaldef.txt @@ -0,0 +1,12 @@ +fader KiriInstantFade +{ + DecayStart 60.0 + DecayTime 0.0 +} + +decal KiriTestDecal +{ + pic KSPYA0 + animator KiriInstantFade + randomflipx +} diff --git a/source_data/spray_transpride.aseprite b/source_data/spray_transpride.aseprite new file mode 100644 index 0000000..325bdb5 Binary files /dev/null and b/source_data/spray_transpride.aseprite differ diff --git a/source_data/spraycan_base.kra b/source_data/spraycan_base.kra new file mode 100644 index 0000000..1dc1e64 Binary files /dev/null and b/source_data/spraycan_base.kra differ diff --git a/source_data/spraycan_base.png b/source_data/spraycan_base.png new file mode 100644 index 0000000..511e4a2 Binary files /dev/null and b/source_data/spraycan_base.png differ diff --git a/source_data/spraycan_metallic.png b/source_data/spraycan_metallic.png new file mode 100644 index 0000000..238d7e9 Binary files /dev/null and b/source_data/spraycan_metallic.png differ diff --git a/source_data/spraycan_model.blend b/source_data/spraycan_model.blend new file mode 100644 index 0000000..78863a1 Binary files /dev/null and b/source_data/spraycan_model.blend differ diff --git a/source_data/spraycan_render.png b/source_data/spraycan_render.png new file mode 100644 index 0000000..a3bff41 Binary files /dev/null and b/source_data/spraycan_render.png differ diff --git a/source_data/spraycan_render_pickup.png b/source_data/spraycan_render_pickup.png new file mode 100644 index 0000000..09a4482 Binary files /dev/null and b/source_data/spraycan_render_pickup.png differ diff --git a/source_data/spraycan_roughness.png b/source_data/spraycan_roughness.png new file mode 100644 index 0000000..78b5e78 Binary files /dev/null and b/source_data/spraycan_roughness.png differ diff --git a/textures.txt b/textures.txt index be618ac..95eda57 100644 --- a/textures.txt +++ b/textures.txt @@ -106,3 +106,19 @@ Sprite "KCPLG0", 130, 108 Patch "sprites/cacoplush/cacoplushie_glowing3.png", 0, 0 } +// ---------------------------------------------------------------------- +// Spray can + +Sprite "KSPYA0", 250, 150 +{ + XScale 2 + YScale 2 + Offset 125, 75 + Patch KSPYA0,0,0 { } +} + +Sprite "KSPRB0", 48, 48 +{ + Offset 24, 24 + Patch KSPRB0,0,0 { } +} diff --git a/zscript.zs b/zscript.zs index b1df6b6..55296e1 100644 --- a/zscript.zs +++ b/zscript.zs @@ -4,3 +4,4 @@ version "4.10" #include "zscript/jumpercables.zs" #include "zscript/gretchencounter.zs" #include "zscript/cacoplushie.zs" +#include "zscript/spraycan.zs" diff --git a/zscript/spraycan.zs b/zscript/spraycan.zs new file mode 100644 index 0000000..b8f0c2c --- /dev/null +++ b/zscript/spraycan.zs @@ -0,0 +1,142 @@ + +const KIRI_SPRAYDISTANCE = 96; + +class Sprayer : HDWeapon +{ + default + { + radius 2; + height 4; + +SpriteAngle; + Scale 0.4; + + +hdweapon.fitsinbackpack; + +weapon.wimpy_weapon; + + +INVENTORY.PERSISTENTPOWER; + +INVENTORY.INVBAR; + } + + states + { + spawn: + KSPR B -1; + stop; + + ready: + KSPR A 1 { A_WeaponReady(WRF_ALL); A_WeaponBusy(false); } + goto readyend; + + fire: + KSPR A 2 { + + Actor spawnedThing; + bool success; + float zOffset = GunHeight() * 0.8; + FLineTraceData lineTraceData; + + bool traceHit = LineTrace( + angle, + KIRI_SPRAYDISTANCE, + pitch, + flags : TRF_THRUACTORS, + offsetz : zOffset, + data : lineTraceData); + + if(traceHit) { + + if(lineTraceData.HitLine) { + + console.printf("spray spray spray"); + [success, spawnedThing] = A_SpawnItemEx( + "SprayerDecalSpawner", + xofs : 0, yofs : 0, zofs : zOffset); + + if(success) { + spawnedThing.A_SetPitch(pitch); + spawnedThing.A_SetAngle(angle); + spawnedThing.master = invoker.owner; + } + } + } + } + goto waiting; + + waiting: + KSPR A 5; + KSPR A 0 A_Refire("waiting"); + goto ready; + + } +} + +class SprayerDecalSpawner : Actor +{ + default + { + +nogravity; + } + + states + { + spawn: + TNT1 A 0; + stop; + } + + int timeSinceLastSpray; + int thisSprayerId; + + override void PostBeginPlay() + { + Super.PostBeginPlay(); + console.printf("SPRAY"); + A_SprayDecal("KiriTestDecal", KIRI_SPRAYDISTANCE); + + // Figure out a new ID number. + ThinkerIterator iter = ThinkerIterator.Create("SprayerDecalSpawner"); + SprayerDecalSpawner otherSpawner; + int maxId = 0; + while(otherSpawner = SprayerDecalSpawner(iter.Next())) { + + if(otherSpawner == self) { + continue; + } + + // Keep track of the highest ID. + if(otherSpawner.thisSprayerId > maxId) { + if(otherSpawner.master == master) { + maxId = otherSpawner.thisSprayerId; + } + } + } + thisSprayerId = maxId + 1; + + // Clear old sprayers. + iter = ThinkerIterator.Create("SprayerDecalSpawner"); + while(otherSpawner = SprayerDecalSpawner(iter.Next())) { + + if(otherSpawner == self) { + continue; + } + + if(otherSpawner.thisSprayerId < (thisSprayerId - 5)) { + if(otherSpawner.master == master) { + otherSpawner.Destroy(); + } + } + } + + } + + override void Tick() + { + timeSinceLastSpray++; + + if(timeSinceLastSpray >= 35 * 60) { + A_SprayDecal("KiriTestDecal", KIRI_SPRAYDISTANCE); + timeSinceLastSpray = 0; + } + } +} +