Jump to content
Sign in to follow this  
SigintArmA

Firearm Tilt (Non-Static but placed via script)

Recommended Posts

Hello. I'm using the script found on this site

http://kronzky.info/placer/index.htm

to place a set number of weapons on tables and leaned against objects, yet it doesn't explain how I can alter the 'tilt' of the object. I've tried using the Init code into an invisible H pad with an altered vector so the pad itself is tilted (Can't see the tilt though tested with a visible table) yet the weapons are level yet the H-Pad (And table) are tilted. The script tells you how to define the direction of the weapons, height, spacing, number, magazines and number of mags but I can't figure out how to angle it in any other direction other then the Azimuth the weapons face. And if it sounds confusing of what I'm asking. In the link is shows an example screen shot. I want to angle the weapons like they are angled in the back (Barrel facing up)

Any help would be great!

Share this post


Link to post
Share on other sites

It does show the weapons in the picture being upright but there doesn't seem to be a setting for it.

Anyhow I think I've made it work by adding a vector array, you will have to mess with it to find the right results as even the direction can have strange effects.

call with

[this, 0.95, 0, "M249_EP1", "", 1, 5, 0.9,[-1,1,0.1]] exec "placeweapons.sqs"

;************************************************************************************************************;
;                                                                                                            ;
; PLACE WEAPONS                                                                                              ;
;                                                                                                            ;
; Positions a number of weapons at a selected position                                                       ;
;                                                                                                            ;
; © 2006 - Kronzky (kronzky@gmail.com)                                                                       ;
;                                                                                                            ;
;************************************************************************************************************;
;                                                                                                            ;
; Call arguments: [place, height, direction, weapon, ammo, type, copies, distance]                           ;
;                                                                                                            ;
; place         = Object that defines the 2D-position of the placement (can be a game logic)                 ;
; height        = Distance from the ground for placement.                                                    ;
; direction     = Angle of weapons orientation.                                                              ;
; weapon        = Weapons name                                                                               ;
; ammo          = Ammo name                                                                                  ;
; type          = Specifies whether weapon is primary (1) or secondary (2) weapon.                           ; 
;                 (use 2 if weapon appears upright)                                                          ;
; copies        = How many copies of the weapon should be placed. (optional)                                 ;
; distance      = How far apart weapons copies should be placed (only required if <copies> is declared)      ;
;                                                                                                            ;
; [table1, 0.95, 0, "m16", "m16", 1, 5, 0.2] exec "placeweapons.sqs"                                         ;
; will place 5 M16s 20cm apart at the position of object 'table1', at a height of .95.                       ;
;                                                                                                            ;
; The names for weapons and ammo are available on the wiki: community.bistudio.com/wiki/Category:Weapons     ;
;                                                                                                            ;
;************************************************************************************************************;

;how many magazines per weapon should be created?
_magspergun = 5
;should weapons be usable by player and AI?
_usable = true
_vect =[]

_place = _this select 0
_x = getpos _place select 0
_y = getpos _place select 1
_z = _this select 1
_dir = _this select 2
_weapon = _this select 3
_ammo = _this select 4
_type = _this select 5

_vect = _this select 8 

_holdertype = if (_type==2) then {"secondaryweaponholder"} else {"weaponholder"}
_copies=0
_dist=0
if (format["%1",_this select 6]!="<null>") then {_copies=(_this select 6)-1;_dist = _this select 7}

_dx = sin(_dir)*_dist 
_dy = cos(_dir)*_dist

if (_copies>0) then {_x=_x-(_copies/2)*_dx; _y=_y-(_copies/2)*_dy}

_cnt=0
#fill
_holder = _holdertype createVehicle [0,0]
if (_ammo!="") then {_holder addmagazinecargo [_ammo,_magspergun]}
if (_weapon!="") then {_holder addweaponCargo [_weapon,1]}
_holder setdir _dir
_holder setpos [_x,_y,_z]

_holder setvectorup [_vect select 0,_vect select 1,_vect select 2]

if (_usable) then {player reveal _holder}

_x = _x + _dx
_y = _y + _dy

_cnt=_cnt+1
if (_cnt<=_copies) then {goto "fill"}

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thank you. I'll test this ASAP. This bit of code appears to be perfection now (To me at least haha) Thanks again! :D

Share this post


Link to post
Share on other sites

Was this successful?

Please do tell.

Edited by MrTavish

Share this post


Link to post
Share on other sites

Of course i tried it, I just thought I'd ask before i tried it in case there was any problems.

Anyways, I got it working nicely with an invisible H. Although, i am have having troubles rotating the weapon direction. ie, on the other wall in the pic. I'm sure i'll work it out soon enough.

@F2k Sel - Great innovation! I've been wondering for ages how this could be done.

I get this rpt error though:

Error in expression <_holder setvectorup [_vect select 0,_vect select 1,_vect sele>
 Error position: <_vect select 0,_vect select 1,_vect sele>
 Error Undefined variable in expression: _vect

Any ideas on how i could clean this up? :confused:

@kylania - i'm relatively new to the scripting game and recently discovered you script examples site. All i can say is a big Thank You! A vital resource indeed!

I felt something like this when i found it...

:dancehead:

Edited by MrTavish
typo

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×