+#include "spawn.qh"
#if defined(CSQC)
#elif defined(MENUQC)
#elif defined(SVQC)
// "classname" "target_spawn"
// "message" "fieldname value fieldname value ..."
// "spawnflags"
-// 1 = call the spawn function
-// 2 = trigger on map load
+// ON_MAPLOAD = trigger on map load
float target_spawn_initialized;
.void(entity this) target_spawn_spawnfunc;
data = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", key)));
if(data.y == 0) // undefined field, i.e., invalid type
{
- LOG_INFO("target_spawn: invalid/unknown entity key ", key, " specified, ignored!\n");
+ LOG_INFO("target_spawn: invalid/unknown entity key ", key, " specified, ignored!");
continue;
}
}
}
else
{
- LOG_INFO("target_spawn: invalid/unknown variable replacement ", value, " specified, ignored!\n");
+ LOG_INFO("target_spawn: invalid/unknown variable replacement ", value, " specified, ignored!");
continue;
}
{
if(value != "")
{
- LOG_INFO("target_spawn: try to get a field of a non-entity, ignored!\n");
+ LOG_INFO("target_spawn: try to get a field of a non-entity, ignored!");
continue;
}
data2 = stov(db_get(TemporaryDB, strcat("/target_spawn/field/", valuefield)));
if(data2_y == 0) // undefined field, i.e., invalid type
{
- LOG_INFO("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!\n");
+ LOG_INFO("target_spawn: invalid/unknown entity key replacement ", valuefield, " specified, ignored!");
continue;
}
value = getentityfieldstring(data2_x, valueent);
value = vtos(stov(value) + stov(valueoffset));
break;
default:
- LOG_INFO("target_spawn: only string, float and vector fields can do calculations, calculation ignored!\n");
+ LOG_INFO("target_spawn: only string, float and vector fields can do calculations, calculation ignored!");
break;
}
}
value = vtos(stov(value) + random() * data2_x * '1 0 0' + random() * data2_y * '0 1 0' + random() * data2_z * '0 0 1');
break;
default:
- LOG_INFO("target_spawn: only float and vector fields can do random calculations, calculation ignored!\n");
+ LOG_INFO("target_spawn: only float and vector fields can do random calculations, calculation ignored!");
break;
}
}
else
{
// edit entity
- for(entity e = NULL; (e = find(e, targetname, this.target)); )
- target_spawn_useon(e, this, actor, trigger);
+ FOREACH_ENTITY_STRING(targetname, this.target,
+ {
+ target_spawn_useon(it, this, actor, trigger);
+ });
}
}
void target_spawn_spawnfirst(entity this)
{
entity act = this.target_spawn_activator;
- if(this.spawnflags & 2)
+ if(this.spawnflags & ON_MAPLOAD)
target_spawn_use(this, act, NULL);
}