19 float target_spawn_initialized;
20 .void(
entity this) target_spawn_spawnfunc;
21 float target_spawn_spawnfunc_field;
22 .entity target_spawn_activator;
23 .float target_spawn_id;
24 float target_spawn_count;
26 void target_spawn_helper_setmodel(
entity this)
28 _setmodel(
this, this.
model);
31 void target_spawn_helper_setsize(
entity this)
38 float i, n, valuefieldpos;
39 string key, value, valuefield, valueoffset, valueoffsetrandom;
45 for(i = 0; i < n-1; i += 2)
59 LOG_INFO(
"target_spawn: invalid/unknown entity key ", key,
" specified, ignored!");
77 if(valuefieldpos != -1)
79 valueoffset =
substring(value, valuefieldpos + 1,
strlen(value) - valuefieldpos - 1);
80 value =
substring(value, 0, valuefieldpos);
83 valuefieldpos =
strstrofs(valueoffset,
"+", 0);
84 valueoffsetrandom =
"";
85 if(valuefieldpos != -1)
87 valueoffsetrandom =
substring(valueoffset, valuefieldpos + 1,
strlen(valueoffset) - valuefieldpos - 1);
88 valueoffset =
substring(valueoffset, 0, valuefieldpos);
93 if(valuefieldpos != -1)
95 valuefield =
substring(value, valuefieldpos + 1,
strlen(value) - valuefieldpos - 1);
96 value =
substring(value, 0, valuefieldpos);
104 else if(value ==
"activator")
109 else if(value ==
"other")
114 else if(value ==
"pusher")
116 if(
time < act.pushltime)
117 valueent = act.pusher;
122 else if(value ==
"target")
127 else if(value ==
"killtarget")
132 else if(value ==
"target2")
137 else if(value ==
"target3")
142 else if(value ==
"target4")
147 else if(value ==
"time")
154 LOG_INFO(
"target_spawn: invalid/unknown variable replacement ", value,
" specified, ignored!");
167 LOG_INFO(
"target_spawn: try to get a field of a non-entity, ignored!");
173 LOG_INFO(
"target_spawn: invalid/unknown entity key replacement ", valuefield,
" specified, ignored!");
176 value = getentityfieldstring(data2_x, valueent);
179 if(valueoffset !=
"")
184 value =
strcat(value, valueoffset);
193 LOG_INFO(
"target_spawn: only string, float and vector fields can do calculations, calculation ignored!");
198 if(valueoffsetrandom !=
"")
206 data2 =
stov(valueoffsetrandom);
210 LOG_INFO(
"target_spawn: only float and vector fields can do random calculations, calculation ignored!");
219 value =
strcat(
"target_spawn_helper", value);
220 putentityfieldstring(target_spawn_spawnfunc_field, e, value);
222 e.target_spawn_spawnfunc(e);
230 value = strreplace(
"'",
"", value);
231 putentityfieldstring(data.x, e, value);
238 this.target_spawn_activator = actor;
239 target_spawn_edit_entity(
252 bool target_spawn_cancreate(
entity this)
262 for(e =
NULL; (e =
findfloat(e, target_spawn_id, this.target_spawn_id)); --c)
276 if(!target_spawn_cancreate(
this))
279 e.spawnfunc_checked =
true;
280 target_spawn_useon(e,
this, actor, trigger);
281 e.target_spawn_id = this.target_spawn_id;
283 else if(this.
target ==
"*activator")
287 target_spawn_useon(actor,
this, actor, trigger);
294 target_spawn_useon(it,
this, actor, trigger);
299 void target_spawn_spawnfirst(
entity this)
301 entity act = this.target_spawn_activator;
303 target_spawn_use(
this, act,
NULL);
306 void initialize_field_db()
308 if(!target_spawn_initialized)
315 n = numentityfields();
316 for(i = 0; i < n; ++i)
318 fn = entityfieldname(i);
319 ft = entityfieldtype(i);
320 next = i *
'1 0 0' + ft *
'0 1 0' +
'0 0 1';
325 if(fn ==
"target_spawn_spawnfunc")
326 target_spawn_spawnfunc_field = i;
330 target_spawn_initialized = 1;
336 initialize_field_db();
337 this.
use = target_spawn_use;
339 this.target_spawn_id = ++target_spawn_count;
ERASEABLE void db_put(int db, string key, string value)
spawnfunc(info_player_attacker)
#define FOREACH_ENTITY_STRING(fld, match, body)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE string db_get(int db, string key)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void InitializeEntity(entity e, void(entity this) func, int order)