Skip to content

Commit c2a88a7

Browse files
committed
weaponbox creation logic fix
1 parent 8f7b237 commit c2a88a7

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

amxmodx/scripting/reapi_healthnade.sma

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ new const PLUGIN_VERSION[] = "0.0.7f";
2929
#include <fakemeta>
3030
#include <hamsandwich>
3131
#include <reapi>
32+
#include <xs>
3233
#include <healthnade>
3334

3435
enum E_NadeDropType {
@@ -231,28 +232,41 @@ public CBasePlayer_Killed_Pre(const id) {
231232
return;
232233
}
233234

234-
static const Float:flShiftSpawnEntOrigin = 50.0; // рандомное смещение по координатам
235-
236235
new eEnt, Float:fOrigin[3];
237236

238237
get_entvar(id, var_origin, fOrigin);
239238

240-
fOrigin[0] += random_float(-flShiftSpawnEntOrigin, flShiftSpawnEntOrigin);
241-
fOrigin[1] += random_float(-flShiftSpawnEntOrigin, flShiftSpawnEntOrigin);
239+
new Float:fVelocity[3];
240+
get_entvar(id, var_velocity, fVelocity);
241+
xs_vec_mul_scalar(fVelocity, 0.75, fVelocity);
242242

243243
eEnt = rg_create_entity("info_target");
244244

245-
engfunc(EngFunc_SetModel, eEnt, WORLDMODEL);
246-
engfunc(EngFunc_SetOrigin, eEnt, fOrigin);
247-
engfunc(EngFunc_SetSize, eEnt, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 1.0});
245+
if(is_nullent(eEnt)) {
246+
return;
247+
}
248248

249249
set_entvar(eEnt, var_classname, "healthnade_drop");
250+
251+
engfunc(EngFunc_SetOrigin, eEnt, fOrigin);
250252
set_entvar(eEnt, var_movetype, MOVETYPE_TOSS);
251253
set_entvar(eEnt, var_solid, SOLID_TRIGGER);
254+
engfunc(EngFunc_SetModel, eEnt, WORLDMODEL);
255+
engfunc(EngFunc_SetSize, eEnt, Float:{-6.0, -6.0, -1.0}, Float:{6.0, 6.0, 1.0});
256+
257+
set_entvar(eEnt, var_velocity, fVelocity);
258+
SetThink(eEnt, "think_healthnade_drop");
259+
set_entvar(eEnt, var_nextthink, get_gametime() + get_cvar_float("mp_item_staytime"));
252260

253261
SetTouch(eEnt, "touch_healthnade_drop");
254262
}
255263

264+
public think_healthnade_drop(const eEnt) {
265+
if(is_entity(eEnt)) {
266+
set_entvar(eEnt, var_flags, FL_KILLME);
267+
}
268+
}
269+
256270
public touch_healthnade_drop(const eEnt, const id) {
257271
if (
258272
is_nullent(eEnt)

0 commit comments

Comments
 (0)