scriptified and split up actSpawnThing

This commit is contained in:
Christoph Oelckers 2023-10-09 23:11:55 +02:00
parent 0abba1ab7d
commit 3b39e1db99
6 changed files with 143 additions and 117 deletions

View file

@ -254,6 +254,7 @@ bool ZCCRazeCompiler::CompileFlagDefs(PContainerType* type, TArray<ZCC_FlagDef*>
if (field == nullptr)
{
Error(p, "Variable %s not found in %s", referenced.GetChars(), type->TypeName.GetChars());
continue;
}
else if (!field->Type->isInt() || field->Type->Size != 4)
{
@ -262,10 +263,9 @@ bool ZCCRazeCompiler::CompileFlagDefs(PContainerType* type, TArray<ZCC_FlagDef*>
FName name(p->NodeName);
type->AddNativeField(name.GetChars(), TypeSInt32, field->Offset, 0, 1 << (p->BitValue & 0xffff));
}
}
return true;
}
}
return false;
}
//==========================================================================

View file

@ -1217,17 +1217,10 @@ static void checkAddFrag(DBloodActor* killerActor, DBloodActor* actor)
}
else if (gGameOptions.nGameType == 1 && killerActor->IsPlayerActor() && actor->spr.statnum == kStatDude)
{
switch (actor->GetType())
if (AllowedKillType(actor))
{
case kDudeBat:
case kDudeRat:
case kDudeInnocent:
case kDudeBurningInnocent:
break;
default:
auto pKillerPlayer = getPlayer(killerActor);
pKillerPlayer->fragCount++;
break;
}
}
@ -4346,95 +4339,6 @@ DBloodActor* actSpawnDude(DBloodActor* source, int nType, double dist)
//
//---------------------------------------------------------------------------
DBloodActor* actSpawnThing(sectortype* pSector, const DVector3& pos, int nThingType)
{
assert(nThingType >= kThingBase && nThingType < kThingMax);
auto cls = GetSpawnType(nThingType);
auto actor = actSpawnSprite(pSector, pos, 4, 1, cls, nThingType);
int nType = nThingType - kThingBase;
actor->ChangeType(nThingType);
assert(actor->hasX());
actor->xspr.health = actor->IntVar("defhealth") << 4;
actor->clipdist = actor->FloatVar("defclipdist");
actor->spr.flags = actor->IntVar("defflags");
if (actor->spr.flags & 2) actor->spr.flags |= 4;
actor->spr.cstat |= ESpriteFlags::FromInt(actor->IntVar("defcstat"));
actor->spr.shade = actor->IntVar("defshade");
actor->spr.pal = actor->IntVar("defpal");
actor->spr.cstat2 |= CSTAT2_SPRITE_MAPPED;
switch (nThingType)
{
case kThingVoodooHead:
actor->xspr.data1 = 0;
actor->xspr.data2 = 0;
actor->xspr.data3 = 0;
actor->xspr.data4 = 0;
actor->xspr.state = 1;
actor->xspr.triggerOnce = 1;
actor->xspr.isTriggered = 0;
break;
case kThingDroppedLifeLeech:
#ifdef NOONE_EXTENSIONS
case kModernThingEnemyLifeLeech:
#endif
actor->xspr.data1 = 0;
actor->xspr.data2 = 0;
actor->xspr.data3 = 0;
actor->xspr.data4 = 0;
actor->xspr.state = 1;
actor->xspr.triggerOnce = 0;
actor->xspr.isTriggered = 0;
break;
case kThingZombieHead:
actor->xspr.data1 = 8;
actor->xspr.data2 = 0;
actor->xspr.data3 = 0;
actor->xspr.data4 = 318;
actor->xspr.TargetPos.X = PlayClock + 180;
actor->xspr.locked = 1;
actor->xspr.state = 1;
actor->xspr.triggerOnce = 0;
actor->xspr.isTriggered = 0;
break;
case kThingBloodBits:
case kThingBloodChunks:
actor->xspr.data1 = (nThingType == kThingBloodBits) ? 19 : 8;
actor->xspr.data2 = 0;
actor->xspr.data3 = 0;
actor->xspr.data4 = 319;
actor->xspr.TargetPos.X = PlayClock + 180;
actor->xspr.locked = 1;
actor->xspr.state = 1;
actor->xspr.triggerOnce = 0;
actor->xspr.isTriggered = 0;
break;
case kThingArmedTNTStick:
evPostActor(actor, 0, AF(fxDynPuff));
sfxPlay3DSound(actor, 450, 0, 0);
break;
case kThingArmedTNTBundle:
sfxPlay3DSound(actor, 450, 0, 0);
evPostActor(actor, 0, AF(fxDynPuff));
break;
case kThingArmedSpray:
evPostActor(actor, 0, AF(fxDynPuff));
break;
}
return actor;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
DBloodActor* actFireThing(DBloodActor* actor, double xyoff, double zoff, double zvel, int thingType, double nSpeed)
{
assert(thingType >= kThingBase && thingType < kThingMax);
@ -4446,9 +4350,12 @@ DBloodActor* actFireThing(DBloodActor* actor, double xyoff, double zoff, double
vect.XY() = gHitInfo.hitpos.XY() - actor->spr.Angles.Yaw.ToVector() * actor->clipdist * 2;
}
auto fired = actSpawnThing(actor->sector(), vect, thingType);
if (fired)
{
fired->SetOwner(actor);
fired->spr.Angles.Yaw = actor->spr.Angles.Yaw;
fired->vel = DVector3(fired->spr.Angles.Yaw.ToVector() * nSpeed, nSpeed * zvel * 4) + actor->vel * 0.5;
}
return fired;
}

View file

@ -414,6 +414,27 @@ DBloodActor* actFireMissile(DBloodActor* actor, double xyoff, double zoff, DVect
return nullptr;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
DBloodActor* actSpawnThing(sectortype* pSector, const DVector3& pos, int nThingType)
{
IFVM(BloodThingBase, spawnThing)
{
PClass* ty = GetSpawnType(nThingType);
DBloodActor* spawned;
VMReturn ret((void**)&spawned);
VMValue param[] = { pSector, pos.X, pos.Y, pos.Z, ty };
VMCall(func, param, 5, &ret, 1);
return spawned;
}
return nullptr;
}
//---------------------------------------------------------------------------
//
//

View file

@ -31,6 +31,19 @@ class BloodMissileBase : BloodActor
virtual void initMissile(BloodActor spawner)
{
self.cstat2 |= CSTAT2_SPRITE_MAPPED;
self.shade = self.defshade;
self.pal = self.defpal;
self.clipdist = clipdist;
self.flags = 1;
self.Angle = spawner.angle + self.angleofs;
self.ownerActor = spawner;
self.cstat |= CSTAT_SPRITE_BLOCK;
self.xspr.target = null;
self.evPostActorCallback(600, RemoveActor);
self.vel += self.movementAdd * spawner.vel;
if (self.randomVel > 0)
{

View file

@ -13,6 +13,35 @@ class BloodThingBase : BloodActor
property bouncefactor: bouncefactor;
property dmgResist: dmgResist;
property cstat: defcstat;
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static BloodThingBase spawnThing(sectortype sector, Vector3 pos, class<BloodThingBase> type)
{
if (type == null || !(type is 'BloodThingBase')) return null;
let spawned = BloodThingBase(spawnSprite(sector, pos, kStatThing, true, type));
if (spawned == null) return null;
spawned.initThing();
return spawned;
}
virtual void initThing()
{
self.xspr.health = self.defhealth << 4;
self.clipdist = self.defclipdist;
self.flags = self.defflags;
if (self.flags & 2) self.flags |= 4;
self.cstat |= self.defcstat;
self.shade = self.defshade;
self.pal = self.defpal;
self.cstat2 |= CSTAT2_SPRITE_MAPPED;
}
}
class BloodThingTNTBarrel : BloodThingBase
@ -257,6 +286,14 @@ class BloodThingArmedTNTStick : BloodThingBase
scale 0.500000, 0.500000;
dmgcontrol 64, 256, 128, 64, 0, 0, 256;
}
override void initThing()
{
super.initThing();
self.evPostActorCallback(0, fxDynPuff);
self.play3DSoundID(450, 0, 0);
}
}
class BloodThingArmedTNTBundle : BloodThingBase
@ -275,6 +312,14 @@ class BloodThingArmedTNTBundle : BloodThingBase
scale 0.500000, 0.500000;
dmgcontrol 64, 256, 128, 64, 0, 0, 256;
}
override void initThing()
{
super.initThing();
self.play3DSoundID(450, 0, 0);
self.evPostActorCallback(0, fxDynPuff);
}
}
class BloodThingArmedSpray : BloodThingBase
@ -293,6 +338,13 @@ class BloodThingArmedSpray : BloodThingBase
scale 0.500000, 0.500000;
dmgcontrol 64, 256, 128, 64, 0, 0, 256;
}
override void initThing()
{
super.initThing();
self.evPostActorCallback(0, fxDynPuff);
}
}
class BloodThingBone : BloodThingBase
@ -362,9 +414,20 @@ class BloodThingBloodBits : BloodThingBase
cstat CSTAT_SPRITE_BLOCK_ALL;
dmgcontrol 128, 64, 256, 256, 0, 0, 256;
}
override void initThing()
{
super.initThing();
self.xspr.data1 = 8;
self.xspr.data4 = 319;
self.xspr.TargetPos.X = PlayClock + 180;
self.xspr.locked = 1;
self.xspr.state = 1;
}
}
class BloodThingBloodChunks : BloodThingBase
class BloodThingBloodChunks : BloodThingBloodBits
{
default
{
@ -376,6 +439,13 @@ class BloodThingBloodChunks : BloodThingBase
cstat CSTAT_SPRITE_BLOCK_ALL;
dmgcontrol 128, 64, 256, 256, 0, 0, 64;
}
override void initThing()
{
super.initThing();
self.xspr.data1 = 19;
}
}
class BloodThingZombieHead : BloodThingBase
@ -393,6 +463,17 @@ class BloodThingZombieHead : BloodThingBase
scale 0.625000, 0.625000;
dmgcontrol 128, 64, 256, 256, 0, 0, 64;
}
override void initThing()
{
super.initThing();
self.xspr.data1 = 8;
self.xspr.data4 = 318;
self.xspr.TargetPos.X = PlayClock + 180;
self.xspr.locked = 1;
self.xspr.state = 1;
}
}
class BloodThingNapalmBall : BloodThingBase
@ -464,6 +545,13 @@ class BloodThingDroppedLifeLeech : BloodThingBase
scale 0.750000, 0.750000;
dmgcontrol 64, 64, 112, 64, 0, 96, 96;
}
override void initThing()
{
super.initThing();
self.xspr.state = 1;
}
}
class BloodThingVoodooHead : BloodThingBase
@ -480,6 +568,15 @@ class BloodThingVoodooHead : BloodThingBase
shade -128;
scale 0.250000, 0.250000;
}
override void initThing()
{
super.initThing();
self.xspr.state = 1;
self.xspr.triggerOnce = 1;
}
}
class BloodThingTNTProx : BloodThingBase

