Page 2 of 2
Re: My map for Test-server
Posted: Tue Jul 29, 2025 9:54 am
by Aphex
BeerVial
The code is same as original, BUT there is 1 more line, so they also add Fatness to player. This was done to see who was playing, and who was hanging out in the "bar" instead.
MedPlant
This acts as an "antidote" to BeerVial -- resets Fatness to default (0%).
P.s. I'm not really a programmer, so if you know a way to really "expand" class (add just what's changed without rewriting from scratch), I'd be grateful.
Re: My map for Test-server
Posted: Tue Jul 29, 2025 3:18 pm
by Barbie
Ah, didn't notice the fatness change code.
But another point here:
Code: Select all
P.Fatness +=1;
if (P.Fatness >= 255) P.Fatness = 255;
What will happen if Player's fatness is already at 255, what is the maximum value of type BYTE? An overflow happens, what might set the value to 0 (depening on engine code). Worst case would be that the neighbour memory cell is changed, too.
Better approach:
Aphex wrote: Tue Jul 29, 2025 9:54 am
if you know a way to really "expand" class (add just what's changed without rewriting from scratch), I'd be grateful.
Try this:
Code: Select all
class BeerVial expands HealthVial;
auto state MyPickup expands Pickup
{
function Touch(actor Other) {
local Name CurrentState;
if (IsInState('Sleeping')) // nothing to do for me
{
Super.Touch(Other);
return;
}
CurrentState = GetStateName();
Super.Touch(Other);
// has item been picked up so that the state has changed to 'Sleeping'?
if (GetStateName() != CurrentState && GetStateName() == 'Sleeping')
if (Pawn(Other) != None && Pawn(Other).Fatness < 255)
Pawn(Other).Fatness++;
}
}
defaultproperties {
PickupMessage="You drank a Health Beer +"
ItemName="Health Beer"
PickupSound=Sound'CompuSFX.(All).drinkgulp'
MultiSkins(0)=Texture'GenFluid.Water.Water'
MultiSkins(1)=WetTexture'FireEng.redlavax'
MultiSkins(2)=WetTexture'FireEng.PitLava'
}