Raised This Month: $ Target: $400
 0% 

Getting light entities in a map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-24-2013 , 23:57   Re: Getting light entities in a map
Reply With Quote #1

You could try just "style" as the key name.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
MousePad
Junior Member
Join Date: Apr 2012
Old 04-25-2013 , 00:08   Re: Getting light entities in a map
Reply With Quote #2

Wow thanks, never thought of it

I tried:
DispatchKeyValue( iEnt, "style", "0")
DispatchKeyValue( iEnt, "style", 0)

In both cases m_iStyle did actually change to 0. But the lights still flicker. I also tried:
DispatchKeyValue( iEnt, "pattern", "m")

No luck
MousePad is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-25-2013 , 00:55   Re: Getting light entities in a map
Reply With Quote #3

Try to create all stuff in plugin_precache, it sometimes help.

Also, sources may help you
Code:
//
// Cache user-entity-field values until spawn is called.
//
void CLight :: KeyValue( KeyValueData* pkvd)
{
	if (FStrEq(pkvd->szKeyName, "style"))
	{
		m_iStyle = atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "pitch"))
	{
		pev->angles.x = atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if (FStrEq(pkvd->szKeyName, "pattern"))
	{
		m_iszPattern = ALLOC_STRING( pkvd->szValue );
		pkvd->fHandled = TRUE;
	}
	else
	{
		CPointEntity::KeyValue( pkvd );
	}
}

/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) LIGHT_START_OFF
Non-displayed light.
Default light value is 300
Default style is 0
If targeted, it will toggle between on or off.
*/

void CLight :: Spawn( void )
{
	if (FStringNull(pev->targetname))
	{       // inert light
		REMOVE_ENTITY(ENT(pev));
		return;
	}
	
	if (m_iStyle >= 32)
	{
//		CHANGE_METHOD(ENT(pev), em_use, light_use);
		if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF))
			LIGHT_STYLE(m_iStyle, "a");
		else if (m_iszPattern)
			LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern ));
		else
			LIGHT_STYLE(m_iStyle, "m");
	}
}


void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	if (m_iStyle >= 32)
	{
		if ( !ShouldToggle( useType, !FBitSet(pev->spawnflags, SF_LIGHT_START_OFF) ) )
			return;

		if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF))
		{
			if (m_iszPattern)
				LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern ));
			else
				LIGHT_STYLE(m_iStyle, "m");
			ClearBits(pev->spawnflags, SF_LIGHT_START_OFF);
		}
		else
		{
			LIGHT_STYLE(m_iStyle, "a");
			SetBits(pev->spawnflags, SF_LIGHT_START_OFF);
		}
	}
}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
MousePad
Junior Member
Join Date: Apr 2012
Old 04-25-2013 , 02:03   Re: Getting light entities in a map
Reply With Quote #4

Connor I had already looked at that source but never paid attention to the >=32 check. That gave me new hopes but things still fail even when I set m_iStyle to 32 and try with and without dispatching a pattern value. The Dispatch functions are working and I can successfully set these values before entity spawn. Nonetheless, the lights still flicker.
Also I really don't understand what you mean when you say create everything in plugin_precache.
MousePad is offline
MousePad
Junior Member
Join Date: Apr 2012
Old 04-25-2013 , 22:14   Re: Getting light entities in a map
Reply With Quote #5

Maybe this can make things simpler. Is there any way I can remove a light entity as if it never existed in the map? Seems like when you remove light entities their lighting still remains. Just like when they don't have a targetname they get removed in the engine anyway.
MousePad is offline
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 10:48.


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