Author Topic: Is It Possible To Move A Creature After It Spawns In?  (Read 440 times)

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« on: October 05, 2012, 11:04:37 am »


               Excuse me? Can anyone out there help me please?

Is it possible to tell a script to move a creature to the next waypoint, after you have told the script to spawn a creature in (via "CreateObjectVoid" e.t.c) at the first waypoint?

I'm using Gestalt Scripting here.
For e.g. Creature spawns in at waypoint 1, (Cue fancy spell effect to create the illusion of the spawn in) does a particular action,


"DelayCommand(12.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "creature01", lTarget));

eEffect = EffectVisualEffect(VFX_IMP_HEALING_X);

DelayCommand(12.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, lTarget));"



then moves on to the next waypoint.


"GestaltActionMove(14.00,oCreature1,GetWaypointByTag("CreatureWalkPoint1"),
FALSE,0.0,2.0);
"



So I created the next waypoint, with correct tags e.t.c (I even have said creature(s) setup in my custom pallette too) and scripted it, but my creature(s) won't move to their next waypoint? :-/
Is nwn scripting capable of this at all, and if so, then what script should I use?

If not, then why not? It seems quite a simple thing for a script to achieve.
I don't see why it shouldn't. *sigh!* :-/
               
               

               


                     Modifié par MissJaded, 05 octobre 2012 - 10:19 .
                     
                  


            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #1 on: October 05, 2012, 01:00:45 pm »


               Try adding this and see if this works.

location lNewLocation = GetWayPointByTag("CreatureWalkPoint1");
DelayCommand(14.0, AssignCommand(MoveToNewLocation( lNewLocation,creature01)));

I also know there is a default ai to make npc's walk waypoints. but it has been a long time since i've used it maybe some one else can tell you how.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #2 on: October 05, 2012, 02:39:44 pm »


               To do it while using Gestalt, you will need to create a function to Spawn the creature and them move him to the waypoint.

Then you can just use that function in place of the CreateObjectVoid function.

basicly what patty has wrapped into a function.

Edit:

