Author Topic: OnDeath (of a creature) -> teleport PC - Not working, if damage delt is > 11 (partly solved)  (Read 417 times)

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               Hello all,
I seem to miss something within the NWN-system:

I have a (working) script, which teleports the PC, who delt the killing strike to the creature, to a certain waypoint.

EDIT (added code):
So, this goes into the OnDeath of a monster:

void main()
{
// Control-FX
object oCreature = OBJECT_SELF;
effect eHealVis = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eHealVis,oCreature);

// The teleportation
object oPC = GetLastKiller();
location lTarget;
object oTarget;
oTarget = GetWaypointByTag("WP_Arrive_PortTest" );
lTarget = GetLocation(oTarget);
AssignCommand(oPC, ClearAllActions());
DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));
}

My test victim is goblin with HPs set to 1.
It works nicely, as long as the damage delt is 11 or  less. (In the case of my test monster, one hit is enough). As soon as the delt damage is higher, the script does fire (added some control things like an effect), but the teleport does not happen.

Edit 2: It's probably the number of negative HPs: 0 to -10, the script works, -11 HPs and lower, the teleport is not done.

Is there an explanation to this?

Is there a workaround for this?

Thanks.
               
               

               


                     Modifié par TheOneBlackRider, 20 février 2014 - 08:07 .
                     
                  


            

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               Found the culprit!
It's the delay time (which I want, so there is not an instant teleport) in:
DelayCommand(3.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));

A delay < 3.0 seems to work, regardless of the damage delt!

But in the end, I don't understand, why. Why would the system give a monster more time to execute all of the script, when it has HPs up to -10 and lower (minus) damage results (-12, -13, ...) triggers the "completely destroy this object"-part a bit earlier ( and thus the ActionJump-comand is not available anymore). There is no bleeding possibility for monsters (which would slow the final termination of the object - I guess), is there?

And in general: Is there a way to stop monsters from doing the "dying sequence" (without setting them to plot)? I mean, they take damage until the HPs are down to 0 but then a custom script forces on them another behaviour but dying?
               
               

               


                     Modifié par TheOneBlackRider, 19 février 2014 - 02:51 .
                     
                  


            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0


               I expect that when you sudden death the poor guy (11 or more points at once) he's no longer an object by the time three seconds has passed. On death runs as the dead creature. Try assigning the
delay command to the module or area or something else.

Cheers,
meaglyn
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0


               Or AssignCommand(oPC, DelayCommand(3.0, ActionJumpToLocation(lTarget)));
               
               

               
            

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               

meaglyn wrote...

Or AssignCommand(oPC, DelayCommand(3.0, ActionJumpToLocation(lTarget)));


STRIKE! This way, the delay can be set to any lenght regardless of the damage delt / (minus) HPs of the creature.
Smart to pass this over to the living PC! ':wizard:'

The question, which still remains is: Why is there more time for a script to work itself through, if the HPs are not lower than -10???

Anyways: Thanks alot!
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0


               

TheOneBlackRider wrote...


The question, which still remains is: Why is there more time for a script to work itself through, if the HPs are not lower than -10???



meaglyn already answered that.   Have you ever noticed that when a creature dies he slowly fades away,  unless massive damage is dealt  in which case he explodes and in gone right away.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0


               

TheOneBlackRider wrote...

Smart to pass this over to the living PC! ':wizard:'



Actually, you're much better off passing execution to the Area. Prevents all sorts of problematic scenarios where a pc might, inadvertently or not, prevent the jump from occuring. Search for the ForceJump functin I've posted on these boards for a guaranteed-to-work approach.

Funky
               
               

               
            

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               

Lightfoot8 wrote...

TheOneBlackRider wrote...

The
question, which still remains is: Why is there more time for a script
to work itself through, if the HPs are not lower than -10???



meaglyn
already answered that.   Have you ever noticed that when a creature
dies he slowly fades away,  unless massive damage is dealt  in which
case he explodes and in gone right away.


I made a test and couldn't really see a differance between a death caused by a punch (creature getting with its HPs not lower than -10) and a critical hit (sending the creatures HPs to something around -25 in my case).
Both deaths do the "falling over" and "fade" after 5 seconds thing.

But thanks anyways.


FunkySwerve wrote...

TheOneBlackRider wrote...
Smart to pass this over to the living PC! ':wizard:'



Actually, you're much better off passing execution to the Area. Prevents all sorts of problematic scenarios where a pc might, inadvertently or not, prevent the jump from occuring. Search for the ForceJump functin I've posted on these boards for a guaranteed-to-work approach.

Funky


Found it! Thanks.
I've done some scripting (hobby wise), but never passed anything to the area. Seems to be even better than the PC. But I would want to avoid a heartbeat script, though.

How would you do that?

OArea = GetAarea...(aso)
AssignCommand(oArea, DelayCommand(3.0, [GetPC...] ActionJumpToLocation(lTarget))); ???

Sorry, but I'm a bit lame here here....':whistle:'
               
               

               
            

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               



Actually, you're much better off passing execution to the Area. Prevents all sorts of problematic scenarios where a pc might, inadvertently or not, prevent the jump from occuring. Search for the ForceJump functin I've posted on these boards for a guaranteed-to-work approach.


Funky




 


I'd like to pick this up again and like to get some more "education" here:


I found the ForceJump script, but I don't manage to see, how this is handeled by the area...


 


I do have this creature. If it dies, it initiates the teleportation of the "killer" (and all party members in the same area) to be jumped to a new area. It's working (via AssignCommand -> player), but I still would like to know, how this could be handeled by an area, possibly without a heartbeat-script.


I'm stuck here.


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0


               As suggested earlier in the thread, you can assign actions to the module e.g.

AssignCommand(GetModule(), ...

The module action queue is very reliable, in my experience, and does not wait for a heartbeat before executing.

It's good practice to avoid assigning objects which might clear actions, go dormant or cease to exist in the near future (especially on death). When the area is about to change, I'd even have second thoughts about assigning actions to the area, though no doubt it usually works.

Obviously, it's sometimes necessary to assign commands to (living) creatures. I suspect that's true in your case, because ActionJumpToLocation (or whatever) cannot be assigned to the module. To make this robust, I'd run a snippet something like this on the player (not the dying creature!):
 
ExecuteScript("myscript", oPC);
myscript might read:
 
 
void main()
{
  object oCreature = OBJECT_SELF;
  if (!GetIsPC(oCreature)) SetAILevel(oCreature, AI_LEVEL_NORMAL);
  ClearAllActions(TRUE);
  ActionJumpToLocation.... // Or whatever actions are required
  ActionDoCommand(SetCommandable(TRUE));
  SetCommandable(FALSE);
}
This ensures that the creature AI is responsive, and that the action queue cannot be cleared or interfered with until the desired actions are complete. If the creature is not a PC, you may also need to set the plot flag temporarily, if it's imperative that the creature is not killed until the actions are complete.

Hopefully, you now see how fragile objects (other than the module) can be, when it comes to actions. I must emphasise that even this level of robustness does not work reliably for dead or dying creatures, whereas module actions are dependable.
               
               

               
            

Legacy_TheOneBlackRider

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0


               

Thank you, Proleric!