Jump to content
phronk

[Release] Addon-Free Melee Weapons Script

Recommended Posts

wHO03KC.png

By Phronk

Description
    Scripted melee weapons system which doesn't require addons.  Currently supports up to 7 different melee weapons, each with slightly different characteristics.

 

 

 

 

 

Features

 
  • Melee weapons using vanilla (no addons) ArmA 3 content
    -Axe
    -Axe (Firefighter)
    -Disposable Knife
    -Hammer
    -Saw
    -Shovel
    -Wrench
     
  • Pickup Weapon
    -Checks if you're already wielding a melee weapon
    -Checks if you're holding a gun
    -If gun in hand, melee weapon is carried on your back
    -Animation for picking up object from ground
     
  • Drop Melee Weapon
    -Animation for dropping item onto ground
    -Physically drops from your character
     
  • Carry Melee Weapon On Back
    -Allows you to use a gun if melee weapon is not in your hands
    -Can wield melee weapon again, if no gun in hands
    -Can drop melee weapon
     
  • Wield Melee Weapon from Back
    -Can wield melee weapon in your hands again, if you had put it on your back
    -Checks if you're holding a gun in hands
    -Allows you to use object as a melee weapon again
     
  • Melee Weapon Attack
    -Plays animation somewhat fitting chop or stab animation
    -Plays attack/impact sound effect
    -Cannot attack when prone, already attacking, or in a vehicle
    -Spam-click protected (prevents exploiting)
    -Deals damage to target within 1.8 to 2.2 meters (depending on weapon)
    -Checks if target is "Man" and if he's in your line of sight
    -Doesn't damage vehicles or targets inside of vehicles
    -Doesn't damage objects
    -Each weapon deals different amounts of damage and has different speeds
    -Attacking drains your stamina (each weapon drains stamina differently)
     
  • Vehicle Safe
    -Scripts do not break when entering/exiting a vehicle
     
  • Respawn Friendly
    -Weapon/scripts do not break when killed
    -Weapon drops when killed​

To Do List
  • Improve hit detection & target limb damage
  • Add impact visual effects
  • Add unique sound effects for weapons
  • Add to complexity of each weapon characteristic
  • Add other meaningful uses for each item
  • Rewrite system to be better optimized, efficient, and fully MP compatible

NOTE: Untested online with other players!  Works fine in SP; MP version will be released when it's ready.

 
 

 

Installation
    1. Locate/open the folder of the mission you want to add this script to
 

    2. Copy & Paste the Melee folder contained in the downloaded file, into your mission's folder

 

    3. Copy & Paste this into your mission's init.sqf:
null=[]execVM "Melee\cfg.sqf";"

    4. Place a supported object/weapon to be used as a melee weapon (Example: Land_Axe_F)

    5. Copy & Paste the appropriate below code into your object's init:

        (Example: If the object/weapon is Land_Axe_F, only paste the axe code in it's init)

 

 
//LAND_AXE_F:
PickupAxeAct=this addAction["Take axe",{call pickupAxe;
(_this select 0)removeAction DropAxeAct;
(_this select 0)removeAction PickupAxeAct;}];
 
//LAND_AXE_FIRE_F:
PickupfAxeAct=this addAction["Take fireaxe",{call pickupfAxe;
(_this select 0)removeAction DropfAxeAct;
(_this select 0)removeAction PickupfAxeAct;}];
 
//LAND_SHOVEL_F:
PickupSvlAct=this addAction["Take shovel",{call pickupSvl;
(_this select 0)removeAction DropSvlAct;
(_this select 0)removeAction PickupSvlAct;}];
 
//LAND_TABLEWARE_01_KNIFE_F:
PickupKnfAct=this addAction["Take knife",{call pickupKnf;
(_this select 0)removeAction DropKnfAct;
(_this select 0)removeAction PickupKnfAct;}];
 
//LAND_HAMMER_F:
PickupHamAct=this addAction["Take hammer",{call pickupHam;
(_this select 0)removeAction DropHamAct;
(_this select 0)removeAction PickupHamAct;}];
 
//LAND_SAW_F:
PickupSawAct=this addAction["Take saw",{call pickupSaw;
(_this select 0)removeAction DropSawAct;
(_this select 0)removeAction PickupSawAct;}];
 
//LAND_WRENCH_F:
PickupWrnAct=this addAction["Take wrench",{call pickupWrn;
(_this select 0)removeAction DropWrnAct;
(_this select 0)removeAction PickupWrnAct;}];

 

    7. Done!

DOWNLOAD (10.23.2016)

Known Bugs
    1. Weapon is too static when attached to player

    2. Hit detection is not precise and inefficient against crowds
    3. Can pickup a gun in hands if already holding a melee weapon

    4. Harmless script errors

    5. Potentially broken in multiplayer environment (UNTESTED!)

 

Change-Log

 

 

(Oct 23, 2016)

  • Added: Miss & Impact sound effect to all weapons
  • Removed: Redundant check for full stamina when attacking
  • Removed: "_LoS" variable comment
  • Removed: Author and YouTube channel link comment from all scripts, except for cfg.sqf
  • Tweaked: Weapon speeds adjusted to synchronize with new sound effects
  • Fixed: Hammer and Knife weapons were broken, due to a typo

(Oct 20, 2016)

  • Added: Player must be within 1.5 meters of melee weapon to pick it up

 

(Oct 20, 2016)

  • Initial Release
  • Like 13

Share this post


Link to post
Share on other sites
Guest

Nice work.

I had the idea too so I'm gonna make mine :)

And you gave me few more ideas to make it including the known bugs.

(I won't copy your code but I hope it's ok)

Share this post


Link to post
Share on other sites

No problem! I wrote this because I didn't see any decent melee systems out there for people to use in their missions, so you're free to use this also. This is more of a concept anyway, since it isn't totally MP compatible (I think, I can't test in MP anymore). I plan on rewriting this almost completely to be a lot more efficient and MP compatible, but for now, this will do.

