- Ошибка
-
Добрый день, извините за неправильное написание Я использую переводчик, моя проблема в том, что я загружаю плагин Молотова и при попытке его скомпилировать получаю ошибки
- Компилятор
- Локальный
- Amx Mod X
- 1.10.0
- Исходный код
-
include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#define PLUGIN_NAME "[GRENADE] Molotov"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "medusa"
//const Float:MOLOTOV_RADIUS = 150.0; //Радиус
const Float:MOLOTOV_THROWTIME = 2.0; //Время молотова в полете перед детонацией
const MOLOTOV_DURATION = 12; //20 sec
const Float:MOLOTOV_PLAYTHINK_TIME = 0.04;
new const MOLOTOV_FIRE_CLASSNAME[] = "custom_molotov";
new const EFFECT_CLASSNAME_MUZZLEFLASH[] = "weapon_molotov_muzzleflash";
new const EFFECT_CLASSNAME_WICK[] = "weapon_molotov_wick";
new const SMOKE_CLASSNAME_OWNER[] = "custom_smoke_owner";
const WeaponIdType:WEAPON_FAKE_ID = WeaponIdType:75;
new const WEAPON_NAME[] = "weapon_smokegrenade";
new const AMMO_NAME[] = "Molotov";
new const WEAPON_NEW_NAME[] = "/grenaderad/weapon_molotov";
new const ITEM_CLASSNAME[] = "weapon_molotov";
new const GRENADE_CLASSNAME[] = "molotov";
const AMMO_ID = 16;
//const OBJECT_MOLOTOV_FIRE = 5123;
new MsgIdWeaponList, MsgIdAmmoPickup;
new FwdRegUserMsg, MsgHookWeaponList;
new SpriteFireColumn, SpriteFireExplode, SpriteFireBall;//, SpriteFireGround;, SpriteBeamDisc;
new sizes[] = {51,51,51}, count = 3;
new const WEAPON_MODEL_VIEW_MOLOTOV[] = "models/grenaderad/v_molotov.mdl";
new const WEAPON_MODEL_PLAYER_MOLOTOV[] = "models/grenaderad/p_molotov.mdl";
new const WEAPON_MODEL_WORLD_MOLOTOV[] = "models/grenaderad/w_molotov.mdl";
new const MOLOTOV_MODEL_FLOOR[] = "models/grenaderad/molotov_fire_floor.mdl";
new const MOLOTOV_SPRITE_FIRE_BALL[] = "sprites/grenaderad/molotov_fire_ball.spr";
new const MOLOTOV_SPRITE_FIRE_COLUMN[] = "sprites/grenaderad/molotov_fire_column.spr";
new const MOLOTOV_SPRITE_FIRE_EXPLODE[] = "sprites/grenaderad/molotov_fire_explode_c.spr";
new const MOLOTOV_SPRITE_FIRE_GROUND[] = "sprites/grenaderad/molotov_fire_ground.spr";
new const MOLOTOV_SPRITE_XPARK1[] = "sprites/grenaderad/molotov_fire_blend_c.spr";
new const MOLOTOV_SPRITE_WICK[] = "sprites/grenaderad/molotov_wick.spr";
new const MOLOTOV_SOUND_EXPLODE[] = "weapons/grenaderad/molotov_explode.wav";
new const MOLOTOV_SOUND_EXPLODE2[] = "weapons/grenaderad/molotov_explode2.wav";
new const MOLOTOV_SOUND_HIT[] = "weapons/grenaderad/molotov_hit.wav";
new const MOLOTOV_SOUND_HIT2[] = "weapons/grenaderad/molotov_hit2.wav";
new const MOLOTOV_SOUND_IDLE[] = "weapons/grenaderad/molotov_idle_loop.wav";
new const MOLOTOV_SOUND_LOOP[] = "weapons/grenaderad/molotov_fire_ground.wav";
new const MOLOTOV_SOUND_FADEOUT[] = "weapons/grenaderad/molotov_fire_fadeout.wav";
new const MOLOTOV_SOUND_EXT[] = "weapons/grenaderad/molotov_extinguish.wav";
public plugin_precache() {
precache_generic("sprites/grenaderad/weapon_molotov.txt");
precache_generic("sprites/grenaderad/hud_molotov.spr");
precache_model(WEAPON_MODEL_VIEW_MOLOTOV);
precache_model(WEAPON_MODEL_PLAYER_MOLOTOV);
precache_model(WEAPON_MODEL_WORLD_MOLOTOV);
MsgIdWeaponList = get_user_msgid("WeaponList");
if (MsgIdWeaponList) {
MsgHookWeaponList = register_message(MsgIdWeaponList, "HookWeaponList");
} else {
FwdRegUserMsg = register_forward(FM_RegUserMsg, "RegUserMsg_Post", true);
}
precache_model(MOLOTOV_SPRITE_XPARK1);
precache_model(MOLOTOV_SPRITE_WICK);
precache_sound(MOLOTOV_SOUND_EXPLODE);
precache_sound(MOLOTOV_SOUND_EXPLODE2);
precache_sound(MOLOTOV_SOUND_HIT);
precache_sound(MOLOTOV_SOUND_HIT2);
precache_sound(MOLOTOV_SOUND_IDLE);
precache_sound(MOLOTOV_SOUND_LOOP);
precache_sound(MOLOTOV_SOUND_FADEOUT);
precache_sound(MOLOTOV_SOUND_EXT);
SpriteFireBall = precache_model(MOLOTOV_SPRITE_FIRE_BALL);
SpriteFireColumn = precache_model(MOLOTOV_SPRITE_FIRE_COLUMN);
SpriteFireExplode = precache_model(MOLOTOV_SPRITE_FIRE_EXPLODE);
//SpriteBeamDisc = precache_model("sprites/shockwave.spr");
}
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
register_clcmd(WEAPON_NEW_NAME, "CmdSelect");
register_clcmd("say 1", "@Command_Molotov"); //test
RegisterHam(Ham_Item_Deploy, WEAPON_NAME, "Item_Deploy_Post", true);
RegisterHam(Ham_Item_Holster, WEAPON_NAME, "Item_Holster_Post", true);
RegisterHam(Ham_Weapon_PrimaryAttack, WEAPON_NAME, "Item_PrimaryAttack_Pre", false);
RegisterHam(Ham_Think, "env_sprite", "FireMolotov_Think_Post", true);
MsgIdAmmoPickup = get_user_msgid("AmmoPickup");
MsgIdWeaponList = get_user_msgid("WeaponList");
MSG_INIT, 0,
WEAPON_NEW_NAME,
AMMO_ID, 1,
-1, -1, GRENADE_SLOT, 4, WEAPON_NEW_ID,
ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE
);
#else
if (FwdRegUserMsg) {
unregister_forward(FM_RegUserMsg, FwdRegUserMsg, true);
}
unregister_message(MsgIdWeaponList, MsgHookWeaponList);
#endif
}
@Command_Molotov(id)
{
giveNade(id);
giveAmmo(id, 9, AMMO_ID, 10); //ammo - max
}
#if WEAPON_NEW_ID != WEAPON_GLOCK
public RegUserMsg_Post(const name[]) {
if (strcmp(name, "WeaponList") == 0) {
MsgIdWeaponList = get_orig_retval();
MsgHookWeaponList = register_message(MsgIdWeaponList, "HookWeaponList");
}
}
public HookWeaponList(const msg_id, const msg_dest, const msg_entity) {
enum {
arg_name = 1,
arg_ammo1,
arg_ammo1_max,
arg_ammo2,
arg_ammo2_max,
arg_slot,
arg_position,
arg_id,
arg_flags,
};
if (msg_dest != MSG_INIT || WeaponIdType:get_msg_arg_int(arg_id) != WEAPON_NEW_ID) {
return PLUGIN_CONTINUE;
}
set_msg_arg_string(arg_name,WEAPON_NEW_NAME);
set_msg_arg_int(arg_ammo1, ARG_BYTE, AMMO_ID);
set_msg_arg_int(arg_ammo1_max, ARG_BYTE, 1);
set_msg_arg_int(arg_ammo2, ARG_BYTE, -1);
set_msg_arg_int(arg_ammo2_max, ARG_BYTE, -1);
set_msg_arg_int(arg_slot, ARG_BYTE, _:GRENADE_SLOT - 1);
set_msg_arg_int(arg_position, ARG_BYTE, 4);
set_msg_arg_int(arg_flags, ARG_BYTE, ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE);
return PLUGIN_CONTINUE;
}
#endif
public CmdSelect(const id) {
if (!is_user_alive(id)) {
return PLUGIN_HANDLED;
}
new item = rg_get_player_item(id, ITEM_CLASSNAME, GRENADE_SLOT);
if (item != 0 && get_member(id, m_pActiveItem) != item) {
rg_switch_weapon(id, item);
}
return PLUGIN_HANDLED;
}
public CSGameRules_CleanUpMap_Post() {
new ent = rg_find_ent_by_class(NULLENT, GRENADE_CLASSNAME, false);
while (ent > 0) {
destroyNade(ent);
ent = rg_find_ent_by_class(ent, GRENADE_CLASSNAME, false);
}
new MolotovFire = rg_find_ent_by_class(NULLENT, MOLOTOV_FIRE_CLASSNAME, false);
while (MolotovFire > 0) {
destroyNade(MolotovFire);
MolotovFire = rg_find_ent_by_class(MolotovFire, MOLOTOV_FIRE_CLASSNAME, false);
}
}
public CBasePlayer_GiveAmmo_Pre(const id, const amount, const name[]) {
if (strcmp(name, AMMO_NAME) != 0) {
return HC_CONTINUE;
}
giveAmmo(id, amount, AMMO_ID, 1);
SetHookChainReturn(ATYPE_INTEGER, AMMO_ID);
return HC_SUPERCEDE;
}
public CBasePlayerWeapon_DefaultDeploy_Pre(const item, const szViewModel[], const szWeaponModel[], const iAnim, const szAnimExt[], const skiplocal) {
if (FClassnameIs(item, ITEM_CLASSNAME)) {
SetHookChainArg(2, ATYPE_STRING, WEAPON_MODEL_VIEW_MOLOTOV);
SetHookChainArg(3, ATYPE_STRING, WEAPON_MODEL_PLAYER_MOLOTOV);
}
new WeaponIdType:wid = WeaponIdType:rg_get_iteminfo(item, ItemInfo_iId);
if (wid != WEAPON_ID && wid != WEAPON_FAKE_ID) {
return HC_CONTINUE;
}
new lastItem = get_member(get_member(item, m_pPlayer), m_pLastItem);
if (is_nullent(lastItem) || item == lastItem) {
return HC_CONTINUE;
}
if (WeaponIdType:rg_get_iteminfo(lastItem, ItemInfo_iId) == WEAPON_ID) {
SetHookChainArg(6, ATYPE_INTEGER, 0);
}
return HC_CONTINUE;
}
public Item_Deploy_Post(const item) { //Вытащил по команде
if (WeaponIdType:rg_get_iteminfo(item, ItemInfo_iId) == WEAPON_FAKE_ID) {
rg_set_iteminfo(item, ItemInfo_iId, WEAPON_ID);
}
new other = get_member(get_member(item, m_pPlayer), m_rgpPlayerItems, GRENADE_SLOT);
while (!is_nullent(other)) {
if (item != other && WeaponIdType:rg_get_iteminfo(other, ItemInfo_iId) == WEAPON_ID) {
rg_set_iteminfo(other, ItemInfo_iId, WEAPON_FAKE_ID);
}
other = get_member(other, m_pNext);
}
}
public Item_Holster_Post(const item) {
new other = get_member(get_member(item, m_pPlayer), m_rgpPlayerItems, GRENADE_SLOT);
while (!is_nullent(other)) {
Molotov_DeleteMuzzleFlash(item);
if (item != other && WeaponIdType:rg_get_iteminfo(other, ItemInfo_iId) == WEAPON_FAKE_ID) {
rg_set_iteminfo(other, ItemInfo_iId, WEAPON_ID);
//rh_emit_sound2(other, other, CHAN_WEAPON, MOLOTOV_SOUND_IDLE, 0.0, ATTN_NONE, SND_STOP);
}
other = get_member(other, m_pNext);
}
}
public Item_PrimaryAttack_Pre(item)
{
if(is_nullent(item)) return;
new other = get_member(item, m_pPlayer);
if(FClassnameIs(item, ITEM_CLASSNAME) && Float: get_member(item, m_flStartThrow) + 0.5 < get_gametime() && get_member(item, m_flStartThrow)){
if(bCreate[other]){
return;
}
if(!bCreate[other]){
Molotov_CreateMuzzleFlash(item, other, MOLOTOV_SPRITE_FIRE_COLUMN, 200.0, 25.0, 0.028, 3);
Molotov_CreateMuzzleFlash(item, other, MOLOTOV_SPRITE_FIRE_BALL, 180.0, 30.0, 0.035, 3);
Molotov_CreateMuzzleFlash(item, other, MOLOTOV_SPRITE_FIRE_BALL, 250.0, 25.0, 0.026, 4);
Molotov_CreateMuzzleFlash(item, other, MOLOTOV_SPRITE_XPARK1, 100.0, 1.0, 0.032, 4);
//rh_emit_sound2(other, other, CHAN_WEAPON, MOLOTOV_SOUND_IDLE);
bCreate[other] = true;
}
}
if(FClassnameIs(item, ITEM_CLASSNAME) && !Float: get_member(item, m_flStartThrow)) {
bCreate[other] = false;
}
}
public CBasePlayer_ThrowGrenade_Pre(const id, const item, const Float:vecSrc[3], const Float:vecThrow[3], const Float:time, const const usEvent) {
if (!FClassnameIs(item, ITEM_CLASSNAME)) {
return HC_CONTINUE;
}
new grenade = throwNade(id, vecSrc, vecThrow, MOLOTOV_THROWTIME);
SetHookChainReturn(ATYPE_INTEGER, grenade);
Molotov_DeleteMuzzleFlash(item);
return HC_SUPERCEDE;
}
public FireMolotov_Think_Post(iEntity)
{
if(is_nullent(iEntity)) return;
set_entvar(iEntity, var_nextthink, get_gametime() + 0.025); //Скорость синка
}
giveNade(const id) {
new item = rg_get_player_item(id, ITEM_CLASSNAME, GRENADE_SLOT);
if (item != 0) {
giveAmmo(id, 1, AMMO_ID, 1);
return item;
}
item = rg_create_entity(WEAPON_NAME, false);
if (is_nullent(item)) {
return NULLENT;
}
new Float:origin[3];
get_entvar(id, var_origin, origin);
set_entvar(item, var_origin, origin);
set_entvar(item, var_spawnflags, get_entvar(item, var_spawnflags) | SF_NORESPAWN);
set_member(item, m_Weapon_iPrimaryAmmoType, AMMO_ID);
set_member(item, m_Weapon_iSecondaryAmmoType, -1);
set_entvar(item, var_classname, ITEM_CLASSNAME);
dllfunc(DLLFunc_Spawn, item);
set_member(item, m_iId, WEAPON_NEW_ID);
rg_set_iteminfo(item, ItemInfo_pszName, WEAPON_NEW_NAME);
rg_set_iteminfo(item, ItemInfo_pszAmmo1, AMMO_NAME);
rg_set_iteminfo(item, ItemInfo_iMaxAmmo1, 1);
rg_set_iteminfo(item, ItemInfo_iId, WEAPON_FAKE_ID);
rg_set_iteminfo(item, ItemInfo_iPosition, 4);
rg_set_iteminfo(item, ItemInfo_iWeight, 1);
dllfunc(DLLFunc_Touch, item, id);
if (get_entvar(item, var_owner) != id) {
set_entvar(item, var_flags, FL_KILLME);
return NULLENT;
}
return item;
}
giveAmmo(const id, const amount, const ammo, const max) {
if (get_entvar(id, var_flags) & FL_SPECTATOR) {
return;
}
new count = get_member(id, m_rgAmmo, ammo);
new add = min(amount, max - count);
if (add < 1) {
return;
}
set_member(id, m_rgAmmo, count + add, ammo);
emessage_begin(MSG_ONE, MsgIdAmmoPickup, .player = id);
ewrite_byte(ammo);
ewrite_byte(add);
emessage_end();
}
throwNade(const id, const Float:vecSrc[3], const Float:vecThrow[3], const Float:time) {
new grenade = rg_create_entity("info_target", false);
if (is_nullent(grenade)) {
return 0;
}
set_entvar(grenade, var_classname, GRENADE_CLASSNAME);
set_entvar(grenade, var_movetype, MOVETYPE_BOUNCE);
set_entvar(grenade, var_solid, SOLID_BBOX);
engfunc(EngFunc_SetOrigin, grenade, vecSrc);
new Float:angles[3];
get_entvar(id, var_angles, angles);
set_entvar(grenade, var_angles, angles);
set_entvar(grenade, var_owner, id);
if (time < 0.1) {
set_entvar(grenade, var_nextthink, get_gametime());
set_entvar(grenade, var_velocity, Float:{0.0, 0.0, 0.0});
} else {
set_entvar(grenade, var_nextthink, get_gametime() + time);
set_entvar(grenade, var_velocity, vecThrow);
}
set_entvar(grenade, var_animtime, get_gametime());
set_entvar(grenade, var_sequence, random_num(1, 7));
set_entvar(grenade, var_framerate, 1.0);
set_entvar(grenade, var_gravity, 0.5);
set_entvar(grenade, var_friction, 0.8);
engfunc(EngFunc_SetModel, grenade, WEAPON_MODEL_WORLD_MOLOTOV);
//set_entvar(grenade, var_dmg, 30.0);
set_entvar(grenade, var_dmgtime, get_gametime() + time);
set_entvar(grenade, var_nextthink, get_gametime() + 0.01);
if (!is_nullent(grenade)) {
Molotov_CreateWickFollow(grenade, MOLOTOV_SPRITE_WICK, 250.0, 25.0, 0.125, 1);
}
SetTouch(grenade, "GrenadeTouch");
SetThink(grenade, "GrenadeThink");
return grenade;
}
public GrenadeTouch(const grenade, const other) {
if(is_nullent(grenade)) return;
if(!is_nullent(other) && FClassnameIs(other, "func_breakable") && get_entvar(other, var_spawnflags) != SF_BREAK_TRIGGER_ONLY)
dllfunc(DLLFunc_Use, other, grenade);
if (!is_nullent(other) && FClassnameIs(other, SMOKE_CLASSNAME_OWNER))
{
//client_print(0, print_chat, "SMOKE TOUCH MOLOTOV");
destroyNade(grenade);
//rh_emit_sound2(this, 0, CHAN_STATIC, MOLOTOV_SOUND_EXT);
}
new iOwner = get_entvar(grenade, var_owner);
if(!is_nullent(other) && ExecuteHam(Ham_IsPlayer, other)) //тут надо фикс по наклону сделать , чтобы приземление было вниз
{
ExecuteHamB(Ham_TakeDamage, other, grenade, iOwner, 2.0, DMG_GRENADE);
set_entvar(grenade, var_dmgtime, 0.0);
set_entvar(grenade, var_nextthink, get_gametime() + 0.01);
return;
}
new Float: flFraction;
new Float: vecOffset[6][3] =
{
{ 0.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0 }, { -1.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0 }, { 0.0, -1.0, 0.0 }, { 0.0, 1.0, 0.0 }
};
new Float: vecEnd[3];
new Float: origin[3];
new Float: vecPlaneNormal[3];
get_entvar(grenade, var_origin, origin);
for(new i = 0; i < 6; i++)
{
vecEnd[0] = origin[0] + vecOffset[i][0];
vecEnd[1] = origin[1] + vecOffset[i][1];
vecEnd[2] = origin[2] + vecOffset[i][2];
engfunc(EngFunc_TraceLine, origin, vecEnd, IGNORE_MONSTERS, grenade, 0);
get_tr2(0, TR_flFraction, flFraction);
if(flFraction >= 1.0)
continue;
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
if(vecPlaneNormal[2] >= 0.5)
{
set_entvar(grenade, var_dmgtime, 0.0);
set_entvar(grenade, var_nextthink, get_gametime() + 0.01);
}
else
rh_emit_sound2(grenade, 0, CHAN_VOICE, random_num(0, 1) ? MOLOTOV_SOUND_HIT : MOLOTOV_SOUND_HIT2);
break;
}
}
public GrenadeThink(const grenade) {
if(is_nullent(grenade)) return;
new Float: origin[3];
get_entvar(grenade, var_origin, origin);
if(engfunc(EngFunc_PointContents, origin) == CONTENTS_SKY )
{
set_entvar(grenade, var_flags, FL_KILLME);
return;
}
set_entvar(grenade, var_nextthink, get_gametime() + 0.1);
if(Float: get_entvar(grenade, var_dmgtime) > get_gametime())
return;
explodeNade(grenade);
}
explodeNade(const grenade) {
if(is_nullent(grenade)) return;
new Float: flFraction;
new Float: vecEnd[3];
new Float: origin[3];
new Float: angles[3];
get_entvar(grenade, var_origin, origin);
get_entvar(grenade, var_angles, angles);
vecEnd = origin;
vecEnd[2] -= 64.0;
engfunc(EngFunc_TraceLine, origin, vecEnd, IGNORE_MONSTERS, grenade, 0);
get_tr2(0, TR_flFraction, flFraction);
if(flFraction >= 1.0)
{
UTIL_CreateExplosion(origin, Float: { 0.0, 0.0, 20.0 }, SpriteFireExplode, 16, 20, TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
//UTIL_CreateExplosion(origin, Float: { 0.0, 0.0, 20.0 }, SpriteFireBall, 14, 20, TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
rh_emit_sound2(grenade, 0, CHAN_STATIC, MOLOTOV_SOUND_EXPLODE);
//set_entvar(grenade, var_flags, FL_KILLME);
destroyNade(grenade);
return;
}
if(engfunc(EngFunc_PointContents, origin) == CONTENTS_WATER)
{
new dropgrenade = rg_create_entity("info_target", false);
if(is_nullent(dropgrenade)) return;
set_entvar(dropgrenade, var_classname, GRENADE_CLASSNAME);
engfunc(EngFunc_SetModel, dropgrenade, WEAPON_MODEL_WORLD_MOLOTOV);
//set_entvar(dropgrenade, var_body, 1);
set_entvar(dropgrenade, var_sequence, 0);
set_entvar(dropgrenade, var_movetype, MOVETYPE_TOSS);
set_entvar(dropgrenade, var_solid, SOLID_TRIGGER);
set_entvar(dropgrenade, var_velocity, Float:{0.0, 0.0, 0.0});
engfunc(EngFunc_SetOrigin, dropgrenade, origin);
set_entvar(dropgrenade, var_angles, angles);
set_entvar(dropgrenade, var_owner, grenade);
SetTouch(dropgrenade, "Drop_ItemMolotov_Touch");
destroyNade(grenade);
return;
}
//new owner = get_entvar(grenade, var_owner); // igrok kinuvshiy grenu
new Float: vecEndPos[3];
new Float: vecPlaneNormal[3];
get_tr2(0, TR_vecEndPos, vecEndPos);
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
UTIL_CreateExplosion(origin, Float: { 0.0, 0.0, 0.0 }, SpriteFireExplode, 10, 20, TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
//UTIL_BeamDisk(origin, SpriteBeamDisc, 1, 5, 5, 5, {0, 0, 80}, 200, 5, MOLOTOV_RADIUS);
rh_emit_sound2(grenade, 0, CHAN_STATIC, MOLOTOV_SOUND_EXPLODE2);
engfunc(EngFunc_VecToAngles, vecPlaneNormal, angles);
for(new i = 0; i < 3; i++)
origin[i] = vecEndPos[i] + vecPlaneNormal[i];
new EntMolotovRadius = rg_create_entity("info_target");
if (is_nullent(EntMolotovRadius))
return;
set_entvar(EntMolotovRadius, var_origin, origin);
set_entvar(EntMolotovRadius, var_angles, angles);
set_entvar(EntMolotovRadius, var_classname, MOLOTOV_FIRE_CLASSNAME);
set_entvar(EntMolotovRadius, var_solid, SOLID_TRIGGER);
set_entvar(EntMolotovRadius, var_movetype, MOVETYPE_TOSS); //тосс для детекта тригера
//set_entvar(EntMolotovRadius, var_effects, EF_NODRAW)
set_entvar(EntMolotovRadius, var_iuser2, get_gametime() + MOLOTOV_DURATION);
set_entvar(EntMolotovRadius, var_fuser1, get_gametime() + 0.3);
engfunc(EngFunc_SetOrigin, EntMolotovRadius, origin);
engfunc(EngFunc_SetSize, EntMolotovRadius, Float:{-100.0, -100.0, -30.0}, Float:{100.0, 100.0, 30.0});
set_entvar(EntMolotovRadius, var_nextthink, get_gametime() + MOLOTOV_PLAYTHINK_TIME);
Molotov_CreateModelFloor(EntMolotovRadius, origin, angles,{1,15,30}, 1, 12);
//suda random radius mini modelski seq 25-50 2-3 wtyki a potom v sinke half timer na razgoranie
//Molotov_CreateDebris(EntMolotovRadius, origin);
SetThink(EntMolotovRadius, "ThinkFire");
SetTouch(EntMolotovRadius, "Molotov_TouchSmoke");
//UTIL_CreateExplosion(origin, Float: { -10.0, 10.0, -50.0 }, SpriteFireBall, 6, 23,TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
//var_iuser1 = Номера энтити огня
//var_iuser2 = тайм самого огня, надо проверку чтобы пока тайм не кончиться не удалять
//var_fuser1 = тайм для UTIl эффектов
//var_iuser3 = Количество моделей горения
//rh_emit_sound2(MolotovFire, 0, CHAN_STATIC, SMOKE_SOUND);
destroyNade(grenade);
}
public ThinkFire(EntMolotovRadius)
{
if (is_nullent(EntMolotovRadius))
return;
static Float: origin[3];
get_entvar(EntMolotovRadius, var_origin, origin);
if(get_entvar(EntMolotovRadius, var_fuser1) <= get_gametime())
{
/*UTIL_CreateExplosion(origin, Float: { 10.0, 5.0, 20.0 }, SpriteFireBall, 5, 31, TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { 5.0, 10.0, 0.0 }, SpriteFireColumn, 4, 23, TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { 0.0, 0.0, 0.0 }, SpriteFireExplode, 5, 28, TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { -15.0, -15.0, -20.0 }, SpriteFireBall, 6, 31, TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { -10.0, -10.0, -35.0 }, SpriteFireColumn, 4, 23,TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { -10.0, 10.0, -50.0 }, SpriteFireBall, 6, 23,TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);*/
UTIL_CreateExplosion(origin, Float: { 3.0, 3.0, 0.0 }, SpriteFireBall, 3, 20, TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { 6.0, 6.0, 0.0 }, SpriteFireColumn, 3, 20,TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
UTIL_CreateExplosion(origin, Float: { 0.0, 0.0, 0.0 }, SpriteFireBall, 5, 23,TE_EXPLFLAG_NODLIGHTS | TE_EXPLFLAG_NOSOUND | TE_EXPLFLAG_NOPARTICLES);
set_entvar(EntMolotovRadius, var_fuser1, get_gametime() + random_float(0.35, 0.45));
}
new iFireNum = get_entvar(EntMolotovRadius, var_iuser3);
if(iFireNum < 3 )
{
new Float: flFraction;
new Float: vecStart[3];
new Float: vecEnd[3];
new Float: vecAngles[3];
new Float: vecViewForward[3];
new Float: vecPlaneNormal[3];
get_entvar(EntMolotovRadius, var_vuser2, vecPlaneNormal);
vecAngles[0] = random_float(-32.0, -128.0); //(-45.0, -135.0);
vecAngles[1] = random_float(0.0, 360.0);
engfunc(EngFunc_MakeVectors, vecAngles);
global_get(glb_v_forward, vecViewForward);
for(new i = 0; i < 3; i++)
{
vecStart[i] = origin[i] + vecPlaneNormal[i] * 32.0;
vecEnd[i] = vecStart[i] + vecViewForward[i] * 128.0;
}
engfunc(EngFunc_TraceLine, vecStart, vecEnd, IGNORE_MONSTERS, EntMolotovRadius, 0);
get_tr2(0, TR_flFraction, flFraction);
get_tr2(0, TR_vecEndPos, vecEnd);
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
if(flFraction >= 1.0 || vecPlaneNormal[2] == -1.0) //flFraction >= 1.0
{
Molotov_CreateModelFloor(EntMolotovRadius, vecEnd, vecAngles,{1,15,30}, random_num(1,50) , random_num(3,8)); // random ili enum - {1,15,30}
set_entvar(EntMolotovRadius, var_iuser3, iFireNum + 1);
//client_print(0, print_chat, "num1 = %d",iFireNum);
}
}
new iDebrisNum = get_entvar(EntMolotovRadius, var_iuser4);
if(iDebrisNum < 40)
{
new Float: flFraction;
new Float: vecStart[3];
new Float: vecEnd[3];
new Float: vecAngles[3];
new Float: vecViewForward[3];
new Float: vecPlaneNormal[3];
get_entvar(EntMolotovRadius, var_vuser1, vecPlaneNormal);
vecAngles[0] = random_float(-32.0, -128.0); //(-45.0, -135.0);
vecAngles[1] = random_float(0.0, 360.0);
engfunc(EngFunc_MakeVectors, vecAngles);
global_get(glb_v_forward, vecViewForward);
for(new i = 0; i < 3; i++)
{
vecStart[i] = origin[i] + vecPlaneNormal[i] * 32.0;
vecEnd[i] = vecStart[i] + vecViewForward[i] * 128.0;
}
engfunc(EngFunc_TraceLine, vecStart, vecEnd, IGNORE_MONSTERS, EntMolotovRadius, 0);
get_tr2(0, TR_flFraction, flFraction);
get_tr2(0, TR_vecEndPos, vecEnd);
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
if(flFraction >= 1.0 || vecPlaneNormal[2] == -1.0)
{
set_entvar(EntMolotovRadius, var_iuser4, iDebrisNum + 1);
//client_print(0, print_chat, "num2 = %i",iFireNum);
Molotov_CreateDebris(EntMolotovRadius, vecEnd);
}
}
new MolotovFire = MaxClients + 1;
new Float:flDuration = get_entvar(EntMolotovRadius, var_iuser2);
if (flDuration <= get_gametime())
{
set_entvar(EntMolotovRadius, var_nextthink, get_gametime() + MOLOTOV_PLAYTHINK_TIME);
SetThink(EntMolotovRadius, "FireRemove");
return;
}
while ((MolotovFire = rg_find_ent_by_class(MolotovFire, MOLOTOV_FIRE_CLASSNAME)))
{
if (get_entvar(MolotovFire, var_owner) != EntMolotovRadius)
continue;
new Float:flDuration = get_entvar(get_entvar(MolotovFire, var_iuser1), var_iuser2);
new parts[3]; get_entvar(MolotovFire, var_vuser1, parts);
if (flDuration >= get_gametime())
for(new i = 0; i < count; i++)
{
parts[i]++;
if(parts[i] > 50)
parts[i] = 1;
}
else
for(new i = 0; i < count; i++)
{
if(parts[i] > 0)
parts[i]++;
if(parts[i] > 50)
parts[i] = 0;
}
set_entvar(MolotovFire, var_vuser1, parts);
set_entvar(MolotovFire, var_body, CalculateModelBodyArr(parts, sizes, count));
}
set_entvar(EntMolotovRadius, var_nextthink, get_gametime() + MOLOTOV_PLAYTHINK_TIME);
}
public FireRemove(EntMolotovRadius)
{
if (is_nullent(EntMolotovRadius))
return;
new MolotovFire = MaxClients + 1;
while ((MolotovFire = rg_find_ent_by_class(MolotovFire, MOLOTOV_FIRE_CLASSNAME)))
{
if (get_entvar(MolotovFire, var_owner) != EntMolotovRadius)
continue;
new parts[3]; get_entvar(MolotovFire, var_vuser1, parts);
for(new i = 0; i < count; i++)
{
if(parts[i] > 0)
parts[i]++;
if(parts[i] > 50)
parts[i] = 0;
}
set_entvar(MolotovFire, var_vuser1, parts);
set_entvar(MolotovFire, var_body, CalculateModelBodyArr(parts, sizes, count));
if((parts[0] | parts[1] | parts[2]) == 0 )
set_entvar(MolotovFire, var_flags, FL_KILLME);
}
set_entvar(EntMolotovRadius, var_nextthink, get_gametime() + MOLOTOV_PLAYTHINK_TIME);
}
public Molotov_TouchSmoke(item, other)
{
if(is_nullent(item) || is_nullent(other)) return;
//set_entvar(item, var_nextthink, get_gametime() + 0.01);
if (!is_nullent(other) && FClassnameIs(other, SMOKE_CLASSNAME_OWNER))
{
//client_print(0, print_chat, "TOUCH smoke");
new MolotovFire = MaxClients + 1;
while ((MolotovFire = rg_find_ent_by_class(MolotovFire, MOLOTOV_FIRE_CLASSNAME)))
{
if (get_entvar(MolotovFire, var_owner) != item)
continue;
set_entvar(MolotovFire, var_flags, FL_KILLME);
}
destroyNade(item);
rh_emit_sound2(item, 0, CHAN_STATIC, MOLOTOV_SOUND_EXT);
SetTouch(item, "");
}
}
public Drop_ItemMolotov_Touch(item, other)
{
if(is_nullent(item) || is_nullent(other)) return;
if(!ExecuteHam(Ham_IsPlayer, other)) return;
new ammo = rg_get_player_item(other, ITEM_CLASSNAME, GRENADE_SLOT);
if(ammo != 0) return;
giveNade(other);
set_entvar(item, var_flags, FL_KILLME);
}
destroyNade(const grenade) {
SetTouch(grenade, "");
SetThink(grenade, "");
set_entvar(grenade, var_flags, FL_KILLME);
new item = MaxClients + 1;
while((item = rg_find_ent_by_class(item, EFFECT_CLASSNAME_WICK)))
{
if(get_entvar(item, var_owner) != grenade)
continue;
if(!is_nullent(item))
set_entvar(item, var_flags, FL_KILLME);
}
}
stock rg_get_player_item(const id, const classname[], const InventorySlotType:slot = NONE_SLOT) {
new item = get_member(id, m_rgpPlayerItems, slot);
while (!is_nullent(item)) {
if (FClassnameIs(item, classname)) {
return item;
}
item = get_member(item, m_pNext);
}
return 0;
}
stock UTIL_WeapoList(
const type,
const player,
const name[],
const ammo1,
const maxAmmo1,
const ammo2,
const maxammo2,
const InventorySlotType:slot,
const position,
const WeaponIdType:id,
const flags
) {
message_begin(type, MsgIdWeaponList, .player = player);
write_string(name);
write_byte(ammo1);
write_byte(maxAmmo1);
write_byte(ammo2);
write_byte(maxammo2);
write_byte(_:slot - 1);
write_byte(position);
write_byte(_:id);
write_byte(flags);
message_end();
}
/*stock UTIL_BeamDisk(const Float:origin[3], const sprite, const framerate, const life, const width, const amplitude, const color[3], const bright, const speed, const Float:size) {
message_begin_f(MSG_BROADCAST, SVC_TEMPENTITY, origin, 0);
write_byte(TE_BEAMDISK);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2]);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2] + size);
write_short(sprite);
write_byte(0);
write_byte(framerate);
write_byte(life);
write_byte(width);
write_byte(amplitude);
write_byte(color[0]);
write_byte(color[1]);
write_byte(color[2]);
write_byte(bright);
write_byte(speed);
message_end();
}*/
stock UTIL_CreateExplosion(const Float: origin[3], const Float: vecOriginOffset[3] = { 0.0, 0.0, 0.0 }, const isModelIndex, const iScale, const iFrameRate, const iFlags)
{
message_begin_f(MSG_BROADCAST, SVC_TEMPENTITY, origin, 0);
write_byte(TE_EXPLOSION);
write_coord_f(origin[0] + vecOriginOffset[0]);
write_coord_f(origin[1] + vecOriginOffset[1]);
write_coord_f(origin[2] + vecOriginOffset[2]);
write_short(isModelIndex);
write_byte(iScale);
write_byte(iFrameRate);
write_byte(iFlags);
message_end();
}
/*stock UTIL_Flame(const Float: origin[3], const isModelIndex)
{
message_begin_f(MSG_BROADCAST, SVC_TEMPENTITY, origin, 0);
write_byte(TE_SPRITE);
write_coord_f(origin[0]);
write_coord_f(origin[1]);
write_coord_f(origin[2]);
write_short(isModelIndex);
write_byte(5);
write_byte(255);
message_end();
}*/
stock Molotov_CreateModelFloor(owner, Float: origin[3], Float: angles[3], parts[3], sequence, time )
{
if(is_nullent(owner)) return;
new Float: flFraction;
new Float: vecEndPos[3];
new Float: vecPlaneNormal[3];
new Float: vecAngles[3];
vecEndPos = origin;
vecEndPos[2] -= 256.0;
engfunc(EngFunc_TraceLine, origin, vecEndPos, IGNORE_MONSTERS, owner, 0);
get_tr2(0, TR_flFraction, flFraction);
if(flFraction >= 1.0)
return;
get_tr2(0, TR_vecEndPos, vecEndPos);
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
engfunc(EngFunc_VecToAngles, vecPlaneNormal, vecAngles);
for(new i = 0; i < 3; i++)
origin[i] = vecEndPos[i] + vecPlaneNormal[i];
FloorOriginAngles(origin, angles);
new MolotovFire = rg_create_entity("info_target", false);
if(is_nullent(MolotovFire)) return;
//new parts[3] = {1,15,30};
set_entvar(MolotovFire, var_classname, MOLOTOV_FIRE_CLASSNAME);
set_entvar(MolotovFire, var_owner, owner);
engfunc(EngFunc_SetOrigin, MolotovFire, origin);
engfunc(EngFunc_SetModel, MolotovFire, MOLOTOV_MODEL_FLOOR);
set_entvar(MolotovFire, var_angles, angles);
set_entvar(MolotovFire, var_sequence, sequence);
set_entvar(MolotovFire, var_rendermode, kRenderTransAdd);
set_entvar(MolotovFire, var_renderamt, 255.0);
set_entvar(MolotovFire, var_vuser1, parts);
set_entvar(MolotovFire, var_iuser1, MolotovFire);
set_entvar(MolotovFire, var_iuser2, get_gametime() + time);
dllfunc(DLLFunc_Spawn, MolotovFire);
}
stock Molotov_CreateDebris(owner, Float: origin[3])
{
if(is_nullent(owner)) return;
new Float: flFraction;
//new Float: flCurTime = get_gametime();
new Float: vecEndPos[3];
new Float: vecPlaneNormal[3];
new Float: vecAngles[3];
vecEndPos = origin;
vecEndPos[2] -= 256.0;
engfunc(EngFunc_TraceLine, origin, vecEndPos, IGNORE_MONSTERS, owner, 0);
get_tr2(0, TR_flFraction, flFraction);
if(flFraction >= 1.0)
return;
get_tr2(0, TR_vecEndPos, vecEndPos);
get_tr2(0, TR_vecPlaneNormal, vecPlaneNormal);
engfunc(EngFunc_VecToAngles, vecPlaneNormal, vecAngles);
for(new i = 0; i < 3; i++)
origin[i] = vecEndPos[i] + vecPlaneNormal[i];
vecAngles[0] = -vecAngles[0] + 180.0;
vecAngles[2] = -vecAngles[2] + 180.0;
new iFire = rg_create_entity("env_sprite", true);
if(is_nullent(iFire))
return;
set_entvar(iFire, var_classname, MOLOTOV_FIRE_CLASSNAME);
set_entvar(iFire, var_origin, origin);
set_entvar(iFire, var_angles, vecAngles);
set_entvar(iFire, var_model, MOLOTOV_SPRITE_FIRE_GROUND);
set_entvar(iFire, var_spawnflags, SF_SPRITE_STARTON);
//set_entvar(iFire, var_teleport_time, flCurTime + 10.0);
set_entvar(iFire, var_owner, owner);
set_entvar(iFire, var_rendermode, kRenderTransAdd);
set_entvar(iFire, var_renderamt, 255.0);
set_entvar(iFire, var_framerate, 12.0 );
set_entvar(iFire, var_scale, 0.5);
//set_entvar(iFire, var_nextthink, get_gametime() + 0.015);
dllfunc(DLLFunc_Spawn, iFire);
/*if(owner < MaxClients)
set_entvar(iFire, var_vuser1, vecPlaneNormal);*/
}
stock Molotov_CreateMuzzleFlash(item, other, const models[], Float:renderamt, Float:frame, Float:scale, body)
{
if(is_nullent(item)) return;
new iMuzzleFlash = rg_create_entity("env_sprite", true);
if(is_nullent(iMuzzleFlash)) return;
set_entvar(iMuzzleFlash, var_model, models);
set_entvar(iMuzzleFlash, var_classname, EFFECT_CLASSNAME_MUZZLEFLASH);
set_entvar(iMuzzleFlash, var_spawnflags, SF_SPRITE_STARTON);
set_entvar(iMuzzleFlash, var_rendermode, kRenderTransAdd);
set_entvar(iMuzzleFlash, var_renderamt, renderamt);
set_entvar(iMuzzleFlash, var_framerate, frame);
set_entvar(iMuzzleFlash, var_scale, scale);
set_entvar(iMuzzleFlash, var_owner, other);
set_entvar(iMuzzleFlash, var_aiment, other);
set_entvar(iMuzzleFlash, var_body, body); // аттач к фитилю кости в модельке ( 4- самый низ * 3 - середина * 2 - выше серидины * 1 -самое горлышко)
dllfunc(DLLFunc_Spawn, iMuzzleFlash);
}
stock Molotov_CreateWickFollow(other, const models[], Float:renderamt, Float:frame, Float:scale, body)
{
new iWickFollow = rg_create_entity("env_sprite", true);
if(is_nullent(iWickFollow)) return;
set_entvar(iWickFollow, var_model, models);
//engfunc(EngFunc_SetModel, iWickFollow, models);
set_entvar(iWickFollow, var_classname, EFFECT_CLASSNAME_WICK);
set_entvar(iWickFollow, var_spawnflags, SF_SPRITE_STARTON);
set_entvar(iWickFollow, var_rendermode, kRenderTransAdd);
set_entvar(iWickFollow, var_renderamt, renderamt);
set_entvar(iWickFollow, var_framerate, frame);
set_entvar(iWickFollow, var_scale, scale);
set_entvar(iWickFollow, var_owner, other);
set_entvar(iWickFollow, var_aiment, other);
set_entvar(iWickFollow, var_body, body);
dllfunc(DLLFunc_Spawn, iWickFollow);
}
stock Molotov_DeleteMuzzleFlash(other)
{
new item = MaxClients + 1;
while((item = rg_find_ent_by_class(item, EFFECT_CLASSNAME_MUZZLEFLASH)))
{
if(get_entvar(item, var_owner) != get_entvar(other, var_owner))
continue;
if(!is_nullent(item))
set_entvar(item, var_flags, FL_KILLME);
}
}
public CalculateModelBodyArr(const parts[], const sizes[],const count){//Если есть массив который нужно выбрать
static bodyInt32 = 0, temp=0, it=0, tempCount;bodyInt32=0;tempCount = count;
while (tempCount--){
if (sizes[tempCount] == 1)continue;
temp = parts[tempCount]; for (it=0;it<tempCount;it++)temp *= sizes[it];
bodyInt32 += temp;
}
return bodyInt32;
}
new const Float:SubFloat[3] = {0.0, 0.0, 9999.0};
stock FloorOriginAngles(Float:flOrigin[3], Float:fAngles[3]){
static Float:traceto[3], Float:fraction, Float:original_forward[3], Float:angles2[3], Float:right[3], Float:up[3], Float:fwd[3];
new iTrace = create_tr2();if(!iTrace)return;
xs_vec_sub(flOrigin, SubFloat, traceto);
engfunc(EngFunc_TraceLine, flOrigin, traceto, IGNORE_MONSTERS|IGNORE_MISSILE, 0, iTrace);
get_tr2(iTrace, TR_flFraction, fraction);
if(fraction == 1.0){free_tr2(iTrace);return;}
angle_vector(fAngles, ANGLEVECTOR_FORWARD, original_forward);
get_tr2(iTrace, TR_vecPlaneNormal, up); free_tr2(iTrace);
xs_vec_cross(original_forward, up, right);
xs_vec_cross(up, right, fwd);
vector_to_angle(fwd, fAngles);
vector_to_angle(right, angles2);
fAngles[2] = -1.0 * angles2[0];
}
В этой теме было размещено решение! Перейти к решению.