Page 1 of 35

[Mod] Simple Mobs [mobs]

PostPosted: Sat Sep 15, 2012 13:55
by PilzAdam
Hello everyone!
Ive created a simple and (hopefully) lightweight mod that adds currently 5 hostile mobs and 2 passive animals to MT.

This mod is good for everyone who cant run the animals mod.

The models are conributed by Pavel_S.
.blend files for the models: https://www.dropbox.com/sh/j4ux5fxw8jfazzr/h1O7SU0Y2p

Documentation by Temperest:
Code: Select all
Mobs
====

This mod adds mobs to Minetest.

Minetest's damage system
------------------------
The damage system in Minetest is more complex than just hold down the left mouse button. After the first punch your hand or weapon has a "reload" time. This is for most weapons 1 second. After the reload time the player can punch again.

Settings
--------
When you add `only_peaceful_mobs = true` to minetest.conf then all hostile mobs will despawn.
`display_mob_spawn = true` will show you a message in the chat when a mob spawns.

Items
-----
* Meat: dropped by sheep upon dying. When cooked in a furnace, results in cooked meat that heals players when eaten.
* Wheat: players holding wheat cause sheep to follow them. Right clicking sheep with wheat tames them.

List of mobs
------------

### Hostile mobs
Hostile mobs walk arround in the world and start to attack the player when they see him.

* Dirt Monster: spawns on grass at night. It has the same velocity as the player and cause 1 heart damage. It dies in water, lava and sunlight. Drops dirt when killed by a player.
* Stone Monster: spawns on normal stone in the dark. It is slower than the player but can only be hurt by at least a stone sword. It causes 2 heart damage and is immune to water, lava and light. Drops mossy cobble when killed by a player.
* Sand Monster: spawns at deserts. It is faster than the player but dies fast and doesnt cause much damage. It dies in water and lava. Drops sand when killed by a player.
* Oerkki: from version 0.3 of Minetest. It spawns on stone in the dark and has same velocity as the player. It causes more damage than the dirt monster and dies in lava and water.
* Dungeon Master: from version 0.3 of Minetest. It spawns on stone in the dark and throws fireballs at the player. It dies in water and lava and the player needs at least a stone sword to kill it. Has a 1% chance of dropping MESE when killed by a player.

### Friendly mobs
Friendly mobs walk arround in the world. They do not attack the player but some of them have useful features.

* Sheep: friendly animal that walks randomly in the world. It spawns on grass and gives the player wool if right clicked and meat if he kills it. It will follow players holding wheat. If fed wheat by right clicking, they are tamed, do not despawn, and regrow wool.
* Rat: from version 0.3 of Minetest. Its a friendly animal that spawns on grass and stone. The player can right click it to get it into his inventory. In the inventory the rat can be replaced in the world or cooked in the furnace.

API
---
You can use the API of simple mobs in your own mods if you have it installed. See the [init.lua]([url]https://github.com/PilzAdam/mobs/blob/master/init.lua[/url]) file in the mod to have some examples of the usage.

Simple Mobs has a simple API. Other mods can use the functions to add their own mobs.

### mobs:register_mob(name, definition)

This functions registers a new mob as a Minetest entity.
* `name` is the name of the mob (e.g. "mobs:dirt_monster")
* `definition` is a table with the following fields
  * `type` the type of the mob ("monster" or "animal")
  * `hp_max` same is in minetest.register_entity()
  * `physical` same is in minetest.register_entity()
  * `collisionbox` same is in minetest.register_entity()
  * `visual` same is in minetest.register_entity()
  * `visual_size` same is in minetest.register_entity()
  * `textures` same is in minetest.register_entity()
  * `mesh` same is in minetest.register_entity()
  * `makes_footstep_sound`: same is in minetest.register_entity()
  * `view_range` the range in that the monster will see the playerand follow him
  * `walk_velocity` the velocity when the monster is walking around
  * `run_velocity` the velocity when the monster is attacking a player
  * `damage` the damage per second
  * `drops` is list of tables with the following fields:
    * `name` itemname
    * `chance` the inverted chance (same as in abm) to get the item
    * `min` the minimum number of items
    * `max` the maximum number of items
  * `armor` the armor (integer)(3=lowest; 1=highest)(fleshy group is used)
  * `drawtype` "front" or "side"
  * `water_damage` the damage per second if the mob is in water
  * `lava_damage` the damage per second if the mob is in lava
  * `light_damage` the damage per second if the mob is in light
  * `on_rightclick` its same as in minetest.register_entity()
  * `attack_type` the attack type of a monster ("dogfight", "shoot", maybe somehting like "explode" in the future)
  * `arrow` if the attack_type="shoot" needed: the entity name of the arrow
  * `shoot_interval` the minimum shoot interval
    * `sounds` this is a table with sounds of the mob
      * `random` a sound that is played randomly
      * `attack` a sound that is played when a mob hits a player
  * `animation` a table with the animation ranges and speed of the model
    * `stand_start`
    * `stand_end`
    * `walk_start`
    * `walk_end`
    * `run_start`
    * `run_end`
    * `punch_start`
    * `punch_end`
    * `speed_normal`
    * `speed_run` used when mob runs behind player to make animation faster


### mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height)

This function registers a spawn algorithm for the animal. Without this function the call the mobs won't spawn.
* `name` is the name of the animal/monster
* `nodes` is a list of nodenames on that the animal/monster can spawn
* `max_light` is the maximum of light
* `min_light` is the minimum of light
* `chance` is same as in register_abm()
* `active_object_count` mob is only spawned if active_object_count_wider of ABM is <= this
* `max_height` is the maximum height the mob can spawn

For each mob that spawns with this function is a field in `mobs.spawning_mobs`. It tells if the mob should spawn or not. Default is `true`. So other mods can only use the API of this mod by disabling the spawning of the default mobs in this mod.


### mobs:register_arrow(name, definition)

This function registers a arrow for mobs with the attack type shoot.
* `name` is the name of the arrow
* `definition` is a table with the following values:
  * `visual` same is in minetest.register_entity()
  * `visual_size` same is in minetest.register_entity()
  * `textures` same is in minetest.register_entity()
  * `velocity` the velocity of the arrow
  * `hit_player` a function that is called when the arrow hits a player; this function should hurt the player
    * the parameters are (self, player)
  * `hit_node` a function that is called when the arrow hits a node
    * the parameters are (self, pos, node)


Wiki:
https://github.com/PilzAdam/mobs/wiki

License:
WTFPL

Depends:
default
fire

Download:
https://github.com/PilzAdam/mobs/zipball/master

GitHub:
https://github.com/PilzAdam/mobs

PostPosted: Sat Sep 15, 2012 14:05
by OwenBean
Testing now :)

