コード例 #1
0
ファイル: g_trigger.cpp プロジェクト: drone-pl/ufoai
/**
 * @brief Touch trigger
 * @sa SP_trigger_touch
 */
static bool Touch_TouchTrigger (Edict* self, Edict* activator)
{
	/* these actors should really not be able to trigger this - they don't move anymore */
	assert(!G_IsDead(activator));

	self->_owner = G_EdictsFindTargetEntity(self->target);
	if (!self->owner()) {
		gi.DPrintf("Target '%s' wasn't found for %s\n", self->target, self->classname);
		G_FreeEdict(self);
		return false;
	}

	if (self->owner()->flags & FL_CLIENTACTION) {
		G_ActorSetClientAction(activator, self->owner());
	} else if (!(self->spawnflags & TRIGGER_TOUCH_ONCE) || self->touchedNext == nullptr) {
		if (!self->owner()->use) {
			gi.DPrintf("Owner of %s doesn't have a use function\n", self->classname);
			G_FreeEdict(self);
			return false;
		}
		G_UseEdict(self->owner(), activator);
	}

	return false;
}
コード例 #2
0
ファイル: g_trigger.cpp プロジェクト: drone-pl/ufoai
static void Reset_TouchTrigger (Edict* self, Edict* activator)
{
	/* fire the use function on leaving the trigger area */
	if (activator != nullptr && (self->owner()->flags & FL_CLIENTACTION))
		G_ActorSetClientAction(activator, nullptr);
	else if ((self->spawnflags & TRIGGER_TOUCH_ONCE) && self->touchedNext == nullptr)
		G_UseEdict(self->owner(), activator);
}
コード例 #3
0
ファイル: g_func.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief Trigger to open the door we are standing in front of it
 * @sa CL_DoorOpen
 * @sa LE_CloseOpen
 * @sa CL_ActorDoorAction
 * @sa AI_CheckUsingDoor
 */
static bool Touch_DoorTrigger (edict_t *self, edict_t *activator)
{
    if (self->owner && self->owner->inuse) {
        if (G_IsAI(activator)) {
            /* let the ai interact with the door */
            if (self->flags & FL_GROUPSLAVE)
                self = self->groupMaster;
            if (AI_CheckUsingDoor(activator, self->owner))
                G_ActorUseDoor(activator, self->owner);
            /* we don't want the client action stuff to be send for ai actors */
            return false;
        } else {
            /* prepare for client action */
            G_ActorSetClientAction(activator, self->owner);
            return true;
        }
    }
    return false;
}
コード例 #4
0
ファイル: g_func.cpp プロジェクト: MyWifeRules/ufoai-1
/**
 * @brief Left the door trigger zone - reset the client action
 * @param self The trigger
 * @param activator The edict that left the trigger zone
 */
static void Reset_DoorTrigger (edict_t *self, edict_t *activator)
{
    if (activator->clientAction == self->owner)
        G_ActorSetClientAction(activator, NULL);
}