NeverwinterConnections.com

   NeverwinterConnections.com
   Main Topics
   Builders Discussion

   Frustrated
Pages: 1  
   Author  Topic: Frustrated  (Read 115 times)
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13
Frustrated
Return To Top       

My issue is this

I'm getting quite sick of declaring objects location in relation to PC or NPC for CreateObject(). Is there any way to declare locations on an X,Y,Z basis? for example. i want to create a portal at X = 32.55,Y= 55.22,Z= 22.95
oObject = SomeModellessObject
oPortal = GetTag(oObject)

CreateObject(oPortal,X,Y,Z)

I mean seriously, if i want a PC to walk through a hallway and he walks through a trigger and it spawns objects in a line (lets say Boxes)side by side that block his path backwards.
*Note to self look for a way to Offset object in multiple directions from originating object...*

Second. I'm trying to figure out how to Rotate objects facing. i understanding the facings themselves, i just need to know the actual function to change objects orientation. an example of how it is used as well.

Also, Does anyone know where the predefined functions are defined. for example where is CreateObject() Defined? I want to look at these functions to see what they actually do.

« Last Edit: on: May 16, 2010, 4:14AM » I.P. Logged
Olias Stormcrow

Extreme Poster


Last On: 06/15/11
View Profile
Message Player

United Kingdom

Posts: 368

Return To Top       

on May 16, 2010, 4:02 AM, Demon002 wrote:
My issue is this

I'm getting quite sick of declaring objects location in relation to PC or NPC for CreateObject(). Is there any way to declare locations on an X,Y,Z basis? for example. i want to create a portal at X = 32.55,Y= 55.22,Z= 22.95
oObject = SomeModellessObject
oPortal = GetTag(oObject)

CreateObject(oPortal,X,Y,Z)

I mean seriously, if i want a PC to walk through a hallway and he walks through a trigger and it spawns objects in a line (lets say Boxes)side by side that block his path backwards.
*Note to self look for a way to Offset object in multiple directions from originating object...*

Second. I'm trying to figure out how to Rotate objects facing. i understanding the facings themselves, i just need to know the actual function to change objects orientation. an example of how it is used as well.

Also, Does anyone know where the predefined functions are defined. for example where is CreateObject() Defined? I want to look at these functions to see what they actually do.


It's possible to spawn in placeables at specific locations and with a specific orientation as well as specifying the location to spawn the placeable in relation to the PC.

For placeables that will be spawned in a specific location; like boulders falling to block a path behind a character; you should place them in the toolset, then note down the location and orientation of each placeable.
You can then use that (x,y,z) and orientation in your script.

Take a look at the scripts in Negalith's Karador theatre where he uses something similar to what you're describing to spawn in set backdrops.

http://nwvault.ign.com/View.php?view=Prefabs.Detail&id=741

Alternatively, you can set the specific location of where you'd like to spawn a placeable using waypoints.

Try the NWN lexicon for function definitions.

http://www.nwnlexicon.com/

I hope that helps.

I.P. Logged
Lazybones

Forum God


Last On: 12/31/11
View Profile
Message Player

United States

Posts: 4696

Return To Top       

Why not just use waypoints to determine where the placeable is created?

« Last Edit: on: May 16, 2010, 5:09PM » I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

Basically because if i want to be memory efficient i must destroy the waypoints afterwards and thats extra code to do so on top of the fact that these waypoints exist in memory anyway. + more time to write the few extra lines of code.

Edit: Found orientation SetFacing()
Also i attempted to use that erf you referenced bt every time i try to load it into a mod it crashes with a memory access error, Hell if i try to make a new mod does the same thing.
[code]
1.)#include "x0_i0_position"
2.)
3.)void main()
4.){
5.) //OnHeartBeat Define Var for scriptstop|start condition. Stop Command Flood.
6.)
7.)
8.) if(iStop = 0)
9.){ if (fPos=0; fPos < 360; fPos+24)
10) {
11) ClearAllActions();
12) SetFacing(IntToFloat(fPos));
13) iStop++;
14) }
15) }
16) if(iStop = 1)
17) {return;}
1
19)
20)}
[/code]

