mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-26 00:50:21 +01:00
added new line_of_sight that uses raycasting when mt5.0 is found (thanks Astrobe)
This commit is contained in:
parent
ddbd403285
commit
392974e835
46
api.lua
46
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20190430",
|
version = "20190508",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- check line of sight (BrunoMine)
|
-- check line of sight (BrunoMine)
|
||||||
function mob_class:line_of_sight(pos1, pos2, stepsize)
|
local line_of_sight = function(self, pos1, pos2, stepsize)
|
||||||
|
|
||||||
stepsize = stepsize or 1
|
stepsize = stepsize or 1
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- check line of sight (by BrunoMine, tweaked by Astrobe)
|
-- check line of sight (by BrunoMine, tweaked by Astrobe)
|
||||||
function mob_class:NEW_line_of_sight(pos1, pos2, stepsize)
|
local new_line_of_sight = function(self, pos1, pos2, stepsize)
|
||||||
|
|
||||||
if not pos1 or not pos2 then return end
|
if not pos1 or not pos2 then return end
|
||||||
|
|
||||||
@ -447,10 +447,46 @@ function mob_class:NEW_line_of_sight(pos1, pos2, stepsize)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- check line of sight using raycasting (thanks Astrobe)
|
||||||
|
local ray_line_of_sight = function(self, pos1, pos2)
|
||||||
|
|
||||||
|
local ray = minetest.raycast(pos1, pos2, true, false)
|
||||||
|
local thing = ray:next()
|
||||||
|
|
||||||
|
while thing do
|
||||||
|
|
||||||
|
if thing.type == "object"
|
||||||
|
and thing.ref ~= self.object
|
||||||
|
and not thing.ref:is_player() then return false end
|
||||||
|
|
||||||
|
if thing.type == "node" then
|
||||||
|
|
||||||
|
local name = minetest.get_node(thing.under).name
|
||||||
|
|
||||||
|
if minetest.registered_items[name].walkable then return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
thing = ray:next()
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- detect if using minetest 5.0 by searching for permafrost node
|
||||||
|
local is_50 = minetest.registered_nodes["default:permafrost"]
|
||||||
|
|
||||||
|
function mob_class:line_of_sight(pos1, pos2, stepsize)
|
||||||
|
|
||||||
|
if is_50 then -- only use if minetest 5.0 is detected
|
||||||
|
return ray_line_of_sight(self, pos1, pos2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return line_of_sight(self, pos1, pos2, stepsize)
|
||||||
|
end
|
||||||
|
|
||||||
-- global function
|
-- global function
|
||||||
function mobs:line_of_sight(entity, pos1, pos2, stepsize)
|
function mobs:line_of_sight(entity, pos1, pos2, stepsize)
|
||||||
|
return mob_class.line_of_sight(pos1, pos2, stepsize)
|
||||||
return mob_class.line_of_sight(entity, pos1, pos2, stepsize)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
6
api.txt
6
api.txt
@ -576,7 +576,7 @@ Certain variables need to be set before using the above functions:
|
|||||||
'self.driver_scale' sets driver scale for mobs larger than {x=1, y=1}
|
'self.driver_scale' sets driver scale for mobs larger than {x=1, y=1}
|
||||||
|
|
||||||
|
|
||||||
mobs:line_of_sight(self, pos1, pos2, stepsize)
|
mobs:line_of_sight(self, pos1, pos2, stepsize) [DEPRECATED]
|
||||||
|
|
||||||
This function is for use within the mobs definition for special use cases and
|
This function is for use within the mobs definition for special use cases and
|
||||||
returns true if a mob can see the player or victim.
|
returns true if a mob can see the player or victim.
|
||||||
@ -586,6 +586,10 @@ returns true if a mob can see the player or victim.
|
|||||||
'pos2' position of vistim or player
|
'pos2' position of vistim or player
|
||||||
'stepsize' usually set to 1
|
'stepsize' usually set to 1
|
||||||
|
|
||||||
|
Use this instead:
|
||||||
|
|
||||||
|
mob_class:line_of_sight(pos1, pos2, stepsize)
|
||||||
|
|
||||||
|
|
||||||
External Settings for "minetest.conf"
|
External Settings for "minetest.conf"
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
171
readme.MD
171
readme.MD
@ -1,85 +1,86 @@
|
|||||||
|
|
||||||
MOBS REDO for MINETEST
|
MOBS REDO for MINETEST
|
||||||
|
|
||||||
Built from PilzAdam's original Simple Mobs with additional mobs by KrupnoPavel, Zeg9, ExeterDad and AspireMint.
|
Built from PilzAdam's original Simple Mobs with additional mobs by KrupnoPavel, Zeg9, ExeterDad and AspireMint.
|
||||||
|
|
||||||
|
|
||||||
This mod contains the API only for adding your own mobs into the world, so please use the additional modpacks to add animals, monsters etc.
|
This mod contains the API only for adding your own mobs into the world, so please use the additional modpacks to add animals, monsters etc.
|
||||||
|
|
||||||
|
|
||||||
https://forum.minetest.net/viewtopic.php?f=11&t=9917
|
https://forum.minetest.net/viewtopic.php?f=11&t=9917
|
||||||
|
|
||||||
|
|
||||||
Crafts:
|
Crafts:
|
||||||
|
|
||||||
- Nametag (paper, black dye, string) can be used right-click on a tamed mob to give them a name.
|
- Nametag (paper, black dye, string) can be used right-click on a tamed mob to give them a name.
|
||||||
- Nets can be used to right-click tamed mobs to pick them up and place inside inventory as a spawn egg.
|
- Nets can be used to right-click tamed mobs to pick them up and place inside inventory as a spawn egg.
|
||||||
- Magic Lasso is similar to nets but with a better chance of picking up larger mobs.
|
- Magic Lasso is similar to nets but with a better chance of picking up larger mobs.
|
||||||
- Shears are used to right-click sheep and return 1-3 wool.
|
- Shears are used to right-click sheep and return 1-3 wool.
|
||||||
- Protection Rune lets you protect tamed mobs from harm by other players
|
- Protection Rune lets you protect tamed mobs from harm by other players
|
||||||
- Mob Fence and Fence Top (to stop mobs escaping/glitching through fences)
|
- Mob Fence and Fence Top (to stop mobs escaping/glitching through fences)
|
||||||
|
|
||||||
Lucky Blocks: 9
|
Lucky Blocks: 9
|
||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found (thanks Astrobe)
|
||||||
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
||||||
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
|
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
||||||
- 1.46- Mobs only drop rare items when killed by player (drops.min = 0 makes them rare), code tweak, pathfinding no longer sees through walkable nodes
|
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
|
||||||
- 1.45- Added Fence Top to add on top of any fence to stop mobs escaping, new line_of_sight tweaked by Astrobe
|
- 1.46- Mobs only drop rare items when killed by player (drops.min = 0 makes them rare), code tweak, pathfinding no longer sees through walkable nodes
|
||||||
- 1.44- Added ToolRanks support for swords when attacking mobs
|
- 1.45- Added Fence Top to add on top of any fence to stop mobs escaping, new line_of_sight tweaked by Astrobe
|
||||||
- 1.43- Better 0.4.16 compatibility, added general attack function and settings
|
- 1.44- Added ToolRanks support for swords when attacking mobs
|
||||||
- 1.42- Added "all" option to immune_to table, tidied floating mobs to be less intensive
|
- 1.43- Better 0.4.16 compatibility, added general attack function and settings
|
||||||
- 1.41- Mob pathfinding has been updated thanks to Elkien3
|
- 1.42- Added "all" option to immune_to table, tidied floating mobs to be less intensive
|
||||||
- 1.40- Updated to use newer functions, requires Minetest 0.4.16+ to work.
|
- 1.41- Mob pathfinding has been updated thanks to Elkien3
|
||||||
- 1.39- Added 'on_breed', 'on_grown' and 'do_punch' custom functions per mob
|
- 1.40- Updated to use newer functions, requires Minetest 0.4.16+ to work.
|
||||||
- 1.38- Better entity checking, nametag setting and on_spawn function added to mob registry, tweaked light damage
|
- 1.39- Added 'on_breed', 'on_grown' and 'do_punch' custom functions per mob
|
||||||
- 1.37- Added support for Raymoo's CMI (common mob interface) mod: https://forum.minetest.net/viewtopic.php?f=9&t=15448
|
- 1.38- Better entity checking, nametag setting and on_spawn function added to mob registry, tweaked light damage
|
||||||
- 1.36- Death check added, if mob dies in fire/lava/with lava pick then drops are cooked
|
- 1.37- Added support for Raymoo's CMI (common mob interface) mod: https://forum.minetest.net/viewtopic.php?f=9&t=15448
|
||||||
- 1.35- Added owner_loyal flag for owned mobs to attack player enemies, also fixed group_attack
|
- 1.36- Death check added, if mob dies in fire/lava/with lava pick then drops are cooked
|
||||||
- 1.34- Added function to fly mob using directional movement (thanks D00Med for flying code)
|
- 1.35- Added owner_loyal flag for owned mobs to attack player enemies, also fixed group_attack
|
||||||
- 1.33- Added functions to mount ride mobs (mobs.attach, mobs.detach, mobs.drive) many thanks to Blert2112
|
- 1.34- Added function to fly mob using directional movement (thanks D00Med for flying code)
|
||||||
- 1.32- Added new spawn check to count specific mobs AND new minetest.conf setting to chance spawn chance and numbers, added ability to protect tamed mobs
|
- 1.33- Added functions to mount ride mobs (mobs.attach, mobs.detach, mobs.drive) many thanks to Blert2112
|
||||||
- 1.31- Added 'attack_animals' and 'specific_attack' flags for custom monster attacks, also 'mob_difficulty' .conf setting to make mobs harder.
|
- 1.32- Added new spawn check to count specific mobs AND new minetest.conf setting to chance spawn chance and numbers, added ability to protect tamed mobs
|
||||||
- 1.30- Added support for invisibility mod (mobs cant attack what they cant see), tweaked and tidied code
|
- 1.31- Added 'attack_animals' and 'specific_attack' flags for custom monster attacks, also 'mob_difficulty' .conf setting to make mobs harder.
|
||||||
- 1.29- Split original Mobs Redo into a modpack to make it easier to disable mob sets (animal, monster, npc) or simply use the Api itself for your own mod
|
- 1.30- Added support for invisibility mod (mobs cant attack what they cant see), tweaked and tidied code
|
||||||
- 1.28- New damage system added with ability for mob to be immune to weapons or healed by them :)
|
- 1.29- Split original Mobs Redo into a modpack to make it easier to disable mob sets (animal, monster, npc) or simply use the Api itself for your own mod
|
||||||
- 1.27- Added new sheep, lava flan and spawn egg textures. New Lava Pick tool smelts what you dig. New atan checking function.
|
- 1.28- New damage system added with ability for mob to be immune to weapons or healed by them :)
|
||||||
- 1.26- Pathfinding feature added thanks to rnd, when monsters attack they become scary smart in finding you :) also, beehive produces honey now :)
|
- 1.27- Added new sheep, lava flan and spawn egg textures. New Lava Pick tool smelts what you dig. New atan checking function.
|
||||||
- 1.25- Mobs no longer spawn within 12 blocks of player or despawn within same range, spawners now have player detection, Code tidy and tweak.
|
- 1.26- Pathfinding feature added thanks to rnd, when monsters attack they become scary smart in finding you :) also, beehive produces honey now :)
|
||||||
- 1.24- Added feature where certain animals run away when punched (runaway = true in mob definition)
|
- 1.25- Mobs no longer spawn within 12 blocks of player or despawn within same range, spawners now have player detection, Code tidy and tweak.
|
||||||
- 1.23- Added mob spawner block for admin to setup spawners in-game (place and right click to enter settings)
|
- 1.24- Added feature where certain animals run away when punched (runaway = true in mob definition)
|
||||||
- 1.22- Added ability to name tamed animals and npc using nametags, also npc will attack anyone who punches them apart from owner
|
- 1.23- Added mob spawner block for admin to setup spawners in-game (place and right click to enter settings)
|
||||||
- 1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
|
- 1.22- Added ability to name tamed animals and npc using nametags, also npc will attack anyone who punches them apart from owner
|
||||||
- 1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
|
- 1.21- Added some more error checking to reduce serialize.h error and added height checks for falling off cliffs (thanks cmdskp)
|
||||||
- 1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
|
- 1.20- Error checking added to remove bad mobs, out of map limit mobs and stop serialize.h error
|
||||||
- 1.18- Added docile_by_day flag so that monsters will not attack automatically during daylight hours unless hit first
|
- 1.19- Chickens now drop egg items instead of placing the egg, also throwing eggs result in 1/8 chance of spawning chick
|
||||||
- 1.17- Added 'dogshoot' attack type, shoots when out of reach, melee attack when in reach, also api tweaks and self.reach added
|
- 1.18- Added docile_by_day flag so that monsters will not attack automatically during daylight hours unless hit first
|
||||||
- 1.16- Mobs follow multiple items now, Npc's can breed
|
- 1.17- Added 'dogshoot' attack type, shoots when out of reach, melee attack when in reach, also api tweaks and self.reach added
|
||||||
- 1.15- Added Feeding/Taming/Breeding function, right-click to pick up any sheep with X mark on them and replace with new one to fix compatibility.
|
- 1.16- Mobs follow multiple items now, Npc's can breed
|
||||||
- 1.14- All .self variables saved in staticdata, Fixed self.health bug
|
- 1.15- Added Feeding/Taming/Breeding function, right-click to pick up any sheep with X mark on them and replace with new one to fix compatibility.
|
||||||
- 1.13- Added capture function (thanks blert2112) chance of picking up mob with hand; net; magic lasso, replaced some .x models with newer .b3d one's
|
- 1.14- All .self variables saved in staticdata, Fixed self.health bug
|
||||||
- 1.12- Added animal ownership so that players cannot steal your tamed animals
|
- 1.13- Added capture function (thanks blert2112) chance of picking up mob with hand; net; magic lasso, replaced some .x models with newer .b3d one's
|
||||||
- 1.11- Added flying mobs (and swimming), fly=true and fly_in="air" or "deafult:water_source" for fishy
|
- 1.12- Added animal ownership so that players cannot steal your tamed animals
|
||||||
- 1,10- Footstep removed (use replace), explosion routine added for exploding mobs.
|
- 1.11- Added flying mobs (and swimming), fly=true and fly_in="air" or "deafult:water_source" for fishy
|
||||||
- 1.09- reworked breeding routine, added mob rotation value, added footstep feature, added jumping mobs with sounds feature, added magic lasso for picking up animals
|
- 1,10- Footstep removed (use replace), explosion routine added for exploding mobs.
|
||||||
- 1.08- Mob throwing attack has been rehauled so that they can damage one another, also drops and on_die function added
|
- 1.09- reworked breeding routine, added mob rotation value, added footstep feature, added jumping mobs with sounds feature, added magic lasso for picking up animals
|
||||||
- 1.07- Npc's can now be set to follow player or stand by using self.order and self.owner variables
|
- 1.08- Mob throwing attack has been rehauled so that they can damage one another, also drops and on_die function added
|
||||||
- beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop
|
- 1.07- Npc's can now be set to follow player or stand by using self.order and self.owner variables
|
||||||
- 1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
|
- beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop
|
||||||
- 1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten
|
- 1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
|
||||||
- 1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :)
|
- 1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten
|
||||||
- 1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc.
|
- 1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :)
|
||||||
- 1.02- Sheared sheep are remembered and spawn shaven, Warthogs will attack when threatened, Api additions
|
- 1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc.
|
||||||
- 1.01- Mobs that suffer fall damage or die in water/lava/sunlight will now drop items
|
- 1.02- Sheared sheep are remembered and spawn shaven, Warthogs will attack when threatened, Api additions
|
||||||
- 1.0 - more work on Api so that certain mobs can float in water while some sink like a brick :)
|
- 1.01- Mobs that suffer fall damage or die in water/lava/sunlight will now drop items
|
||||||
- 0.9 - Spawn eggs added for all mobs (admin only, cannot be placed in protected areas)... Api tweaked
|
- 1.0 - more work on Api so that certain mobs can float in water while some sink like a brick :)
|
||||||
- 0.8 - Added sounds to monster mobs (thanks Cyberpangolin for the sfx) and also chicken sound
|
- 0.9 - Spawn eggs added for all mobs (admin only, cannot be placed in protected areas)... Api tweaked
|
||||||
- 0.7 - mobs.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
|
- 0.8 - Added sounds to monster mobs (thanks Cyberpangolin for the sfx) and also chicken sound
|
||||||
- 0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block
|
- 0.7 - mobs.protected switch added to api.lua, when set to 1 mobs no longer spawn in protected areas, also bug fixes
|
||||||
- 0.5 - Mobs now float in water, die from falling, and some code improvements
|
- 0.6 - Api now supports multi-textured mobs, e.g oerkki, dungeon master, rats and chickens have random skins when spawning (sheep fix TODO), also new Honey block
|
||||||
- 0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :)
|
- 0.5 - Mobs now float in water, die from falling, and some code improvements
|
||||||
- 0.3 - Added LOTT's Spider mob, made Cobwebs, added KPavel's Bee with Honey and Beehives (made texture), Warthogs now have sound and can be tamed, taming of shaved sheep or milked cow with 8 wheat so it will not despawn, many bug fixes :)
|
- 0.4 - Dungeon Masters and Mese Monsters have much better aim due to shoot_offset, also they can both shoot through nodes that aren't walkable (flowers, grass etc) plus new sheep sound :)
|
||||||
- 0.2 - Cooking bucket of milk into cheese now returns empty bucket
|
- 0.3 - Added LOTT's Spider mob, made Cobwebs, added KPavel's Bee with Honey and Beehives (made texture), Warthogs now have sound and can be tamed, taming of shaved sheep or milked cow with 8 wheat so it will not despawn, many bug fixes :)
|
||||||
- 0.1 - Initial Release
|
- 0.2 - Cooking bucket of milk into cheese now returns empty bucket
|
||||||
|
- 0.1 - Initial Release
|
||||||
|
Loading…
Reference in New Issue
Block a user