Enjoy!

Share this post


Link to post
Share on other sites

this would be a fun script to add to my server :)

if you need a dedicated server to run tests on, i can let you use mine... i have a deathmatch mission running on it with a bunch of diffrent scripts(not using apex).

id prefer you run the script in my mission to test, or atleast set it back to my mission when your done testing. if thats cool i can give you server root access. 

let me know in a pm or something if your interested. 

nice script

Share this post


Link to post
Share on other sites

EDIT :  by the way :

We should have a relative attachTo function in the next stable update (already in DEV) : https://community.bistudio.com/wiki/BIS_fnc_attachToRelative

 

Way I understand it, that just means we no longer have to use worldToModel to get the relative position first. Shouldn't really make a difference for this script.

  • Like 1

Share this post


Link to post
Share on other sites

Love it dude!    Nice complete job.

 

Wanted to do this since ARMA 2 which actually had a "swing axe" animation, but no axe object (there was one embedded in a stump though).  So I used the axe swing anim for AI to beat on someone using an RPG as a club.  lol.

Share this post


Link to post
Share on other sites

great job  :D just what i was looking for....

 

just a question is it possible to add the addaction by cursor target?

 

 

 
player  addaction ["Take axe","Take_axe.sqf",0,0,true,true,"","(typeof cursortarget) == 'LAND_AXE_F' and _this distance cursortarget <2"];
 
 
by this way?
 
only to test:
 
_vehaxe = "LAND_AXE_F" createVehicle position player;
 
PickupAxeAct =_vehaxe addAction["Take axe",{call pickupAxe;
(_this select 0)removeAction DropAxeAct;
(_this select 0)removeAction PickupAxeAct;}];
 
 
but it return an  error variable melee.sqf line 78
 
i can pick it one time only??
 
 
 
i am workink on a SP zombs sandbox and i don t know the best way to add your function to a spawned axe..
 
 
i say again thanks for your work.

Share this post


Link to post
Share on other sites

i love this! and by the looks of it you seem to be working on a whole addon free zombie thing. i hope it's planned to be released. looks great.

  • Like 1

Share this post


Link to post
Share on other sites

@thesnypr: I actually meant to add a distance check early on the development of this script and completely forgot. I'll see if I can work on it and update the script later today/tonight. TakeAxe.sqf doesn't exist, you have to call the function pickupAxe in the addAction.

​[EDIT]
​I've added a distance check to all the weapons and will upload an update later.

@bad benson: Yeah, I'm working on an addon-free zombie sandbox mission to release open-sourced as sort of a template once it's complete enough. Still have a lot of code to write and rewrite before it's ready, so don't hold your breath just yet. ;)

  • Like 1

