How to trigger a door/container trap at distance?

i’m making a spell that allows you to open doors and containers at medium distance. Also, it needs to trigger the trap of the placeable if it haves one.

I tried with a Scripthidden object and the ActionInteractObject which work perfectly except for one thing, it also triggers floor traps. I just need to trigger the trap of the placeable.

This is the code:

object oTarget = GetSpellTargetObject();

	int nMagicImmunity = FALSE;
	int nFeedbackRef = 248757;
	int nResist =  GetDoorFlag(oTarget,DOOR_FLAG_RESIST_KNOCK);
		nMagicImmunity = TRUE;
		nFeedbackRef = 83887;	
	else if(GetLocked(oTarget))//THE PLACEABLE IS LOCKED, YOU CAN'T OPEN IT
		nMagicImmunity = TRUE;
		nFeedbackRef = 248758;	
	if(!GetIsOpen(oTarget) && !nMagicImmunity)
		effect eVis = EffectVisualEffect(VFX_HIT_SPELL_TRANSMUTATION);
		ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
		//object oOpener = CreateObject(OBJECT_TYPE_CREATURE,"c_invisiblenode",GetLocation(oTarget));
			AssignCommand(oTarget, ActionOpenDoor(oTarget));
			AssignCommand(oTarget, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));
			&& GetTrapOneShot(oTarget)
			&& GetTrapDisarmable(oTarget))
		nFeedbackRef = 248760;
1 Like

For doors you can specify by using ActionOpenDoor. I am certain there is a function for containers in the same direction too but I don’t know it off the top of my head.

1 Like

You should be able to use ActionUnlockObject, I think.

1 Like

I’m already using ActionOpenDoor but it doesn’t trigger the trap, only ActionInteractObject triggers the trap but the placeable can’t use that.

I have updated the main post to make it easier to understand what i want and what i have.

Have you tried ActionUnlockObject?

I think I’m out of sync with the question. What’s you end state? You have a spell and the result is … you want the door/placeable open and/or unlocked? The traps set on the door/placeable triggered (or not triggered)? View placeable inventory from a distance? Which floor traps are being triggered when you ActionInteractObject?

Open a door or container and also trigger the trap of the door or container if it haves one. Just that.

I have updated the main post to make it easier to understand what i want and what i have.

Ok, got it. I don’t have a lot of experience with that, and I put a question in with the experts, but my first guess would be to check if there target (door/placeable) had a active tap, then either deactivate it and play a VFX in its place (to simulate trap trigger), or if it’s a projectile trap, trigger the projectile trap. I’m looking at various trap manipulation functions, I’ll let you know if I figure out something better.

Another option I can think of off the top of my head is to potentially create an invisible creature to interact with the door and trigger the stock script, then destroy the creature. Side effect might be it triggers any other traps it happens to step on in the vicinity of the door/placeable.

Possible pseudocode solution, since you’re just looking for the visual effects and not the damage:

  • Cast your custom spell
  • If target is placeable or door, check if trapped and if trap is active
  • Get base trap type and pair it with an appropriate vfx
  • disable the trap
  • unlock/open the target
  • play VFX at target location
  • reset trap after specified delay

I tried that and does indeed trigger other traps, also, it may break the game if the container/door trigger something else like a cutscene or door when interacting with the ActionInteractObject.

Yeah, i think that i’m going to go with disabling the trap and playing a vfx at the location. That part is commented in the code that i posted above, inside the if(GetIsTrapped(oTarget)).

My bad, I’ve been on my phone all day and didn’t even see the code. That could’ve saved me a lot of phone-typing. Sorry 'bout that!