Hey!
I am looking for some kind of sacrifice script.
Details
When a PC kills (anything) inside a designated area (trigger) a door opens.
Can someone go pro at this? ![]()
Hey!
I am looking for some kind of sacrifice script.
Details
When a PC kills (anything) inside a designated area (trigger) a door opens.
Can someone go pro at this? ![]()
Is it the PC or the creature that need to be in the trigger, or both?
Assuming it's the creature - in the trigger OnEnter, set a local int flag on the creature. OnExit, delete it. Add a line to the OnDeath script(s) to open the door if the flag is set.
Have a go. Happy to help if your script doesn't work.
Hey and thanks for the reply!
Proleric: I have figured this out myself, but I would need some help with the actual script. I tried it myself with Lilac's, but it didn't work. :/
If you post what you have so far, I'm sure we can fix it.
I have nothing, because Lilac only set integers on the PC and not the creature/npc.
But this is what I got
//Put this script OnDeath
void main()
{
object oPC = GetLastKiller();
if (!GetIsPC(oPC)) return;
if (GetLocalInt(oPC, "int_sacrifice_tri")!= 1)
return;
object oTarget;
oTarget = GetObjectByTag("sv_barrow_door");
AssignCommand(oTarget, ActionOpenDoor(oTarget));
}
OK, so heading in the right direction, just needs some work.
If you already have many different creatures that might be sacrificed, you probably want to make one script change that affects them all automatically. That avoids all the work of editing the creature templates and instances.
So, I suggest you change the default OnDeath script nw_c2_default7.
Open the script editor > Open An Existing File > check "All Resources" > select "nw_c2_default7" > OK to the warning.
Replace this line
craft_drop_items(oKiller);
with this:
craft_drop_items(oKiller);
// Custom code
if (GetLocalInt(OBJECT_SELF, "int_sacrifice_tri")!= 1)
return;
object oTarget;
oTarget = GetObjectByTag("sv_barrow_door");
AssignCommand(GetModule(), AssignCommand(oTarget, ActionOpenDoor(oTarget)));
// End custom code
You'll see I've made two changes to your code.
Firstly, OBJECT_SELF is the creature who just died.
Secondly, I've told the module to issue your action to the door. This is a trick to avoid the general rule that orders issued by dead creatures get cancelled.
I can make it a little tidier, if you like.
Perfect, it works. I made the OnEnter and OnExit trigger aswell! Thank you! ![]()
Nice. One thing you might want to do is reverse the sense of the "if", remove the return; and enclose the rest in brackets {}. As it stands if you add any code after that it won't run unless this variable is set. It just looks like a frustrating bug waiting to happen.
e.g.:
if (GetLocalInt(OBJECT_SELF, "int_sacrifice_tri")) {
object oTarget;
oTarget = GetObjectByTag("sv_barrow_door");
AssignCommand(GetModule(), AssignCommand(oTarget, ActionOpenDoor(oTarget)));
}
Also, why not just assign the opendoor command to the module?
Yeah, totally with you and not trying to criticize
I could see him adding more code down there for another feature and not getting the results he expected. that's a bit more than tidiness. It's a functional difference which may save Fog some pain later on. Just trying to save future pain ...