mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- added script exports for 'spawn' and 'lotsofglass' and made the spawn variant using class names operational.
This commit is contained in:
parent
317968c45a
commit
306db376d9
3 changed files with 70 additions and 12 deletions
|
@ -50,22 +50,32 @@ BEGIN_DUKE_NS
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
|
||||
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* clstype, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
|
||||
{
|
||||
// sector pointer must be strictly validated here or the engine will crash.
|
||||
if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr;
|
||||
// spawning out of range sprites will also crash.
|
||||
if (s_pn < 0 || s_pn >= MAXTILES) return nullptr;
|
||||
if (clstype == nullptr && (s_pn < 0 || s_pn >= MAXTILES)) return nullptr;
|
||||
|
||||
auto info = spawnMap.CheckKey(s_pn);
|
||||
auto act = static_cast<DDukeActor*>(InsertActor(info ? info->Class() : RUNTIME_CLASS(DDukeActor), whatsectp, s_stat));
|
||||
int basepicnum = -1;
|
||||
if (!clstype)
|
||||
{
|
||||
auto info = spawnMap.CheckKey(s_pn);
|
||||
if (info)
|
||||
{
|
||||
clstype = static_cast<PClassActor*>(info->Class());
|
||||
basepicnum = info->param;
|
||||
}
|
||||
}
|
||||
|
||||
auto act = static_cast<DDukeActor*>(InsertActor(clstype? clstype : RUNTIME_CLASS(DDukeActor), whatsectp, s_stat));
|
||||
|
||||
if (act == nullptr) return nullptr;
|
||||
SetupGameVarsForActor(act);
|
||||
|
||||
act->basepicnum = info ? info->param : -1;
|
||||
act->basepicnum = basepicnum;
|
||||
act->spr.pos = pos;
|
||||
act->spr.picnum = s_pn;
|
||||
if (s_pn != -1) act->spr.picnum = s_pn; // if -1 use the class default.
|
||||
act->spr.shade = s_shd;
|
||||
act->spr.scale = DVector2(scale.X, scale.Y);
|
||||
|
||||
|
@ -114,6 +124,16 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, in
|
|||
|
||||
}
|
||||
|
||||
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
|
||||
{
|
||||
return CreateActor(whatsectp, pos, nullptr, s_pn, s_shd, scale, s_ang, s_vel, s_zvel, s_ow, s_stat);
|
||||
}
|
||||
|
||||
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, PClassActor* cls, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
|
||||
{
|
||||
return CreateActor(whatsectp, pos, cls, -1, s_shd, scale, s_ang, s_vel, s_zvel, s_ow, s_stat);
|
||||
}
|
||||
|
||||
DDukeActor* SpawnActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
|
||||
{
|
||||
auto actor = CreateActor(whatsectp, pos, s_pn, s_shd, scale, s_ang, s_vel, s_zvel, s_ow, s_stat);
|
||||
|
@ -223,19 +243,15 @@ DDukeActor* spawn(DDukeActor* actj, int pn)
|
|||
|
||||
DDukeActor* spawn(DDukeActor* actj, PClassActor * cls)
|
||||
{
|
||||
// still needs work to do.
|
||||
#if 0
|
||||
if (actj)
|
||||
if (actj && cls)
|
||||
{
|
||||
if (pn < 0) return nullptr;
|
||||
auto spawned = CreateActor(actj->sector(), actj->spr.pos, pn, 0, DVector2(0, 0), nullAngle, 0., 0., actj, 0);
|
||||
auto spawned = CreateActor(actj->sector(), actj->spr.pos, cls, 0, DVector2(0, 0), nullAngle, 0., 0., actj, 0);
|
||||
if (spawned)
|
||||
{
|
||||
spawned->attackertype = actj->spr.picnum;
|
||||
return fi.spawninit(actj, spawned, nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,46 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, PlayActorSound, DukeActor_PlayActorSou
|
|||
ACTION_RETURN_INT(DukeActor_PlayActorSound(self, snd));
|
||||
}
|
||||
|
||||
DDukeActor* DukeActor_Spawn(DDukeActor* origin, int intname)
|
||||
{
|
||||
int picnum = -1;
|
||||
// this is still a hack so it can spawn actors which haven't been scriptified yet. This will go away later.
|
||||
if (FName(ENamedName(intname)) == FName("DukeToiletWater"))
|
||||
{
|
||||
picnum = TileFiles.tileForName("TOILETWATER");
|
||||
}
|
||||
|
||||
if (picnum == -1)
|
||||
{
|
||||
auto cls = PClass::FindActor(FName(ENamedName(intname)));
|
||||
if (cls) return spawn(origin, cls);
|
||||
}
|
||||
else
|
||||
{
|
||||
return spawn(origin, picnum);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawn, DukeActor_Spawn)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DDukeActor);
|
||||
PARAM_INT(type);
|
||||
ACTION_RETURN_POINTER(DukeActor_Spawn(self, type));
|
||||
}
|
||||
|
||||
void DukeActor_Lotsofglass(DDukeActor* origin, int count)
|
||||
{
|
||||
lotsofglass(origin, nullptr, count);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofglass, DukeActor_Lotsofglass)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DDukeActor);
|
||||
PARAM_INT(count);
|
||||
DukeActor_Lotsofglass(self, count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -69,6 +69,8 @@ class DukeActor : CoreActor native
|
|||
native int ifhitbyweapon();
|
||||
native int domove(int clipmask);
|
||||
native void PlayActorSound(int snd);
|
||||
native DukeActor spawn(Name type);
|
||||
native void lotsofglass(int count);
|
||||
|
||||
virtual void BeginPlay() {}
|
||||
virtual void Initialize() {}
|
||||
|
|
Loading…
Reference in a new issue