Script for "Dice Roll"

Post » Wed May 02, 2012 10:45 pm

Ok for my mod it's like a 'Random encounter' how do I make a random number/dice roll? I heres bit of what it is going to do but I don't know how to set 'encounterNum' var to a Random number (like 1-30) if your can help me I am lost in what to do for the Random number/dice roll thing lol.

SCN CUSRINLinPoopleattSCRPTshort encounterGo ; 1 = start the encountershort EnReturn	; 1 = cancel encounter (one Or NPC(s) is dead0short encounterNumBEGIN gamemodeif player.getincell MyCellID == 1if encounterNum == 1; do nothing endif encounterNum == 2; do nothing endif encounterNum == 3if BobGenREF.getdead == 0set encounterGo to 1BobGenREF.enableBobGenREF.moveto playerBobGenREF.startcombat playerelseset EnReturn to 1endifendifendEND
User avatar
maddison
 
Posts: 3498
Joined: Sat Mar 10, 2007 9:22 pm

Post » Wed May 02, 2012 7:18 pm

1. You cannot end your 'IF' commands with an 'end' command. The end command will terminate the current script block.

2. Use http://geck.gamesas.com/index.php/GetRandomPercent to get a random number. I usually use the default and return a value from 0 to 99. I then split that up in my IF checks divided evenly.

set myRanNum to GetRandomPercentif myRanNum < 3   ;do thiselseif myRanNum < 6   ;do thiselseif myRanNum < 9   ;do thiselseif myRanNum < 12   ;do thiselseif myRanNum < 15   ;do thiselse   do thisendif

And since the first 'true' statement is executed, you do not need to check for 'greater than' values if you set it up checking lowest to highest.
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Thu May 03, 2012 1:01 am

1. You cannot end your 'IF' commands with an 'end' command. The end command will terminate the current script block.

2. Use http://geck.gamesas.com/index.php/GetRandomPercent to get a random number. I usually use the default and return a value from 0 to 99. I then split that up in my IF checks divided evenly.

set myRanNum to GetRandomPercentif myRanNum < 3   ;do thiselseif myRanNum < 6   ;do thiselseif myRanNum < 9   ;do thiselseif myRanNum < 12   ;do thiselseif myRanNum < 15   ;do thiselse   do thisendif

And since the first 'true' statement is executed, you do not need to check for 'greater than' values if you set it up checking lowest to highest.
Thanks with your help I Came up with this it only gets the values 1-10 now thanks I forgot about GetRandomPercent if anyone thinking what 'enGo' is it's just a var to stop looping lol
if player.getincell Tenpenny01 == 1 && enGo == 0set encounterNum to  GetRandomPercent * 1/10if encounterNum == 1;Do nothingset enGo to 1elseif encounterNum >= 2 && encounterNum <=4Showmessage DebugMESSset enGo to 1elseif encounterNum == 5Showmessage DebugMESSset enGo to 1elseif encounterNum == 6;Do nothingset enGo to 1elseif encounterNum == 7Showmessage DebugMESSset enGo to 1elseif encounterNum == 8Showmessage DebugMESSset enGo to 1elseif encounterNum == 10;Do nothingset enGo to 1elseif encounterNum == 10Showmessage DebugMESSset enGo to 1ENDIFENDIF
User avatar
~Amy~
 
Posts: 3478
Joined: Sat Aug 12, 2006 5:38 am

Post » Wed May 02, 2012 11:49 am

You have two '10's which is probably a typo. One of them probably should be a '9'.
User avatar
suniti
 
Posts: 3176
Joined: Mon Sep 25, 2006 4:22 pm

Post » Wed May 02, 2012 5:20 pm

You have two '10's which is probably a typo. One of them probably should be a '9'.
Yea typo lol one last question on 'Return' does 'Return' stop rest of the code from executing? here is it so far
SCN CUSRINLinPoopleattSCRPTshort enGo ; 1 = start the encounter ;2 = encounter not doneshort EnReturn	; 1 = cancel encountershort encounterNumshort EnEnd ;set to 1 from a different script (the NPCs  script)BEGIN GameModeif player.getincell OldOlney01 == 0 ;PC is now  not in the cell OldOlney01if EnReturn == 1 ; used if one or more of the NPCs are still dead and has not being respawned yet.set EnReturn to 0 ; sets back to 0Return ;******THISendifif enGo ==1 && EnEnd ==0set enGo to 0elseif enGo == 2 && EnEnd ==1set enGo to 0set enEnd to 0endifendifendifif player.getincell OldOlney01 == 1 && enGo == 0 && EnEnd == 0                                     set encounterNum to  GetRandomPercent * 1/10                if encounterNum == 1;Do nothing                      set enGo to 1                    elseif encounterNum >= 2 && encounterNum <=4                    if CUSRENLinPeopleF44MagREF.getdead == 0 && CUSRENLinPeopleMREF.getdead == 0CUSRENLinPeopleF44MagREF.enableCUSRENLinPeopleMREF.enableCUSRENLinPeopleF44MagREF.moveto playerCUSRENLinPeopleMREF.moveto playerset enGo to 2elseset EnReturn to 1 ;Err One or both NPCs are dead cancel encounter for now.Return ;******THISendifelseif encounterNum == 5set enGo to 1elseif encounterNum == 6set enGo to 1  ;Do nothing set to 1 to stop code from executing till PC reenters cell OldOlney01elseif encounterNum == 7set enGo to 1  ;Do nothing set to 1 to stop code from executing till PC reenters cell OldOlney01elseif encounterNum == 8set enGo to 1  ;Do nothing set to 1 to stop code from executing till PC reenters cell OldOlney01elseif encounterNum == 9set enGo to 1   ;Do nothing set to 1 to stop code from executing till PC reenters cell OldOlney01elseif encounterNum == 10set enGo to 1  ;Do nothing set to 1 to stop code from executing till PC reenters cell OldOlney01ENDIFENDIFEND

Nothing much for the NPCs scr
SCN LinPeopEn01SCRshort DeathCounterBEGIN ondeathset DeathCounter to DeathCounter +1if DeathCounter >=2set DeathCounter to 0set CUSRINLinPeopleatt.EnEnd to 1endifEND
User avatar
Lauren Dale
 
Posts: 3491
Joined: Tue Jul 04, 2006 8:57 am

Post » Wed May 02, 2012 10:08 am

I cant read your script easily without being indented for each IF/Endif block of code. (like my example above)

You can read up on the http://cs.elderscrolls.com/constwiki/index.php/Return command there.
User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am


Return to Fallout 3