raze/wadsrc/static/zscript/games/duke/actors/viewscreen.zs
Christoph Oelckers f103e33300 - fixed code up to the point where everything compiles again. Duke sounds are currently non-functional.
All Duke script code has been changed to use strings as sound names now, just like GZDoom these will be looked up at compile time.
Original Duke sound indices still exist but are now being managed as resource IDs, not sound engine indices anymore.
2022-12-11 18:41:51 +01:00

151 lines
No EOL
3 KiB
Text

class DukeViewscreen : DukeActor
{
default
{
lotag 1;
extra 1;
statnum STAT_STANDABLE;
spriteset "VIEWSCREEN", "STATIC", "VIEWSCR";
}
const VIEWSCR_DIST = 1024; // was originally 2048, was increased to 8192 by EDuke32 and RedNukem, but with high resolutions the resulting 512 map units are still too low.
override void Initialize()
{
self.ownerActor = self;
}
override void Tick()
{
if (self.scale.X == 0) self.Destroy();
else
{
let p = self.findplayer();
double x = (self.pos - p.actor.pos).LengthSquared(); // the result from findplayer is not really useful.
if (x >= VIEWSCR_DIST * VIEWSCR_DIST && camsprite == self)
{
camsprite = null;
self.yint = 0;
self.temp_data[0] = 0;
}
}
}
override bool onUse(DukePlayer user)
{
DukeStatIterator it;
for(let acti = it.First(STAT_ACTOR); acti; acti = it.Next())
{
if (acti.actorflag2(SFLAG2_CAMERA) && acti.yint == 0 && self.hitag == acti.lotag)
{
acti.yint = 1; //Using this camera
if (user == Duke.GetViewPlayer()) Duke.PlaySound("MONITOR_ACTIVE");
self.ownerActor = acti;
self.yint = 1;
camsprite = self;
user.newOwner = acti;
return true;
}
}
user.clearcameras();
return true;
}
override bool animate(tspritetype tspr)
{
let actor = DukeActor(tspr.ownerActor);
let hitowner = actor.hitOwnerActor;
if (camsprite != null && hitowner && hitowner.temp_data[0] == 1)
{
tspr.SetSpritePic(self, 1);
tspr.cstat &= ~ (CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
tspr.cstat |= randomFlip();
tspr.scale.X += (0.125);
tspr.scale.Y += (0.125);
}
else if (camsprite && camsprite == hitowner)
{
tspr.SetSpritePic(self, 2);
}
return true;
}
}
class DukeViewscreen2 : DukeViewscreen
{
default
{
spriteset "VIEWSCREEN", "STATIC", "VIEWSCR";
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
class DukeCamera : DukeActor
{
default
{
pic "CAMERA1";
statnum STAT_ACTOR;
extra 1;
}
override void Initialize()
{
if (gs.camerashitable) self.cstat = CSTAT_SPRITE_BLOCK_ALL;
else self.cstat = 0;
if (ud.multimode < 2 && self.pal != 0)
{
self.scale = (0, 0);
self.ChangeStat(STAT_MISC);
return;
}
else self.pal = 0;
}
override void Tick()
{
if (self.temp_data[0] == 0)
{
self.temp_data[1] += 8;
if (gs.camerashitable)
{
int j = self.ifhitbyweapon();
if (j >= 0)
{
self.temp_data[0] = 1; // static
self.cstat = CSTAT_SPRITE_INVISIBLE;
for (int x = 0; x < 5; x++)
self.RANDOMSCRAP();
return;
}
}
if (self.hitag > 0)
{
let angle = 360. / 256;
if (self.temp_data[1] < self.hitag)
self.angle += angle;
else if (self.temp_data[1] < (self.hitag * 3))
self.angle -= angle;
else if (self.temp_data[1] < (self.hitag * 4))
self.angle += angle;
else
{
self.angle += angle;
self.temp_data[1] = 0;
}
}
}
}
}