![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
![]() |
#11 |
Ace of the Deep
![]() Join Date: Apr 2002
Location: UK
Posts: 1,278
Downloads: 0
Uploads: 0
|
![]()
* int IRandom(int min, int max);
* Gives an integer random number in the interval min <= x <= max. * (max-min < MAXINT). * The resolution is the same as for Random(). the above an explanation of the irandom code function from microsoft.com /////////////////////////////////////////////////////////////////////// and here an example of it's use in an functioning SOF mission script irandom [num1],$1,$27 ////////////////////////////////////// If <Boolean expression> then one or more statements that are executed if the Boolean expression is true Else one or more statements that are executed if the Boolean expression is false End If the above an explanation of the IF ELSE function from microsoft.com ///////////////////////////////////// and here it's use in a functioning this time entirely STOCK SOF mission script if SetCondition [feind1] then KiSetCommand [ship1],$9,8000,4000,3000,[feind1] else if !Setcondition [order1] then SimSetSpeeddirect [ship1],10 KiSetCommand [ship1],$d,-0.785,10,0,$0 endif endif ////////////////// and here i have combined both functions to randomise the early war campaign # Nah Patrouille 23.08.1914 ( 3001) id mysim int num int num1 int num2 int num3 int num4 int num5 int numT float gt int processed int weather int processed2 int weather2 int processed3 int weather3 phase init SetDescriptionMapTexture "ordermap_nordsee.jpg" SetTimeLimit $0 StartTime 11.0, 15.0 CampaignStartDate ChangeGeoPivot 8,53 irandom [num],$1,$3 if sameint [num],$1 then Weather "sun" endif if sameint [num],$2 then Weather "rainsun" endif if sameint [num],$3 then Weather "sunrise" endif irandom [numT],$1,$27 if sameint [numT],$1 then *SDensity1914 endif if sameint [numT],$2 then *SDensity1914 *TOstengland endif if sameint [numT],$3 then *SDensity1914 *TOstengland *TKanal endif if sameint [numT],$4 then *SDensity1914 *TOstengland *TKanal *PKanal endif if sameint [numT],$5 then *SDensity1914 *TOstengland *TKanal *PKanal *MKanal endif if sameint [numT],$6 then *SDensity1914 *TOstengland *TKanal *PKanal *MKanal *MNordSee endif if sameint [numT],$7 then *TOstengland *TKanal *PKanal *MKanal *MNordSee endif if sameint [numT],$8 then *TKanal *PKanal *MKanal *MNordSee endif if sameint [numT],$9 then *PKanal *MKanal *MNordSee endif if sameint [numT],$10 then *MKanal *MNordSee endif if sameint [numT],$11 then *SDensity1914 *MKanal *MNordSee endif if sameint [numT],$12 then *SDensity1914 *TKanal *PKanal *MKanal endif if sameint [numT],$13 then *SDensity1914 *TOstengland *MNordSee endif if sameint [numT],$14 then *TOstengland *MNordSee endif if sameint [numT],$15 then *TOstengland *PKanal *MKanal endif if sameint [numT],$16 then *TOstengland *PKanal *MKanal *MNordSee endif if sameint [numT],$17 then *TKanal *PKanal endif if sameint [numT],$18 then *TOstengland *TKanal *MNordSee endif if sameint [numT],$19 then *MNordSee endif if sameint [numT],$20 then *MKanal endif if sameint [numT],$21 then *TKanal *MNordSee endif if sameint [numT],$22 then *SDensity1914 *PKanal *MNordSee endif if sameint [numT],$23 then *SDensity1914 *MNordSee endif if sameint [numT],$24 then *SDensity1914 *TKanal *MKanal *MNordSee endif if sameint [numT],$25 then *TOstengland *PKanal *MNordSee endif if sameint [numT],$26 then *PKanal *MKanal endif if sameint [numT],$27 then *TOstengland endif CreateSimulationObject [mysim],"ufp" SetPositionGeo [mysim],8.214,53.5399,0 BindToController [mysim] irandom [num1],$1,$27 if sameint [num1],$1 then DefineMissionGoal $0,"StayArea", 6.353, 55.608, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$2 then DefineMissionGoal $0,"StayArea", 5.338, 54.577, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$3 then DefineMissionGoal $0,"StayArea", 6.353, 55.608, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$4 then DefineMissionGoal $0,"StayArea", 3.483, 52.963, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$5 then DefineMissionGoal $0,"StayArea", 3.277, 51.486, 10000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$6 then DefineMissionGoal $0,"StayArea", 3.183, 51.744, 30000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$7 then DefineMissionGoal $0,"StayArea", 2.455, 51.389, 30000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$8 then DefineMissionGoal $0,"StayArea", 3.183, 51.744, 30000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$9 then DefineMissionGoal $0,"StayArea", 2.455, 51.389, 30000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Targetz Area" endif if sameint [num1],$10 then DefineMissionGoal $0,"StayArea", 4.167, 58.484, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$11 then DefineMissionGoal $0,"StayArea", 3.651, 59.862, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$12 then DefineMissionGoal $0,"StayArea", 7.466, 57.417, 60000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$13 then DefineMissionGoal $0,"StayArea", 3.234, 54.680, 30000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$14 then DefineMissionGoal $0,"StayArea", 0.604, 57.668, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$15 then DefineMissionGoal $0,"StayArea", -2.840, 58.852, 30000, $2d0 SetMissionGoalText $0,"Go to Target Area",$1,"Target Area" endif if sameint [num1],$16 then DefineMissionGoal $0,"StayArea", 3.901, 52.581, 15000, $2d0 SetMissionGoalText $0,"Go to Target Area",$1,"Target Area" endif if sameint [num1],$17 then DefineMissionGoal $0,"StayArea", -1.141, 56.265, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$18 then DefineMissionGoal $0,"StayArea", 10.372, 66.666, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$19 then DefineMissionGoal $0,"StayArea",6.788, 64.595, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$20 then DefineMissionGoal $0,"StayArea", -3.742, 60.263, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$21 then DefineMissionGoal $0,"StayArea", 0.854, 60.847, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$22 then DefineMissionGoal $0,"StayArea", -1.425, 56.569, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$23 then DefineMissionGoal $0,"StayArea",0.721, 55.679, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$24 then DefineMissionGoal $0,"StayArea", 0.253,55.287, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$25 then DefineMissionGoal $0,"StayArea", -1.141, 56.265, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$26 then DefineMissionGoal $0,"StayArea", -11.069, 53.020, 75000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif if sameint [num1],$27 then DefineMissionGoal $0,"StayArea", -0.818, 55.641, 50000, $2d0 SetMissionGoalText $0,"Patrol in Target Area",$1,"Target Area" endif DefineMissionGoal $1,"StayArea", 8.129, 53.49, 3000, $1,$3 SetMissionGoalText $1,"Rückkehr zur Basis",$1,"Heimatgebiet" ApplyStateEngine $0,"FleeNorth#borneo#6.353,55.608,50000,720#0" #Mission ApplyStateEngine $0,"TradeRouteFour#Borneo,1#-1.698,56.719#1.593,53.601#6.840,54.450#-1.698,56.719#12" ApplyStateEngine $0,"TradeRouteFour#Berberis,2#2.380,51.776#4.047,5 5.892#-2.069,58.676#5.218,54.278#15" ApplyStateEngine $0,"Traderoutefour#Prometheus,3#-2.704,56.143#-0.795,56.081#0.858,53.377#1.975,52.607#10" irandom [num2],$1,$11 if sameint [num2],$1 then ApplyStateEngine $0,"ThreePoint#lion#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#10" ApplyStateEngine $0,"ThreePoint#zerst3#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#10" endif if sameint [num2],$2 then ApplyStateEngine $0,"ThreePoint#iron_duke#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#11" ApplyStateEngine $0,"ThreePoint#zerst3#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#11" endif if sameint [num2],$3 then ApplyStateEngine $0,"ThreePoint#iron_duke#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#12" ApplyStateEngine $0,"ThreePoint#lion#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#12" endif if sameint [num2],$4 then ApplyStateEngine $0,"ThreePoint#aylwn#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#13" ApplyStateEngine $0,"ThreePoint#zerst2#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#13" endif if sameint [num2],$5 then ApplyStateEngine $0,"ThreePoint#aylwn#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#14" ApplyStateEngine $0,"ThreePoint#cuba#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#14" endif if sameint [num2],$6 then ApplyStateEngine $0,"ThreePoint#cressy#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#15" ApplyStateEngine $0,"ThreePoint#zerst2#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#15" endif if sameint [num2],$7 then ApplyStateEngine $0,"ThreePoint#iron_duke#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#16" ApplyStateEngine $0,"ThreePoint#zerst3#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#16" endif if sameint [num2],$8 then ApplyStateEngine $0,"ThreePoint#iron_duke#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#17" ApplyStateEngine $0,"ThreePoint#lion#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#17" endif if sameint [num2],$9 then ApplyStateEngine $0,"ThreePoint#aylwn#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#18" ApplyStateEngine $0,"ThreePoint#zerst2#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#18" endif if sameint [num2],$10 then ApplyStateEngine $0,"ThreePoint#aylwn#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#19" ApplyStateEngine $0,"ThreePoint#cuba#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#19" endif if sameint [num2],$11 then ApplyStateEngine $0,"ThreePoint#cressy#-2.600,58.900,300000000#-0.200,59.900#-0.400,57.700#20" ApplyStateEngine $0,"ThreePoint#zerst2#-2.615,58.900,300000000#-0.200,59.900#-0.400,57.700#20" endif irandom [num3],$1,$3 if sameint [num3],$1 then AddPositionTracker $1,$630,"Von Admiralität.\\To .\U-Boote.\Hostile contact.\\Position: %s\Course: %d\\Instructions,\if possible.\Attack.\if current orders\allow!" endif if sameint [num3],$2 then AddPositionTracker $2,$630,"Von Admiralität.\\To .\U-Boote.\Enemy contact.\\Position: %s\Course: %d\\Instructions,\Confirm this contact.\ And Attack.\if current orders allow\Kaptain!" endif if sameint [num3],$3 then AddPositionTracker $3,$630,"Von Admiralität.\\To .\U-Boote.\British contact.\\Position: %s\Course: %d\\Instructions,\Confirm this contact.\ And Attack.\if current orders allow\Kaptain!" endif irandom [num4],$1,$3 if sameint [num4],$1 then AddRandomShips "Attack#zerst3#6.840,54.450,200000#20",1120 endif if sameint [num4],$2 then AddRandomShips "Attack#zerst3#0.858,53.377,200000#20",1120 endif if sameint [num4],$3 then AddRandomShips "Attack#zerst3#2.380,51.776,200000#20",1120 endif irandom [num5],$1,$3 if sameint [num5],$1 then ApplyStateEngine $0,"TradeRouteFour#Zerst3#-1.679,56.726#1.593,53.601#6.840,54.450#-1.698,56.719#12" endif if sameint [num5],$2 then ApplyStateEngine $0,"TradeRouteFour#Zerst3#2.389,51.789#4.047,55.89 2#-2.069,58.676#5.218,54.278#15" endif if sameint [num5],$3 then ApplyStateEngine $0,"Traderoutefour#zerst3#-2.712,56.148#-0.795,56.081#0.858,53.377#1.975,52.607#10" endif EveryFrame CompleteOnGoal "Willkommen zu Hause!",$2 irandom [weather],$1,$3 if sameint [weather],$1 then GameTime [gt] ifall sameint [processed],$0 greater [gt],36000 then Weather "mgrain" setint [processed],$1 endif endif if sameint [weather],$2 then GameTime [gt] ifall sameint [processed],$0 greater [gt],36000 then Weather "mgfog" setint [processed],$1 endif endif if sameint [weather],$3 then GameTime [gt] ifall sameint [processed],$0 greater [gt],36000 then Weather "mgsun" setint [processed],$1 endif endif irandom [weather2],$1,$3 if sameint [weather2],$1 then GameTime [gt] ifall sameint [processed2],$0 greater [gt],70000 then Weather "mgsun" setint [processed2],$1 endif endif if sameint [weather2],$2 then GameTime [gt] ifall sameint [processed2],$0 greater [gt],70000 then Weather "mgrain" setint [processed2],$1 endif endif if sameint [weather2],$3 then GameTime [gt] ifall sameint [processed2],$0 greater [gt],70000 then Weather "mgfog" setint [processed2],$1 endif endif irandom [weather3],$1,$3 if sameint [weather3],$1 then GameTime [gt] ifall sameint [processed3],$0 greater [gt],280000 then Weather "mgsun" setint [processed3],$1 endif endif if sameint [weather3],$2 then GameTime [gt] ifall sameint [processed3],$0 greater [gt],280000 then Weather "mgrain" setint [processed3],$1 endif endif if sameint [weather3],$3 then GameTime [gt] ifall sameint [processed3],$0 greater [gt],280000 then Weather "mgfog" setint [processed3],$1 endif endif Endphase end showing perfectly how the raw VB code has been combined with the more natural SOF mission script code to randomise the in mission events...the as i have allready stated truly remarkable thing here is that you do not need an external mission generator to do this...the actual SOF mission script it self becomes the mission generator in effect... i DO hope this doesn't freak any one else out.(or perhaps that should be any-one ELSE IF out)..as i'm getting a bit tired of it by now....:rotfl: grow up people a jokes a joke...but rank stupidity is just rank stupidity and i wouldn't want to think that of any-body here...? or should i? the only possible argument is to debate what PRECISE form of code we are talking about here.. visual basic..visual studio..visual net..C++ even perhaps javascript....but that would be nit picking to the extreme as these functions are used in one shape or another by nearly if not all such code if you cannot believe it works.....download the campaign and run it...if you cannot believe it works after that then contact microsoft and inform them of their mistakes ...or consult a doctor..
__________________
the world's tinyiest sh3 supermod- ![]() and other SH3/SH2 stuff http://www.ebort2.co.uk/ The best lack all conviction, while the worst Are full of passionate intensity. W.B.Yeats Last edited by CB..; 09-29-07 at 04:46 PM. |
![]() |
![]() |
|
|