74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
#include "precompile.h"
|
|
#include "global.h"
|
|
|
|
int g_hint_flags = 0;
|
|
|
|
int Global::g_nowtime = time(nullptr);
|
|
ColliderComponent* Global::last_collider = nullptr;
|
|
|
|
bool IsValidSlotId(int slot_id)
|
|
{
|
|
return slot_id >= 0 && slot_id < IS_END;
|
|
}
|
|
|
|
bool IsValidBuffEffect(int buff_effect)
|
|
{
|
|
return buff_effect > kBET_Begin && buff_effect < (kBET_End + 10);
|
|
}
|
|
|
|
bool IsValidHumanAttr(int attr_type)
|
|
{
|
|
return attr_type > kHAT_Begin && attr_type < kHAT_End;
|
|
}
|
|
|
|
bool IsValidCondBuff(int cond)
|
|
{
|
|
return cond >= 0 && cond < kCondBuffEnd;
|
|
}
|
|
|
|
bool IsValidWeaponOpt(int opt)
|
|
{
|
|
return opt >= 0 && opt < kWeaponOptEnd;
|
|
}
|
|
|
|
bool IsValidBuffOpt(int opt)
|
|
{
|
|
return opt >= 0 && opt < kBuffOptEnd;
|
|
}
|
|
|
|
float GetAttrAbsFromXObject(std::shared_ptr<a8::XObject> obj, int attr_id)
|
|
{
|
|
if (obj->IsArray()) {
|
|
for (int i = 0; i < obj->Size(); ++i) {
|
|
auto attr = obj->At(i);
|
|
if (attr->IsObject()){
|
|
int tmp_attr_id = attr->Get("attr_id", 0);
|
|
int tmp_type = attr->Get("type", 0);
|
|
int tmp_val = attr->Get("val", 0);
|
|
if (tmp_attr_id == attr_id && tmp_type == 1) {
|
|
return tmp_val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
float GetAttrRateFromXObject(std::shared_ptr<a8::XObject> obj,int attr_id)
|
|
{
|
|
if (obj->IsArray()) {
|
|
for (int i = 0; i < obj->Size(); ++i) {
|
|
auto attr = obj->At(i);
|
|
if (attr->IsObject()){
|
|
int tmp_attr_id = attr->Get("attr_id", 0);
|
|
int tmp_type = attr->Get("type", 0);
|
|
int tmp_val = attr->Get("val", 0);
|
|
if (tmp_attr_id == attr_id && tmp_type == 2) {
|
|
return tmp_val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|