Grodin 0 Posted October 2, 2008 EDIT: Script fixed as i finally got to test it, WORKS NOW! Quote[/b] ];Disembark.sqs;Executed with [Groupname, Vehiclename] exec "Disembark.sqs" ;Make sure to stop your vehicle or ppl will die from ejecting. ;Its set for 8 ppl, see logic spawns to change. _group = _this select 0 _vehicle = _this select 1 _unitslist = units _group _unitcount = count _unitslist _nextunit = 0 Logic1 = "Logic" createVehicle (_vehicle modelToWorld [+8,+8,0]) Logic2 = "Logic" createVehicle (_vehicle modelToWorld [+8,-8,0]) Logic3 = "Logic" createVehicle (_vehicle modelToWorld [+8,0,0]) Logic4 = "Logic" createVehicle (_vehicle modelToWorld [-8,-8,0]) Logic5 = "Logic" createVehicle (_vehicle modelToWorld [-8,+8,0]) Logic6 = "Logic" createVehicle (_vehicle modelToWorld [-8,0,0]) Logic7 = "Logic" createVehicle (_vehicle modelToWorld [0,-8,0]) Logic8 = "Logic" createVehicle (_vehicle modelToWorld [0,+8,0]) Logic1 setpos (_vehicle modelToWorld [+8,+8,0]) Logic2 setpos (_vehicle modelToWorld [+8,-8,0]) Logic3 setpos (_vehicle modelToWorld [+8,0,0]) Logic4 setpos (_vehicle modelToWorld [-8,-8,0]) Logic5 setpos (_vehicle modelToWorld [-8,+8,0]) Logic6 setpos (_vehicle modelToWorld [-8,0,0]) Logic7 setpos (_vehicle modelToWorld [0,-8,0]) Logic8 setpos (_vehicle modelToWorld [0,+8,0]) #loop _unit = _unitslist select _nextunit [_unit] joinsilent grpnull _unit setunitpos "UP" _unit setcombatmode "yellow" _unit action ["EJECT", _vehicle] unassignvehicle _unit _object = position _unit nearestObject "logic" _unit domove getpos _object _unit setspeedmode "full" deleteVehicle _object [_unit, _group] exec "Disembark2.sqs" _nextunit = _nextunit +1 ~1 ?_unitcount > _nextunit : goto "loop" @ SituationOver {_x enableai "move"} foreach units _group _group domove getmarkerpos "nextobjective" exit ******************************* Quote[/b] ];Disembark2.sqs_a = _this select 0 _b = _this select 1 @ unitReady _a _a disableai "move" [_a] joinsilent _b _a setunitpos "middle" ?(_a hasWeapon "M240") : _a setunitpos "down" ?(_a hasWeapon "PK") : _a setunitpos "down" group _b setcombatmode "yellow" exit This makes my 8 soldiers eject and form a nice defensive position around the car/chopper/etc. Can anyone help me change this script so it would add these game logics only as many as i need... could do it with something like " Goto : "(_unitcount" and then make #5 #7 etc between every logic line but... well, ideas? Share this post Link to post Share on other sites
Asuriel 0 Posted October 2, 2008 you could spawn the game logics within the script placing them in the positions you want using either modeltoworld command or using polarcoordinates. Now i find polarcoordinates more accurate to work with, since you'll be using angles and distances to place the logics instead of only distances in [x, y, z] form. It makes predicting the placement ingame more easy. actually, all move commands such as domove, move, moveto take position arrays so you don't actually need any game logics at all. just calc the position where you'd put your gamelogic (so where the soldier should move to) and send it to him after ejecting directly using a move command. as with the return formation. I think I'd create a trigger in the script which is placed on the vehicle with a given radius which triggers a global variable when the opposing forces are defeated. after that you can oder them to move again and they should return to formation automatically since they are still one group. now getting them to sit still in their positions is probably going to be more difficult then having them return to formation Share this post Link to post Share on other sites
Grodin 0 Posted October 2, 2008 you could spawn the game logics within the script placing them in the positions you want using either modeltoworld command or using polarcoordinates.Now i find polarcoordinates more accurate to work with, since you'll be using angles and distances to place the logics instead of only distances in [x, y, z] form. It makes predicting the placement ingame more easy. actually, all move commands such as domove, move, moveto take position arrays so you don't actually need any game logics at all. just calc the position where you'd put your gamelogic (so where the soldier should move to) and send it to him after ejecting directly using a move command. as with the return formation. I think I'd create a trigger in the script which is placed on the vehicle with a given radius which triggers a global variable when the opposing forces are defeated. after that you can oder them to move again and they should return to formation automatically since they are still one group. now getting them to sit still in their positions is probably going to be more difficult then having them return to formation Thanks! But how exactly do i make unit go to a specific direction? like, Unit1 move 20 meters from hes current position to azimuth 270? All i can figure is the exact coordinates, wich doesnt work here as you mentioned! Enable / Disable AI will make sure they stay at their positions until they are supposed to group up again. Share this post Link to post Share on other sites
Grodin 0 Posted October 3, 2008 Ok so i updated the script, now it works VERY well as long as i have them game logics set around the car. it actually works BRILLIANT, they go straight to positions to surround the car and kneel down. Now all i need is help to create the game logics around the car using azimuth and distance? Share this post Link to post Share on other sites
tj72 0 Posted October 3, 2008 I wouldnt disjoin them from the group since they will have to join another group and whatever leader of that group will then be in effect and do the same thing. One group per unit would be a solution but it seems complicated and not efficient due to the way the game handles things. So keep it the same group and try this: If you can get the units to the position you want and then disableAI "move" them they should stay at that position. DisableAI "target" will get them even more under controll because with "target" enabled, they try to run and engage targets instead of holding position and defending. They should still shoot at targets with the "target" disabled but wont run off to find them. The script can use @unitready to wait for the unit to reach the spot, or a loop can check the distance between the unit and the destination spot and go to the next part when the distance is low enough. Keep in mind that in combat your unit could die at any time and if the loop doesnt check it then it will keep going forever, so think of ways to kill the loops in case of death or maybe the unit gets stuck on something so a timeout needs to be done eg in .sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> unit1 domove getpos target unit1 disableAI "target" _timestart = _time + 50 #START ~4 ? unit1 distance target < 5:goto "End" ?! alive unit1:goto "Dead" ? _time >=_timestart:goto "Timeout" goto "Start" #END hint "unit arrived at position" unit1 disableAI "move" [unit1] exec "arrived.sqs" exit #DEAD hint "unit is dead" exit #TIMEOUT hint "unit never arrived, time is up" exit So you can see I tried to account for the death of the unit or simply time has run out to reach the position and the script just gives up. I gave the loop a 4 second wait. I set the distance threshold to 5 meters but it could be changed to any value. I set the timeout to 50 seconds but could be changed to any value. I also spawned another script for the unit arriving but the same code could stay in this script as well. Its your decision how you want to "split" things based on various reasons but it should be to avoid problems and errors coming up, and to make the scripts easier for you to read and edit/modify later on. . Share this post Link to post Share on other sites
Grodin 0 Posted October 4, 2008 I made them join grpnull so they just leave the group. Then i pointed him to the second script that waits until the unit is "ready" status and then disables hes moving ability and puts him back to the group. No need to use the unit is close to object thing, and it kinda wouldnt work as the object doesnt even exist when he gets there. Theres no need to disable hes target, because they are in combat mode yellow so they wont engage anyway. All i need is the info how to spawn the game logics next to the car ^^ It works great now, ive tested it alot. SOMEONE PLEASE tell me how to create gamelogics OR move commands using angles and distances from given objects! Share this post Link to post Share on other sites
johnnyboy 3797 Posted October 5, 2008 As suggested earlier, I believe modelToWorld is what you want. modelToWorld is the relative position of one object to another. So if the soldier is to move to a position 6 meters behind BMP1, then this would be the command: soldier1 moveTo (bmp1 modelToWorld [0,-6,0]); So in this example [0,-6,0] is the relative position of six meters behind (x axis) the BMP vehicle. (Note: I may have my x and y axis confused, but you get the idea). All your defensive positions can be represented as positions relative to the vehicle using modelToWorld. Share this post Link to post Share on other sites
Grodin 0 Posted October 5, 2008 As suggested earlier, I believe modelToWorld is what you want. modelToWorld is the relative position of one object to another. So if the soldier is to move to a position 6 meters behind BMP1, then this would be the command: soldier1 moveTo (bmp1 modelToWorld [0,-6,0]); So in this example [0,-6,0] is the relative position of six meters behind (x axis) the BMP vehicle. Â (Note: Â I may have my x and y axis confused, but you get the idea). All your defensive positions can be represented as positions relative to the vehicle using modelToWorld. Exactly! Thanks a million Going to write the script with them now! Share this post Link to post Share on other sites
Grodin 0 Posted October 5, 2008 Edit: Sorry, script didn't work earlier. I fixed it, now it works FLAWLESSLY! I'll add a feature so the script picks a right formation for different sized groups from 2 to 16 soldiers. Share this post Link to post Share on other sites
lecholas 2 Posted October 6, 2008 I've been struggling with similar problems once and I came up two scripts (which can be combined btw). They aren't finished and can have some issues but maybe you can benefit from them a bit. Semi automatic defensive positions on OFPEC forums Dismount drill on OFPEC forums Share this post Link to post Share on other sites
Grodin 0 Posted October 6, 2008 I've been struggling with similar problems once and I came up two scripts (which can be combined btw). They aren't finished and can have some issues but maybe you can benefit from them a bit.Semi automatic defensive positions on OFPEC forums Dismount drill on OFPEC forums Damn you. Your script works so well that all my works gone to waste now Im just gonna trash it and use yours, heh... Only issue i got is that the units go under my car Gotta lower the arc i guess.. Share this post Link to post Share on other sites
lecholas 2 Posted October 6, 2008 I'm glad I could help. I thought that I'll release those scripts though they aren't finished cause someone can find them useful. Both scripts could be developed much further but I don't have time and skills to do it. Share this post Link to post Share on other sites
Grodin 0 Posted October 6, 2008 I'm glad I could help. I thought that I'll release those scripts though they aren't finished cause someone can find them useful. Both scripts could be developed much further but I don't have time and skills to do it. Ill do that ill implement all the vehicles for it, and add some variables to choose if units should stay at their positions even they are ready, and wether they should be crouched or prone depending if they need to go fast or not, etc ^^ edit: its your playmove wich caused some units to go "further" than intended ^^ Share this post Link to post Share on other sites
nikita320106 0 Posted October 7, 2008 what about reliase some betas??? alfa?? version)) Share this post Link to post Share on other sites