Page 1 of 9 12345 ... LastLast
Results 1 to 10 of 81

Thread: Scripted weapon collision addon - looking for input

  1. #1

    Scripted weapon collision addon - looking for input

    As we all know the weapon interaction with objects (door/walls/etc) is a major annoyance in Arma.
    However there are games like the UT Infiltration MOD, Vietcong or RO2 (?) (are said to) do it fairly well.

    The general idea is to lower the weapon/put it aside, when getting too close to objects, and have it back ready,
    where there is enough room again.


    With the recent intersect commands, I think we might be able to script a decent solution or at least build a prototype BI could build upon.

    If someone has access to the source code of these games, it would help immensely to understand how they do it.
    Not sure if its available though - can you check or does someone know developers from these games?


    My basic concept so far is this:
    1. Create a game logic
    2. Attach it to the player so that its in front of him
    3. This way you can easily check for objects between the logic and the player with lineIntersectsWith (note: another approach could be to use nearestObjects or such first and only use lineIntersectsWith if an object is actually nearby, if lineIntersectsWith is too demanding to be run constantly with a high frequency)
    4. Next check the distance from the player to the object
    5. This has to involve boundigBox and some geometry/trigonometry I believe for proper distance checking to the edges of the object (rather than just center)
    6. If the player is too close, lower the weapon via script (player action ["WeaponOnBack", player])
    7. If the player moves away again, pull the weapon back up via script (player action ["WeaponInHand", player])



    This may work more or less. I'd very much appreciate help with this.


    Testing code:
    PHP Code:
    sign "sign_sphere25cm_ep1" createVehicleLocal (getpos player);
    sign attachTo [player];//actual offset to be defined 
    objects lineIntersectsWith [eyePos playereyePos signplayersign]; 
    object = if (count objects 0then {objects select 0} else {objNull};
    player distance object;
    player action ["WeaponOnBack"player];
    player action ["WeaponInHand"player]; 

    Ref:
    http://dslyecxi.com/botg_infiltration_2.html - Weapon Collision with Environment
    http://forums.tripwireinteractive.co...ad.php?t=30529
    http://www.serellan.com/forums/index...ody-collision/
    http://forums.beyondunreal.com/showthread.php?t=80902
    http://forums.bistudio.com/showthrea...ollision-Shape
    Last edited by .kju [PvPscene]; Jun 29 2012 at 07:53.

  2. #2


    Spoiler:

  3. #3
    First Lieutenant CameronMcDonald's Avatar
    Join Date
    Oct 10 2005
    Location
    Sydney, Australia.
    Posts
    5,553
    Interesting concept, and a good idea.

    Potential sticking points:

    - The actions causing the player to stop mid-stride, for example, when cutting the pie. It would be great if the weapon raising/lowering animation could be a gesture (i.e. limited to the upper body) rather than a full body animation.
    - When looking through optics and using the WeaponOnBack action, the lowering animation is played and the weapon is raised immediately after (perhaps kick the player out of optics?).
    - When prone, either action causes the player to stand up, hence you'll need an animation check or somesuch. Similar anomalies occur when kneeling.

    There may be too many issues with the particular actions WeaponInHand or WeaponOnBack to be used - would the use of the specific kneeling and standing animations be a better bet?

    Everyone tempted to post another inane/useless/whogivesatoss topic in the A3 forum - here.

  4. #4
    I think talking to the guys that did the SMK Animations would help. Some of there action are connected to surface arround you. For example, lean on wall or jump over wall.

  5. #5
    Good points CMD - in the end only BI can do the smooth and nice solution.
    To get a working prototype would improve chances significantly to see it in A3 I believe.

  6. #6
    You seen this right PVPscene
    ShackTac Movement
    http://www.armaholic.com/page.php?id=12540
    is this along the same idea as what your saying, or close but not complete?

    Hosting Missions for Invasion-1944, Iron Front: Liberation 1944, & Hell in the Pacific

    WarMod Series - Massive Addon & Mod Customizable Compilation Mods for Arma1, Arma2, & Arma2CO
    WarMod | A2WarMod |A2WarModACE | COWarMod | COWarModACE | COWarModI44 |COSLX

  7. #7
    ShackTac movement made it so you wont get stuck on a corner if you get too close.
    (not lowering the weapon but keeps some of the CQB clumpsyness away from arma)

    This idea in this thread is about making the player do a "lower weapon" animation if he gets too close.
    (lowering the weapon making it unusable while you're too close to a wall)

  8. #8
    Master Gunnery Sergeant norrin's Avatar
    Join Date
    Aug 30 2006
    Location
    Melbourne, Australia
    Posts
    1,122
    @ PVP - I must admit I haven't looked at the intersect command yet so I can't comment on its suitability, but I've often wondered about solving this problem. This is all very pie in the sky and you'll know a lot more about how movable objects interact with static environmental objects so you may say straight off the bat that what I'm about to propose is impossible.

    Add to all wall, building etc class objects a custom config entry stating that if its a solid object then it forces the players weapon to be lowered (eg. lowerWeapon = true). This could be done fairly high up the class tree or you could be more specific if you liked based on wall/vehicle height etc (for example, some objects would only occlude if you were kneeling). I then envisaged a nearObjects type loop that would look for all objects that contained the custom config statement within a metre or so of the player and if a players hands or weapon were within a certain distance the player would be forced to lower his weapon - I imagine this would have to be done in model space. A similar method could be used to identify walls etc that a player could use for cover or when stacking up next to a closed door using something like smookies custom animations. All of this would be fairly processor intensive I guess so it it may not be worth contemplating.

    Anyway my 2 cents let me know if you want me to flesh out the idea further - if I ever get the time I may even get around to giving it a go.

    norrin


    EDIT: Ignore all of that

    Try this, it seems to work, the distance from the wall may need a little tweaking and you can also get locked into a weapon up/down loop because the players eye position moves when the weapon is lowered - this would probably work better with the shactac addon. The only other problem I can see is that when you are in aiming mode you only lower your weapon for a second if you are standing against a wall, seems to work fine when you're kneeling in aim mode though.
    Code:
    _occlude = false;
    _c = 0;
    while {true} do {
    	_wepDir = player weaponDirection (primaryWeapon player);
    	_wepRotate = (_wepDir select 0) atan2 (_wepDir select 1);
    	_playerPos = eyePos player;
    	_viewPos = [(_playerPos select 0) + (sin _wepRotate) * 1.2, (_playerPos select 1) + (cos _wepRotate) * 1.2, (_playerPos select 2)]; //eye distance from wall = 1.2 metres
    	_occlude = lineIntersects [eyePos player, _viewPos];
    	hintSilent format ["%1", _occlude];// Hint Player against wall
    	if (_occlude) then {
    		if (_c == 0) then {
    			player action ["WeaponOnBack", player]; 
    			_c = 1;
    		};
    	} else {
    		if (_c == 1) then {
    			player action ["WeaponInHand", player];
    			_c = 0;
    		};
    	};
    	sleep 0.1;
    };
    One final thing if you were to reverse the distance eg. -1.2 you could determine whether a players back was against a wall!
    Last edited by norrin; Jul 6 2012 at 13:34. Reason: Added working code

    **[XDF]*****************************[AAW]**

  9. #9
    Here is a test mission if someone wants to test norrin approach:
    http://www.file-upload.net/download-...sert_e.7z.html

    It works fairly well. Thanks for sharing norrin

    Can you please clarify - you use eyePos to try to see if there is actually a blocking shape between you and the object?
    This is an interesting idea and approach - well done. Question if usable enough within the SQF command limits.

  10. #10
    Master Gunnery Sergeant norrin's Avatar
    Join Date
    Aug 30 2006
    Location
    Melbourne, Australia
    Posts
    1,122
    Quote Originally Posted by PvPscene View Post
    Can you please clarify - you use eyePos to try to see if there is actually a blocking shape between you and the object?
    This is an interesting idea and approach - well done. Question if usable enough within the SQF command limits.
    Yes that's correct, the code checks to see if there is an object 1.2 metres directly in front of the players eyes in the direction that the player's weapon is currently facing, so if you were to turn your head without turning your body and your line of sight was no longer blocked then the weapon would remain lowered. From the limited testing I've done it seems to work correctly with windows ie. if standing in front of a window the weapon does not lower and it also works properly if you are standing in front of a waist high wall ie. when standing view is not blocked weapon is up, when kneeling and the view is blocked the weapon is lowered.

    CamMcD is right the weapononback/weaponinhand action is far from perfect for this function for all the reasons he describes. I'll try and find a way around it - might make a new animation - the big sticking point will be incorporating it smoothly into the existing suite of movements without resorting to the switchMove command. If on the otherhand BIS could create an upper body weapon up/down action as CamMc suggests then we'd be getting pretty close to something that was usable.

    EDIT: I've revised the code to make things work a little better, still far from perfect though.
    1. I've increased the "sleep" time a little (to 0.3 seconds), this makes the code slightly less responsive however it reduces the chance of getting stuck in a weapon raised/lowered loop.
    2. I've added an animation check to determine whether the player is standing or kneeling when approaching and moving away from a wall so that the correct weapon up/down animation is played
    3. I've added an anim check to determine whether the player's weapon is already lowered (default key: 2 x ctrl) when he gets to the wall so that it doesn't play the lower weapon animation if it is not necessary.
    4. If you're prone and against a wall no animation is played
    5. I haven't added it yet but I've worked out a fix for the aiming bug while standing using the switchCamera command, I also think I may have come up with an idea that will fix the looping animation bug. I'll see if I can post some further revisions tomorrow night.

    Code:
    _occlude 	= false;
    _c 			= 0;
    _animState  = "";
    _anim 		= "";
    _wepReady	= ""; 
    _stance 	= nil;
    _toArray 	= [];
    
    while {true} do {
    	_wepDir = player weaponDirection (primaryWeapon player);
    	_wepRotate = (_wepDir select 0) atan2 (_wepDir select 1);
    	_playerPos = eyePos player;
    	_viewPos = [(_playerPos select 0) + (sin _wepRotate) * 1.2, (_playerPos select 1) + (cos _wepRotate) * 1.2, (_playerPos select 2)]; //eye distance from wall = 1.2 metres
    	_occlude = lineIntersects [eyePos player, _viewPos];
    	_animState = animationState player; // Determine player's current animation
    	_toArray = toArray _animState; // convert animation string to an array of numbers
    	_stance = _toArray select 5; // check player's current stance 101 = standing, 107 = kneeling
    	_wepReady = _toArray select 13; //// check whether player's weapon is ready 114 = raised, 108 = lowered
    	hintSilent format ["%1", _occlude];// Hint player's weapon against wall
    	if (_occlude) then {
    		if (_c == 0 && _wepReady == 114) then {
    			_anim = switch (_stance) do {
    				case 101 : {"AmovPercMstpSlowWrflDnon"};
    				case 107 : {"AmovPknlMstpSlowWrflDnon"};
    			};
    			player playMove _anim;
    			_c = 1;
    		};
    	} else {
    		if (_c == 1) then {
    			_anim = switch (_stance) do {
    				case 101 : {"AidlPercMstpSrasWrflDnon_aiming0S"};
    				case 107 : {"AidlPknlMstpSrasWrflDnon0S"};
    			};
    			player playMove _anim;
    			_c = 0;
    		};
    	};
    	sleep 0.3;
    };
    Last edited by norrin; Jul 8 2012 at 13:09.

Page 1 of 9 12345 ... LastLast

Similar Threads

  1. Weapon Modelling (newbie needing input)
    By Alwarren in forum ARMA 2 & OA : MODELLING - (O2)
    Replies: 27
    Last Post: Nov 25 2011, 22:10
  2. Improve weapon collision around corners?
    By Chunk3ym4n in forum ARMA 2 & OA - SUGGESTIONS
    Replies: 1
    Last Post: Oct 27 2009, 23:21
  3. PROPER Weapon Collision Shape
    By .kju [PvPscene] in forum ARMA - ADDONS & MODS: COMPLETE
    Replies: 32
    Last Post: Nov 29 2008, 06:03
  4. Weapon collision in the ArmA world no fun
    By .kju [PvPscene] in forum ARMA - ADDONS & MODS: DISCUSSION
    Replies: 2
    Last Post: Oct 30 2008, 08:18
  5. Weapon "grip points" defined by addon maker/weapon
    By Kirby in forum ARMA 2 & OA - SUGGESTIONS
    Replies: 5
    Last Post: Jul 30 2007, 13:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •