Scripting Handout 3
Create an object before an individual

>>> SCRIPT BEGINS BELOW <<<

;create_object.sqs
;this script will spontaneously create an object and place it in front of the player.
;It takes in two arguments:
;_myplayer: The name of the person whose location and direction will determing where the object is to be placed
;_myobject: the classname of the object to be placed.

_myplayer = _this select 0
_myobject = _this select 1

;set distance to place object
_mydistance = 5

;make calculations on the location of the object
;get player direction
_mydir = getdir _myplayer

;decide X and Y coordinates of object placement using trigonometry
_myXpos = ((sin _mydir) * _mydistance) + (getpos _myplayer select 0)
_myYpos = ((cos _mydir) * _mydistance) + (getpos _myplayer select 1)

;create the object
_newobject = _myobject  createVehicle [_myXpos, _myYpos, 0]

;orient object to user facing
_newobject setdir _mydir

hint "object placed"

exit
