Raised This Month: $32 Target: $400
 8% 

How to copy smoke entity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 07-10-2022 , 14:43   How to copy smoke entity?
Reply With Quote #1

In an effort to make smoke more dense, I am looking for a way to copy its entity sprite. I ended up with the code:

Code:
public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
	register_forward(FM_EmitSound, "emit_sound_event");
}
public emit_sound_event(orig_ent, channel, const sample[], Float:vol, Float:attn, flags, pitch)
{
	static const smoke_sound[] = "weapons/sg_explode.wav";
	static num = 0;
	new ent;
	new Float:origin[3], Float:angles[3], Float:velocity[3];
	new model[64], classname[64];

	entity_get_string(orig_ent, EV_SZ_classname, classname, charsmax(classname));
	entity_get_string(orig_ent, EV_SZ_model, model, charsmax(model));
	// client_print(1, print_chat, "#%d on channel %d: %s", ++num, channel, sample);
	if(channel != CHAN_WEAPON || !equal(sample, smoke_sound))
		return;
	/* copy smoke info */
	entity_get_vector(orig_ent, EV_VEC_origin, origin);
	entity_get_vector(orig_ent, EV_VEC_angles, angles);
	entity_get_string(orig_ent, EV_SZ_model, model, charsmax(model));
	// client_print(1, print_chat, "classname: %s, model: %s", classname, model);
	entity_set_vector(orig_ent, EV_VEC_origin, Float:{9999.9, 9999.9, 9999.9});
	ent = create_entity("info_target");
	if(ent == 0)
		return;
	entity_set_string(ent, EV_SZ_classname, classname);
	entity_set_origin(ent, origin);
	entity_set_vector(ent, EV_VEC_angles, angles);
	entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
	entity_set_int(ent, EV_INT_solid, SOLID_NOT);
	entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1);
	entity_set_model(ent, model);
	velocity[0] = random_float(-120.0, 120.0);
	velocity[1] = random_float(-120.0, 120.0);
	velocity[2] = random_float(200.0, 300.0);
	entity_set_vector(ent, EV_VEC_velocity, velocity);
	call_think(ent);
	emit_sound(ent, channel, sample, vol, attn, flags, pitch);
	client_print(1, print_chat, "reached end of the function");
}
The entity (smoke grenade) is created and placed in the right place, the sound is also emitted. But I do not see the smoke puff. I was hoping that creating an entity with appropriate classname would be enough to trigger "think" process. Forcing call_think() has no effect too. I decided to move on and tried to write my own logic for the smoke with no luck. The first image is message "TE_SMOKE" and the second one is message "TE_SPRITE". I want the smoke to be gray, not with black background or white.



If possible I would like to just copy an entity and trigger default engine behavior. Otherwise, here is the code of messages:

Code:
public add_smoke(ent)
{
	new Float:origin[3]
	new smokescale = 50;
	new fps = 2;
	new brightness = 20;
	new smoke;
	
	// new smoke_path[] = "sprites/unrealsmoke_2.spr";
	// smoke = precache_model(smoke_path);
	new smoke_path[] = "sprites/smoke.spr";
	smoke = engfunc(EngFunc_PrecacheModel, smoke_path);
	entity_get_vector(ent, EV_VEC_origin, origin);
	// show smoke
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	// write_byte(TE_SMOKE);
	write_byte(TE_SPRITE);
	engfunc(EngFunc_WriteCoord, origin[0]);
	engfunc(EngFunc_WriteCoord, origin[1]);
	engfunc(EngFunc_WriteCoord, origin[2]);
	write_short(smoke);
	write_byte(smokescale);
	// write_byte(fps);
	write_byte(brightness);
	message_end();
}

Last edited by damage220; 07-10-2022 at 14:52.
damage220 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode