Added EntitySpeed
This commit is contained in:
parent
5a8610c2f4
commit
064c25caa1
@ -20,5 +20,3 @@ function core.parse_relative_pos(param)
|
||||
if success then pos = vector.round(vector.add(core.localplayer:get_pos(), pos)) end
|
||||
return success, pos
|
||||
end
|
||||
|
||||
core.anticheat_protection = minetest.settings:get_bool("anticheat_protection") ~= false
|
||||
|
@ -2251,9 +2251,6 @@ hud_flags_bypass (HUDBypass) bool true
|
||||
|
||||
antiknockback (AntiKnockback) bool false
|
||||
|
||||
# Set to true if AntiCheat is enabled on server
|
||||
anticheat_protection (AnticheatProtection) bool true
|
||||
|
||||
autorespawn (AutoRespawn) bool false
|
||||
|
||||
show_cheat_hud (CheatHUD) bool true
|
||||
|
@ -45,10 +45,7 @@ minetest.register_chatcommand("deletewarp", {
|
||||
func = warp.delete,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("warp", {
|
||||
params = "<pos>|<warp>",
|
||||
description = "Warp to a set warp or a position. " .. (core.anticheat_protection and "You have to be attached for this to work (sitting in a boat or similar) and you will be disconnected and have to rejoin." or ""),
|
||||
func = function(param)
|
||||
local function do_warp(param)
|
||||
if param == "" then return false, "Missing parameter." end
|
||||
local success, pos = minetest.parse_pos(param)
|
||||
if not success then
|
||||
@ -59,11 +56,23 @@ minetest.register_chatcommand("warp", {
|
||||
end
|
||||
end
|
||||
minetest.localplayer:set_pos(pos)
|
||||
if core.anticheat_protection then
|
||||
minetest.disconnect()
|
||||
end
|
||||
return true, "Warped to " .. minetest.pos_to_string(pos)
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("warp", {
|
||||
params = "<pos>|<warp>",
|
||||
description = "Warp to a set warp or a position.",
|
||||
func = do_warp
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("warpandexit", {
|
||||
params = "<pos>|<warp>",
|
||||
description = "Warp to a set warp or a position and exit.",
|
||||
func = function(param)
|
||||
local s, m = do_warp(param)
|
||||
if s then
|
||||
minetest.disconnect()
|
||||
end
|
||||
return s,m
|
||||
end
|
||||
})
|
||||
|
@ -1290,7 +1290,7 @@ void Client::sendReady()
|
||||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Client::sendPlayerPos()
|
||||
void Client::sendPlayerPos(v3f pos)
|
||||
{
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
if (!player)
|
||||
@ -1308,7 +1308,7 @@ void Client::sendPlayerPos()
|
||||
// return;
|
||||
|
||||
if (
|
||||
player->last_position == player->getPosition() &&
|
||||
player->last_position == pos &&
|
||||
player->last_speed == player->getSpeed() &&
|
||||
player->last_pitch == player->getPitch() &&
|
||||
player->last_yaw == player->getYaw() &&
|
||||
@ -1317,7 +1317,7 @@ void Client::sendPlayerPos()
|
||||
player->last_wanted_range == wanted_range)
|
||||
return;
|
||||
|
||||
player->last_position = player->getPosition();
|
||||
player->last_position = pos;
|
||||
player->last_speed = player->getSpeed();
|
||||
player->last_pitch = player->getPitch();
|
||||
player->last_yaw = player->getYaw();
|
||||
@ -1332,6 +1332,14 @@ void Client::sendPlayerPos()
|
||||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Client::sendPlayerPos()
|
||||
{
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
if (!player)
|
||||
return;
|
||||
sendPlayerPos(player->getPosition());
|
||||
}
|
||||
|
||||
void Client::removeNode(v3s16 p)
|
||||
{
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
|
@ -437,6 +437,7 @@ public:
|
||||
return m_env.getLocalPlayer()->formspec_prepend;
|
||||
}
|
||||
|
||||
void sendPlayerPos(v3f pos);
|
||||
void sendPlayerPos();
|
||||
MeshUpdateThread m_mesh_update_thread;
|
||||
|
||||
|
@ -472,13 +472,14 @@ void GenericCAO::setAttachment(int parent_id, const std::string &bone, v3f posit
|
||||
ClientActiveObject *parent = m_env->getActiveObject(parent_id);
|
||||
|
||||
if (parent_id != old_parent) {
|
||||
if (old_parent)
|
||||
m_waiting_for_reattach = 10;
|
||||
if (auto *o = m_env->getActiveObject(old_parent))
|
||||
o->removeAttachmentChild(m_id);
|
||||
if (parent)
|
||||
parent->addAttachmentChild(m_id);
|
||||
}
|
||||
|
||||
|
||||
updateAttachments();
|
||||
}
|
||||
|
||||
|
@ -224,6 +224,7 @@ public:
|
||||
void addAttachmentChild(int child_id);
|
||||
void removeAttachmentChild(int child_id);
|
||||
ClientActiveObject *getParent() const;
|
||||
int getParentId() const { return m_attachment_parent_id; }
|
||||
const std::unordered_set<int> &getAttachmentChildIds() const
|
||||
{ return m_attachment_child_ids; }
|
||||
void updateAttachments();
|
||||
@ -275,4 +276,6 @@ public:
|
||||
{
|
||||
return m_prop.infotext;
|
||||
}
|
||||
|
||||
float m_waiting_for_reattach;
|
||||
};
|
||||
|
@ -2417,26 +2417,8 @@ PointedThing Game::updatePointedThing(
|
||||
ClientMap &map = env.getClientMap();
|
||||
const NodeDefManager *nodedef = map.getNodeDefManager();
|
||||
|
||||
if (g_settings->getBool("killaura")) {
|
||||
std::vector<DistanceSortedActiveObject> allObjects;
|
||||
env.getActiveObjects(shootline.start, shootline.getLength() + 10.0f, allObjects);
|
||||
const v3f line_vector = shootline.getVector();
|
||||
for (const auto &allObject : allObjects) {
|
||||
ClientActiveObject *obj = allObject.obj;
|
||||
s16 id = obj->getId();
|
||||
v3f pos = obj->getPosition();
|
||||
v3f intersection;
|
||||
v3s16 normal;
|
||||
aabb3f selection_box;
|
||||
if (! obj->getSelectionBox(&selection_box))
|
||||
continue;
|
||||
aabb3f offsetted_box(selection_box.MinEdge + pos, selection_box.MaxEdge + pos);
|
||||
boxLineCollision(offsetted_box, shootline.start, line_vector, &intersection, &normal);
|
||||
PointedThing pointed(id, intersection, normal, (intersection - shootline.start).getLengthSQ());
|
||||
client->interact(INTERACT_START_DIGGING, pointed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (g_settings->getBool("killaura"))
|
||||
handleKillaura(shootline.start, shootline.getLength());
|
||||
|
||||
runData.selected_object = NULL;
|
||||
hud->pointing_at_object = false;
|
||||
@ -2514,6 +2496,22 @@ PointedThing Game::updatePointedThing(
|
||||
return result;
|
||||
}
|
||||
|
||||
void Game::handleKillaura(v3f origin, f32 max_d)
|
||||
{
|
||||
ClientEnvironment &env = client->getEnv();
|
||||
std::vector<DistanceSortedActiveObject> allObjects;
|
||||
env.getActiveObjects(origin, max_d, allObjects);
|
||||
for (const auto &allObject : allObjects) {
|
||||
ClientActiveObject *obj = allObject.obj;
|
||||
s16 id = obj->getId();
|
||||
aabb3f selection_box;
|
||||
if (! obj->getSelectionBox(&selection_box))
|
||||
continue;
|
||||
PointedThing pointed(id, v3f(0,0,0), v3s16(0,0,0), 0);
|
||||
client->interact(INTERACT_START_DIGGING, pointed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Game::handlePointingAtNothing(const ItemStack &playerItem)
|
||||
{
|
||||
|
@ -771,6 +771,7 @@ public:
|
||||
PointedThing updatePointedThing(
|
||||
const core::line3d<f32> &shootline, bool liquids_pointable,
|
||||
bool look_for_object, const v3s16 &camera_offset);
|
||||
void handleKillaura(v3f origin, f32 max_d);
|
||||
void handlePointingAtNothing(const ItemStack &playerItem);
|
||||
void handlePointingAtNode(const PointedThing &pointed,
|
||||
const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
|
||||
|
@ -27,6 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "map.h"
|
||||
#include "client.h"
|
||||
#include "content_cao.h"
|
||||
#include "util/pointedthing.h"
|
||||
#include "client/game.h"
|
||||
|
||||
/*
|
||||
LocalPlayer
|
||||
@ -168,6 +170,9 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position,
|
||||
void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||
std::vector<CollisionInfo> *collision_info)
|
||||
{
|
||||
if (m_cao && m_cao->m_waiting_for_reattach > 0)
|
||||
m_cao->m_waiting_for_reattach -= dtime;
|
||||
|
||||
// Node at feet position, update each ClientEnvironment::step()
|
||||
if (!collision_info || collision_info->empty())
|
||||
m_standing_node = floatToInt(m_position, BS);
|
||||
@ -712,7 +717,7 @@ v3f LocalPlayer::getEyeOffset() const
|
||||
|
||||
ClientActiveObject *LocalPlayer::getParent() const
|
||||
{
|
||||
return m_cao ? m_cao->getParent() : nullptr;
|
||||
return (m_cao && ! g_settings->getBool("entity_speed")) ? m_cao->getParent() : nullptr;
|
||||
}
|
||||
|
||||
bool LocalPlayer::isDead() const
|
||||
@ -721,6 +726,18 @@ bool LocalPlayer::isDead() const
|
||||
return !getCAO()->isImmortal() && hp == 0;
|
||||
}
|
||||
|
||||
void LocalPlayer::tryReattach(int id)
|
||||
{
|
||||
PointedThing pointed(id, v3f(0, 0, 0), v3s16(0, 0, 0), 0);
|
||||
m_client->interact(INTERACT_PLACE, pointed);
|
||||
m_cao->m_waiting_for_reattach = 10;
|
||||
}
|
||||
|
||||
bool LocalPlayer::isWaitingForReattach() const
|
||||
{
|
||||
return g_settings->getBool("entity_speed") && m_cao && ! m_cao->getParent() && m_cao->m_waiting_for_reattach > 0;
|
||||
}
|
||||
|
||||
// 3D acceleration
|
||||
void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H,
|
||||
const f32 max_increase_V, const bool use_pitch)
|
||||
|
@ -158,6 +158,10 @@ public:
|
||||
added_velocity += vel;
|
||||
}
|
||||
|
||||
void tryReattach(int id);
|
||||
|
||||
bool isWaitingForReattach() const;
|
||||
|
||||
private:
|
||||
void accelerate(const v3f &target_speed, const f32 max_increase_H,
|
||||
const f32 max_increase_V, const bool use_pitch);
|
||||
|
@ -76,6 +76,7 @@ void set_default_settings(Settings *settings)
|
||||
settings->setDefault("increase_tool_range", "true");
|
||||
settings->setDefault("hud_flags_bypass", "true");
|
||||
settings->setDefault("antiknockback", "false");
|
||||
settings->setDefault("entity_speed", "false");
|
||||
|
||||
// Keymap
|
||||
settings->setDefault("remote_port", "30000");
|
||||
|
@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "server.h"
|
||||
#include "util/strfnd.h"
|
||||
#include "client/clientevent.h"
|
||||
#include "client/content_cao.h"
|
||||
#include "client/sound.h"
|
||||
#include "network/clientopcodes.h"
|
||||
#include "network/connection.h"
|
||||
@ -449,6 +450,9 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt)
|
||||
}
|
||||
*/
|
||||
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
bool try_reattach = player && player->isWaitingForReattach();
|
||||
|
||||
try {
|
||||
u8 type;
|
||||
u16 removed_count, added_count, id;
|
||||
@ -467,6 +471,8 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt)
|
||||
for (u16 i = 0; i < added_count; i++) {
|
||||
*pkt >> id >> type;
|
||||
m_env.addActiveObject(id, type, pkt->readLongString());
|
||||
if (try_reattach)
|
||||
player->tryReattach(id);
|
||||
}
|
||||
} catch (PacketError &e) {
|
||||
infostream << "handleCommand_ActiveObjectRemoveAdd: " << e.what()
|
||||
@ -593,6 +599,9 @@ void Client::handleCommand_MovePlayer(NetworkPacket* pkt)
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
assert(player != NULL);
|
||||
|
||||
if ((player->getCAO() && player->getCAO()->getParentId()) || player->isWaitingForReattach())
|
||||
return;
|
||||
|
||||
v3f pos;
|
||||
f32 pitch, yaw;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user