Compare commits

..

6 Commits

Author SHA1 Message Date
c453013abf Added reverse cycling for the spray pattern selection. Also shows list index now. 2023-09-12 20:44:37 -07:00
364fb7e7ab Added KiriInstantFade back in, as essentaially a no-op, because a bunch of user-made sprays already refer to it. Removed KiriInstantFade from the example sprays. 2023-09-12 20:16:04 -07:00
emmie
56a46d0790 spraycan: use permanent decals
instead of using auto decals, letting them time out and just Not
replacing them when they're meant to be gone, this spawns a permanent
decal (not affected by decal limit) and explicitly deletes it when
necessary.
as a consequence of this, spraying more than 11 decals Immediately
removes the oldest spray.

Addresses issue #1
2023-09-11 20:47:55 -07:00
emmie
f4bf7a793e spraycan: fix cvar not being updated properly
GetCVar returns a per-player copy of the requested cvar, which is only
used to have separate values for each player - changes are propagated To
it, but not From it.
writing to this cvar is only useful if you know what the actual new
value is going to be & want the cvar to update Immediately.
(in this case, the cvar needs to be updated before A_SetHelpText so the
 displayed spray name is correct)

FindCVar returns the actual cvar for the local player. changes to this
cvar Are propagated to other clients.
2023-09-11 20:47:55 -07:00
emmie
333c40e46a silence implicit float->int conversion warnings 2023-09-11 20:47:55 -07:00
emmie
829c9c1242 fix dropped item sprites clipping into ground
fixes sprites being offset into the floor with automatic sprite clipping
adjustment disabled
2023-09-11 20:47:55 -07:00
5 changed files with 105 additions and 56 deletions

View File

@ -1,20 +1,25 @@
fader KiriInstantFade
stretcher KiriInstantFade
{
DecayStart 60.0
DecayTime 0.0
// You don't need this anymore! It's just here because a bunch of
// sprays were already made that use it!
// These numbers are designed to do nothing, and wait a long time
// before doing it. It's a no-op.
GoalX 1.0
GoalY 1.0
StretchStart 9999999.0
StretchTime 9999999.0
}
decal KiriTestDecal
{
pic KSPYA0
animator KiriInstantFade
randomflipx
}
decal SnekSpray_TransPride
{
pic KSPYA0
animator KiriInstantFade
randomflipx
translucent 0.8
}
@ -22,7 +27,6 @@ decal SnekSpray_TransPride
decal SnekSpray_LesbianPride
{
pic KSPYB0
animator KiriInstantFade
randomflipx
translucent 0.8
}
@ -30,7 +34,6 @@ decal SnekSpray_LesbianPride
decal SnekSpray_NBPride
{
pic KSPYC0
animator KiriInstantFade
randomflipx
translucent 0.8
}
@ -38,7 +41,6 @@ decal SnekSpray_NBPride
decal SnekSpray_AcePride
{
pic KSPYD0
animator KiriInstantFade
randomflipx
translucent 0.8
}
@ -46,34 +48,29 @@ decal SnekSpray_AcePride
decal SnekSpray_ProgressPride
{
pic KSPYE0
animator KiriInstantFade
translucent 0.8
}
decal SnekSpray_DemiPride
{
pic KSPYF0
animator KiriInstantFade
translucent 0.8
}
decal SnekSpray_PanPride
{
pic KSPYG0
animator KiriInstantFade
translucent 0.8
}
decal SnekSpray_SwitchPride
{
pic KSPYH0
animator KiriInstantFade
}
decal SnekSpray_BiPride
{
pic KSPYI0
animator KiriInstantFade
translucent 0.8
randomflipx
}
@ -81,7 +78,6 @@ decal SnekSpray_BiPride
decal SnekSpray_GayPride
{
pic KSPYJ0
animator KiriInstantFade
translucent 0.8
randomflipx
}

View File

@ -1,7 +1,6 @@
decal SnekSpray_Example
{
pic KSPEA0
animator KiriInstantFade
translucent 0.8
randomflipx
}

View File

