Author Topic: Anyone Know A Script To Ascend My Placeable Airship Upwards Please?  (Read 319 times)

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0


               Excuse me?

If there is anyone out there who still plays neverwinter nights these days? (I know it's been around for some time now, but I don't know how long to be honest) I'm looking for someone with good scripting knowledge to help me out some.

Sometime back, I had been working on a module, and I wanted a script which would move a placeable (and in my case) airship along. Out of the few very helpful people who replied and tried to help me.... one person made this litle demo at n.w vault which involves just what I asked for at the time.

Airship Movement Demo

That looks rather helpful indeed! But since then, I have changed my mind, and I now want my airship to ASCEND (move straight upwards) instead of moving outwards or coming inwards like it does in that demo.

I just have no clue really. '<img'>

The thing is, I know a script can be used to "create object" from the pallete in the toolset
Also... if the object (placeable airship in this  case} is already painted down, (so that it is visible, and you can see it) then a script can be used to "destroy object" too

But as I have found, (with use of "Lilac Soul's Script Generator") it seems that you cannot "create object" (from the pallete) to THEN..... have it destroyed some seconds later!'<img'>

That was the only way I could think of, in my experiments with scripting, and obviously I found that it odesn't work like that.'<img'>

I don't really understand the workings of the script in that demo link I posted.
So in a similar way to that, or any way at all..... can anyone give me a script  which makes my placeable airship ascend STRAIGHT upwards please?

Regards,
"MissJaded"B)
               
               

               


                     Modifié par MissJaded, 31 octobre 2010 - 08:37 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Anyone Know A Script To Ascend My Placeable Airship Upwards Please?
« Reply #1 on: September 10, 2010, 04:39:45 pm »


               The higher the airship goes, the quicker it will rise.

You will need to tweak this for your needs of course to create the result you're after.

If you'd like to change the value of the ship going upward, change the vPos1.z += values.

Here is a quick tutorial of the script.

When you're ready to have the airship begin to rise upwards, you'll want to change the airshipstart variable to something other than 0.

A counter will begin and increment every 6 seconds, changing the height of the airship placeable.

So the first 6 second count, the airship will be destroyed and recreated at a height of 0.20 off the ground.

At 12 seconds, the airship will be destroyed and recreated at a height of 0.40.

These are the values you will want to play around with, depending on the size of the placeable, these increments of 0.20 may not be enough to give a visual representation of the airship actually moving upward.

So instead of creating the airship the first time at 0.20, you might want to set it to 0.80, etc.

Each value after will need to be higher than the last.

After 11 heartbeat cycles, the airship is destroyed and the variable is reset to 0 to stop the script from going off again.

Change all lines that have "TAG_OF_AIRSHIP" to the real TAG of your airship.

Change all lines that have "RESREF_OF_AIRSHIP" to the real RESREF of your airship.

void main()
{

// Place this script on the Airship's OnHeartbeat
//
// AIRSHIP FIRE VARIABLE - airshipstart
//
// At some point, when the airship is ready to begin moving upward,
// change the airshipstart variable from 0 to something else.
//
// example - SetLocalInt(GetModule(), "airshipstart", 100);
//
// Once it's anything but 0, the script below will begin to fire.
//

object oMod = GetModule();
int nNth = GetLocalInt(GetModule(), "airshipup");

// Checks to see if script should begin to fire & airship to rise upward
if (GetLocalInt(GetModule(), "airshipstart") == 0) return;

// HB counter to destroy & create airship
nNth++;


   if (GetLocalInt(GetModule(), "airshipup") == 0)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 0.20;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);
   }

   if (GetLocalInt(GetModule(), "airshipup") == 1)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 0.40;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);
   }

   if (GetLocalInt(GetModule(), "airshipup") == 2)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 0.60;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);

   }

   if (GetLocalInt(GetModule(), "airshipup") == 3)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 0.80;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);
       }

   if (GetLocalInt(GetModule(), "airshipup") == 4)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 1.00;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);
   }

   if (GetLocalInt(GetModule(), "airshipup") == 5)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 1.40;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);
       }

   if (GetLocalInt(GetModule(), "airshipup") == 6)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 1.80;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);


   }

   if (GetLocalInt(GetModule(), "airshipup") == 7)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 2.20;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);


   }

   if (GetLocalInt(GetModule(), "airshipup") == 8)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 2.80;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);


   }

   if (GetLocalInt(GetModule(), "airshipup") == 9)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 4.00;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);


   }

   if (GetLocalInt(GetModule(), "airshipup") == 10)
   {
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   location lLoc1 = GetLocation(OBJECT_SELF);
   float fFacing = GetFacing(OBJECT_SELF);
   vector vPos1 = GetPositionFromLocation(lLoc1);
   vPos1.z += 5.00;
   lLoc1 = Location(GetArea(OBJECT_SELF), vPos1, fFacing);
   CreateObject(OBJECT_TYPE_PLACEABLE, "RESREF_OF_AIRSHIP", lLoc1);


   }

   if (GetLocalInt(GetModule(), "airshipup") == 11)
   {
   // END AIRSHIP JOURNEY
   DestroyObject(GetObjectByTag("TAG_OF_AIRSHIP"));
   SetLocalInt(GetModule(), "airshipstart", 0);
   }




}