PostPosted: Sat Sep 15, 2012 14:07
by OwenBean
Sorry - I get a failed to run init.lua

PostPosted: Sat Sep 15, 2012 14:10
by cornernote
Cool, I been thinking about a mob for a game, but no simple examples exist. This will help a lot.

PostPosted: Sat Sep 15, 2012 14:29
by PilzAdam
Stone monster added.

PostPosted: Sat Sep 15, 2012 14:48
by OwenBean
Any idea why im getting my error?

PostPosted: Sat Sep 15, 2012 14:50
by PilzAdam
OwenBean wrote:Any idea why im getting my error?

Did you renamed the folder into "mobs"?
Please give me more information.

PostPosted: Sat Sep 15, 2012 14:51
by PilzAdam
Sand monster added.

PostPosted: Sat Sep 15, 2012 14:56
by Phitherek_
You work really fast ;). Finally something not as lag-producing as mobf, I will test it when I'll have time.

PostPosted: Sat Sep 15, 2012 16:22
by jordan4ibanez
that's pretty cool

PostPosted: Sat Sep 15, 2012 16:25
by OwenBean
Hi, I renamed the folder mobs and it seemed to work - I ran a server for a while, until i came up with the following error


Code: Select all
17:16:30: VERBOSE[main]: Client: Loaded cached media: abda151694e436e4b43a15c07894d3a2963c8c12 "default_tree_top.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "default_water.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 5cc652492e44c42c66799cbbaf8e7547cb00d220 "default_water.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "default_wood.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 0d83e2e9530a917ab915378753d248fb4fe98b2e "default_wood.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "door_wood.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: d5bd9ecfaf7bab30b54b3748cf03042b85ee671b "door_wood.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "door_wood_a.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 337849a84dbd13d7f7c745dec2583f89d952c6b6 "door_wood_a.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "door_wood_a_r.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 0428a6dd36bbf3f8109f9a88ad447c3583e4172b "door_wood_a_r.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "door_wood_b.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 49f81e9e391194e764ccb64d291f7760423607e5 "door_wood_b.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "door_wood_b_r.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: adb91dd5db349fbc705d9fefed454a592b8fd87e "door_wood_b_r.png"
17:16:30: INFO[main]: Server: Saving players
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "drippingwater_drip_a.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: INFO[main]: Audio file C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg loaded
17:16:30: VERBOSE[main]: Client: Loaded cached media: ddecb92cd78859812366279c825f288d440feb32 "drippingwater_drip_a.ogg"
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "drippingwater_drip_b.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: INFO[main]: Server: Saving environment metadata
17:16:30: INFO[main]: Server: Stopping and waiting threads
17:16:30: INFO[main]: Audio file C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg loaded
17:16:30: VERBOSE[main]: Client: Loaded cached media: 0585c90ec74bbacccec214b678e3cf01536c93a2 "drippingwater_drip_b.ogg"
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "drippingwater_drip_c.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: INFO[main]: Audio file C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg loaded
17:16:30: VERBOSE[main]: Client: Loaded cached media: 8f2bcd9ed8818df43bdb76841fe6b544877e2313 "drippingwater_drip_c.ogg"
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "drowning_gasp.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: INFO[main]: Audio file C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg loaded
17:16:30: VERBOSE[main]: Client: Loaded cached media: 5781fc00f9aae7b2e0b5d4767f57bff4f257f90e "drowning_gasp.ogg"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dungeon_master.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: abfe83f61f6fd89b9a867fb78992998db414e434 "dungeon_master.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_black.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: c5df5aeb39757e1b9813d54445da1b05ceb4779a "dye_black.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_blue.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 2ef3caa009d83ec64449b22383316aab2901ced5 "dye_blue.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_brown.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 0896f7505834462eb5d73755325ba4e14b95ec80 "dye_brown.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_cyan.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: bee7b098caffa9afd94917b48335f46c6ac1f94f "dye_cyan.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_dark_green.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: ba2caa4273327461542b82bef6e2edb33c8a0ac1 "dye_dark_green.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_dark_grey.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 1a979830b0b885cc2a3171d4b0c670802769e893 "dye_dark_grey.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_green.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 6ea883b86230ac8cea0d0fbbd64d333bca85e2a2 "dye_green.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_grey.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: e896a00a9609b108b99cec2eb47b40b54479925d "dye_grey.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_magenta.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: fe266a799a8447841f1f4d8d9a169f2122563bcf "dye_magenta.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_orange.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: b40d72f152e6b1a18b03242926e05a266d1f8a9e "dye_orange.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_pink.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 825ca106ce6f8ced472bbe16cf44a2ca46c974d2 "dye_pink.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_red.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: d65e65f658a856804ebacf2bc1cab3212f8a7238 "dye_red.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_violet.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: a497ea4aedd0d479d961cb43a5eb5926e17df63e "dye_violet.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_white.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: 7cf6df89404e591e7f52c2242786bf2fe234f3a8 "dye_white.png"
17:16:30: VERBOSE[main]: Client: Attempting to load image file "dye_yellow.png"
17:16:30: VERBOSE[main]: Client: Loaded cached media: e8ed4dd932cb4a9d09f5dc8fa82bf6670e87265d "dye_yellow.png"
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "earth01a.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: INFO[main]: Server: Threads stopped
17:16:30: VERBOSE[main]: ServerEnvironment::deactivateFarObjects(): deactivating object id=1 on inactive block (-1,0,0)
17:16:30: VERBOSE[main]: ServerEnvironment::deactivateFarObjects(): object id=1 is not known by clients; deleting
17:16:30: VERBOSE[main]: ServerEnvironment::deactivateFarObjects(): deactivating object id=2 on inactive block (-2,0,-1)
17:16:30: VERBOSE[main]: LuaEntitySAO::getStaticData
17:16:30: VERBOSE[main]: ServerEnvironment::deactivateFarObjects(): object id=2 is not known by clients; deleting
17:16:30: VERBOSE[main]: scriptapi_luaentity_rm: id=2
17:16:30: VERBOSE[main]: ServerMap::~ServerMap
17:16:30: INFO[main]: Audio file C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg loaded
17:16:30: VERBOSE[main]: Client: Loaded cached media: a563982063971b519b987d0a407511cb1aacc227 "earth01a.ogg"
17:16:30: INFO[main]: ServerMap: Written: 0 sector metadata files, 2 block files, 125 blocks in memory.
17:16:30: INFO[main]: ServerMap: Blocks modified by:
17:16:30: INFO[main]:   setNodeNoCheck: - - - - - - - - - - - - - 1
17:16:30: INFO[main]:   setNodeNoCheck, setNodeNoCheck, setNode, setNode...: 1
17:16:30: INFO[main]: ServerMap: Saved map to C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\worlds\WinterWonderland
17:16:30: INFO[main]: RollbackManager::~RollbackManager()
17:16:30: INFO[main]: RollbackManager::flush()
17:16:30: INFO[main]: Server: Deinitializing scripting
17:16:30: INFO[main]: BanManager: saving to C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\worlds\WinterWonderland\ipban.txt
17:16:30: VERBOSE[main]: Client: Attempting to load sound file "eastern_feeling.ogg"
17:16:30: VERBOSE[main]: OpenALSoundManager::loadSoundData(): Writing temporary file to [C:\Users\Owen\Downloads\Games\minetest-0.4.3-win32\minetest-0.4.3-win32\bin\..\cache\tmp\tmp.ogg]
17:16:30: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: error running function 'on_step': attempt to index a number value
17:16:30: ERROR[main]: stack traceback:

