Exemple #1
0
ItemLookAt ScriptItem::getLookAt(Character *character) const {
    auto script = Data::CommonItems.script(getId());

    if (script && script->existsEntrypoint("LookAtItem")) {
        ItemLookAt lookAt = script->LookAtItem(character, *this);

        if (lookAt.isValid()) {
            return lookAt;
        }
    }

    return lookAtItemScript->lookAtItem(character, *this);
}
bool LuaMonsterScript::setTarget(Character *Monster, const std::vector<Player *> &CandidateList, Player *&Target) {
    Target = 0;

    if (!existsEntrypoint("setTarget")) {
        return false;
    }

    luabind::object luaCandidateList = luabind::newtable(_luaState);
    int index = 1;

    for (const auto &player : CandidateList) {
        character_ptr fuse_it(player);
        luaCandidateList[index++] = fuse_it;
    }

    character_ptr fuse_Monster(Monster);
    index = callEntrypoint<int>("setTarget", fuse_Monster, luaCandidateList) - 1;

    if (index >= 0 && index < (int)CandidateList.size()) {
        Target = CandidateList[index];
    }

    return true;
}