OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: klavan on 16 Jul 2004, 00:54:32

Title: What's wrong with this?
Post by: klavan on 16 Jul 2004, 00:54:32
#Sightning
?(_Unit knowsabout _Shilka1 >0) then (_Marker1 SetMarkerType "WARNING")
?(_Unit knowsabout _Shilka2 >0) then (_Marker2 SetMarkerType "WARNING")
?!(alive _Shilka1) and ?!(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

I want to put two markers over the Shilkas when _Unit detect 'em and then close the script when both are destroyed. I'had put two "empty" markers on the map, named 'em, etc... But I gained no effect.
In addiction an error message occour in the line (4th) that should be determining the Shilkas's status. Where's the problem? I tried various sintax combinations, but no one seem to be the right one!
Thanks in advance for any help to a newbie scripter!
CiaoCiao!!!
Title: Re:What's wrong with this?
Post by: ponq on 16 Jul 2004, 01:02:52
replace "then" with  ":"

?(_Unit knowsabout _Shilka1 >0) : (_Marker1 SetMarkerType "WARNING")
Title: Re:What's wrong with this?
Post by: klavan on 16 Jul 2004, 01:14:41
I tried, but nothing appear!  ???
Here's the full script:

_Unit = _this select 0
_Shilka1 = _this select 1
_Shilka2 = _this select 2
_Marker1 = _this select 3
_Marker2 = _this select 4

#Sightning
?(_Unit knowsabout _Shilka1 >0) : (_Marker1 SetMarkerType "WARNING")
?(_Unit knowsabout _Shilka2 >0) : (_Marker2 SetMarkerType "WARNING")
?!(alive _Shilka1) and ?!(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit
Title: Re:What's wrong with this?
Post by: macguba on 16 Jul 2004, 01:19:41
If you get an erro message quote it here exactly so we know what it says.

setMarker commands need strings as arguments so maybe it should be

"_marker1"

You have too many ? in the fourth line, one at the start is sufficient.   Thereafter use brackets ( ) to make it make sense logically.

Also, it's not always good practice to use alive with a vehicle:  the vehicle can look destroyed when it isn't, which is confusing for the player.     Better is

not canMove S1 and not canFire S1

you can add not alive conditions for the crew as well if you like.  
Title: Re:What's wrong with this?
Post by: klavan on 16 Jul 2004, 01:36:06
Well, i Think it's too late for a test, just now. Tomorrow I'm sure that all will be much more clear than now. Goodnight to all the folks and thanks.
Title: Re:What's wrong with this?
Post by: Messiah on 16 Jul 2004, 02:03:39
Code: [Select]
?((_Unit knowsabout _Shilka1) >0) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >0) : ("_Marker2" SetMarkerType "WARNING")
?!(alive _Shilka1) and !(alive _Shilka2) : goto "Done"
~1
goto "Sightning"

that should do it i think... ':' and 'then' are the same thing
one thing i'm wondering about is isn't the knowsabout a little small? this script will fire very early on as the unit aproaches the shilka...
Title: Re:What's wrong with this?
Post by: ponq on 16 Jul 2004, 12:05:19
Quote
':' and 'then' are the same thing

Does that mean you can use both in ofp?
Title: Re:What's wrong with this?
Post by: Messiah on 16 Jul 2004, 12:21:02
i can't see why not, but i've never used 'then' before in a script - ':' is much simpler to use
Title: Re:What's wrong with this?
Post by: klavan on 16 Jul 2004, 13:15:34
Ok, here's the last version:

;Objective2 Script
;EXECUTION:
;[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,"_Marker1Name","_Marker1Name"] exec "obj2.sqs"


_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5


#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : (_Marker1 SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : (_Marker2 SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit

The line determining the Shilkas status now run properly.  ;)
Those that should place the Markers, not. If I'm not in mistake, passing string into a script is determined by the " in the execution commands, as reported above. So quoting the names of the markers transform 'em into strings that should be read by the setmarkertype command, making unecessary quoting _Marker1 and _Marker2 in the scripts.
Or not.......  ???
   
Title: Re:What's wrong with this?
Post by: Messiah on 16 Jul 2004, 13:24:10
read my original post - u've missed out the "" again on the marker bit  ::)

Code: [Select]
("_Marker1" SetMarkerType "WARNING")

that should now work, so you script will look like this:

Code: [Select]
Objective2 Script
;EXECUTION:
;[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,_Marker1Name,_Marker1Name] exec "obj2.sqs"


_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5


#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : ("_Marker2" SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit


