Page 1 of 1

[Mod] Entity Control Function Library [entitycontrol]

PostPosted: Wed Jun 13, 2018 03:17
by Noodlemire
As I was trying to fix falling beds in my mod [clumpfall], I realized that falling nodes don't call on_place due to using set_node when landing instead of place_node. Since the only mod that I could find that provides a way to override entities, [entity_override], has a dead repo and no other download links, I decided to make this quick mod to provide said function. Also made a method to unregister entities since I saw it on the to-do list of [entity_override] and hadn't found anything about that, either.

In order to use it, just install it in your preferred mods folder and add it as a dependency to your mod. There, you'll be able to use these functions however you please. With it, you'll be able to easily make changes to any mobs you please without needing to worry about

Example override:
Code: Select all
--Give dirt monsters a lot less maximum hp, but give them a ranged attack.
entitycontrol.override_entity("mobs_monster:dirt_monster",
{
   hp_max = 15,
   attack_type = "dogshoot",
   dogshoot_switch = 1,
   dogshoot_count_max = 1, -- shoot for 1 second
   dogshoot_count2_max = 3, -- dogfight for 3 seconds while waiting between shots
   shoot_interval = 3,
   arrow = "modname:dirt_shot",
   shoot_offset = 1,
})

mobs:register_arrow("modname:dirt_shot", {
   visual = "sprite",
   visual_size = {x = 0.5, y = 0.5},
   textures = {"default_dirt.png"},
   velocity = 6,
   expire = 0.1,

   --Low damage hits
   hit_player = function(self, player)
      player:punch(self.object, 1.0, {
         full_punch_interval = 1.0,
         damage_groups = {fleshy = 8},
      }, nil)
   end,

   hit_mob = function(self, player)
      player:punch(self.object, 1.0, {
         full_punch_interval = 1.0,
         damage_groups = {fleshy = 8},
      }, nil)
   end,

   --Turns nodes into dirt
   hit_node = function(self, pos, node)
      minetest.set_node(pos, {name="default:dirt"})
   end
})


If anyone want to see any other entity-related functions in this, feel free to provide suggestions.

Repository: https://github.com/Noodlemire/entitycontrol
License: Apache 2.0, https://github.com/Noodlemire/entitycon ... ICENSE.txt
Download: https://mega.nz/#!W25QmBiY!8RZA4IJjq4wG ... _11b-Y9mw0

Re: [Mod] Entity Control Function Library [entitycontrol]

PostPosted: Mon Jun 25, 2018 15:50
by Sokomine
Could be intresting. I do have some problems with snowballs falling right next to fields with grown crops. Such a snowball can take an entire field down in one go :/

Re: [Mod] Entity Control Function Library [entitycontrol]

PostPosted: Fri Feb 08, 2019 13:54
by texmex
Thanks noodlemire!