OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Javaman on 14 Jan 2004, 04:48:13
-
;In Game Call=["TriggerName",HowManyBombs,Delay,targetRadius,Title,ObjectType] exec "java.sqs"
;TriggerName=The Name of your Trigger
;HowManyBombs=How many bombs you want to fall
;Delay=Delay between each bomb and this number will be randamized
;targetRadius=how close from the target do u want to have the bombs drop and this number will be randamized (0=perfect)
;Title= find out if it should warn you to take cover or not with a text warning
;Example [bomb,20,40,true,"Shell125"] exec "java.sqs"
TriggerName,AmountofShells,TriggerSize,Title,ObjectType
;========================================================================
; Initialize All Arrays
;========================================================================
_TriggerName=[]
_AmountofShells=[]
_TriggerSize=[]
_Title=[]
_ObjectType=[]
_BreakupTriggerPosXYZ=[]
_x =[]
_y =[]
_z =[]
_ShellPostion=[]
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Initialize All Public Var for Multiplayer
;========================================================================
publicVariable "_TriggerName"
publicVariable "_AmountofShells"
publicVariable "_TriggerSize"
publicVariable "_Title"
publicVariable "_ObjectType"
publicVariable "_BreakupTriggerPosXYZ"
publicVariable "_x"
publicVariable "_y"
publicVariable "_z"
publicVariable "_ShellPostion"
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; GET INFORMATION FROM ARRAY
;========================================================================
;MarkerName
_TriggerName = _this select 0
;HowManyBombs
_AmountofShells = _this select 1
;Random Number for Marker Pos
_TriggerSize=random (_this select 2)
;Next 2 lines with find out if it should warn you to take cover or not
_Title=(_this select 3)
?(_Title) : titletext ["\n\n\n\n\n\n\nTake cover ! INCOMING","plain", 2]
;Create ObjectType (art shell) and make it drop in random postions based on TriggerSize
_ObjectType = _this select 4
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Find Marker Postion so i can make it a random postion
;========================================================================
_BreakupTriggerPosXYZ = GetPos _TriggerName
_x = _BreakupTriggerPosXYZ select 0
_y = _BreakupTriggerPosXYZ select 1
_z = _BreakupTriggerPosXYZ select 2
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Make Label to come back to if need be
;========================================================================
#Loop
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Insert Delay Time
;========================================================================
~(random 3)
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Choose a random shell postion inside the tigger
;========================================================================
_ShellPostion= random 3
_ShellPostion0=0
_ShellPostion1=1
_ShellPostion2=2
_ShellPostion3=3
? _ShellPostion == _ShellPostion0 : _ObjectType camCreate [_x +(random _TriggerSize),_y + (random _TriggerSize),_z]
? _ShellPostion == _ShellPostion1 : _ObjectType camCreate [_x -(random _TriggerSize),_y - (random _TriggerSize),_z]
? _ShellPostion == _ShellPostion2 : _ObjectType camCreate [_x -(random _TriggerSize),_y + (random _TriggerSize),_z]
? _ShellPostion == _ShellPostion3 : _ObjectType camCreate [_x +(random _TriggerSize),_y - (random _TriggerSize),_z]
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; minus one from AmountofShells
;========================================================================
_AmountofShells=_AmountofShells-1
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
; Check amount counter to see if we need to loop again for another Bomb Run
;========================================================================
?(_AmountofShells > 0) : goto "Loop"
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
;========================================================================
;Keep this or del it , made for testing only so i knew when it was done bombing
CreateFlare1 = "FlareGreen" camCreate [_x + _TriggerSize,_y + _TriggerSize,_z + 100]
;////////////////////////////////////////////////////////////////////////////////////////////////////////////
end
the part thats in bold is where im having problems with,
no matter what i do i cannot get it to create the objectType UNLESS i dont make it use a random number...if i just put a number for _ShellPostion like
_ShellPostion=2 it will use
? _ShellPostion == _ShellPostion2 : _ObjectType camCreate [_x -(random _TriggerSize),_y + (random _TriggerSize),_z]
i just dont get it....
can anyone help me?
Thanks Javaman
-
First of all, get rid of all that crap you put in as comments, I think it's easier to read if you just have one line of comments.
EDIT: Now I've read your script and I have no idea. I'm a bit tired cause I just woke up. ::)
:beat: *Gets Shot* :beat:
-
It's because random 3 can give a value like 2,64296 or 0.93759 or whatever like that.
So you see with all the decimals it's actually a very slim chance that _shellposition is ever exactly 0,1,2 or 3.
You'd need to either round the random result using the mod command or take a bigger random and use a 'between' statement.
So,
_ShellPostion= random 100
?_ShellPostion < 25: _shellpostion0 = 0
_ShellPostion => 25 && _shellpostion < 50: _shellpostion1 = 1
_ShellPostion => 50 && _shellpostion < 75: _shellpostion2 = 2
_ShellPostion => 75: _shellpostion3 = 3
? _ShellPostion0 == 0 : _ObjectType camCreate [_x +(random _TriggerSize),_y + (random _TriggerSize),_z]
? _ShellPostion1 == 1 : _ObjectType camCreate [_x -(random _TriggerSize),_y - (random _TriggerSize),_z]
? _ShellPostion2 == 2 : _ObjectType camCreate [_x -(random _TriggerSize),_y + (random _TriggerSize),_z]
? _ShellPostion3 == 3 : _ObjectType camCreate [_x +(random _TriggerSize),_y - (random _TriggerSize),_z]
And btw, shellpostion would be more english if it was typed shellposition
-
Thank You
Javaman
-
I like the heavy duty comments making it really obvious what each section is for.
As Artak said, you can use the command mod to turn a random number into a random whole number
_rand = random 3.9
_num = _rand - (_rand mod 1)
I haven't checked the script, but be aware that in MP random gives a different result on each client. Or something.
-
thanks and i am aware of the mp issue and i thought by using
publicVariable
that would fix it...am i wrong
this is my very first script for ofp...hell i have only played the game for less then 2 weeks :)
Javaman
-
Still on honeymoon? ;D
:beat: *Gets SHot* :beat:
-
Wow, just saw this thread :o
Sorry Javaman, but there are some things really totally
wrong in this script, that will cause parts of your script
not to work in multiplayer anyway.
I'm very short on time right now, so i'm gonna pop up here
later 2nite to tell you about the details.
~S~ CD
-
Thanks Chris
-
Well this one may as well still have the problems at which you will be telling me about tonight but this is my newest version of this script
Javaman
;In Game Call=["TriggerName",HowManyShells,targetRadius,Title,ObjectType,quad1,quad2,quad3,quad4,"DevMode"] exec "java.sqs"
;TriggerName=The Name of your Trigger
;HowManyShells=How many bombs you want to fall
;targetRadius=how close from the target do u want to have the bombs drop
;Title= find out if it should warn you to take cover or not with a text warning
;Object Type=kind of shell you want to use
;quad1=top left kill zone (on=1 off=0)
;quad2=top right kill zone (on=1 off=0)
;quad3=bottom left kill zone (on=1 off=0)
;quad4=bottom right kill zone (on=1 off=0)
;DevMode=With this on it will just pop up a text message telling you what quad is firing and which one is not
;Example [bomb,20,40,true,"Shell125",1,1,1,1,"DevMode"] exec "java.sqs"
;========================================================================
;Initialize All Arrays
;========================================================================
TriggerName=[]
AmountofShells=[]
TriggerSize=[]
Title=[]
ObjectType=[]
BreakupTriggerPosXYZ=[]
x =[]
y =[]
z =[]
ShellPostion=[]
;========================================================================
;Initialize All Public Var for Multiplayer
;========================================================================
publicVariable "TriggerName"
publicVariable "AmountofShells"
publicVariable "TriggerSize"
publicVariable "Title"
publicVariable "ObjectType"
publicVariable "BreakupTriggerPosXYZ"
publicVariable "x"
publicVariable "y"
publicVariable "z"
publicVariable "ShellPosition"
;========================================================================
;GET INFORMATION FROM ARRAY
;========================================================================
;MarkerName
TriggerName = _this select 0
;HowManyBombs
AmountofShells = ((_this select 1) / 4)
;Random Number for Marker Pos
TriggerSize=random (_this select 2)
;Next 3 lines with find out if it should warn you to take cover or not
Title=(_this select 3)
?(Title) : titletext ["\n\n\n\n\n\n\nTake cover ! INCOMING","plain", 2]
~(random 2)
;Create ObjectType (art shell) and make it drop in random postions based on TriggerSize
ObjectType = _this select 4
;========================================================================
;Find Marker Postion so i can make it a random postion
;========================================================================
BreakupTriggerPosXYZ = GetPos TriggerName
x = BreakupTriggerPosXYZ select 0
y = BreakupTriggerPosXYZ select 1
z = BreakupTriggerPosXYZ select 2
;========================================================================
;Make Label to come back to if need be
;========================================================================
#Loop
;========================================================================
; Choose a QUAD position inside the tigger
;========================================================================
;quad1=top left
? (_this select 5) == 1 : ObjectType camCreate [x -(random TriggerSize),y + (random TriggerSize),z]
? (_this select 5) == 1 : DidItFire=True
? (_this select 5) != 1 : DidItFire=False
? (_this select 9) == "DevMode" : titletext [format ["\n\n\n\n\n\n\nQUAD 1=%1.", DidItFire],"plain",1]
~(random 1)
;quad2=top right
? (_this select 6) == 1 : ObjectType camCreate [x +(random TriggerSize),y + (random TriggerSize),z]
? (_this select 6) == 1 : DidItFire=True
? (_this select 6) != 1 : DidItFire=False
? (_this select 9) == "DevMode" : titletext [format ["\n\n\n\n\n\n\nQUAD 2=%1.", DidItFire],"plain",1]
~(random 1)
;quad3=bottom left
? (_this select 7) == 1 : ObjectType camCreate [x -(random TriggerSize),y - (random TriggerSize),z]
? (_this select 7) == 1 : DidItFire=True
? (_this select 7) != 1 : DidItFire=False
? (_this select 9) == "DevMode" : titletext [format ["\n\n\n\n\n\n\nQUAD 3=%1.", DidItFire],"plain",1]
~(random 1)
;quad4=bottom right
? (_this select 8) == 1 : ObjectType camCreate [x +(random TriggerSize),y - (random TriggerSize),z]
? (_this select 8) == 1 : DidItFire=True
? (_this select 8) != 1 : DidItFire=False
? (_this select 9) == "DevMode" : titletext [format ["\n\n\n\n\n\n\nQUAD 4=%1.", DidItFire],"plain",1]
~(random 1)
;========================================================================
;minus one from AmountofShells
;========================================================================
AmountofShells=AmountofShells-1
;========================================================================
;Check amount counter to see if we need to loop again for another Bomb Run
;========================================================================
?(AmountofShells > 0) : goto "Loop"
;========================================================================
;Keep this or del it , made for testing only so i knew when it was done bombing
CreateFlare = "FlareGreen" camCreate [x + TriggerSize,y + TriggerSize,z + 100]
end
-
well Chris after doing some reading I take it this is what is wrong....
http://www.ofpec.com/yabbse/index.php?board=7;action=display;threadid=13549
-
excellent find m8 ;)
Especially that all of your publicVariables do not make
sense, as they will not work.
You cannot publicVariable an array, and all of your variables
are initialized as arrays.
But then again later you reassign them as strings/variables/objects
This makes following lines totally useless:
;========================================================================
;Initialize All Arrays
;========================================================================
TriggerName=[]
AmountofShells=[]
TriggerSize=[]
Title=[]
ObjectType=[]
BreakupTriggerPosXYZ=[]
x =[]
y =[]
z =[]
ShellPostion=[]
;========================================================================
;Initialize All Public Var for Multiplayer
;========================================================================
publicVariable "TriggerName"
publicVariable "AmountofShells"
publicVariable "TriggerSize"
publicVariable "Title"
publicVariable "ObjectType"
publicVariable "BreakupTriggerPosXYZ"
publicVariable "x"
publicVariable "y"
publicVariable "z"
publicVariable "ShellPosition"
Now i can't find any condition in your script so that it will run only one one machine, therefore the use of publicVariable
makes no sense at all, as the script will run everywhere.
Then have a look what happens here:
;HowManyShells=How many bombs you want to fall
AmountofShells=[]
;HowManyBombs
AmountofShells = ((_this select 1) / 4)
;========================================================================
;minus one from AmountofShells
;========================================================================
AmountofShells=AmountofShells-1
;========================================================================
;Check amount counter to see if we need to loop again for another Bomb Run
;========================================================================
?(AmountofShells > 0) : goto "Loop"
You initialize AmmountofShells as an array, though it should
be a numeric variable as seen in your example at the top
of your script (20)
Then you say:
AmountofShells = ((_this select 1) / 4)
The whole operation will not work - result is nothing, so
AmountofShells variable is not useable in your script
OK, that's it for now after a quick look thru your script, without
having had running the whole script thru ma head.
I'll start working in 2 hours and there i'm gonna print it out
on paper to let the whole script make a dummy run thru
me brain ;)
P.S: sorry for not having popped up during the night as promissed, but i felt to sleep as soon as i arrived @ home
~S~ CD
-
thanks Chris i see what you are saying and im not even sure why i scripted it like the way i did. i should have known better...
but i do have a ? for you about
"Now i can't find any condition in your script so that it will run only one one machine, therefore the use of publicVariable
makes no sense at all, as the script will run everywhere."
i thought i had to use this for MP. so my ? to you is , just when should i use it?
Javaman
-
Yo Javaman, i've already had a deeper look into your script
now, but i thought about not to confuse you with details too
much at the mo, as we should clear the real big misssssies first.
OK, your question:
but i do have a ? for you about
"Now i can't find any condition in your script so that it will run only one one machine, therefore the use of publicVariable
makes no sense at all, as the script will run everywhere."
i thought i had to use this for MP. so my ? to you is , just when should i use it?
If you alter a variable/object locally, you need to inform other
participiants about that.
let's say:
A = 0
(everywhere)
Now you say: A = 1 (only on serverside)
Server:
A = 1
Clients:
A = 0
To inform the clients about the new value of A, you need:
publicVariable "A"
publicVariable "variable" will transfer the value from where you
run the command, to everybody else.
Therefore this command has to run only on one machine.
~S~ CD
-
If the script would only run on some computer in the game, for example only on server, you would use the publicvariable to broadcast the variable to all computers in the game.
For example, on the top of my head, if you have
;serverscript.sqs
;this is for server only
#loop
value = random 100
hint format ["%1",value]
?value > 80: clientgogo = true; publicvariable "clientgogo"; publicvariable "value";
~5
goto "loop"
and
;client.sqs
;this is for clients only
#loop
@clientgogo
?!local server: hint format ["%1",value]
clientgogo = false
goto "loop"
-
hehe Artak - 1 sec tooo late ;D
j/k
~S~ CD
-
The story of my life ::) ;D
-
Thank You
Javaman