void CreateCreatureAndMoveToWayPoint( string sResRef, location lCreateAt, object oWayPoint)
{
    object oCreature = CreateObject(OBJECT_TYPE_CREATURE,sResRef, lCreateAt,);
   AssignCommand( oCreature, ClearAllActions());
   AssignCommand( oCreature, ActionMoveToObject( oWayPoint);

}
               
               

               


                     Modifié par Lightfoot8, 05 octobre 2012 - 04:41 .
                     
                  


            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #3 on: October 05, 2012, 09:30:06 pm »


               You are just spawning in a NPC and just want it to walk waypoints try this http://nwn.wikia.com/wiki/Waypoints_used_with_walkwaypoints and see if it helps.
               
               

               
            

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #4 on: October 06, 2012, 04:36:24 am »


               Thanks for trying to help me guys, but absolutely nothng in either of your replies has helped me whatsoever!'<img'>
I tried to include your short scripts into mine, but I just ended up with compile errors on all accounts.'<img'>


Pattycake1 wrote...

You are just spawning in a NPC and just want it to walk waypoints try this http://nwn.wikia.com/wiki/Waypoints_used_with_walkwaypoints and see if it helps.


I couldn't find anything in this link which helped me either. *sigh!* :-/


I think the info which relates to what my problem is, is this. (I quote)

NPC won't walk to its waypoints

In the onspawn script of your NPC ensure that following two lines are still commented out (e.g. the // is still before the lines, and the line is displayed green)

    SetSpawnInCondition (NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
    SetSpawnInCondition (NW_FLAG_AMBIENT_ANIMATIONS);



I don't understand that at all!'<img'>
I mean, I know where to look for the  "OnSpawn" Script of the  NPC, and there is already a default script in there.
But I have absolutely no idea what to do with it. :-/

And what on earth do I do with those 2 "SetSpawnInCondition" scripts above??
AM I supposed to put them in my script somehow? Where do I put them??
I'm completely clueless here!'<img'>

So as you may realize, It's evident that I've never really had much experiecne with scripting, and everyrime I try to read up about it, I just get too confused. So I just give up. *sigh!*
The only thing I'll ever understand is just copying script lines from a program like Lilac Souls Script Generator which I've used to help with simple scripting, plus Gestalt when someone can tell me what lines to use, and of course copying bits of scripts which others like yourselves
have kindly written out for me.
               
               

               


                     Modifié par MissJaded, 06 octobre 2012 - 03:47 .
                     
                  


            

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #5 on: October 06, 2012, 04:54:41 am »


               Okay, I wasn't going to show this at first becasue it's something I keep working on every now and again just on and off because I keep running into stop points just casue I keep running out of ideas.
But I think now, that if I show you guys what my script is, then you would know where to put or change my script so that I can have my 2 wolf creatures move to their next waypoint after they spawn in, since I personally have absolutely no idea how to do this! :-/

----------------------------------------------------------------------------------------------------------------------------------------
#include "nw_i0_2q4luskan"
#include "in_g_cutscene"

void main()
{
object oPC = GetEnteringObject();
//Let's declare the wolves ahead of time to clean things up.
object oWolf3 = GetObjectByTag("WinterWolf3");
object oWolf4 = GetObjectByTag("WinterWolf4");

object oWolf5 = GetObjectByTag("WinterWolf5");
object oWolf6 = GetObjectByTag("WinterWolf6");


  GestaltStartCutscene(oPC, "cranecam");


   GestaltCameraCrane  (0.0,
                        0.0, 3.0, 90.0, 3.0,
                        0.0, 3.0, 90.0, 3.0,
                        8.0, 10.0,
                        oPC, 0);


if (!GetIsPC(oPC)) return;

//Added this, setting duration to the end just after the last ActionMove
//commands will be completed firing (take their fDelay time and add the fTime
//used in the function).
GestaltInvisibility (0.0, oPC, 40.0);

//For the movement commands we will have to add WPs if we want the camera to
//be somewhere other than the wolves. For simplicity, I will just use the
//existing WPs

//Move wolves and camera to First WP in 2 seconds (2.0/18.0).
GestaltActionMove(1.00,oWolf3,GetWaypointByTag("WPWinterwolf3"),FALSE,0.0,2.0);
GestaltActionMove(1.00,oWolf4,GetWaypointByTag("WPWinterwolf4"),FALSE,0.0,2.0);
GestaltActionMove(1.00,oPC,GetWaypointByTag("WP_PC_Move4"),FALSE,0.0,2.0);


if (!GetIsPC(oPC)) return;

object oCaster;
oCaster = GetObjectByTag("WinterWolf3");

object oTarget;
oTarget = GetObjectByTag("WP_WolfHowl_3");

DelayCommand(9.0, AssignCommand(oCaster, ActionCastFakeSpellAtLocation(VFX_FNF_HOWL_WAR_CRY, GetLocation(oTarget), PROJECTILE_PATH_TYPE_DEFAULT)));


oCaster = GetObjectByTag("WinterWolf4");
oTarget = GetObjectByTag("WP_WolfHowl_4");

DelayCommand(9.0, AssignCommand(oCaster, ActionCastFakeSpellAtLocation(VFX_FNF_HOWL_WAR_CRY, GetLocation(oTarget), PROJECTILE_PATH_TYPE_DEFAULT)));


if (!GetIsPC(oPC)) return;


oTarget = GetObjectByTag("SoundWolfHowls");

DelayCommand(9.0, SoundObjectPlay(oTarget));

DelayCommand(9.0, SoundObjectSetVolume(oTarget, 2000));

DelayCommand(13.0, SoundObjectStop(oTarget));

if (!GetIsPC(oPC)) return;

location lTarget;
oTarget = GetWaypointByTag("WPWinterWolf5");
lTarget = GetLocation(oTarget);
DelayCommand(12.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "winterwolf005", lTarget));

effect eEffect;
eEffect = EffectVisualEffect(VFX_IMP_HEALING_X);

DelayCommand(12.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, lTarget));


oTarget = GetWaypointByTag("WPWinterWolf6");
lTarget = GetLocation(oTarget);
DelayCommand(12.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "winterwolf006", lTarget));

eEffect = EffectVisualEffect(VFX_IMP_HEALING_X);

DelayCommand(12.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, lTarget));


