Skip to content

Commit

Permalink
allow summon to work with visual thinkers
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Dec 7, 2024
1 parent fb660fa commit 484ff81
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
23 changes: 18 additions & 5 deletions src/d_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions src/gamedata/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "texturemanager.h"
#include "d_main.h"
#include "maps.h"
#include "p_visualthinker.h"

extern void LoadActors ();
extern void InitBotStuff();
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 484ff81

Please sign in to comment.