game2006/server/gameserver/bornpoint.cc
aozhiwei d907cf5e2f 1
2024-04-17 20:53:18 +08:00

77 lines
2.0 KiB
C++

#include "precompile.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/vec2.hpp>
#include "bornpoint.h"
#include "room.h"
#include "glmhelper.h"
#include "tracemgr.h"
#include "mt/Map.h"
Position BornPoint::RandPoint(Room* room) const
{
Position pos;
if (wo_meta) {
pos.FromGlmVec3(wo_meta->pos);
if (room->IsMobaModeRoom()) {
glm::vec3 dir = GlmHelper::UP;
GlmHelper::RotateY(dir, glm::radians((float)(rand() % 360)));
pos.AddGlmVec3(dir * (float)a8::RandEx(10, 100));
#ifdef MYDEBUG
a8::XPrintf("RandPoint wo_meta:%d pos:%d %d %d\n",
{
(long long)((char*)wo_meta.get()),
pos.GetX(),
pos.GetY(),
pos.GetZ()
});
#endif
}
} else {
pos.SetX(5120.000000000000);
pos.SetY(6.250846862793);
pos.SetZ(5120.000000000000);
}
if (!room->IsMobaModeRoom() && room->IsSandTableRoom()) {
pos.SetX(60 + rand() % ((int)room->GetMapMeta()->map_width() - 100));
pos.SetY(6.250846862793);
pos.SetZ(60 + rand() % ((int)room->GetMapMeta()->map_height() - 100));
}
return pos;
}
int BornPoint::GetNum()
{
return 4;
}
Position BornPoint::GetSrcPoint(Room* room) const
{
Position pos;
if (wo_meta) {
pos.FromGlmVec3(wo_meta->pos);
} else {
pos.SetX(5120.000000000000);
pos.SetY(6.250846862793);
pos.SetZ(5120.000000000000);
}
return pos;
}
Position BornPoint::NewRandPoint(Room* room, int min_radius, int max_radius) const
{
Position pos;
if (wo_meta) {
pos.FromGlmVec3(wo_meta->pos);
glm::vec3 dir = GlmHelper::UP;
GlmHelper::RotateY(dir, glm::radians((float)(rand() % 360)));
pos.AddGlmVec3(dir * (float)a8::RandEx(min_radius, max_radius));
} else {
A8_ABORT();
}
return pos;
}