EDIT: Thanks SunJammer '<img'>

FP!
               
               

               


                     Modifié par Fester Pot, 10 septembre 2010 - 11:20 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Anyone Know A Script To Ascend My Placeable Airship Upwards Please?
« Reply #2 on: September 11, 2010, 01:20:44 am »


               Here is one from SunJammer.

//------------------------------------------------------------------------------
// Executeable script: call from an OnUse or an Conversation Action script
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// User Settings
//------------------------------------------------------------------------------

// controls the number of moves to make to get the airship up
const int NUMBER_OF_MOVES = 12;

// controls the time in seconds between each move
const float DELAY_BETWEEN_MOVES = 1.0;

// controls the airship to be affected by this script: the tag should be unique
const string TAG_OF_AIRSHIP = "your_tag_goes_here";


//------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------

// generic function that "moves" an object by destroying the current instance
// and creating a new instance offset by a given amount
// NOTE: the object must have its own blueprint so that it can recreate itself
void MoveObject(object oObject, vector vMove)
{
// the old object destroys itself (after the script completes)
DestroyObject(oObject);

// deconstruct the current location
object oArea = GetArea(oObject);
vector vPosition = GetPosition(oObject);
float fFacing = GetFacing(oObject);

// construct a new location
location lNew = Location(oArea, vPosition + vMove, fFacing);

// create a new object
CreateObject(GetObjectType(oObject), GetResRef(oObject), lNew);
}