@ -35,7 +35,7 @@ sprite JMPRD0, 49, 43 {
}
sprite JMPKA0, 48, 32 {
offset 24, 16
offset 24, 32
patch JMPKA0,0,0 { }
}
@ -77,7 +77,7 @@ Sprite "KCPLD0", 130, 108
{
XScale 4
YScale 4
Offset 64, 52
Offset 64, 100
Patch "sprites/cacoplush/cacoplushie_pickup.png", 0, 0
}
@ -111,7 +111,7 @@ Sprite "KCPLG0", 130, 108
Sprite "KSPRB0", 48, 48
{
Offset 24, 24
Offset 24, 48
Patch KSPRB0,0,0 { }
}

View File

@ -284,8 +284,8 @@ class KiriCacodemonPlushie : HDWeapon {
A_StartSound("potion/chug");
invoker.owner.A_TakeInventory("SecondBlood", 1, TIF_NOTAKEINFINITE);
invoker.setMonsterHealth(
invoker.getMonsterHealth() +
invoker.getMonsterMaxHealth() * 0.25);
int(invoker.getMonsterHealth() +
invoker.getMonsterMaxHealth() * 0.25));
// Throw out a spend blood bag.
A_SpawnItemEx(
@ -303,13 +303,14 @@ class KiriCacodemonPlushie : HDWeapon {
HDBleedingWound hbl = HDBleedingWound.inflict(
invoker.owner, 2, 1, source : invoker.owner);
HDPlayerPawn(invoker.owner).bloodloss += 0.1;
// FIXME this gets rounded down to 0
//HDPlayerPawn(invoker.owner).bloodloss += 0.1;
A_StartSound(invoker.owner.painsound);
invoker.setMonsterHealth(
invoker.getMonsterHealth() +
invoker.getMonsterMaxHealth() * 0.1);
int(invoker.getMonsterHealth() +
invoker.getMonsterMaxHealth() * 0.1));
}
}

View File

