forked from VoxeLibre/VoxeLibre
Compare commits
452 Commits
mobs-study
...
master
Author | SHA1 | Date |
---|---|---|
cora | e322a9e23a | |
MysticTempest | dd1a58b01e | |
cora | 87c9969801 | |
PrairieAstronomer | fec5650711 | |
PrairieAstronomer | 5abfa555eb | |
PrairieAstronomer | dead4069b0 | |
PrairieAstronomer | 4bc67a174b | |
PrairieAstronomer | c71b036e6a | |
PrairieAstronomer | 046698c64f | |
cora | e80eebd989 | |
cora | 31b8ea26a2 | |
cora | fd6f2be485 | |
cora | 07e0a90051 | |
cora | f073d4d420 | |
cora | 89aaf6b709 | |
cora | f09b578034 | |
cora | 0ce1a92282 | |
cora | 135ee97b21 | |
cora | 51cf92a909 | |
cora | 2d47ad3e5f | |
cora | c28d700caf | |
cora | ba861d7b74 | |
cora | 9b8b7ce6b4 | |
cora | 046b3a4ce2 | |
cora | 354d17a14c | |
cora | 11265b60de | |
Mikita Wiśniewski | 7f3ba7d4a2 | |
cora | 88e87bccff | |
cora | a1209b14a1 | |
cora | 729159f631 | |
kabou | baf8e0b79c | |
chmodsayshello | 00dba67cd8 | |
kabou | 872b708465 | |
kabou | 74e70b674e | |
kabou | 14c882f982 | |
kabou | 8ae605165b | |
kabou | aca4aca79b | |
kabou | bacc7613b5 | |
kabou | 8a4b8707fa | |
kabou | a8c231da34 | |
cora | 4d342b8365 | |
cora | 12a943e222 | |
cora | 8d0afede37 | |
cora | 0288581407 | |
cora | 3774044f86 | |
cora | 46dbf8c0ab | |
cora | 7c263c6a18 | |
MysticTempest | 44b1d583a7 | |
cora | 1565999134 | |
cora | 5a25e42fd3 | |
cora | 421995deb3 | |
kabou | 4e3a2a7b4c | |
cora | e8e565fc06 | |
chmodsayshello | 6cb08a3c87 | |
chmodsayshello | 31a8ddabb8 | |
chmodsayshello | 6806ea311d | |
cora | ea2b53b231 | |
cora | e1ed990f58 | |
cora | e4c5f81524 | |
kay27 | 53042b6f48 | |
cora | fbe048087f | |
Elias Fleckenstein | 34e5bb0334 | |
Elias Fleckenstein | c05a2d3a9d | |
cora | 40d2e3b2b1 | |
cora | f1fc84b31b | |
cora | 85fb33aa4c | |
AFCMS | f9a2dacdd4 | |
AFCMS | 00c70014c7 | |
3raven | f4020ebd31 | |
kay27 | 74322ead49 | |
kay27 | 1a83f50505 | |
kay27 | 206c98e354 | |
kay27 | 69e83d5c0a | |
kay27 | d3dfd13f78 | |
kay27 | e28ccd9a80 | |
kay27 | a5fba06a2c | |
1F616EMO | 6c36c83a18 | |
1F616EMO | 48a4e069f9 | |
1F616EMO | 60e04438e0 | |
1F616EMO | 0b01d299ea | |
1F616EMO | ebdf944dda | |
1F616EMO | 794e10df4e | |
cora | 1cc8a7f8df | |
cora | 6a2fe2eb4f | |
cora | 6674684998 | |
kabou | 1266396e1d | |
kabou | f5abc28190 | |
AFCMS | f8f6ea22c8 | |
cora | b0b8ef3921 | |
cora | be6d2db7d4 | |
cora | dc40ed18b3 | |
cora | 1b99de73d2 | |
NO11 | c97e0cd631 | |
NO11 | 8c7a8a61d2 | |
NO11 | 6bdaa9f2d1 | |
cora | 8b8a133381 | |
kabou | dceb48bf94 | |
cora | e10c06ba98 | |
AFCMS | 8a47a195f6 | |
AFCMS | d0b60e2399 | |
AFCMS | 3ca40cd4e4 | |
cora | 0e8a87befa | |
kabou | 920b8b9654 | |
cora | dab80c45fd | |
kabou | f1a494ea62 | |
kabou | 64bb50dfd5 | |
kabou | 9edb40b5c5 | |
kabou | b0ae135b3c | |
cora | b13835dd6f | |
chmodsayshello | 3699ca5535 | |
chmodsayshello | 9c652df8a2 | |
chmodsayshello | 390802a344 | |
cora | a27abae045 | |
cora | 61a999fe5a | |
cora | 85afc8bd53 | |
kabou | ed8995acec | |
cora | 38f1db7a04 | |
chmodsayshello | f1c60a48e0 | |
chmodsayshello | c97fc42b68 | |
chmodsayshello | 92cd3381ad | |
chmodsayshello | f7a5862df2 | |
chmodsayshello | ba8e072265 | |
chmodsayshello | f9d8b61dc1 | |
chmodsayshello | dd727510ba | |
cora | a4e8c0b884 | |
Nils Dagsson Moskopp | 057051aa6d | |
cora | 83aebb8b99 | |
cora | deb2e1c50b | |
cora | 7d9cbd5f84 | |
cora | deb2c4ab50 | |
cora | 64ec36fe36 | |
Nils Dagsson Moskopp | cbf3dc49aa | |
cora | 6bc676545b | |
chmodsayshello | 77c2f9371e | |
cora | 4cdb1130af | |
cora | 5f126c4686 | |
cora | dd12417529 | |
Nils Dagsson Moskopp | 67ae203772 | |
Nils Dagsson Moskopp | 5ba36c08b6 | |
Nils Dagsson Moskopp | 56db877360 | |
Nils Dagsson Moskopp | e1d67a2095 | |
Nils Dagsson Moskopp | a2dd8c935d | |
Nils Dagsson Moskopp | 4fda54b0d1 | |
Nils Dagsson Moskopp | 9a53761b08 | |
Alexander Minges | 9b614c115c | |
Alexander Minges | faf3f60cff | |
cora | 1bcbdfbc4c | |
cora | b6ab815adc | |
cora | 511b7030e1 | |
cora | a83a2e9aba | |
cora | 0c03d420b8 | |
AFCMS | 8396dfe7e3 | |
cora | 231b658c3f | |
kay27 | dc4ccf91cc | |
cora | 8bf1d2b235 | |
cora | 3cb9947cf4 | |
cora | d1cd46e197 | |
cora | 33097a7656 | |
cora | 9ad4222f35 | |
cora | feb1fcc5b4 | |
cora | 6976ffca62 | |
Nils Dagsson Moskopp | 34b5002fc8 | |
cora | e63e3b3cbd | |
NO411 | 2aa04519dd | |
NO411 | e790bf90f4 | |
NO411 | b108f58b2f | |
cora | 8e904e2ca9 | |
cora | bb593159f1 | |
cora | 83c91aba93 | |
cora | e7970ecce5 | |
kabou | b96fb2af17 | |
kabou | 152e552458 | |
cora | f807ac5c70 | |
kabou | ace0dc00c7 | |
cora | 85d1f61188 | |
kabou | f3b28df6cc | |
kabou | f37f8b6bca | |
kabou | 2ba801dfc7 | |
kabou | bba3aabb59 | |
kabou | 19eb31f389 | |
kabou | 541a805a48 | |
kabou | cd12e1d78c | |
kabou | 4335d0d659 | |
kabou | de16eb3c5a | |
cora | 6851fa759e | |
cora | 7f1bb7af92 | |
cora | 53715212a2 | |
cora | c146426c5c | |
cora | dc24f45cfa | |
cora | d2861c5955 | |
cora | 1e4494e85d | |
cora | 4eae95fa47 | |
cora | ef7ebda90c | |
kabou | 1b99b73894 | |
kabou | 14da059ce7 | |
cora | 04f0ea260d | |
NO11 | 5974b6f609 | |
NO411 | 148be4ea39 | |
NO411 | 6afe7cfb58 | |
cora | 8e24e6edfe | |
AFCMS | 909b77ce4d | |
cora | 1dde51dd0b | |
NO11 | 63a156c30c | |
cora | 1c9f0c3238 | |
cora | 50e99f470e | |
NO411 | aeff7cf1a4 | |
cora | bc723616ea | |
kabou | 46ee5aaa59 | |
cora | 3dd4eec4e8 | |
NO411 | 019dd45381 | |
NO411 | d481f7b720 | |
NO411 | c94964d10a | |
kabou | a9a3f01a0e | |
kabou | ae6bea73fd | |
kabou | 2002872af8 | |
kabou | 8518ce2c19 | |
NO411 | 6158e4e50d | |
NO411 | 7c0a48bebf | |
NO411 | 5bdf83cbfc | |
NO411 | 976cfba53a | |
NO411 | fc9e83c059 | |
NO411 | 60d877b718 | |
cora | 81a1b9973a | |
kabou | 9eba0e4860 | |
kabou | 90311da514 | |
kabou | e9ff2ba32a | |
cora | 0b89149fe2 | |
cora | 7df6c8739e | |
cora | cd725137ae | |
NO411 | 0f8f5a41d2 | |
NO411 | db68c0e26b | |
NO11 | 627da6d305 | |
cora | 1803cc560d | |
kabou | 3f787f8305 | |
epCode | 9534624b21 | |
epCode | 4483f4b6b6 | |
cora | d3bfdb190e | |
AFCMS | 47b1eeda74 | |
cora | ba0e2cbf29 | |
Freedom | f430aec0cd | |
NO11 | a44846a82c | |
cora | 22edd08387 | |
kabou | 17b8eab368 | |
cora | 119b4aa82c | |
cora | 181c3f0c0f | |
cora | 21e7ab1f2a | |
cora | 6f284c0c95 | |
cora | e0801ba7e4 | |
cora | 267031793d | |
MysticTempest | de3cdee09e | |
cora | c5993a60ae | |
Nils Dagsson Moskopp | 77f8ecd6e8 | |
Nils Dagsson Moskopp | 4da5084daf | |
cora | dca653651c | |
kabou | deed231f28 | |
kabou | 11ee1d133f | |
kabou | 1326b9e7e7 | |
kabou | 6a69f49fa0 | |
kabou | f5a8d6d17a | |
kabou | 3f4dafc68f | |
kabou | 9bac0da01a | |
kabou | 818cbb2f48 | |
kabou | 88f7a150c7 | |
kabou | 962500b189 | |
kabou | 95cfa43483 | |
kabou | 4a1b93bbfa | |
kabou | b9c2c3bd0a | |
cora | 52333cea0f | |
Dieter44 | f8c60b5f75 | |
cora | bcf302ceb0 | |
MysticTempest | 7a53ea8b70 | |
cora | e8ff33a741 | |
Elias Åström | 3c10f0e970 | |
cora | f7d712543f | |
kabou | c3e0996902 | |
kabou | d424d4f10e | |
kabou | e80006f4ea | |
kabou | b17776699e | |
kabou | 86a4ece7d2 | |
kabou | df5d24104d | |
cora | 8dd540269c | |
kabou | 56b63463a5 | |
cora | c2ae28aec1 | |
Nils Dagsson Moskopp | 66bb209ad1 | |
cora | a3e01e6dbe | |
AFCMS | 5a7b1cc382 | |
AFCMS | 210a0d8ee1 | |
AFCMS | eae8effd57 | |
AFCMS | b51e322304 | |
AFCMS | 096d46152e | |
AFCMS | d89687984b | |
AFCMS | c6f72c473f | |
AFCMS | 540b72f1d6 | |
AFCMS | 7449725a56 | |
AFCMS | 9e7a525a0a | |
AFCMS | 4bd91750bc | |
cora | 8e1a9e1785 | |
E | 87e494f42b | |
cora | dfed21ee14 | |
cora | 3feca330c9 | |
cora | caacb378de | |
cora | 379972ea11 | |
cora | 414e2e7725 | |
cora | 435b5d756d | |
cora | 2bb416765c | |
cora | 02361b2d01 | |
cora | 86ca401e4e | |
cora | 378b5b30c9 | |
cora | 840b705a22 | |
cora | 80c79dde1c | |
Nils Dagsson Moskopp | 27842aa2f5 | |
cora | 85e0e23c76 | |
Nils Dagsson Moskopp | 41550da87b | |
cora | a4e541bcd2 | |
AFCMS | 89a930ace3 | |
AFCMS | 129117efb3 | |
AFCMS | cbfc71705d | |
cora | 4b89398b3b | |
kabou | 5431e206b0 | |
cora | c60fd92638 | |
1F616EMO | 06deb92dd6 | |
1F616EMO | 7685b4758f | |
1F616EMO | 9944abb328 | |
1F616EMO | 5ce1852c1d | |
1F616EMO | 56a70025b8 | |
1F616EMO | 9fe3bbd2fa | |
1F616EMO | fb1d189d40 | |
1F616EMO | 9cd24f4af5 | |
1F616EMO | a64c3f87bc | |
1F616EMO | 5075f2ca56 | |
1F616EMO | 249dfac319 | |
1F616EMO | 2b5a0242db | |
1F616EMO | 790ccf0812 | |
1F616EMO | 8d639794f3 | |
1F616EMO | af8681c143 | |
1F616EMO | 1ef58f7250 | |
1F616EMO | 15747220f2 | |
1F616EMO | 925dad7f5e | |
1F616EMO | 729f653c85 | |
1F616EMO | d1e328e57a | |
1F616EMO | 615a968fbb | |
1F616EMO | 7e5a9bd8b6 | |
1F616EMO | d018bee00a | |
1F616EMO | 1365d0b257 | |
1F616EMO | a289a00427 | |
1F616EMO | a238aabbb0 | |
1F616EMO | b02f7cd974 | |
1F616EMO | e19113d4e0 | |
1F616EMO | 4deac632e6 | |
1F616EMO | c480e6891d | |
1F616EMO | 844eb3fb7c | |
1F616EMO | fc768cb1ad | |
1F616EMO | 1f9a919459 | |
1F616EMO | 70007e3453 | |
1F616EMO | 3aff1f8981 | |
1F616EMO | c86a506672 | |
1F616EMO | f348223da2 | |
1F616EMO | ca6469b959 | |
1F616EMO | c52e09ddcd | |
1F616EMO | bb55120adc | |
1F616EMO | 77339afbe2 | |
1F616EMO | 9b15599bee | |
1F616EMO | a685c3bc83 | |
1F616EMO | b01d4eba88 | |
1F616EMO | 952747d4da | |
1F616EMO | 430f5b05ab | |
1F616EMO | e4a311e28a | |
1F616EMO | 6a115a68ef | |
1F616EMO | f3d0ec845c | |
1F616EMO | 563daeed8a | |
1F616EMO | a6c3cab791 | |
1F616EMO | bb4ddee570 | |
1F616EMO | fe3e80bc0e | |
1F616EMO | 59fe078fd7 | |
1F616EMO | dba08ddc1f | |
1F616EMO | 551bf917e2 | |
1F616EMO | 26dadb1846 | |
1F616EMO | 33a353e20d | |
1F616EMO | f02f3c9f40 | |
1F616EMO | 410c1ecd1f | |
1F616EMO | ba172f0847 | |
1F616EMO | ad42c3588b | |
1F616EMO | 9734c74c56 | |
1F616EMO | c3dd5e6c2c | |
1F616EMO | 21808390f9 | |
1F616EMO | cc87791327 | |
1F616EMO | f8cd01a15e | |
1F616EMO | a8aabb2329 | |
1F616EMO | 4f00b62a18 | |
cora | 97412b139a | |
AFCMS | ceb27b6929 | |
AFCMS | b2614f8d78 | |
AFCMS | 84596b2ebb | |
cora | 6bb6966752 | |
AFCMS | 360a1604ba | |
AFCMS | 61f4c5b885 | |
AFCMS | a272322cb5 | |
AFCMS | 9112915ddd | |
AFCMS | 397c243e89 | |
AFCMS | c64d0e4558 | |
AFCMS | 61e54ed617 | |
AFCMS | 0988637ea1 | |
AFCMS | b88060dbfb | |
AFCMS | e3e06b4a4b | |
AFCMS | 34b445b04a | |
AFCMS | d41a836514 | |
AFCMS | 80fb59f9ac | |
cora | dae7c22dd9 | |
cora | a9357f7380 | |
cora | dcfbfd67b8 | |
kabou | af132cc523 | |
cora | a0b5e4dd0b | |
kabou | e54502edd6 | |
kabou | 639bf936c5 | |
kabou | d2261426c3 | |
kabou | 88ce1e3662 | |
kabou | b3aed9d6b8 | |
kabou | 13baa68b67 | |
kabou | 315f251584 | |
kabou | 584a75df76 | |
cora | c392fd0269 | |
kabou | 8d18ab8a7a | |
kabou | f81980da51 | |
kabou | 55009c257e | |
kabou | 51ca60c097 | |
kabou | f22baafaa6 | |
kabou | ffc2c94096 | |
kabou | cea821b2fa | |
kabou | 64608f50f8 | |
kabou | 3257014e00 | |
kabou | 06274518bf | |
kabou | 8d79d16531 | |
kabou | 1f7697b6f5 | |
kabou | 64203c38a6 | |
kabou | 4cf88abe4c | |
kabou | df8576e77c | |
cora | 6493f2885b | |
NO11 | c40c05f594 | |
NO11 | 8db28c1337 | |
NO11 | d46a96c43a | |
NO11 | 3cfcd1355f | |
NO11 | 4707cd4526 | |
NO11 | ad99746d99 | |
cora | cabf6e8cd1 | |
Nils Dagsson Moskopp | adf738854a | |
cora | 87427cb8af | |
AFCMS | da4952a125 | |
AFCMS | c59bea211d | |
AFCMS | 5aa18d573e | |
AFCMS | 13f8fd457c | |
AFCMS | 2b820d7756 | |
NO11 | 4dce90543d |
|
@ -1,2 +1,5 @@
|
||||||
# Text Editor TMP Files
|
# Text Editor TMP Files
|
||||||
*.swp
|
*.swp
|
||||||
|
*.blend1
|
||||||
|
*.blend2
|
||||||
|
*.blend3
|
||||||
|
|
21
CREDITS.md
21
CREDITS.md
|
@ -6,10 +6,14 @@
|
||||||
## Creator of MineClone2
|
## Creator of MineClone2
|
||||||
* Wuzzy
|
* Wuzzy
|
||||||
|
|
||||||
|
|
||||||
## Maintainers
|
## Maintainers
|
||||||
* Fleckenstein
|
|
||||||
* Nicu
|
* Nicu
|
||||||
* kay27
|
* cora
|
||||||
|
|
||||||
|
## Previous Maintainers
|
||||||
|
* Fleckenstein
|
||||||
|
* jordan4ibanez
|
||||||
|
|
||||||
## Developers
|
## Developers
|
||||||
* bzoss
|
* bzoss
|
||||||
|
@ -22,8 +26,7 @@
|
||||||
* aligator
|
* aligator
|
||||||
* Code-Sploit
|
* Code-Sploit
|
||||||
* NO11
|
* NO11
|
||||||
* cora
|
* kabou
|
||||||
* jordan4ibanez
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
* Laurent Rocher
|
* Laurent Rocher
|
||||||
|
@ -75,6 +78,16 @@
|
||||||
* epCode
|
* epCode
|
||||||
* NO11
|
* NO11
|
||||||
* j45
|
* j45
|
||||||
|
* 3raven
|
||||||
|
* PrarieWind
|
||||||
|
* Gustavo1
|
||||||
|
* CableGuy67
|
||||||
|
|
||||||
|
## Mineclonia
|
||||||
|
* erlehmann
|
||||||
|
* Li0n
|
||||||
|
* E
|
||||||
|
* n_to
|
||||||
|
|
||||||
## Original Mod Authors
|
## Original Mod Authors
|
||||||
* Wuzzy
|
* Wuzzy
|
||||||
|
|
|
@ -41,6 +41,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `flammable=-1` Does not get destroyed by fire
|
* `flammable=-1` Does not get destroyed by fire
|
||||||
* `fire_encouragement`: How quickly this block catches fire
|
* `fire_encouragement`: How quickly this block catches fire
|
||||||
* `fire_flammability`: How fast the block will burn away
|
* `fire_flammability`: How fast the block will burn away
|
||||||
|
* `path_creation_possible=1`: Node can be turned into grass path by using a shovel on it
|
||||||
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
* `spreading_dirt_type=1`: A dirt-type block with a cover (e.g. grass) which may spread to neighbor dirt blocks
|
||||||
* `dirtifies_below_solid=1`: This node turns into dirt immediately when a solid or dirtifier node is placed on top
|
* `dirtifies_below_solid=1`: This node turns into dirt immediately when a solid or dirtifier node is placed on top
|
||||||
* `dirtifier=1`: This node turns nodes the above group into dirt when placed above
|
* `dirtifier=1`: This node turns nodes the above group into dirt when placed above
|
||||||
|
@ -56,6 +57,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored.
|
* `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored.
|
||||||
* `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar
|
* `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar
|
||||||
* `attached_node_facedir=1`: Like `attached_node`, but for facedir nodes
|
* `attached_node_facedir=1`: Like `attached_node`, but for facedir nodes
|
||||||
|
* `supported_node=1`: Like `attached_node`, but can be placed on any nodes that do not have the `drawtype="airlike"` attribute.
|
||||||
* `cauldron`: Cauldron. 1: Empty. 2-4: Water height
|
* `cauldron`: Cauldron. 1: Empty. 2-4: Water height
|
||||||
* `anvil`: Anvil. 1: No damage. 2-3: Higher damage levels
|
* `anvil`: Anvil. 1: No damage. 2-3: Higher damage levels
|
||||||
* `no_rename=1`: Item cannot be renamed by anvil
|
* `no_rename=1`: Item cannot be renamed by anvil
|
||||||
|
@ -71,6 +73,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `coral_block=X`: Coral block (1 = alive, 2 = dead)
|
* `coral_block=X`: Coral block (1 = alive, 2 = dead)
|
||||||
* `coral_species=X`: Specifies the species of a coral; equal X means equal species
|
* `coral_species=X`: Specifies the species of a coral; equal X means equal species
|
||||||
* `set_on_fire=X`: Sets any (not fire-resistant) mob or player on fire for X seconds when touching
|
* `set_on_fire=X`: Sets any (not fire-resistant) mob or player on fire for X seconds when touching
|
||||||
|
* `compostability=X`: Item can be used on a composter block; X (1-100) is the % chance of adding a level of compost
|
||||||
|
|
||||||
#### Footnotes
|
#### Footnotes
|
||||||
|
|
||||||
|
@ -99,6 +102,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
|
||||||
* `water_bucket=1`: Bucket containing a liquid of group “water”
|
* `water_bucket=1`: Bucket containing a liquid of group “water”
|
||||||
* `enchantability=X`: How good the enchantments are the item gets (1 equals book)
|
* `enchantability=X`: How good the enchantments are the item gets (1 equals book)
|
||||||
* `enchanted=1`: The item is already enchanted, meaning that it can't be enchanted using an enchanting table
|
* `enchanted=1`: The item is already enchanted, meaning that it can't be enchanted using an enchanting table
|
||||||
|
* `cobble=1`: Cobblestone of any kind
|
||||||
|
|
||||||
### Material groups
|
### Material groups
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
An unofficial Minecraft-like game for Minetest. Forked from MineClone by davedevils.
|
An unofficial Minecraft-like game for Minetest. Forked from MineClone by davedevils.
|
||||||
Developed by many people. Not developed or endorsed by Mojang AB.
|
Developed by many people. Not developed or endorsed by Mojang AB.
|
||||||
|
|
||||||
Version: 0.72.0 (in development)
|
Version: 0.75 (in development)
|
||||||
|
|
||||||
### Gameplay
|
### Gameplay
|
||||||
You start in a randomly-generated world made entirely of cubes. You can explore
|
You start in a randomly-generated world made entirely of cubes. You can explore
|
||||||
|
@ -66,7 +66,7 @@ Use the `/giveme` chat command to obtain them. See the in-game help for
|
||||||
an explanation.
|
an explanation.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
This game requires [Minetest](http://minetest.net) to run (version 5.3.0 or
|
This game requires [Minetest](http://minetest.net) to run (version 5.4.1 or
|
||||||
later). So you need to install Minetest first. Only stable versions of Minetest
|
later). So you need to install Minetest first. Only stable versions of Minetest
|
||||||
are officially supported.
|
are officially supported.
|
||||||
There is no support for running MineClone2 in development versions of Minetest.
|
There is no support for running MineClone2 in development versions of Minetest.
|
||||||
|
|
|
@ -0,0 +1,324 @@
|
||||||
|
# MineClone 2
|
||||||
|
一個非官方的Minetest遊戲,遊玩方式和Minecraft類似。由davedevils從MineClone分拆。
|
||||||
|
由許多人開發。並非由Mojang Studios開發。<!-- "Mojang AB"'s Name changed at 2020/05, main README should change too -->
|
||||||
|
|
||||||
|
版本:0.71.0
|
||||||
|
|
||||||
|
### 遊玩
|
||||||
|
你開始在一個完全由方塊隨機生成的世界裡。你可以探索這個世界,挖掘和建造世界上幾乎所有的方塊,以創造新的結構。你可以選擇在「生存模式」中進行遊戲,在這個模式中,你必須與怪物戰鬥,飢餓求生,並在遊戲的其他各個環節中慢慢進步,如採礦、養殖、建造機器等等。
|
||||||
|
|
||||||
|
或者你也可以在「創造模式」中玩,在這個模式中,你可以瞬間建造大部分東西。
|
||||||
|
#### Gameplay summary
|
||||||
|
|
||||||
|
* 沙盒式遊戲,沒有明確目標
|
||||||
|
* 生存:與怪物和飢餓搏鬥
|
||||||
|
* 挖礦來獲得礦物和寶物
|
||||||
|
* 附魔:獲得經驗值並以附魔強化你的工具
|
||||||
|
* 使用收集的方塊來創造偉大的建築
|
||||||
|
* 收集鮮花(和其他染料來源),令世界多姿多彩
|
||||||
|
* 找些種子並開始耕種
|
||||||
|
* 尋找或合成數百個物品之一
|
||||||
|
* 建立一個鐵路系統,並從礦車中得到樂趣
|
||||||
|
* 用紅石電路建造複雜的機器
|
||||||
|
* 在創造模式下,你幾乎可以免費建造任何東西,而且沒有限制。
|
||||||
|
|
||||||
|
## 如何開始
|
||||||
|
### 開始生存
|
||||||
|
* **挖樹幹**直到其破裂並收集木材
|
||||||
|
* 將木頭**放入2×2的格子中**(你的物品欄中的「合成格子」),然後製作4塊木材。
|
||||||
|
* 將4塊木材按2×2的形狀擺放在合成格子裡,製作成合成臺。
|
||||||
|
* **右鍵單擊製作臺**以獲得3×3製作網格,製作更複雜的東西
|
||||||
|
* 使用**合成指南**(書形圖標)了解所有可能的合成方式
|
||||||
|
* **製作一個木鎬**,這樣你就可以挖石頭了。
|
||||||
|
* 不同的工具可以打破不同種類的方塊。試試吧!
|
||||||
|
* 繼續玩你想玩的。盡情享受吧!
|
||||||
|
|
||||||
|
### 耕種
|
||||||
|
* 找到種子
|
||||||
|
* 合成鋤頭
|
||||||
|
* 用鋤頭右鍵點擊泥土或類似的方塊,創建農田
|
||||||
|
* 將種子放在農田上,看著它們長出來
|
||||||
|
* Collect plant when fully grown
|
||||||
|
* If near water, farmland becomes wet and speeds up growth
|
||||||
|
|
||||||
|
### Furnace
|
||||||
|
* Craft furnace
|
||||||
|
* Furnace allows you to obtain more items
|
||||||
|
* Upper slot must contain a smeltable item (example: iron ore)
|
||||||
|
* Lower slot must contain a fuel item (example: coal)
|
||||||
|
* See tooltips in crafting guide to learn about fuels and smeltable items
|
||||||
|
|
||||||
|
### Additional help
|
||||||
|
More help about the gameplay, blocks items and much more can be found from inside
|
||||||
|
the game. You can access the help from your inventory menu.
|
||||||
|
|
||||||
|
### Special items
|
||||||
|
The following items are interesting for Creative Mode and for adventure
|
||||||
|
map builders. They can not be obtained in-game or in the creative inventory.
|
||||||
|
|
||||||
|
* Barrier: `mcl_core:barrier`
|
||||||
|
|
||||||
|
Use the `/giveme` chat command to obtain them. See the in-game help for
|
||||||
|
an explanation.
|
||||||
|
|
||||||
|
#### Incomplete items
|
||||||
|
These items do not work yet, but you can get them with `/giveme` for testing:
|
||||||
|
|
||||||
|
* Minecart with Chest: `mcl_minecarts:chest_minecart`
|
||||||
|
* Minecart with Furnace: `mcl_minecarts:furnace_minecart`
|
||||||
|
* Minecart with Hopper: `mcl_minecarts:hopper_minecart`
|
||||||
|
* Minecart with Command Block: `mcl_minecarts:command_block_minecart`
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
This game requires [Minetest](http://minetest.net) to run (version 5.0.0 or
|
||||||
|
later). So you need to install Minetest first. Only stable versions of Minetest
|
||||||
|
are officially supported.
|
||||||
|
There is no support for running MineClone 2 in development versions of Minetest.
|
||||||
|
|
||||||
|
To install MineClone 2 (if you haven't already), move this directory into the
|
||||||
|
“games” directory of your Minetest data directory. Consult the help of
|
||||||
|
Minetest to learn more.
|
||||||
|
|
||||||
|
## Project description
|
||||||
|
The main goal of **MineClone 2** is to be a clone of Minecraft and to be released as free software.
|
||||||
|
|
||||||
|
* **開發目標:我的世界, Java版, 版本 1.12**
|
||||||
|
* MineClone2還包括Minetest支持的Optifine功能。
|
||||||
|
* 後期Minecraft版本的功能可能會偷偷加入,但它們的優先級較低。
|
||||||
|
* 總的來說,Minecraft的目標是在Minetest目前允許的情況下進行克隆。
|
||||||
|
* 克隆Minecraft是最優先的。
|
||||||
|
* MineClone2將使用不同的圖形和聲音,但風格相似。
|
||||||
|
* 克隆界面沒有優先權。只會被粗略地模仿。
|
||||||
|
* 在Minetest中發現的局限性將在開發過程中被記錄和報告。
|
||||||
|
|
||||||
|
## 完成程度
|
||||||
|
該遊戲目前處於**alpha**階段。
|
||||||
|
它是可玩的,但尚未完成,預計會出現許多錯誤。
|
||||||
|
向後兼容性是**不能保證的**,更新你的世界可能會造成大大小小的bug(比如「缺少節點」的錯誤甚至崩潰)。
|
||||||
|
|
||||||
|
已經實現以下功能:
|
||||||
|
|
||||||
|
* 工具,武器
|
||||||
|
* 盔甲
|
||||||
|
* 合成和熔煉系統:2×2 合成格, 合成臺 (3×3 合成格), 熔爐, 合成教學
|
||||||
|
* 儲物箱,大型儲物箱,終界箱和界伏盒
|
||||||
|
* 熔爐, 漏斗
|
||||||
|
* 飢餓和飽食
|
||||||
|
* 大多數怪物和動物
|
||||||
|
* Minecraft 1.12中的所有礦物<!-- Minecraft 1.17 added copper, so here must mark the version is 1.12, then main README should also add this -->
|
||||||
|
* 主世界的大部分方塊
|
||||||
|
* 水和岩漿
|
||||||
|
* 天氣
|
||||||
|
* 28個生態域
|
||||||
|
* 地獄,熾熱的維度
|
||||||
|
* 紅石電路(部分)
|
||||||
|
* 礦車(部分)
|
||||||
|
* 狀態效果(部分)
|
||||||
|
* 經驗系統
|
||||||
|
* 附魔
|
||||||
|
* 釀造,藥水,藥水箭(部分)
|
||||||
|
* 船
|
||||||
|
* 火
|
||||||
|
* 建築方塊:樓梯、半磚、門、地板門、柵欄、柵欄門、牆。
|
||||||
|
* 時鐘
|
||||||
|
* 指南針
|
||||||
|
* 海綿
|
||||||
|
* 史萊姆方塊(不與紅石互動)
|
||||||
|
* 小植物和樹苗
|
||||||
|
* 染料
|
||||||
|
* 旗幟
|
||||||
|
* 裝飾方塊:玻璃、染色玻璃、玻璃片、鐵柵欄、陶土(和染色版本)、頭顱等
|
||||||
|
* 物品展示框
|
||||||
|
* 唱片機
|
||||||
|
* 床
|
||||||
|
* 物品欄
|
||||||
|
* 創造模式物品欄
|
||||||
|
* 生產
|
||||||
|
* 書和羽毛筆
|
||||||
|
* 一些服務器命令
|
||||||
|
* 還有更多!
|
||||||
|
|
||||||
|
以下是不完整的特性:
|
||||||
|
|
||||||
|
* 生成結構(特別是村莊)
|
||||||
|
* 一些怪物和動物
|
||||||
|
* 紅石系統
|
||||||
|
* 終界
|
||||||
|
* 特殊的礦車
|
||||||
|
* 一些不簡單的方塊和物品。
|
||||||
|
|
||||||
|
額外功能(在Minecraft 1.11中沒有)。
|
||||||
|
|
||||||
|
* 內置合成指南,向你展示製作和熔煉的配方
|
||||||
|
* 遊戲中的幫助系統包含了大量關於遊戲基礎知識、方塊、物品等方面的幫助。
|
||||||
|
* 臨時製作配方。它們的存在只是為了在你不在創造模式下時,提供一些其他無法獲得的物品。這些配方將隨著開發的進行和更多功能的出現而被移除。
|
||||||
|
* v6地圖生成器中箱子裡的樹苗。
|
||||||
|
* 完全可修改(得益於Minetest強大的Lua API)。
|
||||||
|
* 新的方塊和物品:
|
||||||
|
* 查找工具,顯示觸及事物的幫助
|
||||||
|
* 更多的半磚和樓梯
|
||||||
|
* 地獄磚柵欄門
|
||||||
|
* 紅地獄磚柵欄
|
||||||
|
* 紅地獄磚柵欄門
|
||||||
|
|
||||||
|
與Minecraft的技性術差異:
|
||||||
|
|
||||||
|
* 高度限制為31000格(遠高於Minecraft)
|
||||||
|
* 水平世界大小約為62000×62000格(比Minecraft中的小得多,但仍然非常大)。
|
||||||
|
* 仍然非常不完整和有問題
|
||||||
|
* 塊、物品、敵人和其他功能缺失。
|
||||||
|
* 一些項目的名稱略有不同,以便於區分。
|
||||||
|
* 唱片機的音樂不同
|
||||||
|
* 不同的材質(像素完美)
|
||||||
|
* 不同的聲音(各種來源)
|
||||||
|
* 不同的引擎(Minetest)
|
||||||
|
|
||||||
|
...最後,MineClone2是自由軟件!
|
||||||
|
|
||||||
|
## 錯誤報告
|
||||||
|
請在此處報告所有錯誤和缺少的功能:
|
||||||
|
|
||||||
|
<https://git.minetest.land/MineClone2/MineClone2/issues>
|
||||||
|
|
||||||
|
## Chating with the community
|
||||||
|
我們有Discord交流羣:
|
||||||
|
|
||||||
|
<https://discord.gg/84GKcxczG3>
|
||||||
|
|
||||||
|
|
||||||
|
## Other readme files
|
||||||
|
|
||||||
|
* `LICENSE.txt`:GPLv3許可文本
|
||||||
|
* `CONTRIBUTING.md`: 為那些想參與貢獻的人提供資訊
|
||||||
|
* `MISSING_ENGINE_FEATURES.md`: MineClone2需要改进,Minetest中缺失的功能列表。
|
||||||
|
* `API.md`: 關於MineClone2的API
|
||||||
|
|
||||||
|
## 參與者
|
||||||
|
有這麼多人要列出(抱歉)。詳情請查看各mod目錄。本節只是粗略地介紹了本遊戲的核心作者。
|
||||||
|
|
||||||
|
### 程式碼
|
||||||
|
* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082):大多數mod的主要程序員(已退休)
|
||||||
|
* davedevils:MineClone 2的原型——「MineClone」的創造者
|
||||||
|
* [ex-bart](https://github.com/ex-bart):紅石比較器
|
||||||
|
* [Rootyjr](https://github.com/Rootyjr):釣竿和錯誤修復
|
||||||
|
* [aligator](https://github.com/aligator):改進門
|
||||||
|
* [ryvnf](https://github.com/ryvnf):爆炸物理
|
||||||
|
* MysticTempest:錯誤修復
|
||||||
|
* [bzoss](https://github.com/bzoss):狀態效果,釀造,藥水
|
||||||
|
* kay27 <kay27@bk.ru>:經驗系統,錯誤修復和優化(當前維護者)
|
||||||
|
* [EliasFleckenstein03](https://github.com/EliasFleckenstein03):終界水晶,附魔,燃燒的怪物/玩家,箱子的動畫和錯誤修復(當前維護者)
|
||||||
|
* epCode:更好的玩家動畫,新徽標
|
||||||
|
* 2mac:修復動力鐵軌的錯誤
|
||||||
|
* 更多:待篇寫 (請查看各mod目錄)
|
||||||
|
|
||||||
|
#### Mod(概括)
|
||||||
|
|
||||||
|
* `controls`: Arcelmi
|
||||||
|
* `flowlib`: Qwertymine13
|
||||||
|
* `walkover`: lordfingle
|
||||||
|
* `drippingwater`: kddekadenz
|
||||||
|
* `mobs_mc`: maikerumine, 22i and others
|
||||||
|
* `awards`: rubenwardy
|
||||||
|
* `screwdriver`: RealBadAngel, Maciej Kastakin, Minetest contributors
|
||||||
|
* `xpanes`: Minetest contributors
|
||||||
|
* `mesecons` mods: Jeija and contributors
|
||||||
|
* `wieldview`: Stuart Jones
|
||||||
|
* `mcl_meshhand`: Based on `newhand` by jordan4ibanez
|
||||||
|
* `mcl_mobs`: Based on Mobs Redo [`mobs`] by TenPlus1 and contributors
|
||||||
|
* 大多其他的Mod: Wuzzy
|
||||||
|
|
||||||
|
每个mod的详细參與者可以在各个mod目录中找到。
|
||||||
|
|
||||||
|
### 圖形
|
||||||
|
* [XSSheep](http://www.minecraftforum.net/members/XSSheep):主要作者;Minecraft 1.11的Pixel Perfection资源包的制作者
|
||||||
|
* [Wuzzy](https://forum.minetest.net/memberlist.php?mode=viewprofile&u=3082):主菜單圖像和各種編輯和添加的材質包
|
||||||
|
* [kingoscargames](https://github.com/kingoscargames):現有材質的各種編輯和添加
|
||||||
|
* [leorockway](https://github.com/leorockway):怪物紋理的一些編輯
|
||||||
|
* [xMrVizzy](https://minecraft.curseforge.com/members/xMrVizzy):釉陶(材質以後會被替換)
|
||||||
|
* yutyo <tanakinci2002@gmail.com>:MineClone2標志
|
||||||
|
* 其他:GUI圖片
|
||||||
|
|
||||||
|
### 翻譯
|
||||||
|
* Wuzzy:德語
|
||||||
|
* Rocher Laurent <rocherl@club-internet.fr>:法語
|
||||||
|
* wuniversales:西班牙語
|
||||||
|
* kay27 <kay27@bk.ru>:俄語
|
||||||
|
* [Emoji](https://toyshost2.ddns.net):繁體中文<!-- Hi, after the translate finish, this name should add to the main README too! -->
|
||||||
|
|
||||||
|
### 模型
|
||||||
|
* [22i](https://github.com/22i):所有模型的作者
|
||||||
|
* [tobyplowy](https://github.com/tobyplowy):對上述模型進行UV映射修復
|
||||||
|
|
||||||
|
### 聲音和音樂
|
||||||
|
多種來源。 有關詳細信息,請參見相應的mod目錄。
|
||||||
|
|
||||||
|
### 特殊感謝
|
||||||
|
|
||||||
|
* Wuzzy,感謝他啟動和維護MineClone2多年。
|
||||||
|
* celeron55,創建Minetest。
|
||||||
|
* Minetest的社區提供了大量的mods選擇,其中一些最終被納入MineClone 2。
|
||||||
|
* Jordach,為《Big Freaking Dig》的唱片機音樂合輯而來
|
||||||
|
* 花了太多時間為Minecraft Wiki寫作的工作狂。它是創建這個遊戲的寶貴資源。
|
||||||
|
* Notch和Jeb是Minecraft背后的主要力量
|
||||||
|
* XSSheep用於創建Pixel Perfection資源包。
|
||||||
|
* [22i](https://github.com/22i) 提供出色的模型和支持
|
||||||
|
* [maikerumine](http://github.com/maikerumine) 揭開生物和生物群落的序幕
|
||||||
|
|
||||||
|
## 給程序員的信息
|
||||||
|
你可以在「API.md」中找到有趣和有用的信息。
|
||||||
|
|
||||||
|
## 法律信息
|
||||||
|
這是一款粉絲開發的遊戲,並非由Mojang AB開發或認可。
|
||||||
|
|
||||||
|
複製是一種愛的行為。請複制和分享! <3
|
||||||
|
下面是詳細的法律條文,有需要的朋友可以參考。
|
||||||
|
|
||||||
|
### License of source code
|
||||||
|
```
|
||||||
|
MineClone 2 (by kay27, EliasFleckenstein, Wuzzy, davedevils and countless others)
|
||||||
|
is an imitation of Minecraft.
|
||||||
|
|
||||||
|
MineClone 2 is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License (in the LICENSE.txt file) for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
In the mods you might find in the read-me or license
|
||||||
|
text files a different license. This counts as dual-licensing.
|
||||||
|
You can choose which license applies to you: Either the
|
||||||
|
license of MineClone 2 (GNU GPLv3) or the mod's license.
|
||||||
|
|
||||||
|
MineClone 2 is a direct continuation of the discontinued MineClone
|
||||||
|
project by davedevils.
|
||||||
|
|
||||||
|
Mod credits:
|
||||||
|
See `README.txt` or `README.md` in each mod directory for information about other authors.
|
||||||
|
For mods that do not have such a file, the license is the source code license
|
||||||
|
of MineClone 2 and the author is Wuzzy.
|
||||||
|
```
|
||||||
|
|
||||||
|
### License of media (textures and sounds)
|
||||||
|
```
|
||||||
|
No non-free licenses are used anywhere.
|
||||||
|
|
||||||
|
The textures, unless otherwise noted, are based on the Pixel Perfection resource pack for Minecraft 1.11,
|
||||||
|
authored by XSSheep. Most textures are verbatim copies, while some textures have been changed or redone
|
||||||
|
from scratch.
|
||||||
|
The glazed terracotta textures have been created by (MysticTempest)[https://github.com/MysticTempest].
|
||||||
|
Source: <https://www.planetminecraft.com/texture_pack/131pixel-perfection/>
|
||||||
|
License: [CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)
|
||||||
|
|
||||||
|
The main menu images are release under: [CC0](https://creativecommons.org/publicdomain/zero/1.0/)
|
||||||
|
|
||||||
|
All other files, unless mentioned otherwise, fall under:
|
||||||
|
Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
|
See README.txt in each mod directory for detailed information about other authors.
|
||||||
|
```
|
BIN
menu/Logo.blend
BIN
menu/Logo.blend
Binary file not shown.
BIN
menu/icon.png
BIN
menu/icon.png
Binary file not shown.
Before Width: | Height: | Size: 547 KiB After Width: | Height: | Size: 51 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
Binary file not shown.
Before Width: | Height: | Size: 419 KiB After Width: | Height: | Size: 830 KiB |
|
@ -1,29 +1,93 @@
|
||||||
|
-- Overrides the builtin minetest.check_single_for_falling.
|
||||||
|
-- We need to do this in order to handle nodes in mineclone specific groups
|
||||||
|
-- "supported_node" and "attached_node_facedir".
|
||||||
|
--
|
||||||
|
-- Nodes in group "supported_node" can be placed on any node that does not
|
||||||
|
-- have the "airlike" drawtype. Carpets are an example of this type.
|
||||||
|
|
||||||
local vector = vector
|
local vector = vector
|
||||||
|
|
||||||
local facedir_to_dir = minetest.facedir_to_dir
|
local facedir_to_dir = minetest.facedir_to_dir
|
||||||
local get_item_group = minetest.get_item_group
|
local get_item_group = minetest.get_item_group
|
||||||
local remove_node = minetest.remove_node
|
local remove_node = minetest.remove_node
|
||||||
local get_node = minetest.get_node
|
local get_node = minetest.get_node
|
||||||
|
local get_meta = minetest.get_meta
|
||||||
|
local registered_nodes = minetest.registered_nodes
|
||||||
|
local get_node_drops = minetest.get_node_drops
|
||||||
|
local add_item = minetest.add_item
|
||||||
|
|
||||||
|
-- drop_attached_node(p)
|
||||||
|
--
|
||||||
|
-- This function is copied verbatim from minetest/builtin/game/falling.lua
|
||||||
|
-- We need this to do the exact same dropping node handling in our override
|
||||||
|
-- minetest.check_single_for_falling() function as in the builtin function.
|
||||||
|
--
|
||||||
|
local function drop_attached_node(p)
|
||||||
|
local n = get_node(p)
|
||||||
|
local drops = get_node_drops(n, "")
|
||||||
|
local def = registered_nodes[n.name]
|
||||||
|
if def and def.preserve_metadata then
|
||||||
|
local oldmeta = get_meta(p):to_table().fields
|
||||||
|
-- Copy pos and node because the callback can modify them.
|
||||||
|
local pos_copy = vector.new(p)
|
||||||
|
local node_copy = {name=n.name, param1=n.param1, param2=n.param2}
|
||||||
|
local drop_stacks = {}
|
||||||
|
for k, v in pairs(drops) do
|
||||||
|
drop_stacks[k] = ItemStack(v)
|
||||||
|
end
|
||||||
|
drops = drop_stacks
|
||||||
|
def.preserve_metadata(pos_copy, node_copy, oldmeta, drops)
|
||||||
|
end
|
||||||
|
if def and def.sounds and def.sounds.fall then
|
||||||
|
core.sound_play(def.sounds.fall, {pos = p}, true)
|
||||||
|
end
|
||||||
|
remove_node(p)
|
||||||
|
for _, item in pairs(drops) do
|
||||||
|
local pos = {
|
||||||
|
x = p.x + math.random()/2 - 0.25,
|
||||||
|
y = p.y + math.random()/2 - 0.25,
|
||||||
|
z = p.z + math.random()/2 - 0.25,
|
||||||
|
}
|
||||||
|
add_item(pos, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- minetest.check_single_for_falling(pos)
|
||||||
|
--
|
||||||
|
-- * causes an unsupported `group:falling_node` node to fall and causes an
|
||||||
|
-- unattached `group:attached_node` or `group:attached_node_facedir` node
|
||||||
|
-- or unsupported `group:supported_node` node to drop.
|
||||||
|
-- * does not spread these updates to neighbours.
|
||||||
|
--
|
||||||
|
-- Returns true if the node at <pos> has spawned a falling node or has been
|
||||||
|
-- dropped as item(s).
|
||||||
|
--
|
||||||
local original_function = minetest.check_single_for_falling
|
local original_function = minetest.check_single_for_falling
|
||||||
|
|
||||||
function minetest.check_single_for_falling(pos)
|
function minetest.check_single_for_falling(pos)
|
||||||
local ret_o = original_function(pos)
|
if original_function(pos) then
|
||||||
local ret = false
|
return true
|
||||||
local node = minetest.get_node(pos)
|
end
|
||||||
|
|
||||||
|
local node = get_node(pos)
|
||||||
if get_item_group(node.name, "attached_node_facedir") ~= 0 then
|
if get_item_group(node.name, "attached_node_facedir") ~= 0 then
|
||||||
local dir = facedir_to_dir(node.param2)
|
local dir = facedir_to_dir(node.param2)
|
||||||
if dir then
|
if dir then
|
||||||
if get_item_group(get_node(vector.add(pos, dir)).name, "solid") == 0 then
|
if get_item_group(get_node(vector.add(pos, dir)).name, "solid") == 0 then
|
||||||
remove_node(pos)
|
drop_attached_node(pos)
|
||||||
local drops = minetest.get_node_drops(node.name, "")
|
return true
|
||||||
for dr=1, #drops do
|
|
||||||
minetest.add_item(pos, drops[dr])
|
|
||||||
end
|
|
||||||
ret = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ret_o or ret
|
|
||||||
|
if get_item_group(node.name, "supported_node") ~= 0 then
|
||||||
|
local def = registered_nodes[get_node(vector.offset(pos, 0, -1, 0)).name]
|
||||||
|
if def and def.drawtype == "airlike" then
|
||||||
|
drop_attached_node(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
# mcl_damage
|
||||||
|
|
||||||
|
This mod is intended to overall minetest's native damage system, to provide a better integration between features that deals with entities' health.
|
||||||
|
|
||||||
|
WARNING: Not using it inside your mods may cause strange bugs (using the native damage system may cause conflicts with this system).
|
||||||
|
|
||||||
|
## Callbacks
|
||||||
|
|
||||||
|
To modify the amount of damage made by something:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
--obj: an ObjectRef
|
||||||
|
mcl_damage.register_modifier(function(obj, damage, reason)
|
||||||
|
end, 0)
|
||||||
|
```
|
|
@ -0,0 +1,2 @@
|
||||||
|
# textdomain:mcl_explosions
|
||||||
|
@1 was caught in an explosion.=@1 被炸飛了
|
|
@ -357,6 +357,32 @@ function mcl_util.get_first_occupied_inventory_slot(inventory, listname)
|
||||||
return mcl_util.get_eligible_transfer_item_slot(inventory, listname)
|
return mcl_util.get_eligible_transfer_item_slot(inventory, listname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function drop_item_stack(pos, stack)
|
||||||
|
if not stack or stack:is_empty() then return end
|
||||||
|
local drop_offset = vector.new(math.random() - 0.5, 0, math.random() - 0.5)
|
||||||
|
minetest.add_item(vector.add(pos, drop_offset), stack)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mcl_util.drop_items_from_meta_container(listname)
|
||||||
|
return function(pos, oldnode, oldmetadata)
|
||||||
|
if oldmetadata and oldmetadata.inventory then
|
||||||
|
-- process in after_dig_node callback
|
||||||
|
local main = oldmetadata.inventory.main
|
||||||
|
if not main then return end
|
||||||
|
for _, stack in pairs(main) do
|
||||||
|
drop_item_stack(pos, stack)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1, inv:get_size("main") do
|
||||||
|
drop_item_stack(pos, inv:get_stack("main", i))
|
||||||
|
end
|
||||||
|
meta:from_table()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns true if item (itemstring or ItemStack) can be used as a furnace fuel.
|
-- Returns true if item (itemstring or ItemStack) can be used as a furnace fuel.
|
||||||
-- Returns false otherwise
|
-- Returns false otherwise
|
||||||
function mcl_util.is_fuel(item)
|
function mcl_util.is_fuel(item)
|
||||||
|
@ -571,3 +597,16 @@ function mcl_util.replace_mob(obj, mob)
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_util.get_pointed_thing(player, liquid)
|
||||||
|
local pos = vector.offset(player:get_pos(), 0, player:get_properties().eye_height, 0)
|
||||||
|
local look_dir = vector.multiply(player:get_look_dir(), 5)
|
||||||
|
local pos2 = vector.add(pos, look_dir)
|
||||||
|
local ray = minetest.raycast(pos, pos2, false, liquid)
|
||||||
|
|
||||||
|
if ray then
|
||||||
|
for pointed_thing in ray do
|
||||||
|
return pointed_thing
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -153,3 +153,22 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
function mcl_worlds.get_cloud_parameters()
|
||||||
|
if minetest.get_mapgen_setting("mg_name") == "valleys" then
|
||||||
|
return {
|
||||||
|
height = 384, --valleys has a much higher average elevation thus often "normal" landscape ends up in the clouds
|
||||||
|
speed = {x=-2, z=0},
|
||||||
|
thickness=5,
|
||||||
|
color="#FFF0FEF",
|
||||||
|
ambient = "#201060",
|
||||||
|
}
|
||||||
|
else
|
||||||
|
-- MC-style clouds: Layer 127, thickness 4, fly to the “West”
|
||||||
|
return {
|
||||||
|
height = mcl_worlds.layer_to_y(127),
|
||||||
|
speed = {x=-2, z=0},
|
||||||
|
thickness = 4,
|
||||||
|
color = "#FFF0FEF",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -84,7 +84,7 @@ function image:encode()
|
||||||
end
|
end
|
||||||
|
|
||||||
function image:save(filename)
|
function image:save(filename)
|
||||||
local f = assert(io.open(filename, "w"))
|
local f = assert(io.open(filename, "wb"))
|
||||||
f:write(self.data)
|
f:write(self.data)
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
|
@ -267,7 +267,7 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local yaw = self.object:get_yaw()
|
local yaw = self.object:get_yaw()
|
||||||
if ctrl.up then
|
if ctrl and ctrl.up then
|
||||||
-- Forwards
|
-- Forwards
|
||||||
self._v = self._v + 0.1 * v_factor
|
self._v = self._v + 0.1 * v_factor
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ function boat.on_step(self, dtime, moveresult)
|
||||||
self.object:set_animation({x=0, y=40}, paddling_speed, 0, true)
|
self.object:set_animation({x=0, y=40}, paddling_speed, 0, true)
|
||||||
self._animation = 1
|
self._animation = 1
|
||||||
end
|
end
|
||||||
elseif ctrl.down then
|
elseif ctrl and ctrl.down then
|
||||||
-- Backwards
|
-- Backwards
|
||||||
self._v = self._v - 0.1 * v_factor
|
self._v = self._v - 0.1 * v_factor
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# textdomain: mcl_boats
|
||||||
|
Acacia Boat=相思木船
|
||||||
|
Birch Boat=白樺木船
|
||||||
|
Boat=船
|
||||||
|
Boats are used to travel on the surface of water.=船是用來在水上行走的交通工具。
|
||||||
|
Dark Oak Boat=黑橡木船
|
||||||
|
Jungle Boat=叢林木船
|
||||||
|
Oak Boat=橡木船
|
||||||
|
Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Rightclick the boat again to leave it, punch the boat to make it drop as an item.=右鍵單擊水源以放置船。右鍵單擊船以搭乘它。使用[左]和[右]進行轉向,[向前]加快速度,[向後]減速或向後移動。再次右鍵單擊船以離開它,打擊船以使其掉落為物品。
|
||||||
|
Spruce Boat=杉木船
|
||||||
|
Water vehicle=水上交通工具
|
|
@ -26,20 +26,64 @@ function mcl_burning.get_collisionbox(obj, smaller, storage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local find_nodes_in_area = minetest.find_nodes_in_area
|
||||||
|
|
||||||
function mcl_burning.get_touching_nodes(obj, nodenames, storage)
|
function mcl_burning.get_touching_nodes(obj, nodenames, storage)
|
||||||
local pos = obj:get_pos()
|
local pos = obj:get_pos()
|
||||||
local minp, maxp = mcl_burning.get_collisionbox(obj, true, storage)
|
local minp, maxp = mcl_burning.get_collisionbox(obj, true, storage)
|
||||||
local nodes = minetest.find_nodes_in_area(vector.add(pos, minp), vector.add(pos, maxp), nodenames)
|
local nodes = find_nodes_in_area(vector.add(pos, minp), vector.add(pos, maxp), nodenames)
|
||||||
return nodes
|
return nodes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Manages the fire animation on a burning player's HUD
|
||||||
|
--
|
||||||
|
-- Parameters:
|
||||||
|
-- player - a valid player object;
|
||||||
|
--
|
||||||
|
-- If the player already has a fire HUD, updates the burning animation.
|
||||||
|
-- If the fire does not have a fire HUD, initializes the HUD.
|
||||||
|
--
|
||||||
|
function mcl_burning.update_hud(player)
|
||||||
|
local animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
|
||||||
|
local hud_flame_animated = "mcl_burning_hud_flame_animated.png^[opacity:180^[verticalframe:" .. animation_frames .. ":"
|
||||||
|
|
||||||
|
local storage = mcl_burning.get_storage(player)
|
||||||
|
if not storage.fire_hud_id then
|
||||||
|
storage.animation_frame = 1
|
||||||
|
storage.fire_hud_id = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0.5, y = 0.5},
|
||||||
|
scale = {x = -100, y = -100},
|
||||||
|
text = hud_flame_animated .. storage.animation_frame,
|
||||||
|
z_index = 1000,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
storage.animation_frame = storage.animation_frame + 1
|
||||||
|
if storage.animation_frame > animation_frames - 1 then
|
||||||
|
storage.animation_frame = 0
|
||||||
|
end
|
||||||
|
player:hud_change(storage.fire_hud_id, "text", hud_flame_animated .. storage.animation_frame)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sets and object state as burning and adds a fire animation to the object.
|
||||||
|
--
|
||||||
|
-- Parameters:
|
||||||
|
-- obj - may be a player or a lua_entity;
|
||||||
|
-- burn_time - sets the object's burn duration;
|
||||||
|
--
|
||||||
|
-- If obj is a player, adds a fire animation to the HUD, if obj is a
|
||||||
|
-- lua_entity, adds an animated fire entity to obj.
|
||||||
|
-- The effective burn duration is modified by obj's armor protection.
|
||||||
|
-- If obj was already burning, its burn duration is updated if the current
|
||||||
|
-- duration is less than burn_time.
|
||||||
|
-- If obj is dead, fireproof or a creative player, this function does nothing.
|
||||||
|
--
|
||||||
function mcl_burning.set_on_fire(obj, burn_time)
|
function mcl_burning.set_on_fire(obj, burn_time)
|
||||||
if obj:get_hp() < 0 then
|
if obj:get_hp() < 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local storage = mcl_burning.get_storage(obj)
|
|
||||||
|
|
||||||
local luaentity = obj:get_luaentity()
|
local luaentity = obj:get_luaentity()
|
||||||
if luaentity and luaentity.fire_resistant then
|
if luaentity and luaentity.fire_resistant then
|
||||||
return
|
return
|
||||||
|
@ -60,44 +104,32 @@ function mcl_burning.set_on_fire(obj, burn_time)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if max_fire_prot_lvl > 0 then
|
if max_fire_prot_lvl > 0 then
|
||||||
burn_time = burn_time - math.floor(burn_time * max_fire_prot_lvl * 0.15)
|
burn_time = burn_time - math.floor(burn_time * max_fire_prot_lvl * 0.15)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not storage.burn_time or burn_time >= storage.burn_time then
|
local storage = mcl_burning.get_storage(obj)
|
||||||
if obj:is_player() then
|
if storage.burn_time then
|
||||||
mcl_burning.channels[obj]:send_all(tostring(mcl_burning.animation_frames))
|
if burn_time > storage.burn_time then
|
||||||
mcl_burning.channels[obj]:send_all("start")
|
storage.burn_time = burn_time
|
||||||
end
|
end
|
||||||
storage.burn_time = burn_time
|
return
|
||||||
storage.fire_damage_timer = 0
|
end
|
||||||
|
storage.burn_time = burn_time
|
||||||
|
storage.fire_damage_timer = 0
|
||||||
|
|
||||||
local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire")
|
local minp, maxp = mcl_burning.get_collisionbox(obj, false, storage)
|
||||||
local minp, maxp = mcl_burning.get_collisionbox(obj, false, storage)
|
local size = vector.subtract(maxp, minp)
|
||||||
local obj_size = obj:get_properties().visual_size
|
size = vector.multiply(size, vector.new(1.1, 1.2, 1.1))
|
||||||
|
size = vector.divide(size, obj:get_properties().visual_size)
|
||||||
|
|
||||||
local vertical_grow_factor = 1.2
|
local fire_entity = minetest.add_entity(obj:get_pos(), "mcl_burning:fire")
|
||||||
local horizontal_grow_factor = 1.1
|
fire_entity:set_properties({visual_size = size})
|
||||||
local grow_vector = vector.new(horizontal_grow_factor, vertical_grow_factor, horizontal_grow_factor)
|
fire_entity:set_attach(obj, "", vector.new(0, size.y * 5, 0), vector.new(0, 0, 0))
|
||||||
|
|
||||||
local size = vector.subtract(maxp, minp)
|
if obj:is_player() then
|
||||||
size = vector.multiply(size, grow_vector)
|
mcl_burning.update_hud(obj)
|
||||||
size = vector.divide(size, obj_size)
|
|
||||||
local offset = vector.new(0, size.y * 10 / 2, 0)
|
|
||||||
|
|
||||||
fire_entity:set_properties({visual_size = size})
|
|
||||||
fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0})
|
|
||||||
local fire_luaentity = fire_entity:get_luaentity()
|
|
||||||
|
|
||||||
for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do
|
|
||||||
local other_luaentity = other:get_luaentity()
|
|
||||||
if other_luaentity and other_luaentity.name == "mcl_burning:fire" and other_luaentity ~= fire_luaentity then
|
|
||||||
other:remove()
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,7 +137,9 @@ function mcl_burning.extinguish(obj)
|
||||||
if mcl_burning.is_burning(obj) then
|
if mcl_burning.is_burning(obj) then
|
||||||
local storage = mcl_burning.get_storage(obj)
|
local storage = mcl_burning.get_storage(obj)
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
mcl_burning.channels[obj]:send_all("stop")
|
if storage.fire_hud_id then
|
||||||
|
obj:hud_remove(storage.fire_hud_id)
|
||||||
|
end
|
||||||
mcl_burning.storage[obj] = {}
|
mcl_burning.storage[obj] = {}
|
||||||
else
|
else
|
||||||
storage.burn_time = nil
|
storage.burn_time = nil
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
local pairs = pairs
|
|
||||||
|
|
||||||
local get_connected_players = minetest.get_connected_players
|
|
||||||
local get_item_group = minetest.get_item_group
|
|
||||||
|
|
||||||
mcl_burning = {
|
mcl_burning = {
|
||||||
storage = {},
|
-- the storage table holds a list of objects (players,luaentities) and tables
|
||||||
channels = {},
|
-- associated with these objects. These tables have the following attributes:
|
||||||
animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
|
-- burn_time:
|
||||||
|
-- Remaining time that object will burn.
|
||||||
|
-- fire_damage_timer:
|
||||||
|
-- Timer for dealing damage every second while burning.
|
||||||
|
-- fire_hud_id:
|
||||||
|
-- HUD id of the flames animation on a burning player's HUD.
|
||||||
|
-- animation_frame:
|
||||||
|
-- The HUD's current animation frame, used by update_hud().
|
||||||
|
-- collisionbox_cache:
|
||||||
|
-- Used by mcl_burning.get_collisionbox() to avoid recalculations.
|
||||||
|
storage = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
dofile(modpath .. "/api.lua")
|
dofile(modpath .. "/api.lua")
|
||||||
|
|
||||||
|
local pairs = pairs
|
||||||
|
local get_connected_players = minetest.get_connected_players
|
||||||
|
local get_item_group = minetest.get_item_group
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in pairs(get_connected_players()) do
|
for _, player in pairs(get_connected_players()) do
|
||||||
local storage = mcl_burning.storage[player]
|
local storage = mcl_burning.storage[player]
|
||||||
|
@ -44,25 +53,43 @@ minetest.register_on_respawnplayer(function(player)
|
||||||
mcl_burning.extinguish(player)
|
mcl_burning.extinguish(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mcl_burning.init_player(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local meta = player:get_meta()
|
local storage = {}
|
||||||
-- NOTE: mcl_burning:data may be "return nil" (which deserialize into nil) for reasons unknown.
|
local burn_data = player:get_meta():get_string("mcl_burning:data")
|
||||||
if meta:get_string("mcl_burning:data"):find("return nil", 1, true) then
|
if burn_data ~= "" then
|
||||||
minetest.log("warning", "[mcl_burning] 'mcl_burning:data' player meta field is invalid! Please report this bug")
|
storage = minetest.deserialize(burn_data) or storage
|
||||||
end
|
end
|
||||||
mcl_burning.storage[player] = meta:contains("mcl_burning:data") and minetest.deserialize(meta:get_string("mcl_burning:data")) or {}
|
mcl_burning.storage[player] = storage
|
||||||
mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name())
|
if storage.burn_time and storage.burn_time > 0 then
|
||||||
|
mcl_burning.update_hud(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function on_leaveplayer(player)
|
||||||
|
local storage = mcl_burning.storage[player]
|
||||||
|
if not storage then
|
||||||
|
-- For some unexplained reasons, mcl_burning.storage can be `nil` here.
|
||||||
|
-- Logging this exception to assist in finding the cause of this.
|
||||||
|
minetest.log("warning", "on_leaveplayer: missing mcl_burning.storage "
|
||||||
|
.. "for player " .. player:get_player_name())
|
||||||
|
storage = {}
|
||||||
|
end
|
||||||
|
storage.fire_hud_id = nil
|
||||||
|
player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage))
|
||||||
|
mcl_burning.storage[player] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
mcl_burning.init_player(player)
|
|
||||||
end)
|
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
player:get_meta():set_string("mcl_burning:data", minetest.serialize(mcl_burning.storage[player]))
|
on_leaveplayer(player)
|
||||||
mcl_burning.storage[player] = nil
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
|
on_leaveplayer(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8
|
||||||
|
|
||||||
minetest.register_entity("mcl_burning:fire", {
|
minetest.register_entity("mcl_burning:fire", {
|
||||||
initial_properties = {
|
initial_properties = {
|
||||||
|
@ -70,42 +97,35 @@ minetest.register_entity("mcl_burning:fire", {
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
visual = "upright_sprite",
|
visual = "upright_sprite",
|
||||||
textures = {
|
textures = {
|
||||||
name = "mcl_burning_entity_flame_animated.png",
|
"mcl_burning_entity_flame_animated.png",
|
||||||
animation = {
|
"mcl_burning_entity_flame_animated.png"
|
||||||
type = "vertical_frames",
|
|
||||||
aspect_w = 16,
|
|
||||||
aspect_h = 16,
|
|
||||||
length = 1.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
spritediv = {x = 1, y = mcl_burning.animation_frames},
|
spritediv = {x = 1, y = animation_frames},
|
||||||
pointable = false,
|
pointable = false,
|
||||||
glow = -1,
|
glow = -1,
|
||||||
backface_culling = false,
|
backface_culling = false,
|
||||||
},
|
},
|
||||||
animation_frame = 0,
|
_mcl_animation_timer = 0,
|
||||||
animation_timer = 0,
|
|
||||||
on_activate = function(self)
|
on_activate = function(self)
|
||||||
self.object:set_sprite({x = 0, y = 0}, mcl_burning.animation_frames, 1.0 / mcl_burning.animation_frames)
|
self.object:set_sprite({x = 0, y = 0}, animation_frames, 1.0 / animation_frames)
|
||||||
end,
|
end,
|
||||||
on_step = function(self)
|
on_step = function(self, dtime)
|
||||||
if not self:sanity_check() then
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
sanity_check = function(self)
|
|
||||||
local parent = self.object:get_attach()
|
local parent = self.object:get_attach()
|
||||||
|
|
||||||
if not parent then
|
if not parent then
|
||||||
return false
|
self.object:remove()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local storage = mcl_burning.get_storage(parent)
|
local storage = mcl_burning.get_storage(parent)
|
||||||
|
|
||||||
if not storage or not storage.burn_time then
|
if not storage or not storage.burn_time then
|
||||||
return false
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if parent:is_player() then
|
||||||
|
self._mcl_animation_timer = self._mcl_animation_timer + dtime
|
||||||
|
if self._mcl_animation_timer >= 0.1 then
|
||||||
|
self._mcl_animation_timer = 0
|
||||||
|
mcl_burning.update_hud(parent)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
# textdomain: mcl_falling_nodes
|
||||||
|
@1 was smashed by a falling anvil.=@1 被鐵砧壓扁了。
|
||||||
|
@1 was smashed by a falling block.=@1 被掉下來的方塊壓扁了。
|
|
@ -110,7 +110,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if tick == true and pool[name] > 0 then
|
if tick == true and pool[name] > 0 then
|
||||||
minetest.sound_play("item_drop_pickup", {
|
minetest.sound_play("item_drop_pickup", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 0.7,
|
gain = 0.3,
|
||||||
max_hear_distance = 16,
|
max_hear_distance = 16,
|
||||||
pitch = math.random(70,110)/100
|
pitch = math.random(70,110)/100
|
||||||
})
|
})
|
||||||
|
@ -256,6 +256,8 @@ function minetest.handle_node_drops(pos, drops, digger)
|
||||||
|
|
||||||
local silk_touch_drop = false
|
local silk_touch_drop = false
|
||||||
local nodedef = minetest.registered_nodes[dug_node.name]
|
local nodedef = minetest.registered_nodes[dug_node.name]
|
||||||
|
if not nodedef then return end
|
||||||
|
|
||||||
if shearsy_level and shearsy_level > 0 and nodedef._mcl_shears_drop then
|
if shearsy_level and shearsy_level > 0 and nodedef._mcl_shears_drop then
|
||||||
if nodedef._mcl_shears_drop == true then
|
if nodedef._mcl_shears_drop == true then
|
||||||
drops = { dug_node.name }
|
drops = { dug_node.name }
|
||||||
|
@ -416,7 +418,11 @@ minetest.register_entity(":__builtin:item", {
|
||||||
end
|
end
|
||||||
local stack = ItemStack(itemstring)
|
local stack = ItemStack(itemstring)
|
||||||
if minetest.get_item_group(stack:get_name(), "compass") > 0 then
|
if minetest.get_item_group(stack:get_name(), "compass") > 0 then
|
||||||
stack:set_name("mcl_compass:16")
|
if string.find(stack:get_name(), "_lodestone") then
|
||||||
|
stack:set_name("mcl_compass:18_lodestone")
|
||||||
|
else
|
||||||
|
stack:set_name("mcl_compass:18")
|
||||||
|
end
|
||||||
itemstring = stack:to_string()
|
itemstring = stack:to_string()
|
||||||
self.itemstring = itemstring
|
self.itemstring = itemstring
|
||||||
end
|
end
|
||||||
|
|
|
@ -432,7 +432,8 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o
|
||||||
-- Slow down or speed up
|
-- Slow down or speed up
|
||||||
local acc = dir.y * -1.8
|
local acc = dir.y * -1.8
|
||||||
local friction = 0.4
|
local friction = 0.4
|
||||||
local speed_mod = minetest.registered_nodes[minetest.get_node(pos).name]._rail_acceleration
|
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
local speed_mod = ndef and ndef._rail_acceleration
|
||||||
|
|
||||||
acc = acc - friction
|
acc = acc - friction
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -502,6 +502,20 @@ and damages any entity caught inside the blast radius. Protection will limit
|
||||||
node destruction but not entity damage.
|
node destruction but not entity damage.
|
||||||
|
|
||||||
|
|
||||||
|
mobs:capture_mob
|
||||||
|
----------------
|
||||||
|
|
||||||
|
mobs:capture_mob(...)
|
||||||
|
|
||||||
|
Does nothing and returns false.
|
||||||
|
|
||||||
|
This function is provided for compability with Mobs Redo for an attempt to
|
||||||
|
capture a mob.
|
||||||
|
Mobs cannot be captured in MineClone 2.
|
||||||
|
|
||||||
|
In Mobs Redo, this is generally called inside the on_rightclick section of the mob
|
||||||
|
api code, it provides a chance of capturing the mob. See Mobs Redo documentation
|
||||||
|
of parameters.
|
||||||
|
|
||||||
Feeding and Taming/Breeding
|
Feeding and Taming/Breeding
|
||||||
---------------------------
|
---------------------------
|
||||||
|
@ -521,6 +535,19 @@ Will return true when mob is fed with item it likes.
|
||||||
them up
|
them up
|
||||||
|
|
||||||
|
|
||||||
|
Protecting Mobs
|
||||||
|
---------------
|
||||||
|
|
||||||
|
mobs:protect(self, clicker)
|
||||||
|
|
||||||
|
This function can be used to right-click any tamed mob with mobs:protector item,
|
||||||
|
this will protect the mob from harm inside of a protected area from other
|
||||||
|
players. Will return true when mob right-clicked with mobs:protector item.
|
||||||
|
|
||||||
|
'self' mob information
|
||||||
|
'clicker' player information
|
||||||
|
|
||||||
|
|
||||||
Riding Mobs
|
Riding Mobs
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -578,7 +605,7 @@ Note: animation names above are from the pre-defined animation lists inside mob
|
||||||
registry without extensions.
|
registry without extensions.
|
||||||
|
|
||||||
|
|
||||||
mobs.set_mob_animation(self, name)
|
mobs:set_animation(self, name)
|
||||||
|
|
||||||
This function sets the current animation for mob, defaulting to "stand" if not
|
This function sets the current animation for mob, defaulting to "stand" if not
|
||||||
found.
|
found.
|
||||||
|
@ -754,5 +781,8 @@ mobs:register_mob("mob_horse:horse", {
|
||||||
inv:remove_item("main", "mobs:saddle")
|
inv:remove_item("main", "mobs:saddle")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- used to capture horse with magic lasso
|
||||||
|
mobs:capture_mob(self, clicker, 0, 0, 80, false, nil)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,736 +0,0 @@
|
||||||
-- API for Mobs Redo: MineClone 2 Delux 2.0 DRM Free Early Access Super Extreme Edition
|
|
||||||
|
|
||||||
-- mobs library
|
|
||||||
mobs = {}
|
|
||||||
|
|
||||||
-- lua locals - can grab from this to easily plop them into the api lua files
|
|
||||||
|
|
||||||
--localize minetest functions
|
|
||||||
local minetest_settings = minetest.settings
|
|
||||||
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
|
||||||
local minetest_get_modpath = minetest.get_modpath
|
|
||||||
local minetest_registered_nodes = minetest.registered_nodes
|
|
||||||
local minetest_get_node = minetest.get_node
|
|
||||||
--local minetest_get_item_group = minetest.get_item_group
|
|
||||||
local minetest_registered_entities = minetest.registered_entities
|
|
||||||
--local minetest_line_of_sight = minetest.line_of_sight
|
|
||||||
--local minetest_after = minetest.after
|
|
||||||
--local minetest_sound_play = minetest.sound_play
|
|
||||||
--local minetest_add_particlespawner = minetest.add_particlespawner
|
|
||||||
--local minetest_registered_items = minetest.registered_items
|
|
||||||
--local minetest_set_node = minetest.set_node
|
|
||||||
local minetest_add_item = minetest.add_item
|
|
||||||
--local minetest_get_craft_result = minetest.get_craft_result
|
|
||||||
--local minetest_find_path = minetest.find_path
|
|
||||||
local minetest_is_creative_enabled = minetest.is_creative_enabled
|
|
||||||
--local minetest_find_node_near = minetest.find_node_near
|
|
||||||
--local minetest_find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
|
||||||
--local minetest_raycast = minetest.raycast
|
|
||||||
--local minetest_get_us_time = minetest.get_us_time
|
|
||||||
local minetest_add_entity = minetest.add_entity
|
|
||||||
--local minetest_get_natural_light = minetest.get_natural_light
|
|
||||||
--local minetest_get_node_or_nil = minetest.get_node_or_nil
|
|
||||||
|
|
||||||
-- localize math functions
|
|
||||||
local math = math
|
|
||||||
|
|
||||||
-- localize vector functions
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
local string = string
|
|
||||||
|
|
||||||
-- mob constants
|
|
||||||
--local BREED_TIME = 30
|
|
||||||
--local BREED_TIME_AGAIN = 300
|
|
||||||
--local CHILD_GROW_TIME = 60*20
|
|
||||||
--local DEATH_DELAY = 0.5
|
|
||||||
local DEFAULT_FALL_SPEED = -10
|
|
||||||
--local FLOP_HEIGHT = 5.0
|
|
||||||
--local FLOP_HOR_SPEED = 1.5
|
|
||||||
local GRAVITY = minetest_settings:get("movement_gravity")-- + 9.81
|
|
||||||
|
|
||||||
local MAX_MOB_NAME_LENGTH = 30
|
|
||||||
|
|
||||||
|
|
||||||
--[[local MOB_CAP = {}
|
|
||||||
MOB_CAP.hostile = 70
|
|
||||||
MOB_CAP.passive = 10
|
|
||||||
MOB_CAP.ambient = 15
|
|
||||||
MOB_CAP.water = 15
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- Load main settings
|
|
||||||
--local damage_enabled = minetest_settings:get_bool("enable_damage")
|
|
||||||
--local disable_blood = minetest_settings:get_bool("mobs_disable_blood")
|
|
||||||
--local mobs_drop_items = minetest_settings:get_bool("mobs_drop_items") ~= false
|
|
||||||
--local mobs_griefing = minetest_settings:get_bool("mobs_griefing") ~= false
|
|
||||||
--local spawn_protected = minetest_settings:get_bool("mobs_spawn_protected") ~= false
|
|
||||||
--local remove_far = true
|
|
||||||
local difficulty = tonumber(minetest_settings:get("mob_difficulty")) or 1.0
|
|
||||||
--local show_health = false
|
|
||||||
--local max_per_block = tonumber(minetest_settings:get("max_objects_per_block") or 64)
|
|
||||||
---local mobs_spawn_chance = tonumber(minetest_settings:get("mobs_spawn_chance") or 2.5)
|
|
||||||
|
|
||||||
-- pathfinding settings
|
|
||||||
--local enable_pathfinding = true
|
|
||||||
--local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
|
|
||||||
--local stuck_path_timeout = 10 -- how long will mob follow path before giving up
|
|
||||||
|
|
||||||
-- default nodes
|
|
||||||
--local node_ice = "mcl_core:ice"
|
|
||||||
--local node_snowblock = "mcl_core:snowblock"
|
|
||||||
--local node_snow = "mcl_core:snow"
|
|
||||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
|
||||||
|
|
||||||
--local mod_weather = minetest_get_modpath("mcl_weather")
|
|
||||||
--local mod_explosions = minetest_get_modpath("mcl_explosions")
|
|
||||||
local mod_mobspawners = minetest_get_modpath("mcl_mobspawners")
|
|
||||||
--local mod_hunger = minetest_get_modpath("mcl_hunger")
|
|
||||||
--local mod_worlds = minetest_get_modpath("mcl_worlds")
|
|
||||||
--local mod_armor = minetest_get_modpath("mcl_armor")
|
|
||||||
--local mod_experience = minetest_get_modpath("mcl_experience")
|
|
||||||
|
|
||||||
|
|
||||||
-- random locals I found
|
|
||||||
--local los_switcher = false
|
|
||||||
--local height_switcher = false
|
|
||||||
|
|
||||||
-- Get translator
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
|
||||||
|
|
||||||
-- CMI support check
|
|
||||||
--local use_cmi = minetest.global_exists("cmi")
|
|
||||||
|
|
||||||
-- creative check
|
|
||||||
function mobs.is_creative(name)
|
|
||||||
return minetest_is_creative_enabled(name)
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[local function atan(x)
|
|
||||||
if not x or x ~= x then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return math.atan(x)
|
|
||||||
end
|
|
||||||
end]]
|
|
||||||
|
|
||||||
-- Shows helpful debug info above each mob
|
|
||||||
--local mobs_debug = minetest_settings:get_bool("mobs_debug", false)
|
|
||||||
|
|
||||||
-- Peaceful mode message so players will know there are no monsters
|
|
||||||
if minetest_settings:get_bool("only_peaceful_mobs", false) then
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
|
||||||
minetest.chat_send_player(player:get_player_name(),
|
|
||||||
S("Peaceful mode active! No monsters will spawn."))
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local api_path = minetest.get_modpath(minetest.get_current_modname()).."/api/mob_functions/"
|
|
||||||
|
|
||||||
--ignite all parts of the api
|
|
||||||
dofile(api_path .. "flow_lib.lua")
|
|
||||||
dofile(api_path .. "ai.lua")
|
|
||||||
dofile(api_path .. "animation.lua")
|
|
||||||
dofile(api_path .. "collision.lua")
|
|
||||||
dofile(api_path .. "environment.lua")
|
|
||||||
dofile(api_path .. "interaction.lua")
|
|
||||||
dofile(api_path .. "movement.lua")
|
|
||||||
dofile(api_path .. "set_up.lua")
|
|
||||||
dofile(api_path .. "attack_type_instructions.lua")
|
|
||||||
dofile(api_path .. "sound_handling.lua")
|
|
||||||
dofile(api_path .. "death_logic.lua")
|
|
||||||
dofile(api_path .. "mob_effects.lua")
|
|
||||||
dofile(api_path .. "projectile_handling.lua")
|
|
||||||
dofile(api_path .. "breeding.lua")
|
|
||||||
dofile(api_path .. "head_logic.lua")
|
|
||||||
|
|
||||||
|
|
||||||
mobs.spawning_mobs = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- register mob entity
|
|
||||||
function mobs:register_mob(name, def)
|
|
||||||
|
|
||||||
local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}
|
|
||||||
|
|
||||||
-- Workaround for <https://github.com/minetest/minetest/issues/5966>:
|
|
||||||
-- Increase upper Y limit to avoid mobs glitching through solid nodes.
|
|
||||||
-- FIXME: Remove workaround if it's no longer needed.
|
|
||||||
|
|
||||||
if collisionbox[5] < 0.79 then
|
|
||||||
collisionbox[5] = 0.79
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.spawning_mobs[name] = true
|
|
||||||
|
|
||||||
local function scale_difficulty(value, default, min, special)
|
|
||||||
if (not value) or (value == default) or (value == special) then
|
|
||||||
return default
|
|
||||||
else
|
|
||||||
return math.max(min, value * difficulty)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity(name, {
|
|
||||||
description = def.description,
|
|
||||||
use_texture_alpha = def.use_texture_alpha,
|
|
||||||
stepheight = def.stepheight or 0.6,
|
|
||||||
stepheight_backup = def.stepheight or 0.6,
|
|
||||||
name = name,
|
|
||||||
type = def.type,
|
|
||||||
attack_type = def.attack_type,
|
|
||||||
fly = def.fly,
|
|
||||||
fly_in = def.fly_in or {"air", "__airlike"},
|
|
||||||
owner = def.owner or "",
|
|
||||||
order = def.order or "",
|
|
||||||
on_die = def.on_die,
|
|
||||||
spawn_small_alternative = def.spawn_small_alternative,
|
|
||||||
do_custom = def.do_custom,
|
|
||||||
jump_height = def.jump_height or 4, -- was 6
|
|
||||||
rotate = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2
|
|
||||||
hp_min = scale_difficulty(def.hp_min, 5, 1),
|
|
||||||
hp_max = scale_difficulty(def.hp_max, 10, 1),
|
|
||||||
xp_min = def.xp_min or 1,
|
|
||||||
xp_max = def.xp_max or 5,
|
|
||||||
breath_max = def.breath_max or 6,
|
|
||||||
breathes_in_water = def.breathes_in_water or false,
|
|
||||||
physical = true,
|
|
||||||
collisionbox = collisionbox,
|
|
||||||
collide_with_objects = def.collide_with_objects or false,
|
|
||||||
selectionbox = def.selectionbox or def.collisionbox,
|
|
||||||
visual = def.visual,
|
|
||||||
visual_size = def.visual_size or {x = 1, y = 1},
|
|
||||||
mesh = def.mesh,
|
|
||||||
makes_footstep_sound = def.makes_footstep_sound or false,
|
|
||||||
view_range = def.view_range or 16,
|
|
||||||
walk_velocity = def.walk_velocity or 1,
|
|
||||||
run_velocity = def.run_velocity or 2,
|
|
||||||
damage = scale_difficulty(def.damage, 0, 0),
|
|
||||||
light_damage = def.light_damage or 0,
|
|
||||||
sunlight_damage = def.sunlight_damage or 0,
|
|
||||||
water_damage = def.water_damage or 0,
|
|
||||||
lava_damage = def.lava_damage or 8,
|
|
||||||
fire_damage = def.fire_damage or 1,
|
|
||||||
suffocation = def.suffocation or true,
|
|
||||||
fall_damage = def.fall_damage or 1,
|
|
||||||
fall_speed = def.fall_speed or DEFAULT_FALL_SPEED, -- must be lower than -2
|
|
||||||
drops = def.drops or {},
|
|
||||||
armor = def.armor or 100,
|
|
||||||
on_rightclick = mobs.create_mob_on_rightclick(def.on_rightclick),
|
|
||||||
arrow = def.arrow,
|
|
||||||
shoot_interval = def.shoot_interval,
|
|
||||||
sounds = def.sounds or {},
|
|
||||||
animation = def.animation,
|
|
||||||
jump = def.jump ~= false,
|
|
||||||
walk_chance = def.walk_chance or 50,
|
|
||||||
attacks_monsters = def.attacks_monsters or false,
|
|
||||||
group_attack = def.group_attack or false,
|
|
||||||
passive = def.passive or false,
|
|
||||||
knock_back = def.knock_back ~= false,
|
|
||||||
shoot_offset = def.shoot_offset or 0,
|
|
||||||
floats = def.floats or 1, -- floats in water by default
|
|
||||||
floats_on_lava = def.floats_on_lava or 0,
|
|
||||||
replace_rate = def.replace_rate,
|
|
||||||
replace_what = def.replace_what,
|
|
||||||
replace_with = def.replace_with,
|
|
||||||
replace_offset = def.replace_offset or 0,
|
|
||||||
on_replace = def.on_replace,
|
|
||||||
timer = 0,
|
|
||||||
state_timer = 0,
|
|
||||||
env_damage_timer = 0,
|
|
||||||
tamed = false,
|
|
||||||
pause_timer = 0,
|
|
||||||
gotten = false,
|
|
||||||
reach = def.reach or 3,
|
|
||||||
htimer = 0,
|
|
||||||
texture_list = def.textures,
|
|
||||||
child_texture = def.child_texture,
|
|
||||||
docile_by_day = def.docile_by_day or false,
|
|
||||||
time_of_day = 0.5,
|
|
||||||
fear_height = def.fear_height or 0,
|
|
||||||
runaway = def.runaway,
|
|
||||||
runaway_timer = 0,
|
|
||||||
pathfinding = def.pathfinding,
|
|
||||||
immune_to = def.immune_to or {},
|
|
||||||
explosion_radius = def.explosion_radius, -- LEGACY
|
|
||||||
explosion_damage_radius = def.explosion_damage_radius, -- LEGACY
|
|
||||||
explosiontimer_reset_radius = def.explosiontimer_reset_radius,
|
|
||||||
explosion_timer = def.explosion_timer or 3,
|
|
||||||
allow_fuse_reset = def.allow_fuse_reset ~= false,
|
|
||||||
stop_to_explode = def.stop_to_explode ~= false,
|
|
||||||
custom_attack = def.custom_attack,
|
|
||||||
double_melee_attack = def.double_melee_attack,
|
|
||||||
dogshoot_switch = def.dogshoot_switch,
|
|
||||||
dogshoot_count = 0,
|
|
||||||
dogshoot_count_max = def.dogshoot_count_max or 5,
|
|
||||||
dogshoot_count2_max = def.dogshoot_count2_max or (def.dogshoot_count_max or 5),
|
|
||||||
attack_animals = def.attack_animals or false,
|
|
||||||
specific_attack = def.specific_attack,
|
|
||||||
runaway_from = def.runaway_from,
|
|
||||||
owner_loyal = def.owner_loyal,
|
|
||||||
facing_fence = false,
|
|
||||||
|
|
||||||
_cmi_is_mob = true,
|
|
||||||
|
|
||||||
pushable = def.pushable or true,
|
|
||||||
|
|
||||||
--j4i stuff
|
|
||||||
yaw = 0,
|
|
||||||
automatic_face_movement_dir = def.rotate or 0, -- 0=front, 90=side, 180=back, 270=side2
|
|
||||||
automatic_face_movement_max_rotation_per_sec = 360, --degrees
|
|
||||||
backface_culling = true,
|
|
||||||
walk_timer = 0,
|
|
||||||
stand_timer = 0,
|
|
||||||
current_animation = "",
|
|
||||||
gravity = GRAVITY,
|
|
||||||
swim = def.swim,
|
|
||||||
swim_in = def.swim_in or {mobs_mc.items.water_source, "mcl_core:water_flowing", mobs_mc.items.river_water_source},
|
|
||||||
pitch_switch = "static",
|
|
||||||
jump_only = def.jump_only,
|
|
||||||
hostile = def.hostile,
|
|
||||||
neutral = def.neutral,
|
|
||||||
attacking = nil,
|
|
||||||
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
|
||||||
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
|
||||||
death_animation_timer = 0,
|
|
||||||
hostile_cooldown = def.hostile_cooldown or 15,
|
|
||||||
tilt_fly = def.tilt_fly,
|
|
||||||
tilt_swim = def.tilt_swim,
|
|
||||||
fall_slow = def.fall_slow,
|
|
||||||
projectile_cooldown_min = def.projectile_cooldown_min or 2,
|
|
||||||
projectile_cooldown_max = def.projectile_cooldown_max or 6,
|
|
||||||
skittish = def.skittish,
|
|
||||||
|
|
||||||
minimum_follow_distance = def.minimum_follow_distance or 0.5, --make mobs not freak out when underneath
|
|
||||||
|
|
||||||
memory = 0, -- memory timer if chasing/following
|
|
||||||
fly_random_while_attack = def.fly_random_while_attack,
|
|
||||||
|
|
||||||
--for spiders
|
|
||||||
always_climb = def.always_climb,
|
|
||||||
|
|
||||||
--despawn mechanic variables
|
|
||||||
lifetimer_reset = 30, --30 seconds
|
|
||||||
lifetimer = 30, --30 seconds
|
|
||||||
|
|
||||||
--breeding stuff
|
|
||||||
breed_timer = 0,
|
|
||||||
breed_lookout_timer = 0,
|
|
||||||
breed_distance = def.breed_distance or 1.5, --how far away mobs have to be to begin actual breeding
|
|
||||||
breed_lookout_timer_goal = 30, --30 seconds (this timer is for how long the mob looks for a mate)
|
|
||||||
breed_timer_cooloff = 5*60, -- 5 minutes (this timer is for how long the mob has to wait before being bred again)
|
|
||||||
bred = false,
|
|
||||||
follow = def.follow, --this item is also used for the breeding mechanism
|
|
||||||
follow_distance = def.follow_distance or 2,
|
|
||||||
baby_size = def.baby_size or 0.5,
|
|
||||||
baby = false,
|
|
||||||
grow_up_timer = 0,
|
|
||||||
grow_up_goal = 20*60, --in 20 minutes the mob grows up
|
|
||||||
special_breed_timer = 0, --this is used for the AHEM AHEM part of breeding
|
|
||||||
|
|
||||||
backup_visual_size = def.visual_size,
|
|
||||||
backup_collisionbox = collisionbox,
|
|
||||||
backup_selectionbox = def.selectionbox or def.collisionbox,
|
|
||||||
|
|
||||||
|
|
||||||
--fire timer
|
|
||||||
burn_timer = 0,
|
|
||||||
|
|
||||||
ignores_cobwebs = def.ignores_cobwebs,
|
|
||||||
breath = def.breath_max or 6,
|
|
||||||
|
|
||||||
random_sound_timer_min = 3,
|
|
||||||
random_sound_timer_max = 10,
|
|
||||||
|
|
||||||
--head code variables
|
|
||||||
--defaults are for the cow's default
|
|
||||||
--because I don't know what else to set them
|
|
||||||
--to :P
|
|
||||||
|
|
||||||
--you must use these to adjust the mob's head positions
|
|
||||||
|
|
||||||
--has_head is used as a logic gate (quick easy check)
|
|
||||||
has_head = def.has_head or false,
|
|
||||||
--head_bone is the actual bone in the model which the head
|
|
||||||
--is attached to for animation
|
|
||||||
head_bone = def.head_bone or "head",
|
|
||||||
|
|
||||||
--this part controls the base position of the head calculations
|
|
||||||
--localized to the mob's visual yaw when gotten (self.object:get_yaw())
|
|
||||||
--you can enable the debug in /mob_functions/head_logic.lua by uncommenting the
|
|
||||||
--particle spawner code
|
|
||||||
head_height_offset = def.head_height_offset or 1.0525,
|
|
||||||
head_direction_offset = def.head_direction_offset or 0.5,
|
|
||||||
|
|
||||||
--this part controls the visual of the head
|
|
||||||
head_bone_pos_y = def.head_bone_pos_y or 3.6,
|
|
||||||
head_bone_pos_z = def.head_bone_pos_z or -0.6,
|
|
||||||
head_pitch_modifier = def.head_pitch_modifier or 0,
|
|
||||||
|
|
||||||
--these variables are switches in case the model
|
|
||||||
--moves the wrong way
|
|
||||||
swap_y_with_x = def.swap_y_with_x or false,
|
|
||||||
reverse_head_yaw = def.reverse_head_yaw or false,
|
|
||||||
|
|
||||||
--END HEAD CODE VARIABLES
|
|
||||||
|
|
||||||
--end j4i stuff
|
|
||||||
|
|
||||||
-- MCL2 extensions
|
|
||||||
teleport = mobs.teleport,
|
|
||||||
do_teleport = def.do_teleport,
|
|
||||||
spawn_class = def.spawn_class,
|
|
||||||
ignores_nametag = def.ignores_nametag or false,
|
|
||||||
rain_damage = def.rain_damage or 0,
|
|
||||||
glow = def.glow,
|
|
||||||
--can_despawn = can_despawn,
|
|
||||||
child = def.child or false,
|
|
||||||
texture_mods = {},
|
|
||||||
shoot_arrow = def.shoot_arrow,
|
|
||||||
sounds_child = def.sounds_child,
|
|
||||||
explosion_strength = def.explosion_strength,
|
|
||||||
suffocation_timer = 0,
|
|
||||||
follow_velocity = def.follow_velocity or 2.4,
|
|
||||||
instant_death = def.instant_death or false,
|
|
||||||
fire_resistant = def.fire_resistant or false,
|
|
||||||
fire_damage_resistant = def.fire_damage_resistant or false,
|
|
||||||
ignited_by_sunlight = def.ignited_by_sunlight or false,
|
|
||||||
eye_height = def.eye_height or 1.5,
|
|
||||||
defuse_reach = def.defuse_reach or 4,
|
|
||||||
-- End of MCL2 extensions
|
|
||||||
|
|
||||||
on_spawn = def.on_spawn,
|
|
||||||
|
|
||||||
--on_blast = def.on_blast or do_tnt,
|
|
||||||
|
|
||||||
on_step = mobs.mob_step,
|
|
||||||
|
|
||||||
--do_punch = def.do_punch,
|
|
||||||
|
|
||||||
on_punch = mobs.mob_punch,
|
|
||||||
|
|
||||||
--on_breed = def.on_breed,
|
|
||||||
|
|
||||||
--on_grown = def.on_grown,
|
|
||||||
|
|
||||||
--on_detach_child = mob_detach_child,
|
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime)
|
|
||||||
self.object:set_acceleration(vector.new(0,-GRAVITY, 0))
|
|
||||||
return mobs.mob_activate(self, staticdata, def, dtime)
|
|
||||||
end,
|
|
||||||
|
|
||||||
get_staticdata = function(self)
|
|
||||||
return mobs.mob_staticdata(self)
|
|
||||||
end,
|
|
||||||
|
|
||||||
--harmed_by_heal = def.harmed_by_heal,
|
|
||||||
})
|
|
||||||
|
|
||||||
if minetest_get_modpath("doc_identifier") then
|
|
||||||
doc.sub.identifier.register_object(name, "basics", "mobs")
|
|
||||||
end
|
|
||||||
|
|
||||||
end -- END mobs:register_mob function
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- register arrow for shoot attack
|
|
||||||
function mobs:register_arrow(name, def)
|
|
||||||
|
|
||||||
-- errorcheck
|
|
||||||
if not name or not def then
|
|
||||||
print("failed to register arrow entity")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_entity(name.."_entity", {
|
|
||||||
|
|
||||||
physical = false,
|
|
||||||
visual = def.visual,
|
|
||||||
visual_size = def.visual_size,
|
|
||||||
textures = def.textures,
|
|
||||||
velocity = def.velocity,
|
|
||||||
hit_player = def.hit_player,
|
|
||||||
hit_node = def.hit_node,
|
|
||||||
hit_mob = def.hit_mob,
|
|
||||||
hit_object = def.hit_object,
|
|
||||||
drop = def.drop or false, -- drops arrow as registered item when true
|
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0}, -- remove box around arrows
|
|
||||||
timer = 0,
|
|
||||||
switch = 0,
|
|
||||||
owner_id = def.owner_id,
|
|
||||||
rotate = def.rotate,
|
|
||||||
speed = def.speed or nil,
|
|
||||||
on_step = function(self)
|
|
||||||
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if self.timer > 150
|
|
||||||
or not mobs.within_limits(pos, 0) then
|
|
||||||
mcl_burning.extinguish(self.object)
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- does arrow have a tail (fireball)
|
|
||||||
if def.tail
|
|
||||||
and def.tail == 1
|
|
||||||
and def.tail_texture then
|
|
||||||
|
|
||||||
--do this to prevent clipping through main entity sprite
|
|
||||||
local pos_adjustment = vector.multiply(vector.normalize(vel), -1)
|
|
||||||
local divider = def.tail_distance_divider or 1
|
|
||||||
pos_adjustment = vector.divide(pos_adjustment, divider)
|
|
||||||
local new_pos = vector.add(pos, pos_adjustment)
|
|
||||||
minetest.add_particle({
|
|
||||||
pos = new_pos,
|
|
||||||
velocity = {x = 0, y = 0, z = 0},
|
|
||||||
acceleration = {x = 0, y = 0, z = 0},
|
|
||||||
expirationtime = def.expire or 0.25,
|
|
||||||
collisiondetection = false,
|
|
||||||
texture = def.tail_texture,
|
|
||||||
size = def.tail_size or 5,
|
|
||||||
glow = def.glow or 0,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.hit_node then
|
|
||||||
|
|
||||||
local node = minetest_get_node(pos).name
|
|
||||||
|
|
||||||
if minetest_registered_nodes[node].walkable then
|
|
||||||
|
|
||||||
self.hit_node(self, pos, node)
|
|
||||||
|
|
||||||
if self.drop == true then
|
|
||||||
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
|
|
||||||
self.lastpos = (self.lastpos or pos)
|
|
||||||
|
|
||||||
minetest_add_item(self.lastpos, self.object:get_luaentity().name)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:remove();
|
|
||||||
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.hit_player or self.hit_mob or self.hit_object then
|
|
||||||
|
|
||||||
for _,player in pairs(minetest_get_objects_inside_radius(pos, 1.5)) do
|
|
||||||
|
|
||||||
if self.hit_player
|
|
||||||
and player:is_player() then
|
|
||||||
|
|
||||||
if self.hit_player then
|
|
||||||
self.hit_player(self, player)
|
|
||||||
else
|
|
||||||
mobs.arrow_hit(self, player)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
local entity = player:get_luaentity()
|
|
||||||
|
|
||||||
if entity
|
|
||||||
and self.hit_mob
|
|
||||||
and entity._cmi_is_mob == true
|
|
||||||
and tostring(player) ~= self.owner_id
|
|
||||||
and entity.name ~= self.object:get_luaentity().name
|
|
||||||
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
|
|
||||||
|
|
||||||
--self.hit_mob(self, player)
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
--[[
|
|
||||||
if entity
|
|
||||||
and self.hit_object
|
|
||||||
and (not entity._cmi_is_mob)
|
|
||||||
and tostring(player) ~= self.owner_id
|
|
||||||
and entity.name ~= self.object:get_luaentity().name
|
|
||||||
and (self._shooter and entity.name ~= self._shooter:get_luaentity().name) then
|
|
||||||
|
|
||||||
--self.hit_object(self, player)
|
|
||||||
self.object:remove();
|
|
||||||
return
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.lastpos = pos
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Register spawn eggs
|
|
||||||
|
|
||||||
-- Note: This also introduces the “spawn_egg” group:
|
|
||||||
-- * spawn_egg=1: Spawn egg (generic mob, no metadata)
|
|
||||||
-- * spawn_egg=2: Spawn egg (captured/tamed mob, metadata)
|
|
||||||
function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|
||||||
|
|
||||||
local grp = {spawn_egg = 1}
|
|
||||||
|
|
||||||
-- do NOT add this egg to creative inventory (e.g. dungeon master)
|
|
||||||
if no_creative == true then
|
|
||||||
grp.not_in_creative_inventory = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local invimg = background
|
|
||||||
|
|
||||||
if addegg == 1 then
|
|
||||||
invimg = "mobs_chicken_egg.png^(" .. invimg ..
|
|
||||||
"^[mask:mobs_chicken_egg_overlay.png)"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- register old stackable mob egg
|
|
||||||
minetest.register_craftitem(mob, {
|
|
||||||
|
|
||||||
description = desc,
|
|
||||||
inventory_image = invimg,
|
|
||||||
groups = grp,
|
|
||||||
|
|
||||||
_doc_items_longdesc = S("This allows you to place a single mob."),
|
|
||||||
_doc_items_usagehelp = S("Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns."),
|
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
|
|
||||||
local pos = pointed_thing.above
|
|
||||||
|
|
||||||
-- am I clicking on something with existing on_rightclick function?
|
|
||||||
local under = minetest_get_node(pointed_thing.under)
|
|
||||||
local def = minetest_registered_nodes[under.name]
|
|
||||||
if def and def.on_rightclick then
|
|
||||||
return def.on_rightclick(pointed_thing.under, under, placer, itemstack)
|
|
||||||
end
|
|
||||||
|
|
||||||
if pos
|
|
||||||
--and within_limits(pos, 0)
|
|
||||||
and not minetest.is_protected(pos, placer:get_player_name()) then
|
|
||||||
|
|
||||||
local name = placer:get_player_name()
|
|
||||||
local privs = minetest.get_player_privs(name)
|
|
||||||
if mod_mobspawners and under.name == "mcl_mobspawners:spawner" then
|
|
||||||
if minetest.is_protected(pointed_thing.under, name) then
|
|
||||||
minetest.record_protection_violation(pointed_thing.under, name)
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
if not privs.maphack then
|
|
||||||
minetest.chat_send_player(name, S("You need the “maphack” privilege to change the mob spawner."))
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
mcl_mobspawners.setup_spawner(pointed_thing.under, itemstack:get_name())
|
|
||||||
if not mobs.is_creative(name) then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
if not minetest_registered_entities[mob] then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
if minetest_settings:get_bool("only_peaceful_mobs", false)
|
|
||||||
and minetest_registered_entities[mob].type == "monster" then
|
|
||||||
minetest.chat_send_player(name, S("Only peaceful mobs allowed!"))
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local mob = minetest_add_entity(pos, mob)
|
|
||||||
minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos))
|
|
||||||
local ent = mob:get_luaentity()
|
|
||||||
|
|
||||||
-- don't set owner if monster or sneak pressed
|
|
||||||
--[[
|
|
||||||
if ent.type ~= "monster"
|
|
||||||
and not placer:get_player_control().sneak then
|
|
||||||
ent.owner = placer:get_player_name()
|
|
||||||
ent.tamed = true
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
-- set nametag
|
|
||||||
local nametag = itemstack:get_meta():get_string("name")
|
|
||||||
if nametag ~= "" then
|
|
||||||
if string.len(nametag) > MAX_MOB_NAME_LENGTH then
|
|
||||||
nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH)
|
|
||||||
end
|
|
||||||
ent.nametag = nametag
|
|
||||||
--update_tag(ent)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if not in creative then take item
|
|
||||||
if not mobs.is_creative(placer:get_player_name()) then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,257 +0,0 @@
|
||||||
local math = math
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
local HALF_PI = math.pi/2
|
|
||||||
|
|
||||||
|
|
||||||
local vector_direction = vector.direction
|
|
||||||
local vector_distance = vector.distance
|
|
||||||
local vector_new = vector.new
|
|
||||||
|
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
|
||||||
|
|
||||||
-- set defined animation
|
|
||||||
mobs.set_mob_animation = function(self, anim, fixed_frame)
|
|
||||||
|
|
||||||
if not self.animation or not anim then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.state == "die" and anim ~= "die" and anim ~= "stand" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if (not self.animation[anim .. "_start"] or not self.animation[anim .. "_end"]) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--animations break if they are constantly set
|
|
||||||
--so we put this return gate to check if it is
|
|
||||||
--already at the animation we are trying to implement
|
|
||||||
if self.current_animation == anim then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local a_start = self.animation[anim .. "_start"]
|
|
||||||
local a_end
|
|
||||||
|
|
||||||
if fixed_frame then
|
|
||||||
a_end = a_start
|
|
||||||
else
|
|
||||||
a_end = self.animation[anim .. "_end"]
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:set_animation({
|
|
||||||
x = a_start,
|
|
||||||
y = a_end},
|
|
||||||
self.animation[anim .. "_speed"] or self.animation.speed_normal or 15,
|
|
||||||
0, self.animation[anim .. "_loop"] ~= false)
|
|
||||||
|
|
||||||
self.current_animation = anim
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mobs.death_effect = function(pos, yaw, collisionbox, rotate)
|
|
||||||
local min, max
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
else
|
|
||||||
min = { x = -0.5, y = 0, z = -0.5 }
|
|
||||||
max = { x = 0.5, y = 0.5, z = 0.5 }
|
|
||||||
end
|
|
||||||
if rotate then
|
|
||||||
min = vector.rotate(min, {x=0, y=yaw, z=math.pi/2})
|
|
||||||
max = vector.rotate(max, {x=0, y=yaw, z=math.pi/2})
|
|
||||||
min, max = vector.sort(min, max)
|
|
||||||
min = vector.multiply(min, 0.5)
|
|
||||||
max = vector.multiply(max, 0.5)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
|
||||||
amount = 50,
|
|
||||||
time = 0.001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector_new(-5,-5,-5),
|
|
||||||
maxvel = vector_new(5,5,5),
|
|
||||||
minexptime = 1.1,
|
|
||||||
maxexptime = 1.5,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "mcl_particles_mob_death.png^[colorize:#000000:255",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.sound_play("mcl_mobs_mob_poof", {
|
|
||||||
pos = pos,
|
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 8,
|
|
||||||
}, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--this allows auto facedir rotation while making it so mobs
|
|
||||||
--don't look like wet noodles flopping around
|
|
||||||
mobs.movement_rotation_lock = function(self)
|
|
||||||
local current_engine_yaw = self.object:get_yaw()
|
|
||||||
local current_lua_yaw = self.yaw
|
|
||||||
|
|
||||||
if current_engine_yaw > math.pi * 2 then
|
|
||||||
current_engine_yaw = current_engine_yaw - (math.pi * 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
if math.abs(current_engine_yaw - current_lua_yaw) <= 0.05 and self.object:get_properties().automatic_face_movement_dir then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = false}
|
|
||||||
elseif math.abs(current_engine_yaw - current_lua_yaw) > 0.05 and self.object:get_properties().automatic_face_movement_dir == false then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = self.rotate}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--this is used when a mob is chasing a player
|
|
||||||
mobs.set_yaw_while_attacking = function(self)
|
|
||||||
|
|
||||||
if self.object:get_properties().automatic_face_movement_dir then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = false}
|
|
||||||
end
|
|
||||||
|
|
||||||
--turn positions into pseudo 2d vectors
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
|
|
||||||
local pos2 = self.attacking:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
|
|
||||||
local new_direction = vector_direction(pos1,pos2)
|
|
||||||
local new_yaw = minetest_dir_to_yaw(new_direction)
|
|
||||||
|
|
||||||
self.object:set_yaw(new_yaw)
|
|
||||||
self.yaw = new_yaw
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is used to unlock a mob's yaw after attacking
|
|
||||||
mobs.unlock_yaw = function(self)
|
|
||||||
if self.object:get_properties().automatic_face_movement_dir == false then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = self.rotate}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is used to lock a mob's yaw when they're standing
|
|
||||||
mobs.lock_yaw = function(self)
|
|
||||||
if self.object:get_properties().automatic_face_movement_dir then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = false}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local calculate_pitch = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
local pos2 = self.old_pos
|
|
||||||
|
|
||||||
if pos == nil or pos2 == nil then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest_dir_to_yaw(vector_new(vector_distance(vector_new(pos.x,0,pos.z),vector_new(pos2.x,0,pos2.z)),0,pos.y - pos2.y)) + HALF_PI
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is a helper function used to make mobs pitch rotation dynamically flow when flying/swimming
|
|
||||||
mobs.set_dynamic_pitch = function(self)
|
|
||||||
local pitch = calculate_pitch(self)
|
|
||||||
|
|
||||||
if not pitch then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_rotation = self.object:get_rotation()
|
|
||||||
|
|
||||||
current_rotation.x = pitch
|
|
||||||
|
|
||||||
self.object:set_rotation(current_rotation)
|
|
||||||
|
|
||||||
self.pitch_switch = "dynamic"
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is a helper function used to make mobs pitch rotation reset when flying/swimming
|
|
||||||
mobs.set_static_pitch = function(self)
|
|
||||||
|
|
||||||
if self.pitch_switch == "static" then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_rotation = self.object:get_rotation()
|
|
||||||
|
|
||||||
current_rotation.x = 0
|
|
||||||
|
|
||||||
self.object:set_rotation(current_rotation)
|
|
||||||
self.pitch_switch = "static"
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is a helper function for mobs explosion animation
|
|
||||||
mobs.handle_explosion_animation = function(self)
|
|
||||||
|
|
||||||
--secondary catch-all
|
|
||||||
if not self.explosion_animation then
|
|
||||||
self.explosion_animation = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--the timer works from 0 for sense of a 0 based counting
|
|
||||||
--but this just bumps it up so it's usable in here
|
|
||||||
local explosion_timer_adjust = self.explosion_animation + 1
|
|
||||||
|
|
||||||
|
|
||||||
local visual_size_modified = table.copy(self.visual_size_origin)
|
|
||||||
|
|
||||||
visual_size_modified.x = visual_size_modified.x * (explosion_timer_adjust ^ 3)
|
|
||||||
visual_size_modified.y = visual_size_modified.y * explosion_timer_adjust
|
|
||||||
|
|
||||||
self.object:set_properties({visual_size = visual_size_modified})
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--this is used when a mob is following player
|
|
||||||
mobs.set_yaw_while_following = function(self)
|
|
||||||
|
|
||||||
if self.object:get_properties().automatic_face_movement_dir then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = false}
|
|
||||||
end
|
|
||||||
|
|
||||||
--turn positions into pseudo 2d vectors
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
|
|
||||||
local pos2 = self.following_person:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
|
|
||||||
local new_direction = vector_direction(pos1,pos2)
|
|
||||||
local new_yaw = minetest_dir_to_yaw(new_direction)
|
|
||||||
|
|
||||||
self.object:set_yaw(new_yaw)
|
|
||||||
self.yaw = new_yaw
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is used for when mobs breed
|
|
||||||
mobs.set_yaw_while_breeding = function(self, mate)
|
|
||||||
|
|
||||||
if self.object:get_properties().automatic_face_movement_dir then
|
|
||||||
self.object:set_properties{automatic_face_movement_dir = false}
|
|
||||||
end
|
|
||||||
|
|
||||||
--turn positions into pseudo 2d vectors
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
|
|
||||||
local pos2 = mate:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
|
|
||||||
local new_direction = vector_direction(pos1,pos2)
|
|
||||||
local new_yaw = minetest_dir_to_yaw(new_direction)
|
|
||||||
|
|
||||||
self.object:set_yaw(new_yaw)
|
|
||||||
self.yaw = new_yaw
|
|
||||||
end
|
|
|
@ -1,347 +0,0 @@
|
||||||
local vector_direction = vector.direction
|
|
||||||
--local minetest_dir_to_yaw = minetest.dir_to_yaw
|
|
||||||
local vector_distance = vector.distance
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
local math_random = math.random
|
|
||||||
|
|
||||||
--[[
|
|
||||||
_ _ _ _
|
|
||||||
| | | | | | | |
|
|
||||||
| | | | __ _ _ __ __| | | |
|
|
||||||
| | | | / _` | '_ \ / _` | | |
|
|
||||||
|_| | |___| (_| | | | | (_| | |_|
|
|
||||||
(_) \_____/\__,_|_| |_|\__,_| (_)
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
_____ _ _
|
|
||||||
| ___| | | | |
|
|
||||||
| |____ ___ __ | | ___ __| | ___
|
|
||||||
| __\ \/ / '_ \| |/ _ \ / _` |/ _ \
|
|
||||||
| |___> <| |_) | | (_) | (_| | __/
|
|
||||||
\____/_/\_\ .__/|_|\___/ \__,_|\___|
|
|
||||||
| |
|
|
||||||
|_|
|
|
||||||
]]--
|
|
||||||
|
|
||||||
mobs.explode_attack_walk = function(self,dtime)
|
|
||||||
|
|
||||||
--this needs an exception
|
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
|
||||||
self.attacking = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
|
||||||
|
|
||||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
|
||||||
|
|
||||||
--make mob walk up to player within 2 nodes distance then start exploding
|
|
||||||
if distance_from_attacking >= self.reach and
|
|
||||||
--don't allow explosion to cancel unless out of the reach boundary
|
|
||||||
not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then
|
|
||||||
|
|
||||||
mobs.set_velocity(self, self.run_velocity)
|
|
||||||
mobs.set_mob_animation(self,"run")
|
|
||||||
|
|
||||||
mobs.reverse_explosion_animation(self,dtime)
|
|
||||||
else
|
|
||||||
mobs.set_velocity(self,0)
|
|
||||||
|
|
||||||
--this is the only way I can reference this without dumping extra data on all mobs
|
|
||||||
if not self.explosion_animation then
|
|
||||||
self.explosion_animation = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--play ignite sound
|
|
||||||
if self.explosion_animation == 0 then
|
|
||||||
mobs.play_sound(self,"attack")
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_mob_animation(self,"stand")
|
|
||||||
|
|
||||||
mobs.handle_explosion_animation(self)
|
|
||||||
|
|
||||||
self.explosion_animation = self.explosion_animation + (dtime/2.5)
|
|
||||||
end
|
|
||||||
|
|
||||||
--make explosive mobs jump
|
|
||||||
--check for nodes to jump over
|
|
||||||
--explosive mobs will just ride against walls for now
|
|
||||||
local node_in_front_of = mobs.jump_check(self)
|
|
||||||
if node_in_front_of == 1 then
|
|
||||||
mobs.jump(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
--do biggening explosion thing
|
|
||||||
if self.explosion_animation and self.explosion_animation > self.explosion_timer then
|
|
||||||
mcl_explosions.explode(self.object:get_pos(), self.explosion_strength,{ drop_chance = 1.0 })
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--this is a small helper function to make working with explosion animations easier
|
|
||||||
mobs.reverse_explosion_animation = function(self,dtime)
|
|
||||||
--if explosion animation was greater than 0 then reverse it
|
|
||||||
if self.explosion_animation and self.explosion_animation > 0 then
|
|
||||||
self.explosion_animation = self.explosion_animation - dtime
|
|
||||||
if self.explosion_animation < 0 then
|
|
||||||
self.explosion_animation = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.handle_explosion_animation(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
______ _
|
|
||||||
| ___ \ | |
|
|
||||||
| |_/ / _ _ __ ___| |__
|
|
||||||
| __/ | | | '_ \ / __| '_ \
|
|
||||||
| | | |_| | | | | (__| | | |
|
|
||||||
\_| \__,_|_| |_|\___|_| |_|
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mobs.punch_attack_walk = function(self,dtime)
|
|
||||||
--this needs an exception
|
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
|
||||||
self.attacking = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local distance_from_attacking = mobs.get_2d_distance(self.object:get_pos(), self.attacking:get_pos())
|
|
||||||
|
|
||||||
if distance_from_attacking >= self.minimum_follow_distance then
|
|
||||||
mobs.set_velocity(self, self.run_velocity)
|
|
||||||
mobs.set_mob_animation(self, "run")
|
|
||||||
else
|
|
||||||
mobs.set_velocity(self, 0)
|
|
||||||
mobs.set_mob_animation(self, "stand")
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
|
||||||
|
|
||||||
--make punchy mobs jump
|
|
||||||
--check for nodes to jump over
|
|
||||||
--explosive mobs will just ride against walls for now
|
|
||||||
local node_in_front_of = mobs.jump_check(self)
|
|
||||||
|
|
||||||
if node_in_front_of == 1 then
|
|
||||||
mobs.jump(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
--mobs that can climb over stuff
|
|
||||||
if self.always_climb and node_in_front_of > 0 then
|
|
||||||
mobs.climb(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--auto reset punch_timer
|
|
||||||
if not self.punch_timer then
|
|
||||||
self.punch_timer = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.punch_timer > 0 then
|
|
||||||
self.punch_timer = self.punch_timer - dtime
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.punch_attack = function(self)
|
|
||||||
|
|
||||||
self.attacking:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = self.damage}
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
self.punch_timer = self.punch_timer_cooloff
|
|
||||||
|
|
||||||
|
|
||||||
--knockback
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
local pos2 = self.attacking:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
local dir = vector_direction(pos1,pos2)
|
|
||||||
|
|
||||||
dir = vector_multiply(dir,3)
|
|
||||||
|
|
||||||
if self.attacking:get_velocity().y <= 1 then
|
|
||||||
dir.y = 5
|
|
||||||
end
|
|
||||||
|
|
||||||
self.attacking:add_velocity(dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
______ _ _ _ _
|
|
||||||
| ___ \ (_) | | (_) |
|
|
||||||
| |_/ / __ ___ _ ___ ___| |_ _| | ___
|
|
||||||
| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \
|
|
||||||
| | | | | (_) | | __/ (__| |_| | | __/
|
|
||||||
\_| |_| \___/| |\___|\___|\__|_|_|\___|
|
|
||||||
_/ |
|
|
||||||
|__/
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
mobs.projectile_attack_walk = function(self,dtime)
|
|
||||||
|
|
||||||
--this needs an exception
|
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
|
||||||
self.attacking = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
|
||||||
|
|
||||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
|
||||||
|
|
||||||
|
|
||||||
if distance_from_attacking >= self.reach then
|
|
||||||
mobs.set_velocity(self, self.run_velocity)
|
|
||||||
mobs.set_mob_animation(self,"run")
|
|
||||||
else
|
|
||||||
mobs.set_velocity(self,0)
|
|
||||||
mobs.set_mob_animation(self,"stand")
|
|
||||||
end
|
|
||||||
|
|
||||||
--do this to not load data into other mobs
|
|
||||||
if not self.projectile_timer then
|
|
||||||
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
|
|
||||||
end
|
|
||||||
|
|
||||||
--run projectile timer
|
|
||||||
if self.projectile_timer > 0 then
|
|
||||||
self.projectile_timer = self.projectile_timer - dtime
|
|
||||||
|
|
||||||
--shoot
|
|
||||||
if self.projectile_timer <= 0 then
|
|
||||||
--reset timer
|
|
||||||
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
|
|
||||||
mobs.shoot_projectile(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--make shooty mobs jump
|
|
||||||
--check for nodes to jump over
|
|
||||||
--explosive mobs will just ride against walls for now
|
|
||||||
local node_in_front_of = mobs.jump_check(self)
|
|
||||||
if node_in_front_of == 1 then
|
|
||||||
mobs.jump(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
_ ______ _ _
|
|
||||||
| | | ___| | | |
|
|
||||||
| | | |_ | |_ _ | |
|
|
||||||
| | | _| | | | | | | |
|
|
||||||
|_| | | | | |_| | |_|
|
|
||||||
(_) \_| |_|\__, | (_)
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
______ _ _ _ _
|
|
||||||
| ___ \ (_) | | (_) |
|
|
||||||
| |_/ / __ ___ _ ___ ___| |_ _| | ___
|
|
||||||
| __/ '__/ _ \| |/ _ \/ __| __| | |/ _ \
|
|
||||||
| | | | | (_) | | __/ (__| |_| | | __/
|
|
||||||
\_| |_| \___/| |\___|\___|\__|_|_|\___|
|
|
||||||
_/ |
|
|
||||||
|__/
|
|
||||||
]]--
|
|
||||||
|
|
||||||
local random_pitch_multiplier = {-1,1}
|
|
||||||
|
|
||||||
mobs.projectile_attack_fly = function(self, dtime)
|
|
||||||
--this needs an exception
|
|
||||||
if self.attacking == nil or not self.attacking:is_player() then
|
|
||||||
self.attacking = nil
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is specifically for random ghast movement
|
|
||||||
if self.fly_random_while_attack then
|
|
||||||
|
|
||||||
--enable rotation locking
|
|
||||||
mobs.movement_rotation_lock(self)
|
|
||||||
|
|
||||||
self.walk_timer = self.walk_timer - dtime
|
|
||||||
|
|
||||||
--reset the walk timer
|
|
||||||
if self.walk_timer <= 0 then
|
|
||||||
--re-randomize the walk timer
|
|
||||||
self.walk_timer = math.random(1,6) + math.random()
|
|
||||||
--set the mob into a random direction
|
|
||||||
self.yaw = (math_random() * (math.pi * 2))
|
|
||||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
|
||||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_fly_velocity(self, self.run_velocity)
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
|
||||||
|
|
||||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
|
||||||
|
|
||||||
if distance_from_attacking >= self.reach then
|
|
||||||
mobs.set_pitch_while_attacking(self)
|
|
||||||
mobs.set_fly_velocity(self, self.run_velocity)
|
|
||||||
mobs.set_mob_animation(self,"run")
|
|
||||||
else
|
|
||||||
mobs.set_pitch_while_attacking(self)
|
|
||||||
mobs.set_fly_velocity(self, 0)
|
|
||||||
mobs.set_mob_animation(self,"stand")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--do this to not load data into other mobs
|
|
||||||
if not self.projectile_timer then
|
|
||||||
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
|
|
||||||
end
|
|
||||||
|
|
||||||
--run projectile timer
|
|
||||||
if self.projectile_timer > 0 then
|
|
||||||
self.projectile_timer = self.projectile_timer - dtime
|
|
||||||
|
|
||||||
--shoot
|
|
||||||
if self.projectile_timer <= 0 then
|
|
||||||
|
|
||||||
if self.fly_random_while_attack then
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
|
||||||
self.walk_timer = 0
|
|
||||||
end
|
|
||||||
--reset timer
|
|
||||||
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
|
|
||||||
mobs.shoot_projectile(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,179 +0,0 @@
|
||||||
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
|
||||||
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
--check to see if someone nearby has some tasty food
|
|
||||||
mobs.check_following = function(self) -- returns true or false
|
|
||||||
--ignore
|
|
||||||
if not self.follow then
|
|
||||||
self.following_person = nil
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--hey look, this thing works for passive mobs too!
|
|
||||||
local follower = mobs.detect_closest_player_within_radius(self,true,self.view_range,self.eye_height)
|
|
||||||
|
|
||||||
--check if the follower is a player incase they log out
|
|
||||||
if follower and follower:is_player() then
|
|
||||||
local stack = follower:get_wielded_item()
|
|
||||||
--safety check
|
|
||||||
if not stack then
|
|
||||||
self.following_person = nil
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
|
||||||
--all checks have passed, that guy has some good looking food
|
|
||||||
if item_name == self.follow then
|
|
||||||
self.following_person = follower
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--everything failed
|
|
||||||
self.following_person = nil
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--a function which attempts to make mobs enter
|
|
||||||
--the breeding state
|
|
||||||
mobs.enter_breed_state = function(self,clicker)
|
|
||||||
|
|
||||||
--do not breed if baby
|
|
||||||
if self.baby then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--do not do anything if looking for mate or
|
|
||||||
--if cooling off from breeding
|
|
||||||
if self.breed_lookout_timer > 0 or self.breed_timer > 0 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--if this is caught, that means something has gone
|
|
||||||
--seriously wrong
|
|
||||||
if not clicker or not clicker:is_player() then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local stack = clicker:get_wielded_item()
|
|
||||||
--safety check
|
|
||||||
if not stack then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
|
||||||
--all checks have passed, that guy has some good looking food
|
|
||||||
if item_name == self.follow then
|
|
||||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
|
||||||
stack:take_item()
|
|
||||||
clicker:set_wielded_item(stack)
|
|
||||||
end
|
|
||||||
self.breed_lookout_timer = self.breed_lookout_timer_goal
|
|
||||||
self.bred = true
|
|
||||||
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
--everything failed
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--find the closest mate in the area
|
|
||||||
mobs.look_for_mate = function(self)
|
|
||||||
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = pos1.y + self.eye_height
|
|
||||||
|
|
||||||
local mates_in_area = {}
|
|
||||||
local winner_mate = nil
|
|
||||||
local mates_detected = 0
|
|
||||||
local radius = self.view_range
|
|
||||||
|
|
||||||
--get mates in radius
|
|
||||||
for _,mate in pairs(minetest_get_objects_inside_radius(pos1, radius)) do
|
|
||||||
|
|
||||||
--look for a breeding mate
|
|
||||||
if mate and mate:get_luaentity()
|
|
||||||
and mate:get_luaentity()._cmi_is_mob
|
|
||||||
and mate:get_luaentity().name == self.name
|
|
||||||
and mate:get_luaentity().breed_lookout_timer > 0
|
|
||||||
and mate:get_luaentity() ~= self then
|
|
||||||
|
|
||||||
local pos2 = mate:get_pos()
|
|
||||||
|
|
||||||
local distance = vector.distance(pos1,pos2)
|
|
||||||
|
|
||||||
if distance <= radius then
|
|
||||||
if minetest.line_of_sight then
|
|
||||||
--must add eye height or stuff breaks randomly because of
|
|
||||||
--seethrough nodes being a blocker (like grass)
|
|
||||||
if minetest.line_of_sight(
|
|
||||||
vector.new(pos1.x, pos1.y, pos1.z),
|
|
||||||
vector.new(pos2.x, pos2.y + mate:get_properties().eye_height, pos2.z)
|
|
||||||
) then
|
|
||||||
mates_detected = mates_detected + 1
|
|
||||||
mates_in_area[mate] = distance
|
|
||||||
end
|
|
||||||
else
|
|
||||||
mates_detected = mates_detected + 1
|
|
||||||
mates_in_area[mate] = distance
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--return if there's no one near by
|
|
||||||
if mates_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--do a default radius max
|
|
||||||
local shortest_distance = radius + 1
|
|
||||||
|
|
||||||
--sort through mates and find the closest mate
|
|
||||||
for mate,distance in pairs(mates_in_area) do
|
|
||||||
if distance < shortest_distance then
|
|
||||||
shortest_distance = distance
|
|
||||||
winner_mate = mate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return winner_mate
|
|
||||||
end
|
|
||||||
|
|
||||||
--make the baby grow up
|
|
||||||
mobs.baby_grow_up = function(self)
|
|
||||||
self.baby = nil
|
|
||||||
self.visual_size = self.backup_visual_size
|
|
||||||
self.collisionbox = self.backup_collisionbox
|
|
||||||
self.selectionbox = self.backup_selectionbox
|
|
||||||
self.object:set_properties(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
--makes the baby grow up faster with diminishing returns
|
|
||||||
mobs.make_baby_grow_faster = function(self,clicker)
|
|
||||||
if clicker and clicker:is_player() then
|
|
||||||
local stack = clicker:get_wielded_item()
|
|
||||||
--safety check
|
|
||||||
if not stack then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local item_name = stack:get_name()
|
|
||||||
--all checks have passed, that guy has some good looking food
|
|
||||||
if item_name == self.follow then
|
|
||||||
self.grow_up_timer = self.grow_up_timer - (self.grow_up_timer * 0.10) --take 10 percent off - diminishing returns
|
|
||||||
|
|
||||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
|
||||||
stack:take_item()
|
|
||||||
clicker:set_wielded_item(stack)
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.play_sound_specific(self,"mobs_mc_animal_eat_generic")
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
|
@ -1,135 +0,0 @@
|
||||||
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
|
||||||
|
|
||||||
local math_random = math.random
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
|
|
||||||
local vector_direction = vector.direction
|
|
||||||
|
|
||||||
local integer_test = {-1,1}
|
|
||||||
|
|
||||||
mobs.collision = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
if not self or not self.object or not self.object:get_luaentity() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--do collision detection from the base of the mob
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
pos.y = pos.y + collisionbox[2]
|
|
||||||
|
|
||||||
local collision_boundary = collisionbox[4]
|
|
||||||
|
|
||||||
local radius = collision_boundary
|
|
||||||
|
|
||||||
if collisionbox[5] > collision_boundary then
|
|
||||||
radius = collisionbox[5]
|
|
||||||
end
|
|
||||||
|
|
||||||
local collision_count = 0
|
|
||||||
|
|
||||||
|
|
||||||
local check_for_attack = false
|
|
||||||
|
|
||||||
if self.attack_type == "punch" and self.hostile and self.attacking then
|
|
||||||
check_for_attack = true
|
|
||||||
end
|
|
||||||
|
|
||||||
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
|
|
||||||
if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true and object:get_luaentity().health > 0)) and
|
|
||||||
--don't collide with rider, rider don't collide with thing
|
|
||||||
(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and
|
|
||||||
(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
|
|
||||||
--stop infinite loop
|
|
||||||
collision_count = collision_count + 1
|
|
||||||
--mob cramming
|
|
||||||
if collision_count > 30 then
|
|
||||||
self.health = -20
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos2 = object:get_pos()
|
|
||||||
|
|
||||||
local object_collisionbox = object:get_properties().collisionbox
|
|
||||||
|
|
||||||
pos2.y = pos2.y + object_collisionbox[2]
|
|
||||||
|
|
||||||
local object_collision_boundary = object_collisionbox[4]
|
|
||||||
|
|
||||||
|
|
||||||
--this is checking the difference of the object collided with's possision
|
|
||||||
--if positive top of other object is inside (y axis) of current object
|
|
||||||
local y_base_diff = (pos2.y + object_collisionbox[5]) - pos.y
|
|
||||||
|
|
||||||
local y_top_diff = (pos.y + collisionbox[5]) - pos2.y
|
|
||||||
|
|
||||||
|
|
||||||
local distance = vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z))
|
|
||||||
|
|
||||||
if distance <= collision_boundary + object_collision_boundary and y_base_diff >= 0 and y_top_diff >= 0 then
|
|
||||||
|
|
||||||
local dir = vector.direction(pos,pos2)
|
|
||||||
|
|
||||||
dir.y = 0
|
|
||||||
|
|
||||||
--eliminate mob being stuck in corners
|
|
||||||
if dir.x == 0 and dir.z == 0 then
|
|
||||||
--slightly adjust mob position to prevent equal length
|
|
||||||
--corner/wall sticking
|
|
||||||
dir.x = dir.x + ((math_random()/10)*integer_test[math.random(1,2)])
|
|
||||||
dir.z = dir.z + ((math_random()/10)*integer_test[math.random(1,2)])
|
|
||||||
end
|
|
||||||
|
|
||||||
local velocity = dir
|
|
||||||
|
|
||||||
--0.5 is the max force multiplier
|
|
||||||
local force = 0.5 - (0.5 * distance / (collision_boundary + object_collision_boundary))
|
|
||||||
|
|
||||||
local vel1 = vector.multiply(velocity, -1.5)
|
|
||||||
local vel2 = vector.multiply(velocity, 1.5)
|
|
||||||
|
|
||||||
vel1 = vector.multiply(vel1, force * 10)
|
|
||||||
vel2 = vector.multiply(vel2, force)
|
|
||||||
|
|
||||||
if object:is_player() then
|
|
||||||
vel2 = vector_multiply(vel2, 2.5)
|
|
||||||
|
|
||||||
--integrate mob punching into collision detection
|
|
||||||
if check_for_attack and self.punch_timer <= 0 then
|
|
||||||
if object == self.attacking then
|
|
||||||
mobs.punch_attack(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.object:add_velocity(vel1)
|
|
||||||
object:add_velocity(vel2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--this is used for arrow collisions
|
|
||||||
mobs.arrow_hit = function(self, player)
|
|
||||||
player:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = self._damage}
|
|
||||||
}, nil)
|
|
||||||
|
|
||||||
|
|
||||||
--knockback
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
local pos2 = player:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
local dir = vector_direction(pos1,pos2)
|
|
||||||
|
|
||||||
dir = vector_multiply(dir,3)
|
|
||||||
|
|
||||||
if player:get_velocity().y <= 1 then
|
|
||||||
dir.y = 5
|
|
||||||
end
|
|
||||||
|
|
||||||
player:add_velocity(dir)
|
|
||||||
end
|
|
|
@ -1,161 +0,0 @@
|
||||||
local minetest_add_item = minetest.add_item
|
|
||||||
--local minetest_sound_play = minetest.sound_play
|
|
||||||
|
|
||||||
local math_pi = math.pi
|
|
||||||
local math_random = math.random
|
|
||||||
local math_floor = math.floor
|
|
||||||
local HALF_PI = math_pi / 2
|
|
||||||
|
|
||||||
local vector_new = vector.new
|
|
||||||
|
|
||||||
|
|
||||||
-- drop items
|
|
||||||
local item_drop = function(self, cooked, looting_level)
|
|
||||||
|
|
||||||
looting_level = looting_level or 0
|
|
||||||
|
|
||||||
-- no drops for child mobs (except monster)
|
|
||||||
if (self.child and self.type ~= "monster") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local obj, item
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
self.drops = self.drops or {} -- nil check
|
|
||||||
|
|
||||||
for n = 1, #self.drops do
|
|
||||||
local dropdef = self.drops[n]
|
|
||||||
local chance = 1 / dropdef.chance
|
|
||||||
local looting_type = dropdef.looting
|
|
||||||
|
|
||||||
if looting_level > 0 then
|
|
||||||
local chance_function = dropdef.looting_chance_function
|
|
||||||
if chance_function then
|
|
||||||
chance = chance_function(looting_level)
|
|
||||||
elseif looting_type == "rare" then
|
|
||||||
chance = chance + (dropdef.looting_factor or 0.01) * looting_level
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local num = 0
|
|
||||||
local do_common_looting = (looting_level > 0 and looting_type == "common")
|
|
||||||
if math_random() < chance then
|
|
||||||
num = math_random(dropdef.min or 1, dropdef.max or 1)
|
|
||||||
elseif not dropdef.looting_ignore_chance then
|
|
||||||
do_common_looting = false
|
|
||||||
end
|
|
||||||
|
|
||||||
if do_common_looting then
|
|
||||||
num = num + math_floor(math_random(0, looting_level) + 0.5)
|
|
||||||
end
|
|
||||||
|
|
||||||
if num > 0 then
|
|
||||||
item = dropdef.name
|
|
||||||
|
|
||||||
-- cook items when true
|
|
||||||
if cooked then
|
|
||||||
|
|
||||||
local output = minetest.get_craft_result({
|
|
||||||
method = "cooking",
|
|
||||||
width = 1,
|
|
||||||
items = {item},
|
|
||||||
})
|
|
||||||
|
|
||||||
if output and output.item and not output.item:is_empty() then
|
|
||||||
item = output.item:get_name()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- add item if it exists
|
|
||||||
for x = 1, num do
|
|
||||||
obj = minetest_add_item(pos, ItemStack(item .. " " .. 1))
|
|
||||||
end
|
|
||||||
|
|
||||||
if obj and obj:get_luaentity() then
|
|
||||||
|
|
||||||
obj:set_velocity({
|
|
||||||
x = math_random(-10, 10) / 9,
|
|
||||||
y = 6,
|
|
||||||
z = math_random(-10, 10) / 9,
|
|
||||||
})
|
|
||||||
elseif obj then
|
|
||||||
obj:remove() -- item does not exist
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.drops = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
mobs.death_logic = function(self, dtime)
|
|
||||||
|
|
||||||
--stop crashing game when object is nil
|
|
||||||
if not self or not self.object or not self.object:get_luaentity() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self.death_animation_timer = self.death_animation_timer + dtime
|
|
||||||
|
|
||||||
--get all attached entities and sort through them
|
|
||||||
local attached_entities = self.object:get_children()
|
|
||||||
if #attached_entities > 0 then
|
|
||||||
for _,entity in pairs(attached_entities) do
|
|
||||||
--kick the player off
|
|
||||||
if entity:is_player() then
|
|
||||||
mobs.detach(entity)
|
|
||||||
--kick mobs off
|
|
||||||
--if there is scaling issues, this needs an additional check
|
|
||||||
else
|
|
||||||
entity:set_detach()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--stop mob from getting in the way of other mobs you're fighting
|
|
||||||
if self.object:get_properties().pointable then
|
|
||||||
self.object:set_properties({pointable = false})
|
|
||||||
end
|
|
||||||
|
|
||||||
--the final POOF of a mob despawning
|
|
||||||
if self.death_animation_timer >= 1.25 then
|
|
||||||
item_drop(self,false,1)
|
|
||||||
mobs.death_effect(self)
|
|
||||||
mcl_experience.throw_xp(self.object:get_pos(), math_random(self.xp_min, self.xp_max))
|
|
||||||
if self.on_die then
|
|
||||||
self.on_die(self, self.object:get_pos())
|
|
||||||
end
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--I'm sure there's a more efficient way to do this
|
|
||||||
--but this is the easiest, easier to work with 1 variable synced
|
|
||||||
--this is also not smooth
|
|
||||||
local death_animation_roll = self.death_animation_timer * 2 -- * 2 to make it faster
|
|
||||||
if death_animation_roll > 1 then
|
|
||||||
death_animation_roll = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local rot = self.object:get_rotation() --(no pun intended)
|
|
||||||
|
|
||||||
rot.z = death_animation_roll * HALF_PI
|
|
||||||
|
|
||||||
self.object:set_rotation(rot)
|
|
||||||
|
|
||||||
mobs.set_mob_animation(self,"stand", true)
|
|
||||||
|
|
||||||
|
|
||||||
--flying and swimming mobs just fall down
|
|
||||||
if self.fly or self.swim then
|
|
||||||
if self.object:get_acceleration().y ~= -self.gravity then
|
|
||||||
self.object:set_acceleration(vector_new(0,-self.gravity,0))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--when landing allow mob to slow down and just fall if in air
|
|
||||||
if self.pause_timer <= 0 then
|
|
||||||
mobs.set_velocity(self,0)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,250 +0,0 @@
|
||||||
local minetest_line_of_sight = minetest.line_of_sight
|
|
||||||
--local minetest_dir_to_yaw = minetest.dir_to_yaw
|
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
|
||||||
local minetest_get_node = minetest.get_node
|
|
||||||
local minetest_get_item_group = minetest.get_item_group
|
|
||||||
local minetest_get_objects_inside_radius = minetest.get_objects_inside_radius
|
|
||||||
local minetest_get_node_or_nil = minetest.get_node_or_nil
|
|
||||||
local minetest_registered_nodes = minetest.registered_nodes
|
|
||||||
local minetest_get_connected_players = minetest.get_connected_players
|
|
||||||
|
|
||||||
local vector_new = vector.new
|
|
||||||
local vector_add = vector.add
|
|
||||||
local vector_multiply = vector.multiply
|
|
||||||
local vector_distance = vector.distance
|
|
||||||
|
|
||||||
local table_copy = table.copy
|
|
||||||
|
|
||||||
local math_abs = math.abs
|
|
||||||
|
|
||||||
-- default function when mobs are blown up with TNT
|
|
||||||
--[[local function do_tnt(obj, damage)
|
|
||||||
obj.object:punch(obj.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = damage},
|
|
||||||
}, nil)
|
|
||||||
return false, true, {}
|
|
||||||
end]]
|
|
||||||
|
|
||||||
--a fast function to be able to detect only players without using objects_in_radius
|
|
||||||
mobs.detect_closest_player_within_radius = function(self, line_of_sight, radius, object_height_adder)
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
local players_in_area = {}
|
|
||||||
local winner_player = nil
|
|
||||||
local players_detected = 0
|
|
||||||
|
|
||||||
--get players in radius
|
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
|
||||||
if player and player:get_hp() > 0 then
|
|
||||||
|
|
||||||
local pos2 = player:get_pos()
|
|
||||||
|
|
||||||
local distance = vector_distance(pos1,pos2)
|
|
||||||
|
|
||||||
if distance <= radius then
|
|
||||||
if line_of_sight then
|
|
||||||
--must add eye height or stuff breaks randomly because of
|
|
||||||
--seethrough nodes being a blocker (like grass)
|
|
||||||
if minetest_line_of_sight(
|
|
||||||
vector_new(pos1.x, pos1.y + object_height_adder, pos1.z),
|
|
||||||
vector_new(pos2.x, pos2.y + player:get_properties().eye_height, pos2.z)
|
|
||||||
) then
|
|
||||||
players_detected = players_detected + 1
|
|
||||||
players_in_area[player] = distance
|
|
||||||
end
|
|
||||||
else
|
|
||||||
players_detected = players_detected + 1
|
|
||||||
players_in_area[player] = distance
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--return if there's no one near by
|
|
||||||
if players_detected <= 0 then --handle negative numbers for some crazy error that could possibly happen
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--do a default radius max
|
|
||||||
local shortest_distance = radius + 1
|
|
||||||
|
|
||||||
--sort through players and find the closest player
|
|
||||||
for player,distance in pairs(players_in_area) do
|
|
||||||
if distance < shortest_distance then
|
|
||||||
shortest_distance = distance
|
|
||||||
winner_player = player
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return winner_player
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--check if a mob needs to jump
|
|
||||||
mobs.jump_check = function(self,dtime)
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
pos.y = pos.y + 0.1
|
|
||||||
local dir = minetest_yaw_to_dir(self.yaw)
|
|
||||||
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
local radius = collisionbox[4] + 0.5
|
|
||||||
|
|
||||||
vector_multiply(dir, radius)
|
|
||||||
|
|
||||||
--only jump if there's a node and a non-solid node above it
|
|
||||||
local test_dir = vector_add(pos,dir)
|
|
||||||
|
|
||||||
local green_flag_1 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") ~= 0
|
|
||||||
|
|
||||||
test_dir.y = test_dir.y + 1
|
|
||||||
|
|
||||||
local green_flag_2 = minetest_get_item_group(minetest_get_node(test_dir).name, "solid") == 0
|
|
||||||
|
|
||||||
if green_flag_1 and green_flag_2 then
|
|
||||||
--can jump over node
|
|
||||||
return 1
|
|
||||||
elseif green_flag_1 and not green_flag_2 then
|
|
||||||
--wall in front of mob
|
|
||||||
return 2
|
|
||||||
end
|
|
||||||
--nothing to jump over
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
-- a helper function to quickly turn neutral passive mobs hostile
|
|
||||||
local turn_hostile = function(self,detected_mob)
|
|
||||||
--drop in variables for attacking (stops crash)
|
|
||||||
detected_mob.punch_timer = 0
|
|
||||||
--set to hostile
|
|
||||||
detected_mob.hostile = true
|
|
||||||
--hostile_cooldown timer is initialized here
|
|
||||||
detected_mob.hostile_cooldown_timer = detected_mob.hostile_cooldown
|
|
||||||
--set target to the same
|
|
||||||
detected_mob.attacking = self.attacking
|
|
||||||
end
|
|
||||||
|
|
||||||
--allow hostile mobs to signal to other mobs
|
|
||||||
--to switch from neutal passive to neutral hostile
|
|
||||||
mobs.group_attack_initialization = function(self)
|
|
||||||
|
|
||||||
--get basic data
|
|
||||||
local friends_list
|
|
||||||
|
|
||||||
if self.group_attack == true then
|
|
||||||
friends_list = {self.name}
|
|
||||||
else
|
|
||||||
friends_list = table_copy(self.group_attack)
|
|
||||||
end
|
|
||||||
|
|
||||||
local objects_in_area = minetest_get_objects_inside_radius(self.object:get_pos(), self.view_range)
|
|
||||||
|
|
||||||
--get the player's name
|
|
||||||
local name = self.attacking:get_player_name()
|
|
||||||
|
|
||||||
--re-use local variable
|
|
||||||
local detected_mob
|
|
||||||
|
|
||||||
--run through mobs in viewing distance
|
|
||||||
for _,object in pairs(objects_in_area) do
|
|
||||||
if object and object:get_luaentity() then
|
|
||||||
detected_mob = object:get_luaentity()
|
|
||||||
-- only alert members of same mob or friends
|
|
||||||
if detected_mob._cmi_is_mob and detected_mob.state ~= "attack" and detected_mob.owner ~= name then
|
|
||||||
if detected_mob.name == self.name then
|
|
||||||
turn_hostile(self,detected_mob)
|
|
||||||
else
|
|
||||||
for _,id in pairs(friends_list) do
|
|
||||||
if detected_mob.name == id then
|
|
||||||
turn_hostile(self,detected_mob)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--THIS NEEDS TO BE RE-IMPLEMENTED AS A GLOBAL HIT IN MOB_PUNCH!!
|
|
||||||
-- have owned mobs attack player threat
|
|
||||||
--if obj.owner == name and obj.owner_loyal then
|
|
||||||
-- do_attack(obj, self.object)
|
|
||||||
--end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if within physical map limits (-30911 to 30927)
|
|
||||||
-- within_limits, wmin, wmax = nil, -30913, 30928
|
|
||||||
mobs.within_limits = function(pos, radius)
|
|
||||||
local wmin, wmax
|
|
||||||
if mcl_vars then
|
|
||||||
if mcl_vars.mapgen_edge_min and mcl_vars.mapgen_edge_max then
|
|
||||||
wmin, wmax = mcl_vars.mapgen_edge_min, mcl_vars.mapgen_edge_max
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return pos
|
|
||||||
and (pos.x - radius) > wmin and (pos.x + radius) < wmax
|
|
||||||
and (pos.y - radius) > wmin and (pos.y + radius) < wmax
|
|
||||||
and (pos.z - radius) > wmin and (pos.z + radius) < wmax
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get node but use fallback for nil or unknown
|
|
||||||
mobs.node_ok = function(pos, fallback)
|
|
||||||
|
|
||||||
fallback = fallback or mobs.fallback_node
|
|
||||||
|
|
||||||
local node = minetest_get_node_or_nil(pos)
|
|
||||||
|
|
||||||
if node and minetest_registered_nodes[node.name] then
|
|
||||||
return node
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest_registered_nodes[fallback]
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--a teleport functoin
|
|
||||||
mobs.teleport = function(self, target)
|
|
||||||
if self.do_teleport then
|
|
||||||
if self.do_teleport(self, target) == false then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--a function used for despawning mobs
|
|
||||||
mobs.check_for_player_within_area = function(self, radius)
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
--get players in radius
|
|
||||||
for _,player in pairs(minetest_get_connected_players()) do
|
|
||||||
if player and player:get_hp() > 0 then
|
|
||||||
local pos2 = player:get_pos()
|
|
||||||
local distance = vector_distance(pos1,pos2)
|
|
||||||
if distance < radius then
|
|
||||||
--found a player
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--did not find a player
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--a simple helper function for mobs following
|
|
||||||
mobs.get_2d_distance = function(pos1,pos2)
|
|
||||||
pos1.y = 0
|
|
||||||
pos2.y = 0
|
|
||||||
return vector_distance(pos1, pos2)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- fall damage onto solid ground
|
|
||||||
mobs.calculate_fall_damage = function(self)
|
|
||||||
if self.old_velocity and self.old_velocity.y < -7 and self.object:get_velocity().y == 0 then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if vel then
|
|
||||||
local damage = math_abs(self.old_velocity.y + 7) * 2
|
|
||||||
self.pause_timer = 0.4
|
|
||||||
self.health = self.health - damage
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,78 +0,0 @@
|
||||||
--this is from https://github.com/HybridDog/builtin_item/blob/e6dfd9dce86503b3cbd1474257eca5f6f6ca71c2/init.lua#L50
|
|
||||||
local
|
|
||||||
minetest,vector,math,pairs,minetest_get_node,vector_subtract,minetest_registered_nodes
|
|
||||||
=
|
|
||||||
minetest,vector,math,pairs,minetest.get_node,vector.subtract,minetest.registered_nodes
|
|
||||||
|
|
||||||
local tab
|
|
||||||
local n
|
|
||||||
local function get_nodes(pos)
|
|
||||||
tab,n = {},1
|
|
||||||
for i = -1,1,2 do
|
|
||||||
for _,p in pairs({
|
|
||||||
{x=pos.x+i, y=pos.y, z=pos.z},
|
|
||||||
{x=pos.x, y=pos.y, z=pos.z+i}
|
|
||||||
}) do
|
|
||||||
tab[n] = {p, minetest_get_node(p)}
|
|
||||||
n = n+1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return tab
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local data
|
|
||||||
local param2
|
|
||||||
local nd
|
|
||||||
local par2
|
|
||||||
local name
|
|
||||||
local tmp
|
|
||||||
local c_node
|
|
||||||
function mobs.get_flowing_dir(pos)
|
|
||||||
c_node = minetest_get_node(pos).name
|
|
||||||
if c_node ~= "mcl_core:water_flowing" and c_node ~= "mcl_core:water" then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
data = get_nodes(pos)
|
|
||||||
param2 = minetest_get_node(pos).param2
|
|
||||||
if param2 > 7 then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
if c_node == "mcl_core:water" then
|
|
||||||
for _,i in pairs(data) do
|
|
||||||
nd = i[2]
|
|
||||||
name = nd.name
|
|
||||||
par2 = nd.param2
|
|
||||||
if name == "mcl_core:water_flowing" and par2 == 7 then
|
|
||||||
return(vector_subtract(i[1],pos))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for _,i in pairs(data) do
|
|
||||||
nd = i[2]
|
|
||||||
name = nd.name
|
|
||||||
par2 = nd.param2
|
|
||||||
if name == "mcl_core:water_flowing" and par2 < param2 then
|
|
||||||
return(vector_subtract(i[1],pos))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for _,i in pairs(data) do
|
|
||||||
nd = i[2]
|
|
||||||
name = nd.name
|
|
||||||
par2 = nd.param2
|
|
||||||
if name == "mcl_core:water_flowing" and par2 >= 11 then
|
|
||||||
return(vector_subtract(i[1],pos))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for _,i in pairs(data) do
|
|
||||||
nd = i[2]
|
|
||||||
name = nd.name
|
|
||||||
par2 = nd.param2
|
|
||||||
tmp = minetest_registered_nodes[name]
|
|
||||||
if tmp and not tmp.walkable and name ~= "mcl_core:water_flowing" and name ~= "mcl_core:water" then
|
|
||||||
return(vector_subtract(i[1],pos))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
|
|
@ -1,98 +0,0 @@
|
||||||
local math = math
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
--converts yaw to degrees
|
|
||||||
local degrees = function(yaw)
|
|
||||||
return yaw*180.0/math.pi
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.do_head_logic = function(self,dtime)
|
|
||||||
|
|
||||||
local player = minetest.get_player_by_name("singleplayer")
|
|
||||||
|
|
||||||
local look_at = player:get_pos()
|
|
||||||
look_at.y = look_at.y + player:get_properties().eye_height
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
local body_yaw = self.object:get_yaw()
|
|
||||||
|
|
||||||
local body_dir = minetest.yaw_to_dir(body_yaw)
|
|
||||||
|
|
||||||
pos.y = pos.y + self.head_height_offset
|
|
||||||
|
|
||||||
local head_offset = vector.multiply(body_dir, self.head_direction_offset)
|
|
||||||
|
|
||||||
pos = vector.add(pos, head_offset)
|
|
||||||
|
|
||||||
minetest.add_particle({
|
|
||||||
pos = pos,
|
|
||||||
velocity = {x=0, y=0, z=0},
|
|
||||||
acceleration = {x=0, y=0, z=0},
|
|
||||||
expirationtime = 0.2,
|
|
||||||
size = 1,
|
|
||||||
texture = "default_dirt.png",
|
|
||||||
})
|
|
||||||
|
|
||||||
local bone_pos = vector.new(0,0,0)
|
|
||||||
|
|
||||||
--(horizontal)
|
|
||||||
bone_pos.y = self.head_bone_pos_y
|
|
||||||
|
|
||||||
--(vertical)
|
|
||||||
bone_pos.z = self.head_bone_pos_z
|
|
||||||
|
|
||||||
--print(yaw)
|
|
||||||
|
|
||||||
--local _, bone_rot = self.object:get_bone_position("head")
|
|
||||||
|
|
||||||
--bone_rot.x = bone_rot.x + (dtime * 10)
|
|
||||||
--bone_rot.z = bone_rot.z + (dtime * 10)
|
|
||||||
|
|
||||||
local head_yaw = minetest.dir_to_yaw(vector.direction(pos,look_at)) - body_yaw
|
|
||||||
|
|
||||||
if self.reverse_head_yaw then
|
|
||||||
head_yaw = head_yaw * -1
|
|
||||||
end
|
|
||||||
|
|
||||||
--over rotation protection
|
|
||||||
--stops radians from going out of spec
|
|
||||||
if head_yaw > math.pi then
|
|
||||||
head_yaw = head_yaw - (math.pi * 2)
|
|
||||||
elseif head_yaw < -math.pi then
|
|
||||||
head_yaw = head_yaw + (math.pi * 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local check_failed = false
|
|
||||||
--upper check + 90 degrees or upper math.radians (3.14/2)
|
|
||||||
if head_yaw > math.pi - (math.pi/2) then
|
|
||||||
head_yaw = 0
|
|
||||||
check_failed = true
|
|
||||||
--lower check - 90 degrees or lower negative math.radians (-3.14/2)
|
|
||||||
elseif head_yaw < -math.pi + (math.pi/2) then
|
|
||||||
head_yaw = 0
|
|
||||||
check_failed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local head_pitch = 0
|
|
||||||
|
|
||||||
--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
|
|
||||||
--head_yaw = 0
|
|
||||||
--DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
|
|
||||||
|
|
||||||
if not check_failed then
|
|
||||||
head_pitch = minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(look_at.x,0,look_at.z)),0,pos.y-look_at.y))+(math.pi/2)
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.head_pitch_modifier then
|
|
||||||
head_pitch = head_pitch + self.head_pitch_modifier
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.swap_y_with_x then
|
|
||||||
self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),degrees(head_yaw),0))
|
|
||||||
else
|
|
||||||
self.object:set_bone_position(self.head_bone, bone_pos, vector.new(degrees(head_pitch),0,degrees(head_yaw)))
|
|
||||||
end
|
|
||||||
--set_bone_position([bone, position, rotation])
|
|
||||||
end
|
|
|
@ -1,276 +0,0 @@
|
||||||
local minetest_after = minetest.after
|
|
||||||
local minetest_sound_play = minetest.sound_play
|
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
|
||||||
|
|
||||||
local math = math
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
local MAX_MOB_NAME_LENGTH = 30
|
|
||||||
|
|
||||||
local mod_hunger = minetest.get_modpath("mcl_hunger")
|
|
||||||
|
|
||||||
mobs.feed_tame = function(self)
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Code to execute before custom on_rightclick handling
|
|
||||||
local function on_rightclick_prefix(self, clicker)
|
|
||||||
local item = clicker:get_wielded_item()
|
|
||||||
|
|
||||||
-- Name mob with nametag
|
|
||||||
if not self.ignores_nametag and item:get_name() == "mcl_mobs:nametag" then
|
|
||||||
|
|
||||||
local tag = item:get_meta():get_string("name")
|
|
||||||
if tag ~= "" then
|
|
||||||
if string.len(tag) > MAX_MOB_NAME_LENGTH then
|
|
||||||
tag = string.sub(tag, 1, MAX_MOB_NAME_LENGTH)
|
|
||||||
end
|
|
||||||
self.nametag = tag
|
|
||||||
|
|
||||||
mobs.update_tag(self)
|
|
||||||
|
|
||||||
if not mobs.is_creative(clicker:get_player_name()) then
|
|
||||||
item:take_item()
|
|
||||||
clicker:set_wielded_item(item)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- I have no idea what this does
|
|
||||||
mobs.create_mob_on_rightclick = function(on_rightclick)
|
|
||||||
return function(self, clicker)
|
|
||||||
--don't allow rightclicking dead mobs
|
|
||||||
if self.health <= 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local stop = on_rightclick_prefix(self, clicker)
|
|
||||||
if (not stop) and (on_rightclick) then
|
|
||||||
on_rightclick(self, clicker)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- deal damage and effects when mob punched
|
|
||||||
mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
|
||||||
--don't do anything if the mob is already dead
|
|
||||||
if self.health <= 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--neutral passive mobs switch to neutral hostile
|
|
||||||
if self.neutral then
|
|
||||||
--drop in variables for attacking (stops crash)
|
|
||||||
self.attacking = hitter
|
|
||||||
self.punch_timer = 0
|
|
||||||
self.hostile = true
|
|
||||||
--hostile_cooldown timer is initialized here
|
|
||||||
self.hostile_cooldown_timer = self.hostile_cooldown
|
|
||||||
|
|
||||||
--initialize the group attack (check for other mobs in area, make them neutral hostile)
|
|
||||||
if self.group_attack then
|
|
||||||
mobs.group_attack_initialization(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--turn skittish mobs away and RUN
|
|
||||||
if self.skittish then
|
|
||||||
|
|
||||||
self.state = "run"
|
|
||||||
|
|
||||||
self.run_timer = 5 --arbitrary 5 seconds
|
|
||||||
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
local pos2 = hitter:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
|
|
||||||
|
|
||||||
local dir = vector.direction(pos2,pos1)
|
|
||||||
|
|
||||||
local yaw = minetest_dir_to_yaw(dir)
|
|
||||||
|
|
||||||
self.yaw = yaw
|
|
||||||
end
|
|
||||||
|
|
||||||
-- custom punch function
|
|
||||||
if self.do_punch then
|
|
||||||
-- when false skip going any further
|
|
||||||
if self.do_punch(self, hitter, tflp, tool_capabilities, dir) == false then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--don't do damage until pause timer resets
|
|
||||||
if self.pause_timer > 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- error checking when mod profiling is enabled
|
|
||||||
if not tool_capabilities then
|
|
||||||
minetest.log("warning", "[mobs_mc] Mod profiling enabled, damage not enabled")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local is_player = hitter:is_player()
|
|
||||||
|
|
||||||
-- punch interval
|
|
||||||
local weapon = hitter:get_wielded_item()
|
|
||||||
|
|
||||||
--local punch_interval = 1.4
|
|
||||||
|
|
||||||
-- exhaust attacker
|
|
||||||
if mod_hunger and is_player then
|
|
||||||
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- calculate mob damage
|
|
||||||
local damage = 0
|
|
||||||
local armor = self.object:get_armor_groups() or {}
|
|
||||||
|
|
||||||
--calculate damage groups
|
|
||||||
for group,_ in pairs( (tool_capabilities.damage_groups or {}) ) do
|
|
||||||
damage = damage + (tool_capabilities.damage_groups[group] or 0) * ((armor[group] or 0) / 100.0)
|
|
||||||
end
|
|
||||||
|
|
||||||
if weapon then
|
|
||||||
local fire_aspect_level = mcl_enchanting.get_enchantment(weapon, "fire_aspect")
|
|
||||||
if fire_aspect_level > 0 then
|
|
||||||
mcl_burning.set_on_fire(self.object, fire_aspect_level * 4)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check for tool immunity or special damage
|
|
||||||
for n = 1, #self.immune_to do
|
|
||||||
if self.immune_to[n][1] == weapon:get_name() then
|
|
||||||
damage = self.immune_to[n][2] or 0
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- healing
|
|
||||||
if damage <= -1 then
|
|
||||||
self.health = self.health - math.floor(damage)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--if tool_capabilities then
|
|
||||||
-- punch_interval = tool_capabilities.full_punch_interval or 1.4
|
|
||||||
--end
|
|
||||||
|
|
||||||
-- add weapon wear manually
|
|
||||||
-- Required because we have custom health handling ("health" property)
|
|
||||||
--minetest_is_creative_enabled("") ~= true --removed for now
|
|
||||||
if tool_capabilities then
|
|
||||||
if tool_capabilities.punch_attack_uses then
|
|
||||||
-- Without this delay, the wear does not work. Quite hacky ...
|
|
||||||
minetest_after(0, function(name)
|
|
||||||
local player = minetest.get_player_by_name(name)
|
|
||||||
if not player then return end
|
|
||||||
local weapon = hitter:get_wielded_item(player)
|
|
||||||
local def = weapon:get_definition()
|
|
||||||
if def.tool_capabilities and def.tool_capabilities.punch_attack_uses then
|
|
||||||
local wear = math.floor(65535/tool_capabilities.punch_attack_uses)
|
|
||||||
weapon:add_wear(wear)
|
|
||||||
hitter:set_wielded_item(weapon)
|
|
||||||
end
|
|
||||||
end, hitter:get_player_name())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--if player is falling multiply damage by 1.5
|
|
||||||
--critical hit
|
|
||||||
if hitter:get_velocity().y < 0 then
|
|
||||||
damage = damage * 1.5
|
|
||||||
mobs.critical_effect(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately.
|
|
||||||
if damage >= 0.1 then
|
|
||||||
|
|
||||||
minetest_sound_play("default_punch", {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = 16
|
|
||||||
}, true)
|
|
||||||
|
|
||||||
-- do damage
|
|
||||||
self.health = self.health - damage
|
|
||||||
|
|
||||||
|
|
||||||
--0.4 seconds until you can hurt the mob again
|
|
||||||
self.pause_timer = 0.4
|
|
||||||
|
|
||||||
--don't do knockback from a rider
|
|
||||||
for _,obj in pairs(self.object:get_children()) do
|
|
||||||
if obj == hitter then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- knock back effect
|
|
||||||
local velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
--2d direction
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
pos1.y = 0
|
|
||||||
local pos2 = hitter:get_pos()
|
|
||||||
pos2.y = 0
|
|
||||||
|
|
||||||
local dir = vector.direction(pos2,pos1)
|
|
||||||
|
|
||||||
local up = 3
|
|
||||||
|
|
||||||
-- if already in air then dont go up anymore when hit
|
|
||||||
if velocity.y ~= 0 then
|
|
||||||
up = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--0.75 for perfect distance to not be too easy, and not be too hard
|
|
||||||
local multiplier = 0.75
|
|
||||||
|
|
||||||
-- check if tool already has specific knockback value
|
|
||||||
local knockback_enchant = mcl_enchanting.get_enchantment(hitter:get_wielded_item(), "knockback")
|
|
||||||
if knockback_enchant and knockback_enchant > 0 then
|
|
||||||
multiplier = knockback_enchant + 1 --(starts from 1, 1 would be no change)
|
|
||||||
end
|
|
||||||
|
|
||||||
--do this to sure you can punch a mob back when
|
|
||||||
--it's coming for you
|
|
||||||
if self.hostile then
|
|
||||||
multiplier = multiplier + 2
|
|
||||||
end
|
|
||||||
dir = vector.multiply(dir,multiplier)
|
|
||||||
dir.y = up
|
|
||||||
--add the velocity
|
|
||||||
self.object:add_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--do internal per mob projectile calculations
|
|
||||||
mobs.shoot_projectile = function(self)
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
--add mob eye height
|
|
||||||
pos1.y = pos1.y + self.eye_height
|
|
||||||
|
|
||||||
local pos2 = self.attacking:get_pos()
|
|
||||||
--add player eye height
|
|
||||||
pos2.y = pos2.y + self.attacking:get_properties().eye_height
|
|
||||||
|
|
||||||
--get direction
|
|
||||||
local dir = vector.direction(pos1,pos2)
|
|
||||||
|
|
||||||
--call internal shoot_arrow function
|
|
||||||
self.shoot_arrow(self,pos1,dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.update_tag = function(self)
|
|
||||||
self.object:set_properties({
|
|
||||||
nametag = self.nametag,
|
|
||||||
})
|
|
||||||
end
|
|
|
@ -1,150 +0,0 @@
|
||||||
local minetest_add_particlespawner = minetest.add_particlespawner
|
|
||||||
|
|
||||||
mobs.death_effect = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local yaw = self.object:get_yaw()
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
local min, max
|
|
||||||
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
|
||||||
amount = 50,
|
|
||||||
time = 0.0001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector.new(-0.5,0.5,-0.5),
|
|
||||||
maxvel = vector.new(0.5,1,0.5),
|
|
||||||
minexptime = 1.1,
|
|
||||||
maxexptime = 1.5,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "mcl_particles_mob_death.png", -- this particle looks strange
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.critical_effect = function(self)
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local yaw = self.object:get_yaw()
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
local min, max
|
|
||||||
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
|
||||||
amount = 10,
|
|
||||||
time = 0.0001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector.new(-1,1,-1),
|
|
||||||
maxvel = vector.new(1,3,1),
|
|
||||||
minexptime = 0.7,
|
|
||||||
maxexptime = 1,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "heart.png^[colorize:black:255",
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
--when feeding a mob
|
|
||||||
mobs.feed_effect = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local yaw = self.object:get_yaw()
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
local min, max
|
|
||||||
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
|
||||||
amount = 10,
|
|
||||||
time = 0.0001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector.new(-1,1,-1),
|
|
||||||
maxvel = vector.new(1,3,1),
|
|
||||||
minexptime = 0.7,
|
|
||||||
maxexptime = 1,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "heart.png^[colorize:gray:255",
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
--hearts when tamed
|
|
||||||
mobs.tamed_effect = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local yaw = self.object:get_yaw()
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
local min, max
|
|
||||||
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
|
||||||
amount = 30,
|
|
||||||
time = 0.0001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector.new(-1,1,-1),
|
|
||||||
maxvel = vector.new(1,3,1),
|
|
||||||
minexptime = 0.7,
|
|
||||||
maxexptime = 1,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "heart.png",
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
--hearts when breeding
|
|
||||||
mobs.breeding_effect = function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local yaw = self.object:get_yaw()
|
|
||||||
local collisionbox = self.object:get_properties().collisionbox
|
|
||||||
|
|
||||||
local min, max
|
|
||||||
|
|
||||||
if collisionbox then
|
|
||||||
min = {x=collisionbox[1], y=collisionbox[2], z=collisionbox[3]}
|
|
||||||
max = {x=collisionbox[4], y=collisionbox[5], z=collisionbox[6]}
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest_add_particlespawner({
|
|
||||||
amount = 2,
|
|
||||||
time = 0.0001,
|
|
||||||
minpos = vector.add(pos, min),
|
|
||||||
maxpos = vector.add(pos, max),
|
|
||||||
minvel = vector.new(-1,1,-1),
|
|
||||||
maxvel = vector.new(1,3,1),
|
|
||||||
minexptime = 0.7,
|
|
||||||
maxexptime = 1,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "heart.png",
|
|
||||||
})
|
|
||||||
end
|
|
|
@ -1,390 +0,0 @@
|
||||||
-- localize math functions
|
|
||||||
local math = math
|
|
||||||
local HALF_PI = math.pi / 2
|
|
||||||
local DOUBLE_PI = math.pi * 2
|
|
||||||
|
|
||||||
-- localize vector functions
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
local minetest_yaw_to_dir = minetest.yaw_to_dir
|
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
|
||||||
|
|
||||||
local DEFAULT_JUMP_HEIGHT = 5
|
|
||||||
local DEFAULT_FLOAT_SPEED = 4
|
|
||||||
local DEFAULT_CLIMB_SPEED = 3
|
|
||||||
|
|
||||||
mobs.stick_in_cobweb = function(self)
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = vector.multiply(vector.normalize(current_velocity), 0.4)
|
|
||||||
|
|
||||||
goal_velocity.y = -0.5
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is a generic float function
|
|
||||||
mobs.float = function(self)
|
|
||||||
|
|
||||||
local acceleration = self.object:get_acceleration()
|
|
||||||
|
|
||||||
if not acceleration then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if acceleration.y ~= 0 then
|
|
||||||
self.object:set_acceleration({x=0, y=0, z=0})
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = 0,
|
|
||||||
y = DEFAULT_FLOAT_SPEED,
|
|
||||||
z = 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity, current_velocity)
|
|
||||||
|
|
||||||
new_velocity_addition.x = 0
|
|
||||||
new_velocity_addition.z = 0
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--this is a generic climb function
|
|
||||||
mobs.climb = function(self)
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = 0,
|
|
||||||
y = DEFAULT_CLIMB_SPEED,
|
|
||||||
z = 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
new_velocity_addition.x = 0
|
|
||||||
new_velocity_addition.z = 0
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
_ _
|
|
||||||
| | | |
|
|
||||||
| | __ _ _ __ __| |
|
|
||||||
| | / _` | '_ \ / _` |
|
|
||||||
| |___| (_| | | | | (_| |
|
|
||||||
\_____/\__,_|_| |_|\__,_|
|
|
||||||
]]
|
|
||||||
|
|
||||||
|
|
||||||
-- move mob in facing direction
|
|
||||||
--this has been modified to be internal
|
|
||||||
--internal = lua (self.yaw)
|
|
||||||
--engine = c++ (self.object:get_yaw())
|
|
||||||
mobs.set_velocity = function(self, v)
|
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = (math.sin(yaw) * -v),
|
|
||||||
y = 0,
|
|
||||||
z = (math.cos(yaw) * v),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
|
||||||
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
|
||||||
end
|
|
||||||
|
|
||||||
new_velocity_addition.y = 0
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- calculate mob velocity
|
|
||||||
mobs.get_velocity = function(self)
|
|
||||||
|
|
||||||
local v = self.object:get_velocity()
|
|
||||||
|
|
||||||
v.y = 0
|
|
||||||
|
|
||||||
if v then
|
|
||||||
return vector.length(v)
|
|
||||||
end
|
|
||||||
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--make mobs jump
|
|
||||||
mobs.jump = function(self, velocity)
|
|
||||||
|
|
||||||
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--fallback velocity to allow modularity
|
|
||||||
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
|
||||||
|
|
||||||
self.object:add_velocity(vector.new(0,velocity,0))
|
|
||||||
end
|
|
||||||
|
|
||||||
--make mobs fall slowly
|
|
||||||
mobs.mob_fall_slow = function(self)
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = 0,
|
|
||||||
y = -2,
|
|
||||||
z = 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
new_velocity_addition.x = 0
|
|
||||||
new_velocity_addition.z = 0
|
|
||||||
|
|
||||||
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
|
||||||
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
|
||||||
end
|
|
||||||
|
|
||||||
new_velocity_addition.x = 0
|
|
||||||
new_velocity_addition.z = 0
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
_____ _
|
|
||||||
/ ___| (_)
|
|
||||||
\ `--.__ ___ _ __ ___
|
|
||||||
`--. \ \ /\ / / | '_ ` _ \
|
|
||||||
/\__/ /\ V V /| | | | | | |
|
|
||||||
\____/ \_/\_/ |_|_| |_| |_|
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--make mobs flop
|
|
||||||
mobs.flop = function(self, velocity)
|
|
||||||
|
|
||||||
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.set_velocity(self, 0)
|
|
||||||
|
|
||||||
--fallback velocity to allow modularity
|
|
||||||
velocity = velocity or DEFAULT_JUMP_HEIGHT
|
|
||||||
|
|
||||||
--create a random direction (2d yaw)
|
|
||||||
local dir = DOUBLE_PI * math.random()
|
|
||||||
|
|
||||||
--create a random force value
|
|
||||||
local force = math.random(0,3) + math.random()
|
|
||||||
|
|
||||||
--convert the yaw to a direction vector then multiply it times the force
|
|
||||||
local final_additional_force = vector.multiply(minetest_yaw_to_dir(dir), force)
|
|
||||||
|
|
||||||
--place in the "flop" velocity to make the mob flop
|
|
||||||
final_additional_force.y = velocity
|
|
||||||
|
|
||||||
self.object:add_velocity(final_additional_force)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- move mob in facing direction
|
|
||||||
--this has been modified to be internal
|
|
||||||
--internal = lua (self.yaw)
|
|
||||||
--engine = c++ (self.object:get_yaw())
|
|
||||||
mobs.set_swim_velocity = function(self, v)
|
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
|
||||||
local pitch = (self.pitch or 0)
|
|
||||||
|
|
||||||
if v == 0 then
|
|
||||||
pitch = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = (math.sin(yaw) * -v),
|
|
||||||
y = pitch,
|
|
||||||
z = (math.cos(yaw) * v),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
|
||||||
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
|
||||||
end
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
______ _
|
|
||||||
| ___| |
|
|
||||||
| |_ | |_ _
|
|
||||||
| _| | | | | |
|
|
||||||
| | | | |_| |
|
|
||||||
\_| |_|\__, |
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
]]--
|
|
||||||
|
|
||||||
-- move mob in facing direction
|
|
||||||
--this has been modified to be internal
|
|
||||||
--internal = lua (self.yaw)
|
|
||||||
--engine = c++ (self.object:get_yaw())
|
|
||||||
mobs.set_fly_velocity = function(self, v)
|
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
|
||||||
local pitch = (self.pitch or 0)
|
|
||||||
|
|
||||||
if v == 0 then
|
|
||||||
pitch = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = (math.sin(yaw) * -v),
|
|
||||||
y = pitch,
|
|
||||||
z = (math.cos(yaw) * v),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
|
||||||
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
|
||||||
end
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--a quick and simple pitch calculation between two vector positions
|
|
||||||
mobs.calculate_pitch = function(pos1, pos2)
|
|
||||||
|
|
||||||
if pos1 == nil or pos2 == nil then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest_dir_to_yaw(vector.new(vector.distance(vector.new(pos1.x,0,pos1.z),vector.new(pos2.x,0,pos2.z)),0,pos1.y - pos2.y)) + HALF_PI
|
|
||||||
end
|
|
||||||
|
|
||||||
--make mobs fly up or down based on their y difference
|
|
||||||
mobs.set_pitch_while_attacking = function(self)
|
|
||||||
local pos1 = self.object:get_pos()
|
|
||||||
local pos2 = self.attacking:get_pos()
|
|
||||||
|
|
||||||
local pitch = mobs.calculate_pitch(pos2,pos1)
|
|
||||||
|
|
||||||
self.pitch = pitch
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
___
|
|
||||||
|_ |
|
|
||||||
| |_ _ _ __ ___ _ __
|
|
||||||
| | | | | '_ ` _ \| '_ \
|
|
||||||
/\__/ / |_| | | | | | | |_) |
|
|
||||||
\____/ \__,_|_| |_| |_| .__/
|
|
||||||
| |
|
|
||||||
|_|
|
|
||||||
]]--
|
|
||||||
|
|
||||||
--special mob jump movement
|
|
||||||
mobs.jump_move = function(self, velocity)
|
|
||||||
|
|
||||||
if self.object:get_velocity().y ~= 0 or not self.old_velocity or (self.old_velocity and self.old_velocity.y > 0) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--make the mob stick for a split second
|
|
||||||
mobs.set_velocity(self,0)
|
|
||||||
|
|
||||||
--fallback velocity to allow modularity
|
|
||||||
local jump_height = DEFAULT_JUMP_HEIGHT
|
|
||||||
|
|
||||||
local yaw = (self.yaw or 0)
|
|
||||||
|
|
||||||
local current_velocity = self.object:get_velocity()
|
|
||||||
|
|
||||||
local goal_velocity = {
|
|
||||||
x = (math.sin(yaw) * -velocity),
|
|
||||||
y = jump_height,
|
|
||||||
z = (math.cos(yaw) * velocity),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
local new_velocity_addition = vector.subtract(goal_velocity,current_velocity)
|
|
||||||
|
|
||||||
if vector.length(new_velocity_addition) > vector.length(goal_velocity) then
|
|
||||||
vector.multiply(new_velocity_addition, (vector.length(goal_velocity) / vector.length(new_velocity_addition)))
|
|
||||||
end
|
|
||||||
|
|
||||||
--smooths out mobs a bit
|
|
||||||
if vector.length(new_velocity_addition) >= 0.0001 then
|
|
||||||
self.object:add_velocity(new_velocity_addition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--make it so mobs do not glitch out and freak out
|
|
||||||
--when moving around over nodes
|
|
||||||
mobs.swap_auto_step_height_adjust = function(self)
|
|
||||||
local y_vel = self.object:get_velocity().y
|
|
||||||
|
|
||||||
if y_vel == 0 and self.stepheight ~= self.stepheight_backup then
|
|
||||||
self.stepheight = self.stepheight_backup
|
|
||||||
elseif y_vel ~= 0 and self.stepheight ~= 0 then
|
|
||||||
self.stepheight = 0
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,43 +0,0 @@
|
||||||
local GRAVITY = minetest.settings:get("movement_gravity")-- + 9.81
|
|
||||||
|
|
||||||
mobs.shoot_projectile_handling = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable, gravity)
|
|
||||||
local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity")
|
|
||||||
if power == nil then
|
|
||||||
power = 19
|
|
||||||
end
|
|
||||||
if damage == nil then
|
|
||||||
damage = 3
|
|
||||||
end
|
|
||||||
|
|
||||||
gravity = gravity or -GRAVITY
|
|
||||||
|
|
||||||
local knockback
|
|
||||||
if bow_stack then
|
|
||||||
local enchantments = mcl_enchanting.get_enchantments(bow_stack)
|
|
||||||
if enchantments.power then
|
|
||||||
damage = damage + (enchantments.power + 1) / 4
|
|
||||||
end
|
|
||||||
if enchantments.punch then
|
|
||||||
knockback = enchantments.punch * 3
|
|
||||||
end
|
|
||||||
if enchantments.flame then
|
|
||||||
mcl_burning.set_on_fire(obj, math.huge)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power})
|
|
||||||
obj:set_acceleration({x=0, y=gravity, z=0})
|
|
||||||
obj:set_yaw(yaw-math.pi/2)
|
|
||||||
local le = obj:get_luaentity()
|
|
||||||
le._shooter = shooter
|
|
||||||
le._damage = damage
|
|
||||||
le._is_critical = is_critical
|
|
||||||
le._startpos = pos
|
|
||||||
le._knockback = knockback
|
|
||||||
le._collectable = collectable
|
|
||||||
|
|
||||||
--play custom shoot sound
|
|
||||||
if shooter and shooter.shoot_sound then
|
|
||||||
minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true)
|
|
||||||
end
|
|
||||||
return obj
|
|
||||||
end
|
|
|
@ -1,224 +0,0 @@
|
||||||
local math_random = math.random
|
|
||||||
|
|
||||||
local minetest_settings = minetest.settings
|
|
||||||
|
|
||||||
-- CMI support check
|
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
|
||||||
|
|
||||||
-- get entity staticdata
|
|
||||||
mobs.mob_staticdata = function(self)
|
|
||||||
--despawn mechanism
|
|
||||||
--don't despawned tamed or bred mobs
|
|
||||||
if not self.tamed and not self.bred then
|
|
||||||
if not mobs.check_for_player_within_area(self, 64) then
|
|
||||||
--print("removing SERIALIZED!")
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.remove_ok = true
|
|
||||||
self.attack = nil
|
|
||||||
self.following = nil
|
|
||||||
|
|
||||||
if use_cmi then
|
|
||||||
self.serialized_cmi_components = cmi.serialize_components(self._cmi_components)
|
|
||||||
end
|
|
||||||
|
|
||||||
local tmp = {}
|
|
||||||
|
|
||||||
for _,stat in pairs(self) do
|
|
||||||
|
|
||||||
local t = type(stat)
|
|
||||||
|
|
||||||
if t ~= "function"
|
|
||||||
and t ~= "nil"
|
|
||||||
and t ~= "userdata"
|
|
||||||
and _ ~= "_cmi_components" then
|
|
||||||
tmp[_] = self[_]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest.serialize(tmp)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- activate mob and reload settings
|
|
||||||
mobs.mob_activate = function(self, staticdata, def, dtime)
|
|
||||||
|
|
||||||
-- remove monsters in peaceful mode
|
|
||||||
if self.type == "monster" and minetest_settings:get_bool("only_peaceful_mobs", false) then
|
|
||||||
mcl_burning.extinguish(self.object)
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- load entity variables
|
|
||||||
local tmp = minetest.deserialize(staticdata)
|
|
||||||
|
|
||||||
if tmp then
|
|
||||||
for _,stat in pairs(tmp) do
|
|
||||||
self[_] = stat
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--set up wandering
|
|
||||||
if not self.wandering then
|
|
||||||
self.wandering = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--clear animation
|
|
||||||
self.current_animation = nil
|
|
||||||
|
|
||||||
-- select random texture, set model and size
|
|
||||||
if not self.base_texture then
|
|
||||||
|
|
||||||
-- compatiblity with old simple mobs textures
|
|
||||||
if type(def.textures[1]) == "string" then
|
|
||||||
def.textures = {def.textures}
|
|
||||||
end
|
|
||||||
|
|
||||||
self.base_texture = def.textures[math_random(1, #def.textures)]
|
|
||||||
self.base_mesh = def.mesh
|
|
||||||
self.base_size = self.visual_size
|
|
||||||
self.base_colbox = self.collisionbox
|
|
||||||
self.base_selbox = self.selectionbox
|
|
||||||
end
|
|
||||||
|
|
||||||
-- for current mobs that dont have this set
|
|
||||||
if not self.base_selbox then
|
|
||||||
self.base_selbox = self.selectionbox or self.base_colbox
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set texture, model and size
|
|
||||||
local textures = self.base_texture
|
|
||||||
local mesh = self.base_mesh
|
|
||||||
local vis_size = self.base_size
|
|
||||||
local colbox = self.base_colbox
|
|
||||||
local selbox = self.base_selbox
|
|
||||||
|
|
||||||
-- specific texture if gotten
|
|
||||||
if self.gotten == true
|
|
||||||
and def.gotten_texture then
|
|
||||||
textures = def.gotten_texture
|
|
||||||
end
|
|
||||||
|
|
||||||
-- specific mesh if gotten
|
|
||||||
if self.gotten == true
|
|
||||||
and def.gotten_mesh then
|
|
||||||
mesh = def.gotten_mesh
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set baby mobs to half size
|
|
||||||
if self.baby == true then
|
|
||||||
|
|
||||||
vis_size = {
|
|
||||||
x = self.base_size.x * self.baby_size,
|
|
||||||
y = self.base_size.y * self.baby_size,
|
|
||||||
}
|
|
||||||
|
|
||||||
if def.child_texture then
|
|
||||||
textures = def.child_texture[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
colbox = {
|
|
||||||
self.base_colbox[1] * self.baby_size,
|
|
||||||
self.base_colbox[2] * self.baby_size,
|
|
||||||
self.base_colbox[3] * self.baby_size,
|
|
||||||
self.base_colbox[4] * self.baby_size,
|
|
||||||
self.base_colbox[5] * self.baby_size,
|
|
||||||
self.base_colbox[6] * self.baby_size
|
|
||||||
}
|
|
||||||
selbox = {
|
|
||||||
self.base_selbox[1] * self.baby_size,
|
|
||||||
self.base_selbox[2] * self.baby_size,
|
|
||||||
self.base_selbox[3] * self.baby_size,
|
|
||||||
self.base_selbox[4] * self.baby_size,
|
|
||||||
self.base_selbox[5] * self.baby_size,
|
|
||||||
self.base_selbox[6] * self.baby_size
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
--stop mobs from reviving
|
|
||||||
if not self.dead and not self.health then
|
|
||||||
self.health = math_random (self.hp_min, self.hp_max)
|
|
||||||
end
|
|
||||||
|
|
||||||
if not self.random_sound_timer then
|
|
||||||
self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max)
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.breath == nil then
|
|
||||||
self.breath = self.breath_max
|
|
||||||
end
|
|
||||||
|
|
||||||
-- pathfinding init
|
|
||||||
self.path = {}
|
|
||||||
self.path.way = {} -- path to follow, table of positions
|
|
||||||
self.path.lastpos = {x = 0, y = 0, z = 0}
|
|
||||||
self.path.stuck = false
|
|
||||||
self.path.following = false -- currently following path?
|
|
||||||
self.path.stuck_timer = 0 -- if stuck for too long search for path
|
|
||||||
|
|
||||||
-- Armor groups
|
|
||||||
-- immortal=1 because we use custom health
|
|
||||||
-- handling (using "health" property)
|
|
||||||
local armor
|
|
||||||
if type(self.armor) == "table" then
|
|
||||||
armor = table.copy(self.armor)
|
|
||||||
armor.immortal = 1
|
|
||||||
else
|
|
||||||
armor = {immortal=1, fleshy = self.armor}
|
|
||||||
end
|
|
||||||
self.object:set_armor_groups(armor)
|
|
||||||
self.old_y = self.object:get_pos().y
|
|
||||||
self.old_health = self.health
|
|
||||||
self.sounds.distance = self.sounds.distance or 10
|
|
||||||
self.textures = textures
|
|
||||||
self.mesh = mesh
|
|
||||||
self.collisionbox = colbox
|
|
||||||
self.selectionbox = selbox
|
|
||||||
self.visual_size = vis_size
|
|
||||||
self.standing_in = "ignore"
|
|
||||||
self.standing_on = "ignore"
|
|
||||||
self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time
|
|
||||||
self.opinion_sound_cooloff = 0 -- used to prevent sound spam of particular sound types
|
|
||||||
|
|
||||||
self.texture_mods = {}
|
|
||||||
|
|
||||||
self.v_start = false
|
|
||||||
self.timer = 0
|
|
||||||
self.blinktimer = 0
|
|
||||||
self.blinkstatus = false
|
|
||||||
|
|
||||||
|
|
||||||
--continue mob effect on server restart
|
|
||||||
if self.dead or self.health <= 0 then
|
|
||||||
self.object:set_texture_mod("^[colorize:red:120")
|
|
||||||
else
|
|
||||||
self.object:set_texture_mod("")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set anything changed above
|
|
||||||
self.object:set_properties(self)
|
|
||||||
|
|
||||||
--update_tag(self)
|
|
||||||
--mobs.set_animation(self, "stand")
|
|
||||||
|
|
||||||
-- run on_spawn function if found
|
|
||||||
if self.on_spawn and not self.on_spawn_run then
|
|
||||||
if self.on_spawn(self) then
|
|
||||||
self.on_spawn_run = true -- if true, set flag to run once only
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- run after_activate
|
|
||||||
if def.after_activate then
|
|
||||||
def.after_activate(self, staticdata, def, dtime)
|
|
||||||
end
|
|
||||||
|
|
||||||
if use_cmi then
|
|
||||||
self._cmi_components = cmi.activate_components(self.serialized_cmi_components)
|
|
||||||
cmi.notify_activate(self.object, dtime)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,59 +0,0 @@
|
||||||
local math_random = math.random
|
|
||||||
|
|
||||||
|
|
||||||
--generic call for sound handler for mobs (data access)
|
|
||||||
mobs.play_sound = function(self,sound)
|
|
||||||
local soundinfo = self.sounds
|
|
||||||
|
|
||||||
if not soundinfo then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local play_sound = soundinfo[sound]
|
|
||||||
|
|
||||||
if not play_sound then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
mobs.play_sound_handler(self, play_sound)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--generic sound handler for mobs
|
|
||||||
mobs.play_sound_handler = function(self, sound)
|
|
||||||
local pitch = (100 + math_random(-15,15) + math_random()) / 100
|
|
||||||
local distance = self.sounds.distance or 16
|
|
||||||
|
|
||||||
minetest.sound_play(sound, {
|
|
||||||
object = self.object,
|
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = distance,
|
|
||||||
pitch = pitch,
|
|
||||||
}, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--random sound timing handler
|
|
||||||
mobs.random_sound_handling = function(self,dtime)
|
|
||||||
|
|
||||||
self.random_sound_timer = self.random_sound_timer - dtime
|
|
||||||
|
|
||||||
--play sound and reset timer
|
|
||||||
if self.random_sound_timer <= 0 then
|
|
||||||
mobs.play_sound(self,"random")
|
|
||||||
self.random_sound_timer = math_random(self.random_sound_timer_min,self.random_sound_timer_max)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--used for playing a non-mob internal sound at random pitches
|
|
||||||
mobs.play_sound_specific = function(self,soundname)
|
|
||||||
local pitch = (100 + math_random(-15,15) + math_random()) / 100
|
|
||||||
local distance = self.sounds.distance or 16
|
|
||||||
|
|
||||||
minetest.sound_play(soundname, {
|
|
||||||
object = self.object,
|
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = distance,
|
|
||||||
pitch = pitch,
|
|
||||||
}, true)
|
|
||||||
end
|
|
|
@ -1,709 +0,0 @@
|
||||||
--lua locals
|
|
||||||
local get_node = minetest.get_node
|
|
||||||
local get_item_group = minetest.get_item_group
|
|
||||||
local get_node_light = minetest.get_node_light
|
|
||||||
local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
|
||||||
local get_biome_name = minetest.get_biome_name
|
|
||||||
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
|
||||||
local get_connected_players = minetest.get_connected_players
|
|
||||||
|
|
||||||
|
|
||||||
local math_random = math.random
|
|
||||||
local math_floor = math.floor
|
|
||||||
--local max = math.max
|
|
||||||
|
|
||||||
--local vector_distance = vector.distance
|
|
||||||
local vector_new = vector.new
|
|
||||||
local vector_floor = vector.floor
|
|
||||||
|
|
||||||
local table_copy = table.copy
|
|
||||||
local table_remove = table.remove
|
|
||||||
|
|
||||||
local pairs = pairs
|
|
||||||
|
|
||||||
-- range for mob count
|
|
||||||
local aoc_range = 48
|
|
||||||
|
|
||||||
--do mobs spawn?
|
|
||||||
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
|
||||||
|
|
||||||
--[[
|
|
||||||
|
|
||||||
THIS IS THE BIG LIST OF ALL BIOMES - used for programming/updating mobs
|
|
||||||
|
|
||||||
underground:
|
|
||||||
"FlowerForest_underground",
|
|
||||||
"JungleEdge_underground",local spawning_position = spawning_position_list[math.random(1,#spawning_position_list)]
|
|
||||||
"ColdTaiga_underground",
|
|
||||||
"IcePlains_underground",
|
|
||||||
"IcePlainsSpikes_underground",
|
|
||||||
"MegaTaiga_underground",
|
|
||||||
"Taiga_underground",
|
|
||||||
"ExtremeHills+_underground",
|
|
||||||
"JungleM_underground",
|
|
||||||
"ExtremeHillsM_underground",
|
|
||||||
"JungleEdgeM_underground",
|
|
||||||
|
|
||||||
ocean:
|
|
||||||
"RoofedForest_ocean",
|
|
||||||
"JungleEdgeM_ocean",
|
|
||||||
"BirchForestM_ocean",
|
|
||||||
"BirchForest_ocean",
|
|
||||||
"IcePlains_deep_ocean",
|
|
||||||
"Jungle_deep_ocean",
|
|
||||||
"Savanna_ocean",
|
|
||||||
"MesaPlateauF_ocean",
|
|
||||||
"ExtremeHillsM_deep_ocean",
|
|
||||||
"Savanna_deep_ocean",
|
|
||||||
"SunflowerPlains_ocean",
|
|
||||||
"Swampland_deep_ocean",
|
|
||||||
"Swampland_ocean",
|
|
||||||
"MegaSpruceTaiga_deep_ocean",
|
|
||||||
"ExtremeHillsM_ocean",
|
|
||||||
"JungleEdgeM_deep_ocean",
|
|
||||||
"SunflowerPlains_deep_ocean",
|
|
||||||
"BirchForest_deep_ocean",
|
|
||||||
"IcePlainsSpikes_ocean",
|
|
||||||
"Mesa_ocean",
|
|
||||||
"StoneBeach_ocean",
|
|
||||||
"Plains_deep_ocean",
|
|
||||||
"JungleEdge_deep_ocean",
|
|
||||||
"SavannaM_deep_ocean",
|
|
||||||
"Desert_deep_ocean",
|
|
||||||
"Mesa_deep_ocean",
|
|
||||||
"ColdTaiga_deep_ocean",
|
|
||||||
"Plains_ocean",
|
|
||||||
"MesaPlateauFM_ocean",
|
|
||||||
"Forest_deep_ocean",
|
|
||||||
"JungleM_deep_ocean",
|
|
||||||
"FlowerForest_deep_ocean",
|
|
||||||
"MushroomIsland_ocean",
|
|
||||||
"MegaTaiga_ocean",
|
|
||||||
"StoneBeach_deep_ocean",
|
|
||||||
"IcePlainsSpikes_deep_ocean",
|
|
||||||
"ColdTaiga_ocean",
|
|
||||||
"SavannaM_ocean",
|
|
||||||
"MesaPlateauF_deep_ocean",
|
|
||||||
"MesaBryce_deep_ocean",
|
|
||||||
"ExtremeHills+_deep_ocean",
|
|
||||||
"ExtremeHills_ocean",
|
|
||||||
"MushroomIsland_deep_ocean",
|
|
||||||
"Forest_ocean",
|
|
||||||
"MegaTaiga_deep_ocean",
|
|
||||||
"JungleEdge_ocean",
|
|
||||||
"MesaBryce_ocean",
|
|
||||||
"MegaSpruceTaiga_ocean",
|
|
||||||
"ExtremeHills+_ocean",
|
|
||||||
"Jungle_ocean",
|
|
||||||
"RoofedForest_deep_ocean",
|
|
||||||
"IcePlains_ocean",
|
|
||||||
"FlowerForest_ocean",
|
|
||||||
"ExtremeHills_deep_ocean",
|
|
||||||
"MesaPlateauFM_deep_ocean",
|
|
||||||
"Desert_ocean",
|
|
||||||
"Taiga_ocean",
|
|
||||||
"BirchForestM_deep_ocean",
|
|
||||||
"Taiga_deep_ocean",
|
|
||||||
"JungleM_ocean",
|
|
||||||
|
|
||||||
water or beach?
|
|
||||||
"MesaPlateauFM_sandlevel",
|
|
||||||
"MesaPlateauF_sandlevel",
|
|
||||||
"MesaBryce_sandlevel",
|
|
||||||
"Mesa_sandlevel",
|
|
||||||
|
|
||||||
beach:
|
|
||||||
"FlowerForest_beach",
|
|
||||||
"Forest_beach",
|
|
||||||
"StoneBeach",
|
|
||||||
"ColdTaiga_beach_water",
|
|
||||||
"Taiga_beach",
|
|
||||||
"Savanna_beach",
|
|
||||||
"Plains_beach",
|
|
||||||
"ExtremeHills_beach",
|
|
||||||
"ColdTaiga_beach",
|
|
||||||
"Swampland_shore",
|
|
||||||
"MushroomIslandShore",
|
|
||||||
"JungleM_shore",
|
|
||||||
"Jungle_shore",
|
|
||||||
|
|
||||||
dimension biome:
|
|
||||||
"Nether",
|
|
||||||
"End",
|
|
||||||
|
|
||||||
Overworld regular:
|
|
||||||
"Mesa",
|
|
||||||
"FlowerForest",
|
|
||||||
"Swampland",
|
|
||||||
"Taiga",
|
|
||||||
"ExtremeHills",
|
|
||||||
"Jungle",
|
|
||||||
"Savanna",
|
|
||||||
"BirchForest",
|
|
||||||
"MegaSpruceTaiga",
|
|
||||||
"MegaTaiga",
|
|
||||||
"ExtremeHills+",
|
|
||||||
"Forest",
|
|
||||||
"Plains",
|
|
||||||
"Desert",
|
|
||||||
"ColdTaiga",
|
|
||||||
"MushroomIsland",
|
|
||||||
"IcePlainsSpikes",
|
|
||||||
"SunflowerPlains",
|
|
||||||
"IcePlains",
|
|
||||||
"RoofedForest",
|
|
||||||
"ExtremeHills+_snowtop",
|
|
||||||
"MesaPlateauFM_grasstop",
|
|
||||||
"JungleEdgeM",
|
|
||||||
"ExtremeHillsM",
|
|
||||||
"JungleM",
|
|
||||||
"BirchForestM",
|
|
||||||
"MesaPlateauF",
|
|
||||||
"MesaPlateauFM",
|
|
||||||
"MesaPlateauF_grasstop",
|
|
||||||
"MesaBryce",
|
|
||||||
"JungleEdge",
|
|
||||||
"SavannaM",
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- count how many mobs are in an area
|
|
||||||
local function count_mobs(pos)
|
|
||||||
local num = 0
|
|
||||||
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
|
|
||||||
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
|
|
||||||
num = num + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return num
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- global functions
|
|
||||||
|
|
||||||
function mobs:spawn_abm_check(pos, node, name)
|
|
||||||
-- global function to add additional spawn checks
|
|
||||||
-- return true to stop spawning mob
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
Custom elements changed:
|
|
||||||
|
|
||||||
name:
|
|
||||||
the mobs name
|
|
||||||
|
|
||||||
dimension:
|
|
||||||
"overworld"
|
|
||||||
"nether"
|
|
||||||
"end"
|
|
||||||
|
|
||||||
types of spawning:
|
|
||||||
"water"
|
|
||||||
"ground"
|
|
||||||
"lava"
|
|
||||||
|
|
||||||
biomes: tells the spawner to allow certain mobs to spawn in certain biomes
|
|
||||||
{"this", "that", "grasslands", "whatever"}
|
|
||||||
|
|
||||||
|
|
||||||
what is aoc??? objects in area
|
|
||||||
|
|
||||||
WARNING: BIOME INTEGRATION NEEDED -> How to get biome through lua??
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
--this is where all of the spawning information is kept
|
|
||||||
local spawn_dictionary = {}
|
|
||||||
|
|
||||||
function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
|
|
||||||
|
|
||||||
--print(dump(biomes))
|
|
||||||
|
|
||||||
-- Do mobs spawn at all?
|
|
||||||
if true or not mobs_spawn then --MOBSTUDY disable natural spawning of old mobs(redo)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- chance/spawn number override in minetest.conf for registered mob
|
|
||||||
local numbers = minetest.settings:get(name)
|
|
||||||
|
|
||||||
if numbers then
|
|
||||||
numbers = numbers:split(",")
|
|
||||||
chance = tonumber(numbers[1]) or chance
|
|
||||||
aoc = tonumber(numbers[2]) or aoc
|
|
||||||
|
|
||||||
if chance == 0 then
|
|
||||||
minetest.log("warning", string.format("[mobs] %s has spawning disabled", name))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.log("action",
|
|
||||||
string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc))
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
local function spawn_action(pos, node, active_object_count, active_object_count_wider, name)
|
|
||||||
|
|
||||||
local orig_pos = table.copy(pos)
|
|
||||||
-- is mob actually registered?
|
|
||||||
if not mobs.spawning_mobs[name]
|
|
||||||
or not minetest.registered_entities[name] then
|
|
||||||
minetest.log("warning", "Mob spawn of "..name.." failed, unknown entity or mob is not registered for spawning!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- additional custom checks for spawning mob
|
|
||||||
if mobs:spawn_abm_check(pos, node, name) == true then
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, ABM check rejected!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- count nearby mobs in same spawn class
|
|
||||||
local entdef = minetest.registered_entities[name]
|
|
||||||
local spawn_class = entdef and entdef.spawn_class
|
|
||||||
if not spawn_class then
|
|
||||||
if entdef.type == "monster" then
|
|
||||||
spawn_class = "hostile"
|
|
||||||
else
|
|
||||||
spawn_class = "passive"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local in_class_cap = count_mobs(pos, "!"..spawn_class) < MOB_CAP[spawn_class]
|
|
||||||
-- do not spawn if too many of same mob in area
|
|
||||||
if active_object_count_wider >= max_per_block -- large-range mob cap
|
|
||||||
or (not in_class_cap) -- spawn class mob cap
|
|
||||||
or count_mobs(pos, name) >= aoc then -- per-mob mob cap
|
|
||||||
-- too many entities
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too crowded!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if toggle set to nil then ignore day/night check
|
|
||||||
if day_toggle then
|
|
||||||
|
|
||||||
local tod = (minetest.get_timeofday() or 0) * 24000
|
|
||||||
|
|
||||||
if tod > 4500 and tod < 19500 then
|
|
||||||
-- daylight, but mob wants night
|
|
||||||
if day_toggle == false then
|
|
||||||
-- mob needs night
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, mob needs light!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- night time but mob wants day
|
|
||||||
if day_toggle == true then
|
|
||||||
-- mob needs day
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, mob needs daylight!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- spawn above node
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
|
|
||||||
-- only spawn away from player
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 24)
|
|
||||||
|
|
||||||
for n = 1, #objs do
|
|
||||||
|
|
||||||
if objs[n]:is_player() then
|
|
||||||
-- player too close
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, player too close!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- mobs cannot spawn in protected areas when enabled
|
|
||||||
if not spawn_protected
|
|
||||||
and minetest.is_protected(pos, "") then
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, position is protected!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- are we spawning within height limits?
|
|
||||||
if pos.y > max_height
|
|
||||||
or pos.y < min_height then
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, out of height limit!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- are light levels ok?
|
|
||||||
local light = minetest.get_node_light(pos)
|
|
||||||
if not light
|
|
||||||
or light > max_light
|
|
||||||
or light < min_light then
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, bad light!")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- do we have enough space to spawn mob?
|
|
||||||
local ent = minetest.registered_entities[name]
|
|
||||||
local width_x = max(1, math.ceil(ent.collisionbox[4] - ent.collisionbox[1]))
|
|
||||||
local min_x, max_x
|
|
||||||
if width_x % 2 == 0 then
|
|
||||||
max_x = math.floor(width_x/2)
|
|
||||||
min_x = -(max_x-1)
|
|
||||||
else
|
|
||||||
max_x = math.floor(width_x/2)
|
|
||||||
min_x = -max_x
|
|
||||||
end
|
|
||||||
|
|
||||||
local width_z = max(1, math.ceil(ent.collisionbox[6] - ent.collisionbox[3]))
|
|
||||||
local min_z, max_z
|
|
||||||
if width_z % 2 == 0 then
|
|
||||||
max_z = math.floor(width_z/2)
|
|
||||||
min_z = -(max_z-1)
|
|
||||||
else
|
|
||||||
max_z = math.floor(width_z/2)
|
|
||||||
min_z = -max_z
|
|
||||||
end
|
|
||||||
|
|
||||||
local max_y = max(0, math.ceil(ent.collisionbox[5] - ent.collisionbox[2]) - 1)
|
|
||||||
|
|
||||||
for y = 0, max_y do
|
|
||||||
for x = min_x, max_x do
|
|
||||||
for z = min_z, max_z do
|
|
||||||
local pos2 = {x = pos.x+x, y = pos.y+y, z = pos.z+z}
|
|
||||||
if minetest.registered_nodes[node_ok(pos2).name].walkable == true then
|
|
||||||
-- inside block
|
|
||||||
minetest.log("info", "Mob spawn of "..name.." at "..minetest.pos_to_string(pos).." failed, too little space!")
|
|
||||||
if ent.spawn_small_alternative and (not minetest.registered_nodes[node_ok(pos).name].walkable) then
|
|
||||||
minetest.log("info", "Trying to spawn smaller alternative mob: "..ent.spawn_small_alternative)
|
|
||||||
spawn_action(orig_pos, node, active_object_count, active_object_count_wider, ent.spawn_small_alternative)
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- tweak X/Y/Z spawn pos
|
|
||||||
if width_x % 2 == 0 then
|
|
||||||
pos.x = pos.x + 0.5
|
|
||||||
end
|
|
||||||
if width_z % 2 == 0 then
|
|
||||||
pos.z = pos.z + 0.5
|
|
||||||
end
|
|
||||||
pos.y = pos.y - 0.5
|
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, name)
|
|
||||||
minetest.log("action", "Mob spawned: "..name.." at "..minetest.pos_to_string(pos))
|
|
||||||
|
|
||||||
if on_spawn then
|
|
||||||
|
|
||||||
local ent = mob:get_luaentity()
|
|
||||||
|
|
||||||
on_spawn(ent, pos)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function spawn_abm_action(pos, node, active_object_count, active_object_count_wider)
|
|
||||||
spawn_action(pos, node, active_object_count, active_object_count_wider, name)
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
local entdef = minetest.registered_entities[name]
|
|
||||||
local spawn_class
|
|
||||||
if entdef.type == "monster" then
|
|
||||||
spawn_class = "hostile"
|
|
||||||
else
|
|
||||||
spawn_class = "passive"
|
|
||||||
end
|
|
||||||
|
|
||||||
--load information into the spawn dictionary
|
|
||||||
local key = #spawn_dictionary + 1
|
|
||||||
spawn_dictionary[key] = {}
|
|
||||||
spawn_dictionary[key]["name"] = name
|
|
||||||
spawn_dictionary[key]["dimension"] = dimension
|
|
||||||
spawn_dictionary[key]["type_of_spawning"] = type_of_spawning
|
|
||||||
spawn_dictionary[key]["biomes"] = biomes
|
|
||||||
spawn_dictionary[key]["min_light"] = min_light
|
|
||||||
spawn_dictionary[key]["max_light"] = max_light
|
|
||||||
spawn_dictionary[key]["interval"] = interval
|
|
||||||
spawn_dictionary[key]["chance"] = chance
|
|
||||||
spawn_dictionary[key]["aoc"] = aoc
|
|
||||||
spawn_dictionary[key]["min_height"] = min_height
|
|
||||||
spawn_dictionary[key]["max_height"] = max_height
|
|
||||||
spawn_dictionary[key]["day_toggle"] = day_toggle
|
|
||||||
--spawn_dictionary[key]["on_spawn"] = spawn_abm_action
|
|
||||||
spawn_dictionary[key]["spawn_class"] = spawn_class
|
|
||||||
|
|
||||||
--[[
|
|
||||||
minetest.register_abm({
|
|
||||||
label = name .. " spawning",
|
|
||||||
nodenames = nodes,
|
|
||||||
neighbors = neighbors,
|
|
||||||
interval = interval,
|
|
||||||
chance = floor(max(1, chance * mobs_spawn_chance)),
|
|
||||||
catch_up = false,
|
|
||||||
action = spawn_abm_action,
|
|
||||||
})
|
|
||||||
]]--
|
|
||||||
end
|
|
||||||
|
|
||||||
-- compatibility with older mob registration
|
|
||||||
-- we're going to forget about this for now -j4i
|
|
||||||
--[[
|
|
||||||
function mobs:register_spawn(name, nodes, max_light, min_light, chance, active_object_count, max_height, day_toggle)
|
|
||||||
|
|
||||||
mobs:spawn_specific(name, nodes, {"air"}, min_light, max_light, 30,
|
|
||||||
chance, active_object_count, -31000, max_height, day_toggle)
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
|
|
||||||
|
|
||||||
--Don't disable this yet-j4i
|
|
||||||
-- MarkBu's spawn function
|
|
||||||
|
|
||||||
function mobs:spawn(def)
|
|
||||||
--does nothing for now
|
|
||||||
--[[
|
|
||||||
local name = def.name
|
|
||||||
local nodes = def.nodes or {"group:soil", "group:stone"}
|
|
||||||
local neighbors = def.neighbors or {"air"}
|
|
||||||
local min_light = def.min_light or 0
|
|
||||||
local max_light = def.max_light or 15
|
|
||||||
local interval = def.interval or 30
|
|
||||||
local chance = def.chance or 5000
|
|
||||||
local active_object_count = def.active_object_count or 1
|
|
||||||
local min_height = def.min_height or -31000
|
|
||||||
local max_height = def.max_height or 31000
|
|
||||||
local day_toggle = def.day_toggle
|
|
||||||
local on_spawn = def.on_spawn
|
|
||||||
|
|
||||||
mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, interval,
|
|
||||||
chance, active_object_count, min_height, max_height, day_toggle, on_spawn)
|
|
||||||
]]--
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local axis
|
|
||||||
--inner and outer part of square donut radius
|
|
||||||
local inner = 15
|
|
||||||
local outer = 64
|
|
||||||
local int = {-1,1}
|
|
||||||
|
|
||||||
local function position_calculation(pos)
|
|
||||||
|
|
||||||
pos = vector_floor(pos)
|
|
||||||
|
|
||||||
--this is used to determine the axis buffer from the player
|
|
||||||
axis = math_random(0,1)
|
|
||||||
|
|
||||||
--cast towards the direction
|
|
||||||
if axis == 0 then --x
|
|
||||||
pos.x = pos.x + math_random(inner,outer)*int[math_random(1,2)]
|
|
||||||
pos.z = pos.z + math_random(-outer,outer)
|
|
||||||
else --z
|
|
||||||
pos.z = pos.z + math_random(inner,outer)*int[math_random(1,2)]
|
|
||||||
pos.x = pos.x + math_random(-outer,outer)
|
|
||||||
end
|
|
||||||
return pos
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[
|
|
||||||
local decypher_limits_dictionary = {
|
|
||||||
["overworld"] = {mcl_vars.mg_overworld_min,mcl_vars.mg_overworld_max},
|
|
||||||
["nether"] = {mcl_vars.mg_nether_min, mcl_vars.mg_nether_max},
|
|
||||||
["end"] = {mcl_vars.mg_end_min, mcl_vars.mg_end_max}
|
|
||||||
}
|
|
||||||
]]--
|
|
||||||
|
|
||||||
local function decypher_limits(posy)
|
|
||||||
--local min_max_table = decypher_limits_dictionary[dimension]
|
|
||||||
--return min_max_table[1],min_max_table[2]
|
|
||||||
posy = math_floor(posy)
|
|
||||||
return posy - 32, posy + 32
|
|
||||||
end
|
|
||||||
|
|
||||||
--a simple helper function for mob_spawn
|
|
||||||
local function biome_check(biome_list, biome_goal)
|
|
||||||
for _,data in ipairs(biome_list) do
|
|
||||||
if data == biome_goal then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--todo mob limiting
|
|
||||||
--MAIN LOOP
|
|
||||||
|
|
||||||
if mobs_spawn then
|
|
||||||
local timer = 0
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
timer = timer + dtime
|
|
||||||
if timer >= 10 then
|
|
||||||
timer = 0
|
|
||||||
for _,player in pairs(get_connected_players()) do
|
|
||||||
-- after this line each "break" means "continue"
|
|
||||||
local do_mob_spawning = true
|
|
||||||
repeat
|
|
||||||
--don't need to get these variables more than once
|
|
||||||
--they happen in a single server step
|
|
||||||
|
|
||||||
local player_pos = player:get_pos()
|
|
||||||
local dimension = mcl_worlds.pos_to_dimension(player_pos)
|
|
||||||
|
|
||||||
if dimension == "void" or dimension == "default" then
|
|
||||||
break -- ignore void and unloaded area
|
|
||||||
end
|
|
||||||
|
|
||||||
local min, max = decypher_limits(player_pos.y)
|
|
||||||
|
|
||||||
for i = 1, math_random(1,4) do
|
|
||||||
-- after this line each "break" means "continue"
|
|
||||||
local do_mob_algorithm = true
|
|
||||||
repeat
|
|
||||||
|
|
||||||
local goal_pos = position_calculation(player_pos)
|
|
||||||
|
|
||||||
local spawning_position_list = find_nodes_in_area_under_air(vector_new(goal_pos.x,min,goal_pos.z), vector_new(goal_pos.x,max,goal_pos.z), {"group:solid", "group:water", "group:lava"})
|
|
||||||
|
|
||||||
--couldn't find node
|
|
||||||
if #spawning_position_list <= 0 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local spawning_position = spawning_position_list[math_random(1,#spawning_position_list)]
|
|
||||||
|
|
||||||
--Prevent strange behavior --- this is commented out: /too close to player --fixed with inner circle
|
|
||||||
if not spawning_position then -- or vector_distance(player_pos, spawning_position) < 15
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
--hard code mob limit in area to 5 for now
|
|
||||||
if count_mobs(spawning_position) >= 5 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local gotten_node = get_node(spawning_position).name
|
|
||||||
|
|
||||||
if not gotten_node or gotten_node == "air" then --skip air nodes
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local gotten_biome = minetest.get_biome_data(spawning_position)
|
|
||||||
|
|
||||||
if not gotten_biome then
|
|
||||||
break --skip if in unloaded area
|
|
||||||
end
|
|
||||||
|
|
||||||
gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with
|
|
||||||
|
|
||||||
--add this so mobs don't spawn inside nodes
|
|
||||||
spawning_position.y = spawning_position.y + 1
|
|
||||||
|
|
||||||
--only need to poll for node light if everything else worked
|
|
||||||
local gotten_light = get_node_light(spawning_position)
|
|
||||||
|
|
||||||
local is_water = get_item_group(gotten_node, "water") ~= 0
|
|
||||||
local is_lava = get_item_group(gotten_node, "lava") ~= 0
|
|
||||||
|
|
||||||
local mob_def = nil
|
|
||||||
|
|
||||||
--create a disconnected clone of the spawn dictionary
|
|
||||||
--prevents memory leak
|
|
||||||
local mob_library_worker_table = table_copy(spawn_dictionary)
|
|
||||||
|
|
||||||
--grab mob that fits into the spawning location
|
|
||||||
--randomly grab a mob, don't exclude any possibilities
|
|
||||||
local repeat_mob_search = true
|
|
||||||
repeat
|
|
||||||
|
|
||||||
--do not infinite loop
|
|
||||||
if #mob_library_worker_table <= 0 then
|
|
||||||
--print("breaking infinite loop")
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
local skip = false
|
|
||||||
|
|
||||||
--use this for removing table elements of mobs that do not match
|
|
||||||
local temp_index = math_random(1,#mob_library_worker_table)
|
|
||||||
|
|
||||||
local temp_def = mob_library_worker_table[temp_index]
|
|
||||||
|
|
||||||
--skip if something ridiculous happens (nil mob def)
|
|
||||||
--something truly horrible has happened if skip gets
|
|
||||||
--activated at this point
|
|
||||||
if not temp_def then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if not skip and (spawning_position.y < temp_def.min_height or spawning_position.y > temp_def.max_height) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--skip if not correct dimension
|
|
||||||
if not skip and (temp_def.dimension ~= dimension) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--skip if not in correct biome
|
|
||||||
if not skip and (not biome_check(temp_def.biomes, gotten_biome)) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--don't spawn if not in light limits
|
|
||||||
if not skip and (gotten_light < temp_def.min_light or gotten_light > temp_def.max_light) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--skip if not in correct spawning type
|
|
||||||
if not skip and (temp_def.type_of_spawning == "ground" and is_water) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if not skip and (temp_def.type_of_spawning == "ground" and is_lava) then
|
|
||||||
skip = true
|
|
||||||
end
|
|
||||||
|
|
||||||
--found a mob, exit out of loop
|
|
||||||
if not skip then
|
|
||||||
--minetest.log("warning", "found mob:"..temp_def.name)
|
|
||||||
--print("found mob:"..temp_def.name)
|
|
||||||
mob_def = table_copy(temp_def)
|
|
||||||
break
|
|
||||||
else
|
|
||||||
--minetest.log("warning", "deleting temp index "..temp_index)
|
|
||||||
--print("deleting temp index")
|
|
||||||
table_remove(mob_library_worker_table, temp_index)
|
|
||||||
end
|
|
||||||
|
|
||||||
until repeat_mob_search == false --this is needed to sort through mobs randomly
|
|
||||||
|
|
||||||
|
|
||||||
--catch if went through all mobs and something went horribly wrong
|
|
||||||
--could not find a valid mob to spawn that fits the environment
|
|
||||||
if not mob_def then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
--adjust the position for water and lava mobs
|
|
||||||
if mob_def.type_of_spawning == "water" or mob_def.type_of_spawning == "lava" then
|
|
||||||
spawning_position.y = spawning_position.y - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
--print("spawning: " .. mob_def.name)
|
|
||||||
|
|
||||||
--everything is correct, spawn mob
|
|
||||||
minetest.add_entity(spawning_position, mob_def.name)
|
|
||||||
|
|
||||||
break
|
|
||||||
until do_mob_algorithm == false --this is a safety catch
|
|
||||||
end
|
|
||||||
|
|
||||||
break
|
|
||||||
until do_mob_spawning == false --this is a performance catch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mcl_mobs")
|
||||||
|
|
||||||
-- name tag
|
-- name tag
|
||||||
minetest.register_craftitem("mcl_mobs:nametag", {
|
minetest.register_craftitem("mcl_mobs:nametag", {
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
|
|
||||||
local path = minetest.get_modpath(minetest.get_current_modname())
|
local path = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
local api_path = path.."/api"
|
|
||||||
|
|
||||||
-- Mob API
|
-- Mob API
|
||||||
dofile(api_path .. "/api.lua")
|
dofile(path .. "/api.lua")
|
||||||
|
|
||||||
-- Spawning Algorithm
|
-- Spawning Algorithm
|
||||||
dofile(api_path .. "/spawning.lua")
|
dofile(path .. "/spawning.lua")
|
||||||
|
|
||||||
-- Rideable Mobs
|
-- Rideable Mobs
|
||||||
dofile(api_path .. "/mount.lua")
|
dofile(path .. "/mount.lua")
|
||||||
|
|
||||||
-- Mob Items
|
-- Mob Items
|
||||||
dofile(path .. "/crafts.lua")
|
dofile(path .. "/crafts.lua")
|
|
@ -1,11 +0,0 @@
|
||||||
# textdomain: mcl_mobs
|
|
||||||
Peaceful mode active! No monsters will spawn.=Tryb pokojowy aktywowany! Potwory nie będą się pojawiać.
|
|
||||||
This allows you to place a single mob.=To pozwala na przywołanie jednego moba.
|
|
||||||
Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns.=Postaw to w miejscu w którym chcesz aby pojawił się mob. Zwierzęta pojawią się jako oswojone chyba, że będziesz się skradał podczas stawiania. Jeśli postawisz to na spawnerze to zmienisz którego moba przywołuje.
|
|
||||||
You need the “maphack” privilege to change the mob spawner.=Potrzebujesz przywileju "maphack", aby zmienić spawner.
|
|
||||||
Name Tag=Znacznik
|
|
||||||
A name tag is an item to name a mob.=Znacznik jest przedmiotem pozwalającym nazwać moba.
|
|
||||||
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=Zanim użyjesz znacznika musisz wybrać imię przy kowadle. Następnie możesz użyć znacznika by nazwać moba. To zużywa znacznik.
|
|
||||||
Only peaceful mobs allowed!=Tylko pokojowe moby są dozwolone!
|
|
||||||
Give names to mobs=Nazwij moby
|
|
||||||
Set name at anvil=Wybierz imię przy kowadle
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# textdomain: mcl_mobs
|
||||||
|
Peaceful mode active! No monsters will spawn.=和平模式已啓用!不會生成怪物。
|
||||||
|
This allows you to place a single mob.=允許你放置一個生物。
|
||||||
|
Just place it where you want the mob to appear. Animals will spawn tamed, unless you hold down the sneak key while placing. If you place this on a mob spawner, you change the mob it spawns.=把它放在你希望生物出現的地方。除非你在放置的時候按住潛行鍵,否則動物會被馴服地產生。如果你把它放在一個生怪磚上,你就會改變它所產的生物。
|
||||||
|
You need the “maphack” privilege to change the mob spawner.=你要「maphack」權限來修改生怪磚。
|
||||||
|
Name Tag=命名牌
|
||||||
|
A name tag is an item to name a mob.=命名牌是一個用於命名生物的物品
|
||||||
|
Before you use the name tag, you need to set a name at an anvil. Then you can use the name tag to name a mob. This uses up the name tag.=在使用名字標籤之前,你需要在一個鐵砧上設置一個名字。然後你就可以用名字標籤來給生物命名。這會消耗命名牌。
|
||||||
|
Only peaceful mobs allowed!=只允許和平生物!
|
||||||
|
Give names to mobs=替生物命名
|
||||||
|
Set name at anvil=在鐵砧上設置名字
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
if minetest.get_modpath("lucky_block") then
|
||||||
|
|
||||||
|
lucky_block:add_blocks({
|
||||||
|
{"dro", {"mcl_mobs:nametag"}, 1},
|
||||||
|
{"lig"},
|
||||||
|
})
|
||||||
|
end
|
|
@ -2,4 +2,4 @@ name = mcl_mobs
|
||||||
author = PilzAdam
|
author = PilzAdam
|
||||||
description = Adds a mob API for mods to add animals or monsters, etc.
|
description = Adds a mob API for mods to add animals or monsters, etc.
|
||||||
depends = mcl_particles
|
depends = mcl_particles
|
||||||
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience
|
optional_depends = mcl_weather, mcl_explosions, mcl_hunger, mcl_worlds, invisibility, lucky_block, cmi, doc_identifier, mcl_armor, mcl_portals, mcl_experience
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
|
|
||||||
-- lib_mount by Blert2112 (edited by TenPlus1)
|
-- lib_mount by Blert2112 (edited by TenPlus1)
|
||||||
|
|
||||||
--local enable_crash = false
|
local enable_crash = false
|
||||||
--local crash_threshold = 6.5 -- ignored if enable_crash=false
|
local crash_threshold = 6.5 -- ignored if enable_crash=false
|
||||||
|
|
||||||
local math = math
|
|
||||||
local vector = vector
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -13,7 +10,7 @@ local vector = vector
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
--
|
--
|
||||||
|
|
||||||
--[[local function node_ok(pos, fallback)
|
local node_ok = function(pos, fallback)
|
||||||
|
|
||||||
fallback = fallback or mobs.fallback_node
|
fallback = fallback or mobs.fallback_node
|
||||||
|
|
||||||
|
@ -24,10 +21,10 @@ local vector = vector
|
||||||
end
|
end
|
||||||
|
|
||||||
return {name = fallback}
|
return {name = fallback}
|
||||||
end]]
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[local function node_is(pos)
|
local function node_is(pos)
|
||||||
|
|
||||||
local node = node_ok(pos)
|
local node = node_ok(pos)
|
||||||
|
|
||||||
|
@ -48,7 +45,7 @@ end]]
|
||||||
end
|
end
|
||||||
|
|
||||||
return "other"
|
return "other"
|
||||||
end]]
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_sign(i)
|
local function get_sign(i)
|
||||||
|
@ -63,11 +60,13 @@ local function get_sign(i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--[[local function get_velocity(v, yaw, y)
|
local function get_velocity(v, yaw, y)
|
||||||
|
|
||||||
local x = -math.sin(yaw) * v
|
local x = -math.sin(yaw) * v
|
||||||
local z = math.cos(yaw) * v
|
local z = math.cos(yaw) * v
|
||||||
|
|
||||||
return {x = x, y = y, z = z}
|
return {x = x, y = y, z = z}
|
||||||
end]]
|
end
|
||||||
|
|
||||||
|
|
||||||
local function get_v(v)
|
local function get_v(v)
|
||||||
|
@ -173,7 +172,7 @@ function mobs.detach(player, offset)
|
||||||
|
|
||||||
--pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
|
--pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
|
||||||
|
|
||||||
player:add_velocity(vector.new(math.random(-6,6), math.random(5,8), math.random(-6,6))) --throw the rider off
|
player:add_velocity(vector.new(math.random(-6,6),math.random(5,8),math.random(-6,6))) --throw the rider off
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
minetest.after(0.1, function(name, pos)
|
minetest.after(0.1, function(name, pos)
|
||||||
|
@ -188,13 +187,13 @@ end
|
||||||
|
|
||||||
function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
|
|
||||||
--local rot_view = 0
|
local rot_view = 0
|
||||||
|
|
||||||
--if entity.player_rotation.y == 90 then
|
if entity.player_rotation.y == 90 then
|
||||||
-- rot_view = math.pi/2
|
rot_view = math.pi/2
|
||||||
--end
|
end
|
||||||
|
|
||||||
--local acce_y = 0
|
local acce_y = 0
|
||||||
local velo = entity.object:get_velocity()
|
local velo = entity.object:get_velocity()
|
||||||
|
|
||||||
entity.v = get_v(velo) * get_sign(entity.v)
|
entity.v = get_v(velo) * get_sign(entity.v)
|
||||||
|
@ -207,30 +206,21 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
-- move forwards
|
-- move forwards
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
|
|
||||||
mobs.set_velocity(entity, entity.run_velocity)
|
entity.v = entity.v + entity.accel / 10
|
||||||
|
|
||||||
mobs.set_mob_animation(entity, moving_anim)
|
|
||||||
|
|
||||||
-- move backwards
|
-- move backwards
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
|
|
||||||
mobs.set_velocity(entity, -entity.run_velocity)
|
if entity.max_speed_reverse == 0 and entity.v == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
mobs.set_mob_animation(entity, moving_anim)
|
entity.v = entity.v - entity.accel / 10
|
||||||
|
|
||||||
--halt
|
|
||||||
else
|
|
||||||
|
|
||||||
mobs.set_velocity(entity, 0)
|
|
||||||
|
|
||||||
mobs.set_mob_animation(entity, stand_anim)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mob rotation
|
-- fix mob rotation
|
||||||
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
||||||
entity.yaw = entity.driver:get_look_horizontal() - entity.rotate
|
|
||||||
|
|
||||||
--[[
|
|
||||||
if can_fly then
|
if can_fly then
|
||||||
|
|
||||||
-- fly up
|
-- fly up
|
||||||
|
@ -254,21 +244,32 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
]]--
|
|
||||||
|
|
||||||
-- jump
|
-- jump
|
||||||
if ctrl.jump then
|
if ctrl.jump then
|
||||||
|
|
||||||
|
if velo.y == 0 then
|
||||||
|
velo.y = velo.y + entity.jump_height
|
||||||
|
acce_y = acce_y + (acce_y * 3) + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mobs.jump(entity)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
-- if not moving then set animation and return
|
||||||
|
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
|
|
||||||
|
if stand_anim then
|
||||||
|
mobs:set_animation(entity, stand_anim)
|
||||||
|
end
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- set moving animation
|
-- set moving animation
|
||||||
if moving_anim then
|
if moving_anim then
|
||||||
mobs:set_mob_animation(entity, moving_anim)
|
mobs:set_animation(entity, moving_anim)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop!
|
-- Stop!
|
||||||
|
@ -382,17 +383,13 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
entity.v2 = v
|
entity.v2 = v
|
||||||
]]--
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- directional flying routine by D00Med (edited by TenPlus1)
|
-- directional flying routine by D00Med (edited by TenPlus1)
|
||||||
|
|
||||||
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||||
if true then
|
|
||||||
print("succ")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local ctrl = entity.driver:get_player_control()
|
local ctrl = entity.driver:get_player_control()
|
||||||
local velo = entity.object:get_velocity()
|
local velo = entity.object:get_velocity()
|
||||||
local dir = entity.driver:get_look_dir()
|
local dir = entity.driver:get_look_dir()
|
||||||
|
@ -443,9 +440,9 @@ function mobs.fly(entity, dtime, speed, shoots, arrow, moving_anim, stand_anim)
|
||||||
-- change animation if stopped
|
-- change animation if stopped
|
||||||
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
if velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
|
|
||||||
mobs:set_mob_animation(entity, stand_anim)
|
mobs:set_animation(entity, stand_anim)
|
||||||
else
|
else
|
||||||
-- moving animation
|
-- moving animation
|
||||||
mobs:set_mob_animation(entity, moving_anim)
|
mobs:set_animation(entity, moving_anim)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
default_punch.1 = https://freesound.org/people/Merrick079/sounds/566436/
|
|
||||||
default_punch.2 = https://freesound.org/people/Merrick079/sounds/566435/
|
|
||||||
default_punch.3 = https://freesound.org/people/Merrick079/sounds/566434/
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,484 @@
|
||||||
|
--lua locals
|
||||||
|
local get_node = minetest.get_node
|
||||||
|
local get_item_group = minetest.get_item_group
|
||||||
|
local get_node_light = minetest.get_node_light
|
||||||
|
local find_nodes_in_area_under_air = minetest.find_nodes_in_area_under_air
|
||||||
|
local get_biome_name = minetest.get_biome_name
|
||||||
|
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
|
local get_connected_players = minetest.get_connected_players
|
||||||
|
local minetest_get_perlin = minetest.get_perlin
|
||||||
|
|
||||||
|
local math_random = math.random
|
||||||
|
local math_floor = math.floor
|
||||||
|
local math_ceil = math.ceil
|
||||||
|
local math_cos = math.cos
|
||||||
|
local math_sin = math.sin
|
||||||
|
local math_round = function(x) return (x > 0) and math_floor(x + 0.5) or math_ceil(x - 0.5) end
|
||||||
|
|
||||||
|
--local vector_distance = vector.distance
|
||||||
|
local vector_new = vector.new
|
||||||
|
local vector_floor = vector.floor
|
||||||
|
|
||||||
|
local table_copy = table.copy
|
||||||
|
local table_remove = table.remove
|
||||||
|
|
||||||
|
local pairs = pairs
|
||||||
|
|
||||||
|
-- range for mob count
|
||||||
|
local aoc_range = 32
|
||||||
|
|
||||||
|
--do mobs spawn?
|
||||||
|
local mobs_spawn = minetest.settings:get_bool("mobs_spawn", true) ~= false
|
||||||
|
|
||||||
|
|
||||||
|
local noise_params = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 3,
|
||||||
|
spread = {
|
||||||
|
x = 301,
|
||||||
|
y = 50,
|
||||||
|
z = 304,
|
||||||
|
},
|
||||||
|
seed = 100,
|
||||||
|
octaves = 3,
|
||||||
|
persistence = 0.5,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- THIS IS THE BIG LIST OF ALL BIOMES - used for programming/updating mobs
|
||||||
|
-- Also used for missing parameter
|
||||||
|
-- Please update the list when adding new biomes!
|
||||||
|
|
||||||
|
local list_of_all_biomes = {
|
||||||
|
|
||||||
|
-- underground:
|
||||||
|
|
||||||
|
"FlowerForest_underground",
|
||||||
|
"JungleEdge_underground",
|
||||||
|
"ColdTaiga_underground",
|
||||||
|
"IcePlains_underground",
|
||||||
|
"IcePlainsSpikes_underground",
|
||||||
|
"MegaTaiga_underground",
|
||||||
|
"Taiga_underground",
|
||||||
|
"ExtremeHills+_underground",
|
||||||
|
"JungleM_underground",
|
||||||
|
"ExtremeHillsM_underground",
|
||||||
|
"JungleEdgeM_underground",
|
||||||
|
|
||||||
|
-- ocean:
|
||||||
|
|
||||||
|
"RoofedForest_ocean",
|
||||||
|
"JungleEdgeM_ocean",
|
||||||
|
"BirchForestM_ocean",
|
||||||
|
"BirchForest_ocean",
|
||||||
|
"IcePlains_deep_ocean",
|
||||||
|
"Jungle_deep_ocean",
|
||||||
|
"Savanna_ocean",
|
||||||
|
"MesaPlateauF_ocean",
|
||||||
|
"ExtremeHillsM_deep_ocean",
|
||||||
|
"Savanna_deep_ocean",
|
||||||
|
"SunflowerPlains_ocean",
|
||||||
|
"Swampland_deep_ocean",
|
||||||
|
"Swampland_ocean",
|
||||||
|
"MegaSpruceTaiga_deep_ocean",
|
||||||
|
"ExtremeHillsM_ocean",
|
||||||
|
"JungleEdgeM_deep_ocean",
|
||||||
|
"SunflowerPlains_deep_ocean",
|
||||||
|
"BirchForest_deep_ocean",
|
||||||
|
"IcePlainsSpikes_ocean",
|
||||||
|
"Mesa_ocean",
|
||||||
|
"StoneBeach_ocean",
|
||||||
|
"Plains_deep_ocean",
|
||||||
|
"JungleEdge_deep_ocean",
|
||||||
|
"SavannaM_deep_ocean",
|
||||||
|
"Desert_deep_ocean",
|
||||||
|
"Mesa_deep_ocean",
|
||||||
|
"ColdTaiga_deep_ocean",
|
||||||
|
"Plains_ocean",
|
||||||
|
"MesaPlateauFM_ocean",
|
||||||
|
"Forest_deep_ocean",
|
||||||
|
"JungleM_deep_ocean",
|
||||||
|
"FlowerForest_deep_ocean",
|
||||||
|
"MushroomIsland_ocean",
|
||||||
|
"MegaTaiga_ocean",
|
||||||
|
"StoneBeach_deep_ocean",
|
||||||
|
"IcePlainsSpikes_deep_ocean",
|
||||||
|
"ColdTaiga_ocean",
|
||||||
|
"SavannaM_ocean",
|
||||||
|
"MesaPlateauF_deep_ocean",
|
||||||
|
"MesaBryce_deep_ocean",
|
||||||
|
"ExtremeHills+_deep_ocean",
|
||||||
|
"ExtremeHills_ocean",
|
||||||
|
"MushroomIsland_deep_ocean",
|
||||||
|
"Forest_ocean",
|
||||||
|
"MegaTaiga_deep_ocean",
|
||||||
|
"JungleEdge_ocean",
|
||||||
|
"MesaBryce_ocean",
|
||||||
|
"MegaSpruceTaiga_ocean",
|
||||||
|
"ExtremeHills+_ocean",
|
||||||
|
"Jungle_ocean",
|
||||||
|
"RoofedForest_deep_ocean",
|
||||||
|
"IcePlains_ocean",
|
||||||
|
"FlowerForest_ocean",
|
||||||
|
"ExtremeHills_deep_ocean",
|
||||||
|
"MesaPlateauFM_deep_ocean",
|
||||||
|
"Desert_ocean",
|
||||||
|
"Taiga_ocean",
|
||||||
|
"BirchForestM_deep_ocean",
|
||||||
|
"Taiga_deep_ocean",
|
||||||
|
"JungleM_ocean",
|
||||||
|
|
||||||
|
-- water or beach?
|
||||||
|
|
||||||
|
"MesaPlateauFM_sandlevel",
|
||||||
|
"MesaPlateauF_sandlevel",
|
||||||
|
"MesaBryce_sandlevel",
|
||||||
|
"Mesa_sandlevel",
|
||||||
|
|
||||||
|
-- beach:
|
||||||
|
|
||||||
|
"FlowerForest_beach",
|
||||||
|
"Forest_beach",
|
||||||
|
"StoneBeach",
|
||||||
|
"ColdTaiga_beach_water",
|
||||||
|
"Taiga_beach",
|
||||||
|
"Savanna_beach",
|
||||||
|
"Plains_beach",
|
||||||
|
"ExtremeHills_beach",
|
||||||
|
"ColdTaiga_beach",
|
||||||
|
"Swampland_shore",
|
||||||
|
"MushroomIslandShore",
|
||||||
|
"JungleM_shore",
|
||||||
|
"Jungle_shore",
|
||||||
|
|
||||||
|
-- dimension biome:
|
||||||
|
|
||||||
|
"Nether",
|
||||||
|
"End",
|
||||||
|
|
||||||
|
-- Overworld regular:
|
||||||
|
|
||||||
|
"Mesa",
|
||||||
|
"FlowerForest",
|
||||||
|
"Swampland",
|
||||||
|
"Taiga",
|
||||||
|
"ExtremeHills",
|
||||||
|
"Jungle",
|
||||||
|
"Savanna",
|
||||||
|
"BirchForest",
|
||||||
|
"MegaSpruceTaiga",
|
||||||
|
"MegaTaiga",
|
||||||
|
"ExtremeHills+",
|
||||||
|
"Forest",
|
||||||
|
"Plains",
|
||||||
|
"Desert",
|
||||||
|
"ColdTaiga",
|
||||||
|
"MushroomIsland",
|
||||||
|
"IcePlainsSpikes",
|
||||||
|
"SunflowerPlains",
|
||||||
|
"IcePlains",
|
||||||
|
"RoofedForest",
|
||||||
|
"ExtremeHills+_snowtop",
|
||||||
|
"MesaPlateauFM_grasstop",
|
||||||
|
"JungleEdgeM",
|
||||||
|
"ExtremeHillsM",
|
||||||
|
"JungleM",
|
||||||
|
"BirchForestM",
|
||||||
|
"MesaPlateauF",
|
||||||
|
"MesaPlateauFM",
|
||||||
|
"MesaPlateauF_grasstop",
|
||||||
|
"MesaBryce",
|
||||||
|
"JungleEdge",
|
||||||
|
"SavannaM",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- count how many mobs are in an area
|
||||||
|
local function count_mobs(pos)
|
||||||
|
local num = 0
|
||||||
|
for _,object in pairs(get_objects_inside_radius(pos, aoc_range)) do
|
||||||
|
if object and object:get_luaentity() and object:get_luaentity()._cmi_is_mob then
|
||||||
|
num = num + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return num
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- global functions
|
||||||
|
|
||||||
|
function mobs:spawn_abm_check(pos, node, name)
|
||||||
|
-- global function to add additional spawn checks
|
||||||
|
-- return true to stop spawning mob
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Custom elements changed:
|
||||||
|
|
||||||
|
name:
|
||||||
|
the mobs name
|
||||||
|
|
||||||
|
dimension:
|
||||||
|
"overworld"
|
||||||
|
"nether"
|
||||||
|
"end"
|
||||||
|
|
||||||
|
types of spawning:
|
||||||
|
"water"
|
||||||
|
"ground"
|
||||||
|
"lava"
|
||||||
|
|
||||||
|
biomes: tells the spawner to allow certain mobs to spawn in certain biomes
|
||||||
|
{"this", "that", "grasslands", "whatever"}
|
||||||
|
|
||||||
|
|
||||||
|
what is aoc??? objects in area
|
||||||
|
|
||||||
|
WARNING: BIOME INTEGRATION NEEDED -> How to get biome through lua??
|
||||||
|
]]--
|
||||||
|
|
||||||
|
|
||||||
|
--this is where all of the spawning information is kept
|
||||||
|
local spawn_dictionary = {}
|
||||||
|
local summary_chance = 0
|
||||||
|
|
||||||
|
function mobs:spawn_setup(def)
|
||||||
|
if not mobs_spawn then return end
|
||||||
|
|
||||||
|
if not def then
|
||||||
|
minetest.log("warning", "Empty mob spawn setup definition")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local name = def.name
|
||||||
|
if not name then
|
||||||
|
minetest.log("warning", "Missing mob name")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local dimension = def.dimension or "overworld"
|
||||||
|
local type_of_spawning = def.type_of_spawning or "ground"
|
||||||
|
local biomes = def.biomes or list_of_all_biomes
|
||||||
|
local min_light = def.min_light or 0
|
||||||
|
local max_light = def.max_light or (minetest.LIGHT_MAX + 1)
|
||||||
|
local chance = def.chance or 1000
|
||||||
|
local aoc = def.aoc or aoc_range
|
||||||
|
local min_height = def.min_height or mcl_mapgen.overworld.min
|
||||||
|
local max_height = def.max_height or mcl_mapgen.overworld.max
|
||||||
|
local day_toggle = def.day_toggle
|
||||||
|
local on_spawn = def.on_spawn
|
||||||
|
local check_position = def.check_position
|
||||||
|
|
||||||
|
-- chance/spawn number override in minetest.conf for registered mob
|
||||||
|
local numbers = minetest.settings:get(name)
|
||||||
|
if numbers then
|
||||||
|
numbers = numbers:split(",")
|
||||||
|
chance = tonumber(numbers[1]) or chance
|
||||||
|
aoc = tonumber(numbers[2]) or aoc
|
||||||
|
if chance == 0 then
|
||||||
|
minetest.log("warning", string.format("[mobs] %s has spawning disabled", name))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.log("action", string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc))
|
||||||
|
end
|
||||||
|
|
||||||
|
if chance < 1 then
|
||||||
|
chance = 1
|
||||||
|
minetest.log("warning", "Chance shouldn't be less than 1 (mob name: " .. name ..")")
|
||||||
|
end
|
||||||
|
|
||||||
|
spawn_dictionary[#spawn_dictionary + 1] = {
|
||||||
|
name = name,
|
||||||
|
dimension = dimension,
|
||||||
|
type_of_spawning = type_of_spawning,
|
||||||
|
biomes = biomes,
|
||||||
|
min_light = min_light,
|
||||||
|
max_light = max_light,
|
||||||
|
chance = chance,
|
||||||
|
aoc = aoc,
|
||||||
|
min_height = min_height,
|
||||||
|
max_height = max_height,
|
||||||
|
day_toggle = day_toggle,
|
||||||
|
check_position = check_position,
|
||||||
|
on_spawn = on_spawn,
|
||||||
|
}
|
||||||
|
summary_chance = summary_chance + chance
|
||||||
|
end
|
||||||
|
|
||||||
|
function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)
|
||||||
|
|
||||||
|
-- Do mobs spawn at all?
|
||||||
|
if not mobs_spawn then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- chance/spawn number override in minetest.conf for registered mob
|
||||||
|
local numbers = minetest.settings:get(name)
|
||||||
|
|
||||||
|
if numbers then
|
||||||
|
numbers = numbers:split(",")
|
||||||
|
chance = tonumber(numbers[1]) or chance
|
||||||
|
aoc = tonumber(numbers[2]) or aoc
|
||||||
|
|
||||||
|
if chance == 0 then
|
||||||
|
minetest.log("warning", string.format("[mobs] %s has spawning disabled", name))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.log("action", string.format("[mobs] Chance setting for %s changed to %s (total: %s)", name, chance, aoc))
|
||||||
|
end
|
||||||
|
|
||||||
|
--load information into the spawn dictionary
|
||||||
|
local key = #spawn_dictionary + 1
|
||||||
|
spawn_dictionary[key] = {}
|
||||||
|
spawn_dictionary[key]["name"] = name
|
||||||
|
spawn_dictionary[key]["dimension"] = dimension
|
||||||
|
spawn_dictionary[key]["type_of_spawning"] = type_of_spawning
|
||||||
|
spawn_dictionary[key]["biomes"] = biomes
|
||||||
|
spawn_dictionary[key]["min_light"] = min_light
|
||||||
|
spawn_dictionary[key]["max_light"] = max_light
|
||||||
|
spawn_dictionary[key]["chance"] = chance
|
||||||
|
spawn_dictionary[key]["aoc"] = aoc
|
||||||
|
spawn_dictionary[key]["min_height"] = min_height
|
||||||
|
spawn_dictionary[key]["max_height"] = max_height
|
||||||
|
spawn_dictionary[key]["day_toggle"] = day_toggle
|
||||||
|
|
||||||
|
summary_chance = summary_chance + chance
|
||||||
|
end
|
||||||
|
|
||||||
|
local two_pi = 2 * math.pi
|
||||||
|
local function get_next_mob_spawn_pos(pos)
|
||||||
|
local distance = math_random(25, 32)
|
||||||
|
local angle = math_random() * two_pi
|
||||||
|
return {
|
||||||
|
x = math_round(pos.x + distance * math_cos(angle)),
|
||||||
|
y = pos.y,
|
||||||
|
z = math_round(pos.z + distance * math_sin(angle))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function decypher_limits(posy)
|
||||||
|
posy = math_floor(posy)
|
||||||
|
return posy - 32, posy + 32
|
||||||
|
end
|
||||||
|
|
||||||
|
--a simple helper function for mob_spawn
|
||||||
|
local function biome_check(biome_list, biome_goal)
|
||||||
|
for _, data in pairs(biome_list) do
|
||||||
|
if data == biome_goal then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_farm_animal(n)
|
||||||
|
return n == "mobs_mc:pig" or n == "mobs_mc:cow" or n == "mobs_mc:sheep" or n == "mobs_mc:chicken" or n == "mobs_mc:horse" or n == "mobs_mc:donkey"
|
||||||
|
end
|
||||||
|
|
||||||
|
if mobs_spawn then
|
||||||
|
|
||||||
|
local perlin_noise
|
||||||
|
|
||||||
|
local function spawn_a_mob(pos, dimension, y_min, y_max)
|
||||||
|
local dimension = dimension or mcl_worlds.pos_to_dimension(pos)
|
||||||
|
local goal_pos = get_next_mob_spawn_pos(pos)
|
||||||
|
local spawning_position_list = find_nodes_in_area_under_air(
|
||||||
|
{x = goal_pos.x, y = y_min, z = goal_pos.z},
|
||||||
|
{x = goal_pos.x, y = y_max, z = goal_pos.z},
|
||||||
|
{"group:solid", "group:water", "group:lava"}
|
||||||
|
)
|
||||||
|
if #spawning_position_list <= 0 then return end
|
||||||
|
local spawning_position = spawning_position_list[math_random(1, #spawning_position_list)]
|
||||||
|
|
||||||
|
--hard code mob limit in area to 5 for now
|
||||||
|
if count_mobs(spawning_position) >= 5 then return end
|
||||||
|
|
||||||
|
local gotten_node = get_node(spawning_position).name
|
||||||
|
local gotten_biome = minetest.get_biome_data(spawning_position)
|
||||||
|
if not gotten_node or not gotten_biome then return end
|
||||||
|
gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with
|
||||||
|
|
||||||
|
--add this so mobs don't spawn inside nodes
|
||||||
|
spawning_position.y = spawning_position.y + 1
|
||||||
|
|
||||||
|
--only need to poll for node light if everything else worked
|
||||||
|
local gotten_light = get_node_light(spawning_position)
|
||||||
|
|
||||||
|
local is_water = get_item_group(gotten_node, "water") ~= 0
|
||||||
|
local is_lava = get_item_group(gotten_node, "lava") ~= 0
|
||||||
|
local is_ground = not (is_water or is_lava)
|
||||||
|
local is_grass = minetest.get_item_group(gotten_node,"grass_block") ~= 0
|
||||||
|
local has_bed = minetest.find_node_near(pos,25,{"group:bed"})
|
||||||
|
|
||||||
|
if not is_ground then
|
||||||
|
spawning_position.y = spawning_position.y - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local mob_def
|
||||||
|
|
||||||
|
--create a disconnected clone of the spawn dictionary
|
||||||
|
--prevents memory leak
|
||||||
|
local mob_library_worker_table = table_copy(spawn_dictionary)
|
||||||
|
|
||||||
|
--grab mob that fits into the spawning location
|
||||||
|
--randomly grab a mob, don't exclude any possibilities
|
||||||
|
perlin_noise = perlin_noise or minetest_get_perlin(noise_params)
|
||||||
|
local noise = perlin_noise:get_3d(spawning_position)
|
||||||
|
local current_summary_chance = summary_chance
|
||||||
|
while #mob_library_worker_table > 0 do
|
||||||
|
local mob_chance_offset = (math_round(noise * current_summary_chance + 12345) % current_summary_chance) + 1
|
||||||
|
local mob_index = 1
|
||||||
|
local mob_chance = mob_library_worker_table[mob_index].chance
|
||||||
|
local step_chance = mob_chance
|
||||||
|
while step_chance < mob_chance_offset do
|
||||||
|
mob_index = mob_index + 1
|
||||||
|
mob_chance = mob_library_worker_table[mob_index].chance
|
||||||
|
step_chance = step_chance + mob_chance
|
||||||
|
end
|
||||||
|
local mob_def = mob_library_worker_table[mob_index]
|
||||||
|
local mob_type = minetest.registered_entities[mob_def.name].type
|
||||||
|
if mob_def
|
||||||
|
and spawning_position.y >= mob_def.min_height
|
||||||
|
and spawning_position.y <= mob_def.max_height
|
||||||
|
and mob_def.dimension == dimension
|
||||||
|
and biome_check(mob_def.biomes, gotten_biome)
|
||||||
|
and gotten_light >= mob_def.min_light
|
||||||
|
and gotten_light <= mob_def.max_light
|
||||||
|
and (is_ground or mob_def.type_of_spawning ~= "ground")
|
||||||
|
and (mob_def.check_position and mob_def.check_position(spawning_position) or true)
|
||||||
|
and (not is_farm_animal(mob_def.name) or is_grass)
|
||||||
|
and (mob_type ~= "npc" or has_bed)
|
||||||
|
then
|
||||||
|
--everything is correct, spawn mob
|
||||||
|
local object = minetest.add_entity(spawning_position, mob_def.name)
|
||||||
|
if object then
|
||||||
|
return mob_def.on_spawn and mob_def.on_spawn(object, pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
current_summary_chance = current_summary_chance - mob_chance
|
||||||
|
table_remove(mob_library_worker_table, mob_index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--MAIN LOOP
|
||||||
|
|
||||||
|
local timer = 0
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
timer = timer + dtime
|
||||||
|
if timer < 10 then return end
|
||||||
|
timer = 0
|
||||||
|
for _, player in pairs(get_connected_players()) do
|
||||||
|
local pos = player:get_pos()
|
||||||
|
local dimension = mcl_worlds.pos_to_dimension(pos)
|
||||||
|
-- ignore void and unloaded area
|
||||||
|
if dimension ~= "void" and dimension ~= "default" then
|
||||||
|
local y_min, y_max = decypher_limits(pos.y)
|
||||||
|
for i = 1, math_random(1, 4) do
|
||||||
|
spawn_a_mob(pos, dimension, y_min, y_max)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
|
@ -1 +0,0 @@
|
||||||
--use vector.distance to count down mob despawn timer
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# textdomain:mcl_paintings
|
||||||
|
Painting=畫
|
|
@ -0,0 +1,50 @@
|
||||||
|
local dim = {"x", "z"}
|
||||||
|
|
||||||
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||||
|
|
||||||
|
local function load_schem(filename)
|
||||||
|
local file = io.open(modpath .. "/schems/" .. filename, "r")
|
||||||
|
local data = minetest.deserialize(file:read())
|
||||||
|
file:close()
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
local wither_spawn_schems = {}
|
||||||
|
|
||||||
|
for _, d in pairs(dim) do
|
||||||
|
wither_spawn_schems[d] = load_schem("wither_spawn_" .. d .. ".we")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_schem(pos, schem)
|
||||||
|
for _, n in pairs(schem) do
|
||||||
|
if minetest.get_node(vector.add(pos, n)).name ~= n.name then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function remove_schem(pos, schem)
|
||||||
|
for _, n in pairs(schem) do
|
||||||
|
minetest.remove_node(vector.add(pos, n))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function wither_spawn(pos)
|
||||||
|
for _, d in pairs(dim) do
|
||||||
|
for i = 0, 2 do
|
||||||
|
local p = vector.add(pos, {x = 0, y = -2, z = 0, [d] = -i})
|
||||||
|
local schem = wither_spawn_schems[d]
|
||||||
|
if check_schem(p, schem) then
|
||||||
|
remove_schem(p, schem)
|
||||||
|
minetest.add_entity(vector.add(p, {x = 0, y = 1, z = 0, [d] = 1}), "mobs_mc:wither")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local old_onplace=minetest.registered_nodes[mobs_mc.items.head_wither_skeleton].on_place
|
||||||
|
minetest.registered_nodes[mobs_mc.items.head_wither_skeleton].on_place=function(itemstack,placer,pointed)
|
||||||
|
minetest.after(0, wither_spawn, pointed.above)
|
||||||
|
old_onplace(itemstack,placer,pointed)
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
name = mcl_wither_spawning
|
||||||
|
description = Wither Spawning for MineClone2
|
||||||
|
author = Fleckenstein
|
||||||
|
depends = mobs_mc, mcl_heads
|
|
@ -0,0 +1 @@
|
||||||
|
return {{["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}, {["y"] = 0, ["x"] = 1, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 1, ["x"] = 1, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 1, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}, {["y"] = 1, ["x"] = 2, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 2, ["x"] = 2, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 2, ["param1"] = 15}}
|
|
@ -0,0 +1 @@
|
||||||
|
return {{["y"] = 0, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 1}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 0}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 1}, {["y"] = 1, ["x"] = 0, ["name"] = "mcl_nether:soul_sand", ["z"] = 2}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 0, ["param2"] = 1, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 1, ["param2"] = 1, ["param1"] = 15}, {["y"] = 2, ["x"] = 0, ["name"] = "mcl_heads:wither_skeleton", ["z"] = 2, ["param2"] = 1, ["param1"] = 15}}
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2019 TheTermos
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
|
@ -1,6 +0,0 @@
|
||||||
# mobkit
|
|
||||||
Entity API for Minetest
|
|
||||||
|
|
||||||
This library is meant to be shared between mods</br>
|
|
||||||
Please do not write to the mobkit namespace ('mobkit' global table),</br>
|
|
||||||
nor include own copies of mobkit in your mods and modpacks.
|
|
|
@ -1,830 +0,0 @@
|
||||||
local abs = math.abs
|
|
||||||
local pi = math.pi
|
|
||||||
local floor = math.floor
|
|
||||||
local ceil = math.ceil
|
|
||||||
local random = math.random
|
|
||||||
local sqrt = math.sqrt
|
|
||||||
local max = math.max
|
|
||||||
local min = math.min
|
|
||||||
local tan = math.tan
|
|
||||||
local pow = math.pow
|
|
||||||
local dbg = minetest.chat_send_all
|
|
||||||
|
|
||||||
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
|
|
||||||
|
|
||||||
local neighbors ={
|
|
||||||
{x=1,z=0},
|
|
||||||
{x=1,z=1},
|
|
||||||
{x=0,z=1},
|
|
||||||
{x=-1,z=1},
|
|
||||||
{x=-1,z=0},
|
|
||||||
{x=-1,z=-1},
|
|
||||||
{x=0,z=-1},
|
|
||||||
{x=1,z=-1}
|
|
||||||
}
|
|
||||||
|
|
||||||
function [yournamespace].dir2neighbor(dir)
|
|
||||||
dir.y=0
|
|
||||||
dir=vector.round(vector.normalize(dir))
|
|
||||||
for k,v in ipairs(neighbors) do
|
|
||||||
if v.x == dir.x and v.z == dir.z then return k end
|
|
||||||
end
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].neighbor_shift(neighbor,shift) -- int shift: minus is left, plus is right
|
|
||||||
return (8+neighbor+shift-1)%8+1
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].is_neighbor_node_reachable(self,neighbor) -- todo: take either number or pos
|
|
||||||
local offset = neighbors[neighbor]
|
|
||||||
local pos=mobkit.get_stand_pos(self)
|
|
||||||
local tpos = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
local recursteps = ceil(self.jump_height)+1
|
|
||||||
local height, liquidflag = mobkit.get_terrain_height(tpos,recursteps)
|
|
||||||
|
|
||||||
if height and abs(height-pos.y) <= self.jump_height then
|
|
||||||
tpos.y = height
|
|
||||||
height = height - pos.y
|
|
||||||
|
|
||||||
-- don't cut corners
|
|
||||||
if neighbor % 2 == 0 then -- diagonal neighbors are even
|
|
||||||
local n2 = neighbor-1 -- left neighbor never < 0
|
|
||||||
offset = neighbors[n2]
|
|
||||||
local t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
local h2 = mobkit.get_terrain_height(t2,recursteps)
|
|
||||||
if h2 and h2 - pos.y > 0.02 then return end
|
|
||||||
n2 = (neighbor+1)%8 -- right neighbor
|
|
||||||
offset = neighbors[n2]
|
|
||||||
t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
h2 = mobkit.get_terrain_height(t2,recursteps)
|
|
||||||
if h2 and h2 - pos.y > 0.02 then return end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check headroom
|
|
||||||
if tpos.y+self.height-pos.y > 1 then -- if head in next node above, else no point checking headroom
|
|
||||||
local snpos = mobkit.get_node_pos(pos)
|
|
||||||
local pos1 = {x=pos.x,y=snpos.y+1,z=pos.z} -- current pos plus node up
|
|
||||||
local pos2 = {x=tpos.x,y=tpos.y+self.height,z=tpos.z} -- target head pos
|
|
||||||
|
|
||||||
local nodes = mobkit.get_nodes_in_area(pos1,pos2,true)
|
|
||||||
|
|
||||||
for p,node in pairs(nodes) do
|
|
||||||
if snpos.x==p.x and snpos.z==p.z then
|
|
||||||
if node.name=='ignore' or node.walkable then return end
|
|
||||||
else
|
|
||||||
if node.name=='ignore' or
|
|
||||||
(node.walkable and mobkit.get_node_height(p)>tpos.y+0.001) then return end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return height, tpos, liquidflag
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].get_next_waypoint(self,tpos)
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local dir=vector.direction(pos,tpos)
|
|
||||||
local neighbor = [yournamespace].dir2neighbor(dir)
|
|
||||||
local function update_pos_history(self,pos)
|
|
||||||
table.insert(self.pos_history,1,pos)
|
|
||||||
if #self.pos_history > 2 then table.remove(self.pos_history,#self.pos_history) end
|
|
||||||
end
|
|
||||||
local nogopos = self.pos_history[2]
|
|
||||||
|
|
||||||
local height, pos2, liquidflag = [yournamespace].is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height and not liquidflag
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
|
|
||||||
local heightl = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,-1))
|
|
||||||
if heightl and abs(heightl-height)<0.001 then
|
|
||||||
local heightr = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,1))
|
|
||||||
if heightr and abs(heightr-height)<0.001 then
|
|
||||||
dir.y = 0
|
|
||||||
local dirn = vector.normalize(dir)
|
|
||||||
local npos = mobkit.get_node_pos(mobkit.pos_shift(pos,neighbors[neighbor]))
|
|
||||||
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
|
|
||||||
pos2=mobkit.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height, pos2
|
|
||||||
else
|
|
||||||
|
|
||||||
for i=1,3 do
|
|
||||||
-- scan left
|
|
||||||
local height, pos2, liq = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,-i*self.path_dir))
|
|
||||||
if height and not liq
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
-- scan right
|
|
||||||
height, pos2, liq = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,i*self.path_dir))
|
|
||||||
if height and not liq
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--scan rear
|
|
||||||
height, pos2, liquidflag = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,4))
|
|
||||||
if height and not liquidflag
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- stuck condition here
|
|
||||||
table.remove(self.pos_history,2)
|
|
||||||
self.path_dir = self.path_dir*-1 -- subtle change in pathfinding
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].get_next_waypoint_fast(self,tpos,nogopos)
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local dir=vector.direction(pos,tpos)
|
|
||||||
local neighbor = [yournamespace].dir2neighbor(dir)
|
|
||||||
local height, pos2, liquidflag = [yournamespace].is_neighbor_node_reachable(self,neighbor)
|
|
||||||
|
|
||||||
if height and not liquidflag then
|
|
||||||
local fast = false
|
|
||||||
heightl = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,-1))
|
|
||||||
if heightl and abs(heightl-height)<0.001 then
|
|
||||||
heightr = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,1))
|
|
||||||
if heightr and abs(heightr-height)<0.001 then
|
|
||||||
fast = true
|
|
||||||
dir.y = 0
|
|
||||||
local dirn = vector.normalize(dir)
|
|
||||||
local npos = mobkit.get_node_pos(mobkit.pos_shift(pos,neighbors[neighbor]))
|
|
||||||
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
|
|
||||||
pos2=mobkit.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return height, pos2, fast
|
|
||||||
else
|
|
||||||
|
|
||||||
for i=1,4 do
|
|
||||||
-- scan left
|
|
||||||
height, pos2, liq = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,-i))
|
|
||||||
if height and not liq then return height,pos2 end
|
|
||||||
-- scan right
|
|
||||||
height, pos2, liq = [yournamespace].is_neighbor_node_reachable(self,[yournamespace].neighbor_shift(neighbor,i))
|
|
||||||
if height and not liq then return height,pos2 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].goto_next_waypoint(self,tpos)
|
|
||||||
local height, pos2 = [yournamespace].get_next_waypoint(self,tpos)
|
|
||||||
|
|
||||||
if not height then return false end
|
|
||||||
|
|
||||||
if height <= 0.01 then
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local tyaw = minetest.dir_to_yaw(vector.direction(self.object:get_pos(),pos2))
|
|
||||||
if abs(tyaw-yaw) > 1 then
|
|
||||||
[yournamespace].lq_turn2pos(self,pos2)
|
|
||||||
end
|
|
||||||
[yournamespace].lq_dumbwalk(self,pos2)
|
|
||||||
else
|
|
||||||
[yournamespace].lq_turn2pos(self,pos2)
|
|
||||||
[yournamespace].lq_dumbjump(self,height)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
----------------------------
|
|
||||||
-- BEHAVIORS
|
|
||||||
----------------------------
|
|
||||||
-- LOW LEVEL QUEUE FUNCTIONS
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
function [yournamespace].lq_turn2pos(self,tpos)
|
|
||||||
local func=function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
return mobkit.turn2yaw(self,
|
|
||||||
minetest.dir_to_yaw(vector.direction(pos,tpos)))
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_idle(self,duration,anim)
|
|
||||||
anim = anim or 'stand'
|
|
||||||
local init = true
|
|
||||||
local func=function(self)
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,anim)
|
|
||||||
init=false
|
|
||||||
end
|
|
||||||
duration = duration-self.dtime
|
|
||||||
if duration <= 0 then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_dumbwalk(self,dest,speed_factor)
|
|
||||||
local timer = 3 -- failsafe
|
|
||||||
speed_factor = speed_factor or 1
|
|
||||||
local func=function(self)
|
|
||||||
mobkit.animate(self,'walk')
|
|
||||||
timer = timer - self.dtime
|
|
||||||
if timer < 0 then return true end
|
|
||||||
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local y = self.object:get_velocity().y
|
|
||||||
|
|
||||||
if mobkit.is_there_yet2d(pos,minetest.yaw_to_dir(self.object:get_yaw()),dest) then
|
|
||||||
-- if mobkit.isnear2d(pos,dest,0.25) then
|
|
||||||
if not self.isonground or abs(dest.y-pos.y) > 0.1 then -- prevent uncontrolled fall when velocity too high
|
|
||||||
-- if abs(dest.y-pos.y) > 0.1 then -- isonground too slow for speeds > 4
|
|
||||||
self.object:set_velocity({x=0,y=y,z=0})
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.isonground then
|
|
||||||
local dir = vector.normalize(vector.direction({x=pos.x,y=0,z=pos.z},
|
|
||||||
{x=dest.x,y=0,z=dest.z}))
|
|
||||||
dir = vector.multiply(dir,self.max_speed*speed_factor)
|
|
||||||
-- self.object:set_yaw(minetest.dir_to_yaw(dir))
|
|
||||||
mobkit.turn2yaw(self,minetest.dir_to_yaw(dir))
|
|
||||||
dir.y = y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- initial velocity for jump height h, v= a*sqrt(h*2/a) ,add 20%
|
|
||||||
function [yournamespace].lq_dumbjump(self,height,anim)
|
|
||||||
anim = anim or 'stand'
|
|
||||||
local jump = true
|
|
||||||
local func=function(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
if self.isonground then
|
|
||||||
if jump then
|
|
||||||
mobkit.animate(self,anim)
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
dir.y = -mobkit.gravity*sqrt((height+0.35)*2/-mobkit.gravity)
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
jump = false
|
|
||||||
else -- the eagle has landed
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if self.lastvelocity.y < 0.9 then
|
|
||||||
dir = vector.multiply(dir,3)
|
|
||||||
end
|
|
||||||
dir.y = vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_jumpout(self)
|
|
||||||
local phase = 1
|
|
||||||
local func=function(self)
|
|
||||||
local vel=self.object:get_velocity()
|
|
||||||
if phase == 1 then
|
|
||||||
vel.y=vel.y+5
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
phase = 2
|
|
||||||
else
|
|
||||||
if vel.y < 0 then return true end
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir.y=vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_freejump(self)
|
|
||||||
local phase = 1
|
|
||||||
local func=function(self)
|
|
||||||
local vel=self.object:get_velocity()
|
|
||||||
if phase == 1 then
|
|
||||||
vel.y=vel.y+6
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
phase = 2
|
|
||||||
else
|
|
||||||
if vel.y <= 0.01 then return true end
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir.y=vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_jumpattack(self,height,target)
|
|
||||||
local init=true
|
|
||||||
local timer=0.5
|
|
||||||
local tgtbox = target:get_properties().collisionbox
|
|
||||||
local func=function(self)
|
|
||||||
if not mobkit.is_alive(target) then return true end
|
|
||||||
if self.isonground then
|
|
||||||
if init then -- collision bug workaround
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir=vector.multiply(dir,6)
|
|
||||||
dir.y = -mobkit.gravity*sqrt(height*2/-mobkit.gravity)
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
mobkit.make_sound(self,'charge')
|
|
||||||
init=false
|
|
||||||
else
|
|
||||||
[yournamespace].lq_idle(self,0.3)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local tgtpos = target:get_pos()
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
-- calculate attack spot
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
local apos = mobkit.pos_translate2d(pos,yaw,self.attack.range)
|
|
||||||
|
|
||||||
if mobkit.is_pos_in_box(apos,tgtpos,tgtbox) then --bite
|
|
||||||
target:punch(self.object,1,self.attack)
|
|
||||||
-- bounce off
|
|
||||||
local vy = self.object:get_velocity().y
|
|
||||||
self.object:set_velocity({x=dir.x*-3,y=vy,z=dir.z*-3})
|
|
||||||
-- play attack sound if defined
|
|
||||||
mobkit.make_sound(self,'attack')
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].lq_fallover(self)
|
|
||||||
local zrot = 0
|
|
||||||
local init = true
|
|
||||||
local func=function(self)
|
|
||||||
if init then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
self.object:set_velocity(mobkit.pos_shift(vel,{y=1}))
|
|
||||||
mobkit.animate(self,'stand')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
zrot=zrot+pi*0.05
|
|
||||||
local rot = self.object:get_rotation()
|
|
||||||
self.object:set_rotation({x=rot.x,y=rot.y,z=zrot})
|
|
||||||
if zrot >= pi*0.5 then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
-----------------------------
|
|
||||||
-- HIGH LEVEL QUEUE FUNCTIONS
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
function [yournamespace].dumbstep(self,height,tpos,speed_factor,idle_duration)
|
|
||||||
if height <= 0.001 then
|
|
||||||
[yournamespace].lq_turn2pos(self,tpos)
|
|
||||||
[yournamespace].lq_dumbwalk(self,tpos,speed_factor)
|
|
||||||
else
|
|
||||||
[yournamespace].lq_turn2pos(self,tpos)
|
|
||||||
[yournamespace].lq_dumbjump(self,height)
|
|
||||||
end
|
|
||||||
idle_duration = idle_duration or 6
|
|
||||||
[yournamespace].lq_idle(self,random(ceil(idle_duration*0.5),idle_duration))
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_roam(self,prty)
|
|
||||||
local func=function(self)
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local neighbor = random(8)
|
|
||||||
|
|
||||||
local height, tpos, liquidflag = [yournamespace].is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height and not liquidflag then [yournamespace].dumbstep(self,height,tpos,0.3) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_follow0(self,tgtobj) -- probably delete this one
|
|
||||||
local func = function(self)
|
|
||||||
if not tgtobj then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) > 3 then
|
|
||||||
local neighbor = [yournamespace].dir2neighbor(vector.direction(pos,opos))
|
|
||||||
if not neighbor then return true end --temp debug
|
|
||||||
local height, tpos = [yournamespace].is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height then [yournamespace].dumbstep(self,height,tpos)
|
|
||||||
else
|
|
||||||
for i=1,4 do --scan left
|
|
||||||
height, tpos = [yournamespace].is_neighbor_node_reachable(self,(8+neighbor-i-1)%8+1)
|
|
||||||
if height then [yournamespace].dumbstep(self,height,tpos)
|
|
||||||
break
|
|
||||||
end --scan right
|
|
||||||
height, tpos = [yournamespace].is_neighbor_node_reachable(self,(neighbor+i-1)%8+1)
|
|
||||||
if height then [yournamespace].dumbstep(self,height,tpos)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
[yournamespace].lq_idle(self,1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,0)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_follow(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) > 3 then
|
|
||||||
[yournamespace].goto_next_waypoint(self,opos)
|
|
||||||
else
|
|
||||||
[yournamespace].lq_idle(self,1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_goto(self,prty,tpos)
|
|
||||||
local func = function(self)
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
if vector.distance(pos,tpos) > 3 then
|
|
||||||
[yournamespace].goto_next_waypoint(self,tpos)
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_runfrom(self,prty,tgtobj)
|
|
||||||
local init=true
|
|
||||||
local timer=6
|
|
||||||
local func = function(self)
|
|
||||||
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
timer = timer-self.dtime
|
|
||||||
if timer <=0 or vector.distance(self.object:get_pos(),tgtobj:get_pos()) < 8 then
|
|
||||||
mobkit.make_sound(self,'scared')
|
|
||||||
init=false
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) < self.view_range*1.1 then
|
|
||||||
local tpos = {x=2*pos.x - opos.x,
|
|
||||||
y=opos.y,
|
|
||||||
z=2*pos.z - opos.z}
|
|
||||||
[yournamespace].goto_next_waypoint(self,tpos)
|
|
||||||
else
|
|
||||||
self.object:set_velocity({x=0,y=0,z=0})
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_hunt(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
local dist = vector.distance(pos,opos)
|
|
||||||
if dist > self.view_range then
|
|
||||||
return true
|
|
||||||
elseif dist > 3 then
|
|
||||||
[yournamespace].goto_next_waypoint(self,opos)
|
|
||||||
else
|
|
||||||
[yournamespace].hq_attack(self,prty+1,tgtobj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_warn(self,prty,tgtobj)
|
|
||||||
local timer=0
|
|
||||||
local tgttime = 0
|
|
||||||
local init = true
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'stand')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
local dist = vector.distance(pos,opos)
|
|
||||||
|
|
||||||
if dist > 11 then
|
|
||||||
return true
|
|
||||||
elseif dist < 4 or timer > 12 then -- too close man
|
|
||||||
-- mobkit.clear_queue_high(self)
|
|
||||||
mobkit.remember(self,'hate',tgtobj:get_player_name())
|
|
||||||
[yournamespace].hq_hunt(self,prty+1,tgtobj) -- priority
|
|
||||||
else
|
|
||||||
timer = timer+self.dtime
|
|
||||||
if mobkit.is_queue_empty_low(self) then
|
|
||||||
[yournamespace].lq_turn2pos(self,opos)
|
|
||||||
end
|
|
||||||
-- make noise in random intervals
|
|
||||||
if timer > tgttime then
|
|
||||||
mobkit.make_sound(self,'warn')
|
|
||||||
-- if self.sounds and self.sounds.warn then
|
|
||||||
-- minetest.sound_play(self.sounds.warn, {object=self.object})
|
|
||||||
-- end
|
|
||||||
tgttime = timer + 1.1 + random()*1.5
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_die(self)
|
|
||||||
local timer = 5
|
|
||||||
local start = true
|
|
||||||
local func = function(self)
|
|
||||||
if start then
|
|
||||||
[yournamespace].lq_fallover(self)
|
|
||||||
self.logic = function(self) end -- brain dead as well
|
|
||||||
start=false
|
|
||||||
end
|
|
||||||
timer = timer-self.dtime
|
|
||||||
if timer < 0 then self.object:remove() end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,100)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_attack(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
-- local tpos = tgtobj:get_pos()
|
|
||||||
local tpos = mobkit.get_stand_pos(tgtobj)
|
|
||||||
local dist = vector.distance(pos,tpos)
|
|
||||||
if dist > 3 then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
[yournamespace].lq_turn2pos(self,tpos)
|
|
||||||
local height = tgtobj:is_player() and 0.35 or tgtobj:get_luaentity().height*0.6
|
|
||||||
if tpos.y+height>pos.y then
|
|
||||||
[yournamespace].lq_jumpattack(self,tpos.y+height-pos.y,tgtobj)
|
|
||||||
else
|
|
||||||
[yournamespace].lq_dumbwalk(self,mobkit.pos_shift(tpos,{x=random()-0.5,z=random()-0.5}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_liquid_recovery(self,prty) -- scan for nearest land
|
|
||||||
local radius = 1
|
|
||||||
local yaw = 0
|
|
||||||
local func = function(self)
|
|
||||||
if not self.isinliquid then return true end
|
|
||||||
local pos=self.object:get_pos()
|
|
||||||
local vec = minetest.yaw_to_dir(yaw)
|
|
||||||
local pos2 = mobkit.pos_shift(pos,vector.multiply(vec,radius))
|
|
||||||
local height, liquidflag = mobkit.get_terrain_height(pos2)
|
|
||||||
if height and not liquidflag then
|
|
||||||
[yournamespace].hq_swimto(self,prty,pos2)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
yaw=yaw+pi*0.25
|
|
||||||
if yaw>2*pi then
|
|
||||||
yaw = 0
|
|
||||||
radius=radius+1
|
|
||||||
if radius > self.view_range then
|
|
||||||
self.hp = 0
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_swimto(self,prty,tpos)
|
|
||||||
local box = self.object:get_properties().collisionbox
|
|
||||||
local cols = {}
|
|
||||||
local func = function(self)
|
|
||||||
if not self.isinliquid then
|
|
||||||
if self.isonground then return true end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local y=self.object:get_velocity().y
|
|
||||||
local pos2d = {x=pos.x,y=tpos.y,z=pos.z}
|
|
||||||
local dir=vector.normalize(vector.direction(pos2d,tpos))
|
|
||||||
local yaw = minetest.dir_to_yaw(dir)
|
|
||||||
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
cols = mobkit.get_box_displace_cols(pos,box,dir,1)
|
|
||||||
for _,p in ipairs(cols[1]) do
|
|
||||||
p.y=pos.y
|
|
||||||
local h,l = mobkit.get_terrain_height(p)
|
|
||||||
if h and h>pos.y and self.isinliquid then
|
|
||||||
[yournamespace].lq_freejump(self)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif mobkit.turn2yaw(self,yaw) then
|
|
||||||
dir.y = y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
---------------------
|
|
||||||
-- AQUATIC
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
-- MACROS
|
|
||||||
local function aqua_radar_dumb(pos,yaw,range,reverse)
|
|
||||||
range = range or 4
|
|
||||||
|
|
||||||
local function okpos(p)
|
|
||||||
local node = mobkit.nodeatpos(p)
|
|
||||||
if node then
|
|
||||||
if node.drawtype == 'liquid' then
|
|
||||||
local nodeu = mobkit.nodeatpos(mobkit.pos_shift(p,{y=1}))
|
|
||||||
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=-1}))
|
|
||||||
if (nodeu and nodeu.drawtype == 'liquid') or (noded and noded.drawtype == 'liquid') then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local h,l = mobkit.get_terrain_height(p)
|
|
||||||
if h then
|
|
||||||
local node2 = mobkit.nodeatpos({x=p.x,y=h+1.99,z=p.z})
|
|
||||||
if node2 and node2.drawtype == 'liquid' then return true, h end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local fpos = mobkit.pos_translate2d(pos,yaw,range)
|
|
||||||
local ok,h = okpos(fpos)
|
|
||||||
if not ok then
|
|
||||||
local ffrom, fto, fstep
|
|
||||||
if reverse then
|
|
||||||
ffrom, fto, fstep = 3,1,-1
|
|
||||||
else
|
|
||||||
ffrom, fto, fstep = 1,3,1
|
|
||||||
end
|
|
||||||
for i=ffrom, fto, fstep do
|
|
||||||
local ok,h = okpos(mobkit.pos_translate2d(pos,yaw+i,range))
|
|
||||||
if ok then return yaw+i,h end
|
|
||||||
ok,h = okpos(mobkit.pos_translate2d(pos,yaw-i,range))
|
|
||||||
if ok then return yaw-i,h end
|
|
||||||
end
|
|
||||||
return yaw+pi,h
|
|
||||||
else
|
|
||||||
return yaw, h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].is_in_deep(target)
|
|
||||||
if not target then return false end
|
|
||||||
local nodepos = mobkit.get_stand_pos(target)
|
|
||||||
local node1 = mobkit.nodeatpos(nodepos)
|
|
||||||
nodepos.y=nodepos.y+1
|
|
||||||
local node2 = mobkit.nodeatpos(nodepos)
|
|
||||||
nodepos.y=nodepos.y-2
|
|
||||||
local node3 = mobkit.nodeatpos(nodepos)
|
|
||||||
if node1 and node2 and node3 and node1.drawtype=='liquid' and (node2.drawtype=='liquid' or node3.drawtype=='liquid') then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- HQ behaviors
|
|
||||||
|
|
||||||
function [yournamespace].hq_aqua_roam(self,prty,speed)
|
|
||||||
local tyaw = 0
|
|
||||||
local init = true
|
|
||||||
local prvscanpos = {x=0,y=0,z=0}
|
|
||||||
local center = self.object:get_pos()
|
|
||||||
local func = function(self)
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'def')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local scanpos = mobkit.get_node_pos(mobkit.pos_translate2d(pos,yaw,speed))
|
|
||||||
if not vector.equals(prvscanpos,scanpos) then
|
|
||||||
prvscanpos=scanpos
|
|
||||||
local nyaw,height = aqua_radar_dumb(pos,yaw,speed,true)
|
|
||||||
if height and height > pos.y then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
vel.y = vel.y+1
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
end
|
|
||||||
if yaw ~= nyaw then
|
|
||||||
tyaw=nyaw
|
|
||||||
[yournamespace].hq_aqua_turn(self,prty+1,tyaw,speed)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
if vector.distance(pos,center) > abr*16*0.5 then
|
|
||||||
tyaw = minetest.dir_to_yaw(vector.direction(pos,{x=center.x+random()*10-5,y=center.y,z=center.z+random()*10-5}))
|
|
||||||
else
|
|
||||||
if random(10)>=9 then tyaw=tyaw+random()*pi - pi*0.5 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mobkit.turn2yaw(self,tyaw,3)
|
|
||||||
-- local yaw = self.object:get_yaw()
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_aqua_turn(self,prty,tyaw,speed)
|
|
||||||
local func = function(self)
|
|
||||||
local finished=mobkit.turn2yaw(self,tyaw)
|
|
||||||
-- local yaw = self.object:get_yaw()
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
if finished then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function [yournamespace].hq_aqua_attack(self,prty,tgtobj,speed)
|
|
||||||
local tyaw = 0
|
|
||||||
local prvscanpos = {x=0,y=0,z=0}
|
|
||||||
local init = true
|
|
||||||
local tgtbox = tgtobj:get_properties().collisionbox
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'fast')
|
|
||||||
mobkit.make_sound(self,'attack')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local scanpos = mobkit.get_node_pos(mobkit.pos_translate2d(pos,yaw,speed))
|
|
||||||
if not vector.equals(prvscanpos,scanpos) then
|
|
||||||
prvscanpos=scanpos
|
|
||||||
local nyaw,height = aqua_radar_dumb(pos,yaw,speed*0.5)
|
|
||||||
if height and height > pos.y then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
vel.y = vel.y+1
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
end
|
|
||||||
if yaw ~= nyaw then
|
|
||||||
tyaw=nyaw
|
|
||||||
[yournamespace].hq_aqua_turn(self,prty+1,tyaw,speed)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local tpos = tgtobj:get_pos()
|
|
||||||
local tyaw=minetest.dir_to_yaw(vector.direction(pos,tpos))
|
|
||||||
mobkit.turn2yaw(self,tyaw,3)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
if not [yournamespace].is_in_deep(tgtobj) then return true end
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if tpos.y>pos.y+0.5 then self.object:set_velocity({x=vel.x,y=vel.y+0.5,z=vel.z})
|
|
||||||
elseif tpos.y<pos.y-0.5 then self.object:set_velocity({x=vel.x,y=vel.y-0.5,z=vel.z}) end
|
|
||||||
end
|
|
||||||
if mobkit.is_pos_in_box(mobkit.pos_translate2d(pos,yaw,self.attack.range),tpos,tgtbox) then --bite
|
|
||||||
tgtobj:punch(self.object,1,self.attack)
|
|
||||||
[yournamespace].hq_aqua_turn(self,prty,yaw-pi,speed)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
|
@ -1,830 +0,0 @@
|
||||||
local abs = math.abs
|
|
||||||
local pi = math.pi
|
|
||||||
local floor = math.floor
|
|
||||||
local ceil = math.ceil
|
|
||||||
local random = math.random
|
|
||||||
local sqrt = math.sqrt
|
|
||||||
local max = math.max
|
|
||||||
local min = math.min
|
|
||||||
local tan = math.tan
|
|
||||||
local pow = math.pow
|
|
||||||
local dbg = minetest.chat_send_all
|
|
||||||
|
|
||||||
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
|
|
||||||
|
|
||||||
local neighbors ={
|
|
||||||
{x=1,z=0},
|
|
||||||
{x=1,z=1},
|
|
||||||
{x=0,z=1},
|
|
||||||
{x=-1,z=1},
|
|
||||||
{x=-1,z=0},
|
|
||||||
{x=-1,z=-1},
|
|
||||||
{x=0,z=-1},
|
|
||||||
{x=1,z=-1}
|
|
||||||
}
|
|
||||||
|
|
||||||
function mobkit.dir2neighbor(dir)
|
|
||||||
dir.y=0
|
|
||||||
dir=vector.round(vector.normalize(dir))
|
|
||||||
for k,v in ipairs(neighbors) do
|
|
||||||
if v.x == dir.x and v.z == dir.z then return k end
|
|
||||||
end
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.neighbor_shift(neighbor,shift) -- int shift: minus is left, plus is right
|
|
||||||
return (8+neighbor+shift-1)%8+1
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_neighbor_node_reachable(self,neighbor) -- todo: take either number or pos
|
|
||||||
local offset = neighbors[neighbor]
|
|
||||||
local pos=mobkit.get_stand_pos(self)
|
|
||||||
local tpos = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
local recursteps = ceil(self.jump_height)+1
|
|
||||||
local height, liquidflag = mobkit.get_terrain_height(tpos,recursteps)
|
|
||||||
|
|
||||||
if height and abs(height-pos.y) <= self.jump_height then
|
|
||||||
tpos.y = height
|
|
||||||
height = height - pos.y
|
|
||||||
|
|
||||||
-- don't cut corners
|
|
||||||
if neighbor % 2 == 0 then -- diagonal neighbors are even
|
|
||||||
local n2 = neighbor-1 -- left neighbor never < 0
|
|
||||||
offset = neighbors[n2]
|
|
||||||
local t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
local h2 = mobkit.get_terrain_height(t2,recursteps)
|
|
||||||
if h2 and h2 - pos.y > 0.02 then return end
|
|
||||||
n2 = (neighbor+1)%8 -- right neighbor
|
|
||||||
offset = neighbors[n2]
|
|
||||||
t2 = mobkit.get_node_pos(mobkit.pos_shift(pos,offset))
|
|
||||||
h2 = mobkit.get_terrain_height(t2,recursteps)
|
|
||||||
if h2 and h2 - pos.y > 0.02 then return end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check headroom
|
|
||||||
if tpos.y+self.height-pos.y > 1 then -- if head in next node above, else no point checking headroom
|
|
||||||
local snpos = mobkit.get_node_pos(pos)
|
|
||||||
local pos1 = {x=pos.x,y=snpos.y+1,z=pos.z} -- current pos plus node up
|
|
||||||
local pos2 = {x=tpos.x,y=tpos.y+self.height,z=tpos.z} -- target head pos
|
|
||||||
|
|
||||||
local nodes = mobkit.get_nodes_in_area(pos1,pos2,true)
|
|
||||||
|
|
||||||
for p,node in pairs(nodes) do
|
|
||||||
if snpos.x==p.x and snpos.z==p.z then
|
|
||||||
if node.name=='ignore' or node.walkable then return end
|
|
||||||
else
|
|
||||||
if node.name=='ignore' or
|
|
||||||
(node.walkable and mobkit.get_node_height(p)>tpos.y+0.001) then return end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return height, tpos, liquidflag
|
|
||||||
else
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_next_waypoint(self,tpos)
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local dir=vector.direction(pos,tpos)
|
|
||||||
local neighbor = mobkit.dir2neighbor(dir)
|
|
||||||
local function update_pos_history(self,pos)
|
|
||||||
table.insert(self.pos_history,1,pos)
|
|
||||||
if #self.pos_history > 2 then table.remove(self.pos_history,#self.pos_history) end
|
|
||||||
end
|
|
||||||
local nogopos = self.pos_history[2]
|
|
||||||
|
|
||||||
local height, pos2, liquidflag = mobkit.is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height and not liquidflag
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
|
|
||||||
local heightl = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,-1))
|
|
||||||
if heightl and abs(heightl-height)<0.001 then
|
|
||||||
local heightr = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,1))
|
|
||||||
if heightr and abs(heightr-height)<0.001 then
|
|
||||||
dir.y = 0
|
|
||||||
local dirn = vector.normalize(dir)
|
|
||||||
local npos = mobkit.get_node_pos(mobkit.pos_shift(pos,neighbors[neighbor]))
|
|
||||||
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
|
|
||||||
pos2=mobkit.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height, pos2
|
|
||||||
else
|
|
||||||
|
|
||||||
for i=1,3 do
|
|
||||||
-- scan left
|
|
||||||
local height, pos2, liq = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,-i*self.path_dir))
|
|
||||||
if height and not liq
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
-- scan right
|
|
||||||
height, pos2, liq = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,i*self.path_dir))
|
|
||||||
if height and not liq
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--scan rear
|
|
||||||
height, pos2, liquidflag = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,4))
|
|
||||||
if height and not liquidflag
|
|
||||||
and not (nogopos and mobkit.isnear2d(pos2,nogopos,0.1)) then
|
|
||||||
update_pos_history(self,pos2)
|
|
||||||
return height,pos2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- stuck condition here
|
|
||||||
table.remove(self.pos_history,2)
|
|
||||||
self.path_dir = self.path_dir*-1 -- subtle change in pathfinding
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_next_waypoint_fast(self,tpos,nogopos)
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local dir=vector.direction(pos,tpos)
|
|
||||||
local neighbor = mobkit.dir2neighbor(dir)
|
|
||||||
local height, pos2, liquidflag = mobkit.is_neighbor_node_reachable(self,neighbor)
|
|
||||||
|
|
||||||
if height and not liquidflag then
|
|
||||||
local fast = false
|
|
||||||
heightl = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,-1))
|
|
||||||
if heightl and abs(heightl-height)<0.001 then
|
|
||||||
heightr = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,1))
|
|
||||||
if heightr and abs(heightr-height)<0.001 then
|
|
||||||
fast = true
|
|
||||||
dir.y = 0
|
|
||||||
local dirn = vector.normalize(dir)
|
|
||||||
local npos = mobkit.get_node_pos(mobkit.pos_shift(pos,neighbors[neighbor]))
|
|
||||||
local factor = abs(dirn.x) > abs(dirn.z) and abs(npos.x-pos.x) or abs(npos.z-pos.z)
|
|
||||||
pos2=mobkit.pos_shift(pos,{x=dirn.x*factor,z=dirn.z*factor})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return height, pos2, fast
|
|
||||||
else
|
|
||||||
|
|
||||||
for i=1,4 do
|
|
||||||
-- scan left
|
|
||||||
height, pos2, liq = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,-i))
|
|
||||||
if height and not liq then return height,pos2 end
|
|
||||||
-- scan right
|
|
||||||
height, pos2, liq = mobkit.is_neighbor_node_reachable(self,mobkit.neighbor_shift(neighbor,i))
|
|
||||||
if height and not liq then return height,pos2 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.goto_next_waypoint(self,tpos)
|
|
||||||
local height, pos2 = mobkit.get_next_waypoint(self,tpos)
|
|
||||||
|
|
||||||
if not height then return false end
|
|
||||||
|
|
||||||
if height <= 0.01 then
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local tyaw = minetest.dir_to_yaw(vector.direction(self.object:get_pos(),pos2))
|
|
||||||
if abs(tyaw-yaw) > 1 then
|
|
||||||
mobkit.lq_turn2pos(self,pos2)
|
|
||||||
end
|
|
||||||
mobkit.lq_dumbwalk(self,pos2)
|
|
||||||
else
|
|
||||||
mobkit.lq_turn2pos(self,pos2)
|
|
||||||
mobkit.lq_dumbjump(self,height)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
----------------------------
|
|
||||||
-- BEHAVIORS
|
|
||||||
----------------------------
|
|
||||||
-- LOW LEVEL QUEUE FUNCTIONS
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
function mobkit.lq_turn2pos(self,tpos)
|
|
||||||
local func=function(self)
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
return mobkit.turn2yaw(self,
|
|
||||||
minetest.dir_to_yaw(vector.direction(pos,tpos)))
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_idle(self,duration,anim)
|
|
||||||
anim = anim or 'stand'
|
|
||||||
local init = true
|
|
||||||
local func=function(self)
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,anim)
|
|
||||||
init=false
|
|
||||||
end
|
|
||||||
duration = duration-self.dtime
|
|
||||||
if duration <= 0 then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_dumbwalk(self,dest,speed_factor)
|
|
||||||
local timer = 3 -- failsafe
|
|
||||||
speed_factor = speed_factor or 1
|
|
||||||
local func=function(self)
|
|
||||||
mobkit.animate(self,'walk')
|
|
||||||
timer = timer - self.dtime
|
|
||||||
if timer < 0 then return true end
|
|
||||||
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local y = self.object:get_velocity().y
|
|
||||||
|
|
||||||
if mobkit.is_there_yet2d(pos,minetest.yaw_to_dir(self.object:get_yaw()),dest) then
|
|
||||||
-- if mobkit.isnear2d(pos,dest,0.25) then
|
|
||||||
if not self.isonground or abs(dest.y-pos.y) > 0.1 then -- prevent uncontrolled fall when velocity too high
|
|
||||||
-- if abs(dest.y-pos.y) > 0.1 then -- isonground too slow for speeds > 4
|
|
||||||
self.object:set_velocity({x=0,y=y,z=0})
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.isonground then
|
|
||||||
local dir = vector.normalize(vector.direction({x=pos.x,y=0,z=pos.z},
|
|
||||||
{x=dest.x,y=0,z=dest.z}))
|
|
||||||
dir = vector.multiply(dir,self.max_speed*speed_factor)
|
|
||||||
-- self.object:set_yaw(minetest.dir_to_yaw(dir))
|
|
||||||
mobkit.turn2yaw(self,minetest.dir_to_yaw(dir))
|
|
||||||
dir.y = y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- initial velocity for jump height h, v= a*sqrt(h*2/a) ,add 20%
|
|
||||||
function mobkit.lq_dumbjump(self,height,anim)
|
|
||||||
anim = anim or 'stand'
|
|
||||||
local jump = true
|
|
||||||
local func=function(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
if self.isonground then
|
|
||||||
if jump then
|
|
||||||
mobkit.animate(self,anim)
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
dir.y = -mobkit.gravity*sqrt((height+0.35)*2/-mobkit.gravity)
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
jump = false
|
|
||||||
else -- the eagle has landed
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if self.lastvelocity.y < 0.9 then
|
|
||||||
dir = vector.multiply(dir,3)
|
|
||||||
end
|
|
||||||
dir.y = vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_jumpout(self)
|
|
||||||
local phase = 1
|
|
||||||
local func=function(self)
|
|
||||||
local vel=self.object:get_velocity()
|
|
||||||
if phase == 1 then
|
|
||||||
vel.y=vel.y+5
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
phase = 2
|
|
||||||
else
|
|
||||||
if vel.y < 0 then return true end
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir.y=vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_freejump(self)
|
|
||||||
local phase = 1
|
|
||||||
local func=function(self)
|
|
||||||
local vel=self.object:get_velocity()
|
|
||||||
if phase == 1 then
|
|
||||||
vel.y=vel.y+6
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
phase = 2
|
|
||||||
else
|
|
||||||
if vel.y <= 0.01 then return true end
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir.y=vel.y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_jumpattack(self,height,target)
|
|
||||||
local init=true
|
|
||||||
local timer=0.5
|
|
||||||
local tgtbox = target:get_properties().collisionbox
|
|
||||||
local func=function(self)
|
|
||||||
if not mobkit.is_alive(target) then return true end
|
|
||||||
if self.isonground then
|
|
||||||
if init then -- collision bug workaround
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
local dir = minetest.yaw_to_dir(self.object:get_yaw())
|
|
||||||
dir=vector.multiply(dir,6)
|
|
||||||
dir.y = -mobkit.gravity*sqrt(height*2/-mobkit.gravity)
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
mobkit.make_sound(self,'charge')
|
|
||||||
init=false
|
|
||||||
else
|
|
||||||
mobkit.lq_idle(self,0.3)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local tgtpos = target:get_pos()
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
-- calculate attack spot
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local dir = minetest.yaw_to_dir(yaw)
|
|
||||||
local apos = mobkit.pos_translate2d(pos,yaw,self.attack.range)
|
|
||||||
|
|
||||||
if mobkit.is_pos_in_box(apos,tgtpos,tgtbox) then --bite
|
|
||||||
target:punch(self.object,1,self.attack)
|
|
||||||
-- bounce off
|
|
||||||
local vy = self.object:get_velocity().y
|
|
||||||
self.object:set_velocity({x=dir.x*-3,y=vy,z=dir.z*-3})
|
|
||||||
-- play attack sound if defined
|
|
||||||
mobkit.make_sound(self,'attack')
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.lq_fallover(self)
|
|
||||||
local zrot = 0
|
|
||||||
local init = true
|
|
||||||
local func=function(self)
|
|
||||||
if init then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
self.object:set_velocity(mobkit.pos_shift(vel,{y=1}))
|
|
||||||
mobkit.animate(self,'stand')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
zrot=zrot+pi*0.05
|
|
||||||
local rot = self.object:get_rotation()
|
|
||||||
self.object:set_rotation({x=rot.x,y=rot.y,z=zrot})
|
|
||||||
if zrot >= pi*0.5 then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func)
|
|
||||||
end
|
|
||||||
-----------------------------
|
|
||||||
-- HIGH LEVEL QUEUE FUNCTIONS
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
function mobkit.dumbstep(self,height,tpos,speed_factor,idle_duration)
|
|
||||||
if height <= 0.001 then
|
|
||||||
mobkit.lq_turn2pos(self,tpos)
|
|
||||||
mobkit.lq_dumbwalk(self,tpos,speed_factor)
|
|
||||||
else
|
|
||||||
mobkit.lq_turn2pos(self,tpos)
|
|
||||||
mobkit.lq_dumbjump(self,height)
|
|
||||||
end
|
|
||||||
idle_duration = idle_duration or 6
|
|
||||||
mobkit.lq_idle(self,random(ceil(idle_duration*0.5),idle_duration))
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_roam(self,prty)
|
|
||||||
local func=function(self)
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local neighbor = random(8)
|
|
||||||
|
|
||||||
local height, tpos, liquidflag = mobkit.is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height and not liquidflag then mobkit.dumbstep(self,height,tpos,0.3) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_follow0(self,tgtobj) -- probably delete this one
|
|
||||||
local func = function(self)
|
|
||||||
if not tgtobj then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) > 3 then
|
|
||||||
local neighbor = mobkit.dir2neighbor(vector.direction(pos,opos))
|
|
||||||
if not neighbor then return true end --temp debug
|
|
||||||
local height, tpos = mobkit.is_neighbor_node_reachable(self,neighbor)
|
|
||||||
if height then mobkit.dumbstep(self,height,tpos)
|
|
||||||
else
|
|
||||||
for i=1,4 do --scan left
|
|
||||||
height, tpos = mobkit.is_neighbor_node_reachable(self,(8+neighbor-i-1)%8+1)
|
|
||||||
if height then mobkit.dumbstep(self,height,tpos)
|
|
||||||
break
|
|
||||||
end --scan right
|
|
||||||
height, tpos = mobkit.is_neighbor_node_reachable(self,(neighbor+i-1)%8+1)
|
|
||||||
if height then mobkit.dumbstep(self,height,tpos)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
mobkit.lq_idle(self,1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,0)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_follow(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) > 3 then
|
|
||||||
mobkit.goto_next_waypoint(self,opos)
|
|
||||||
else
|
|
||||||
mobkit.lq_idle(self,1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_goto(self,prty,tpos)
|
|
||||||
local func = function(self)
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
if vector.distance(pos,tpos) > 3 then
|
|
||||||
mobkit.goto_next_waypoint(self,tpos)
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_runfrom(self,prty,tgtobj)
|
|
||||||
local init=true
|
|
||||||
local timer=6
|
|
||||||
local func = function(self)
|
|
||||||
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
timer = timer-self.dtime
|
|
||||||
if timer <=0 or vector.distance(self.object:get_pos(),tgtobj:get_pos()) < 8 then
|
|
||||||
mobkit.make_sound(self,'scared')
|
|
||||||
init=false
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
if vector.distance(pos,opos) < self.view_range*1.1 then
|
|
||||||
local tpos = {x=2*pos.x - opos.x,
|
|
||||||
y=opos.y,
|
|
||||||
z=2*pos.z - opos.z}
|
|
||||||
mobkit.goto_next_waypoint(self,tpos)
|
|
||||||
else
|
|
||||||
self.object:set_velocity({x=0,y=0,z=0})
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_hunt(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) and self.isonground then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
local dist = vector.distance(pos,opos)
|
|
||||||
if dist > self.view_range then
|
|
||||||
return true
|
|
||||||
elseif dist > 3 then
|
|
||||||
mobkit.goto_next_waypoint(self,opos)
|
|
||||||
else
|
|
||||||
mobkit.hq_attack(self,prty+1,tgtobj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_warn(self,prty,tgtobj)
|
|
||||||
local timer=0
|
|
||||||
local tgttime = 0
|
|
||||||
local init = true
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'stand')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local opos = tgtobj:get_pos()
|
|
||||||
local dist = vector.distance(pos,opos)
|
|
||||||
|
|
||||||
if dist > 11 then
|
|
||||||
return true
|
|
||||||
elseif dist < 4 or timer > 12 then -- too close man
|
|
||||||
-- mobkit.clear_queue_high(self)
|
|
||||||
mobkit.remember(self,'hate',tgtobj:get_player_name())
|
|
||||||
mobkit.hq_hunt(self,prty+1,tgtobj) -- priority
|
|
||||||
else
|
|
||||||
timer = timer+self.dtime
|
|
||||||
if mobkit.is_queue_empty_low(self) then
|
|
||||||
mobkit.lq_turn2pos(self,opos)
|
|
||||||
end
|
|
||||||
-- make noise in random intervals
|
|
||||||
if timer > tgttime then
|
|
||||||
mobkit.make_sound(self,'warn')
|
|
||||||
-- if self.sounds and self.sounds.warn then
|
|
||||||
-- minetest.sound_play(self.sounds.warn, {object=self.object})
|
|
||||||
-- end
|
|
||||||
tgttime = timer + 1.1 + random()*1.5
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_die(self)
|
|
||||||
local timer = 5
|
|
||||||
local start = true
|
|
||||||
local func = function(self)
|
|
||||||
if start then
|
|
||||||
mobkit.lq_fallover(self)
|
|
||||||
self.logic = function(self) end -- brain dead as well
|
|
||||||
start=false
|
|
||||||
end
|
|
||||||
timer = timer-self.dtime
|
|
||||||
if timer < 0 then self.object:remove() end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,100)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_attack(self,prty,tgtobj)
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if mobkit.is_queue_empty_low(self) then
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
-- local tpos = tgtobj:get_pos()
|
|
||||||
local tpos = mobkit.get_stand_pos(tgtobj)
|
|
||||||
local dist = vector.distance(pos,tpos)
|
|
||||||
if dist > 3 then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
mobkit.lq_turn2pos(self,tpos)
|
|
||||||
local height = tgtobj:is_player() and 0.35 or tgtobj:get_luaentity().height*0.6
|
|
||||||
if tpos.y+height>pos.y then
|
|
||||||
mobkit.lq_jumpattack(self,tpos.y+height-pos.y,tgtobj)
|
|
||||||
else
|
|
||||||
mobkit.lq_dumbwalk(self,mobkit.pos_shift(tpos,{x=random()-0.5,z=random()-0.5}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_liquid_recovery(self,prty) -- scan for nearest land
|
|
||||||
local radius = 1
|
|
||||||
local yaw = 0
|
|
||||||
local func = function(self)
|
|
||||||
if not self.isinliquid then return true end
|
|
||||||
local pos=self.object:get_pos()
|
|
||||||
local vec = minetest.yaw_to_dir(yaw)
|
|
||||||
local pos2 = mobkit.pos_shift(pos,vector.multiply(vec,radius))
|
|
||||||
local height, liquidflag = mobkit.get_terrain_height(pos2)
|
|
||||||
if height and not liquidflag then
|
|
||||||
mobkit.hq_swimto(self,prty,pos2)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
yaw=yaw+pi*0.25
|
|
||||||
if yaw>2*pi then
|
|
||||||
yaw = 0
|
|
||||||
radius=radius+1
|
|
||||||
if radius > self.view_range then
|
|
||||||
self.hp = 0
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_swimto(self,prty,tpos)
|
|
||||||
local box = self.object:get_properties().collisionbox
|
|
||||||
local cols = {}
|
|
||||||
local func = function(self)
|
|
||||||
if not self.isinliquid then
|
|
||||||
if self.isonground then return true end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local y=self.object:get_velocity().y
|
|
||||||
local pos2d = {x=pos.x,y=tpos.y,z=pos.z}
|
|
||||||
local dir=vector.normalize(vector.direction(pos2d,tpos))
|
|
||||||
local yaw = minetest.dir_to_yaw(dir)
|
|
||||||
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
cols = mobkit.get_box_displace_cols(pos,box,dir,1)
|
|
||||||
for _,p in ipairs(cols[1]) do
|
|
||||||
p.y=pos.y
|
|
||||||
local h,l = mobkit.get_terrain_height(p)
|
|
||||||
if h and h>pos.y and self.isinliquid then
|
|
||||||
mobkit.lq_freejump(self)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif mobkit.turn2yaw(self,yaw) then
|
|
||||||
dir.y = y
|
|
||||||
self.object:set_velocity(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
---------------------
|
|
||||||
-- AQUATIC
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
-- MACROS
|
|
||||||
local function aqua_radar_dumb(pos,yaw,range,reverse)
|
|
||||||
range = range or 4
|
|
||||||
|
|
||||||
local function okpos(p)
|
|
||||||
local node = mobkit.nodeatpos(p)
|
|
||||||
if node then
|
|
||||||
if node.drawtype == 'liquid' then
|
|
||||||
local nodeu = mobkit.nodeatpos(mobkit.pos_shift(p,{y=1}))
|
|
||||||
local noded = mobkit.nodeatpos(mobkit.pos_shift(p,{y=-1}))
|
|
||||||
if (nodeu and nodeu.drawtype == 'liquid') or (noded and noded.drawtype == 'liquid') then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local h,l = mobkit.get_terrain_height(p)
|
|
||||||
if h then
|
|
||||||
local node2 = mobkit.nodeatpos({x=p.x,y=h+1.99,z=p.z})
|
|
||||||
if node2 and node2.drawtype == 'liquid' then return true, h end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local fpos = mobkit.pos_translate2d(pos,yaw,range)
|
|
||||||
local ok,h = okpos(fpos)
|
|
||||||
if not ok then
|
|
||||||
local ffrom, fto, fstep
|
|
||||||
if reverse then
|
|
||||||
ffrom, fto, fstep = 3,1,-1
|
|
||||||
else
|
|
||||||
ffrom, fto, fstep = 1,3,1
|
|
||||||
end
|
|
||||||
for i=ffrom, fto, fstep do
|
|
||||||
local ok,h = okpos(mobkit.pos_translate2d(pos,yaw+i,range))
|
|
||||||
if ok then return yaw+i,h end
|
|
||||||
ok,h = okpos(mobkit.pos_translate2d(pos,yaw-i,range))
|
|
||||||
if ok then return yaw-i,h end
|
|
||||||
end
|
|
||||||
return yaw+pi,h
|
|
||||||
else
|
|
||||||
return yaw, h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_in_deep(target)
|
|
||||||
if not target then return false end
|
|
||||||
local nodepos = mobkit.get_stand_pos(target)
|
|
||||||
local node1 = mobkit.nodeatpos(nodepos)
|
|
||||||
nodepos.y=nodepos.y+1
|
|
||||||
local node2 = mobkit.nodeatpos(nodepos)
|
|
||||||
nodepos.y=nodepos.y-2
|
|
||||||
local node3 = mobkit.nodeatpos(nodepos)
|
|
||||||
if node1 and node2 and node3 and node1.drawtype=='liquid' and (node2.drawtype=='liquid' or node3.drawtype=='liquid') then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- HQ behaviors
|
|
||||||
|
|
||||||
function mobkit.hq_aqua_roam(self,prty,speed)
|
|
||||||
local tyaw = 0
|
|
||||||
local init = true
|
|
||||||
local prvscanpos = {x=0,y=0,z=0}
|
|
||||||
local center = self.object:get_pos()
|
|
||||||
local func = function(self)
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'def')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local scanpos = mobkit.get_node_pos(mobkit.pos_translate2d(pos,yaw,speed))
|
|
||||||
if not vector.equals(prvscanpos,scanpos) then
|
|
||||||
prvscanpos=scanpos
|
|
||||||
local nyaw,height = aqua_radar_dumb(pos,yaw,speed,true)
|
|
||||||
if height and height > pos.y then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
vel.y = vel.y+1
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
end
|
|
||||||
if yaw ~= nyaw then
|
|
||||||
tyaw=nyaw
|
|
||||||
mobkit.hq_aqua_turn(self,prty+1,tyaw,speed)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
if vector.distance(pos,center) > abr*16*0.5 then
|
|
||||||
tyaw = minetest.dir_to_yaw(vector.direction(pos,{x=center.x+random()*10-5,y=center.y,z=center.z+random()*10-5}))
|
|
||||||
else
|
|
||||||
if random(10)>=9 then tyaw=tyaw+random()*pi - pi*0.5 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mobkit.turn2yaw(self,tyaw,3)
|
|
||||||
-- local yaw = self.object:get_yaw()
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_aqua_turn(self,prty,tyaw,speed)
|
|
||||||
local func = function(self)
|
|
||||||
local finished=mobkit.turn2yaw(self,tyaw)
|
|
||||||
-- local yaw = self.object:get_yaw()
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
if finished then return true end
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hq_aqua_attack(self,prty,tgtobj,speed)
|
|
||||||
local tyaw = 0
|
|
||||||
local prvscanpos = {x=0,y=0,z=0}
|
|
||||||
local init = true
|
|
||||||
local tgtbox = tgtobj:get_properties().collisionbox
|
|
||||||
local func = function(self)
|
|
||||||
if not mobkit.is_alive(tgtobj) then return true end
|
|
||||||
if init then
|
|
||||||
mobkit.animate(self,'fast')
|
|
||||||
mobkit.make_sound(self,'attack')
|
|
||||||
init = false
|
|
||||||
end
|
|
||||||
local pos = mobkit.get_stand_pos(self)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local scanpos = mobkit.get_node_pos(mobkit.pos_translate2d(pos,yaw,speed))
|
|
||||||
if not vector.equals(prvscanpos,scanpos) then
|
|
||||||
prvscanpos=scanpos
|
|
||||||
local nyaw,height = aqua_radar_dumb(pos,yaw,speed*0.5)
|
|
||||||
if height and height > pos.y then
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
vel.y = vel.y+1
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
end
|
|
||||||
if yaw ~= nyaw then
|
|
||||||
tyaw=nyaw
|
|
||||||
mobkit.hq_aqua_turn(self,prty+1,tyaw,speed)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local tpos = tgtobj:get_pos()
|
|
||||||
local tyaw=minetest.dir_to_yaw(vector.direction(pos,tpos))
|
|
||||||
mobkit.turn2yaw(self,tyaw,3)
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
if mobkit.timer(self,1) then
|
|
||||||
if not mobkit.is_in_deep(tgtobj) then return true end
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if tpos.y>pos.y+0.5 then self.object:set_velocity({x=vel.x,y=vel.y+0.5,z=vel.z})
|
|
||||||
elseif tpos.y<pos.y-0.5 then self.object:set_velocity({x=vel.x,y=vel.y-0.5,z=vel.z}) end
|
|
||||||
end
|
|
||||||
if mobkit.is_pos_in_box(mobkit.pos_translate2d(pos,yaw,self.attack.range),tpos,tgtbox) then --bite
|
|
||||||
tgtobj:punch(self.object,1,self.attack)
|
|
||||||
mobkit.hq_aqua_turn(self,prty,yaw-pi,speed)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,prty)
|
|
||||||
end
|
|
|
@ -1,870 +0,0 @@
|
||||||
-- yaw values:
|
|
||||||
-- x+ = -pi/2
|
|
||||||
-- x- = +pi/2
|
|
||||||
-- z+ = 0
|
|
||||||
-- z- = -pi
|
|
||||||
|
|
||||||
mobkit={}
|
|
||||||
|
|
||||||
mobkit.gravity = -9.8
|
|
||||||
mobkit.friction = 0.4 -- less is more
|
|
||||||
|
|
||||||
local abs = math.abs
|
|
||||||
local pi = math.pi
|
|
||||||
local floor = math.floor
|
|
||||||
local ceil = math.ceil
|
|
||||||
local random = math.random
|
|
||||||
local sqrt = math.sqrt
|
|
||||||
local max = math.max
|
|
||||||
local min = math.min
|
|
||||||
local tan = math.tan
|
|
||||||
local pow = math.pow
|
|
||||||
|
|
||||||
local sign = function(x)
|
|
||||||
return (x<0) and -1 or 1
|
|
||||||
end
|
|
||||||
|
|
||||||
mobkit.terminal_velocity = sqrt(2*-mobkit.gravity*20) -- 20 meter fall = dead
|
|
||||||
mobkit.safe_velocity = sqrt(2*-mobkit.gravity*5) -- 5 m safe fall
|
|
||||||
|
|
||||||
local abr = tonumber(minetest.get_mapgen_setting('active_block_range')) or 3
|
|
||||||
|
|
||||||
-- UTILITY FUNCTIONS
|
|
||||||
|
|
||||||
function mobkit.dot(v1,v2)
|
|
||||||
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.minmax(v,m)
|
|
||||||
return min(abs(v),m)*sign(v)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.pos_shift(pos,vec) -- vec components can be omitted e.g. vec={y=1}
|
|
||||||
vec.x=vec.x or 0
|
|
||||||
vec.y=vec.y or 0
|
|
||||||
vec.z=vec.z or 0
|
|
||||||
return {x=pos.x+vec.x,
|
|
||||||
y=pos.y+vec.y,
|
|
||||||
z=pos.z+vec.z}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.pos_translate2d(pos,yaw,dist) -- translate pos dist distance in yaw direction
|
|
||||||
return vector.add(pos,vector.multiply(minetest.yaw_to_dir(yaw),dist))
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_pos_in_box(pos,bpos,box)
|
|
||||||
return pos.x > bpos.x+box[1] and pos.x < bpos.x+box[4] and
|
|
||||||
pos.y > bpos.y+box[2] and pos.y < bpos.y+box[5] and
|
|
||||||
pos.z > bpos.z+box[3] and pos.z < bpos.z+box[6]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- call this instead if you want feet position.
|
|
||||||
--[[
|
|
||||||
function mobkit.get_stand_pos(thing) -- thing can be luaentity or objectref.
|
|
||||||
if type(thing) == 'table' then
|
|
||||||
return mobkit.pos_shift(thing.object:get_pos(),{y=thing.collisionbox[2]+0.01})
|
|
||||||
elseif type(thing) == 'userdata' then
|
|
||||||
local colbox = thing:get_properties().collisionbox
|
|
||||||
return mobkit.pos_shift(thing:get_pos(),{y=colbox[2]+0.01})
|
|
||||||
end
|
|
||||||
end --]]
|
|
||||||
|
|
||||||
function mobkit.get_stand_pos(thing) -- thing can be luaentity or objectref.
|
|
||||||
local pos = {}
|
|
||||||
local colbox = {}
|
|
||||||
if type(thing) == 'table' then
|
|
||||||
pos = thing.object:get_pos()
|
|
||||||
colbox = thing.object:get_properties().collisionbox
|
|
||||||
elseif type(thing) == 'userdata' then
|
|
||||||
pos = thing:get_pos()
|
|
||||||
colbox = thing:get_properties().collisionbox
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return mobkit.pos_shift(pos,{y=colbox[2]+0.01}), pos
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.set_acceleration(thing,vec,limit)
|
|
||||||
limit = limit or 100
|
|
||||||
if type(thing) == 'table' then thing=thing.object end
|
|
||||||
vec.x=mobkit.minmax(vec.x,limit)
|
|
||||||
vec.y=mobkit.minmax(vec.y,limit)
|
|
||||||
vec.z=mobkit.minmax(vec.z,limit)
|
|
||||||
|
|
||||||
thing:set_acceleration(vec)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.nodeatpos(pos)
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
|
||||||
if node then return minetest.registered_nodes[node.name] end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_nodename_off(pos,vec)
|
|
||||||
return minetest.get_node(mobkit.pos_shift(pos,vec)).name
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_node_pos(pos)
|
|
||||||
return {
|
|
||||||
x=floor(pos.x+0.5),
|
|
||||||
y=floor(pos.y+0.5),
|
|
||||||
z=floor(pos.z+0.5),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_nodes_in_area(pos1,pos2,full)
|
|
||||||
local npos1=mobkit.get_node_pos(pos1)
|
|
||||||
local npos2=mobkit.get_node_pos(pos2)
|
|
||||||
local result = {}
|
|
||||||
local cnt = 0 -- safety
|
|
||||||
|
|
||||||
local sx = (pos2.x<pos1.x) and -1 or 1
|
|
||||||
local sz = (pos2.z<pos1.z) and -1 or 1
|
|
||||||
local sy = (pos2.y<pos1.y) and -1 or 1
|
|
||||||
|
|
||||||
local x=npos1.x-sx
|
|
||||||
local z=npos1.z-sz
|
|
||||||
local y=npos1.y-sy
|
|
||||||
|
|
||||||
repeat
|
|
||||||
x=x+sx
|
|
||||||
z=npos1.z-sz
|
|
||||||
repeat
|
|
||||||
z=z+sz
|
|
||||||
y=npos1.y-sy
|
|
||||||
repeat
|
|
||||||
y=y+sy
|
|
||||||
|
|
||||||
local pos = {x=x,y=y,z=z}
|
|
||||||
local node = mobkit.nodeatpos(pos)
|
|
||||||
if node then
|
|
||||||
if full==true then
|
|
||||||
result[pos] = node
|
|
||||||
else
|
|
||||||
result[node] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
cnt=cnt+1
|
|
||||||
if cnt > 125 then
|
|
||||||
minetest.chat_send_all('get_nodes_in_area: area too big ')
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
until y==npos2.y
|
|
||||||
until z==npos2.z
|
|
||||||
until x==npos2.x
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_hitbox_bottom(self)
|
|
||||||
local y = self.collisionbox[2]
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
return {
|
|
||||||
{x=pos.x+self.collisionbox[1],y=pos.y+y,z=pos.z+self.collisionbox[3]},
|
|
||||||
{x=pos.x+self.collisionbox[1],y=pos.y+y,z=pos.z+self.collisionbox[6]},
|
|
||||||
{x=pos.x+self.collisionbox[4],y=pos.y+y,z=pos.z+self.collisionbox[3]},
|
|
||||||
{x=pos.x+self.collisionbox[4],y=pos.y+y,z=pos.z+self.collisionbox[6]},
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_node_height(pos)
|
|
||||||
local npos = mobkit.get_node_pos(pos)
|
|
||||||
local node = mobkit.nodeatpos(npos)
|
|
||||||
if node == nil then return nil end
|
|
||||||
|
|
||||||
if node.walkable then
|
|
||||||
if node.drawtype == 'nodebox' then
|
|
||||||
if node.node_box and node.node_box.type == 'fixed' then
|
|
||||||
if type(node.node_box.fixed[1]) == 'number' then
|
|
||||||
return npos.y + node.node_box.fixed[5] ,0, false
|
|
||||||
elseif type(node.node_box.fixed[1]) == 'table' then
|
|
||||||
return npos.y + node.node_box.fixed[1][5] ,0, false
|
|
||||||
else
|
|
||||||
return npos.y + 0.5,1, false -- todo handle table of boxes
|
|
||||||
end
|
|
||||||
elseif node.node_box and node.node_box.type == 'leveled' then
|
|
||||||
return minetest.get_node_level(pos)/64-0.5+mobkit.get_node_pos(pos).y, 0, false
|
|
||||||
else
|
|
||||||
return npos.y + 0.5,1, false -- the unforeseen
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return npos.y+0.5,1, false -- full node
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local liquidflag = false
|
|
||||||
if node.drawtype == 'liquid' then liquidflag = true end
|
|
||||||
return npos.y-0.5,-1,liquidflag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get_terrain_height
|
|
||||||
-- steps(optional) number of recursion steps; default=3
|
|
||||||
-- dir(optional) is 1=up, -1=down, 0=both; default=0
|
|
||||||
-- liquidflag(forbidden) never provide this parameter.
|
|
||||||
function mobkit.get_terrain_height(pos,steps,dir,liquidflag) --dir is 1=up, -1=down, 0=both
|
|
||||||
steps = steps or 3
|
|
||||||
dir = dir or 0
|
|
||||||
|
|
||||||
local h,f,l = mobkit.get_node_height(pos)
|
|
||||||
if h == nil then return nil end
|
|
||||||
if l then liquidflag = true end
|
|
||||||
|
|
||||||
if f==0 then
|
|
||||||
return h, liquidflag
|
|
||||||
end
|
|
||||||
|
|
||||||
if dir==0 or dir==f then
|
|
||||||
steps = steps - 1
|
|
||||||
if steps <=0 then return nil end
|
|
||||||
return mobkit.get_terrain_height(mobkit.pos_shift(pos,{y=f}),steps,f,liquidflag)
|
|
||||||
else
|
|
||||||
return h, liquidflag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_spawn_pos_abr(dtime,intrvl,radius,chance,reduction)
|
|
||||||
dtime = min(dtime,0.1)
|
|
||||||
local plyrs = minetest.get_connected_players()
|
|
||||||
intrvl=1/intrvl
|
|
||||||
|
|
||||||
if random()<dtime*(intrvl*#plyrs) then
|
|
||||||
local plyr = plyrs[random(#plyrs)] -- choose random player
|
|
||||||
local vel = plyr:get_player_velocity()
|
|
||||||
local spd = vector.length(vel)
|
|
||||||
chance = (1-chance) * 1/(spd*0.75+1)
|
|
||||||
|
|
||||||
local yaw
|
|
||||||
if spd > 1 then
|
|
||||||
-- spawn in the front arc
|
|
||||||
yaw = minetest.dir_to_yaw(vel) + random()*0.35 - 0.75
|
|
||||||
else
|
|
||||||
-- random yaw
|
|
||||||
yaw = random()*pi*2 - pi
|
|
||||||
end
|
|
||||||
local pos = plyr:get_pos()
|
|
||||||
local dir = vector.multiply(minetest.yaw_to_dir(yaw),radius)
|
|
||||||
local pos2 = vector.add(pos,dir)
|
|
||||||
pos2.y=pos2.y-5
|
|
||||||
local height, liquidflag = mobkit.get_terrain_height(pos2,32)
|
|
||||||
if height then
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos,radius*1.1)
|
|
||||||
for _,obj in ipairs(objs) do -- count mobs in abrange
|
|
||||||
if not obj:is_player() then
|
|
||||||
local lua = obj:get_luaentity()
|
|
||||||
if lua and lua.name ~= '__builtin:item' then
|
|
||||||
chance=chance + (1-chance)*reduction -- chance reduced for every mob in range
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if chance < random() then
|
|
||||||
pos2.y = height
|
|
||||||
objs = minetest.get_objects_inside_radius(pos2,radius*0.95)
|
|
||||||
for _,obj in ipairs(objs) do -- do not spawn if another player around
|
|
||||||
if obj:is_player() then return end
|
|
||||||
end
|
|
||||||
return pos2, liquidflag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.turn2yaw(self,tyaw,rate)
|
|
||||||
tyaw = tyaw or 0 --temp
|
|
||||||
rate = rate or 6
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
yaw = yaw+pi
|
|
||||||
tyaw=(tyaw+pi)%(pi*2)
|
|
||||||
|
|
||||||
local step=min(self.dtime*rate,abs(tyaw-yaw)%(pi*2))
|
|
||||||
|
|
||||||
local dir = abs(tyaw-yaw)>pi and -1 or 1
|
|
||||||
dir = tyaw>yaw and dir*1 or dir * -1
|
|
||||||
|
|
||||||
local nyaw = (yaw+step*dir)%(pi*2)
|
|
||||||
self.object:set_yaw(nyaw-pi)
|
|
||||||
|
|
||||||
if nyaw==tyaw then return true, nyaw-pi
|
|
||||||
else return false, nyaw-pi end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.dir_to_rot(v,rot)
|
|
||||||
rot = rot or {x=0,y=0,z=0}
|
|
||||||
return {x = (v.x==0 and v.y==0 and v.z==0) and rot.x or math.atan2(v.y,vector.length({x=v.x,y=0,z=v.z})),
|
|
||||||
y = (v.x==0 and v.z==0) and rot.y or minetest.dir_to_yaw(v),
|
|
||||||
z=rot.z}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.rot_to_dir(rot) -- keep rot within <-pi/2,pi/2>
|
|
||||||
local dir = minetest.yaw_to_dir(rot.y)
|
|
||||||
dir.y = dir.y+tan(rot.x)*vector.length(dir)
|
|
||||||
return vector.normalize(dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.isnear2d(p1,p2,thresh)
|
|
||||||
if abs(p2.x-p1.x) < thresh and abs(p2.z-p1.z) < thresh then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- object has reached the destination if dest is in the rear half plane.
|
|
||||||
function mobkit.is_there_yet2d(pos,dir,dest) -- obj positon; facing vector; destination position
|
|
||||||
|
|
||||||
local c = -dir.x*pos.x-dir.z*pos.z -- the constant
|
|
||||||
|
|
||||||
if dir.z > 0 then
|
|
||||||
return dest.z <= (-dir.x*dest.x - c)/dir.z -- line equation
|
|
||||||
elseif dir.z < 0 then
|
|
||||||
return dest.z >= (-dir.x*dest.x - c)/dir.z
|
|
||||||
elseif dir.x > 0 then
|
|
||||||
return dest.x <= (-dir.z*dest.z - c)/dir.x
|
|
||||||
elseif dir.x < 0 then
|
|
||||||
return dest.x >= (-dir.z*dest.z - c)/dir.x
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.isnear3d(p1,p2,thresh)
|
|
||||||
if abs(p2.x-p1.x) < thresh and abs(p2.z-p1.z) < thresh and abs(p2.y-p1.y) < thresh then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_box_intersect_cols(pos,box)
|
|
||||||
local pmin = {x=floor(pos.x+box[1]+0.5),z=floor(pos.z+box[3]+0.5)}
|
|
||||||
local pmax = {x=floor(pos.x+box[4]+0.5),z=floor(pos.z+box[6]+0.5)}
|
|
||||||
|
|
||||||
result= {}
|
|
||||||
for x=pmin.x,pmax.x do
|
|
||||||
for z=pmin.z,pmax.z do
|
|
||||||
table.insert(result,{x=x,z=z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_box_displace_cols(pos,box,vec,dist)
|
|
||||||
|
|
||||||
local result = {{}}
|
|
||||||
-- front facing corner pos and neighbors
|
|
||||||
local fpos = {pos.y}
|
|
||||||
local xpos={pos.y}
|
|
||||||
local zpos={pos.y}
|
|
||||||
local xoff=nil
|
|
||||||
local zoff=nil
|
|
||||||
|
|
||||||
if vec.x < 0 then
|
|
||||||
fpos.x = pos.x+box[1] -- frontmost corner's x
|
|
||||||
xoff = box[4]-box[1] -- edge offset along x
|
|
||||||
else
|
|
||||||
fpos.x = pos.x+box[4]
|
|
||||||
xoff = box[1]-box[4]
|
|
||||||
end
|
|
||||||
|
|
||||||
if vec.z < 0 then
|
|
||||||
fpos.z = pos.z+box[3] -- frontmost corner's z
|
|
||||||
zoff = box[6]-box[3] -- edge offset along z
|
|
||||||
else
|
|
||||||
fpos.z = pos.z+box[6]
|
|
||||||
zoff = box[3]-box[6]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- displacement vector
|
|
||||||
if dist then vec = vector.multiply(vector.normalize(vec),dist) end
|
|
||||||
|
|
||||||
-- traverse x
|
|
||||||
local xsgn = sign(vec.x)
|
|
||||||
local zsgn = sign(zoff)
|
|
||||||
local index=0
|
|
||||||
for x = floor(fpos.x+0.5)+xsgn*0.5, fpos.x+vec.x, xsgn do
|
|
||||||
index=index+1
|
|
||||||
if index > 50 then return result end
|
|
||||||
result[index] = result[index] or {}
|
|
||||||
local zcomp = vec.x == 0 and 0 or fpos.z + (x-fpos.x)*vec.z/vec.x -- z component at the intersection of x and node edge
|
|
||||||
for z = floor(zcomp+0.5), floor(zcomp+zoff+0.5), zsgn do
|
|
||||||
table.insert(result[index],{x=x+xsgn*0.5,z=z})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- traverse z
|
|
||||||
local zsgn = sign(vec.z)
|
|
||||||
local xsgn = sign(xoff)
|
|
||||||
index=0
|
|
||||||
for z = floor(fpos.z + 0.5)+zsgn*0.5, fpos.z+vec.z, zsgn do
|
|
||||||
index=index+1
|
|
||||||
if index > 50 then return result end
|
|
||||||
result[index] = result[index] or {}
|
|
||||||
local xcomp = vec.z == 0 and 0 or fpos.x + (z-fpos.z)*vec.x/vec.z
|
|
||||||
for x = floor(xcomp+0.5), floor(xcomp+xoff+0.5), xsgn do
|
|
||||||
table.insert(result[index],{x=x,z=z+zsgn*0.5})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_box_height(thing)
|
|
||||||
if type(thing) == 'table' then thing = thing.object end
|
|
||||||
local colbox = thing:get_properties().collisionbox
|
|
||||||
local height
|
|
||||||
if colbox then height = colbox[5]-colbox[2]
|
|
||||||
else height = 0.1 end
|
|
||||||
|
|
||||||
return height > 0 and height or 0.1
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_alive(thing) -- thing can be luaentity or objectref.
|
|
||||||
-- if not thing then return false end
|
|
||||||
if not mobkit.exists(thing) then return false end
|
|
||||||
if type(thing) == 'table' then return thing.hp > 0 end
|
|
||||||
if thing:is_player() then return thing:get_hp() > 0
|
|
||||||
else
|
|
||||||
local lua = thing:get_luaentity()
|
|
||||||
local hp = lua and lua.hp or nil
|
|
||||||
return hp and hp > 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.exists(thing)
|
|
||||||
if not thing then return false end
|
|
||||||
if type(thing) == 'table' then thing=thing.object end
|
|
||||||
if type(thing) == 'userdata' then
|
|
||||||
if thing:is_player() then
|
|
||||||
if thing:get_look_horizontal() then return true end
|
|
||||||
else
|
|
||||||
if thing:get_yaw() then return true end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.hurt(luaent,dmg)
|
|
||||||
if not luaent then return false end
|
|
||||||
if type(luaent) == 'table' then
|
|
||||||
luaent.hp = max((luaent.hp or 0) - dmg,0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.heal(luaent,dmg)
|
|
||||||
if not luaent then return false end
|
|
||||||
if type(luaent) == 'table' then
|
|
||||||
luaent.hp = min(luaent.max_hp,(luaent.hp or 0) + dmg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.animate(self,anim)
|
|
||||||
if self.animation and self.animation[anim] then
|
|
||||||
if self._anim == anim then return end
|
|
||||||
self._anim=anim
|
|
||||||
|
|
||||||
local aparms = {}
|
|
||||||
if #self.animation[anim] > 0 then
|
|
||||||
aparms = self.animation[anim][random(#self.animation[anim])]
|
|
||||||
else
|
|
||||||
aparms = self.animation[anim]
|
|
||||||
end
|
|
||||||
|
|
||||||
aparms.frame_blend = aparms.frame_blend or 0
|
|
||||||
|
|
||||||
self.object:set_animation(aparms.range,aparms.speed,aparms.frame_blend,aparms.loop)
|
|
||||||
else
|
|
||||||
self._anim = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.make_sound(self, sound)
|
|
||||||
local spec = self.sounds and self.sounds[sound]
|
|
||||||
local param_table = {object=self.object}
|
|
||||||
|
|
||||||
if type(spec) == 'table' then
|
|
||||||
--pick random sound if it's a spec for random sounds
|
|
||||||
if #spec > 0 then spec = spec[random(#spec)] end
|
|
||||||
|
|
||||||
--returns value or a random value within the range [value[1], value[2])
|
|
||||||
local function in_range(value)
|
|
||||||
return type(value) == 'table' and value[1]+random()*(value[2]-value[1]) or value
|
|
||||||
end
|
|
||||||
|
|
||||||
--pick random values within a range if they're a table
|
|
||||||
param_table.gain = in_range(spec.gain)
|
|
||||||
param_table.fade = in_range(spec.fade)
|
|
||||||
param_table.pitch = in_range(spec.pitch)
|
|
||||||
return minetest.sound_play(spec.name, param_table)
|
|
||||||
end
|
|
||||||
return minetest.sound_play(spec, param_table)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.go_forward_horizontal(self,speed) -- sets velocity in yaw direction, y component unaffected
|
|
||||||
local y = self.object:get_velocity().y
|
|
||||||
local yaw = self.object:get_yaw()
|
|
||||||
local vel = vector.multiply(minetest.yaw_to_dir(yaw),speed)
|
|
||||||
vel.y = y
|
|
||||||
self.object:set_velocity(vel)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.drive_to_pos(self,tpos,speed,turn_rate,dist)
|
|
||||||
local pos=self.object:get_pos()
|
|
||||||
dist = dist or 0.2
|
|
||||||
if mobkit.isnear2d(pos,tpos,dist) then return true end
|
|
||||||
local tyaw = minetest.dir_to_yaw(vector.direction(pos,tpos))
|
|
||||||
mobkit.turn2yaw(self,tyaw,turn_rate)
|
|
||||||
mobkit.go_forward_horizontal(self,speed)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.timer(self,s) -- returns true approx every s seconds
|
|
||||||
local t1 = floor(self.time_total)
|
|
||||||
local t2 = floor(self.time_total+self.dtime)
|
|
||||||
if t2>t1 and t2%s==0 then return true end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Memory functions.
|
|
||||||
-- Stuff in memory is serialized, never try to remember objectrefs.
|
|
||||||
function mobkit.remember(self,key,val)
|
|
||||||
self.memory[key]=val
|
|
||||||
return val
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.forget(self,key)
|
|
||||||
self.memory[key] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.recall(self,key)
|
|
||||||
return self.memory[key]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Queue functions
|
|
||||||
function mobkit.queue_high(self,func,priority)
|
|
||||||
local maxprty = mobkit.get_queue_priority(self)
|
|
||||||
if priority > maxprty then
|
|
||||||
mobkit.clear_queue_low(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i,f in ipairs(self.hqueue) do
|
|
||||||
if priority > f.prty then
|
|
||||||
table.insert(self.hqueue,i,{func=func,prty=priority})
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(self.hqueue,{func=func,prty=priority})
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.queue_low(self,func)
|
|
||||||
table.insert(self.lqueue,func)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_queue_empty_low(self)
|
|
||||||
if #self.lqueue == 0 then return true
|
|
||||||
else return false end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.clear_queue_high(self)
|
|
||||||
self.hqueue = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.clear_queue_low(self)
|
|
||||||
self.lqueue = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_queue_priority(self)
|
|
||||||
if #self.hqueue > 0 then
|
|
||||||
return self.hqueue[1].prty
|
|
||||||
else return 0 end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.is_queue_empty_high(self)
|
|
||||||
if #self.hqueue == 0 then return true
|
|
||||||
else return false end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_nearby_player(self) -- returns random player if nearby or nil
|
|
||||||
for _,obj in ipairs(self.nearby_objects) do
|
|
||||||
if obj:is_player() and mobkit.is_alive(obj) then return obj end
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_nearby_entity(self,name) -- returns random nearby entity of name or nil
|
|
||||||
for _,obj in ipairs(self.nearby_objects) do
|
|
||||||
if mobkit.is_alive(obj) and not obj:is_player() and obj:get_luaentity().name == name then return obj end
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.get_closest_entity(self,name) -- returns closest entity of name or nil
|
|
||||||
local cobj = nil
|
|
||||||
local dist = abr*64
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
for _,obj in ipairs(self.nearby_objects) do
|
|
||||||
local luaent = obj:get_luaentity()
|
|
||||||
if mobkit.is_alive(obj) and not obj:is_player() and luaent and luaent.name == name then
|
|
||||||
local opos = obj:get_pos()
|
|
||||||
local odist = abs(opos.x-pos.x) + abs(opos.z-pos.z)
|
|
||||||
if odist < dist then
|
|
||||||
dist=odist
|
|
||||||
cobj=obj
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return cobj
|
|
||||||
end
|
|
||||||
|
|
||||||
local function execute_queues(self)
|
|
||||||
--Execute hqueue
|
|
||||||
if #self.hqueue > 0 then
|
|
||||||
local func = self.hqueue[1].func
|
|
||||||
if func(self) then
|
|
||||||
table.remove(self.hqueue,1)
|
|
||||||
self.lqueue = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- Execute lqueue
|
|
||||||
if #self.lqueue > 0 then
|
|
||||||
local func = self.lqueue[1]
|
|
||||||
if func(self) then
|
|
||||||
table.remove(self.lqueue,1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sensors()
|
|
||||||
local timer = 2
|
|
||||||
local pulse = 1
|
|
||||||
return function(self)
|
|
||||||
timer=timer-self.dtime
|
|
||||||
if timer < 0 then
|
|
||||||
|
|
||||||
pulse = pulse + 1 -- do full range every third scan
|
|
||||||
local range = self.view_range
|
|
||||||
if pulse > 2 then
|
|
||||||
pulse = 1
|
|
||||||
else
|
|
||||||
range = self.view_range*0.5
|
|
||||||
end
|
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
|
||||||
--local tim = minetest.get_us_time()
|
|
||||||
self.nearby_objects = minetest.get_objects_inside_radius(pos, range)
|
|
||||||
--minetest.chat_send_all(minetest.get_us_time()-tim)
|
|
||||||
for i,obj in ipairs(self.nearby_objects) do
|
|
||||||
if obj == self.object then
|
|
||||||
table.remove(self.nearby_objects,i)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
timer=2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
------------
|
|
||||||
-- CALLBACKS
|
|
||||||
------------
|
|
||||||
|
|
||||||
function mobkit.default_brain(self)
|
|
||||||
if mobkit.is_queue_empty_high(self) then mobkit.hq_roam(self,0) end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.physics(self)
|
|
||||||
local vel=self.object:get_velocity()
|
|
||||||
local vnew = vector.new(vel)
|
|
||||||
-- dumb friction
|
|
||||||
|
|
||||||
if self.isonground and not self.isinliquid then
|
|
||||||
vnew = {x= vel.x> 0.2 and vel.x*mobkit.friction or 0,
|
|
||||||
y=vel.y,
|
|
||||||
z=vel.z > 0.2 and vel.z*mobkit.friction or 0}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- bounciness
|
|
||||||
if self.springiness and self.springiness > 0 then
|
|
||||||
|
|
||||||
if colinfo and colinfo.collides then
|
|
||||||
for _,c in ipairs(colinfo.collisions) do
|
|
||||||
if c.old_velocity[c.axis] > 0.1 then
|
|
||||||
vnew[c.axis] = vnew[c.axis] * self.springiness * -1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif not colinfo then -- MT 5.2 and earlier
|
|
||||||
for _,k in ipairs({'y','z','x'}) do
|
|
||||||
if vel[k]==0 and abs(self.lastvelocity[k])> 0.1 then
|
|
||||||
vnew[k]=-self.lastvelocity[k]*self.springiness
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:set_velocity(vnew)
|
|
||||||
|
|
||||||
-- buoyancy
|
|
||||||
local surface = nil
|
|
||||||
local surfnodename = nil
|
|
||||||
local spos = mobkit.get_stand_pos(self)
|
|
||||||
spos.y = spos.y+0.01
|
|
||||||
-- get surface height
|
|
||||||
local snodepos = mobkit.get_node_pos(spos)
|
|
||||||
local surfnode = mobkit.nodeatpos(spos)
|
|
||||||
while surfnode and surfnode.drawtype == 'liquid' do
|
|
||||||
surfnodename = surfnode.name
|
|
||||||
surface = snodepos.y+0.5
|
|
||||||
if surface > spos.y+self.height then break end
|
|
||||||
snodepos.y = snodepos.y+1
|
|
||||||
surfnode = mobkit.nodeatpos(snodepos)
|
|
||||||
end
|
|
||||||
self.isinliquid = surfnodename
|
|
||||||
if surface then -- standing in liquid
|
|
||||||
-- self.isinliquid = true
|
|
||||||
local submergence = min(surface-spos.y,self.height)/self.height
|
|
||||||
-- local balance = self.buoyancy*self.height
|
|
||||||
local buoyacc = mobkit.gravity*(self.buoyancy-submergence)
|
|
||||||
mobkit.set_acceleration(self.object,
|
|
||||||
{x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})
|
|
||||||
else
|
|
||||||
-- self.isinliquid = false
|
|
||||||
self.object:set_acceleration({x=0,y=mobkit.gravity,z=0})
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.vitals(self)
|
|
||||||
-- vitals: fall damage
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
local velocity_delta = abs(self.lastvelocity.y - vel.y)
|
|
||||||
if velocity_delta > mobkit.safe_velocity then
|
|
||||||
self.hp = self.hp - floor(self.max_hp * min(1, velocity_delta/mobkit.terminal_velocity))
|
|
||||||
end
|
|
||||||
|
|
||||||
-- vitals: oxygen
|
|
||||||
if self.lung_capacity then
|
|
||||||
local colbox = self.object:get_properties().collisionbox
|
|
||||||
local headnode = mobkit.nodeatpos(mobkit.pos_shift(self.object:get_pos(),{y=colbox[5]})) -- node at hitbox top
|
|
||||||
if headnode and headnode.drawtype == 'liquid' then
|
|
||||||
self.oxygen = self.oxygen - self.dtime
|
|
||||||
else
|
|
||||||
self.oxygen = self.lung_capacity
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.oxygen <= 0 then self.hp=0 end -- drown
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.statfunc(self)
|
|
||||||
local tmptab={}
|
|
||||||
tmptab.memory = self.memory
|
|
||||||
tmptab.hp = self.hp
|
|
||||||
tmptab.texture_no = self.texture_no
|
|
||||||
return minetest.serialize(tmptab)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.actfunc(self, staticdata, dtime_s)
|
|
||||||
|
|
||||||
self.logic = self.logic or self.brainfunc
|
|
||||||
self.physics = self.physics or mobkit.physics
|
|
||||||
|
|
||||||
self.lqueue = {}
|
|
||||||
self.hqueue = {}
|
|
||||||
self.nearby_objects = {}
|
|
||||||
self.nearby_players = {}
|
|
||||||
self.pos_history = {}
|
|
||||||
self.path_dir = 1
|
|
||||||
self.time_total = 0
|
|
||||||
self.water_drag = self.water_drag or 1
|
|
||||||
|
|
||||||
local sdata = minetest.deserialize(staticdata)
|
|
||||||
if sdata then
|
|
||||||
for k,v in pairs(sdata) do
|
|
||||||
self[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.textures==nil then
|
|
||||||
local prop_tex = self.object:get_properties().textures
|
|
||||||
if prop_tex then self.textures=prop_tex end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not self.memory then -- this is the initial activation
|
|
||||||
self.memory = {}
|
|
||||||
|
|
||||||
-- texture variation
|
|
||||||
if #self.textures > 1 then self.texture_no = random(#self.textures) end
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.timeout and ((self.timeout>0 and dtime_s > self.timeout and next(self.memory)==nil) or
|
|
||||||
(self.timeout<0 and dtime_s > abs(self.timeout))) then
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- apply texture
|
|
||||||
if self.textures and self.texture_no then
|
|
||||||
local props = {}
|
|
||||||
props.textures = {self.textures[self.texture_no]}
|
|
||||||
self.object:set_properties(props)
|
|
||||||
end
|
|
||||||
|
|
||||||
--hp
|
|
||||||
self.max_hp = self.max_hp or 10
|
|
||||||
self.hp = self.hp or self.max_hp
|
|
||||||
--armor
|
|
||||||
if type(self.armor_groups) ~= 'table' then
|
|
||||||
self.armor_groups={}
|
|
||||||
end
|
|
||||||
self.armor_groups.immortal = 1
|
|
||||||
self.object:set_armor_groups(self.armor_groups)
|
|
||||||
|
|
||||||
self.buoyancy = self.buoyancy or 0
|
|
||||||
self.oxygen = self.oxygen or self.lung_capacity
|
|
||||||
self.lastvelocity = {x=0,y=0,z=0}
|
|
||||||
self.sensefunc=sensors()
|
|
||||||
end
|
|
||||||
|
|
||||||
function mobkit.stepfunc(self,dtime,colinfo) -- not intended to be modified
|
|
||||||
self.dtime = min(dtime,0.2)
|
|
||||||
self.colinfo = colinfo
|
|
||||||
self.height = mobkit.get_box_height(self)
|
|
||||||
|
|
||||||
-- physics comes first
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
|
|
||||||
if colinfo then
|
|
||||||
self.isonground = colinfo.touching_ground
|
|
||||||
else
|
|
||||||
if self.lastvelocity.y==0 and vel.y==0 then
|
|
||||||
self.isonground = true
|
|
||||||
else
|
|
||||||
self.isonground = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:physics()
|
|
||||||
|
|
||||||
if self.logic then
|
|
||||||
if self.view_range then self:sensefunc() end
|
|
||||||
self:logic()
|
|
||||||
execute_queues(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.lastvelocity = self.object:get_velocity()
|
|
||||||
self.time_total=self.time_total+self.dtime
|
|
||||||
end
|
|
||||||
|
|
||||||
-- load example behaviors
|
|
||||||
dofile(minetest.get_modpath("mobkit") .. "/example_behaviors.lua")
|
|
||||||
|
|
||||||
minetest.register_on_mods_loaded(function()
|
|
||||||
local mbkfuns = ''
|
|
||||||
for n,f in pairs(mobkit) do
|
|
||||||
if type(f) == 'function' then
|
|
||||||
mbkfuns = mbkfuns .. n .. string.split(minetest.serialize(f),'.lua')[2] or ''
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local crc = minetest.sha1(mbkfuns)
|
|
||||||
-- dbg(crc)
|
|
||||||
-- if crc ~= 'a061770008fe9ecf8e1042a227dc3beabd10e481' then
|
|
||||||
-- minetest.log("error","Mobkit namespace inconsistent, has been modified by other mods.")
|
|
||||||
-- end
|
|
||||||
end)
|
|
|
@ -1,560 +0,0 @@
|
||||||
Contents
|
|
||||||
|
|
||||||
1 Concepts
|
|
||||||
1.1 Behavior functions
|
|
||||||
1.1.1 Low level functions
|
|
||||||
1.1.2 High level functions
|
|
||||||
1.1.2.1 Priority
|
|
||||||
1.1.3 Modifying built in behaviors
|
|
||||||
1.2 Logic function
|
|
||||||
1.3 Processing diagram
|
|
||||||
1.4 Entity definition
|
|
||||||
1.5 Exposed luaentity members
|
|
||||||
|
|
||||||
2 Reference
|
|
||||||
2.1 Utility functions
|
|
||||||
2.2 Built in behaviors
|
|
||||||
2.2.1 High level behaviors
|
|
||||||
2.2.2 Low level behaviors
|
|
||||||
2.3 Constants and member variables
|
|
||||||
|
|
||||||
-----------
|
|
||||||
1. Concepts
|
|
||||||
-----------
|
|
||||||
|
|
||||||
1.1 Behavior functions
|
|
||||||
|
|
||||||
These are the most fundamental units of code, every action entities can perform is a separate function.
|
|
||||||
There are two types of behaviors:
|
|
||||||
- low level, these govern physical actions and interactions (think moves)
|
|
||||||
- high level, these are logical structures governing low level behaviors in order to perform more complex tasks
|
|
||||||
|
|
||||||
Behaviors run for considerable amount of time, this means the functions are being called repeatedly on consecutive engine steps.
|
|
||||||
Therefore a need for preserving state between calls, this is why they are implemented as closures, see defining conventions for details.
|
|
||||||
|
|
||||||
Behavior functions are active until they finish the job, are removed from the queue or superseded by a higher priority behavior.
|
|
||||||
They signal finished state by returning true, therefore it's very important to carefully design the completion conditions
|
|
||||||
|
|
||||||
For a behavior to begin executing it has to be put on a queue. There are two separate queues, one for low and one for high level behaviors.
|
|
||||||
Queuing is covered by behavour defining conventions
|
|
||||||
|
|
||||||
Mobkit comes with some example behavior functions, which are located in /example_behaviors.lua
|
|
||||||
!!! In simplest scenarios there's no need to code behaviors, much can be achieved using only built-in stuff !!!
|
|
||||||
!!! To start using the api it's enough to learn defining mobs and writing brain functions !!!
|
|
||||||
|
|
||||||
|
|
||||||
1.1.1 Low level behavior functions
|
|
||||||
|
|
||||||
These are physical actions and interactions: steps, jumps, turns etc. here you'll set velocity, yaw, kick off animations and sounds.
|
|
||||||
|
|
||||||
Low level behavior definition:
|
|
||||||
|
|
||||||
function mobkit.lq_bhv1(self,[optional additional persistent parameters]) -- enclosing function
|
|
||||||
... -- optional definitions of additional persistent variables
|
|
||||||
local func=function(self) -- enclosed function, self is mandatory and the only allowed parameter
|
|
||||||
... -- actual function definition, remember to return true eventually
|
|
||||||
end
|
|
||||||
mobkit.queue_low(self,func) -- this will queue the behavior at the time of lq_bhv1 call
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
1.1.2 High level behavior functions
|
|
||||||
|
|
||||||
These are complex tasks like getting to a position, following other objects, hiding, patrolling an area etc.
|
|
||||||
Their job is tracking changes in the environment and managing low level behavior queue accordingly.
|
|
||||||
|
|
||||||
High level behavior definition:
|
|
||||||
|
|
||||||
function mobkit.hq_bhv1(self,priority,[optional additional persistent parameters]) -- enclosing function
|
|
||||||
... -- optional definitions of additional persistent variables
|
|
||||||
local func=function(self) -- enclosed function, self is mandatory and the only allowed parameter
|
|
||||||
... -- actual function definition, remember to return true eventually
|
|
||||||
end
|
|
||||||
mobkit.queue_high(self,func,priority) -- this will queue the behavior at the time of hq_bhv1 call
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
1.1.2.1 Priority
|
|
||||||
|
|
||||||
Unlike low level behaviors which are executed in FIFO order, high level behaviors support prioritization.
|
|
||||||
This concept is essential for making sure the right behavior is active at the right time.
|
|
||||||
Prioritization is what makes it possible to interrupt a task in order to perform a more important one
|
|
||||||
|
|
||||||
The currently executing behavior is always the first in the queue.
|
|
||||||
When a new behavior is placed onto the queue:
|
|
||||||
If the queue is not empty a new behavior is inserted before the first behavior of lower priority if such exists, or last.
|
|
||||||
If the new behavior supersedes the one currently executing, low level queue is purged immediately.
|
|
||||||
|
|
||||||
Common idioms:
|
|
||||||
|
|
||||||
hq_bhv1(self,prty):
|
|
||||||
...
|
|
||||||
hq_bhv2(self,prty) -- bhv1 kicks off bhv2 with equal priority
|
|
||||||
return true -- and ends,
|
|
||||||
-- bhv2 becomes active on the next engine step.
|
|
||||||
|
|
||||||
hq_bhv1(self,prty):
|
|
||||||
...
|
|
||||||
hq_bhv2(self,prty+1) -- bhv1 kicks off bhv2 with higher priority
|
|
||||||
-- bhv2 takes over and when it ends, bhv1 resumes.
|
|
||||||
|
|
||||||
|
|
||||||
Particular prioritization scheme is to be designed by the user according to specific mod requirements.
|
|
||||||
|
|
||||||
1.1.3 Modifying built in behaviors
|
|
||||||
|
|
||||||
Do not modify example_behaviors.lua directly, because functions defined there are meant to be shared between mods.
|
|
||||||
Instead, copy the contents of /behaviors2override.lua into your mod/game, changing every occurence of the string '[yournamespace]' to the name of a lua table representing your namespace of choice.
|
|
||||||
|
|
||||||
1.2 Logic function
|
|
||||||
------------------
|
|
||||||
Every mob must have one.
|
|
||||||
Its job is managing high level behavior queue in response to events which are not intercepted by callbacks.
|
|
||||||
Contrary to what the name suggests, these functions needn't necessarily be too complex thanks to their limited responsibilities.
|
|
||||||
|
|
||||||
Typical flow might look like this:
|
|
||||||
|
|
||||||
if mobkit.timer(self,1) then -- returns true approx every second
|
|
||||||
local prty = mobkit.get_queue_priority(self)
|
|
||||||
|
|
||||||
if prty < 20
|
|
||||||
if ... then
|
|
||||||
hq_do_important_stuff(self,20)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if prty < 10 then
|
|
||||||
if ... then
|
|
||||||
hq_do_something_else(self,10)
|
|
||||||
return
|
|
||||||
elseif ... then
|
|
||||||
hq_do_this_instead(self,10)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if mobkit.is_queue_empty_high(self) then
|
|
||||||
hq_fool_around(self,0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
1.3 Processing diagram
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
---------------------------------------
|
|
||||||
| PHYSICS |
|
|
||||||
| |
|
|
||||||
| ----------------------- |
|
|
||||||
| | Logic Function | |
|
|
||||||
| ----------------------- |
|
|
||||||
| | |
|
|
||||||
| -----|----------------- |
|
|
||||||
| | V HL Queue| |
|
|
||||||
| | 1| 2| 3|... | |
|
|
||||||
| ----------------------- |
|
|
||||||
| | |
|
|
||||||
| -----|----------------- |
|
|
||||||
| | V LL Queue| |
|
|
||||||
| | 1| 2| 3|... | |
|
|
||||||
| ----------------------- |
|
|
||||||
| |
|
|
||||||
---------------------------------------
|
|
||||||
|
|
||||||
Order of execution during an engine step:
|
|
||||||
First comes physics: gravity, buoyancy, friction etc., then the logic function is called.
|
|
||||||
After that, the first behavior on the high level queue, if exists,
|
|
||||||
and the last, the first low level behavior if present.
|
|
||||||
|
|
||||||
1.4 Entity definition
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
minetest.register_entity("mod:name",{
|
|
||||||
|
|
||||||
-- required minetest api props
|
|
||||||
|
|
||||||
initial_properties = {
|
|
||||||
physical = true,
|
|
||||||
collide_with_objects = true,
|
|
||||||
collisionbox = {...},
|
|
||||||
visual = "mesh",
|
|
||||||
mesh = "...",
|
|
||||||
textures = {...},
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
-- required mobkit props
|
|
||||||
|
|
||||||
timeout = [num], -- entities are removed after this many seconds inactive
|
|
||||||
-- 0 is never
|
|
||||||
-- mobs having memory entries are not affected
|
|
||||||
|
|
||||||
buoyancy = [num], -- (0,1) - portion of collisionbox submerged
|
|
||||||
-- = 1 - controlled buoyancy (fish, submarine)
|
|
||||||
-- > 1 - drowns
|
|
||||||
-- < 0 - MC like water trampolining
|
|
||||||
|
|
||||||
lung_capacity = [num], -- seconds
|
|
||||||
max_hp = [num],
|
|
||||||
on_step = mobkit.stepfunc,
|
|
||||||
on_activate = mobkit.actfunc,
|
|
||||||
get_staticdata = mobkit.statfunc,
|
|
||||||
logic = [function user defined], -- older 'brainfunc' name works as well.
|
|
||||||
|
|
||||||
-- optional mobkit props
|
|
||||||
-- or used by built in behaviors
|
|
||||||
physics = [function user defined] -- optional, overrides built in physics
|
|
||||||
animation = {
|
|
||||||
[name]={range={x=[num],y=[num]},speed=[num],loop=[bool]}, -- single
|
|
||||||
|
|
||||||
[name]={ -- variant, animations are chosen randomly.
|
|
||||||
{range={x=[num],y=[num]},speed=[num],loop=[bool]},
|
|
||||||
{range={x=[num],y=[num]},speed=[num],loop=[bool]},
|
|
||||||
...
|
|
||||||
}
|
|
||||||
...
|
|
||||||
}
|
|
||||||
sounds = {
|
|
||||||
[name] = [string filename], --single, simple,
|
|
||||||
|
|
||||||
[name] = { --single, more powerful. All fields but 'name' are optional
|
|
||||||
name = [string filename],
|
|
||||||
gain=[num or range], --range is a table of the format {left_bound, right_bound}
|
|
||||||
fade=[num or range],
|
|
||||||
pitch=[num or range],
|
|
||||||
},
|
|
||||||
|
|
||||||
[name] = { --variant, sound is chosen randomly
|
|
||||||
{
|
|
||||||
name = [string filename],
|
|
||||||
gain=[num or range],
|
|
||||||
fade=[num or range],
|
|
||||||
pitch=[num or range],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = [string filename],
|
|
||||||
gain=[num or range],
|
|
||||||
fade=[num or range],
|
|
||||||
pitch=[num or range],
|
|
||||||
},
|
|
||||||
...
|
|
||||||
},
|
|
||||||
...
|
|
||||||
},
|
|
||||||
max_speed = [num], -- m/s
|
|
||||||
jump_height = [num], -- nodes/meters
|
|
||||||
view_range = [num], -- nodes/meters
|
|
||||||
attack={range=[num], -- range is distance between attacker's collision box center
|
|
||||||
damage_groups={fleshy=[num]}}, -- and the tip of the murder weapon in nodes/meters
|
|
||||||
armor_groups = {fleshy=[num]}
|
|
||||||
})
|
|
||||||
|
|
||||||
1.5 Exposed luaentity members
|
|
||||||
|
|
||||||
Some frequently used entity fields to be accessed directly for convenience
|
|
||||||
|
|
||||||
self.dtime -- max(dtime as passed to on_step,0.5) - limit of 0.05 to prevent jerkines on long steps.
|
|
||||||
self.hp -- hitpoints
|
|
||||||
self.isonground -- true if in collision with negative Y
|
|
||||||
self.isinliquid -- true if the node at foot level is drawtype=='liquid'
|
|
||||||
|
|
||||||
------------
|
|
||||||
2. Reference
|
|
||||||
------------
|
|
||||||
|
|
||||||
2.1 Utility Functions
|
|
||||||
|
|
||||||
function mobkit.minmax(v,m)
|
|
||||||
-- v,n: numbers
|
|
||||||
-- returns v trimmed to <-m,m> range
|
|
||||||
|
|
||||||
function mobkit.get_terrain_height(pos,steps)
|
|
||||||
-- recursively search for walkable surface at pos.
|
|
||||||
-- steps (optional) is how far from pos it gives up, expressed in nodes, default 3
|
|
||||||
-- Returns:
|
|
||||||
-- surface height at pos, or nil if not found
|
|
||||||
-- liquid flag: true if found surface is covered with liquid
|
|
||||||
|
|
||||||
function mobkit.turn2yaw(self,tyaw,rate)
|
|
||||||
-- gradually turns towards yaw
|
|
||||||
-- self: luaentity
|
|
||||||
-- tyaw: target yaw in radians
|
|
||||||
-- rate: turn rate in rads/s
|
|
||||||
--returns: true if facing tyaw; current yaw
|
|
||||||
|
|
||||||
function mobkit.timer(self,s)
|
|
||||||
-- returns true approx every s seconds
|
|
||||||
-- used to reduce execution of code that needn't necessarily be done on every engine step
|
|
||||||
|
|
||||||
function mobkit.pos_shift(pos,vec)
|
|
||||||
-- convenience function
|
|
||||||
-- returns pos shifted by vec
|
|
||||||
-- vec needn't have all three components given, absent components are assumed zero.
|
|
||||||
-- e.g pos_shift(pos,{y=1}) is valid
|
|
||||||
|
|
||||||
function mobkit.pos_translate2d(pos,yaw,dist)
|
|
||||||
-- returns pos translated in the yaw direction by dist
|
|
||||||
|
|
||||||
function mobkit.get_stand_pos(thing)
|
|
||||||
-- returns object pos projected onto the bottom collisionbox face
|
|
||||||
-- thing can be luaentity or objectref.
|
|
||||||
|
|
||||||
function mobkit.nodeatpos(pos)
|
|
||||||
-- convenience function
|
|
||||||
-- returns nodedef or nil if it's an ignore node
|
|
||||||
|
|
||||||
function mobkit.get_node_pos(pos)
|
|
||||||
-- returns center of the node that pos is inside
|
|
||||||
|
|
||||||
function mobkit.get_nodes_in_area(pos1,pos2,[full])
|
|
||||||
-- in basic mode returns a table of unique nodes within area indexed by node
|
|
||||||
-- in full=true mode returns a table of nodes indexed by pos
|
|
||||||
-- works for up to 125 nodes.
|
|
||||||
|
|
||||||
function mobkit.isnear2d(p1,p2,thresh)
|
|
||||||
-- returns true if pos p2 is within a square with center at pos p1 and radius thresh
|
|
||||||
-- y components are ignored
|
|
||||||
|
|
||||||
function mobkit.is_there_yet2d(pos,dir,dest) -- obj positon; facing vector; destination position
|
|
||||||
-- returns true if a position dest is behind position pos according to facing vector dir
|
|
||||||
-- (checks if dest is in the rear half plane as defined by pos and dir)
|
|
||||||
-- y components are ignored
|
|
||||||
|
|
||||||
function mobkit.isnear3d(p1,p2,thresh)
|
|
||||||
-- returns true if pos p2 is within a cube with center at pos p1 and radius thresh
|
|
||||||
|
|
||||||
function mobkit.get_box_intersect_cols(pos,box)
|
|
||||||
-- returns an array of {x=,z=} columns that the box intersects with.
|
|
||||||
|
|
||||||
function mobkit.get_box_displace_cols(pos,box,vec,dist)
|
|
||||||
-- returns an array of {x=,z=} columns that the box would pass by if moved by horizontal vector vec
|
|
||||||
-- if dist provided, vec gets normalized.
|
|
||||||
|
|
||||||
function mobkit.dir_to_rot(v,rot)
|
|
||||||
-- converts a 3d vector v to rotation like in set_rotation() object method
|
|
||||||
-- rot (optional) is current object rotation
|
|
||||||
|
|
||||||
function mobkit.rot_to_dir(rot)
|
|
||||||
-- converts minetest rotation vector (pitch,yaw,roll) to direction unit vector
|
|
||||||
|
|
||||||
function mobkit.is_alive(thing)
|
|
||||||
-- non essential, checks if thing exists in the world and is alive
|
|
||||||
-- makes an assumption that luaentities are considered dead when their hp < 100
|
|
||||||
-- thing can be luaentity or objectref.
|
|
||||||
-- used for stored luaentities and objectrefs
|
|
||||||
|
|
||||||
function mobkit.exists(thing)
|
|
||||||
-- checks if thing exists in the world
|
|
||||||
-- thing can be luaentity or objectref.
|
|
||||||
-- used for stored luaentities and objectrefs
|
|
||||||
|
|
||||||
function mobkit.hurt(luaent,dmg)
|
|
||||||
-- decrease luaent.hp by dmg
|
|
||||||
|
|
||||||
function mobkit.heal(luaent,dmg)
|
|
||||||
-- increase luaent.hp by dmg
|
|
||||||
|
|
||||||
function mobkit.get_spawn_pos_abr(dtime,intrvl,radius,chance,reduction)
|
|
||||||
-- returns a potential spawn position at random intervals
|
|
||||||
-- intrvl: avg spawn attempt interval for every player
|
|
||||||
-- radius: spawn distance in nodes, active_block_range*16 is recommended
|
|
||||||
-- chance: (0,1) chance to spawn a mob if there are no other objects in area
|
|
||||||
-- reduction: (0,1) spawn chance is reduced by this factor for every object in range.
|
|
||||||
--usage:
|
|
||||||
minetest.register_globalstep(function(dtime)
|
|
||||||
local spawnpos = mobkit.get_spawn_pos_abr(...)
|
|
||||||
if spawnpos then
|
|
||||||
... -- mod/game specific logic
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
function mobkit.animate(self,anim)
|
|
||||||
-- makes an entity play an animation of name anim, or does nothing if not defined
|
|
||||||
-- anim is string, see entity definition
|
|
||||||
-- does nothing if the same animation is already running
|
|
||||||
|
|
||||||
function mobkit.make_sound(self,sound)
|
|
||||||
-- sound is string, see entity definition
|
|
||||||
-- makes an entity play sound, or does nothing if not defined
|
|
||||||
--returns sound handle
|
|
||||||
|
|
||||||
function mobkit.go_forward_horizontal(self,speed)
|
|
||||||
-- sets an entity's horizontal velocity in yaw direction. Vertical velocity unaffected.
|
|
||||||
|
|
||||||
function mobkit.drive_to_pos(self,tpos,speed,turn_rate,dist)
|
|
||||||
-- moves in facing direction while gradually turning towards tpos, returns true if in dist distance from tpos
|
|
||||||
-- tpos: target position
|
|
||||||
-- speed: in m/s
|
|
||||||
-- turn_rate: in rad/s
|
|
||||||
-- dist: in m.
|
|
||||||
|
|
||||||
-- Memory functions.
|
|
||||||
|
|
||||||
This represents mob long term memory
|
|
||||||
Warning: Stuff in memory is serialized, never try to remember objectrefs or tables referencing them
|
|
||||||
or the engine will crash.
|
|
||||||
|
|
||||||
function mobkit.remember(self,key,val)
|
|
||||||
-- premanently store a key, value pair
|
|
||||||
function mobkit.forget(self,key)
|
|
||||||
-- clears a memory entry
|
|
||||||
function mobkit.recall(self,key)
|
|
||||||
-- returns val associated with key
|
|
||||||
|
|
||||||
-- Queue functions
|
|
||||||
|
|
||||||
function mobkit.queue_high(self,func,priority)
|
|
||||||
-- only for use in behavior definitions, see 1.1.2
|
|
||||||
|
|
||||||
function mobkit.queue_low(self,func)
|
|
||||||
-- only for use in behavior definitions, see 1.1.1
|
|
||||||
|
|
||||||
|
|
||||||
function mobkit.clear_queue_high(self)
|
|
||||||
function mobkit.clear_queue_low(self)
|
|
||||||
|
|
||||||
function mobkit.is_queue_empty_high(self)
|
|
||||||
function mobkit.is_queue_empty_low(self)
|
|
||||||
|
|
||||||
function mobkit.get_queue_priority(self)
|
|
||||||
-- returns the priority of currently running behavior
|
|
||||||
-- this is also the highest of all queued behaviors
|
|
||||||
|
|
||||||
|
|
||||||
-- Use these inside logic functions --
|
|
||||||
|
|
||||||
function mobkit.vitals(self)
|
|
||||||
-- default drowning and fall damage, call it before hp check
|
|
||||||
function mobkit.get_nearby_player(self)
|
|
||||||
-- returns random player if nearby or nil
|
|
||||||
function mobkit.get_nearby_entity(self,name)
|
|
||||||
-- returns random nearby entity of name or nil
|
|
||||||
function mobkit.get_closest_entity(self,name)
|
|
||||||
-- returns closest entity of name or nil
|
|
||||||
|
|
||||||
|
|
||||||
-- Misc
|
|
||||||
|
|
||||||
Neighbors structure represents a node's horizontal neighbors
|
|
||||||
Not essential, used by some built in behaviors
|
|
||||||
Custom behaviors may not need it.
|
|
||||||
|
|
||||||
Neighbor #1 is offset {x=1,z=0}, subsequent numbers go clockwise
|
|
||||||
|
|
||||||
function mobkit.dir2neighbor(dir)
|
|
||||||
-- converts a 3d vector to neighbor number, y component ignored
|
|
||||||
|
|
||||||
function mobkit.neighbor_shift(neighbor,shift)
|
|
||||||
-- get another neighbor number relative to the given, shift: plus is clockwise, minus the opposite
|
|
||||||
-- 1,1 = 2; 1,-2 = 7
|
|
||||||
|
|
||||||
|
|
||||||
2.2 Built in behaviors
|
|
||||||
|
|
||||||
function mobkit.goto_next_waypoint(self,tpos)
|
|
||||||
-- this functions groups common operations making mobs move in a specific direction
|
|
||||||
-- not a behavior itself, but is used by some built in HL behaviors
|
|
||||||
-- which use node by node movement algorithm
|
|
||||||
|
|
||||||
2.2.1 High Level Behaviors --
|
|
||||||
|
|
||||||
function mobkit.hq_roam(self,prty)
|
|
||||||
-- slow random roaming
|
|
||||||
-- never returns
|
|
||||||
|
|
||||||
function mobkit.hq_follow(self,prty,tgtobj)
|
|
||||||
-- follow the tgtobj
|
|
||||||
-- returns if tgtobj becomes inactive
|
|
||||||
|
|
||||||
function mobkit.hq_goto(self,prty,tpos)
|
|
||||||
-- go to tpos position
|
|
||||||
-- returns on arrival
|
|
||||||
|
|
||||||
function mobkit.hq_runfrom(self,prty,tgtobj)
|
|
||||||
-- run away from tgtobj object
|
|
||||||
-- returns when tgtobj far enough
|
|
||||||
|
|
||||||
function mobkit.hq_hunt(self,prty,tgtobj)
|
|
||||||
-- follow tgtobj and when close enough, kick off hq_attack
|
|
||||||
-- returns when tgtobj too far
|
|
||||||
|
|
||||||
function mobkit.hq_warn(self,prty,tgtobj)
|
|
||||||
-- when a tgtobj close by, turn towards them and make the 'warn' sound
|
|
||||||
-- kick off hq_hunt if tgtobj too close or timer expired
|
|
||||||
-- returns when tgtobj moves away
|
|
||||||
|
|
||||||
function mobkit.hq_die(self)
|
|
||||||
-- default death, rotate and remove() after set time
|
|
||||||
|
|
||||||
function mobkit.hq_attack(self,prty,tgtobj)
|
|
||||||
-- default attack, turns towards tgtobj and leaps
|
|
||||||
-- returns when tgtobj out of range
|
|
||||||
|
|
||||||
function mobkit.hq_liquid_recovery(self,prty)
|
|
||||||
-- use when submerged in liquid, scan for nearest land
|
|
||||||
-- if land is found within view_range, kick off hq_swimto
|
|
||||||
-- otherwise die
|
|
||||||
|
|
||||||
function mobkit.hq_swimto(self,prty,tpos)
|
|
||||||
-- swim towards the position tpos, jump if necessary
|
|
||||||
-- returns if standing firmly on dry land
|
|
||||||
|
|
||||||
Aquatic behaviors:
|
|
||||||
|
|
||||||
Macros:
|
|
||||||
function aqua_radar_dumb(pos,yaw,range,reverse)
|
|
||||||
-- assumes a mob will avoid shallows
|
|
||||||
-- checks if a pos in front of a moving entity swimmable
|
|
||||||
-- otherwise returns new position
|
|
||||||
|
|
||||||
function mobkit.is_in_deep(target)
|
|
||||||
-- checks if an object is in water at least 2 nodes deep
|
|
||||||
|
|
||||||
Hq Behaviors:
|
|
||||||
function mobkit.hq_aqua_roam(self,prty,speed)
|
|
||||||
function mobkit.hq_aqua_attack(self,prty,tgtobj,speed)
|
|
||||||
function mobkit.hq_aqua_turn(self,prty,tyaw,speed)
|
|
||||||
-- used by both previous bhv
|
|
||||||
|
|
||||||
2.2.2 Low Level Behaviors --
|
|
||||||
|
|
||||||
function mobkit.lq_turn2pos(self,tpos)
|
|
||||||
-- gradually turn towards tpos position
|
|
||||||
-- returns when facing tpos
|
|
||||||
|
|
||||||
function mobkit.lq_idle(self,duration)
|
|
||||||
-- do nothing for duration seconds
|
|
||||||
-- set 'stand' animation
|
|
||||||
|
|
||||||
function mobkit.lq_dumbwalk(self,dest,speed_factor)
|
|
||||||
-- simply move towards dest
|
|
||||||
-- set 'walk' animation
|
|
||||||
|
|
||||||
function mobkit.lq_dumbjump(self,height)
|
|
||||||
-- if standing on the ground, jump in the facing direction
|
|
||||||
-- height is relative to feet level
|
|
||||||
-- set 'stand' animation
|
|
||||||
|
|
||||||
function mobkit.lq_freejump(self)
|
|
||||||
-- unconditional jump in the facing direction
|
|
||||||
-- useful e.g for getting out of water
|
|
||||||
-- returns when the apex has been reached
|
|
||||||
|
|
||||||
function mobkit.lq_jumpattack(self,height,target)
|
|
||||||
-- jump towards the target, punch if a hit
|
|
||||||
-- returns after punch or on the ground
|
|
||||||
|
|
||||||
function mobkit.lq_fallover(self)
|
|
||||||
-- gradually rotates Z = 0 to pi/2
|
|
||||||
|
|
||||||
|
|
||||||
2.3 Constants and member variables --
|
|
||||||
|
|
||||||
mobkit.gravity = -9.8
|
|
||||||
mobkit.friction = 0.4 -- inert entities will slow down when in contact with the ground
|
|
||||||
-- the smaller the number, the greater the effect
|
|
||||||
|
|
||||||
self.dtime -- for convenience, dtime as passed to currently executing on_step()
|
|
||||||
self.isonground -- true if y velocity is 0 for at least two succesive steps
|
|
||||||
self.isinliquid -- true if feet submerged in liquid type=source
|
|
|
@ -1,2 +0,0 @@
|
||||||
name = mobkit
|
|
||||||
description = Entity API
|
|
Binary file not shown.
Before Width: | Height: | Size: 80 KiB |
|
@ -15,7 +15,7 @@ with name "mobs_mc_gameconfig". ]]
|
||||||
-- Set to false in your gameconfig mod if you create your own monster egg nodes.
|
-- Set to false in your gameconfig mod if you create your own monster egg nodes.
|
||||||
mobs_mc.create_monster_egg_nodes = true
|
mobs_mc.create_monster_egg_nodes = true
|
||||||
|
|
||||||
--mobs_mc.items = {}
|
mobs_mc.items = {}
|
||||||
|
|
||||||
mobs_mc.items = {
|
mobs_mc.items = {
|
||||||
-- Items defined in mobs_mc
|
-- Items defined in mobs_mc
|
||||||
|
@ -81,9 +81,7 @@ mobs_mc.items = {
|
||||||
gunpowder = "tnt:gunpowder",
|
gunpowder = "tnt:gunpowder",
|
||||||
flint_and_steel = "fire:flint_and_steel",
|
flint_and_steel = "fire:flint_and_steel",
|
||||||
water_source = "default:water_source",
|
water_source = "default:water_source",
|
||||||
water_flowing = "default:water_flowing",
|
|
||||||
river_water_source = "default:river_water_source",
|
river_water_source = "default:river_water_source",
|
||||||
--water_flowing = "default:river_water_flowing",
|
|
||||||
black_dye = "dye:black",
|
black_dye = "dye:black",
|
||||||
poppy = "flowers:rose",
|
poppy = "flowers:rose",
|
||||||
dandelion = "flowers:dandelion_yellow",
|
dandelion = "flowers:dandelion_yellow",
|
||||||
|
@ -128,6 +126,7 @@ mobs_mc.items = {
|
||||||
|
|
||||||
nether_portal = "nether:portal",
|
nether_portal = "nether:portal",
|
||||||
netherrack = "nether:rack",
|
netherrack = "nether:rack",
|
||||||
|
nether_brick_block = "nether:brick",
|
||||||
|
|
||||||
-- Wool (Minecraft color scheme)
|
-- Wool (Minecraft color scheme)
|
||||||
wool_white = "wool:white",
|
wool_white = "wool:white",
|
||||||
|
@ -170,6 +169,7 @@ mobs_mc.follow = {
|
||||||
dog = { mobs_mc.items.rabbit_raw, mobs_mc.items.rabbit_cooked, mobs_mc.items.mutton_raw, mobs_mc.items.mutton_cooked, mobs_mc.items.beef_raw, mobs_mc.items.beef_cooked, mobs_mc.items.chicken_raw, mobs_mc.items.chicken_cooked, mobs_mc.items.rotten_flesh,
|
dog = { mobs_mc.items.rabbit_raw, mobs_mc.items.rabbit_cooked, mobs_mc.items.mutton_raw, mobs_mc.items.mutton_cooked, mobs_mc.items.beef_raw, mobs_mc.items.beef_cooked, mobs_mc.items.chicken_raw, mobs_mc.items.chicken_cooked, mobs_mc.items.rotten_flesh,
|
||||||
-- Mobs Redo items
|
-- Mobs Redo items
|
||||||
"mobs:meat", "mobs:meat_raw" },
|
"mobs:meat", "mobs:meat_raw" },
|
||||||
|
villager = { "mcl_farming:bread" },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Contents for replace_what
|
-- Contents for replace_what
|
||||||
|
|
|
@ -525,7 +525,7 @@ if c("totem") then
|
||||||
inventory_image = "mcl_totems_totem.png",
|
inventory_image = "mcl_totems_totem.png",
|
||||||
wield_image = "mcl_totems_totem.png",
|
wield_image = "mcl_totems_totem.png",
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
groups = {combat_item=1},
|
groups = {combat_item = 1, offhand_item = 1},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
-- NOTE: Strings intentionally not marked for translation, other mods already have these items.
|
-- NOTE: Strings intentionally not marked for translation, other mods already have these items.
|
||||||
-- TODO: Remove this file eventually, all items here are already outsourced in other mods.
|
-- TODO: Remove this file eventually, all items here are already outsourced in other mods.
|
||||||
|
|
||||||
--local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--maikerumines throwing code
|
--maikerumines throwing code
|
||||||
--arrow (weapon)
|
--arrow (weapon)
|
||||||
|
@ -83,7 +83,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
if self.timer>0.2 then
|
if self.timer>0.2 then
|
||||||
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
|
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
if obj:get_luaentity() then
|
if obj:get_luaentity() ~= nil then
|
||||||
if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
if obj:get_luaentity().name ~= "mobs_mc:arrow_entity" and obj:get_luaentity().name ~= "__builtin:item" then
|
||||||
local damage = 3
|
local damage = 3
|
||||||
minetest.sound_play("damage", {pos = pos}, true)
|
minetest.sound_play("damage", {pos = pos}, true)
|
||||||
|
@ -108,7 +108,7 @@ THROWING_ARROW_ENTITY.on_step = function(self, dtime)
|
||||||
if self.lastpos.x~=nil then
|
if self.lastpos.x~=nil then
|
||||||
if node.name ~= "air" then
|
if node.name ~= "air" then
|
||||||
minetest.sound_play("bowhit1", {pos = pos}, true)
|
minetest.sound_play("bowhit1", {pos = pos}, true)
|
||||||
minetest.add_item(self.lastpos, "mobs_mc:arrow")
|
minetest.add_item(self.lastpos, 'mobs_mc:arrow')
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -155,7 +155,7 @@ end
|
||||||
|
|
||||||
if c("arrow") and c("flint") and c("feather") and c("stick") then
|
if c("arrow") and c("flint") and c("feather") and c("stick") then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mobs_mc:arrow 4",
|
output = 'mobs_mc:arrow 4',
|
||||||
recipe = {
|
recipe = {
|
||||||
{mobs_mc.items.flint},
|
{mobs_mc.items.flint},
|
||||||
{mobs_mc.items.stick},
|
{mobs_mc.items.stick},
|
||||||
|
@ -181,11 +181,11 @@ if c("bow") then
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mobs_mc:bow_wood",
|
output = 'mobs_mc:bow_wood',
|
||||||
recipe = {
|
recipe = {
|
||||||
{mobs_mc.items.string, mobs_mc.items.stick, ""},
|
{mobs_mc.items.string, mobs_mc.items.stick, ''},
|
||||||
{mobs_mc.items.string, "", mobs_mc.items.stick},
|
{mobs_mc.items.string, '', mobs_mc.items.stick},
|
||||||
{mobs_mc.items.string, mobs_mc.items.stick, ""},
|
{mobs_mc.items.string, mobs_mc.items.stick, ''},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -259,7 +259,7 @@ if c("egg") then
|
||||||
})
|
})
|
||||||
|
|
||||||
-- shoot egg
|
-- shoot egg
|
||||||
local function mobs_shoot_egg(item, player, pointed_thing)
|
local mobs_shoot_egg = function (item, player, pointed_thing)
|
||||||
|
|
||||||
local playerpos = player:get_pos()
|
local playerpos = player:get_pos()
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ mobs:register_arrow("mobs_mc:snowball_entity", {
|
||||||
|
|
||||||
if c("snowball") then
|
if c("snowball") then
|
||||||
-- shoot snowball
|
-- shoot snowball
|
||||||
local function mobs_shoot_snowball(item, player, pointed_thing)
|
local mobs_shoot_snowball = function (item, player, pointed_thing)
|
||||||
|
|
||||||
local playerpos = player:get_pos()
|
local playerpos = player:get_pos()
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,10 @@ mobs_mc.make_owner_teleport_function = function(dist, teleport_check_interval)
|
||||||
local telepos_below = {x=telepos.x, y=telepos.y-1, z=telepos.z}
|
local telepos_below = {x=telepos.x, y=telepos.y-1, z=telepos.z}
|
||||||
table.remove(check_offsets, r)
|
table.remove(check_offsets, r)
|
||||||
-- Long story short, spawn on a platform
|
-- Long story short, spawn on a platform
|
||||||
if minetest.registered_nodes[minetest.get_node(telepos).name].walkable == false and
|
local trynode = minetest.registered_nodes[minetest.get_node(telepos).name]
|
||||||
minetest.registered_nodes[minetest.get_node(telepos_below).name].walkable == true then
|
local trybelownode = minetest.registered_nodes[minetest.get_node(telepos_below).name]
|
||||||
|
if trynode and not trynode.walkable and
|
||||||
|
trybelownode and trybelownode.walkable then
|
||||||
-- Correct position found! Let's teleport.
|
-- Correct position found! Let's teleport.
|
||||||
self.object:set_pos(telepos)
|
self.object:set_pos(telepos)
|
||||||
return
|
return
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
-- NOTE: Strings intentionally not marked for translation, other mods already have these items.
|
-- NOTE: Strings intentionally not marked for translation, other mods already have these items.
|
||||||
-- TODO: Remove this file eventually, all items here are already outsourced in other mods.
|
-- TODO: Remove this file eventually, all items here are already outsourced in other mods.
|
||||||
-- TODO: Add translation.
|
|
||||||
|
|
||||||
--local S = local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
-- Heads system
|
-- Heads system
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ Origin of those models:
|
||||||
* `mobs_mc_mushroom_brown.png` (CC0)
|
* `mobs_mc_mushroom_brown.png` (CC0)
|
||||||
|
|
||||||
* “Spawn egg” textures (`mobs_mc_spawn_icon_*`) by 22i
|
* “Spawn egg” textures (`mobs_mc_spawn_icon_*`) by 22i
|
||||||
|
* Llama decor (carpet) textures (`mobs_mc_llama_decor_*`) by erlehmann and rudzik8
|
||||||
* Any other texture not mentioned here are licensed under the MIT License
|
* Any other texture not mentioned here are licensed under the MIT License
|
||||||
|
|
||||||
## Sounds
|
## Sounds
|
||||||
|
@ -190,10 +191,9 @@ Origin of those models:
|
||||||
* [Spennnyyy](https://freesound.org/people/Spennnyyy/) (CC0)
|
* [Spennnyyy](https://freesound.org/people/Spennnyyy/) (CC0)
|
||||||
* `mcl_totems_totem.ogg`
|
* `mcl_totems_totem.ogg`
|
||||||
* Source: <https://freesound.org/people/Spennnyyy/sounds/323502/>
|
* Source: <https://freesound.org/people/Spennnyyy/sounds/323502/>
|
||||||
* [Baŝto](https://opengameart.org/users/ba%C5%9Dto) (remixer) and [kantouth](https://freesound.org/people/kantouth/) (original author)
|
* [Baŝto](https://opengameart.org/users/ba%C5%9Dto)
|
||||||
* `mobs_mc_skeleton_random.*.ogg` (CC BY 3.0)
|
* `mobs_mc_skeleton_random.*.ogg` (CC BY 3.0)
|
||||||
* Source: <https://opengameart.org/content/walking-skeleton>
|
* Source: <https://opengameart.org/content/walking-skeleton>
|
||||||
* Based on: <https://freesound.org/people/kantouth/sounds/115113/>
|
|
||||||
* [spookymodem](https://freesound.org/people/spookymodem/)
|
* [spookymodem](https://freesound.org/people/spookymodem/)
|
||||||
* `mobs_mc_skeleton_death.ogg` (CC0)
|
* `mobs_mc_skeleton_death.ogg` (CC0)
|
||||||
* <https://freesound.org/people/spookymodem/sounds/202091/>
|
* <https://freesound.org/people/spookymodem/sounds/202091/>
|
||||||
|
@ -307,4 +307,4 @@ Origin of those models:
|
||||||
|
|
||||||
Note: Many of these sounds have been more or less modified to fit the game.
|
Note: Many of these sounds have been more or less modified to fit the game.
|
||||||
|
|
||||||
Sounds not mentioned here are licensed under CC0.
|
Sounds not mentioned hre are licensed under CC0.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
--################### AGENT - seemingly unused
|
--################### AGENT - seemingly unused
|
||||||
--###################
|
--###################
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:agent", {
|
mobs:register_mob("mobs_mc:agent", {
|
||||||
type = "npc",
|
type = "npc",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:bat", {
|
mobs:register_mob("mobs_mc:bat", {
|
||||||
description = S("Bat"),
|
description = S("Bat"),
|
||||||
|
@ -8,9 +8,6 @@ mobs:register_mob("mobs_mc:bat", {
|
||||||
spawn_class = "ambient",
|
spawn_class = "ambient",
|
||||||
can_despawn = true,
|
can_despawn = true,
|
||||||
passive = true,
|
passive = true,
|
||||||
rotate = 270,
|
|
||||||
tilt_fly = true,
|
|
||||||
fly = true,
|
|
||||||
hp_min = 6,
|
hp_min = 6,
|
||||||
hp_max = 6,
|
hp_max = 6,
|
||||||
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
|
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
|
||||||
|
@ -48,7 +45,9 @@ mobs:register_mob("mobs_mc:bat", {
|
||||||
fall_damage = 0,
|
fall_damage = 0,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
fear_height = 0,
|
fear_height = 0,
|
||||||
|
|
||||||
jump = false,
|
jump = false,
|
||||||
|
fly = true,
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
-- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez
|
-- Model and mobs_blaze.png see https://github.com/22i/minecraft-voxel-blender-models -hi 22i ~jordan4ibanez
|
||||||
-- blaze.lua partial copy of mobs_mc/ghast.lua
|
-- blaze.lua partial copy of mobs_mc/ghast.lua
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
|
local mod_target = minetest.get_modpath("mcl_target")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### BLAZE
|
--################### BLAZE
|
||||||
|
@ -18,9 +20,6 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
xp_min = 10,
|
xp_min = 10,
|
||||||
xp_max = 10,
|
xp_max = 10,
|
||||||
tilt_fly = false,
|
|
||||||
hostile = true,
|
|
||||||
--rotate = 270,
|
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.79, 0.3},
|
||||||
rotate = -180,
|
rotate = -180,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -39,7 +38,7 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
walk_velocity = .8,
|
walk_velocity = .8,
|
||||||
run_velocity = 1.6,
|
run_velocity = 1.6,
|
||||||
damage = 6,
|
damage = 6,
|
||||||
reach = 4, -- don't want blaze getting too close
|
reach = 2,
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.blaze_rod,
|
{name = mobs_mc.items.blaze_rod,
|
||||||
|
@ -67,7 +66,7 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
fall_speed = -2.25,
|
fall_speed = -2.25,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
attack_type = "projectile",
|
attack_type = "dogshoot",
|
||||||
arrow = "mobs_mc:blaze_fireball",
|
arrow = "mobs_mc:blaze_fireball",
|
||||||
shoot_interval = 3.5,
|
shoot_interval = 3.5,
|
||||||
shoot_offset = 1.0,
|
shoot_offset = 1.0,
|
||||||
|
@ -79,18 +78,9 @@ mobs:register_mob("mobs_mc:blaze", {
|
||||||
fear_height = 0,
|
fear_height = 0,
|
||||||
glow = 14,
|
glow = 14,
|
||||||
fire_resistant = true,
|
fire_resistant = true,
|
||||||
eye_height = 0.75,
|
|
||||||
projectile_cooldown_min = 2,
|
|
||||||
projectile_cooldown_max = 3,
|
|
||||||
shoot_arrow = function(self, pos, dir)
|
|
||||||
-- 2-4 damage per arrow
|
|
||||||
local dmg = math.random(2,4)
|
|
||||||
mobs.shoot_projectile_handling("mobs_mc:blaze_fireball", pos, dir, self.object:get_yaw(), self.object, 7, dmg,nil,nil,nil,-0.4)
|
|
||||||
end,
|
|
||||||
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
if self.attacking and self.state == "attack" and vector.distance(self.object:get_pos(), self.attacking:get_pos()) < 1.2 then
|
if self.state == "attack" and self.attack:get_pos() and vector.distance(self.object:get_pos(), self.attack:get_pos()) < 1.2 then
|
||||||
mcl_burning.set_on_fire(self.attacking, 5)
|
mcl_burning.set_on_fire(self.attack, 5)
|
||||||
end
|
end
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
|
@ -160,11 +150,6 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
visual_size = {x = 0.3, y = 0.3},
|
visual_size = {x = 0.3, y = 0.3},
|
||||||
textures = {"mcl_fire_fire_charge.png"},
|
textures = {"mcl_fire_fire_charge.png"},
|
||||||
velocity = 15,
|
velocity = 15,
|
||||||
speed = 5,
|
|
||||||
tail = 1,
|
|
||||||
tail_texture = "mobs_mc_spit.png^[colorize:black:255", --repurpose spit texture
|
|
||||||
tail_size = 2,
|
|
||||||
tail_distance_divider = 3,
|
|
||||||
_is_fireball = true,
|
_is_fireball = true,
|
||||||
|
|
||||||
-- Direct hit, no fire... just plenty of pain
|
-- Direct hit, no fire... just plenty of pain
|
||||||
|
@ -172,7 +157,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
mcl_burning.set_on_fire(player, 5)
|
mcl_burning.set_on_fire(player, 5)
|
||||||
player:punch(self.object, 1.0, {
|
player:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = self._damage},
|
damage_groups = {fleshy = 5},
|
||||||
}, nil)
|
}, nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -180,7 +165,7 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
mcl_burning.set_on_fire(mob, 5)
|
mcl_burning.set_on_fire(mob, 5)
|
||||||
mob:punch(self.object, 1.0, {
|
mob:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = self._damage},
|
damage_groups = {fleshy = 5},
|
||||||
}, nil)
|
}, nil)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -195,19 +180,20 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
|
||||||
|
|
||||||
-- Node hit, make fire
|
-- Node hit, make fire
|
||||||
hit_node = function(self, pos, node)
|
hit_node = function(self, pos, node)
|
||||||
if node.name ~= "air" then
|
if node == "air" then
|
||||||
local pos_above = table.copy(pos)
|
minetest.set_node(pos, {name = mobs_mc.items.fire})
|
||||||
pos_above.y = pos_above.y + 1
|
|
||||||
minetest.set_node(pos_above, {name=mobs_mc.items.fire})
|
|
||||||
else
|
else
|
||||||
local v = self.object:get_velocity()
|
if self._shot_from_dispenser and mod_target and node == "mcl_target:target_off" then
|
||||||
v = vector.normalize(v)
|
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
|
||||||
|
end
|
||||||
|
local v = vector.normalize(self.object:get_velocity())
|
||||||
local crashpos = vector.subtract(pos, v)
|
local crashpos = vector.subtract(pos, v)
|
||||||
local crashnode = minetest.get_node(crashpos)
|
local crashnode = minetest.get_node(crashpos)
|
||||||
|
local cndef = minetest.registered_nodes[crashnode.name]
|
||||||
-- Set fire if node is air, or a replacable flammable node (e.g. a plant)
|
-- Set fire if node is air, or a replacable flammable node (e.g. a plant)
|
||||||
if crashnode.name == "air" or
|
if crashnode.name == "air" or
|
||||||
(minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then
|
(cndef and cndef.buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then
|
||||||
minetest.set_node(crashpos, {name=mobs_mc.items.fire})
|
minetest.set_node(crashpos, {name = mobs_mc.items.fire})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### CHICKEN
|
--################### CHICKEN
|
||||||
|
@ -18,8 +18,7 @@ mobs:register_mob("mobs_mc:chicken", {
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
xp_max = 3,
|
xp_max = 3,
|
||||||
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.69, 0.2},
|
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.69, 0.2},
|
||||||
skittish = true,
|
runaway = true,
|
||||||
fall_slow = true,
|
|
||||||
floats = 1,
|
floats = 1,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_chicken.b3d",
|
mesh = "mobs_mc_chicken.b3d",
|
||||||
|
@ -27,10 +26,9 @@ mobs:register_mob("mobs_mc:chicken", {
|
||||||
{"mobs_mc_chicken.png"},
|
{"mobs_mc_chicken.png"},
|
||||||
},
|
},
|
||||||
visual_size = {x=2.2, y=2.2},
|
visual_size = {x=2.2, y=2.2},
|
||||||
rotate = 270,
|
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.chicken_raw,
|
{name = mobs_mc.items.chicken_raw,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -66,25 +64,14 @@ mobs:register_mob("mobs_mc:chicken", {
|
||||||
run_start = 0, run_end = 40,
|
run_start = 0, run_end = 40,
|
||||||
},
|
},
|
||||||
|
|
||||||
follow = "mcl_farming:wheat_seeds",
|
follow = mobs_mc.follow.chicken,
|
||||||
breed_distance = 1.5,
|
|
||||||
baby_size = 0.5,
|
|
||||||
follow_distance = 2,
|
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
|
|
||||||
--why do chickend breed if they lay eggs??
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
--attempt to enter breed state
|
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||||
if mobs.enter_breed_state(self,clicker) then
|
if mobs:protect(self, clicker) then return end
|
||||||
return
|
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
|
||||||
end
|
|
||||||
|
|
||||||
--make baby grow faster
|
|
||||||
if self.baby then
|
|
||||||
mobs.make_baby_grow_faster(self,clicker)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
|
@ -111,21 +98,6 @@ mobs:register_mob("mobs_mc:chicken", {
|
||||||
}, true)
|
}, true)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--head code
|
|
||||||
has_head = true,
|
|
||||||
head_bone = "head",
|
|
||||||
|
|
||||||
swap_y_with_x = false,
|
|
||||||
reverse_head_yaw = false,
|
|
||||||
|
|
||||||
head_bone_pos_y = 1.675,
|
|
||||||
head_bone_pos_z = 0,
|
|
||||||
|
|
||||||
head_height_offset = 0.55,
|
|
||||||
head_direction_offset = 0.0925,
|
|
||||||
|
|
||||||
head_pitch_modifier = -math.pi/2,
|
|
||||||
--end head code
|
|
||||||
})
|
})
|
||||||
|
|
||||||
--spawn
|
--spawn
|
||||||
|
@ -134,53 +106,42 @@ mobs:spawn_specific(
|
||||||
"overworld",
|
"overworld",
|
||||||
"ground",
|
"ground",
|
||||||
{
|
{
|
||||||
"FlowerForest_beach",
|
"flat",
|
||||||
"Forest_beach",
|
|
||||||
"StoneBeach",
|
|
||||||
"ColdTaiga_beach_water",
|
|
||||||
"Taiga_beach",
|
|
||||||
"Savanna_beach",
|
|
||||||
"Plains_beach",
|
|
||||||
"ExtremeHills_beach",
|
|
||||||
"ColdTaiga_beach",
|
|
||||||
"Swampland_shore",
|
|
||||||
"JungleM_shore",
|
|
||||||
"Jungle_shore",
|
|
||||||
"MesaPlateauFM_sandlevel",
|
|
||||||
"MesaPlateauF_sandlevel",
|
|
||||||
"MesaBryce_sandlevel",
|
|
||||||
"Mesa_sandlevel",
|
|
||||||
"Mesa",
|
|
||||||
"FlowerForest",
|
|
||||||
"Swampland",
|
|
||||||
"Taiga",
|
|
||||||
"ExtremeHills",
|
|
||||||
"Jungle",
|
|
||||||
"Savanna",
|
|
||||||
"BirchForest",
|
|
||||||
"MegaSpruceTaiga",
|
|
||||||
"MegaTaiga",
|
|
||||||
"ExtremeHills+",
|
|
||||||
"Forest",
|
|
||||||
"Plains",
|
|
||||||
"Desert",
|
|
||||||
"ColdTaiga",
|
|
||||||
"IcePlainsSpikes",
|
"IcePlainsSpikes",
|
||||||
"SunflowerPlains",
|
"ColdTaiga",
|
||||||
"IcePlains",
|
"ColdTaiga_beach",
|
||||||
"RoofedForest",
|
"ColdTaiga_beach_water",
|
||||||
"ExtremeHills+_snowtop",
|
"MegaTaiga",
|
||||||
"MesaPlateauFM_grasstop",
|
"MegaSpruceTaiga",
|
||||||
"JungleEdgeM",
|
"ExtremeHills",
|
||||||
|
"ExtremeHills_beach",
|
||||||
"ExtremeHillsM",
|
"ExtremeHillsM",
|
||||||
"JungleM",
|
"ExtremeHills+",
|
||||||
|
"ExtremeHills+_snowtop",
|
||||||
|
"StoneBeach",
|
||||||
|
"Plains",
|
||||||
|
"Plains_beach",
|
||||||
|
"SunflowerPlains",
|
||||||
|
"Taiga",
|
||||||
|
"Taiga_beach",
|
||||||
|
"Forest",
|
||||||
|
"Forest_beach",
|
||||||
|
"FlowerForest",
|
||||||
|
"FlowerForest_beach",
|
||||||
|
"BirchForest",
|
||||||
"BirchForestM",
|
"BirchForestM",
|
||||||
"MesaPlateauF",
|
"RoofedForest",
|
||||||
"MesaPlateauFM",
|
"Savanna",
|
||||||
"MesaPlateauF_grasstop",
|
"Savanna_beach",
|
||||||
"MesaBryce",
|
|
||||||
"JungleEdge",
|
|
||||||
"SavannaM",
|
"SavannaM",
|
||||||
|
"Jungle",
|
||||||
|
"Jungle_shore",
|
||||||
|
"JungleM",
|
||||||
|
"JungleM_shore",
|
||||||
|
"JungleEdge",
|
||||||
|
"JungleEdgeM",
|
||||||
|
"Swampland",
|
||||||
|
"Swampland_shore"
|
||||||
},
|
},
|
||||||
9,
|
9,
|
||||||
minetest.LIGHT_MAX+1,
|
minetest.LIGHT_MAX+1,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
local cow_def = {
|
local cow_def = {
|
||||||
description = S("Cow"),
|
description = S("Cow"),
|
||||||
|
@ -10,7 +10,6 @@ local cow_def = {
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
xp_max = 3,
|
xp_max = 3,
|
||||||
rotate = 270,
|
|
||||||
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.39, 0.45},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_cow.b3d",
|
mesh = "mobs_mc_cow.b3d",
|
||||||
|
@ -21,7 +20,6 @@ local cow_def = {
|
||||||
visual_size = {x=2.8, y=2.8},
|
visual_size = {x=2.8, y=2.8},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.beef_raw,
|
{name = mobs_mc.items.beef_raw,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -34,7 +32,7 @@ local cow_def = {
|
||||||
max = 2,
|
max = 2,
|
||||||
looting = "common",},
|
looting = "common",},
|
||||||
},
|
},
|
||||||
skittish = true,
|
runaway = true,
|
||||||
sounds = {
|
sounds = {
|
||||||
random = "mobs_mc_cow",
|
random = "mobs_mc_cow",
|
||||||
damage = "mobs_mc_cow_hurt",
|
damage = "mobs_mc_cow_hurt",
|
||||||
|
@ -49,17 +47,12 @@ local cow_def = {
|
||||||
walk_end = 40, run_start = 0,
|
walk_end = 40, run_start = 0,
|
||||||
run_end = 40,
|
run_end = 40,
|
||||||
},
|
},
|
||||||
--follow = mobs_mc.follow.cow,
|
follow = mobs_mc.follow.cow,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
|
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||||
|
if mobs:protect(self, clicker) then return end
|
||||||
|
|
||||||
--attempt to enter breed state
|
if self.child then
|
||||||
if mobs.enter_breed_state(self,clicker) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--make baby grow faster
|
|
||||||
if self.baby then
|
|
||||||
mobs.make_baby_grow_faster(self,clicker)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,28 +71,11 @@ local cow_def = {
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||||
end,
|
end,
|
||||||
breed_distance = 1.5,
|
|
||||||
baby_size = 0.5,
|
|
||||||
follow_distance = 2,
|
|
||||||
follow = mobs_mc.items.wheat,
|
follow = mobs_mc.items.wheat,
|
||||||
view_range = 10,
|
view_range = 10,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
|
|
||||||
--head code
|
|
||||||
has_head = true,
|
|
||||||
head_bone = "head",
|
|
||||||
|
|
||||||
swap_y_with_x = false,
|
|
||||||
reverse_head_yaw = false,
|
|
||||||
|
|
||||||
head_bone_pos_y = 3.6,
|
|
||||||
head_bone_pos_z = -0.6,
|
|
||||||
|
|
||||||
head_height_offset = 1.0525,
|
|
||||||
head_direction_offset = 0.5,
|
|
||||||
head_pitch_modifier = 0,
|
|
||||||
--end head code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:cow", cow_def)
|
mobs:register_mob("mobs_mc:cow", cow_def)
|
||||||
|
@ -110,17 +86,12 @@ mooshroom_def.description = S("Mooshroom")
|
||||||
mooshroom_def.mesh = "mobs_mc_cow.b3d"
|
mooshroom_def.mesh = "mobs_mc_cow.b3d"
|
||||||
mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } }
|
mooshroom_def.textures = { {"mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png"}, {"mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" } }
|
||||||
mooshroom_def.on_rightclick = function(self, clicker)
|
mooshroom_def.on_rightclick = function(self, clicker)
|
||||||
--attempt to enter breed state
|
if mobs:feed_tame(self, clicker, 1, true, true) then return end
|
||||||
if mobs.enter_breed_state(self,clicker) then
|
if mobs:protect(self, clicker) then return end
|
||||||
|
|
||||||
|
if self.child then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--make baby grow faster
|
|
||||||
if self.baby then
|
|
||||||
mobs.make_baby_grow_faster(self,clicker)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
-- Use shears to get mushrooms and turn mooshroom into cow
|
-- Use shears to get mushrooms and turn mooshroom into cow
|
||||||
if item:get_name() == mobs_mc.items.shears then
|
if item:get_name() == mobs_mc.items.shears then
|
||||||
|
@ -169,6 +140,7 @@ mooshroom_def.on_rightclick = function(self, clicker)
|
||||||
minetest.add_item(pos, {name = mobs_mc.items.mushroom_stew})
|
minetest.add_item(pos, {name = mobs_mc.items.mushroom_stew})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||||
end
|
end
|
||||||
mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
|
mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
|
||||||
|
|
||||||
|
@ -179,53 +151,42 @@ mobs:spawn_specific(
|
||||||
"overworld",
|
"overworld",
|
||||||
"ground",
|
"ground",
|
||||||
{
|
{
|
||||||
"FlowerForest_beach",
|
"flat",
|
||||||
"Forest_beach",
|
|
||||||
"StoneBeach",
|
|
||||||
"ColdTaiga_beach_water",
|
|
||||||
"Taiga_beach",
|
|
||||||
"Savanna_beach",
|
|
||||||
"Plains_beach",
|
|
||||||
"ExtremeHills_beach",
|
|
||||||
"ColdTaiga_beach",
|
|
||||||
"Swampland_shore",
|
|
||||||
"JungleM_shore",
|
|
||||||
"Jungle_shore",
|
|
||||||
"MesaPlateauFM_sandlevel",
|
|
||||||
"MesaPlateauF_sandlevel",
|
|
||||||
"MesaBryce_sandlevel",
|
|
||||||
"Mesa_sandlevel",
|
|
||||||
"Mesa",
|
|
||||||
"FlowerForest",
|
|
||||||
"Swampland",
|
|
||||||
"Taiga",
|
|
||||||
"ExtremeHills",
|
|
||||||
"Jungle",
|
|
||||||
"Savanna",
|
|
||||||
"BirchForest",
|
|
||||||
"MegaSpruceTaiga",
|
|
||||||
"MegaTaiga",
|
|
||||||
"ExtremeHills+",
|
|
||||||
"Forest",
|
|
||||||
"Plains",
|
|
||||||
"Desert",
|
|
||||||
"ColdTaiga",
|
|
||||||
"IcePlainsSpikes",
|
"IcePlainsSpikes",
|
||||||
"SunflowerPlains",
|
"ColdTaiga",
|
||||||
"IcePlains",
|
"ColdTaiga_beach",
|
||||||
"RoofedForest",
|
"ColdTaiga_beach_water",
|
||||||
"ExtremeHills+_snowtop",
|
"MegaTaiga",
|
||||||
"MesaPlateauFM_grasstop",
|
"MegaSpruceTaiga",
|
||||||
"JungleEdgeM",
|
"ExtremeHills",
|
||||||
|
"ExtremeHills_beach",
|
||||||
"ExtremeHillsM",
|
"ExtremeHillsM",
|
||||||
"JungleM",
|
"ExtremeHills+",
|
||||||
|
"ExtremeHills+_snowtop",
|
||||||
|
"StoneBeach",
|
||||||
|
"Plains",
|
||||||
|
"Plains_beach",
|
||||||
|
"SunflowerPlains",
|
||||||
|
"Taiga",
|
||||||
|
"Taiga_beach",
|
||||||
|
"Forest",
|
||||||
|
"Forest_beach",
|
||||||
|
"FlowerForest",
|
||||||
|
"FlowerForest_beach",
|
||||||
|
"BirchForest",
|
||||||
"BirchForestM",
|
"BirchForestM",
|
||||||
"MesaPlateauF",
|
"RoofedForest",
|
||||||
"MesaPlateauFM",
|
"Savanna",
|
||||||
"MesaPlateauF_grasstop",
|
"Savanna_beach",
|
||||||
"MesaBryce",
|
|
||||||
"JungleEdge",
|
|
||||||
"SavannaM",
|
"SavannaM",
|
||||||
|
"Jungle",
|
||||||
|
"Jungle_shore",
|
||||||
|
"JungleM",
|
||||||
|
"JungleM_shore",
|
||||||
|
"JungleEdge",
|
||||||
|
"JungleEdgeM",
|
||||||
|
"Swampland",
|
||||||
|
"Swampland_shore"
|
||||||
},
|
},
|
||||||
9,
|
9,
|
||||||
minetest.LIGHT_MAX+1,
|
minetest.LIGHT_MAX+1,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### CREEPER
|
--################### CREEPER
|
||||||
|
@ -12,8 +12,6 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
mobs:register_mob("mobs_mc:creeper", {
|
mobs:register_mob("mobs_mc:creeper", {
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
hostile = true,
|
|
||||||
rotate = 270,
|
|
||||||
hp_min = 20,
|
hp_min = 20,
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
xp_min = 5,
|
xp_min = 5,
|
||||||
|
@ -35,44 +33,28 @@ mobs:register_mob("mobs_mc:creeper", {
|
||||||
explode = "tnt_explode",
|
explode = "tnt_explode",
|
||||||
distance = 16,
|
distance = 16,
|
||||||
},
|
},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1.05,
|
walk_velocity = 1.05,
|
||||||
run_velocity = 2.1,
|
run_velocity = 2.1,
|
||||||
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
|
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
|
||||||
attack_type = "explode",
|
attack_type = "explode",
|
||||||
eye_height = 1.25,
|
|
||||||
--hssssssssssss
|
--hssssssssssss
|
||||||
|
|
||||||
explosion_strength = 3,
|
explosion_strength = 3,
|
||||||
--explosion_radius = 3,
|
explosion_radius = 3.5,
|
||||||
--explosion_damage_radius = 6,
|
explosion_damage_radius = 3.5,
|
||||||
--explosiontimer_reset_radius = 6,
|
explosiontimer_reset_radius = 6,
|
||||||
reach = 3,
|
reach = 3,
|
||||||
defuse_reach = 5.2,
|
explosion_timer = 1.5,
|
||||||
explosion_timer = 0.3,
|
|
||||||
allow_fuse_reset = true,
|
allow_fuse_reset = true,
|
||||||
stop_to_explode = true,
|
stop_to_explode = true,
|
||||||
|
|
||||||
--head code
|
|
||||||
has_head = true,
|
|
||||||
head_bone = "head",
|
|
||||||
|
|
||||||
swap_y_with_x = true,
|
|
||||||
reverse_head_yaw = true,
|
|
||||||
|
|
||||||
head_bone_pos_y = 2.4,
|
|
||||||
head_bone_pos_z = 0,
|
|
||||||
|
|
||||||
head_height_offset = 1.1,
|
|
||||||
head_direction_offset = 0,
|
|
||||||
head_pitch_modifier = 0,
|
|
||||||
--end head code
|
|
||||||
|
|
||||||
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
|
-- Force-ignite creeper with flint and steel and explode after 1.5 seconds.
|
||||||
-- TODO: Make creeper flash after doing this as well.
|
-- TODO: Make creeper flash after doing this as well.
|
||||||
-- TODO: Test and debug this code.
|
-- TODO: Test and debug this code.
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if self._forced_explosion_countdown_timer then
|
if self._forced_explosion_countdown_timer ~= nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
@ -92,11 +74,10 @@ mobs:register_mob("mobs_mc:creeper", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
if self._forced_explosion_countdown_timer then
|
if self._forced_explosion_countdown_timer ~= nil then
|
||||||
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
|
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
|
||||||
if self._forced_explosion_countdown_timer <= 0 then
|
if self._forced_explosion_countdown_timer <= 0 then
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
|
||||||
mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -149,10 +130,9 @@ mobs:register_mob("mobs_mc:creeper", {
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:creeper_charged", {
|
mobs:register_mob("mobs_mc:creeper_charged", {
|
||||||
description = S("Charged Creeper"),
|
description = S("Creeper"),
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
hostile = true,
|
|
||||||
hp_min = 20,
|
hp_min = 20,
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
xp_min = 5,
|
xp_min = 5,
|
||||||
|
@ -169,7 +149,6 @@ mobs:register_mob("mobs_mc:creeper_charged", {
|
||||||
"mobs_mc_creeper_charge.png"},
|
"mobs_mc_creeper_charge.png"},
|
||||||
},
|
},
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
rotate = 270,
|
|
||||||
sounds = {
|
sounds = {
|
||||||
attack = "tnt_ignite",
|
attack = "tnt_ignite",
|
||||||
death = "mobs_mc_creeper_death",
|
death = "mobs_mc_creeper_death",
|
||||||
|
@ -178,19 +157,18 @@ mobs:register_mob("mobs_mc:creeper_charged", {
|
||||||
explode = "tnt_explode",
|
explode = "tnt_explode",
|
||||||
distance = 16,
|
distance = 16,
|
||||||
},
|
},
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1.05,
|
walk_velocity = 1.05,
|
||||||
run_velocity = 2.1,
|
run_velocity = 2.1,
|
||||||
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
|
runaway_from = { "mobs_mc:ocelot", "mobs_mc:cat" },
|
||||||
attack_type = "explode",
|
attack_type = "explode",
|
||||||
|
|
||||||
explosion_strength = 6,
|
explosion_strength = 6,
|
||||||
--explosion_radius = 3,
|
explosion_radius = 8,
|
||||||
--explosion_damage_radius = 6,
|
explosion_damage_radius = 8,
|
||||||
--explosiontimer_reset_radius = 3,
|
explosiontimer_reset_radius = 6,
|
||||||
reach = 3,
|
reach = 3,
|
||||||
defuse_reach = 5.2,
|
explosion_timer = 1.5,
|
||||||
explosion_timer = 0.3,
|
|
||||||
allow_fuse_reset = true,
|
allow_fuse_reset = true,
|
||||||
stop_to_explode = true,
|
stop_to_explode = true,
|
||||||
|
|
||||||
|
@ -198,7 +176,7 @@ mobs:register_mob("mobs_mc:creeper_charged", {
|
||||||
-- TODO: Make creeper flash after doing this as well.
|
-- TODO: Make creeper flash after doing this as well.
|
||||||
-- TODO: Test and debug this code.
|
-- TODO: Test and debug this code.
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if self._forced_explosion_countdown_timer then
|
if self._forced_explosion_countdown_timer ~= nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
|
@ -218,11 +196,10 @@ mobs:register_mob("mobs_mc:creeper_charged", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
if self._forced_explosion_countdown_timer then
|
if self._forced_explosion_countdown_timer ~= nil then
|
||||||
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
|
self._forced_explosion_countdown_timer = self._forced_explosion_countdown_timer - dtime
|
||||||
if self._forced_explosion_countdown_timer <= 0 then
|
if self._forced_explosion_countdown_timer <= 0 then
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
mobs:boom(self, mcl_util.get_object_center(self.object), self.explosion_strength)
|
||||||
mcl_explosions.explode(mcl_util.get_object_center(self.object), self.explosion_strength, { griefing = mobs_griefing, drop_chance = 1.0}, self.object)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -2,28 +2,21 @@
|
||||||
--################### ENDERDRAGON
|
--################### ENDERDRAGON
|
||||||
--###################
|
--###################
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:enderdragon", {
|
mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
description = S("Ender Dragon"),
|
description = S("Ender Dragon"),
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
|
pathfinding = 1,
|
||||||
attacks_animals = true,
|
attacks_animals = true,
|
||||||
walk_chance = 100,
|
walk_chance = 100,
|
||||||
rotate = 270,
|
|
||||||
tilt_fly = true,
|
|
||||||
hostile = true,
|
|
||||||
shoot_arrow = function(self, pos, dir)
|
|
||||||
-- 2-4 damage per arrow
|
|
||||||
local dmg = math.random(2,4)
|
|
||||||
mobs.shoot_projectile_handling("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
|
|
||||||
end,
|
|
||||||
hp_max = 200,
|
hp_max = 200,
|
||||||
hp_min = 200,
|
hp_min = 200,
|
||||||
xp_min = 500,
|
xp_min = 500,
|
||||||
xp_max = 500,
|
xp_max = 500,
|
||||||
collisionbox = {-2, 0, -2, 2, 2, 2},
|
collisionbox = {-2, 3, -2, 2, 5, 2},
|
||||||
eye_height = 1,
|
physical = false,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_dragon.b3d",
|
mesh = "mobs_mc_dragon.b3d",
|
||||||
textures = {
|
textures = {
|
||||||
|
@ -31,7 +24,6 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
},
|
},
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
view_range = 35,
|
view_range = 35,
|
||||||
reach = 20,
|
|
||||||
walk_velocity = 6,
|
walk_velocity = 6,
|
||||||
run_velocity = 6,
|
run_velocity = 6,
|
||||||
can_despawn = false,
|
can_despawn = false,
|
||||||
|
@ -55,10 +47,12 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
lava_damage = 0,
|
lava_damage = 0,
|
||||||
fire_damage = 0,
|
fire_damage = 0,
|
||||||
on_rightclick = nil,
|
on_rightclick = nil,
|
||||||
attack_type = "projectile",
|
attack_type = "dogshoot",
|
||||||
arrow = "mobs_mc:dragon_fireball",
|
arrow = "mobs_mc:dragon_fireball",
|
||||||
shoot_interval = 0.5,
|
shoot_interval = 0.5,
|
||||||
shoot_offset = -1.0,
|
shoot_offset = -1.0,
|
||||||
|
xp_min = 500,
|
||||||
|
xp_max = 500,
|
||||||
animation = {
|
animation = {
|
||||||
fly_speed = 8, stand_speed = 8,
|
fly_speed = 8, stand_speed = 8,
|
||||||
stand_start = 0, stand_end = 20,
|
stand_start = 0, stand_end = 20,
|
||||||
|
@ -111,8 +105,8 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
fire_resistant = true,
|
fire_resistant = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
--TODO: replace this setting by a proper gamerules system
|
|
||||||
local mobs_griefing = minetest.settings:get_bool("mobs_griefing", true)
|
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
|
||||||
|
|
||||||
-- dragon fireball (projectile)
|
-- dragon fireball (projectile)
|
||||||
mobs:register_arrow("mobs_mc:dragon_fireball", {
|
mobs:register_arrow("mobs_mc:dragon_fireball", {
|
||||||
|
@ -139,13 +133,10 @@ mobs:register_arrow("mobs_mc:dragon_fireball", {
|
||||||
|
|
||||||
-- node hit, explode
|
-- node hit, explode
|
||||||
hit_node = function(self, pos, node)
|
hit_node = function(self, pos, node)
|
||||||
--mobs:boom(self, pos, 2)
|
mobs:boom(self, pos, 2)
|
||||||
if mobs_griefing then
|
|
||||||
mcl_explosions.explode(self.object:get_pos(), 2, { drop_chance = 1.0 })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
mobs:register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "mobs_mc_spawn_icon_dragon.png", 0, true)
|
mobs:register_egg("mobs_mc:enderdragon", S("Ender Dragon"), "mobs_mc_spawn_icon_dragon.png", 0, true)
|
||||||
|
|
||||||
--mcl_wip.register_wip_item("mobs_mc:enderdragon")
|
mcl_wip.register_wip_item("mobs_mc:enderdragon")
|
||||||
|
|
|
@ -24,11 +24,9 @@
|
||||||
-- added rain damage.
|
-- added rain damage.
|
||||||
-- fixed the grass_with_dirt issue.
|
-- fixed the grass_with_dirt issue.
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
local vector = vector
|
local telesound = function(pos, is_source)
|
||||||
|
|
||||||
local function telesound(pos, is_source)
|
|
||||||
local snd
|
local snd
|
||||||
if is_source then
|
if is_source then
|
||||||
snd = "mobs_mc_enderman_teleport_src"
|
snd = "mobs_mc_enderman_teleport_src"
|
||||||
|
@ -195,19 +193,18 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
description = S("Enderman"),
|
description = S("Enderman"),
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
neutral = true,
|
passive = true,
|
||||||
|
pathfinding = 1,
|
||||||
hp_min = 40,
|
hp_min = 40,
|
||||||
hp_max = 40,
|
hp_max = 40,
|
||||||
xp_min = 5,
|
xp_min = 5,
|
||||||
xp_max = 5,
|
xp_max = 5,
|
||||||
rotate = 270,
|
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 2.89, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 2.89, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_enderman.b3d",
|
mesh = "mobs_mc_enderman.b3d",
|
||||||
textures = create_enderman_textures(),
|
textures = create_enderman_textures(),
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
eye_height = 2.5,
|
|
||||||
sounds = {
|
sounds = {
|
||||||
-- TODO: Custom war cry sound
|
-- TODO: Custom war cry sound
|
||||||
war_cry = "mobs_sandmonster",
|
war_cry = "mobs_sandmonster",
|
||||||
|
@ -216,8 +213,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
random = {name="mobs_mc_enderman_random", gain=0.5},
|
random = {name="mobs_mc_enderman_random", gain=0.5},
|
||||||
distance = 16,
|
distance = 16,
|
||||||
},
|
},
|
||||||
walk_velocity = 1,
|
walk_velocity = 0.2,
|
||||||
run_velocity = 4,
|
run_velocity = 3.4,
|
||||||
damage = 7,
|
damage = 7,
|
||||||
reach = 2,
|
reach = 2,
|
||||||
drops = {
|
drops = {
|
||||||
|
@ -227,22 +224,6 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
max = 1,
|
max = 1,
|
||||||
looting = "common"},
|
looting = "common"},
|
||||||
},
|
},
|
||||||
|
|
||||||
--head code
|
|
||||||
has_head = false,
|
|
||||||
head_bone = "head.low",
|
|
||||||
|
|
||||||
swap_y_with_x = false,
|
|
||||||
reverse_head_yaw = false,
|
|
||||||
|
|
||||||
head_bone_pos_y = 2.4,
|
|
||||||
head_bone_pos_z = 0,
|
|
||||||
|
|
||||||
head_height_offset = 1.1,
|
|
||||||
head_direction_offset = 0,
|
|
||||||
head_pitch_modifier = 0,
|
|
||||||
--end head code
|
|
||||||
|
|
||||||
animation = select_enderman_animation("normal"),
|
animation = select_enderman_animation("normal"),
|
||||||
_taken_node = "",
|
_taken_node = "",
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
|
@ -301,10 +282,10 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
--self:teleport(nil)
|
--self:teleport(nil)
|
||||||
--self.state = ""
|
--self.state = ""
|
||||||
--else
|
--else
|
||||||
if self.attacking then
|
if self.attack then
|
||||||
local target = self.attacking
|
local target = self.attack
|
||||||
local pos = target:get_pos()
|
local pos = target:get_pos()
|
||||||
if pos then
|
if pos ~= nil then
|
||||||
if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then
|
if vector.distance(self.object:get_pos(), target:get_pos()) > 10 then
|
||||||
self:teleport(target)
|
self:teleport(target)
|
||||||
end
|
end
|
||||||
|
@ -320,12 +301,12 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
local obj = objs[n]
|
local obj = objs[n]
|
||||||
if obj then
|
if obj then
|
||||||
--if minetest.is_player(obj) then
|
if minetest.is_player(obj) then
|
||||||
-- Warp from players during day.
|
-- Warp from players during day.
|
||||||
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
|
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
|
||||||
-- self:teleport(nil)
|
-- self:teleport(nil)
|
||||||
--end
|
--end
|
||||||
if not obj:is_player() then
|
else
|
||||||
local lua = obj:get_luaentity()
|
local lua = obj:get_luaentity()
|
||||||
if lua then
|
if lua then
|
||||||
if lua.name == "mcl_bows:arrow_entity" or lua.name == "mcl_throwing:snowball_entity" then
|
if lua.name == "mcl_bows:arrow_entity" or lua.name == "mcl_throwing:snowball_entity" then
|
||||||
|
@ -343,8 +324,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
-- self:teleport(nil)
|
-- self:teleport(nil)
|
||||||
-- self.state = ""
|
-- self.state = ""
|
||||||
--else
|
--else
|
||||||
if self.attack and not minetest.settings:get_bool("creative_mode") then
|
if self.attack ~= nil and not minetest.settings:get_bool("creative_mode") then
|
||||||
self.state = "attack"
|
self.state = 'attack'
|
||||||
end
|
end
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
@ -379,16 +360,11 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
--if looking in general head position, turn hostile
|
--if looking in general head position, turn hostile
|
||||||
if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then
|
if minetest.line_of_sight(ender_eye_pos, look_pos_base) and vector.distance(look_pos, ender_eye_pos) <= 0.4 then
|
||||||
self.provoked = "staring"
|
self.provoked = "staring"
|
||||||
self.state = "stand"
|
self.attack = minetest.get_player_by_name(obj:get_player_name())
|
||||||
self.hostile = false
|
|
||||||
break
|
break
|
||||||
--begin attacking the player
|
else -- I'm not sure what this part does, but I don't want to break anything - jordan4ibanez
|
||||||
else
|
|
||||||
if self.provoked == "staring" then
|
if self.provoked == "staring" then
|
||||||
self.provoked = "broke_contact"
|
self.provoked = "broke_contact"
|
||||||
self.hostile = true
|
|
||||||
self.state = "attack"
|
|
||||||
self.attacking = obj
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -419,8 +395,9 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
local node = minetest.get_node(take_pos)
|
local node = minetest.get_node(take_pos)
|
||||||
-- Don't destroy protected stuff.
|
-- Don't destroy protected stuff.
|
||||||
if not minetest.is_protected(take_pos, "") then
|
if not minetest.is_protected(take_pos, "") then
|
||||||
local dug = minetest.dig_node(take_pos)
|
minetest.remove_node(take_pos)
|
||||||
if dug then
|
local dug = minetest.get_node_or_nil(take_pos)
|
||||||
|
if dug and dug.name == "air" then
|
||||||
if mobs_mc.enderman_replace_on_take[node.name] then
|
if mobs_mc.enderman_replace_on_take[node.name] then
|
||||||
self._taken_node = mobs_mc.enderman_replace_on_take[node.name]
|
self._taken_node = mobs_mc.enderman_replace_on_take[node.name]
|
||||||
else
|
else
|
||||||
|
@ -454,14 +431,14 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
self.base_texture = create_enderman_textures(block_type, self._taken_node)
|
self.base_texture = create_enderman_textures(block_type, self._taken_node)
|
||||||
self.object:set_properties({ textures = self.base_texture })
|
self.object:set_properties({ textures = self.base_texture })
|
||||||
self.animation = select_enderman_animation("block")
|
self.animation = select_enderman_animation("block")
|
||||||
mobs.set_mob_animation(self, self.animation.current)
|
mobs:set_animation(self, self.animation.current)
|
||||||
if def.sounds and def.sounds.dug then
|
if def.sounds and def.sounds.dug then
|
||||||
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true)
|
minetest.sound_play(def.sounds.dug, {pos = take_pos, max_hear_distance = 16}, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif self._taken_node and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then
|
elseif self._taken_node ~= nil and self._taken_node ~= "" and self._take_place_timer >= self._next_take_place_time then
|
||||||
-- Place taken node
|
-- Place taken node
|
||||||
self._take_place_timer = 0
|
self._take_place_timer = 0
|
||||||
self._next_take_place_time = math.random(take_frequency_min, take_frequency_max)
|
self._next_take_place_time = math.random(take_frequency_min, take_frequency_max)
|
||||||
|
@ -477,7 +454,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
local def = minetest.registered_nodes[self._taken_node]
|
local def = minetest.registered_nodes[self._taken_node]
|
||||||
-- Update animation accordingly (removes visible block)
|
-- Update animation accordingly (removes visible block)
|
||||||
self.animation = select_enderman_animation("normal")
|
self.animation = select_enderman_animation("normal")
|
||||||
mobs.set_mob_animation(self, self.animation.current)
|
mobs:set_animation(self, self.animation.current)
|
||||||
if def.sounds and def.sounds.place then
|
if def.sounds and def.sounds.place then
|
||||||
minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}, true)
|
minetest.sound_play(def.sounds.place, {pos = place_pos, max_hear_distance = 16}, true)
|
||||||
end
|
end
|
||||||
|
@ -487,12 +464,12 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
do_teleport = function(self, target)
|
do_teleport = function(self, target)
|
||||||
if target then
|
if target ~= nil then
|
||||||
local target_pos = target:get_pos()
|
local target_pos = target:get_pos()
|
||||||
-- Find all solid nodes below air in a 10×10×10 cuboid centered on the target
|
-- Find all solid nodes below air in a 10×10×10 cuboid centered on the target
|
||||||
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"})
|
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(target_pos, 5), vector.add(target_pos, 5), {"group:solid", "group:cracky", "group:crumbly"})
|
||||||
local telepos
|
local telepos
|
||||||
if nodes then
|
if nodes ~= nil then
|
||||||
if #nodes > 0 then
|
if #nodes > 0 then
|
||||||
-- Up to 64 attempts to teleport
|
-- Up to 64 attempts to teleport
|
||||||
for n=1, math.min(64, #nodes) do
|
for n=1, math.min(64, #nodes) do
|
||||||
|
@ -502,7 +479,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
-- Selected node needs to have 3 nodes of free space above
|
-- Selected node needs to have 3 nodes of free space above
|
||||||
for u=1, 3 do
|
for u=1, 3 do
|
||||||
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
||||||
if minetest.registered_nodes[node.name].walkable then
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
if ndef and ndef.walkable then
|
||||||
node_ok = false
|
node_ok = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -527,7 +505,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
-- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract():
|
-- We need to add (or subtract) different random numbers to each vector component, so it couldn't be done with a nice single vector.add() or .subtract():
|
||||||
local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) )
|
local randomCube = vector.new( pos.x + 8*(pr:next(0,16)-8), pos.y + 8*(pr:next(0,16)-8), pos.z + 8*(pr:next(0,16)-8) )
|
||||||
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"})
|
local nodes = minetest.find_nodes_in_area_under_air(vector.subtract(randomCube, 4), vector.add(randomCube, 4), {"group:solid", "group:cracky", "group:crumbly"})
|
||||||
if nodes then
|
if nodes ~= nil then
|
||||||
if #nodes > 0 then
|
if #nodes > 0 then
|
||||||
-- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport
|
-- Up to 8 low-level (in total up to 8*8 = 64) attempts to teleport
|
||||||
for n=1, math.min(8, #nodes) do
|
for n=1, math.min(8, #nodes) do
|
||||||
|
@ -536,7 +514,8 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
node_ok = true
|
node_ok = true
|
||||||
for u=1, 3 do
|
for u=1, 3 do
|
||||||
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
local node = minetest.get_node({x=nodepos.x, y=nodepos.y+u, z=nodepos.z})
|
||||||
if minetest.registered_nodes[node.name].walkable then
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
|
if ndef and ndef.walkable then
|
||||||
node_ok = false
|
node_ok = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -559,13 +538,13 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
end,
|
end,
|
||||||
on_die = function(self, pos)
|
on_die = function(self, pos)
|
||||||
-- Drop carried node on death
|
-- Drop carried node on death
|
||||||
if self._taken_node and self._taken_node ~= "" then
|
if self._taken_node ~= nil and self._taken_node ~= "" then
|
||||||
minetest.add_item(pos, self._taken_node)
|
minetest.add_item(pos, self._taken_node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
do_punch = function(self, hitter, tflp, tool_caps, dir)
|
do_punch = function(self, hitter, tflp, tool_caps, dir)
|
||||||
-- damage from rain caused by itself so we don't want it to attack itself.
|
-- damage from rain caused by itself so we don't want it to attack itself.
|
||||||
if hitter ~= self.object and hitter then
|
if hitter ~= self.object and hitter ~= nil then
|
||||||
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
|
--if (minetest.get_timeofday() * 24000) > 5001 and (minetest.get_timeofday() * 24000) < 19000 then
|
||||||
-- self:teleport(nil)
|
-- self:teleport(nil)
|
||||||
--else
|
--else
|
||||||
|
@ -581,7 +560,7 @@ mobs:register_mob("mobs_mc:enderman", {
|
||||||
water_damage = 8,
|
water_damage = 8,
|
||||||
view_range = 64,
|
view_range = 64,
|
||||||
fear_height = 4,
|
fear_height = 4,
|
||||||
attack_type = "punch",
|
attack_type = "dogfight",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,22 +2,19 @@
|
||||||
--################### ENDERMITE
|
--################### ENDERMITE
|
||||||
--###################
|
--###################
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:endermite", {
|
mobs:register_mob("mobs_mc:endermite", {
|
||||||
description = S("Endermite"),
|
description = S("Endermite"),
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
passive = false,
|
passive = false,
|
||||||
rotate = 270,
|
|
||||||
hostile = true,
|
|
||||||
hp_min = 8,
|
hp_min = 8,
|
||||||
hp_max = 8,
|
hp_max = 8,
|
||||||
xp_min = 3,
|
xp_min = 3,
|
||||||
xp_max = 3,
|
xp_max = 3,
|
||||||
armor = {fleshy = 100, arthropod = 100},
|
armor = {fleshy = 100, arthropod = 100},
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
attack_type = "punch",
|
|
||||||
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2},
|
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.29, 0.2},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_endermite.b3d",
|
mesh = "mobs_mc_endermite.b3d",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
--made for MC like Survival game
|
--made for MC like Survival game
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### GHAST
|
--################### GHAST
|
||||||
|
@ -14,17 +14,13 @@ mobs:register_mob("mobs_mc:ghast", {
|
||||||
description = S("Ghast"),
|
description = S("Ghast"),
|
||||||
type = "monster",
|
type = "monster",
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
|
pathfinding = 1,
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
hostile = true,
|
|
||||||
fly_random_while_attack = true,
|
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
rotate = 270,
|
|
||||||
xp_min = 5,
|
xp_min = 5,
|
||||||
xp_max = 5,
|
xp_max = 5,
|
||||||
reach = 20,
|
collisionbox = {-2, 5, -2, 2, 9, 2},
|
||||||
eye_height = 2.5,
|
|
||||||
collisionbox = {-2, 0, -2, 2, 4, 2},
|
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_ghast.b3d",
|
mesh = "mobs_mc_ghast.b3d",
|
||||||
textures = {
|
textures = {
|
||||||
|
@ -40,10 +36,8 @@ mobs:register_mob("mobs_mc:ghast", {
|
||||||
-- TODO: damage
|
-- TODO: damage
|
||||||
-- TODO: better death
|
-- TODO: better death
|
||||||
},
|
},
|
||||||
|
|
||||||
walk_velocity = 1.6,
|
walk_velocity = 1.6,
|
||||||
run_velocity = 3.2,
|
run_velocity = 3.2,
|
||||||
|
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.gunpowder, chance = 1, min = 0, max = 2, looting = "common"},
|
{name = mobs_mc.items.gunpowder, chance = 1, min = 0, max = 2, looting = "common"},
|
||||||
{name = mobs_mc.items.ghast_tear, chance = 10/6, min = 0, max = 1, looting = "common", looting_ignore_chance = true},
|
{name = mobs_mc.items.ghast_tear, chance = 10/6, min = 0, max = 1, looting = "common", looting_ignore_chance = true},
|
||||||
|
@ -54,23 +48,22 @@ mobs:register_mob("mobs_mc:ghast", {
|
||||||
walk_start = 0, walk_end = 40,
|
walk_start = 0, walk_end = 40,
|
||||||
run_start = 0, run_end = 40,
|
run_start = 0, run_end = 40,
|
||||||
},
|
},
|
||||||
|
|
||||||
fall_damage = 0,
|
fall_damage = 0,
|
||||||
view_range = 28,
|
view_range = 100,
|
||||||
attack_type = "projectile",
|
attack_type = "dogshoot",
|
||||||
arrow = "mobs_mc:ghast_fireball",
|
arrow = "mobs_mc:fireball",
|
||||||
|
shoot_interval = 3.5,
|
||||||
|
shoot_offset = -5,
|
||||||
|
dogshoot_switch = 1,
|
||||||
|
dogshoot_count_max =1,
|
||||||
|
passive = false,
|
||||||
|
jump = true,
|
||||||
|
jump_height = 4,
|
||||||
floats=1,
|
floats=1,
|
||||||
fly = true,
|
fly = true,
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
|
instant_death = true,
|
||||||
fire_resistant = true,
|
fire_resistant = true,
|
||||||
projectile_cooldown_min = 5,
|
|
||||||
projectile_cooldown_max = 7,
|
|
||||||
shoot_arrow = function(self, pos, dir)
|
|
||||||
-- 2-4 damage per arrow
|
|
||||||
local dmg = math.random(2,4)
|
|
||||||
mobs.shoot_projectile_handling("mobs_mc:ghast_fireball", pos, dir, self.object:get_yaw(), self.object, 11, dmg,nil,nil,nil,-0.6)
|
|
||||||
end,
|
|
||||||
--[[
|
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
if self.firing == true then
|
if self.firing == true then
|
||||||
self.base_texture = {"mobs_mc_ghast_firing.png"}
|
self.base_texture = {"mobs_mc_ghast_firing.png"}
|
||||||
|
@ -80,7 +73,6 @@ mobs:register_mob("mobs_mc:ghast", {
|
||||||
self.object:set_properties({textures=self.base_texture})
|
self.object:set_properties({textures=self.base_texture})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
]]--
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,40 +92,32 @@ mobs_mc.spawn_height.nether_min,
|
||||||
mobs_mc.spawn_height.nether_max)
|
mobs_mc.spawn_height.nether_max)
|
||||||
|
|
||||||
-- fireball (projectile)
|
-- fireball (projectile)
|
||||||
mobs:register_arrow("mobs_mc:ghast_fireball", {
|
mobs:register_arrow("mobs_mc:fireball", {
|
||||||
visual = "sprite",
|
visual = "sprite",
|
||||||
visual_size = {x = 1, y = 1},
|
visual_size = {x = 1, y = 1},
|
||||||
textures = {"mcl_fire_fire_charge.png"},
|
textures = {"mcl_fire_fire_charge.png"},
|
||||||
velocity = 15,
|
velocity = 15,
|
||||||
collisionbox = {-.5, -.5, -.5, .5, .5, .5},
|
collisionbox = {-.5, -.5, -.5, .5, .5, .5},
|
||||||
tail = 1,
|
|
||||||
tail_texture = "mobs_mc_spit.png^[colorize:black:255", --repurpose spit texture
|
|
||||||
tail_size = 5,
|
|
||||||
_is_fireball = true,
|
_is_fireball = true,
|
||||||
|
|
||||||
hit_player = function(self, player)
|
hit_player = function(self, player)
|
||||||
--[[
|
|
||||||
player:punch(self.object, 1.0, {
|
player:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = 6},
|
damage_groups = {fleshy = 6},
|
||||||
}, nil)
|
}, nil)
|
||||||
]]--
|
mobs:boom(self, self.object:get_pos(), 1, true)
|
||||||
--mobs:boom(self, self.object:get_pos(), 1, true)
|
|
||||||
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
hit_mob = function(self, mob)
|
||||||
mob:punch(self.object, 1.0, {
|
mob:punch(self.object, 1.0, {
|
||||||
full_punch_interval = 1.0,
|
full_punch_interval = 1.0,
|
||||||
damage_groups = {fleshy = self._damage},
|
damage_groups = {fleshy = 6},
|
||||||
}, nil)
|
}, nil)
|
||||||
--mobs:boom(self, self.object:get_pos(), 1, true)
|
mobs:boom(self, self.object:get_pos(), 1, true)
|
||||||
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
hit_node = function(self, pos, node)
|
hit_node = function(self, pos, node)
|
||||||
--mobs:boom(self, pos, 1, true)
|
mobs:boom(self, pos, 1, true)
|
||||||
mcl_explosions.explode(self.object:get_pos(), 3,{ drop_chance = 1.0 })
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
--################### GUARDIAN
|
--################### GUARDIAN
|
||||||
--###################
|
--###################
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:guardian", {
|
mobs:register_mob("mobs_mc:guardian", {
|
||||||
description = S("Guardian"),
|
description = S("Guardian"),
|
||||||
|
@ -13,8 +13,8 @@ mobs:register_mob("mobs_mc:guardian", {
|
||||||
xp_min = 10,
|
xp_min = 10,
|
||||||
xp_max = 10,
|
xp_max = 10,
|
||||||
breath_max = -1,
|
breath_max = -1,
|
||||||
passive = false,
|
passive = false,
|
||||||
attack_type = "punch",
|
attack_type = "dogfight",
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
walk_velocity = 2,
|
walk_velocity = 2,
|
||||||
|
@ -94,6 +94,7 @@ mobs:register_mob("mobs_mc:guardian", {
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source },
|
fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source },
|
||||||
jump = false,
|
jump = false,
|
||||||
|
view_range = 16,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Spawning disabled due to size issues
|
-- Spawning disabled due to size issues
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
--################### GUARDIAN
|
--################### GUARDIAN
|
||||||
--###################
|
--###################
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:guardian_elder", {
|
mobs:register_mob("mobs_mc:guardian_elder", {
|
||||||
description = S("Elder Guardian"),
|
description = S("Elder Guardian"),
|
||||||
|
@ -15,8 +15,8 @@ mobs:register_mob("mobs_mc:guardian_elder", {
|
||||||
xp_min = 10,
|
xp_min = 10,
|
||||||
xp_max = 10,
|
xp_max = 10,
|
||||||
breath_max = -1,
|
breath_max = -1,
|
||||||
passive = false,
|
passive = false,
|
||||||
attack_type = "punch",
|
attack_type = "dogfight",
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
walk_velocity = 2,
|
walk_velocity = 2,
|
||||||
|
@ -104,6 +104,7 @@ mobs:register_mob("mobs_mc:guardian_elder", {
|
||||||
makes_footstep_sound = false,
|
makes_footstep_sound = false,
|
||||||
fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source },
|
fly_in = { mobs_mc.items.water_source, mobs_mc.items.river_water_source },
|
||||||
jump = false,
|
jump = false,
|
||||||
|
view_range = 16,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Spawning disabled due to size issues <- what do you mean? -j4i
|
-- Spawning disabled due to size issues <- what do you mean? -j4i
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
--made for MC like Survival game
|
--made for MC like Survival game
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### HORSE
|
--################### HORSE
|
||||||
|
@ -38,9 +38,9 @@ end
|
||||||
local can_equip_horse_armor = function(entity_id)
|
local can_equip_horse_armor = function(entity_id)
|
||||||
return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse"
|
return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse"
|
||||||
end
|
end
|
||||||
--[[local can_equip_chest = function(entity_id)
|
local can_equip_chest = function(entity_id)
|
||||||
return entity_id == "mobs_mc:mule" or entity_id == "mobs_mc:donkey"
|
return entity_id == "mobs_mc:mule" or entity_id == "mobs_mc:donkey"
|
||||||
end]]
|
end
|
||||||
local can_breed = function(entity_id)
|
local can_breed = function(entity_id)
|
||||||
return entity_id == "mobs_mc:horse" or "mobs_mc:mule" or entity_id == "mobs_mc:donkey"
|
return entity_id == "mobs_mc:horse" or "mobs_mc:mule" or entity_id == "mobs_mc:donkey"
|
||||||
end
|
end
|
||||||
|
@ -88,10 +88,6 @@ local horse = {
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_horse.b3d",
|
mesh = "mobs_mc_horse.b3d",
|
||||||
rotate = 270,
|
|
||||||
walk_velocity = 1,
|
|
||||||
run_velocity = 8,
|
|
||||||
skittish = true,
|
|
||||||
visual_size = {x=3.0, y=3.0},
|
visual_size = {x=3.0, y=3.0},
|
||||||
collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825},
|
collisionbox = {-0.69825, -0.01, -0.69825, 0.69825, 1.59, 0.69825},
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -101,7 +97,7 @@ local horse = {
|
||||||
walk_speed = 25,
|
walk_speed = 25,
|
||||||
walk_start = 0,
|
walk_start = 0,
|
||||||
walk_end = 40,
|
walk_end = 40,
|
||||||
run_speed = 120,
|
run_speed = 60,
|
||||||
run_start = 0,
|
run_start = 0,
|
||||||
run_end = 40,
|
run_end = 40,
|
||||||
},
|
},
|
||||||
|
@ -118,8 +114,7 @@ local horse = {
|
||||||
fly = false,
|
fly = false,
|
||||||
walk_chance = 60,
|
walk_chance = 60,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
follow = "mcl_farming:wheat_item",
|
follow = mobs_mc.follow.horse,
|
||||||
follow_distance = 3,
|
|
||||||
passive = true,
|
passive = true,
|
||||||
hp_min = 15,
|
hp_min = 15,
|
||||||
hp_max = 30,
|
hp_max = 30,
|
||||||
|
@ -187,7 +182,7 @@ local horse = {
|
||||||
-- if driver present and horse has a saddle allow control of horse
|
-- if driver present and horse has a saddle allow control of horse
|
||||||
if self.driver and self._saddle then
|
if self.driver and self._saddle then
|
||||||
|
|
||||||
mobs.drive(self, "run", "stand", false, dtime)
|
mobs.drive(self, "walk", "stand", false, dtime)
|
||||||
|
|
||||||
return false -- skip rest of mob functions
|
return false -- skip rest of mob functions
|
||||||
end
|
end
|
||||||
|
@ -219,21 +214,6 @@ local horse = {
|
||||||
local iname = item:get_name()
|
local iname = item:get_name()
|
||||||
local heal = 0
|
local heal = 0
|
||||||
|
|
||||||
--sneak click to breed the horse/feed it
|
|
||||||
if self.owner and self.owner == clicker:get_player_name() then
|
|
||||||
--attempt to enter breed state
|
|
||||||
if mobs.enter_breed_state(self,clicker) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--don't do any other logic with the baby
|
|
||||||
--make baby grow faster
|
|
||||||
if self.baby then
|
|
||||||
mobs.make_baby_grow_faster(self,clicker)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Taming
|
-- Taming
|
||||||
self.temper = self.temper or (math.random(1,100))
|
self.temper = self.temper or (math.random(1,100))
|
||||||
|
|
||||||
|
@ -259,7 +239,6 @@ local horse = {
|
||||||
self.buck_off_time = 40 -- TODO how long does it take in minecraft?
|
self.buck_off_time = 40 -- TODO how long does it take in minecraft?
|
||||||
if self.temper > 100 then
|
if self.temper > 100 then
|
||||||
self.tamed = true -- NOTE taming can only be finished by riding the horse
|
self.tamed = true -- NOTE taming can only be finished by riding the horse
|
||||||
mobs.tamed_effect(self)
|
|
||||||
if not self.owner or self.owner == "" then
|
if not self.owner or self.owner == "" then
|
||||||
self.owner = clicker:get_player_name()
|
self.owner = clicker:get_player_name()
|
||||||
end
|
end
|
||||||
|
@ -274,14 +253,6 @@ local horse = {
|
||||||
-- If nothing happened temper_increase = 0 and addition does nothing
|
-- If nothing happened temper_increase = 0 and addition does nothing
|
||||||
self.temper = self.temper + temper_increase
|
self.temper = self.temper + temper_increase
|
||||||
|
|
||||||
--give the player some kind of idea
|
|
||||||
--of what's happening with the horse's temper
|
|
||||||
if self.temper <= 100 then
|
|
||||||
mobs.feed_effect(self)
|
|
||||||
else
|
|
||||||
mobs.tamed_effect(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -311,10 +282,14 @@ local horse = {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if mobs:protect(self, clicker) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Make sure tamed horse is mature and being clicked by owner only
|
-- Make sure tamed horse is mature and being clicked by owner only
|
||||||
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
||||||
|
|
||||||
--local inv = clicker:get_inventory()
|
local inv = clicker:get_inventory()
|
||||||
|
|
||||||
-- detatch player already riding horse
|
-- detatch player already riding horse
|
||||||
if self.driver and clicker == self.driver then
|
if self.driver and clicker == self.driver then
|
||||||
|
@ -382,6 +357,9 @@ local horse = {
|
||||||
self.object:set_properties({stepheight = 1.1})
|
self.object:set_properties({stepheight = 1.1})
|
||||||
mobs.attach(self, clicker)
|
mobs.attach(self, clicker)
|
||||||
|
|
||||||
|
-- Used to capture horse
|
||||||
|
elseif not self.driver and iname ~= "" then
|
||||||
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -542,53 +520,42 @@ mobs:spawn_specific(
|
||||||
"overworld",
|
"overworld",
|
||||||
"ground",
|
"ground",
|
||||||
{
|
{
|
||||||
"FlowerForest_beach",
|
"flat",
|
||||||
"Forest_beach",
|
|
||||||
"StoneBeach",
|
|
||||||
"ColdTaiga_beach_water",
|
|
||||||
"Taiga_beach",
|
|
||||||
"Savanna_beach",
|
|
||||||
"Plains_beach",
|
|
||||||
"ExtremeHills_beach",
|
|
||||||
"ColdTaiga_beach",
|
|
||||||
"Swampland_shore",
|
|
||||||
"JungleM_shore",
|
|
||||||
"Jungle_shore",
|
|
||||||
"MesaPlateauFM_sandlevel",
|
|
||||||
"MesaPlateauF_sandlevel",
|
|
||||||
"MesaBryce_sandlevel",
|
|
||||||
"Mesa_sandlevel",
|
|
||||||
"Mesa",
|
|
||||||
"FlowerForest",
|
|
||||||
"Swampland",
|
|
||||||
"Taiga",
|
|
||||||
"ExtremeHills",
|
|
||||||
"Jungle",
|
|
||||||
"Savanna",
|
|
||||||
"BirchForest",
|
|
||||||
"MegaSpruceTaiga",
|
|
||||||
"MegaTaiga",
|
|
||||||
"ExtremeHills+",
|
|
||||||
"Forest",
|
|
||||||
"Plains",
|
|
||||||
"Desert",
|
|
||||||
"ColdTaiga",
|
|
||||||
"IcePlainsSpikes",
|
"IcePlainsSpikes",
|
||||||
"SunflowerPlains",
|
"ColdTaiga",
|
||||||
"IcePlains",
|
"ColdTaiga_beach",
|
||||||
"RoofedForest",
|
"ColdTaiga_beach_water",
|
||||||
"ExtremeHills+_snowtop",
|
"MegaTaiga",
|
||||||
"MesaPlateauFM_grasstop",
|
"MegaSpruceTaiga",
|
||||||
"JungleEdgeM",
|
"ExtremeHills",
|
||||||
|
"ExtremeHills_beach",
|
||||||
"ExtremeHillsM",
|
"ExtremeHillsM",
|
||||||
"JungleM",
|
"ExtremeHills+",
|
||||||
|
"ExtremeHills+_snowtop",
|
||||||
|
"StoneBeach",
|
||||||
|
"Plains",
|
||||||
|
"Plains_beach",
|
||||||
|
"SunflowerPlains",
|
||||||
|
"Taiga",
|
||||||
|
"Taiga_beach",
|
||||||
|
"Forest",
|
||||||
|
"Forest_beach",
|
||||||
|
"FlowerForest",
|
||||||
|
"FlowerForest_beach",
|
||||||
|
"BirchForest",
|
||||||
"BirchForestM",
|
"BirchForestM",
|
||||||
"MesaPlateauF",
|
"RoofedForest",
|
||||||
"MesaPlateauFM",
|
"Savanna",
|
||||||
"MesaPlateauF_grasstop",
|
"Savanna_beach",
|
||||||
"MesaBryce",
|
|
||||||
"JungleEdge",
|
|
||||||
"SavannaM",
|
"SavannaM",
|
||||||
|
"Jungle",
|
||||||
|
"Jungle_shore",
|
||||||
|
"JungleM",
|
||||||
|
"JungleM_shore",
|
||||||
|
"JungleEdge",
|
||||||
|
"JungleEdgeM",
|
||||||
|
"Swampland",
|
||||||
|
"Swampland_shore"
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
minetest.LIGHT_MAX+1,
|
minetest.LIGHT_MAX+1,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
--made for MC like Survival game
|
--made for MC like Survival game
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local path = minetest.get_modpath(minetest.get_current_modname())
|
local path = minetest.get_modpath("mobs_mc")
|
||||||
|
|
||||||
if not minetest.get_modpath("mobs_mc_gameconfig") then
|
if not minetest.get_modpath("mobs_mc_gameconfig") then
|
||||||
mobs_mc = {}
|
mobs_mc = {}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
--made for MC like Survival game
|
--made for MC like Survival game
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### IRON GOLEM
|
--################### IRON GOLEM
|
||||||
|
@ -16,11 +16,8 @@ mobs:register_mob("mobs_mc:iron_golem", {
|
||||||
type = "npc",
|
type = "npc",
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
passive = true,
|
passive = true,
|
||||||
rotate = 270,
|
|
||||||
hp_min = 100,
|
hp_min = 100,
|
||||||
hp_max = 100,
|
hp_max = 100,
|
||||||
protect = true,
|
|
||||||
neutral = true,
|
|
||||||
breath_max = -1,
|
breath_max = -1,
|
||||||
collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.69, 0.7},
|
collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.69, 0.7},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
|
@ -43,7 +40,7 @@ mobs:register_mob("mobs_mc:iron_golem", {
|
||||||
reach = 3,
|
reach = 3,
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
attacks_monsters = true,
|
attacks_monsters = true,
|
||||||
attack_type = "punch",
|
attack_type = "dogfight",
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.iron_ingot,
|
{name = mobs_mc.items.iron_ingot,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -158,11 +155,11 @@ mobs_mc.tools.check_iron_golem_summon = function(pos)
|
||||||
if ok then
|
if ok then
|
||||||
-- Remove the nodes
|
-- Remove the nodes
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
minetest.check_for_falling(pos)
|
core.check_for_falling(pos)
|
||||||
for i=1, 4 do
|
for i=1, 4 do
|
||||||
local cpos = vector.add(pos, checks[c][i])
|
local cpos = vector.add(pos, checks[c][i])
|
||||||
minetest.remove_node(cpos)
|
minetest.remove_node(cpos)
|
||||||
minetest.check_for_falling(cpos)
|
core.check_for_falling(cpos)
|
||||||
end
|
end
|
||||||
-- Summon iron golem
|
-- Summon iron golem
|
||||||
local place
|
local place
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### LLAMA
|
--################### LLAMA
|
||||||
|
@ -28,15 +28,6 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
description = S("Llama"),
|
description = S("Llama"),
|
||||||
type = "animal",
|
type = "animal",
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
rotate = 270,
|
|
||||||
neutral = true,
|
|
||||||
group_attack = true,
|
|
||||||
attack_type = "projectile",
|
|
||||||
shoot_arrow = function(self, pos, dir)
|
|
||||||
-- 2-4 damage per arrow
|
|
||||||
local dmg = 1
|
|
||||||
mobs.shoot_projectile_handling("mobs_mc:spit", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
|
|
||||||
end,
|
|
||||||
hp_min = 15,
|
hp_min = 15,
|
||||||
hp_max = 30,
|
hp_max = 30,
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
|
@ -51,7 +42,6 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
{"blank.png", "blank.png", "mobs_mc_llama_gray.png"},
|
{"blank.png", "blank.png", "mobs_mc_llama_gray.png"},
|
||||||
{"blank.png", "blank.png", "mobs_mc_llama_white.png"},
|
{"blank.png", "blank.png", "mobs_mc_llama_white.png"},
|
||||||
{"blank.png", "blank.png", "mobs_mc_llama.png"},
|
{"blank.png", "blank.png", "mobs_mc_llama.png"},
|
||||||
-- TODO: Add llama carpet textures (Pixel Perfection seems to use verbatim copy from Minecraft :-( )
|
|
||||||
},
|
},
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
|
@ -59,11 +49,7 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 4.4,
|
run_velocity = 4.4,
|
||||||
follow_velocity = 4.4,
|
follow_velocity = 4.4,
|
||||||
breed_distance = 1.5,
|
|
||||||
baby_size = 0.5,
|
|
||||||
follow_distance = 2,
|
|
||||||
floats = 1,
|
floats = 1,
|
||||||
reach = 6,
|
|
||||||
drops = {
|
drops = {
|
||||||
{name = mobs_mc.items.leather,
|
{name = mobs_mc.items.leather,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
|
@ -96,7 +82,7 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
look_start = 78,
|
look_start = 78,
|
||||||
look_end = 108,
|
look_end = 108,
|
||||||
},
|
},
|
||||||
follow = mobs_mc.items.hay_bale,
|
follow = mobs_mc.follow.llama,
|
||||||
view_range = 16,
|
view_range = 16,
|
||||||
do_custom = function(self, dtime)
|
do_custom = function(self, dtime)
|
||||||
|
|
||||||
|
@ -139,111 +125,68 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--owner is broken for this
|
local item = clicker:get_wielded_item()
|
||||||
--we'll make the owner this guy
|
if item:get_name() == mobs_mc.items.hay_bale then
|
||||||
--attempt to enter breed state
|
-- Breed with hay bale
|
||||||
if mobs.enter_breed_state(self,clicker) then
|
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
||||||
self.tamed = true
|
else
|
||||||
self.owner = clicker:get_player_name()
|
-- Feed with anything else
|
||||||
return
|
if mobs:feed_tame(self, clicker, 1, false, true) then return end
|
||||||
end
|
end
|
||||||
|
if mobs:protect(self, clicker) then return end
|
||||||
--ignore other logic
|
|
||||||
--make baby grow faster
|
|
||||||
if self.baby then
|
|
||||||
mobs.make_baby_grow_faster(self,clicker)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Make sure tamed llama is mature and being clicked by owner only
|
-- Make sure tamed llama is mature and being clicked by owner only
|
||||||
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
if self.tamed and not self.child and self.owner == clicker:get_player_name() then
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
-- Place carpet
|
||||||
--safety catch
|
if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then
|
||||||
if not item then
|
for group, carpetdata in pairs(carpets) do
|
||||||
return
|
if minetest.get_item_group(item:get_name(), group) == 1 then
|
||||||
end
|
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
||||||
|
item:take_item()
|
||||||
|
clicker:set_wielded_item(item)
|
||||||
|
|
||||||
--put chest on carpeted llama
|
|
||||||
if self.carpet and not self.chest and item:get_name() == "mcl_chests:chest" then
|
|
||||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
|
||||||
item:take_item()
|
|
||||||
clicker:set_wielded_item(item)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.base_texture = table.copy(self.base_texture)
|
|
||||||
self.base_texture[1] = "mobs_mc_llama_chest.png"
|
|
||||||
self.object:set_properties({
|
|
||||||
textures = self.base_texture,
|
|
||||||
})
|
|
||||||
self.chest = true
|
|
||||||
|
|
||||||
return --don't attempt to ride
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Place carpet
|
|
||||||
--TODO: Re-enable this code when carpet textures arrived.
|
|
||||||
if minetest.get_item_group(item:get_name(), "carpet") == 1 then
|
|
||||||
|
|
||||||
for group, carpetdata in pairs(carpets) do
|
|
||||||
if minetest.get_item_group(item:get_name(), group) == 1 then
|
|
||||||
if not minetest.is_creative_enabled(clicker:get_player_name()) then
|
|
||||||
item:take_item()
|
|
||||||
clicker:set_wielded_item(item)
|
|
||||||
|
|
||||||
--shoot off old carpet
|
|
||||||
if self.carpet then
|
|
||||||
minetest.add_item(self.object:get_pos(), self.carpet)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local substr = carpetdata[2]
|
|
||||||
local tex_carpet = "mobs_mc_llama_decor_"..substr..".png"
|
|
||||||
|
|
||||||
self.base_texture = table.copy(self.base_texture)
|
|
||||||
self.base_texture[2] = tex_carpet
|
|
||||||
self.object:set_properties({
|
|
||||||
textures = self.base_texture,
|
|
||||||
})
|
|
||||||
self.carpet = item:get_name()
|
|
||||||
self.drops = {
|
|
||||||
{name = mobs_mc.items.leather,
|
|
||||||
chance = 1,
|
|
||||||
min = 0,
|
|
||||||
max = 2,},
|
|
||||||
{name = item:get_name(),
|
|
||||||
chance = 1,
|
|
||||||
min = 1,
|
|
||||||
max = 1,},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
local substr = carpetdata[2]
|
||||||
|
local tex_carpet = "mobs_mc_llama_decor_"..substr..".png"
|
||||||
|
self.base_texture = table.copy(self.base_texture)
|
||||||
|
self.base_texture[2] = tex_carpet
|
||||||
|
self.object:set_properties({
|
||||||
|
textures = self.base_texture,
|
||||||
|
})
|
||||||
|
self.carpet = item:get_name()
|
||||||
|
self.drops = {
|
||||||
|
{name = mobs_mc.items.leather,
|
||||||
|
chance = 1,
|
||||||
|
min = 0,
|
||||||
|
max = 2,},
|
||||||
|
{name = item:get_name(),
|
||||||
|
chance = 1,
|
||||||
|
min = 1,
|
||||||
|
max = 1,},
|
||||||
|
}
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if self.carpet then
|
-- detatch player already riding llama
|
||||||
-- detatch player already riding llama
|
if self.driver and clicker == self.driver then
|
||||||
if self.driver and clicker == self.driver then
|
|
||||||
|
|
||||||
mobs.detach(clicker, {x = 1, y = 0, z = 1})
|
mobs.detach(clicker, {x = 1, y = 0, z = 1})
|
||||||
|
|
||||||
-- attach player to llama
|
-- attach player to llama
|
||||||
elseif not self.driver then
|
elseif not self.driver then
|
||||||
|
|
||||||
self.object:set_properties({stepheight = 1.1})
|
self.object:set_properties({stepheight = 1.1})
|
||||||
mobs.attach(self, clicker)
|
mobs.attach(self, clicker)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
-- Used to capture llama
|
||||||
|
elseif not self.driver and clicker:get_wielded_item():get_name() ~= "" then
|
||||||
|
mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--[[
|
|
||||||
TODO: Enable this code when carpet textures arrived.
|
|
||||||
on_breed = function(parent1, parent2)
|
on_breed = function(parent1, parent2)
|
||||||
-- When breeding, make sure the child has no carpet
|
-- When breeding, make sure the child has no carpet
|
||||||
local pos = parent1.object:get_pos()
|
local pos = parent1.object:get_pos()
|
||||||
|
@ -265,7 +208,6 @@ mobs:register_mob("mobs_mc:llama", {
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
]]
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -275,12 +217,18 @@ mobs:spawn_specific(
|
||||||
"overworld",
|
"overworld",
|
||||||
"ground",
|
"ground",
|
||||||
{
|
{
|
||||||
"Mesa",
|
"Mesa",
|
||||||
"MesaPlateauFM_grasstop",
|
"MesaPlateauFM_grasstop",
|
||||||
"MesaPlateauF",
|
"MesaPlateauF",
|
||||||
"MesaPlateauFM",
|
"MesaPlateauFM",
|
||||||
"MesaPlateauF_grasstop",
|
"MesaPlateauF_grasstop",
|
||||||
"MesaBryce",
|
"MesaBryce",
|
||||||
|
"Jungle",
|
||||||
|
"Jungle_shore",
|
||||||
|
"JungleM",
|
||||||
|
"JungleM_shore",
|
||||||
|
"JungleEdge",
|
||||||
|
"JungleEdgeM",
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
minetest.LIGHT_MAX+1,
|
minetest.LIGHT_MAX+1,
|
||||||
|
@ -292,38 +240,3 @@ mobs_mc.spawn_height.overworld_max)
|
||||||
|
|
||||||
-- spawn eggs
|
-- spawn eggs
|
||||||
mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)
|
mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)
|
||||||
|
|
||||||
|
|
||||||
-- llama spit
|
|
||||||
mobs:register_arrow("mobs_mc:spit", {
|
|
||||||
visual = "sprite",
|
|
||||||
visual_size = {x = 0.3, y = 0.3},
|
|
||||||
textures = {"mobs_mc_spit.png"},
|
|
||||||
velocity = 1,
|
|
||||||
speed = 1,
|
|
||||||
tail = 1,
|
|
||||||
tail_texture = "mobs_mc_spit.png",
|
|
||||||
tail_size = 2,
|
|
||||||
tail_distance_divider = 4,
|
|
||||||
|
|
||||||
hit_player = function(self, player)
|
|
||||||
--[[if rawget(_G, "armor") and armor.last_damage_types then
|
|
||||||
armor.last_damage_types[player:get_player_name()] = "spit"
|
|
||||||
end]]
|
|
||||||
player:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = self._damage},
|
|
||||||
}, nil)
|
|
||||||
end,
|
|
||||||
|
|
||||||
hit_mob = function(self, mob)
|
|
||||||
mob:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval = 1.0,
|
|
||||||
damage_groups = {fleshy = self._damage},
|
|
||||||
}, nil)
|
|
||||||
end,
|
|
||||||
|
|
||||||
hit_node = function(self, pos, node)
|
|
||||||
--does nothing
|
|
||||||
end
|
|
||||||
})
|
|
|
@ -28,7 +28,6 @@ Pig=Schwein
|
||||||
Polar Bear=Eisbär
|
Polar Bear=Eisbär
|
||||||
Rabbit=Kaninchen
|
Rabbit=Kaninchen
|
||||||
Killer Bunny=Killerkaninchen
|
Killer Bunny=Killerkaninchen
|
||||||
The Killer Bunny=Das Killerkaninchen
|
|
||||||
Sheep=Schaf
|
Sheep=Schaf
|
||||||
Shulker=Shulker
|
Shulker=Shulker
|
||||||
Silverfish=Silberfischchen
|
Silverfish=Silberfischchen
|
||||||
|
|
|
@ -28,7 +28,6 @@ Pig=Cerdo
|
||||||
Polar Bear=Oso polar
|
Polar Bear=Oso polar
|
||||||
Rabbit=Conejo
|
Rabbit=Conejo
|
||||||
Killer Bunny=Conejo asesino
|
Killer Bunny=Conejo asesino
|
||||||
The Killer Bunny=El Conejo asesino
|
|
||||||
Sheep=Oveja
|
Sheep=Oveja
|
||||||
Shulker=Shulker
|
Shulker=Shulker
|
||||||
Silverfish=Lepisma
|
Silverfish=Lepisma
|
||||||
|
|
|
@ -28,7 +28,6 @@ Pig=Cochon
|
||||||
Polar Bear=Ours blanc
|
Polar Bear=Ours blanc
|
||||||
Rabbit=Lapin
|
Rabbit=Lapin
|
||||||
Killer Bunny=Lapin tueur
|
Killer Bunny=Lapin tueur
|
||||||
The Killer Bunny=Le Lapin tueur
|
|
||||||
Sheep=Mouton
|
Sheep=Mouton
|
||||||
Shulker=Shulker
|
Shulker=Shulker
|
||||||
Silverfish=Poisson d'argent
|
Silverfish=Poisson d'argent
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
# textdomain: mobs_mc
|
|
||||||
Totem of Undying=Token nieśmiertelności
|
|
||||||
A totem of undying is a rare artifact which may safe you from certain death.=Totem nieśmiertelności to rzadki artefakt, który może uchronić cię przed pewną śmiercią.
|
|
||||||
The totem only works while you hold it in your hand. If you receive fatal damage, you are saved from death and you get a second chance with 1 HP. The totem is destroyed in the process, however.=Totem działa tylko kiedy trzymasz go w dłoni. Jeśli otrzymasz obrażenia od upadku zostaniesz oszczędzony i pozostanie ci 1 HP, jednak totem zostanie wtedy zniszczony.
|
|
||||||
Agent=Agent
|
|
||||||
Bat=Nietoperz
|
|
||||||
Blaze=Płomyk
|
|
||||||
Chicken=Kurczak
|
|
||||||
Cow=Krowa
|
|
||||||
Mooshroom=Muuuchomor
|
|
||||||
Creeper=Creeper
|
|
||||||
Ender Dragon=Smok kresu
|
|
||||||
Enderman=Enderman
|
|
||||||
Endermite=Endermit
|
|
||||||
Ghast=Ghast
|
|
||||||
Elder Guardian=Prastrażnik
|
|
||||||
Guardian=Strażnik
|
|
||||||
Horse=Koń
|
|
||||||
Skeleton Horse=Koń szkielet
|
|
||||||
Zombie Horse=Koń zombie
|
|
||||||
Donkey=Osioł
|
|
||||||
Mule=Muł
|
|
||||||
Iron Golem=Żelazny golem
|
|
||||||
Llama=Lama
|
|
||||||
Ocelot=Ocelot
|
|
||||||
Parrot=Papuga
|
|
||||||
Pig=Świnia
|
|
||||||
Polar Bear=Niedźwiedź polarny
|
|
||||||
Rabbit=Królik
|
|
||||||
Killer Bunny=Królik zabójca
|
|
||||||
Sheep=Owca
|
|
||||||
Shulker=Shulker
|
|
||||||
Silverfish=Rybik cukrowy
|
|
||||||
Skeleton=Szkielet
|
|
||||||
Stray=Tułacz
|
|
||||||
Wither Skeleton=Witherowy szkielet
|
|
||||||
Magma Cube=Kostka magmy
|
|
||||||
Slime=Szlam
|
|
||||||
Snow Golem=Śnieżny golem
|
|
||||||
Spider=Pająk
|
|
||||||
Cave Spider=Pająk jaskiniowy
|
|
||||||
Squid=Kałamarnica
|
|
||||||
Vex=Dręczyciel
|
|
||||||
Evoker=Przywoływacz
|
|
||||||
Illusioner=Iluzjonista
|
|
||||||
Villager=Osadnik
|
|
||||||
Vindicator=Obrońca
|
|
||||||
Zombie Villager=Osadnik zombie
|
|
||||||
Witch=Wiedźma
|
|
||||||
Wither=Wither
|
|
||||||
Wolf=Wilk
|
|
||||||
Husk=Posuch
|
|
||||||
Zombie=Zombie
|
|
||||||
Zombie Pigman=Świniak zombie
|
|
||||||
Iron Horse Armor=Żelazna zbroja dla konia
|
|
||||||
Iron horse armor can be worn by horses to increase their protection from harm a bit.=Żelazna zbroja dla konia może być noszona przez konie aby nieco zwiększyć ich odporność na obrażenia.
|
|
||||||
Golden Horse Armor=Złota zbroja dla konia
|
|
||||||
Golden horse armor can be worn by horses to increase their protection from harm.=Złota zbroja dla konia może być noszona przez konie aby zwiększyć ich odporność na obrażenia.
|
|
||||||
Diamond Horse Armor=Diamentowa zbroja dla konia
|
|
||||||
Diamond horse armor can be worn by horses to greatly increase their protection from harm.=Diamentowa zbroja dla konia może być noszona przez konie aby istotnie zwiększyć ich odporność na obrażenia.
|
|
||||||
Place it on a horse to put on the horse armor. Donkeys and mules can't wear horse armor.=Połóż ją na koniu aby założyć zbroję dla konia. Osły i muły nie mogą nosić zbroi dla konia.
|
|
||||||
Farmer=Rolnik
|
|
||||||
Fisherman=Rybak
|
|
||||||
Fletcher=Łuczarz
|
|
||||||
Shepherd=Pasterz
|
|
||||||
Librarian=Bibliotekarz
|
|
||||||
Cartographer=Kartograf
|
|
||||||
Armorer=Płatnerz
|
|
||||||
Leatherworker=Rymarz
|
|
||||||
Butcher=Rzeźnik
|
|
||||||
Weapon Smith=Zbrojmistrz
|
|
||||||
Tool Smith=Narzędziarz
|
|
||||||
Cleric=Kapłan
|
|
||||||
Nitwit=Głupiec
|
|
||||||
Protects you from death while wielding it=Chroni przed śmiercią gdy go trzymasz
|
|
|
@ -28,7 +28,6 @@ Pig=Свинья
|
||||||
Polar Bear=Полярный медведь
|
Polar Bear=Полярный медведь
|
||||||
Rabbit=Кролик
|
Rabbit=Кролик
|
||||||
Killer Bunny=Кролик-убийца
|
Killer Bunny=Кролик-убийца
|
||||||
The Killer Bunny=Кролик-убийца
|
|
||||||
Sheep=Овца
|
Sheep=Овца
|
||||||
Shulker=Шалкер
|
Shulker=Шалкер
|
||||||
Silverfish=Чешуйница
|
Silverfish=Чешуйница
|
||||||
|
|
|
@ -28,7 +28,6 @@ Pig=
|
||||||
Polar Bear=
|
Polar Bear=
|
||||||
Rabbit=
|
Rabbit=
|
||||||
Killer Bunny=
|
Killer Bunny=
|
||||||
The Killer Bunny=
|
|
||||||
Sheep=
|
Sheep=
|
||||||
Shulker=
|
Shulker=
|
||||||
Silverfish=
|
Silverfish=
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Ghast fixed by epCode - Thanks!
|
|
Binary file not shown.
|
@ -3,7 +3,7 @@
|
||||||
--made for MC like Survival game
|
--made for MC like Survival game
|
||||||
--License for code WTFPL and otherwise stated in readmes
|
--License for code WTFPL and otherwise stated in readmes
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator("mobs_mc")
|
||||||
|
|
||||||
--###################
|
--###################
|
||||||
--################### OCELOT AND CAT
|
--################### OCELOT AND CAT
|
||||||
|
@ -31,8 +31,6 @@ local ocelot = {
|
||||||
type = "animal",
|
type = "animal",
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
can_despawn = true,
|
can_despawn = true,
|
||||||
rotate = 270,
|
|
||||||
skittish = true,
|
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
|
@ -45,7 +43,7 @@ local ocelot = {
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_chance = default_walk_chance,
|
walk_chance = default_walk_chance,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 10,
|
run_velocity = 3,
|
||||||
follow_velocity = 1,
|
follow_velocity = 1,
|
||||||
floats = 1,
|
floats = 1,
|
||||||
runaway = true,
|
runaway = true,
|
||||||
|
@ -59,7 +57,7 @@ local ocelot = {
|
||||||
},
|
},
|
||||||
animation = {
|
animation = {
|
||||||
speed_normal = 25,
|
speed_normal = 25,
|
||||||
run_speed = 150,
|
run_speed = 50,
|
||||||
stand_start = 0,
|
stand_start = 0,
|
||||||
stand_end = 0,
|
stand_end = 0,
|
||||||
walk_start = 0,
|
walk_start = 0,
|
||||||
|
@ -125,6 +123,8 @@ cat.sounds = {
|
||||||
}
|
}
|
||||||
cat.on_rightclick = function(self, clicker)
|
cat.on_rightclick = function(self, clicker)
|
||||||
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
if mobs:feed_tame(self, clicker, 1, true, false) then return end
|
||||||
|
if mobs:capture_mob(self, clicker, 0, 60, 5, false, nil) then return end
|
||||||
|
if mobs:protect(self, clicker) then return end
|
||||||
|
|
||||||
if self.child then return end
|
if self.child then return end
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ end
|
||||||
|
|
||||||
mobs:register_mob("mobs_mc:cat", cat)
|
mobs:register_mob("mobs_mc:cat", cat)
|
||||||
|
|
||||||
--local base_spawn_chance = 5000
|
local base_spawn_chance = 5000
|
||||||
|
|
||||||
-- Spawn ocelot
|
-- Spawn ocelot
|
||||||
--they get the same as the llama because I'm trying to rework so much of this code right now -j4i
|
--they get the same as the llama because I'm trying to rework so much of this code right now -j4i
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue