Author Topic: Something to add please...  (Read 346 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
Something to add please...
« on: October 18, 2015, 04:13:49 am »


               

Hello hello! 


 


Here I got yet another question I was wondering about!


 


Here I got this script:


 




void main()

{

    object oTarget;

    object oSpawn;

 

    // Get the creature who triggered this event.

    object oPC = GetEnteringObject();

 

    // Only fire for (real) PCs.

    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )

        return;

 

    // Abort if the PC is not exactly at stage 11 of journal quest "p012".

    if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYp012") != 11 )

        return;

 

    // Spawn "creature014".

    oTarget = GetWaypointByTag("WP_ELVIRAGHOST");

    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature014", GetLocation(oTarget));

}

 



 



So here is my question then!

 

Is it possible to put a check in there that if the npc is already spawned in there won't be another spawned in till its dead or after an ammount of time?

 


               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Something to add please...
« Reply #1 on: October 18, 2015, 05:05:07 am »


               

This should work, just fill in the NPC's real tag where noted.

 

 



void main()


{


object oTarget;


object oSpawn;




// Get the creature who triggered this event.


object oPC = GetEnteringObject();




// Only fire for (real) PCs.


if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )


return;




// Abort if the PC is not exactly at stage 11 of journal quest "p012".


if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYp012") != 11 )


return;




// Spawn "creature014".

if (GetNearestObjectByTag("replace_with_NPC's_tag")!= OBJECT_INVALID)

{

oTarget = GetWaypointByTag("WP_ELVIRAGHOST");

oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "creature014", GetLocation(oTarget));

}

return;

}




               
               

               
            

Legacy_bdtgazo

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Something to add please...
« Reply #2 on: October 21, 2015, 04:19:02 pm »


               

Isn't that checking to see if the npc IS there?  Meaning it will only spawn the npc if another npc with the same tag is already there?


               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Something to add please...
« Reply #3 on: October 21, 2015, 04:26:23 pm »


               

Yeah, sorry. "if (GetNearestObjectByTag("replace_with_NPC's_tag")!= OBJECT_INVALID)" should instead be "if (GetNearestObjectByTag("replace_with_NPC's_tag")== OBJECT_INVALID)". I'd sent the correction to the OP over a Skype chat and din't think to post back here. '<img'>