ArMoGaDoN 0 Posted July 2, 2007 I have adapted another script for auto-placing markers around a killzone for protected respawn-areas. The code all works, but it cannot handle if the angle/azimuth/direction/tilt (whatever you call it) is not at zero.. My math (or lack of) knowledge is letting me down badly here, and I can find nothing much on how to do this anywhere.. The code below is what I have now, plus some attempts and some e.g. code from web. Â If anyone can mod this code to allow the tilt/angle of the ellipse to be properly calculated then it would be VERY much appreciated. The thing only runs once per zone, therefore I want to leave it as sqs. ;areaK.sqs - places warning boards ;[this,100,200]exec"areaK.sqs"; _CT=_this select 0; _xPos=getPos(_CT)select 0; _yPos=getPos(_CT)select 1; _r1=_this select 1; _r2=_this select 2; _tablesC=((_r1 max _r2)*0.36); _i=0; #AKLOOP ?(_i>359):exit; _xP=_xPos+(_r1*(sin _i));_yP=_yPos+(_r2*(cos _i)); if(surfaceIsWater[_xP,_yP])then{k=createVehicle["BuoySmall",[_xP,_yP,0],[],0,"NONE"];}else{k=createVehicle["Danger",[_xP,_yP,0],[],0,"NONE"];}; m=createMarker[format["MarkerK"+str _i],[_xP,_yP,0]]; format["MarkerK"+str _i]setMarkerType "Dot";format["MarkerK"+str _i]setMarkerColor "ColorYellow"; k setdir (_i+180);k setPos [_xP,_yP]; format["MarkerK"+str _i]setMarkerDir _i; _i=_i+(360/_tablesC); ~0.2 goto "AKLOOP"; ;------------------------------ ;tried various other things but didnt work based on this snippet that I found on web... ; Basic coordinates for ellipse with major axis aligned along the x-axis. ; ;set x [expr {$a * cos($angle)}] ;set y [expr {-$b * sin($angle)}] ; ; Co-ordinate frame rotated by "tilt." Note that y-axis is "down" ; ;set xRot [expr {$x * cos($tilt) + $y * sin($tilt)}] ;set yRot [expr {$y * cos($tilt) - $x * sin($tilt)}] ; ;return ;HELP! is it due to radians/degrees or something? ;how should it be done? Â My math is letting me down here... Share this post Link to post Share on other sites
InqWiper 0 Posted July 2, 2007 If you want to create a circle killzone with the radius of 30 or something...why dont you place and object in the middle of the killzone and use a camera with relpos to place the cones/danger signs cam="camera" camcreate [0,0,0] cam camsettarget obj #Loop _i=0 cam camsetrelpos [0,30,0] cam camcommit 0 @camcommited cam sign="danger" createvehicle [getpos cam select 0,getpos cam select 1,0] obj setdir getdir obj+1 _i=_i+1 ?_i<359:goto "Loop" exit I havent tested this I just wanted to show what I meant. I dont know if thats the correct name for the danger sign, you might want to make it run only on the server etc. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted July 2, 2007 I suggest you take a look at kronzky's object placer scripts and see how he did it there as he does that exact same thing. Share this post Link to post Share on other sites
ArMoGaDoN 0 Posted July 2, 2007 Thanks for pointing me in the right direction, those object placement scripts don't work with ellipses, however they did give me a big clue on how to get it working. For anyone interested here's the stuff I added/changed. God knows if the math makes any sense at all, but the ellipse is in right place, tilted to the correct angle, and I have the marker-boards pointing outwards too. _cosdir=cos((_tilt));_sindir=sin((_tilt)); _i=0; #AKLOOP ?(_i>359):exit; ;_xP=_xPos+(_r1*(sin _i)); ;_yP=_yPos+(_r2*(cos _i)); _xP=_xPos+((_cosdir*(_r2*(sin _i)))-(_sindir*(_r1*(cos _i)))); _yP=_yPos+((_sindir*(_r1*(cos _i)))+(_cosdir*(_r2*(sin _i)))); ....... k setdir (_i+180-_tilt);k setPos [_xP,_yP]; ....... Thanks again. Share this post Link to post Share on other sites
ArMoGaDoN 0 Posted July 5, 2007 Dangit Nope it still ain't working right. Works fine for 45-50 degree tilt, but try 1 or 0 or 180 or 5 and the numbers still don't make any sense. Please, if there are any mathematicians out there I am really struggling with this! Share this post Link to post Share on other sites