In thread 2148:
C:\tmp\minetest\src\main.cpp:1741: main: Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 2148:
#0  main
(Leftover data: #1  Dedicated server branch)
(Leftover data: #2  ServerMap::save)
(Leftover data: #3  ServerMap::saveBlock)
17:16:30: VERBOSE[Connection]: con(828/2): RE-SENDING timed-out RELIABLE to 5.215.199.39:30000(t/o=0.333): from_peer_id=2, channel=0, seqnum=65501
17:16:31: VERBOSE[Connection]: con(828/2): RE-SENDING timed-out RELIABLE to 5.215.199.39:30000(t/o=0.333): from_peer_id=2, channel=0, seqnum=65501
17:16:31: VERBOSE[Connection]: con(828/2): RE-SENDING timed-out RELIABLE to 5.215.199.39:30000(t/o=0.333): from_peer_id=2, channel=0, seqnum=65501
17:16:31: VERBOSE[Connection]: con(828/2): RE-SENDING timed-out RELIABLE to 5.215.199.39:30000(t/o=0.360972): from_peer_id=2, channel=0, seqnum=65501

PostPosted: Sat Sep 15, 2012 16:34
by PilzAdam
You need latest dev version of Minetest (its not 0.4.3 stable).

PostPosted: Sat Sep 15, 2012 16:36
by OwenBean
Where can I get it? :)

PostPosted: Sat Sep 15, 2012 16:36
by PilzAdam
OwenBean wrote:Where can I get it? :)

Read the first post.

PostPosted: Sat Sep 15, 2012 16:49
by OwenBean
sorry - not normally this retarded lol

PostPosted: Sat Sep 15, 2012 18:57
by Myu
EDITED.
It does work but I got an error & game crash :

ServerError: LuaError: error running function 'on_step': attempt to index a number value

PostPosted: Sat Sep 15, 2012 21:18
by rnolan25
Hey,

I got an error in that when a mob falls in the water it crashes the game. Hopefully this helps.

PostPosted: Sat Sep 15, 2012 22:15
by joker333
do u think u could make a simple animals mod that is 2d like this mod an mabe a new throwing mod cus i cant get ether urs or jeija throw mod to work no mater what i try

PostPosted: Sat Sep 15, 2012 22:17
by leo_rockway
I like them.

PostPosted: Sat Sep 15, 2012 22:20
by babe223
you could make 3D monsters would be so cool and each monster could be different (if not like it so they IguaĆ­ boat) I liked the mod
=D

PostPosted: Sun Sep 16, 2012 02:06
by Feorth
Really cool mod indeed.
Thanks a lot! I'll be using this one on my server :)

PostPosted: Sun Sep 16, 2012 03:18
by Josh
Just what we need, simple mobs with simple graphics. And the graphics don't look scary! Cool job PilzAdam!

PostPosted: Sun Sep 16, 2012 09:00
by PilzAdam
Myu wrote:EDITED.
It does work but I got an error & game crash :

ServerError: LuaError: error running function 'on_step': attempt to index a number value

Everyone who get this error has not latest dev version of MT installed.

PostPosted: Sun Sep 16, 2012 12:27
by PilzAdam
Sheep added.

PostPosted: Sun Sep 16, 2012 14:08
by irksomeduck
Can't get it to run - Debug.txt entry

Code: Select all
14:05:48: INFO[main]: Waiting for other menus
14:05:48: INFO[main]: Waited for other menus
14:05:48: VERBOSE[main]: error_message = ModError: Failed to load and run C:\Users\Lewis\Desktop\Minetest 0.4.3\bin\..\mods\minetest\PilzAdam-mobs-4151fe2\init.lua
14:05:48: VERBOSE[main]: Check debug.txt for details.
14:05:48: INFO[main]: Created main menu
14:05:48: INFO[main]: locale has been set to:English_United Kingdom.1252
14:05:48: INFO[main]: locale has been set to:C
14:05:51: INFO[main]: locale has been set to:English_United Kingdom.1252
14:05:51: INFO[main]: locale has been set to:C
14:05:52: INFO[main]: Dropping main menu
14:05:52: INFO[main]: Updating configuration file: "C:\Users\Lewis\Desktop\Minetest 0.4.3\bin\..\minetest.conf"
14:05:52: INFO[main]: Changing value of "selected_mainmenu_tab" = "1" -> "0"
14:05:52: INFO[main]: Changing value of "selected_world_path" = "C:\Users\Lewis\Desktop\minetest-0.4.3-4a11323-meta_set_nodedef-win32\bin\..\worlds\Irksomeduck's House world" -> "C:\Users\Lewis\Desktop\Minetest 0.4.3\bin\..\worlds\Irksomeduck's House world"


N.B. I changed the name to "Mobs"