Author Topic: Getting a TAG, jumping an NPC  (Read 315 times)

Legacy_Ulos Doom

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Getting a TAG, jumping an NPC
« on: August 19, 2013, 08:24:31 pm »


               I've been wrestling with a problem the past few days. I have a Serial Killer quest, where an NPC (the killer) randomly spawns into one of nine possible points. Once spawned, the killer selects from a set of NPC's who his victim is (based on spawnpoint location), and the PC has to speak to different NPC's to find out who is missing, and discover clues as to the killers location.

The basic system is working fine. The killer randomly spawns. The victim is randomly chosen, correct custom tokens are set for conversations, and the clues lead to the killers location.

But I want eye candy in the form of the dead body of the victim. Yes, I could simply spawn in a standard corpse, but the effect is much nicer using the body of an NPC that PC's converse with and know.

I've (hopefully) tracked the problem down to two snippets of code.

The first snippet is from the Killers OnSpawn handle:

// Get the Killer's location
    string sKillerSpawnPoint = GetTag(GetNearestObject(OBJECT_TYPE_WAYPOINT,oKiller));
    SetLocalString(oMod,"KILLER_SPAWN_POINT",sKillerSpawnPoint);
//

The second snippet is from am script executed after the killer selects his victim when spawning in.

// Get the TAG of the wapoint to jump to and find the WP.
    string sSpawn = GetLocalString(oMod,"KILLER_SPAWN_POINT");
    object oWay   = GetObjectByTag(sSpawn);
//

What I'm trying to do is get the TAG of the killers Waypoint (I have no way of knowing the tag in advance) so I can jump the victim to the killer, kill the victim with EffectDeath, have the victims body stay through the SetIsDestroyable function. What I'm getting is a dead body where the victim was when the script was called.

Is my code correct in storing the waypoint of the killer and retreiving it in the victims script? If more information is needed, let me know.

Thanks in advance.
               
               

               
            

Legacy_Ulos Doom

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Getting a TAG, jumping an NPC
« Reply #1 on: August 19, 2013, 08:33:56 pm »


               Thought perhaps I should post the entire script for jumping the victim... haven't used these forums in years '<img'>

void main()
{
   object oMod = GetModule();
   object oVictim = GetObjectByTag("feniwien");

   if (!GetIsObjectValid(oVictim))
       return;

   // Get the TAG of the wapoint to jump to and find the WP.
   string sSpawn = GetLocalString(oMod,"KILLER_SPAWN_POINT");
   object oWay   = GetObjectByTag(sSpawn);

   // Get the LOCATION of the WP for the bllodstain
   location lWay = GetLocation(oWay);

   // Deathe effect
   effect eDeath = EffectDeath();

   // Jump the NPC to the Killers Spawnpoint, kill, and add bloodstain
   AssignCommand(oVictim,ClearAllActions());
   AssignCommand(oVictim,ActionJumpToObject(oWay));
   CreateObject(OBJECT_TYPE_PLACEABLE,"bloodstain",lWay);
   ApplyEffectToObject(DURATION_TYPE_INSTANT,eDeath,oVictim);
}
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Getting a TAG, jumping an NPC
« Reply #2 on: August 19, 2013, 09:30:20 pm »


               If you have already moved the killer to his spawnpoint. Instead of jumping the victim to the spawnpoint would it not be simpler to just jump the victim to the killer?
               
               

               
            

Legacy_Ulos Doom

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Getting a TAG, jumping an NPC
« Reply #3 on: August 19, 2013, 10:25:39 pm »


               I've tried that, but perhaps didn't do it correctly. I've changed the code for the jump so many times now my head is spinning. Something like this:

location lKiller = GetLocation(oKiller);
AssignCommand(oVictim(ActionJumpToLocation,lKiller));

I was previously firing all the spawn scripts when the module loaded. The victim was selected, but I wasn't getting a body. Now I'm firing the killers spawn script from a conversation and getting a body. but not where I want it.
               
               

               
            

Legacy_Ulos Doom

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Getting a TAG, jumping an NPC
« Reply #4 on: August 20, 2013, 02:16:27 am »


               Figured it out. I put a DelayCommand before EffectDeath. The short delay did the trick.