View file

@ -438,7 +438,7 @@ native void callbackMissileBurst();
//
//---------------------------------------------------------------------------
BloodActor fireMissile(double xyoff, double zoff, Vector3 dv, class<BloodMissileBase> type)
BloodMissileBase fireMissile(double xyoff, double zoff, Vector3 dv, class<BloodMissileBase> type)
{
if (type == null || !(type is 'BloodMissileBase')) return null;
@ -464,20 +464,7 @@ native void callbackMissileBurst();
let spawned = BloodMissileBase(self.spawnSprite(self.sector, spawnpos, kStatProjectile, true, type));
if (spawned == null) return null;
spawned.cstat2 |= CSTAT2_SPRITE_MAPPED;
spawned.shade = spawned.defshade;
spawned.pal = spawned.defpal;
spawned.clipdist = clipdist;
spawned.flags = 1;
spawned.Angle = self.angle + spawned.angleofs;
spawned.vel = dv.Unit() * spawned.speed;
spawned.ownerActor = self;
spawned.cstat |= CSTAT_SPRITE_BLOCK;
spawned.xspr.target = null;
spawned.evPostActorCallback(600, RemoveActor);
spawned.initMissile(self); // handle type specific init.
if (impact)
@ -487,4 +474,5 @@ native void callbackMissileBurst();
}
return spawned;
}
}