Customizable damage system

User avatar
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

Customizable damage system

by pandaro » Tue Dec 31, 2013 19:21

I was wondering if it was possible to modify the damage system by adding an API. I know that you can create a different damage system by defining the function on_use (). For example, could change the damage by adding certain information contained in the metadata of items wielded. However, a function like that is not fast and it is not comfortable.
So I thought it would be nice if someone with a lot of programming skills could create a new API that should be, more or less, so (if someone has not a better ideas):

minetest. redefine_system_damage (puncher, punched, itemstack, extras)

if this function call would overwrite the damage system, otherwise the damage system would be the default.

I think it's a nice idea, but it is possible to achieve it? is it difficult? What can I do to help this to be done?
sorry for bad english
Linux debian 7 wheezy 64
kde
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jan 01, 2014 20:38

I dont see how this would be faster than using on_use.
Last edited by PilzAdam on Wed Jan 01, 2014 20:39, edited 1 time in total.
 

User avatar
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

by pandaro » Wed Jan 01, 2014 21:21

I tried to create a custom function that would change the system of damage.
The first problem I encountered was when handling "time_from_last_punch" and "full_punch_interval" to modify the damage if you attack too frequently. This can be done by calling "minetest.after ()" which should assign a value to a variable that was changed at the time of the first punch. I took a look inside "minetest / src / tools.cpp" and "minetest / src / tools.h" even though I am a beginner I think is more simple if this was done within the function " HitParams. "

Apart from this small problem that could be overcome, circumvented or simply ignored, there are several functions that must be called in a narrow period of time to make the system of damage, I mean, better and more flexible. I make a couple of examples:
User: get_player_name () "this may be to get a number that represents an ability even saved in a configuration file.
((User: get_wielded_item ()): to_table ()). Metadata "to get extra information from a weapon.
In addition, the part that most slows operations is this:
the "on_use" has as its theme: "pointed_thing", so if I want to get information about the punched object I should insert code more or less like :
if pointed_thing.type == "object" then
get_armor_groups ()
Some code ...
get_hp ()
Some code ...
Etc ... ...
end

For all these reasons I ask for a function that overwrites the current system damage.
sorry for bad english
Linux debian 7 wheezy 64
kde
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 5 guests

cron