GestaltActionMove(15.00,oPC,GetWaypointByTag("WP_PC_Move4"),FALSE,0.0,2.0);


GestaltActionMove(17.00,oWolf3,GetWaypointByTag("WinterWolfWalkPoint7"),FALSE,0.0,2.0);
GestaltActionMove(17.00,oWolf4,GetWaypointByTag("WinterWolfWalkPoint8"),FALSE,0.0,2.0);

GestaltActionMove(17.00,oWolf5,GetWaypointByTag("WinterWolfWalkPoint9"),TRUE,0.0,2.0);
GestaltActionMove(17.00,oWolf6,GetWaypointByTag("WinterWolfWalkPoint10"),TRUE,0.0,2.0);

GestaltActionMove(17.00,oPC,GetWaypointByTag("WP_PC_Move5"),FALSE,0.0,2.0);


if (!GetIsPC(oPC)) return;

GestaltStopCutscene (21.0, oPC);

}

-----------------------------------------------------------------------------------------------------------------------------------------------------

Can someone out there please alter my script  for me so that I have "Winter Wolf 5" and "Winter Wolf 6"
moving to their next waypoints after they have been spawned in?
It would help quite a bit I think.
               
               

               


                     Modifié par MissJaded, 06 octobre 2012 - 03:58 .
                     
                  


            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #6 on: October 06, 2012, 03:39:40 pm »


               Why do you have if (!GetIsPC(oPC)) return; listed several times? I don't see a need for it at all.  Do the other two wolves move or do none of them move to the WPs?
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #7 on: October 06, 2012, 06:21:48 pm »


               Hi,
    This is is not a spawn in vs walkwaypoints problem from the looks of it. The problem I think
is that you looked up wolf5 an wolf6 before you spawned them. So they are not valid objects when
you use them in the later GestaltActionMove commands.

With all the delays invovled you are going to have a hard time getting those variables set right
for creatures spawned in the cut scene. What you might want to do is spawn them before
you start - in a location that is not visible in the area (or maybe another area altogether) .
Then jump them to their target waypoints (the ones you were spawning them at). That way
you can have valid object references for use in the delayed commands.

Wolves 3 and 4 work because they were already spawned when you looked them up at the beginning.

You can put this at the top to see what I mean:

object oWolf3 = GetObjectByTag("WinterWolf3");
if (!GetIsObjectValid(oWolf3) {
      SendMessageToPC(oPC, "Wolf 3 not found");
}
object oWolf4 = GetObjectByTag("WinterWolf4");
if (!GetIsObjectValid(oWolf4) {
      SendMessageToPC(oPC, "Wolf 4 not found");
}
object oWolf5 = GetObjectByTag("WinterWolf5");
if (!GetIsObjectValid(oWolf5) {
      SendMessageToPC(oPC, "Wolf 5 not found");
}
object oWolf6 = GetObjectByTag("WinterWolf6");
if (!GetIsObjectValid(oWolf6) {
      SendMessageToPC(oPC, "Wolf 6 not found");
}

Cheers,

Meaglyn
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #8 on: October 06, 2012, 06:25:19 pm »


               Also, you did not ask for a critique of the whole script just about the specific problem you were having, but Pattycake is right about the check for the PC. If this script can ever fire for non-PCs
you might check that once at the top right after to get oPC, before you start the cutscene. If it ever did fire now the cut scene would not get stopped I think...

Cheers,

Meaglyn
               
               

               
            

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #9 on: October 07, 2012, 09:23:28 pm »


               Thanks a lot for the awsome help guys! '<img'>


@ pattycake1

With my lack of knowledge of scripting, I have no idea why I had (!getIsPC(oPC)
listed nearly several times in my script. I assume it's just basically looking to see if the pc is included in the area. And yes, my wolves do move.

What I was a little confused by though, was that you said it wasn't needed at all.
So I took it out of my script completely to see what would happen.
I ended up with something a bit weird - wolves moving in wrong directions. '<img'>
So I put that (!getIsPC(oPC) back in my script, but only once near the top, and it worked okay again.

meaglyn

I went ahead and took your advice by placing my 2 wolves 5 and 6 in a hidden area first, then calling them in at their respective waypoints afterwards, then scripting them (along with wolves 3 and 4) to move along to their next waypoints. This worked out fine then obviously.

You have helped me to alter my script a bit to how I want it, and now it looks something like this.

----------------------------------------------------------------------------------------------------------------------------------------------
#include "nw_i0_2q4luskan"
#include "in_g_cutscene"

void main()

{

object oPC = GetEnteringObject();
//Let's declare the wolves ahead of time to clean things up.
object oWolf3 = GetObjectByTag("WinterWolf3");
object oWolf4 = GetObjectByTag("WinterWolf4");

object oWolf5 = GetObjectByTag("WinterWolf5");
object oWolf6 = GetObjectByTag("WinterWolf6");


 GestaltStartCutscene(oPC, "cranecam");


   GestaltCameraCrane  (0.0,
                        0.0, 3.0, 90.0, 3.0,
                        0.0, 3.0, 90.0, 3.0,
                        8.0, 10.0,
                        oPC, 0);

   if (!GetIsPC(oPC)) return;

//Added this, setting duration to the end just after the last ActionMove
//commands will be completed firing (take their fDelay time and add the fTime
//used in the function).
GestaltInvisibility (0.0, oPC, 30.0);

//For the movement commands we will have to add WPs if we want the camera to
//be somewhere other than the wolves. For simplicity, I will just use the
//existing WPs



 //Move wolves and camera to First WP in 2 seconds (2.0/18.0).
GestaltActionMove(1.00,oWolf3,GetWaypointByTag("WPWinterwolf3"),FALSE,0.0,2.0);
GestaltActionMove(1.00,oWolf4,GetWaypointByTag("WPWinterwolf4"),FALSE,0.0,2.0);
GestaltActionMove(1.00,oPC,GetWaypointByTag("WP_PC_Move4"),FALSE,0.0,2.0);


object oCaster;
oCaster = GetObjectByTag("WinterWolf3");

object oTarget;
oTarget = GetObjectByTag("WP_WolfHowl_3");

DelayCommand(9.0, AssignCommand(oCaster, ActionCastFakeSpellAtLocation(VFX_FNF_HOWL_WAR_CRY, GetLocation(oTarget), PROJECTILE_PATH_TYPE_DEFAULT)));


oCaster = GetObjectByTag("WinterWolf4");
oTarget = GetObjectByTag("WP_WolfHowl_4");

DelayCommand(9.0, AssignCommand(oCaster, ActionCastFakeSpellAtLocation(VFX_FNF_HOWL_WAR_CRY, GetLocation(oTarget), PROJECTILE_PATH_TYPE_DEFAULT)));


oTarget = GetObjectByTag("SoundWolfHowls");

DelayCommand(9.0, SoundObjectPlay(oTarget));

DelayCommand(9.0, SoundObjectSetVolume(oTarget, 3000));

DelayCommand(13.0, SoundObjectStop(oTarget));



    // Have "Wolf5" perform a sequence of actions.
    oWolf5 = GetObjectByTag("WinterWolf5");
    AssignCommand(oWolf5, ActionWait(12.0));
    AssignCommand(oWolf5, ActionJumpToObject(GetObjectByTag("WPWinterWolf5")));


    // Have "Wolf5" perform a sequence of actions.
    oWolf6 = GetObjectByTag("WinterWolf6");
    AssignCommand(oWolf6, ActionWait(12.0));
    AssignCommand(oWolf6, ActionJumpToObject(GetObjectByTag("WPWinterWolf6")));



effect eVFX;


    // Apply a visual effect.
    eVFX = EffectVisualEffect(VFX_IMP_HEALING_X);
    oTarget = GetObjectByTag("WPWinterWolf5");
    DelayCommand(12.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, GetLocation(oTarget)));



     eVFX = EffectVisualEffect(VFX_IMP_HEALING_X);
    oTarget = GetObjectByTag("WPWinterWolf6");
    DelayCommand(12.0, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, GetLocation(oTarget)));


GestaltActionMove(16.00,oWolf3,GetWaypointByTag("WinterWolfWalkPoint7"),FALSE,0.0,2.0);
GestaltActionMove(16.00,oWolf4,GetWaypointByTag("WinterWolfWalkPoint8"),FALSE,0.0,2.0);

GestaltActionMove(16.00,oWolf5,GetWaypointByTag("WinterWolfWalkPoint9"),FALSE,0.0,2.0);
GestaltActionMove(16.00,oWolf6,GetWaypointByTag("WinterWolfWalkPoint10"),FALSE,0.0,2.0);

GestaltActionMove(16.00,oPC,GetWaypointByTag("WP_PC_Move5"),FALSE,0.0,2.0);



GestaltStopCutscene (24.0, oPC);

}

-------------------------------------------------------------------------------------------------------------------------------------------------------

It's only half finished right now, as I still have a bit more to add to it.
But I've been using the LS TK Script Generator, (which used to be made by "Lilac  Soul")
and hopefully it will help me further to finish my script with the next npc i have included in my area.

Thanks again for the help.'<img'>
               
               

               


                     Modifié par MissJaded, 08 octobre 2012 - 02:58 .
                     
                  


            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #10 on: October 08, 2012, 08:54:32 am »


               If (!GetIsPC(oPC)) return; checks for a non player. So in a sense if a non player (like a DM) walks into the trigger or area, the script will fire. I am presuming you want this to fire when only the PC enters. If that is the case the you might water to do it this way.

void main()
{
Beginning of script here
If(GetIsPC(oPC))
 {
   Rest of script here
 }
}

This would ensure that the script would only fire if a PC entered. The reason why the script didn't work right when you took out the other line is because you didn't give it the script a condition to fire like a if statement. So I guess I should have been a bit more clear on why I asked why you had that statement ask for no PC when you should have been asking for a PC.
               
               

               
            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #11 on: October 08, 2012, 09:01:27 am »


               I posted this from my phone and auto correct likes to change my words so it may read funny at times.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #12 on: October 08, 2012, 12:37:03 pm »


               @PattyCake1: It was correct in the form that he had it.   If it is not a PC he wants to return from the script.  So if any creature that is not a PC enters the script simply exits.   Also a DM is a PC.   So the script will fire for both DM's and players.

Your form is the same thing as what he had.  You are just stating: If PC do this.
Where his stated: If not a PC stop running.
               
               

               
            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #13 on: October 08, 2012, 01:35:40 pm »


               Its been so long since I've actually scripted anything I can see where I was thinking if(!GetIsPC(oPC))return false;

Don't ask me why I was thinking that, like I said it has been years since I've scripted. I also thought DM avitars where not concidered players. Again been years.......
               
               

               
            

Legacy_Pattycake1

  • Jr. Member
  • **
  • Posts: 98
  • Karma: +0/-0
Is It Possible To Move A Creature After It Spawns In?
« Reply #14 on: October 08, 2012, 01:43:28 pm »


               Phone wont let me edit above post. I just remembered that they don't come up as PC's. If they possess a npc..... right?