Raised This Month: $51 Target: $400
 12% 

Lasermine problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeNq!
Senior Member
Join Date: Mar 2009
Old 10-27-2016 , 17:50   Lasermine problem
Reply With Quote #1

Hello,

I have a problem. When I place a lasermine on the wall it doesn't work as it should cause one player standing in it's beam blocks it - other players standing behind him do not take any damage...

Code:

Code:
public Spawn(id){	
	id -= TASK_PLANT
	
	if (!CreateCheck(id))
		return PLUGIN_HANDLED;
	
	new i_Ent = engfunc(EngFunc_CreateNamedEntity,g_EntMine);
	if(!i_Ent)
	{
		client_print(id,print_chat,"[Laesrmine Debug] Can't Create Entity");
		return PLUGIN_HANDLED_MAIN;
	}
	set_pev(i_Ent,pev_classname,ENT_CLASS_NAME);
	
	engfunc(EngFunc_SetModel,i_Ent,ENT_MODELS);
	
	set_pev(i_Ent,pev_solid,SOLID_NOT);
	set_pev(i_Ent,pev_movetype,MOVETYPE_FLY);
	
	set_pev(i_Ent,pev_frame,0);
	set_pev(i_Ent,pev_body,3);
	set_pev(i_Ent,pev_sequence,7);
	set_pev(i_Ent,pev_framerate,0);
	
	set_pev(i_Ent,pev_takedamage,DAMAGE_YES);
	
	set_pev(i_Ent,pev_dmg,100.0);
	set_user_health(i_Ent,get_pcvar_num(g_LHEALTH));
	
	new Float:vOrigin[3];
	new Float:vNewOrigin[3], Float:vNormal[3], Float:vTraceDirection[3], Float:vTraceEnd[3],Float:vEntAngles[3];
	
	pev( id, pev_origin, vOrigin );
	velocity_by_aim( id, 128, vTraceDirection );
	xs_vec_add( vTraceDirection, vOrigin, vTraceEnd );
	
	engfunc( EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0 );
	
	new Float:fFraction;
	get_tr2( 0, TR_flFraction, fFraction );
	
	if ( fFraction < 1.0 )
	{
		get_tr2( 0, TR_vecEndPos, vTraceEnd );
		get_tr2( 0, TR_vecPlaneNormal, vNormal );
	}
	
	xs_vec_mul_scalar( vNormal, 8.0, vNormal );
	xs_vec_add( vTraceEnd, vNormal, vNewOrigin );
	
	engfunc(EngFunc_SetSize, i_Ent, Float:{ -4.0, -4.0, -4.0 }, Float:{ 4.0, 4.0, 4.0 } );
	engfunc(EngFunc_SetOrigin, i_Ent, vNewOrigin );
	
	vector_to_angle(vNormal,vEntAngles );
	set_pev(i_Ent,pev_angles,vEntAngles );
	
	new Float:vBeamEnd[3], Float:vTracedBeamEnd[3];
	
	xs_vec_mul_scalar(vNormal, 8192.0, vNormal );
	xs_vec_add( vNewOrigin, vNormal, vBeamEnd );
	
	engfunc( EngFunc_TraceLine, vNewOrigin, vBeamEnd, IGNORE_MONSTERS, -1, 0 );
	
	get_tr2( 0, TR_vecPlaneNormal, vNormal );
	get_tr2( 0, TR_vecEndPos, vTracedBeamEnd );
	
	set_pev(i_Ent, LASERMINE_OWNER, id );
	set_pev(i_Ent,LASERMINE_BEAMENDPOINT,vTracedBeamEnd);
	set_pev(i_Ent,LASERMINE_TEAM,int:cs_get_user_team(id));
	new Float:fCurrTime = get_gametime();
	
	set_pev(i_Ent,LASERMINE_POWERUP, fCurrTime + 2.5 );
	
	set_pev(i_Ent,LASERMINE_STEP,POWERUP_THINK);
	set_pev(i_Ent,pev_nextthink, fCurrTime + 0.2 );
	
	PlaySound(i_Ent,POWERUP_SOUND );
	g_deployed[id]++;
	g_havemine[id]--;
	DeleteTask(id);
	
	return 1;
}

