allow summon to work with visual thinkers

This commit is contained in:
Ricardo Luís Vaz Silva 2024-12-07 13:36:11 -03:00
parent 62381cc7de
commit 023328da04
2 changed files with 26 additions and 8 deletions

View file

@ -2378,7 +2378,6 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
case DEM_SUMMONFRIEND2:
case DEM_SUMMONFOE2:
{
PClassActor *typeinfo;
int angle = 0;
int16_t tid = 0;
uint8_t special = 0;
@ -2393,11 +2392,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
for(i = 0; i < 5; i++) args[i] = ReadInt32(stream);
}
typeinfo = PClass::FindActor(s);
if (typeinfo != NULL)
AActor *source = players[player].mo;
if(source != NULL)
{
AActor *source = players[player].mo;
if (source != NULL)
PClassActor * typeinfo = PClass::FindActor(s);
if (typeinfo != NULL)
{
if (GetDefaultByType (typeinfo)->flags & MF_MISSILE)
{
@ -2443,6 +2442,20 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
}
}
}
else
{ // not an actor, must be a visualthinker
PClass * typeinfo = PClass::FindClass(s);
if(typeinfo && typeinfo->IsDescendantOf("VisualThinker"))
{
DVector3 spawnpos = source->Vec3Angle(source->radius * 4, source->Angles.Yaw, 8.);
auto vt = DVisualThinker::NewVisualThinker(source->Level, typeinfo);
if(vt)
{
vt->PT.Pos = spawnpos;
vt->UpdateSector();
}
}
}
}
}
break;

View file

@ -55,6 +55,7 @@
#include "texturemanager.h"
#include "d_main.h"
#include "maps.h"
#include "p_visualthinker.h"
extern void LoadActors ();
extern void InitBotStuff();
@ -779,11 +780,15 @@ static void SummonActor (int command, int command2, FCommandLine argv)
if (argv.argc() > 1)
{
PClassActor *type = PClass::FindActor(argv[1]);
PClass *type = PClass::FindActor(argv[1]);
if (type == nullptr)
{
Printf ("Unknown actor '%s'\n", argv[1]);
return;
type = PClass::FindClass(argv[1]);
if(!type || !type->IsDescendantOf("VisualThinker"))
{
Printf ("Unknown actor or visual thinker '%s'\n", argv[1]);
return;
}
}
Net_WriteInt8 (argv.argc() > 2 ? command2 : command);
Net_WriteString (type->TypeName.GetChars());