Jump to content
Sign in to follow this  
XCess

Randomised Objectives (MP)

Recommended Posts

I'm making a large mission with two randomised objectives and a randomised convoy, but having trouble showing these objectives in the initial briefing.

THe scripts defining the objectives:

Init.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; HIDE ALL OBJECTIVES

"1" ObjStatus "HIDDEN"

"2" ObjStatus "HIDDEN"

"3" ObjStatus "HIDDEN"

"4" ObjStatus "HIDDEN"

"5" ObjStatus "HIDDEN"

;"6" ObjStatus "HIDDEN"

"7" ObjStatus "HIDDEN"

"8" ObjStatus "HIDDEN"

"9" Objstatus "HIDDEN"

"10" ObjStatus "HIDDEN"

[] exec "showObjects.sqs"

? !(local server): exit

; DEFINE OBJECTIVE VARIABLES

; These Variables will tell the triggers which objectives are activr

xs_conv1 = false

xs_conv2 = false

object1A = false

object1B = false

object1C = false

object1D = false

object1D = false

takeGravette = false

takeLeMoule = false

takeRegina = false

takeStPierre = false

_nomin_random = random 1

? _nomin_random <= 0.5: {deleteVehicle _x} forEach units nomin_convoy1; deletevehicle nomin_convoyTruck1; deleteVehicle conTone; deletevehicle conRone; deletevehicle conAone; deleteVehicle conBone; xs_conv2 = true

? _nomin_random > 0.5: {deleteVehicle _x} forEach units nomin_convoy2;; deletevehicle nomin_convoyTruck2; deleteVehicle conTtwo; deleteVehicle conRtwo; deleteVehicle conAtwo; deleteVehicle conBtwo; xs_conv1 = true

_ob1_random = random 5

_ob1_num = _ob1_random - (_ob1_random mod 1)

;hint format ["objective: %1",_ob1_num]

? _ob1_num == 0 : goto "obj1_A"

? _ob1_num == 1 : goto "obj1_B"

? _ob1_num == 2 : goto "obj1_C"

? _ob1_num == 3 : goto "obj1_D"

? _ob1_num == 4 : goto "obj1_E"

; OBJECTIVE 1A KILL OFFICER

#obj1_A

xs_ob1 = "1"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1A = true

;hint "killofficer"

goto "objective3"

; OBJECTIVE 1B KILL SPETSNAS GROUP

#obj1_B

xs_ob1 = "3"

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offCar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1B = true

;hint "kill spets"

goto "objective3"

; OBJECTIVE 1C KILL Mi17 HELO

#obj1_C

xs_ob1 = "2"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offCar

object1C = true

;hint "kill helo"

goto "objective3"

; OBJECTIVE 1D KILL PROVINS FUEL STATION

#obj1_D

xs_ob1 = "4"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offcar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1D = true

;hint "kill provins fuel station"

goto"objective3"

; OBJECTIVE 1E KILL TYRONE FUEL STATION

#obj1_E

xs_ob1 = "5"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offcar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1E = true

;hint "kill tyrone fuel station"

#OBJECTIVE3

_ob3_random = random 4

_ob3_num = _ob3_random - (_ob3_random mod 1)

? _ob3_num == 0 : takeGravette = true; xs_ob3 = "8"

? _ob3_num == 1 : takeLeMoule = true; xs_ob3 = "7"

? _ob3_num == 2 : takeRegina = true; xs_ob3 = "9"

? _ob3_num == 3 : takeStPierre = true;xs_ob3 = "10"

runObjects = true

exit

ShowObjects.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@runObjects

xs_ob1 objStatus "ACTIVE"

xs_ob3 objStatus "ACTIVE"

All this works fine server side, but not on other comps. Is there any way to fix this so I can show objectives in the initial briefing, or will I have to show them later on?

Share this post


Link to post
Share on other sites

You seem to be missing a whole lot of publicvariable commands there unless they're all in a separate script.

Just in case... For a client to see a variable that has been set in a server-side script, you must publicvariable "variablename" it. Like:

?not local server : exit

objectives = 1+2+16+64+128

showobjectives = true

publicvariable "objectives"

publicvariable "showobjectives"

Share this post


Link to post
Share on other sites

ah, thanks for that. must be the whole problem.. i feel like such a n00b icon_rolleyes.gif

Share this post


Link to post
Share on other sites

I've updated the script with publicVariables, but I still seem to be missing something. I'm totally new to mp scripting after the past 4 years of SP only, so bear with me tounge2.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; HIDE ALL OBJECTIVES

"1" ObjStatus "HIDDEN"

"2" ObjStatus "HIDDEN"

"3" ObjStatus "HIDDEN"

"4" ObjStatus "HIDDEN"

"5" ObjStatus "HIDDEN"

;"6" ObjStatus "HIDDEN"

"7" ObjStatus "HIDDEN"

"8" ObjStatus "HIDDEN"

"9" Objstatus "HIDDEN"

"10" ObjStatus "HIDDEN"

[] exec "showObjects.sqs"

? !(local server): exit

; DEFINE OBJECTIVE VARIABLES

; These Variables will tell the triggers which objectives are activr

xs_conv1 = false

xs_conv2 = false

object1A = false

object1B = false

object1C = false

object1D = false

object1E = false