bool:CreateCheck(id){
	if (!CanCheck(id,0)) return false;
	
	if (g_deployed[id] >= get_pcvar_num(g_LAMMO))
	{
		client_print(id, print_chat, "%s %s",CHATTAG,STR_MAXDEPLOY);
		return false;
	}
	
	new Float:vTraceDirection[3], Float:vTraceEnd[3],Float:vOrigin[3];
	
	pev( id, pev_origin, vOrigin );
	velocity_by_aim( id, 128, vTraceDirection );
	xs_vec_add( vTraceDirection, vOrigin, vTraceEnd );
	
	engfunc( EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0 );
	
	new Float:fFraction,Float:vTraceNormal[3];
	get_tr2( 0, TR_flFraction, fFraction );
	
	if ( fFraction < 1.0 )
	{
		get_tr2( 0, TR_vecEndPos, vTraceEnd );
		get_tr2( 0, TR_vecPlaneNormal, vTraceNormal );
		
		return true;
	}
	
	client_print(id, print_chat, "%s %s",CHATTAG,STR_PLANTWALL)
	DeleteTask(id);
	
	return false;
}

public ltm_Think(i_Ent){
	if ( !pev_valid( i_Ent ) )
		return FMRES_IGNORED;
	
	new EntityName[32];
	pev( i_Ent, pev_classname, EntityName, 31);
	
	if ( !equal( EntityName, ENT_CLASS_NAME ) )
		return FMRES_IGNORED;
	
	static Float:fCurrTime;
	fCurrTime = get_gametime();
	
	switch( pev( i_Ent, LASERMINE_STEP ) )
	{
		case POWERUP_THINK :
		{
			new Float:fPowerupTime;
			pev( i_Ent, LASERMINE_POWERUP, fPowerupTime );
			
			if( fCurrTime > fPowerupTime )
			{
				set_pev( i_Ent, pev_solid, SOLID_BBOX );
				set_pev( i_Ent, LASERMINE_STEP, BEAMBREAK_THINK );
				
				PlaySound( i_Ent, ACTIVATE_SOUND );
			}
			if(get_pcvar_num(g_LGLOW)!=0)
			{
				new owner = pev(i_Ent, LASERMINE_OWNER);
				if(is_vip_flags(owner)){
					set_rendering(i_Ent,kRenderFxGlowShell,255,0,0,kRenderNormal,5);
				}		
				else {
					set_rendering(i_Ent,kRenderFxGlowShell,255,255,0,kRenderNormal,5);
				}
			}
			set_pev( i_Ent, pev_nextthink, fCurrTime + 0.1 );
		}
		case BEAMBREAK_THINK :
		{
			static Float:vEnd[3],Float:vOrigin[3];
			pev( i_Ent, pev_origin, vOrigin );
			pev( i_Ent, LASERMINE_BEAMENDPOINT, vEnd );
			
			static iHit, Float:fFraction;
			engfunc( EngFunc_TraceLine, vOrigin, vEnd, DONT_IGNORE_MONSTERS, i_Ent, 0 );
			
			get_tr2( 0, TR_flFraction, fFraction );
			iHit = get_tr2( 0, TR_pHit );
			
			if ( fFraction < 1.0 )
			{
				if(pev_valid(iHit))
				{
					pev( iHit, pev_classname, EntityName, 31 );
					
					if( !equal( EntityName, ENT_CLASS_NAME ) )
					{
						set_pev( i_Ent, pev_enemy, iHit );
						CreateLaserDamage(i_Ent,iHit);
						set_pev( i_Ent, pev_nextthink, fCurrTime + random_float( 0.1, 0.3 ) );
					}
				}
		         }
			if(get_pcvar_num(g_LDMGMODE)!=0){
				if(pev(i_Ent,LASERMINE_HITING) != iHit)
					set_pev(i_Ent,LASERMINE_HITING,iHit);
			}			
			if ( pev_valid( i_Ent ))
			{
				static Float:fHealth;
				pev( i_Ent, pev_health, fHealth );
				
				if( fHealth <= 0.0 || (pev(i_Ent,pev_flags) & FL_KILLME))
				{
					set_pev( i_Ent, LASERMINE_STEP, EXPLOSE_THINK );
					set_pev( i_Ent, pev_nextthink, fCurrTime + random_float( 0.1, 0.3 ) );
				}
				
				static Float:fBeamthink;
				pev( i_Ent, LASERMINE_BEAMTHINK, fBeamthink );
				
				if( fBeamthink < fCurrTime && get_pcvar_num(g_LVISIBLE))
				{
					DrawLaser(i_Ent, vOrigin, vEnd );
					set_pev( i_Ent, LASERMINE_BEAMTHINK, fCurrTime + 0.1 );
				}
				set_pev( i_Ent, pev_nextthink, fCurrTime + 0.01 );
			}
		}
		case EXPLOSE_THINK:
		{
			set_pev( i_Ent, pev_nextthink, 0.0 );
			PlaySound( i_Ent, STOP_SOUND );
			g_deployed[pev(i_Ent,LASERMINE_OWNER)]--;
			CreateExplosion( i_Ent );
			RemoveEntity( i_Ent );
		}
	}
	return FMRES_IGNORED;
}