@ -113,8 +113,6 @@ class SnekTechSprayer : HDWeapon
} else {
Actor spawnedThing;
bool success;
float zOffset = GunHeight() * 0.8;
FLineTraceData lineTraceData;
@ -154,15 +152,12 @@ class SnekTechSprayer : HDWeapon
"kiri/spraycan_spray",
CHAN_WEAPON);
[success, spawnedThing] = A_SpawnItemEx(
"SnekTechSprayerDecalSpawner",
xofs : 0, yofs : 0, zofs : zOffset);
let normal = lineTraceData.HitDir;
let spawnedThing = Actor.Spawn("SnekTechSprayerDecalSpawner", lineTraceData.HitLocation - normal);
SnekTechSprayerDecalSpawner spawner = SnekTechSprayerDecalSpawner(spawnedThing);
if(success && spawner) {
spawner.A_SetPitch(pitch);
spawner.A_SetAngle(angle);
if(spawner) {
spawner.angle = VectorAngle(-normal.x, -normal.y);
spawner.actualDecalName = actualDecalName;
spawner.master = invoker.owner;
@ -179,8 +174,12 @@ class SnekTechSprayer : HDWeapon
}
goto waiting;
unload:
KSPR A 2 { invoker.CycleSprayPattern(-1); }
goto waiting;
firemode:
KSPR A 2 { invoker.CycleSprayPattern(); }
KSPR A 2 { invoker.CycleSprayPattern(1); }
goto waiting;
waiting:
@ -248,8 +247,8 @@ class SnekTechSprayer : HDWeapon
}
int time = level.TotalTime;
int lastChargedTime = round(
float(pressure - KIRI_SPRAY_MAXPRESSURE) / float(KIRI_SPRAY_PRESSURE_DECAY_RATE) + time);
int lastChargedTime = int(round(
float(pressure - KIRI_SPRAY_MAXPRESSURE) / float(KIRI_SPRAY_PRESSURE_DECAY_RATE) + time));
weaponstatus[KIRI_SPRAY_WS_PRESSURE] = lastChargedTime;
}
@ -304,7 +303,7 @@ class SnekTechSprayer : HDWeapon
}
}
void CycleSprayPattern()
void CycleSprayPattern(int increment)
{
// Find the current entry in the list of patterns.
String currentPattern = CVar.GetCVar("snektech_spraypattern", owner.player).GetString();
@ -318,13 +317,27 @@ class SnekTechSprayer : HDWeapon
currentIndex = -1;
}
// Increment the index.
int newIndex = (currentIndex + 1) % patternList.size();
// Increment/decrement the index.
int newIndex = (currentIndex + increment) % patternList.size();
if(newIndex < 0) {
newIndex = patternList.size() - 1;
}
// Set the new CVar.
CVar.GetCVar("snektech_spraypattern", owner.player).SetString(patternList[newIndex]);
currentPattern = CVar.GetCVar("snektech_spraypattern", owner.player).GetString();
owner.A_Log("Selected spray pattern: "..currentPattern, true);
currentPattern = patternList[newIndex];
// first, update the Actual cvar
if (owner.PlayerNumber() == consoleplayer)
CVar.FindCVar("snektech_spraypattern").SetString(currentPattern);
// then update the per-player copy so the help text is correct
CVar.GetCVar("snektech_spraypattern", owner.player).SetString(currentPattern);
// Print it.
owner.A_Log(
String.format(
"Selected spray pattern: (%d/%d) %s",
newIndex + 1, patternList.size(),
currentPattern),
true);
// Current pattern is referenced in the help text, so reset
// it.
@ -353,12 +366,13 @@ class SnekTechSprayer : HDWeapon
return
WEPHELP_FIREMODE .. " Cycle pattern (current: "..currentPattern..").\n"..
WEPHELP_UNLOAD .. " Cycle pattern (backwards).\n"..
WEPHELP_ALTFIRE .. " Shake the can.\n"..
WEPHELP_FIRE .. " "..messages[messageIndex % messages.Size()].."\n";
}
}
class SnekTechSprayerDecalSpawner : Actor
class SnekTechSprayerDecalSpawner : Decal
{
default
{
@ -372,14 +386,65 @@ class SnekTechSprayerDecalSpawner : Actor
stop;
}
int timeSinceLastSpray;
int thisSprayerId;
String actualDecalName;
Array<Thinker> decals;
void SpawnDecal()
{
Thinker think;
array<thinker> seen;
// find every decal that Isn't ours
let iter = ThinkerIterator.Create('Thinker', STAT_DECAL);
while (think = iter.Next()) {
// BaseDecal isn't exported to zscript so we have to filter this manually
if (think.GetClassName() == 'BaseDecal') {
seen.Push(think);
}
}
// pass the decal name as a map editor type of argument
args[0] = -int(name(actualDecalName));
// spawn the decal
Super.SpawnDecal();
// then find every decal that we spawned
iter.Reinit();
while (think = iter.Next()) {
if (think.GetClassName() == 'BaseDecal' &&
seen.Find(think) == seen.Size())
{
decals.Push(think);
}
}
}
override void OnDestroy()
{
for (let i = 0; i < decals.Size(); i++) {
if (decals[i]) {
decals[i].Destroy();
}
}
}
// Decal::BeginPlay deletes the actor
override void BeginPlay() {Actor.BeginPlay();}
override void PostBeginPlay()
{
Super.PostBeginPlay();
A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE);
// copy A_SprayDecal z offset
setz(pos.z + height / 2);
SpawnDecal();
if (decals.Size() == 0) {
Destroy();
return;
}
// Figure out a new ID number.
ThinkerIterator iter = ThinkerIterator.Create("SnekTechSprayerDecalSpawner");
@ -417,18 +482,6 @@ class SnekTechSprayerDecalSpawner : Actor
}
}
}
override void Tick()
{
super.Tick();
timeSinceLastSpray++;
if(timeSinceLastSpray >= 35 * 60) {
A_SprayDecal(actualDecalName, KIRI_SPRAY_DISTANCE);
timeSinceLastSpray = 0;
}
}
}
class SnekTechSprayerPattern : Actor