From 023328da047af49882481cabd6a715ee8c8ab895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 7 Dec 2024 13:36:11 -0300 Subject: [PATCH] allow summon to work with visual thinkers --- src/d_net.cpp | 23 ++++++++++++++++++----- src/gamedata/info.cpp | 11 ++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index b785b52e2b9..c7241c3a8b6 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -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; diff --git a/src/gamedata/info.cpp b/src/gamedata/info.cpp index 67fb87f678d..3fc5d2e7636 100644 --- a/src/gamedata/info.cpp +++ b/src/gamedata/info.cpp @@ -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());