diff --git a/NOTES.md b/NOTES.md new file mode 100644 index 0000000..0fe4dd4 --- /dev/null +++ b/NOTES.md @@ -0,0 +1,65 @@ + + + + +### Fiel of view for monsters vs characters + +From https://forum.minetest.net/viewtopic.php?p=182737#p182737 + +If it helps any, here is the in_fov code from mobs redo mod that works (self is mob, pos is player position and self.fov is set to 90, self.rotate is usually 0 for front facing mobs): +CODE: SELECT ALL + +``` +in_fov = function(self,pos) + -- checks if POS is in self's FOV + local yaw = self.object:getyaw() + self.rotate + local vx = math.sin(yaw) + local vz = math.cos(yaw) + local ds = math.sqrt(vx^2 + vz^2) + local ps = math.sqrt(pos.x^2 + pos.z^2) + local d = { x = vx / ds, z = vz / ds } + local p = { x = pos.x / ps, z = pos.z / ps } + local an = ( d.x * p.x ) + ( d.z * p.z ) + + a = math.deg( math.acos( an ) ) +``` + +Thank you everyone, especially TeTpaAka and Nore. All problems were at last solved, and the code now reports the angle difference between entities like it should! You get 0* when standing right in front of the mob, 90* when standing parallel to either side, 180* when standing behind... whereas flying up or down now accounts pitch correctly on top of that. + +Here is the final and fully functional version. I hope it will be helpful to more people than just me, if anyone ever needs a simple and efficient FOV scanner for Minetest. + +``` +local function in_fov (pos1, pos2, yaw, pitch, fov) + local function yaw2vec (yaw, pitch) + -- we must invert the yaw for x to keep the result from inverting when facing opposite directions (0* becoming 180*) + return {x = math.sin(-yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)} + end + + local function dotproduct (v1, v2) + return ((v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)) + end + + local function angle (v1, v2) + return math.deg(math.acos(dotproduct(v1, v2) / (vector.length(v1) * vector.length(v2)))) + end + + local v = vector.subtract(pos2, pos1) + print(angle(yaw2vec(yaw, pitch), v)) +end +``` + +here is the final version of the function which I'll be including in my mod, simplified to only 5 lines of code but with the same result: +CODE: SELECT ALL + +``` +-- returns the angle difference between pos1 and pos2, as seen from pos1 at the specified yaw and pitch +function pos_to_angle (pos1, pos2, yaw, pitch) + -- note: we must invert the yaw for x in yaw_vec, to keep the result from inverting when facing opposite directions (0* becoming 180*) + local yaw_vec = {x = -math.sin(yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)} + local pos_subtract = vector.subtract(pos2, pos1) + local pos_dotproduct = (yaw_vec.x * pos_subtract.x) + (yaw_vec.y * pos_subtract.y) + (yaw_vec.z * pos_subtract.z) + local angle = math.deg(math.acos(pos_dotproduct / (vector.length(yaw_vec) * vector.length(pos_subtract)))) + return angle +end +``` + diff --git a/README.md b/README.md new file mode 100644 index 0000000..641b79a --- /dev/null +++ b/README.md @@ -0,0 +1,112 @@ +Adventuretest game for the Minetest game engine +========================================================== + +To play this game in Minetest, insert this repository as + /games/adventuretest +in the Minetest Engine. + +The Minetest Engine that can play this game can be found at +https://minetest.io/ or just build your version using the minenux branch +at https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0 + +![screenshot.png](screenshot.png) + +INFORMATION +----------- + +The game has a RPG spirit, but not limit to, its focused in +singleplayer, but also works for multiplayer too, creative and +damage are mutually exclusive settings. + +#### Quests + +The game have "quests" that any player can do, some have rewards +others just provide rare things, + +A common rquest is Right click on any of the ladies in the village +with black hair to receive your quest. + +#### Crafting guides + +Build in in the lifesaver button, There is a crafting guide, +of the inventory. also once in the game type `/m` and press +enter and you will get a crafting guide, equipping armor form +and changing skin form. + +### Know issues + +If yu got crash, somethigns you game get slow for movement, in singleplayer, +the character suddently stop and if you tryto move, keep moving until +a block just stop it. +To solve, go into your world directory and delete the affects.txt +and physics file. This happens sometimes when there is a crash. + + +Adventuretest License +------------------------------------------ +Copyright (C) 2013-2014 Brandon Bohannon + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +License of default mods source code +----------------------------------- +Copyright (C) 2010-2012 celeron55, Perttu Ahola +See README.txt in each mod directory for information about other authors. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +License of media (models, textures and sounds) +-------------------------------------- +Copyright (C) 2010-2012 celeron55, Perttu Ahola +See README.txt in each mod directory for information about other authors. + +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) +http://creativecommons.org/licenses/by-sa/3.0/ + +License of menu/header.png +Copyright (C) 2013 BlockMen CC BY-3.0 + +License of Spider model +Copyright (C) 2013 AspireMint CC BY-SA + +goblins_goblin.b3d and goblins_goblin.blend +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) by FreeLikeGNU +http://creativecommons.org/licenses/by-sa/3.0/ + +above meshes based on character from minetest_game +MirceaKitsune (WTFPL) +https://github.com/minetest/minetest_game/blob/master/mods/default/README.txt#L71 + +goblins_goblins*.png files and goblins_goblin.xcf file by FreeLikeGNU +Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) FreeLikeGNU +http://creativecommons.org/licenses/by-sa/3.0/ + +Thanks to Napiophelios for the goblin king skin +https://forum.minetest.net/viewtopic.php?f=9&t=13004#p186921 +goblins_goblin_king.png +License: Creative Commons CC-BY-SA-3.0 SummerFeilds TP + diff --git a/README.txt b/README.txt index 5235cf9..641b79a 100644 --- a/README.txt +++ b/README.txt @@ -5,8 +5,42 @@ To play this game in Minetest, insert this repository as /games/adventuretest in the Minetest Engine. -The Minetest Engine can be found in: - https://github.com/minetest/minetest/ +The Minetest Engine that can play this game can be found at +https://minetest.io/ or just build your version using the minenux branch +at https://codeberg.org/minenux/minetest-engine-minetest/src/branch/stable-4.0 + +![screenshot.png](screenshot.png) + +INFORMATION +----------- + +The game has a RPG spirit, but not limit to, its focused in +singleplayer, but also works for multiplayer too, creative and +damage are mutually exclusive settings. + +#### Quests + +The game have "quests" that any player can do, some have rewards +others just provide rare things, + +A common rquest is Right click on any of the ladies in the village +with black hair to receive your quest. + +#### Crafting guides + +Build in in the lifesaver button, There is a crafting guide, +of the inventory. also once in the game type `/m` and press +enter and you will get a crafting guide, equipping armor form +and changing skin form. + +### Know issues + +If yu got crash, somethigns you game get slow for movement, in singleplayer, +the character suddently stop and if you tryto move, keep moving until +a block just stop it. +To solve, go into your world directory and delete the affects.txt +and physics file. This happens sometimes when there is a crash. + Adventuretest License ------------------------------------------ diff --git a/game.conf b/game.conf index 5010175..e6122a6 100644 --- a/game.conf +++ b/game.conf @@ -1 +1,8 @@ -name = Adventuretest +title = adventuretest +name = adventuretest +author = bremaweb +description = Adventure RPG-hard game for the Minetest game engine +release = 20181212 +min_minetest_version = 0.4.14 +max_minetest_version = 4.99 +disabled_settings = creative_mode, !enable_damage diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..7d30873 Binary files /dev/null and b/screenshot.png differ