[MOD] Melee weapons api! Uses raycasting! [w_api][git][v2]

User avatar
Stix
Member
 
Posts: 1379
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

[MOD] Melee weapons api! Uses raycasting! [w_api][git][v2]

by Stix » Wed Sep 25, 2019 03:12

Image
WARNING: Will crash on latest stable, you need a version that includes the new add_player_velocity
This is my attempt at improving combat mechanics via raycasting.

This mod provides an api to easily add melee weapons like the following:
Code: Select all
w_api.register_weapon("w_api:sword", {
    description = "Large Sword", --item description
    inventory_image = "w_api_sword.png", --inventory image
    primary_use = {
       ent_bl = true, --if true multiple rays in the same swing cant 'hit' the same ent
       crit_mp = 1.5, --value for damage to be multiplied by when the user gets a critical hit
       kb_mp = 2, --value for knockback vector to be multiplied by
       swing_delay = 0.3, --delay till start of swing [in seconds]
       slash_dir = 0, --direction of weapon slash, 0 is left -> right, 1 is right -> left
       dmg = 2, --the amount of damage to deal to the target object
       delay = 0.1, --delay between each raycast [in seconds]
       depth = 1, --how many ents any individual raycast can damage
       range = 4, --range of weapon [in meters]
       spread = 10, --offset between rays [in degrees]
       amount = 4 --amount of total raycasts on either side of the center ray, set to 1 for only the center ray
    }
})

+ Implements

+ Checklist

Licensing:
Everything is licensed under MIT

Credits:
Special thanks to UMTD users Warr1024 --for helping me with some fancy-pants vector math to get me started and GreenDimond --for coming up with a solution to prevent sword spamming

Dependencies:
None!

Downloads:
Github Repo
Attachments
screenshot_20190925_142557.png
(60.68 KiB) Not downloaded yet
Last edited by Stix on Fri Sep 27, 2019 01:03, edited 19 times in total.
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
TumeniNodes
Member
 
Posts: 2827
Joined: Fri Feb 26, 2016 19:49
Location: in the dark recesses of the mind
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][v1]

by TumeniNodes » Wed Sep 25, 2019 04:54

Stix wrote:Check attachments: ill probably create a github repo later


Yesssss.... come to the dark side.... They all float down here...
Ich mag keine grünen Eier und Schinken, ich mag sie nicht Sam I Am
 

User avatar
Stix
Member
 
Posts: 1379
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by Stix » Wed Sep 25, 2019 18:51

Update: Now on ContentDB!
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

Extex
Member
 
Posts: 112
Joined: Wed Mar 14, 2018 23:14
GitHub: Extex101
In-game: Extex

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by Extex » Wed Sep 25, 2019 21:55

Cool idea!
Player of PK, RIP. Creator of the light_tool mod. Working on another mod which is pretty cool so far
 

User avatar
texmex
Member
 
Posts: 1588
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
Stix
Member
 
Posts: 1379
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by Stix » Thu Sep 26, 2019 21:21

Update time!:
Changes:
  • IMPORTANT!: a potential memory leak was fixed, be sure to update your copies!
  • added entity blacklisting, when set to true this means multiple rays from a single sword swing cannot hit the same entity, in order to only deal the specified damage to each entity intersected by a ray
  • added knockback multiplier, change this to increase/decrease knockback per-weapon
  • added critical-hits! When a ray deals damage to a mob when the swinger has a downwards velocity, the hit is considered a critical hit and damage is the weapons damage multiplied by the critical hit multiplier
  • changed the name of some variables to be more self-explanatory and made all weapon-specific values go inside the table
  • added support for secondary attacks! unfortunately this isnt completely usable yet due to lacking a item-def on_rmb callback that runs no matter what the pointed_thing is, but the support is there via major restructuring of the api
I will update the OT and add a new ContentDB release soonish, for now you can get the latest code at the git repo
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

Chem871
Member
 
Posts: 937
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Dwaba_Kukai
 

User avatar
texmex
Member
 
Posts: 1588
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
Stix
Member
 
Posts: 1379
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by Stix » Wed Oct 09, 2019 00:52

Sorry for the late reply, but yeah. if you check the api code you'll see there's a commented out line for spawning particles at the intersection point of each ray, that is what i used

EDIT: https://github.com/Cahrs/w_api/blob/master/api.lua#L80
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
texmex
Member
 
Posts: 1588
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
texmex
Member
 
Posts: 1588
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
Stix
Member
 
Posts: 1379
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by Stix » Sun Oct 13, 2019 18:35

"particle guide"? im not sure what your referring to, please be more specific.
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
texmex
Member
 
Posts: 1588
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [MOD] Melee weapons api! Uses raycasting! [w_api][git][v

by texmex » Sun Oct 13, 2019 20:01

Sorry, I expected one type of visual feedback with the commented out line but reading again I understand that it’s a little different.
 


Return to WIP Mods



Who is online

Users browsing this forum: Hume2, MSN [Bot], runs and 5 guests