Aller au contenu

Photo

Traps damaging NPCs of the same faction


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Terrorble

Terrorble
  • Members
  • 194 messages
I am using Sir Elric's trap system from the vault.  Great in many ways, but when I spawn traps in an area with NPCs from a custom faction, they trigger the traps when they walk over them.  My intention is to have the traps friendly to the NPCs of those areas.  They are already hostile to the player, which is what I want.

Sir Elric's system spawns the traps from the area OnEnter essentially using CreateTrapAtLocation().  It uses STANDARD_FACTION_HOSTILE in the arguments.  I am guessing the problem has something to do with that.

How do I get around this?

#2
WhiZard

WhiZard
  • Members
  • 1 204 messages
Make the traps infinite and use a custom script that checks for the custom faction on that area. If the triggering occurs have the trap destroyed.

If these traps are supposed to be friendly to a PC in any circumstance, then the issue is much more complicated.

#3
Terrorble

Terrorble
  • Members
  • 194 messages
Okay, so make the trap infinite, then you are saying in its impact script, have it compare the entering NPC's faction to say TRAP_SAFE_FACTION|string|... that I set on the area to see whether it activates or not? Or by "custom script" did you mean something else?

To do this, I could add a check to the 50ish nw_t1_ or x2_t1_ scripts to see if they should activate, right? (Sir Elric's system doesn't specify a custom impact script, so it uses the defaults)

#4
WhiZard

WhiZard
  • Members
  • 1 204 messages

Terrorble wrote...

Okay, so make the trap infinite, then you are saying in its impact script, have it compare the entering NPC's faction to say TRAP_SAFE_FACTION|string|... that I set on the area to see whether it activates or not? Or by "custom script" did you mean something else?

To do this, I could add a check to the 50ish nw_t1_ or x2_t1_ scripts to see if they should activate, right? (Sir Elric's system doesn't specify a custom impact script, so it uses the defaults)


Here is an impact script that directly looks up the script for you.

void main()
{
object oEnter = GetEnteringObject();
object oFaction = GetLocalObject(GetArea(oEnter), "TrapFaction");
if(GetFirstFactionMember(oFaction) == GetFirstFactionMember(oEnter)) return;
ExecuteScript(Get2DAString("traps", "TrapScript", GetTrapBaseType(OBJECT_SELF)), OBJECT_SELF);
DestroyObject(OBJECT_SELF, 0.1);
}

#5
ffbj

ffbj
  • Members
  • 593 messages
You could also just write an exception in the script that looks at a local int on the npc. So No_TrapMe
set to 1 on any npc you want to not activate the trap. In this way you could have some npc's that would trigger the trap, or maybe a friendly npc guide that shows the pc, (sets the local No_TrapMe) in a certain area for a certain time where the traps are, so they can be avoided, or perhaps recovered. You can always make them unrecoverable, if you want.

Regarding traps:
http://nwvault.ign.c....Detail&id=3632

Modifié par ffbj, 23 avril 2013 - 12:52 .


#6
WhiZard

WhiZard
  • Members
  • 1 204 messages
Good point. I was envisioning the worst (multiple custom factions with the possibility of members from one faction invading another factions area). If you want the members resilient to all traps set in this manner you could also up the reputation between both them and the standard faction of the trap. You will never trigger traps of a friendly faction, though you will trigger them for a neutral or hostile faction.

#7
Terrorble

Terrorble
  • Members
  • 194 messages

WhiZard wrote...

void main()
{
object oEnter = GetEnteringObject();
object oFaction = GetLocalObject(GetArea(oEnter), "TrapFaction");
if(GetFirstFactionMember(oFaction) == GetFirstFactionMember(oEnter)) return;
ExecuteScript(Get2DAString("traps", "TrapScript", GetTrapBaseType(OBJECT_SELF)), OBJECT_SELF);
DestroyObject(OBJECT_SELF, 0.1);
}


This worked nicely for me.  Comparing first faction members of two objects and firing the trap script based on its 2da entry were both new ways to do things I previously didn't know - got my answer and learned a few things at the same time.
Thanks to both of you.