// self-calling function that move the airship according to the settings
void MoveAirship()
{
object oModule = GetModule();

// get the number of moves made and increment it
int nMove = GetLocalInt(oModule, "airship_move") + 1;

if(nMove
{
// update the number of moves
SetLocalInt(oModule, "airship_move", nMove);

// calculate the vertical offset using some formula to make it appear to
// be accelerating up (replace or tweak as required)
float fZ = pow(1.1, IntToFloat(nMove));
vector vMove = Vector(0.0, 0.0, fZ);

// move the airship
MoveObject(GetObjectByTag(TAG_OF_AIRSHIP), vMove);

// schedule a call back to this function
DelayCommand(DELAY_BETWEEN_MOVES, MoveAirship());
}
else
{
// remove the "move" variable for the next time
DeleteLocalInt(oModule, "airship_move");
}
}


//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

void main()
{
// start the self-calling function
MoveAirship();
}


FP!
               
               

               


                     Modifié par Fester Pot, 11 septembre 2010 - 12:43 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Anyone Know A Script To Ascend My Placeable Airship Upwards Please?
« Reply #3 on: September 11, 2010, 02:53:37 am »


               or you could just move the AirshipDest waypoint to the airship then move it above the airship with outside click on the waypoint and adjust location and change it z axis to like 30 move the ladder by the the airship. All the function are good to use also, but that a simple way with the demo module. '<img'>
               
               

               
            

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Anyone Know A Script To Ascend My Placeable Airship Upwards Please?
« Reply #4 on: September 13, 2010, 10:33:41 pm »


               

Fester Pot wrote...

Here is one from SunJammer.

//------------------------------------------------------------------------------
// Executeable script: call from an OnUse or an Conversation Action script
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// User Settings
//------------------------------------------------------------------------------

// controls the number of moves to make to get the airship up
const int NUMBER_OF_MOVES = 12;

// controls the time in seconds between each move
const float DELAY_BETWEEN_MOVES = 1.0;

// controls the airship to be affected by this script: the tag should be unique
const string TAG_OF_AIRSHIP = "your_tag_goes_here";


//------------------------------------------------------------------------------
// Functions
//------------------------------------------------------------------------------

// generic function that "moves" an object by destroying the current instance
// and creating a new instance offset by a given amount
// NOTE: the object must have its own blueprint so that it can recreate itself
void MoveObject(object oObject, vector vMove)
{
// the old object destroys itself (after the script completes)
DestroyObject(oObject);

// deconstruct the current location
object oArea = GetArea(oObject);
vector vPosition = GetPosition(oObject);
float fFacing = GetFacing(oObject);

// construct a new location
location lNew = Location(oArea, vPosition + vMove, fFacing);

// create a new object
CreateObject(GetObjectType(oObject), GetResRef(oObject), lNew);
}


// self-calling function that move the airship according to the settings
void MoveAirship()
{
object oModule = GetModule();

// get the number of moves made and increment it
int nMove = GetLocalInt(oModule, "airship_move") + 1;

if(nMove
{
// update the number of moves
SetLocalInt(oModule, "airship_move", nMove);

// calculate the vertical offset using some formula to make it appear to
// be accelerating up (replace or tweak as required)
float fZ = pow(1.1, IntToFloat(nMove));
vector vMove = Vector(0.0, 0.0, fZ);

// move the airship
MoveObject(GetObjectByTag(TAG_OF_AIRSHIP), vMove);

// schedule a call back to this function
DelayCommand(DELAY_BETWEEN_MOVES, MoveAirship());
}
else
{
// remove the "move" variable for the next time
DeleteLocalInt(oModule, "airship_move");
}
}


//------------------------------------------------------------------------------
// Main
//------------------------------------------------------------------------------

void main()
{
// start the self-calling function
MoveAirship();
}


FP!



Thanks a lot for your helpful replies Fester Pot.'<img'>

I think your first script is going to be of more use to me.
As you stated, the 2nd one is called from an OnUSe or action conversation script. But that won't really help me, as my script runs from trigger in a cutscene.... which is where your first one will be more useful  I think.
I didn't expect a script to be quite as long as that either, but I have read your descriptions e.t.c and I think I will be able to make something of it.... just about.

I might be back again if I get stuck, but for now
Thanks again.'B)'
               
               

               
            

Legacy_MissJaded

  • Full Member
  • ***
  • Posts: 243
  • Karma: +0/-0
Anyone Know A Script To Ascend My Placeable Airship Upwards Please?
« Reply #5 on: September 13, 2010, 10:57:36 pm »


               

ShadowM wrote...

or you could just move the AirshipDest waypoint to the airship then move it above the airship with outside click on the waypoint and adjust location and change it z axis to like 30 move the ladder by the the airship. All the function are good to use also, but that a simple way with the demo module. '<img'>


Hey there ShadowM:police:

This is somewhat odd, because I realize that you made that airship demo that I linked to in my first post, and yet I am not really understanding how simple your reply seemed to be.

in my cutscene, my waypoints are not destroy waypoints.  That sounds rather confusing to me, because if a destroy waypoint is used, the script thinks I am trying to destroy the waypoint..... NOT... the object (placeable airship)

My waypoints are used from a "CreateObject" script. I place one down, (in relatively same place as you described)
give it a tag name, and tell my script to "CreateObject " (placeable airship) at that waypoint I placed down.

I don't really know how a Destroy Waypoint from a DestroyObject script is going to work in the way that you described it really. I maybe misreading it somehow, but again.... I don't quite understand it really.
I'm sorry.

Regards,
"MissJaded" 'B)'