.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Digital Eel > Weird Worlds: Return to Infinite Space > Scenarios and Mods

 
 
Thread Tools Display Modes
  #1  
Old November 11th, 2007, 04:37 PM

mantari mantari is offline
Private
 
Join Date: May 2007
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
mantari is on a distinguished road
Default Re: Request: some randomness

Quote:
Phlagm said:
I noticed that there is some user accessable randomness in the game (such as fomax's failure to understand your request: "ITEM random life"), but I don't know if there is an option for a random integer generator.
Oh! You gave me an idea! You'd have to account for all your various lifeforms but, the flowchat would go something like this?

ITEM random life
If you haveitem (lifeform1) then set RND=1 and REMV lifeform1
If you haveitem (lifeform2) then set RND=2 and REMV lifeform2
If you haveitem (lifeform3) then set RND=3 and REMV lifeform3

Could that be done at the start of the game?

Basically, you give the player a random lifeform, and depending on which one it is, you set a random number, and then remove that lifeform?
  #2  
Old November 13th, 2007, 05:20 PM

mantari mantari is offline
Private
 
Join Date: May 2007
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
mantari is on a distinguished road
Default RANDOM GENERATOR PROTOTYPE

Okay. I made a prototype for a random generator. This is just a prototype. It needs tweaking. And this would likely best go into haven.ini so it is generated at the start of each game. (That would prevent existing inventory from screwing this up.)

COST: This requires that you reduce the number of lifeforms in the game, because the random generation of lifeforms is what is used to create a random number. In this example, I chose: lookfrog, eel, foureyed, lummox, serpvine, plasworm, threep, bloater, piranbee, windbag.

NOTE: The randomness is not highly random. We're telling to to randomly set 5 out of 10 bits. Sometimes, it'll set 4 out of 10 bits, because of some weirdness with ITEM RANDOM LIFE.

For our random 0-4 number, we see how many of the first 5 bits are set. Most of the time, it'll be 2 or 3, rarely 0, rarely 4.

For our random 0-7 number, we take three bits, and binary add (1+2+4) them to make a random number 0-7.

There are certain relationships between the two sets of numbers that are more probable than others.

Anyhow, just a prototype. Here is the code. Again, requires that you reduce the number of lifeforms to a specific set, before the code works properly. The chance that no individual bits or all individual bits are set are 0%. If you're working under a condition where bit0 is set, there is a 45% chance that bit1 is also set. If you're working under a condition were bit0 and bit1 are set, there is only a 37% chance that bit2 is set.

I won't dive into a possibility matrix, because this is only a prototype random generator.

Code:

FLAG event always
KEYS unstablestar2

STAR 0
UVAR randready 0
STRT msq_yellow
STRN Omni0
PLNC grassland
FLAG nearby
END STAR

CONDITION 0
TYPE explore
STR0 0
END CONDITION

CONDITION 1
TYPE uvar
STR0 randready
STR1 0
END CONDITION

CONDITION 2
TYPE haveitem
STR0 lf_lookfrog
END CONDITION

CONDITION 3
TYPE haveitem
STR0 lf_eel
END CONDITION

CONDITION 4
TYPE haveitem
STR0 lf_foureyed
END CONDITION

CONDITION 5
TYPE haveitem
STR0 lf_lummox
END CONDITION

CONDITION 6
TYPE haveitem
STR0 lf_serpvine
END CONDITION

CONDITION 7
TYPE haveitem
STR0 lf_plasworm
END CONDITION

CONDITION 8
TYPE haveitem
STR0 lf_threep
END CONDITION

CONDITION 9
TYPE haveitem
STR0 lf_bloater
END CONDITION

CONDITION 10
TYPE haveitem
STR0 lf_piranbee
END CONDITION

CONDITION 11
TYPE haveitem
STR0 lf_windbag
END CONDITION

PAGE 0
REQ0 0
ITEM random life
ITEM random life
ITEM random life
ITEM random life
ITEM random life
END PAGE

PAGE 1
REQ0 1
SVAR randA 0
SVAR randB 0
SVAR randC 0
SVAR randD 0
SVAR randE 0
SVAR randF 0
SVAR randG 0
SVAR randH 0
SVAR randI 0
SVAR randJ 0
SVAR rand5 0
SVAR rand8 0
SVAR randready 1
END PAGE

PAGE 2
REQ0 0
END PAGE

PAGE 3
REQ0 0
REQ1 2
REMV lf_lookfrog
SVAR randA 1
INCV rand5 1
END PAGE

PAGE 4
REQ0 0
REQ1 3
REMV lf_eel
SVAR randB 1
INCV rand5 1
END PAGE

PAGE 5
REQ0 0
REQ1 4
REMV lf_foureyed
SVAR randC 1
INCV rand5 1
INCV rand8 1
END PAGE

PAGE 6
REQ0 0
REQ1 5
REMV lf_lummox
SVAR randD 1
INCV rand5 1
INCV rand8 2
END PAGE

PAGE 7
REQ0 0
REQ1 6
REMV lf_serpvine
SVAR randE 1
INCV rand5 1
INCV rand8 4
END PAGE

PAGE 8
REQ0 0
REQ1 7
REMV lf_plasworm
SVAR randF 1
END PAGE

PAGE 9
REQ0 0
REQ1 8
REMV lf_threep
SVAR randG 1
END PAGE

PAGE 10
REQ0 0
REQ1 9
REMV lf_bloater
SVAR randH 1
END PAGE

PAGE 11
REQ0 0
REQ1 10
REMV lf_piranbee
SVAR randI 1
END PAGE

PAGE 12
REQ0 0
REQ1 11
REMV lf_windbag
SVAR randJ 1
END PAGE

PAGE 13
REQ0 0
TEXT RANDOM 0-4: <uvar=rand5><BR>RANDOM 0-7: <uvar=rand8><BR>BITMAP:
<uvar=randA><uvar=randB><uvar=randC><uvar=randD><u var=randE>
<uvar=randF><uvar=randG><uvar=randH><uvar=randI><u var=randJ>
END PAGE



Sample output --
RANDOM 0-4: 1
RANDOM 0-7: 4
BITMAP: 0000110111
  #3  
Old November 14th, 2007, 01:14 PM

mantari mantari is offline
Private
 
Join Date: May 2007
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
mantari is on a distinguished road
Default Re: RANDOM GENERATOR PROTOTYPE

I moved the code into haven.ini so that it would automatically run at the start of each game. The individual items need a bit of reordering (for better readability), but it evaluates correctly.

Now, you may have 14 lifeforms. Also, instead of 5 of the 10 bits being set to 1, anywhere from 3 to 7 of the bits are set to 1. (There is a highly rare chance that only 2 bits could be set, due to the previously mentioned 'ITEM random life' bug.) Most of the time, 4-6 of the 10 'random' bits will be set. [NOTE: Now that I think about it, I see a way that I could go to 7 random bits, and have anywhere from 0 to 7 bits set, but I guess that'll have to be another version, if I attempt it.]

The code does call out some lifeforms (lf_eel, lf_foureyed) that are not in the default game, but that can be changed (from game.ini and inside of the haven.ini code):
lf_eel lf_foureyed lf_lummox lf_megamoeba lf_serpvine lf_plasworm lf_crysfish lf_drmsnake lf_threep lf_bloater lf_piranbee lf_windbag lf_lookfrog lf_ppleater

Here is the new haven.ini code that'll generate some random numbers at the start of each game:
Code:
FLAG always

STAR 0
FLAG existing
PLNT hope
ITEM wp_beamlasr
UVAR randready 0
END STAR

STAR 1
FLAG existing
PLNT hope
ITEM wp_gausscan
END STAR

STAR 2
FLAG existing
PLNT hope
ITEM wp_missfusr
END STAR

CONDITION 0
TYPE homeworld
STR0 terran
END CONDITION

CONDITION 1
TYPE uvar
STR0 randready
STR1 0
END CONDITION

CONDITION 2
TYPE haveitem
STR0 lf_lookfrog
END CONDITION

CONDITION 3
TYPE haveitem
STR0 lf_eel
END CONDITION

CONDITION 4
TYPE haveitem
STR0 lf_foureyed
END CONDITION

CONDITION 5
TYPE haveitem
STR0 lf_lummox
END CONDITION

CONDITION 6
TYPE haveitem
STR0 lf_serpvine
END CONDITION

CONDITION 7
TYPE haveitem
STR0 lf_plasworm
END CONDITION

CONDITION 8
TYPE haveitem
STR0 lf_threep
END CONDITION

CONDITION 9
TYPE haveitem
STR0 lf_bloater
END CONDITION

CONDITION 10
TYPE haveitem
STR0 lf_piranbee
END CONDITION

CONDITION 11
TYPE haveitem
STR0 lf_windbag
END CONDITION

CONDITION 12
TYPE haveitem
STR0 lf_megamoeba
END CONDITION

CONDITION 13
TYPE haveitem
STR0 lf_drmsnake
END CONDITION

CONDITION 14
TYPE haveitem
STR0 lf_crysfish
END CONDITION

CONDITION 15
TYPE haveitem
STR0 lf_ppleater
END CONDITION

PAGE 0
REQ0 0
REQ1 1
ITEM random life
ITEM random life
ITEM random life
ITEM random life
ITEM random life
ITEM random life
ITEM random life
SVAR randA 0
SVAR randB 0
SVAR randC 0
SVAR randD 0
SVAR randE 0
SVAR randF 0
SVAR randG 0
SVAR randH 0
SVAR randI 0
SVAR randJ 0
SVAR rand4 3
SVAR rand5 0
SVAR rand8 0
SVAR randready 1
END PAGE

PAGE 1
REQ0 0
REQ1 15
REMV lf_ppleater
END PAGE

PAGE 2
REQ0 0
REQ1 12
REMV lf_megamoeba
END PAGE

PAGE 3
REQ0 0
REQ1 2
REMV lf_lookfrog
SVAR randA 1
INCV rand5 1
END PAGE

PAGE 4
REQ0 0
REQ1 3
REMV lf_eel
SVAR randB 1
INCV rand5 1
END PAGE

PAGE 5
REQ0 0
REQ1 4
REMV lf_foureyed
SVAR randC 1
INCV rand5 1
INCV rand8 1
END PAGE

PAGE 6
REQ0 0
REQ1 5
REMV lf_lummox
SVAR randD 1
INCV rand5 1
INCV rand8 2
END PAGE

PAGE 7
REQ0 0
REQ1 6
REMV lf_serpvine
SVAR randE 1
INCV rand5 1
INCV rand8 4
END PAGE

PAGE 8
REQ0 0
REQ1 7
REMV lf_plasworm
SVAR randF 1
END PAGE

PAGE 9
REQ0 0
REQ1 8
REMV lf_threep
SVAR randG 1
SVAR rand4 2
END PAGE

PAGE 10
REQ0 0
REQ1 9
REMV lf_bloater
SVAR randH 1
SVAR rand4 2
END PAGE

PAGE 11
REQ0 0
REQ1 10
REMV lf_piranbee
SVAR randI 1
SVAR rand4 1
END PAGE

PAGE 12
REQ0 0
REQ1 11
REMV lf_windbag
SVAR randJ 1
SVAR rand4 0
END PAGE

PAGE 13
REQ0 0
REQ1 13
REMV lf_drmsnake
END PAGE

PAGE 14
REQ0 0
REQ1 14
REMV lf_crysfish
END PAGE

PAGE 15
REQ0 0
DISP 1
ACTN popup endquest
TEXT RANDOM 0-3: <uvar=rand4><BR>RANDOM 0-4:
<uvar=rand5><BR>RANDOM 0-7: <uvar=rand8><BR>BITMAP:
<uvar=randA><uvar=randB><uvar=randC><uvar=randD>
<uvar=randE><uvar=randF><uvar=randG><uvar=randH>
<uvar=randI><uvar=randJ>
END PAGE

  #4  
Old November 14th, 2007, 06:56 PM
Fingers's Avatar

Fingers Fingers is offline
Sergeant
 
Join Date: Jun 2005
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Fingers is on a distinguished road
Default Re: RANDOM GENERATOR PROTOTYPE

There's nothing special about haven.ini. Any quest with the "always" flag will always run.
  #5  
Old November 14th, 2007, 08:41 PM

mantari mantari is offline
Private
 
Join Date: May 2007
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
mantari is on a distinguished road
Default Re: RANDOM GENERATOR PROTOTYPE

Actually, there is something special. Two somethings.

1] Putting the randomizer in haven.ini will ensure that it is that it is always run, yes. But more importantly, it makes sure that it is the first script run (assuming no other strange mods). This makes sure that a random number is seeded, before you rely on it to be used in other scripts.

2] The player won't already have inventory items which will muck up the code, which is based on what lifeforms are randomly placed into their inventory. If you run this code in a different star system, his existing inventory will affect the random number generation, and any lifeforms in his posession will be wiped out.
  #6  
Old November 15th, 2007, 08:17 PM
Fingers's Avatar

Fingers Fingers is offline
Sergeant
 
Join Date: Jun 2005
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
Fingers is on a distinguished road
Default Re: RANDOM GENERATOR PROTOTYPE

You can and should do this in a new quest file. Just set it up exactly like haven.ini and it'll be triggered at the same time (ie. when you first "arrive" at Hope). There's nothing hard-coded in the game to handle any particular quest differently from others.
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 03:44 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.