28 lines
837 B
C++
28 lines
837 B
C++
#include "precompile.h"
|
|
|
|
#include "cs_proto.pb.h"
|
|
|
|
#include "bornpoint.h"
|
|
#include "metamgr.h"
|
|
|
|
a8::Vec2 BornPoint::RandPoint() const
|
|
{
|
|
a8::Vec2 born_point = a8::Vec2(thing_tpl->i->x(), thing_tpl->i->y());
|
|
MetaData::Player* hum_meta = MetaMgr::Instance()->GetPlayer(40002);
|
|
if (hum_meta) {
|
|
born_point.x -= thing_tpl->i->width() / 2;
|
|
born_point.y -= thing_tpl->i->height() / 2;
|
|
born_point.x += hum_meta->i->radius() / 2;
|
|
born_point.y += hum_meta->i->radius() / 2;
|
|
int rand_x = thing_tpl->i->width() - hum_meta->i->radius();
|
|
int rand_y = thing_tpl->i->height() - hum_meta->i->radius();
|
|
if (rand_x > 0) {
|
|
born_point.x += rand() % rand_x;
|
|
}
|
|
if (rand_y > 0) {
|
|
born_point.y += rand() % rand_y;
|
|
}
|
|
}
|
|
return born_point;
|
|
}
|