Add spawnflags and keyvalue support (untested).
This commit is contained in:
@@ -927,6 +927,13 @@ int mmDispatchSpawn( edict_t *pent )
|
||||
delete monsters[index].pMonster;
|
||||
}
|
||||
|
||||
// free any allocated keyvalue memory
|
||||
for (index = 0; index < monster_spawn_count; index++)
|
||||
{
|
||||
if (monster_spawnpoint[index].keyvalue)
|
||||
free(monster_spawnpoint[index].keyvalue);
|
||||
}
|
||||
|
||||
// do level initialization stuff here...
|
||||
|
||||
for (index = 0; monster_types[index].name[0]; index++)
|
||||
|
||||
@@ -62,11 +62,6 @@ bool get_input(FILE *fp, char *input)
|
||||
return FALSE; // no input found
|
||||
}
|
||||
|
||||
struct pKVD
|
||||
{
|
||||
char key[33];
|
||||
char value[33];
|
||||
};
|
||||
void scan_monster_cfg(FILE *fp)
|
||||
{
|
||||
// Let's make a full rework of this. -Giegue
|
||||
@@ -162,10 +157,16 @@ void scan_monster_cfg(FILE *fp)
|
||||
|
||||
if (!badent)
|
||||
{
|
||||
// Make room for entity-specific keyvalues.
|
||||
if (monster)
|
||||
{
|
||||
// The line is a little too long, no?
|
||||
monster_spawnpoint[monster_spawn_count].keyvalue = (pKVD*)calloc(32, sizeof(*monster_spawnpoint[monster_spawn_count].keyvalue));
|
||||
}
|
||||
|
||||
// Done. Let's process the keyvalues.
|
||||
for (int i = 0; i < (kvd_index-1); i++)
|
||||
{
|
||||
// Any unknown keyvalue is ignored.
|
||||
// Any duplicate keyvalue is overwritten.
|
||||
|
||||
if (strcmp(data[i].key, "origin") == 0)
|
||||
@@ -225,6 +226,31 @@ void scan_monster_cfg(FILE *fp)
|
||||
monster_spawnpoint[monster_spawn_count].angles[2] = z;
|
||||
}
|
||||
}
|
||||
else if (strcmp(data[i].key, "spawnflags") == 0)
|
||||
{
|
||||
if (monster)
|
||||
{
|
||||
if (sscanf(data[i].value, "%i", &x) != 1)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "ERROR: invalid spawnflags: %s", input); // print conflictive line
|
||||
|
||||
// default to 30 seconds
|
||||
LOG_MESSAGE(PLID, "ERROR: entity spawnflags will be set to none (0)");
|
||||
x = 0;
|
||||
}
|
||||
monster_spawnpoint[monster_spawn_count].spawnflags = x;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We do not know this keyvalue, but an specific entity might use it.
|
||||
// Save it for later
|
||||
if (monster)
|
||||
{
|
||||
strcpy(data[i].key, monster_spawnpoint[monster_spawn_count].keyvalue[i].key);
|
||||
strcpy(data[i].value, monster_spawnpoint[monster_spawn_count].keyvalue[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (monster)
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#ifndef MONSTER_PLUGIN_H
|
||||
#define MONSTER_PLUGIN_H
|
||||
|
||||
typedef struct pKVD
|
||||
{
|
||||
char key[33];
|
||||
char value[33];
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -33,6 +38,8 @@ typedef struct {
|
||||
Vector angles;
|
||||
float delay;
|
||||
unsigned char monster;
|
||||
int spawnflags;
|
||||
pKVD *keyvalue;
|
||||
float respawn_time;
|
||||
bool need_to_respawn;
|
||||
} monster_spawnpoint_t;
|
||||
|
||||
Reference in New Issue
Block a user