Neverwinter Vault

Expand AllContract All -Site -My Profile -Features

Neverwinter Nights 2

-NWN2 Files -NWN2 Game Info -NWN2 Resources -NWN2 Community

Neverwinter Nights

-NWN Files -NWN Game Info -NWN Resources -NWN Community

Vault Network
RPG Vault
VN Boards
IGN Vault
Vault Wiki
· Age of Conan
· Anarchy Online
· Asheron's Call
· Dark Age of Camelot
· City of Heroes
· D&D
· EVE Online
· EverQuest
· EverQuest 2
· Final Fantasy
· Guild Wars
· Lineage 2
· Lord of the Rings Online
· Middle Earth
· Neverwinter Nights
· Pirates of the Burning Sea
· Rise of the Argonauts
· Star Wars Galaxies
· Tabula Rasa
· The Matrix Online
· The Witcher
· Titan Quest
· Two Worlds
· Vanguard
· Warhammer
· World of Warcraft

Planet Network
Planet Hub

IGN
Games
Cheats
Entertainment

The Web   The Site  



NWN SCRIPTS

- Jump to comments -
Title  X functions 1.3: GetInt / SetInt with new errorvalue, Trace(), ColorText()
Author  Master Lexx
Submitted / Updated  06-08-2005 / 11-22-2006
Category  Scripting routines
Expansions  Works on all versions
Format  Code Only
Type  Type - Other
Includes  None
Description
X functions 1.3
GetInt() / SetInt() and GetFloat() / SetFloat() are identical with the GetLocalInt() and so... functions. The difference is, that they return INT_INVALID and FLOAT_INVALID on error instead a 0. So now you can always be sure that a 0 means that a 0 was previously set. It can be important to know if 0 is an error or just a number.
Also included some simple Trace functions for debugging. They save time (no more sendmessagetopc.........)
Added a few colors and a ColorText function, it can be handy.

Files

NameTypeSizeDownloads
xfunctions.erfxfunctions.erf
Submitted: 06-08-2005 / Last Updated: 06-12-2005
erf5.87Kb155
GetInt() / SetInt() with new errorvalue. Textcolor function.
SCORE OUT OF 10
10
1 votes
View Stats
Cast Your Vote!

PORTFOLIO
Add this entry to your portfolio so you can track it
Manage your existing portfolios or create a new one.
SCREENS
No Images




You Must Be Logged In to Participate.
Comments (20):

Posted by Master Lexx at 2005-06-13 08:39:41    
@Dalex64: thanks, can you please write me an email? I need your help. (check my profile)

Posted by Dalex64 at 2005-06-13 05:40:46    
Here, have some code to go with that vague explaination.

int SQLRandom(int nRange=99, int nSeed=0)
{
float fSQLResult;

int DEBUG_SQLRANDOM=GetLocalInt(GetModule(), "SQLRANDOM_DEBUG");

if(nSeed)
SQLExecDirect("SELECT RAND("+IntToString(nSeed)+");");
else
SQLExecDirect("SELECT RAND();");

fSQLResult = StringToFloat(SQLGetData(SQLFetch()));

if (DEBUG_SQLRANDOM) WriteTimestampedLogEntry("SQLRandom: fSQLResult="+FloatToString(fSQLResult));

return FloatToInt( fSQLResult*( IntToFloat(nRange) )+ 0.49999999999999 );

}

Posted by Dalex64 at 2005-06-12 04:43:36    
I believe the function is in sqlite. The command is RAND() and it returns a float from 0.0 to 1.0. if you call rand with an argument, it uses the argument as a seed.

so, to use it, you go SELECT RAND();

Posted by Master Lexx at 2005-06-12 00:51:37    
I am sorry, I made some mistakes. Random numbers are not possible just with nwscript, and OBJECT_SELF is always the other object with whom the PC is speaking.

Posted by Master Lexx at 2005-06-11 23:31:27    
@Blackdragon, I thank you for trying to help me, but my get GetOtherSpeaker() function get´s the nearest object to the PC! This means, it will work in multiplayer! The nearest object to the PC, that is in conversation, is no summon and is no pc and is in the same area.
@Delax64, thanks for the hint. Is this possible with sqlite too?

Posted by Dalex64 at 2005-06-11 13:24:12    
if you have aps/nwnx, you can use mysql's random number generator.

I seed that generator with SecondsSince1970, so it starts a new sequence of random numbers each time.

Then, to get bioware's Random() and dx() functions to work, on area enter, where it seeds the random number generator (poorly), you can pull a random number (by mysql) and pull that many random numbers out of bioware's Random() call to jump a random amount into the sequence for that.

Posted by Black Dragon ( 62.252.xxx.xxx ) at 2005-06-11 07:09:10    
Sorry to complain about your script writing, I was simply saying what I would have found useful :). Although I do think the chance of 2 NPCs being in conversation at once in 1 area is quite likely especially in a PW.

Posted by Master Lexx at 2005-06-10 20:35:27    
Don´t complain about my script writing. I wrote it, it has a continual system, it saves (visual) space. GetOtherSpeaker() can be used everywhere, how high is the chance that there is another object near, that is no pc, no summon and in conversation?

Posted by Master Lexx at 2005-06-10 20:27:36    
It´s impossible! I tested it with your idea. You can´t have random numbers generated, and it is really not worth to bother with this andmore. If you have more players and some heartbeat scripts, it will be nearly impossible to get the same number sequence again. So I removed this.

Posted by Black Dragon ( 62.252.xxx.xxx ) at 2005-06-10 08:57:42    
Sorry for double post but

int iRandomize = Random( Random( GetTimeMillisecond() +1) +1);

at the top of your script will correnct random number checks.

