New function: summon <item name> [tid [special [arg1 [arg2 [arg3 [arg4 [arg5]]]]]]]
There is working code (maybe it needs some fixes, but it works as is), i dont know which version of zdoom i used

d_net.cpp
Code: Select all
// inside function Net_DoCommand:
case DEM_SUMMON:
case DEM_SUMMONFRIEND:
case DEM_SUMMONFOE:
{
const PClass *typeinfo;
// kgsws's change
SWORD tid;
BYTE special;
int args[5];
// kgsws's end
s = ReadString (stream);
// kgsws's change
tid = ReadWord(stream);
special = ReadByte(stream);
for(i = 0; i < 5; i++) args[i] = ReadLong(stream);
ReadByte(stream);
// kgsws's end
typeinfo = PClass::FindClass (s);
if (typeinfo != NULL && typeinfo->ActorInfo != NULL)
{
AActor *source = players[player].mo;
if (source != NULL)
{
if (GetDefaultByType (typeinfo)->flags & MF_MISSILE)
{
P_SpawnPlayerMissile (source, typeinfo);
}
else
{
const AActor *def = GetDefaultByType (typeinfo);
AActor *spawned = Spawn (typeinfo,
source->x + FixedMul (def->radius * 2 + source->radius, finecosine[source->angle>>ANGLETOFINESHIFT]),
source->y + FixedMul (def->radius * 2 + source->radius, finesine[source->angle>>ANGLETOFINESHIFT]),
source->z + 8 * FRACUNIT, ALLOW_REPLACE);
if (spawned != NULL)
{
// kgsws's change
spawned->angle = source->angle; // Force target face as player, better? :)
spawned->tid = tid;
spawned->special = special;
for(i = 0; i < 5; i++) {
spawned->args[i] = args[i];
}
if(tid) spawned->AddToHash();
// kgsws's end
if (type == DEM_SUMMONFRIEND)
{
if (spawned->CountsAsKill())
{
level.total_monsters--;
}
spawned->FriendPlayer = player + 1;
spawned->flags |= MF_FRIENDLY;
spawned->LastHeard = players[player].mo;
}
else if (type == DEM_SUMMONFOE)
{
spawned->FriendPlayer = 0;
spawned->flags &= ~MF_FRIENDLY;
}
}
}
}
}
}
break;
// inside function Net_SkipCommand:
case DEM_MUSICCHANGE:
case DEM_PRINT:
case DEM_CENTERPRINT:
case DEM_UINFCHANGED:
case DEM_CHANGEMAP:
case DEM_SPRAY:
case DEM_MORPHEX:
case DEM_KILLCLASSCHEAT:
skip = strlen ((char *)(*stream)) + 1;
break;
// kgsws's change
case DEM_SUMMON:
case DEM_SUMMONFRIEND:
case DEM_SUMMONFOE:
skip = strlen ((char *)(*stream)) + 25;
break;
// kgsws's end
case DEM_INVUSE:
case DEM_INVDROP:
case DEM_WARPCHEAT:
skip = 4;
break;
Code: Select all
CCMD (summon)
{
int i;
if (CheckCheatmode ())
return;
if (argv.argc() > 1)
{
const PClass *type = PClass::FindClass (argv[1]);
if (type == NULL)
{
Printf ("Unknown class '%s'\n", argv[1]);
return;
}
Net_WriteByte (DEM_SUMMON);
Net_WriteString (type->TypeName.GetChars());
// kgsws's change
if (argv.argc() > 2) {
Net_WriteWord(clamp(atoi(argv[2]), 0, 32767)); // TID
if (argv.argc() > 3) {
Net_WriteByte(clamp(atoi(argv[3]), 0, 255)); // special
for(i = 4; i < 9; i++) { // args
if(i < argv.argc()) Net_WriteLong(atoi(argv[i])); else Net_WriteLong(0);
}
} else {
Net_WriteByte(0); // special
for(i = 0; i < 5; i++) Net_WriteLong(0); // args
}
} else {
Net_WriteWord(0); // TID
Net_WriteByte(0); // special
for(i = 0; i < 5; i++) Net_WriteLong(0); // args
}
Net_WriteByte(0); // avoid strange things, i dont know why it must be there
// kgsws's end
}
}
It can really help with development of new maps. Now it is required to change map and reload it, but with new summon function it will be possible to try some effects faster.