also noticed this:

Code: [Select]
[_UnitName,_MateName,_Shilka1Name,_Shilka2Name,"_Marker1Name","_Marker1Name"] exec "obj2.sqs"
don't add the "" on the marker bits there, just use their name, "" is just quoting them for the script, not their name. Also, _name is a local variable, as in local to the script, so i don't think you can exec a new script using a local variable... it has to be without the '_', so their editor name
Title: Re:What's wrong with this?
Post by: Tomb on 16 Jul 2004, 13:39:08
 ;D hehehe... them quote marks...  ;D ;D (*shakes head*) :noo:  ;D
Title: Re:What's wrong with this?
Post by: klavan on 16 Jul 2004, 16:25:20
This is a previously script created by me, that run properly:

EXECUTION: [aa,papabear,"Bingo!","Radio"] exec "obj1.sqs"

_Unit = _this select 0
_Hq = _this select 1
MarkerG = _this select 2
MarkerR = _this select 3

~240
"1" ObjStatus "DONE"
_Unit addRating 1000
MarkerG SetMarkerType "WARNING"
~1
_Unit SideChat "blablabla"
~3
_Hq SideChat "blablabla"
~1
"2" ObjStatus "ACTIVE"
"3" ObjStatus "ACTIVE"
MarkerR SetMarkerType "WARNING"
~5
savegame
Exit

The main difference here, as you notice, is that I have setted the markers as global variables, because I want â€Ëœem to remain visible for the entire duration of the scenario (a thing that I will implement in the script that we're talking about).

Here's how I ran the f****d script the last time before to scold my poor niece for nothing: :-[
EXECUTION:[aa,ab,s1,s2,Ma,Mb] exec "obj2.sqs"

_Unit = _this select 0
_Mate = _this select 1
_Shilka1 = _this select 2
_Shilka2 = _this select 3
_Marker1 = _this select 4
_Marker2 = _this select 5

#Sightning
?((_Unit knowsabout _Shilka1) >2) or ((_Mate knowsabout _Shilka1) >2) : ("_Marker1" SetMarkerType "WARNING")
?((_Unit knowsabout _Shilka2) >2) or ((_Mate knowsabout _Shilka2) >2) : ("_Marker2" SetMarkerType "WARNING")
?!(canmove _Shilka1 and canfire _Shilka1) and !(canmove _Shilka2 and canfire _Shilka2) : goto "Done"
~1
goto "Sightning"

#Done
"2" objstatus "DONE"
_Unit addrating 1500
~2
savegame
exit

NOW: I â€Ëœve tried to quote and unquote the names and the variables; I've tried to change the variables from locals to globals (Huu!â€Â¦Bad omen!); I've tried to bracket and unbracket the --("_Marker1" SetMarkerType "WARNING")-- section; I've tried to pray Godâ€Â¦But nothingâ€Â¦ :'(

Title: Re:What's wrong with this?
Post by: h- on 16 Jul 2004, 17:19:44
Couple of facts:
- OFP does not need that humangous amount of brackets... Too much of them actually screws up the script as OFP engine gets confused on what section is supposed to be dealt with first. (afaik... I can be wrong of course ::) )
- markers must be passed into scripts as strings. They are not regular objects, which is probably the reason...
At least I didn't get this script working if I passed the marker names like regular unit names (global variable)...
But when I passed them as strings, it worked...
Actually, I have never had any succes with passing markers into a script if they have not been passed as strings...

Working sript:
Quote
_unit = _this select 0
_mate = _this select 1
_shilka1 = _this select 2
_shilka2 = _this select 3
_marker1 = _this select 4
_marker2 = _this select 5

#sightning
? (_unit knowsAbout _shilka1) > .5 || (_mate knowsAbout _shilka1) > .5: _marker1 setMarkerType "warning"
? (_unit knowsAbout _shilka2) > .5 || (_mate knowsAbout _shilka2) > .5: _marker2 setMarkerType "warning"
? !(canMove _shilka1 && canFire _shilka1) && !(canMove _shilka2 && canFire _shilka2): goto "done"
~1
goto "sightning"

#done
"2" objstatus "done"
_unit addrating 1500
~2
savegame
exit

With knowsAbout .5 the marker appeared when I was about 150 meters away from the vehicle... But of course it's up to you how you want to set it ;)
Title: Re:What's wrong with this?
Post by: klavan on 17 Jul 2004, 00:48:03
 Oh my God! It works!   :thumbsup:
Thanks to all you guys!!  :D