当前位置: 首页>>代码示例>>C++>>正文


C++ Monster::addToRoom方法代码示例

本文整理汇总了C++中Monster::addToRoom方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::addToRoom方法的具体用法?C++ Monster::addToRoom怎么用?C++ Monster::addToRoom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monster的用法示例。


在下文中一共展示了Monster::addToRoom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doFlee

bool Creature::doFlee(bool magicTerror) {
    Monster* mThis = getAsMonster();
    Player* pThis = getAsPlayer();
    BaseRoom* oldRoom = getRoomParent(), *newRoom=0;
    UniqueRoom* uRoom=0;

    Exit*   exit=0;
    unsigned int n=0;

    if(isEffected("fear"))
        magicTerror = true;

    exit = getFleeableExit();
    if(!exit) {
        printColor("You couldn't find any place to run to!\n");
        if(pThis)
            pThis->setFleeing(false);
        return(0);
    }

    newRoom = getFleeableRoom(exit);
    if(!newRoom) {
        printColor("You failed to escape!\n");
        return(0);
    }


    switch(mrand(1,10)) {
    case 1:
        print("You run like a chicken.\n");
        break;
    case 2:
        print("You flee in terror.\n");
        break;
    case 3:
        print("You run screaming in horror.\n");
        break;
    case 4:
        print("You flee aimlessly in any direction you can.\n");
        break;
    case 5:
        print("You run screaming for your mommy.\n");
        break;
    case 6:
        print("You run as your life flashes before your eyes.\n");
        break;
    case 7:
        print("Your heart throbs as you attempt to escape death.\n");
        break;
    case 8:
        print("Colors and sounds mingle as you frantically flee.\n");
        break;
    case 9:
        print("Fear of death grips you as you flee in panic.\n");
        break;
    case 10:
        print("You run like a coward.\n");
        break;
    default:
        print("You run like a chicken.\n");
        break;
    }


    broadcast(getSock(), oldRoom, "%M flees to the %s^x.", this, exit->getCName());
    if(mThis) {
        mThis->diePermCrt();
        if(exit->doEffectDamage(this))
            return(2);
        mThis->deleteFromRoom();
        mThis->addToRoom(newRoom);
    } else if(pThis) {
        pThis->dropWeapons();
        pThis->checkDarkness();
        unhide();

        if(magicTerror)
            printColor("^rYou flee from unnatural fear!\n");

        Move::track(getUniqueRoomParent(), &currentLocation.mapmarker, exit, pThis, false);

        if(pThis->flagIsSet(P_ALIASING)) {
            pThis->getAlias()->deleteFromRoom();
            pThis->getAlias()->addToRoom(newRoom);
        }

        Move::update(pThis);
        pThis->statistics.flee();

        if(cClass == CreatureClass::PALADIN && deity != GRADIUS && !magicTerror && level >= 10) {
            n = level * 8;
            n = MIN<long>(experience, n);
            print("You lose %d experience for your cowardly retreat.\n", n);
            experience -= n;
        }

        if(exit->doEffectDamage(this))
            return(2);
        pThis->deleteFromRoom();
        pThis->addToRoom(newRoom);
//.........这里部分代码省略.........
开发者ID:RealmsMud,项目名称:RealmsCode,代码行数:101,代码来源:creature.cpp


注:本文中的Monster::addToRoom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。