Home   Help Search Login Register  

Author Topic: Generating percentages.  (Read 715 times)

0 Members and 1 Guest are viewing this topic.

klavan

  • Guest
Generating percentages.
« on: 21 Jul 2004, 21:25:09 »
Look at this:

_Unit = _this select 0
_s1 = _this select 1
_s2 = _this select 2
_s3 = _this select 3
_s4 = _this select 4
_HQ = _this select 5

_number = Random 100

~5
?(_number <= 35) : goto "Exit"
?(_number > 35) && (_number <= 45) : goto "1Left"
?(_number > 45) && (_number <= 55) : goto "2Left"
?(_number > 55) && (_number <= 65) : goto "3Left"
?(_number > 65) : goto "DeadPlan"

I think I't's clear that I'm trying to generate a number usefull for a percentage-chance event. Nevertheless, after 30 and more tests, the result is always the same ("DeadPlan", line 13). I've tried to change the random-generated number (line 7) and the the results of the variables (lines 9 to 13), but nothing seem to be helpfull.
Any help?
Thanks in advance.
A rookie.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Generating percentages.
« Reply #1 on: 21 Jul 2004, 21:47:24 »
Can't see anything wrong with it. It should work just the way it is, unless the error is somewhere further in your script ie. in the bookmarks.

/edit
You're not using it in a multiplayer mission are you?
« Last Edit: 21 Jul 2004, 21:48:07 by Artak »
Not all is lost.

Offline Messiah

  • Honourary OFPEC Patron & Drinking Buddy of Wolfsbane
  • Honoured Contributor
  • ***
  • OFPEC Veteran
    • Project UK Forces
Re:Generating percentages.
« Reply #2 on: 21 Jul 2004, 21:58:36 »
not really helping finding whats wrong... but im wondering why u've set your script out the way you have - u dont need to set both ends of the paramters at all... just the higher one and make sure they're in order... so your script will become:

Code: [Select]
_Unit = _this select 0
_s1 = _this select 1
_s2 = _this select 2
_s3 = _this select 3
_s4 = _this select 4
_HQ = _this select 5

_number = Random 100

~5
?_number <= 35 : goto "Exit"
?_number <= 45  ) : goto "1Left"
?_number <= 55  : goto "2Left"
?_number <= 65  : goto "3Left"
?_number <= 100 : goto "DeadPlan"

remember the script reads things in order, so you only need to state each higher end of the parameter, not both ends  ;)

Proud Member of the Volunteer Commando Battalion

klavan

  • Guest
Re:Generating percentages.
« Reply #3 on: 21 Jul 2004, 22:05:02 »
1) Because this is my first attempt with the "Random" , I've tested It adding only a TiltleText-line to the bookmarks, to verify the exactness of the syntax in the preview. But the result is always the same....for past 40 times.....  :-\
2) I'm creating this script for a SP mission.
 

klavan

  • Guest
Re:Generating percentages.
« Reply #4 on: 21 Jul 2004, 22:23:35 »
No changes...after 12 tests.
Last syntax:

; Unit selection
_Unit = _this select 0

; Percentage generator
_number = Random 100

; Consequence selection
~5
?_number <= 35 : goto "WellDone"
?_number <= 45 : goto "1Left"
?_number <= 55 : goto "2Left"
?_number <= 65 : goto "3Left"
?_number <= 100 : goto "DeadPlan"

#WellDone
Titletext ["1","Plain down"]

#1Left
Titletext ["2","Plain down"]

#2Left
Titletext ["3","Plain down"]

#3left
Titletext ["4","Plain down"]

#DeadPlan
Titletext ["5","Plain down"]
« Last Edit: 21 Jul 2004, 22:27:38 by klavan »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Generating percentages.
« Reply #5 on: 21 Jul 2004, 22:34:42 »
See now it's just what I said it would be. You'r not exiting the script after it jumps to a certain bookmark. The script swoops through all the bookmarks and the last titletext will be shown, in this case "5"

Code: [Select]
; Unit selection
_Unit = _this select 0

; Percentage generator
_number = Random 100

; Consequence selection
~5
?_number <= 35 : goto "WellDone"
?_number <= 45 : goto "1Left"
?_number <= 55 : goto "2Left"
?_number <= 65 : goto "3Left"
?_number <= 100 : goto "DeadPlan"

#WellDone
Titletext ["1","Plain down"]
exit
#1Left
Titletext ["2","Plain down"]
exit
#2Left
Titletext ["3","Plain down"]
exit
#3left
Titletext ["4","Plain down"]
exit
#DeadPlan
Titletext ["5","Plain down"]
exit
Not all is lost.

klavan

  • Guest
Re:Generating percentages.
« Reply #6 on: 21 Jul 2004, 22:47:03 »
Damn! It seem  like that I coming back to school... :-[
Thanks guys, It's all OK now!  :thumbsup:
PS: Sorry for my english, I know It's not the best in the plaza.
CiaoCiao.