Share this post


Link to post
Share on other sites

Ok Phronk,

i ve done a long work to a similar project, hunger thirst sytem with hud ,useable craft from inventory, spawn looting,music script,hitsound , scenario script counting all ai around randoming the spawn of "RENEGADES" like DAYZ it s kind of open world . if it can give you help or ideas i will be happy to share it with you.

Share this post


Link to post
Share on other sites

If you want some sounds for this script to play when the player swings an object, hits an enemy, etc. PM me, I have some that might work.

  • Like 3

Share this post


Link to post
Share on other sites

thank you for this.

it would be nice as a mod :

 

-for all of those objects to be called as" weapon " in a loot system based on cfg file, so it wouldn't be needed to place the object and add an init line in Editor.

 

 

keep up the good job.

  • Like 1

Share this post


Link to post
Share on other sites

I'm adding free sound effects found on YouTube for weapon swing/impact and I'll upload it possibly Sunday or some time early in the week.  For now, I've updated the download version  to 0.2, which now has a simple distance check in the addAction for each weapon so the player cannot pickup the weapon object from 50meters away, but within 1.5 meters instead.

 

As for scripts from other missions, I'm going to try to write it all on my own to learn how to code better.  It's more enjoyable that way and also allows me to maintain originality/credit for what I write, as well as the right to release it open-sourced.  I'll create a thread about that project when it's ready to be presented.

Share this post


Link to post
Share on other sites

Update:

  • Added: Miss & Impact sound effect to all weapons
  • Removed: Redundant check for full stamina when attacking
  • Removed: "_LoS" variable comment
  • Removed: Author and YouTube channel link comment from all scripts, except for cfg.sqf
  • Tweaked: Weapon speeds adjusted to synchronize with new sound effects
  • Fixed: Hammer and Knife weapons were broken, due to a typo

All weapons use the same two sound effects to demonstrate how it can be done, but it's not perfect and I'll worry about adding unique sounds for each weapon later.  Starting to rewrite everything to be MP compatible.

  • Like 4

Share this post


Link to post
Share on other sites

this is awesome. definately going to use it in an example mission for raptors/zombies.

Share this post


Link to post
Share on other sites
 
 

When axe on back

AA_Axe attachTo [player,[0,0,0],"launcher"]; onEachFrame {AA_Axe setVectorDirAndUp [((player selectionPosition "rightShoulder") vectorAdd [-0.10,-0.11,-0.05]) vectorFromTo (player selectionPosition "leftshoulder"),(player selectionPosition "spine3") vectorFromTo (player selectionPosition "launcher")];}

When axe in hand

AA_Axe attachTo [player,[0,0,0.16],"rightHand"];onEachFrame {AA_Axe setVectorDirAndUp [((player selectionPosition "rightarmroll")),(player selectionPosition "rightarm") vectorAdd [0,0,1]];}
  • Like 1

Share this post


Link to post
Share on other sites
Guest

 

 
 

When axe on back

AA_Axe attachTo [player,[0,0,0],"launcher"]; onEachFrame {AA_Axe setVectorDirAndUp [((player selectionPosition "rightShoulder") vectorAdd [-0.10,-0.11,-0.05]) vectorFromTo (player selectionPosition "leftshoulder"),(player selectionPosition "spine3") vectorFromTo (player selectionPosition "launcher")];}

When axe in hand

AA_Axe attachTo [player,[0,0,0.16],"rightHand"];onEachFrame {AA_Axe setVectorDirAndUp [((player selectionPosition "rightarmroll")),(player selectionPosition "rightarm") vectorAdd [0,0,1]];}

 

rip fps

Share this post


Link to post
Share on other sites

rip fps

Why would you say that? onEachFrame is about the most economical way to achieve that stuff...

Share this post


Link to post
Share on other sites
Guest

Why would you say that? onEachFrame is about the most economical way to achieve that stuff...

The most economical way does not mean it would not impact performance. Basicly, executing this kind on code on each frame is very power consumming. Now imagine on a server where you have to update that for each player on each frame.

Share this post


Link to post
Share on other sites

Basicly, executing this kind on code on each frame is very power consumming.

 

It's not...

If a couple setVectorDirAndUp onEachFrame are enough to even impact your performances in a regular scenario, you might wanna buy a new machine.

  • Like 1

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

×