My map for Test-server

Topics to existing maps/new maps/map secrets, ...
Aphex
Posts: 20
Joined: Sun Jun 08, 2025 10:31 am
Has thanked: 5 times

Re: My map for Test-server

Post 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.
Barbie
Site Admin
Posts: 268
Joined: Thu Nov 08, 2018 7:12 am
Has thanked: 4 times
Been thanked: 15 times

Re: My map for Test-server

Post 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:

Code: Select all

if (P.Fatness < 255) P.Fatness++;
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'
}
Post Reply