takeGravette = false

takeLeMoule = false

takeRegina = false

takeStPierre = false

xs_ob1 = "0"

xs_ob3 = "0"

runObjects = false

publicVariable "xs_conv1"

publicVariable "xs_conv2"

publicVariable "object1A"

publicVariable "object1B"

publicVariable "object1C"

publicVariable "object1D"

publicVariable "object1D"

publicVariable "object1E"

publicVariable "takeGravette"

publicVariable "takeLeMoule"

publicVariable "takeRegina"

publicVariable "takeStPierre"

publicVariable "runObjects"

publicVariable "xs_ob1"

publicvariable "xs_ob3"

_nomin_random = random 1

? _nomin_random <= 0.5: {deleteVehicle _x} forEach units nomin_convoy1; deletevehicle nomin_convoyTruck1; deleteVehicle conTone; deletevehicle conRone; deletevehicle conAone; deleteVehicle conBone; xs_conv2 = true

? _nomin_random > 0.5: {deleteVehicle _x} forEach units nomin_convoy2;; deletevehicle nomin_convoyTruck2; deleteVehicle conTtwo; deleteVehicle conRtwo; deleteVehicle conAtwo; deleteVehicle conBtwo; xs_conv1 = true

_ob1_random = random 5

_ob1_num = _ob1_random - (_ob1_random mod 1)

;hint format ["objective: %1",_ob1_num]

? _ob1_num == 0 : goto "obj1_A"

? _ob1_num == 1 : goto "obj1_B"

? _ob1_num == 2 : goto "obj1_C"

? _ob1_num == 3 : goto "obj1_D"

? _ob1_num == 4 : goto "obj1_E"

; OBJECTIVE 1A KILL OFFICER

#obj1_A

xs_ob1 = "1"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1A = true

;hint "killofficer"

goto "objective3"

; OBJECTIVE 1B KILL SPETSNAS GROUP

#obj1_B

xs_ob1 = "3"

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offCar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1B = true

;hint "kill spets"

goto "objective3"

; OBJECTIVE 1C KILL Mi17 HELO

#obj1_C

xs_ob1 = "2"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offCar

object1C = true

;hint "kill helo"

goto "objective3"

; OBJECTIVE 1D KILL PROVINS FUEL STATION

#obj1_D

xs_ob1 = "4"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offcar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1D = true

;hint "kill provins fuel station"

goto"objective3"

; OBJECTIVE 1E KILL TYRONE FUEL STATION

#obj1_E

xs_ob1 = "5"

{deleteVehicle _x} forEach units xs_spets

{deleteVehicle _x} forEach units xs_officer

deleteVehicle xs_offcar

{deleteVehicle _x} forEach units xs_transHelo

deleteVehicle tranMI

object1E = true

;hint "kill tyrone fuel station"

#OBJECTIVE3

_ob3_random = random 4

_ob3_num = _ob3_random - (_ob3_random mod 1)

? _ob3_num == 0 : takeGravette = true; xs_ob3 = "8"

? _ob3_num == 1 : takeLeMoule = true; xs_ob3 = "7"

? _ob3_num == 2 : takeRegina = true; xs_ob3 = "9"

? _ob3_num == 3 : takeStPierre = true;xs_ob3 = "10"

runObjects = true

exit

Share this post


Link to post
Share on other sites

You need to use publicvariable after each time you change the variable. Like:

?not local server : exit

A=1

publicvariable "A"

A=2

;at this point clients still see A==1 even though it's A==2 on the server

publicvariable "A"

;now the new value of A is transmitted to them so they see a==2

Share this post


Link to post
Share on other sites

Will this also work on the same line, seperated by a semi colon?

e.g

runObjects = true; publicVariable "runObjects"

Share this post


Link to post
Share on other sites

Sure, why not. It's just that having commands in a single line makes the code harder to follow. Example line from DAC (must be a world record):

?((count (_this select 2) + count (_this select 3) + count (_this select 4) + count (_this select 5)) == 0) || ((count (_this select 1)) < 3) || (((count (_this select 1)) > 3) && (!((count (_this select 1)) == 5))) || (((count (_this select 2)) < 4) && (!((count (_this select 2)) <= 1))) || ((count (_this select 2)) > 5) || (((count (_this select 3)) < 4) && (!((count (_this select 3)) <= 1))) || ((count (_this select 3)) > 5) || (((count (_this select 4)) < 4) && (!((count (_this select 4)) <= 1))) || ((count (_this select 4)) > 5) || (((count (_this select 5)) < 3) && (!((count (_this select 5)) <= 1))) || ((count (_this select 5)) == 5) || ((count (_this select 5)) > 7) || ((count (_this select 6)) < 3) || ((count (_this select 6)) > 3):hintc format["Attention, in at least one zone\nthere is a faulty one script call.\n\nEither parameters were handed over\nnot enough, or too many parameters\nwere handed over...\n\n%1\n%2\n%3\n%4\n%5\n%6\n\nPosition of the faulty zone:\n\nX = %7 | Y = %8",_this select 1,_this select 2,_this select 3,_this select 4,_this select 5,_this select 6,getpos _KiZone select 0,getpos _KiZone select 1];DAC_Basic_Value = 2;publicvariable "DAC_Basic_Value";exit

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×