Posted by Black Dragon ( 62.252.xxx.xxx ) at 2005-06-10 08:54:49    
Nice scripts. Interesting about the random numbers. I think some more commenting may have been useful, as well as structuring your if statements e.g.

if(blah = blah)
{
dowhatever();
}
else
{
if(blah2 = blah3)
{
dowhatever2();
}
somefunction();
}

rather than

if(blah = blah) dowhatever();
else if(blah2 = blah3) dowhatever2();
else somefunction();

this way it's easy to spot nested if statement etc.

BTW I think you may have problems with GetOtherSpeaker() when playing multiplayer.

Posted by f0ul_cr0w at 2005-06-10 00:01:35    
But in a conversation with an NPC (which would be the NPC's conversation), no matter which event the script is (ActionsTaken, TextAppearsWhen, etc) and no matter who is saying the line of dialogue (NPC or PC), OBJECT_SELF is the NPC because it is the NPC's conversation. I still don't understand, unless this isn't for actual conversation events.

Posted by driller at 2005-06-09 15:34:53    
Not sure if this is true, but I have read that if you call Random(GetTimeMillisecond())
then call Random(x) or d(x) it will be different.

I haven't tested this though.

_________________________
Blackstone Keep PW

Posted by driller at 2005-06-09 15:32:20    
Not sure if this is true, but I have read that if you call Random(GetTimeMillisecond())
then call Random(x) or d(x) it will be different.

I haven't tested this though.

_________________________
Blackstone Keep PW

Posted by Steelwing at 2005-06-09 13:23:38    Voted 10.00 on 06/09/05
I can't seem to understand the script but it works well. Nice idea

Posted by Master Lexx at 2005-06-09 13:17:51    
It´s just sometimes very usefull to get the object with whom the pc is speaking just. OBJECT_SLEF is always the object that calls the script.

Posted by f0ul_cr0w at 2005-06-09 12:36:12    
Isn't OBJECT_SELF the NPC in a conversation? Or is this for when there are multiple NPCs?

Posted by Master Lexx at 2005-06-09 11:17:12    
Okay, my tests were wrong, it´s not possible to get a real random number if you use dx() or Random(x) functions. No way! Sorry.

Posted by Master Lexx at 2005-06-09 10:37:02    
No if you first call a dx(), it will not change the random number sequence. It doesn´t matter if you use d100() or Random(101) they both give always the same random number sequence. I tested it in an empty module with a useable placeable, which has a while loop and generates 20 numbers out of Random(101) and d100(), every restart they were the same. The same if i first used a d100() and then generated Random(101) numbers, every restart they were the same.

But then I used d10() * d10() to generate each of the 20 numbers, and those numbers created were always different, don´t know why, they should be the same, like 20 d100() generations, but somehow ..... I don´t know why. But at least I can now be sure that my RealRandom function which uses many d100() * d100() .... will give always different numbers.

Posted by danmar ( 208.212.xxx.xxx ) at 2005-06-09 06:35:21    
Just curious how this generates real random numbers? Given that you're using the dX system which is based on the inherent random number generator I'm assuming does it really matter how you generate the numbers? Or is it only the Random(x) function that's broken in this fashion and the dX functions aren't?

If you call a dX function first does it change the Random sequence at all?


You must be Logged In to post comments in this section.

 
Most recent posts on the MMO General Boards
Analyst: Star Wars: The Old Republic Could...Analyst: Star Wars: The Old Republic Could Sell 3M: more numbers
- last reply by Acao on Aug 15, 2011 06:15 PM
which class will your first character be
- last reply by Blisteringballs on Aug 15, 2011 05:50 PM
New Community Content!
- posted by Vault_News on Aug 15, 2011 05:00 PM
New Community Content!
- posted by Vault_News on Aug 15, 2011 04:00 PM
NWN Idea Database Update
- posted by Vault_News on Aug 15, 2011 03:46 PM
Missing Votes for NWN2 Hall of Fame
- posted by Vault_News on Aug 15, 2011 03:40 PM
Missing Votes for NWN Hall of Fame
- posted by Vault_News on Aug 15, 2011 03:39 PM
Random Questions and game altering suggest...Random Questions and game altering suggestions!!!
- last reply by ArkadyTepes on Aug 15, 2011 03:22 PM
State of the game?
- last reply by LyricOpera on Aug 15, 2011 01:37 PM
Yesterday streaming, now demanding downloa...Yesterday streaming, now demanding download :(
- last reply by Sinane-tk on Aug 15, 2011 10:23 AM
 

   


IGN Entertainment
By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the User Agreement.
Copyright 1996-2011, IGN Entertainment, Inc. | Support | Privacy Policy | User Agreement | RSS Feeds
IGN’s enterprise databases running Oracle, SQL and MySQL are professionally monitored and managed by Pythian Remote DBA.


NWN2 Hall of Fame

HOF NWN2 Tutorials


View all Hall of Fame entries


Neverwinter Nights 2

TOP NWN2 Modules

NEW Modules

NEW Reviews

NEW INTL. Modules

TOP Hakpaks

TOP Gameworlds

TOP Tutorials

TOP Prefab:Areas

TOP Blueprints

TOP Plugins

TOP UI

TOP Other

TOP Visual Effects

TOP Scripts

TOP Tools

TOP Movies

TOP Models

TOP Characters





Hall of Fame

HOF NWN Modules


View all Hall of Fame entries


TOP NWN Modules

NEW NWN Modules

NEW Reviews

TOP Intl. Modules

TOP NWN Hakpaks

TOP NWN Gameworlds

TOP NWN Models

TOP NWN Portraits

TOP NWN Scripts

TOP NWN Prefabs

TOP NWN Other

TOP NWN Movies

TOP Sounds

TOP NWN Textures

TOP NWN Creatures

TOP NWN Characters