Ejemplo n.º 1
0
void CSimpleEnemy::setupInternal() {
	switch (m_eEnemyType) {
	case ET_GREEN_SWORD:
		createTool(CPlayerTool::TOOL_SWORD, true);
		createShield(CShield::ST_SIMPLE_SHIELD, true);
		setCurAndMaxHP(HP_ONE_HEART);
		m_bSwordsDrawn = true;
		break;
    case ET_BLOCKER:
		createTool(CPlayerTool::TOOL_SWORD, true);
		createShield(CShield::ST_SIMPLE_SHIELD, true);
		m_bSwordsDrawn = true;
		animStartBlock();
		setCurAndMaxHP(HP_INFINITY);
		dynamic_cast<CSimpleEnemyController*>(m_pCharacterController)->stun();
		m_uiTakeDamageFlags = CDamage::DMG_NONE;
		break;
	}
}
Ejemplo n.º 2
0
BaseTool *
BaseToolBox::getTool(QString toolName)
{
    BaseTool* tool = m_tools[toolName];

    if (!tool) tool = createTool(toolName);

    connect(tool, SIGNAL(showContextHelp(QString)),
            this, SIGNAL(showContextHelp(QString)));

    return tool;
}
Ejemplo n.º 3
0
/* returns 1 if shop successfully created, 0 o/w */
int
shMapLevel::makeShop (int sx, int sy, int ex, int ey, int kind)
{
    int x, y;
    int dx = -1, gx = -1;
    int dy = -1, gy = -1;
    shFeature *f;
    shFeature *door = NULL;
    shMonster *clerk;
    int roomid = mSquares[sx][sy].mRoomId;

    /* Find the door (we only make shops in rooms with exactly one door). */
    for (x = sx + 1; x < ex; x++) {
        f = getFeature (x, sy);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = x;
            dy = sy;
        }
        f = getFeature (x, ey);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = x;
            dy = ey;
        }
    }
    for (y = sy + 1; y < ey; y++) {
        f = getFeature (sx, y);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = sx;
            dy = y;
        }
        f = getFeature (ex, y);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = ex;
            dy = y;
        }
    }

    if (!door)  return 0;  /* What?! There are no doors to this room? */

    /* Make sure door is a normal automatic door. */
    door->mType = shFeature::kDoorClosed;
    door->mDoor.mFlags = shFeature::kAutomatic;

    /* First row or column from the door shall be empty. */
    if (dx == sx) {
        sx++; dx++; gx = sx;
    } else if (dx == ex) {
        ex--; dx--; gx = ex;
    }
    if (dy == sy) {
        sy++; dy++; gy = sy;
    } else if (dy == ey) {
        ey--; dy--; gy = ey;
    }

    if (-1 == kind) { /* Randomly determine kind of shop. */
        switch (RNG (20)) {
        case 0: case 1: case 2: case 3: case 4:
        case 5: case 6: case 7:
            kind = shRoom::kGeneralStore; break;
        case 8: case 9: case 10:
            kind = shRoom::kHardwareStore; break;
        case 11: case 12: case 13:
            kind = shRoom::kSoftwareStore; break;
        case 14: case 15:
            kind = shRoom::kArmorStore; break;
        case 16: case 17:
            kind = shRoom::kWeaponStore; break;
        case 18:
            kind = shRoom::kImplantStore; break;
        case 19:
            kind = shRoom::kCanisterStore; break;
        }
    }

    bool infested = !RNG (25); /* Full of cockroaches. */

    for (x = sx + 1; x < ex; x++) { /* Get us some stuff to sell. */
        for (y = sy + 1; y < ey; y++) {
            shObject *obj = NULL;

            switch (kind) {
            case shRoom::kGeneralStore:
                obj = generateObject (-1); break;
            case shRoom::kHardwareStore:
                obj = createTool (); break;
            case shRoom::kSoftwareStore:
                if (RNG (8)) {
                    obj = createFloppyDisk ();
                } else {
                    obj = pickFromCategory (kObjGenericComputer);
                } break;
            case shRoom::kArmorStore:
                obj = createArmor (); break;
            case shRoom::kWeaponStore:
                if (RNG (20)) {
                    obj = createWeapon ();
                } else {
                    obj = createRayGun ();
                } break;
            case shRoom::kImplantStore:
                obj = createImplant (); break;
            case shRoom::kCanisterStore:
                obj = createCanister (); break;
            }
            obj->setUnpaid ();
            putObject (obj, x, y);

            if (infested and /* Put one under every big enough item. */
                obj->myIlk ()->mSize > MonIlks[kMonGiantCockroach].mSize)
            {
                shCreature *cockroach = new shMonster (kMonGiantCockroach);
                putCreature (cockroach, x, y);
            }
        }
    }

    /* The shopkeeper droid. */
    clerk = new shMonster (kMonClerkbot);
    putCreature (clerk, dx, dy);
    clerk->mShopKeeper.mHomeX = dx;
    clerk->mShopKeeper.mHomeY = dy;
    clerk->mShopKeeper.mShopId = roomid;
    clerk->mShopKeeper.mBill = 0;

    /* Shops may have a guard. */
    bool guarded = false;
    if (mDLevel > 4 and (!RNG (3) or mDLevel > TOWNLEVEL) and !isTownLevel ()) {
        shMonster *guard = NULL;
        shMonId guardtype[3] = {kMonSecuritron, kMonWarbot, kMonGuardbot};
        guard = new shMonster (guardtype [RNG (3)]);
        if (guard) { /* Pick a nice warm spot in a corner. */
            if (gx == -1) {
                gx = (sx+1 == dx) ? ex-1 :
                     (ex-1 == dx) ? sx+1 :
                          RNG (2) ? sx+1 : ex-1;
            } else {
                gy = (sy+1 == dy) ? ey-1 :
                     (ey-1 == dy) ? sy+1 :
                          RNG (2) ? sy+1 : ey-1;
            }
            if (!putCreature (guard, gx, gy)) {
                guard->mStrategy = shMonster::kGuard;
                guard->mDisposition = shMonster::kIndifferent;
                guard->mGuard.mToll = -1;
                guarded = true;
            }
        }
    }

    mRooms[roomid].mType = (shRoom::Type) kind;
    mFlags |= kHasShop;
    debug.log ("made %s%sshop on level %d.",
        guarded ? "guarded " : "", infested ? "infested " : "", mDLevel);
    return 1;
}