5/16/2010 8:44:27 AM: Error. 'randomfacing' did not compile.
randomfacing.nss(9): ERROR: NO RIGHT BRACKET ON EXPRESSION

....Confused... Someone see what I don't

« Last Edit: on: May 16, 2010, 6:53PM » I.P. Logged
Gulfwulf

Forum God


Last On: 02/12/12
View Profile
Message Player

United States

Posts: 4798

Return To Top       

This is not syntactically correct:

9.){ if (fPos=0; fPos < 360; fPos+24)

What exactly are you testing for here? Also, you need a preceding parenthesis before the first if, not a bracket.

I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

I'm being onrie trying to avoid using the Module script slots and try and jerry rig this script to rotate this placeable FloorDesignsStyle2 on heartbeat. i reworked the script... again. reinteration like 10 lols


#include "x0_i0_position"
int iPos=0;
int iFace = iPos+24;
void main()
{
//Define Var for script stop|start condition. Stop Command Flood.



SetFacing(IntToFloat(iFace));
iPos= iPos+24;





}

I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

--I was trying to nest a IF within a IF. That work?

IF (this = True)
{If ()
{Statements}

IF (this = False)
{Do nothing}

----------

Looking at that.. though looks like it needs to be a for statement... ill try that too.. So what i was trying to do was. Change the value of True to false, so that on the next Heartbeat it wouldnt flood the engine with commands and would finish the cycle of the nested statement


EDIT AGAIN: I found the Vecter data type ^_^ YAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY!

« Last Edit: on: May 16, 2010, 8:42PM » I.P. Logged
Gulfwulf

Forum God


Last On: 02/12/12
View Profile
Message Player

United States

Posts: 4798

Return To Top       

Yes, you can have nested ifs:

If (statement=true)
{
if (other statement=true)
{
Do something.
}
}

Or, you can do If ( (statement=true) && (other statement=true) )
{
Do something
}

The && means both the first statement and the second statement have to be true for the check to be true.

I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

Recap on an earlier question

About seeing where the functions are defined.

I have the Lexicon. what i want is to see where

GetTag() and GetLocation() and etc are defined

I want to know How bioware functions work. and others. So i can write modified versions of these to suit my needs. So i can combine commonly used functions for streamlining the process..

I.P. Logged
Gulfwulf

Forum God


Last On: 02/12/12
View Profile
Message Player

United States

Posts: 4798

Return To Top       

Most functions are defined by the game engine, but you can write include files that have custom defined functions. You can then use those include files where ever you need one or more of the defined functions.

I.P. Logged
Zelknolf

Experienced User


Last On: 10/04/10
View Profile
Message Player

United States

Posts: 31

Return To Top       

... blimey. I'm not sure where to start with this all.

Firstly--
I really don't think you want a for loop to rotate this object. Remember you're using a heartbeat script; it will fire every 6 seconds, and you have access to the item's current facing.

float fFace = GetFacing(OBJECT_SELF);
fFace += 45.0f;
SetFacing(fFace);

Should be closer to what you're looking for, being that the for(fFace = 0; fFace < 360; fFace += 24) loop would queue up many SetFacing commands to be fired instantly, leaving the caller to be facing the same way at the end of the script every time.

I'm also not sure that SetFacing will work on a placeable, but GetFacing()/GetPosition()/GetArea() and Location() can be used with some basic math and CreateObject()/ DestroyObject() to fake it if it resists.




Secondly, be careful with your if syntax.

if(variable = TRUE)
will set variable to 1 and will always be true.

if(variable = FALSE)
will set variable to 0 and will always be false.

if(variable == TRUE)
will only operate the following command or scope if variable was set to 1 by previous events in the script.




To your most recent question, you can indeed write your own functions.

void MyCustomFunction(int nOperand)
{
<>
}

void main()
{
MyCustomFunction(1);
MyCustomFunction(27);
}

Would be an entirely valid script. If you want the function to do math, you can set a return type by replacing void with whatever you'd like to return (object, int, float, vector, struct, etc.) and ending the function with return <>.

If the function would be used in many scripts, you might want to make a function library of it. To do so, you would create a new script, delete the void main() function from it and write all of your custom functions inside. You would then add #include "script_name" to the top of the script that would use the function and could then call said function anywhere in the script.

However, be forewarned that there is a ceiling on how many functions may be declared in any given script (many of which are used up by nwscript.nss) and how many constants may be declared in any given script (again, many of which are used up by nwscript.nss), and in how many resources a module may have before being unable to load (16,384 -- that includes everything custom that is not in a hak that you put into a module; compiled scripts are 2 and function libraries are 1), so it is usually wise to create function libraries sparingly.

I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

on May 17, 2010, 10:07 PM, Gulfwulf wrote:
Most functions are defined by the game engine, but you can write include files that have custom defined functions. You can then use those include files where ever you need one or more of the defined functions.


So you don't know what GetTag() and GetLocation() actually are doing?

And yes, if you remove the static flag off of the placeable it will indeed rotate the placeable. My problem is that OnHeartBeat is too slow really. so i tried to define all the positions i wanted on a single go. And just as you said it ques them all at one time, i didn't realise it would do that, i thought it would do it on a per loop basis. Recent working iterations have produced this error in game, which made me think i was flubbin up my while statement... makes sence now.

I.P. Logged
Olias Stormcrow

Extreme Poster


Last On: 06/15/11
View Profile
Message Player

United Kingdom

Posts: 368

Return To Top       

Try this on heartbeat script for rotating the placeable

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

//Based on the rotate object script by Foolish Demon found on NW Vault

void Rotate(object oObject, int iTurns)
{
if ((oObject != OBJECT_INVALID) && (iTurns > 0))
{
float fStart = GetFacing(oObject);
AssignCommand(oObject, SetFacing(fStart - 24.0));
//Change the above - to a + if you want it to rotate in the opposite direction.
DelayCommand(0.2, Rotate(oObject, iTurns - 1));
}
}

void main()
{
Rotate(OBJECT_SELF,30);
}


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

That should give you a continuously rotating placeable. You can fuss around with the number, angle and frequency of rotations by adjust the appropriate values above.

Since the script will be constantly firing you will probably want to create the placeable when a player enters the area and destroy it when they leave.

If you're doing this in a MP environment you'll have to check and spawn in only one placeable when the first PC enters and destroy the object when the last one leaves. You can achieve that by using local integers on the area.

Dependant on the proximity of the location of the rotating placeable to the location of the area transition where the PC enters, you may see a delay before the heartbeat script kicks in. I haven't tested that.

If you're using this in a DMed environment, simply spawn in your custom placeable using the Creator and destroy the placeable when they leave.

I.P. Logged
Demon002

Experienced User


Last On: 01/30/12
View Profile
Message Player

United States

Posts: 13

Return To Top       

SetFacing(fStart - 24.0)

BAAH! sometimes i think to linearly. Good call, ill reimpliment. I think ill try and see if i can have the loop ++ a while statement to exit a loop then reduce it to zero again outside the loop to allow the script to run again when heartbeat comes around... hmm or would i need to , since the sccript doesnt cash the var anywhere.. maybe i just need to add it.. ill contemplate this at work. Ciao! Thanks for the help

I.P. Logged
Zelknolf

Experienced User


Last On: 10/04/10
View Profile
Message Player

United States

Posts: 31

Return To Top       

You won't need to reset any variables. Every one of them will go out of scope once the script has finished, and the next heartbeat will start a fresh instance.

I.P. Logged
Pages: 1  
Moderators: Rizzen, Shinji, Gilaun, Garnak, J'Dai Voisin, Lazybones, Ochobee, Eliandi
   NeverwinterConnections.com
   Main Topics
   Builders Discussion

   Frustrated

 
Copyright © 2002 Shawn Schultz. All rights reserved.
All trademarks are properties of their respective owners. Read our Terms of Use and our Privacy Policy.