CreateLaserDamage(iCurrent,isHit){	
	if(!game_started() || isHit < 0 ) return PLUGIN_CONTINUE
	switch(get_pcvar_num(g_LDMGMODE))
	{
		case 1:
		{
			if(pev(iCurrent,LASERMINE_HITING) == isHit)
				return PLUGIN_CONTINUE
		}
		case 2:
		{
			if(pev(iCurrent,LASERMINE_HITING) == isHit)
			{
				static Float:cnt
				static now,htime;now = floatround(get_gametime())
				
				pev(iCurrent,LASERMINE_COUNT,cnt)
				htime = floatround(cnt)
				if(now - htime < get_pcvar_num(g_LDSEC))
				{
					return PLUGIN_CONTINUE;
					}else{
					set_pev(iCurrent,LASERMINE_COUNT,get_gametime())
				}
			}
			else
				set_pev(iCurrent,LASERMINE_COUNT,get_gametime())
		}
	}
	
	new Float:vOrigin[3],Float:vEnd[3]
	pev(iCurrent,pev_origin,vOrigin)
	pev(iCurrent,pev_vuser1,vEnd)
	
	new teamid = pev(iCurrent, LASERMINE_TEAM)
	
	new szClassName[32]
	new Alive,God
	new iHitTeam,iHitHP,id
	new hitscore
	
	
	szClassName[0] = '^0'
	pev(isHit,pev_classname,szClassName,32)
	
	if((pev(isHit, pev_flags) & (FL_CLIENT | FL_FAKECLIENT | FL_MONSTER))){
		Alive = pev_user_alive(isHit)
		God = get_user_godmode(isHit)
		if(!Alive || God) return PLUGIN_CONTINUE
		
		iHitTeam = int:cs_get_user_team(isHit)
		iHitHP = pev_user_health(isHit) - get_pcvar_num(g_LDMG)
		id = pev(iCurrent,LASERMINE_OWNER)//, szNetName[32]
		if(iHitHP <= 0)
		{
			if(iHitTeam != teamid)
			{
				emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
				hitscore = 1
				cs_set_user_money(id,cs_get_user_money(id) + get_pcvar_num(g_LFMONEY))
				set_score(id,isHit,hitscore,iHitHP)
			}
			else{
				if(get_pcvar_num(g_LFF))
				{
					emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
					hitscore = -1									
					cs_set_user_money(id,cs_get_user_money(id) - get_pcvar_num(g_LFMONEY))
					set_score(id,isHit,hitscore,iHitHP)
				}
			}
		} 
		else if(iHitTeam != teamid || get_pcvar_num(g_LFF)){
			emit_sound(isHit, CHAN_WEAPON, ENT_SOUND4, 1.0, ATTN_NORM, 0, PITCH_NORM )
			set_user_health(isHit,iHitHP)
			set_pev(iCurrent,LASERMINE_HITING,isHit);
			
			engfunc(EngFunc_MessageBegin,MSG_ONE_UNRELIABLE,g_msgDamage,{0.0,0.0,0.0},isHit);
			write_byte(get_pcvar_num(g_LDMG))
			write_byte(get_pcvar_num(g_LDMG))
			write_long(DMG_BULLET)
			engfunc(EngFunc_WriteCoord,vOrigin[0])
			engfunc(EngFunc_WriteCoord,vOrigin[1])
			engfunc(EngFunc_WriteCoord,vOrigin[2])
			message_end()
		}
	}
	else if(equal(szClassName, ENT_CLASS_NAME3)){
		new hl;
		hl = pev_user_health(isHit);
		set_user_health(isHit,hl-get_pcvar_num(g_LDMG));
	}
	return PLUGIN_CONTINUE
}
Please help me.
Grettings
BeNq! is offline
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-03-2016 , 07:55   Re: Lasermine problem
Reply With Quote #2

Can it be repaired?
BeNq! is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-03-2016 , 08:23   Re: Lasermine problem
Reply With Quote #3

It's just not broken since a laser can never get trough a solid object, just like in real life..

Ever had a laser pen and shined with it on your hand? Funny thing is that the laser can't actually get trough your hand aswell.

What it can do, is burn away some flesh if it's powerfull enough and from the moment the laser burned trough the flesh, it will reach the other person standing next to him.


So what i actually try to say is: The player who touches the laser, has to die first before the laser is actually able to reach the other player.

Anyways, if that is what you want, YES IT IS POSSIBLE, and NO i don't know how to fix it.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Reply



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:33.


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