Initial spraycan implementation.

spraycans
Kiri 2023-09-09 09:02:54 -07:00
parent b98e8cd96f
commit 4d5e7f1d0e
12 changed files with 171 additions and 0 deletions

12
decaldef.txt 100644
View File

@ -0,0 +1,12 @@
fader KiriInstantFade
{
DecayStart 60.0
DecayTime 0.0
}
decal KiriTestDecal
{
pic KSPYA0
animator KiriInstantFade
randomflipx
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -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 { }
}

View File

@ -4,3 +4,4 @@ version "4.10"
#include "zscript/jumpercables.zs"
#include "zscript/gretchencounter.zs"
#include "zscript/cacoplushie.zs"
#include "zscript/spraycan.zs"

142
zscript/spraycan.zs 100644
View File

@ -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;
}
}
}