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.
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.
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.
@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?
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.
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?
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.
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.
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.