示例#1
0
void DispatchTouch( edict_t *pentTouched, edict_t *pentOther )
{
	if ( gTouchDisabled )
		return;

	CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched);
	CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE( pentOther );

	//LLAPb changes begin
	if ( pEntity && pOther && ! ((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME) )
	{
		if (!pEntity->scripted || !ScriptsActive())
		{
			pEntity->Touch( pOther );

			return;
		}

		GenericFunction *pfn = pEntity->my_script->funcs->GetFn(M_TOUCH);

		if (!pfn)
		{
			pEntity->Touch( pOther );

			return;
		}

		if (NoErrors())
		{
			pfn->PreExecute();

			int i = ENTINDEX(pentTouched), j = ENTINDEX(pentOther);

			if (pfn->argc > 0)
				pfn->PassArg(0, Type(&i, _INT));

			if (pfn->argc > 1)
				pfn->PassArg(1, Type(&j, _INT));

			switch (pfn->specification)
			{
			case SPECIFICATION_BEFORE:
				pfn->Execute();
				pEntity->Touch( pOther );
				break;

			case SPECIFICATION_INSTEAD:
				pfn->Execute();
				break;

			default:
				pEntity->Touch( pOther );
				pfn->Execute();
				break;
			}
		}
		else
			pEntity->Touch( pOther );
	}
	//LLAPb changes end
}
示例#2
0
//LLAPb: this function is bullshit!!! Must of all calls of "Use" are coming not from engine. F**k!!!
void DispatchUse( edict_t *pentUsed, edict_t *pentOther )
{
	CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed);
	CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther);

	//LLAPb begin
	if (pEntity && !(pEntity->pev->flags & FL_KILLME) )
	{
		if (!pEntity->scripted || !ScriptsActive())
		{
			pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );

			return;
		}

		GenericFunction *pfn = pEntity->my_script->funcs->GetFn(M_USE);

		if (!pfn)
		{
			pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );

			return;
		}

		if (NoErrors())
		{
			pfn->PreExecute();

			int i = ENTINDEX(pentUsed), j = ENTINDEX(pentOther), t = (int)USE_TOGGLE;
			double v = 0;

			if (pfn->argc > 0)
				pfn->PassArg(0, Type(&i, _INT));

			if (pfn->argc > 1)
				pfn->PassArg(1, Type(&j, _INT));

			if (pfn->argc > 2)
				pfn->PassArg(2, Type(&t, _INT));

			if (pfn->argc > 3)
				pfn->PassArg(3, Type(&v, DOUBLE));

			switch (pfn->specification)
			{
			case SPECIFICATION_BEFORE:
				pfn->Execute();
				pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );
				break;

			case SPECIFICATION_INSTEAD:
				pfn->Execute();
				break;

			default:
				pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );
				pfn->Execute();
				break;
			}
		}
		else
			pEntity->Use( pOther, pOther, USE_TOGGLE, 0 );
	}
	//LLAPb end
}
示例#3
0
//LLAPb: I do not trust this callback, there's a  lots of directly calls of "Spawn" in code. Must be reason...
int DispatchSpawn( edict_t *pent )
{
	CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);

	if (pEntity)
	{
		// Initialize these or entities who don't link to the world won't have anything in here
		pEntity->pev->absmin = pEntity->pev->origin - Vector(1,1,1);
		pEntity->pev->absmax = pEntity->pev->origin + Vector(1,1,1);


		//LLAPb begin
		if (!FStringNull(pEntity->script_file))
		{
			pEntity->PRECACHE_SCRIPT((char*)STRING(pEntity->script_file));
		}

		if (pEntity->scripted && ScriptsActive())
		{
			GenericFunction *pfn = pEntity->my_script->funcs->GetFn(M_SPAWN);

			if (!pfn)
			{
				pEntity->Spawn();

				goto LLAPb_end;
			}

			if (NoErrors())
			{
				pfn->PreExecute();

				int i = ENTINDEX(pent);

				if (pfn->argc > 0)
					pfn->PassArg(0, Type(&i, _INT));

				switch (pfn->specification)
				{
				case SPECIFICATION_BEFORE:
					pfn->Execute();
					pEntity->Spawn();
					break;

				case SPECIFICATION_INSTEAD:
					pfn->Execute();
					break;

				default:
					pEntity->Spawn();
					pfn->Execute();
					break;
				}
			}
			else
				pEntity->Spawn();
		}
		else
			pEntity->Spawn();

		LLAPb_end:
		//LLAPb end


		// Try to get the pointer again, in case the spawn function deleted the entity.
		// UNDONE: Spawn() should really return a code to ask that the entity be deleted, but
		// that would touch too much code for me to do that right now.
		pEntity = (CBaseEntity *)GET_PRIVATE(pent);

		if ( pEntity )
		{
			pEntity->pev->colormap = ENTINDEX(pent);

			if ( g_pGameRules && !g_pGameRules->IsAllowedToSpawn( pEntity ) )
				return -1;	// return that this entity should be deleted
			if ( pEntity->pev->flags & FL_KILLME )
				return -1;
		}
		// Handle global stuff here
		if ( pEntity && pEntity->pev->globalname ) 
		{
			const globalentity_t *pGlobal = gGlobalState.EntityFromTable( pEntity->pev->globalname );
			if ( pGlobal )
			{
				// Already dead? delete
				if ( pGlobal->state == GLOBAL_DEAD )
					return -1;
				else if ( !FStrEq( STRING(gpGlobals->mapname), pGlobal->levelName ) )
					pEntity->MakeDormant();	// Hasn't been moved to this level yet, wait but stay alive
				// In this level & not dead, continue on as normal
			}
			else
			{
				// Spawned entities default to 'On'
				gGlobalState.EntityAdd( pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON );
//				ALERT( at_console, "Added global entity %s (%s)\n", STRING(pEntity->pev->classname), STRING(pEntity->pev->globalname) );
			}
		}

	}

	return 0;
}