1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-06-28 06:30:18 +02:00

code tweaks

This commit is contained in:
tenplus1
2023-10-08 16:44:42 +01:00
parent 7f1ad09870
commit 457eb1838c
2 changed files with 92 additions and 85 deletions

33
api.txt
View File

@ -387,6 +387,31 @@ for each mob.
in it's name.
Internal Functions
------------------
Each mob contains a set of functions that can be called for use internally or from
another mod entirely, replace mob_class with the mob entity variable:
mob_class:mob_sound(sound) -- play sound at mob position
mob_class:do_attack(player) -- if not already attacking, attack object given
mob_class:collision() -- checks for player collision with mob and returns {x, z} vector
mob_class:set_velocity(velocity) -- move at velocity in the facing direction
mob_class:get_velocity() -- returns mob speed value
mob_class:set_yaw(yaw, delay) -- change mob yaw, delay is for smooth rotation (default:0)
mob_class:yaw_to_pos(pos, delay) -- rotates mod to look at position and returns new yaw
mob_class:set_animation(animation, force) -- set mob animation
mob_class:line_of_sight(pos1, pos2, stepsize) -- internal line of sight function
mob_class:attempt_flight_correction(override) -- check for stuck flying mobs and fix
mob_class:update_tag(newname) -- update nametag or give new name
mob_class:do_jump() -- check if mob can jump then jump
mob_class:follow_holding(clicker) -- return True if mob likes what player is holding
mob_class:day_docile() -- return True if mob docile during current daytime
mob_class:mob_expire(pos, dtime) -- check if mob is to despawn
mob_class:get_nodes() -- get specific nodes around mob
mob_class:on_blast(damage) -- function called when mob in blast area
Adding Mobs in World
--------------------
@ -473,6 +498,12 @@ true the mob will not spawn.
'name' is the name of the animal/monster
mobs:node_ok(pos, fallback)
This global function gets the node at pos and if not registered will return the
fallback node instead.
Particle Effects
----------------
@ -717,7 +748,7 @@ returns true if a mob can see the player or victim.
Use this instead:
mob_class:line_of_sight(pos1, pos2, stepsize)
entity:line_of_sight(pos1, pos2, stepsize)
mobs:can_spawn(pos, name)