Пример #1
0
int splRemoveSilence(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;

    if(cmnd->num == 2) {
        target = player;
        if(spellData->how == CastType::POTION && player->isEffected("silence") && !player->flagIsSet(P_DM_SILENCED))
            player->print("You can speak again.\n");
        else {
            player->print("Nothing happens.\n");
            return(0);
        }

    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);

        if(!target) {
            player->print("That's not here.\n");
            return(0);
        }

        if(checkRefusingMagic(player, target))
            return(0);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
            player->print("You cast remove-silence on %N.\n", target);
            broadcast(player->getSock(), target->getSock(), player->getParent(),
                "%M casts remove-silence on %N.", player, target);

            logCast(player, target, "remove-silence");
            if(target->isPlayer()) {
                target->print("%M casts remove-silence on you.\n", player);
                if( (target->flagIsSet(P_DM_SILENCED) && player->isCt()) ||
                     !target->flagIsSet(P_DM_SILENCED)
                )
                    target->print("You can speak again.\n");
                else
                    target->print("Nothing happens.\n");
            }
        }
    }
    if(target->inCombat(false))
        player->smashInvis();

    target->removeEffect("silence");

    if(player->isCt() && target->isPlayer())
        target->clearFlag(P_DM_SILENCED);

    return(1);
}
Пример #2
0
int splRemoveFear(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;

    if(cmnd->num == 2) {
        target = player;

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {

            player->print("You cast remove-fear on yourself.\n");
            if(player->isEffected("fear"))
                player->print("You feel brave again.\n");
            else
                player->print("Nothing happens.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts remove-fear on %sself.", player, player->himHer());
        } else if(spellData->how == CastType::POTION && player->isEffected("fear"))
            player->print("You feel brave again.\n");
        else if(spellData->how == CastType::POTION)
            player->print("Nothing happens.\n");

    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);
        if(!target) {
            player->print("That's not here.\n");
            return(0);
        }


        if(checkRefusingMagic(player, target))
            return(0);


        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
            player->print("You cast remove-fear on %N.\n", target);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts remove-fear on %N.", player, target);
            if(target->isPlayer()) {
                target->print("%M casts remove-fear on you.\n", player);
                if(target->isEffected("fear"))
                    target->print("You feel brave again.\n");
                else
                    player->print("Nothing happens.\n");
            }
        }
    }
    if(target->inCombat(false))
        player->smashInvis();

    target->removeEffect("fear", true, false);
    return(1);
}
Пример #3
0
bool canCastHealing(Creature* player, Creature* target, bool rej=false, bool healSpell=false, bool print=true) {
    if(!healCombatCheck(player, target, print))
        return(false);

    if(target->isEffected("petrification")) {
        if(print)
            player->print("Your %s magic is ineffective.\n", rej ? "healing" : "rejuvinating");
        return(false);
    }

    // for a lich, a heal spell is offensive magic
    if(target->getClass() == CreatureClass::LICH && healSpell)
        return(true);

    if(target->getClass() == CreatureClass::LICH) {
        if(print)
            player->print("The aura of death around %N nullifies your %s magic.\n", target, rej ? "healing" : "rejuvinating");
        return(false);
    }
    if(!rej && target->isEffected("stoneskin")) {
        // don't check this for liches
        if(print)
            player->print("%M's stoneskin spell reflects your %s magic.\n", target, rej ? "healing" : "rejuvinating");
        return(false);
    }

    if(checkRefusingMagic(player, target, true, print))
        return(false);

    if(!rej && target->hp.getCur() >= target->hp.getMax()) {
        if(print)
            player->print("%M is at full health right now.\n", target);
        return(false);
    }
    return(true);
}
Пример #4
0
int doRes(Creature* caster, cmd* cmnd, bool res) {
    // if ress=false, it's a bloodfusion
    Player  *player = caster->getAsPlayer();
    int     prevLevel=0;
    bool    full=false;
    long    t=0;
    Player *target=0;
    BaseRoom *newRoom=0;

    if(player && !player->isDm()) {
        if(player->getNegativeLevels()) {
            player->print("You cannot do that without your full life essence.\n");
            return(0);
        }
        if(player->mp.getCur() < player->mp.getMax()) {
            player->print("You must have full MP to cast that spell.\n");
            return(0);
        }
    } else {
        // a DM can set to a 100% restore instead of 80%
        if(cmnd->num == 4 && !strcasecmp(cmnd->str[3], "-full"))
            full = true;
    }


    if(cmnd->num < 2) {
        caster->print("%s?\n", res ? "Resurrect whom" : "Fuse whom with new blood");
        return(0);
    }

    cmnd->str[2][0] = up(cmnd->str[2][0]);
    target = gServer->findPlayer(cmnd->str[2]);
    if(!target) {
        caster->print("That player is not online.\n");
        return(0);
    }

    if(target->isDm() && target->flagIsSet(P_DM_INVIS) && !caster->isDm()) {
        caster->print("That player is not online.\n");
        return(0);
    }

    if(target->isStaff()) {
        caster->print("Staff characters do not need to be %s.\n",
            res ? "resurrected" : "fused with blood");
        return(0);
    }

    if(checkRefusingMagic(caster, target))
        return(0);

    if(Move::tooFarAway(caster, target, res ? "resurrect" : "fuse with new blood"))
        return(0);

    if(res) {
        if(target->isUndead()) {
            caster->print("Undead players cannot be resurrected.\n");
            return(0);
        }
    } else {
        if(!target->isUndead()) {
            caster->print("Only undead players can be fused with new blood.\n");
            return(0);
        }
    }


    if(!caster->isDm()) {
        if(target->getLocation() != target->getLimboRoom()) {
            caster->print("%s is not in limbo! How can you %s %s?\n",
                target->getCName(), res ? "resurrect" : "bloodfuse", target->himHer());
            return(0);
        }
        if(target->getLevel() < 7) {
            caster->print("%s is not yet powerful enough to be %s.\n",
                target->getCName(), res ? "resurrected" : "fused with blood");
            return(0);
        }
        if(!target->flagIsSet(P_KILLED_BY_MOB)) {
            caster->print("%s does not need to be %s.\n", target->getCName(), res ? "resurrected" : "fused with new blood");
            return(0);
        }
    }

    if(target == caster) {
        caster->print("You cannot %s.\n", res ? "resurrect yourself" : "fuse yourself with new blood");
        return(0);
    }

    if(player && !player->isDm() && player->daily[DL_RESURRECT].cur == 0) {
        player->print("You have done that enough times for today.\n");
        return(0);
    }

    if(!caster->isDm() && target->daily[DL_RESURRECT].cur == 0) {
        caster->print("Players can only be %s once per 24 hours real time.\n", res ? "resurrected" : "fused with new blood");
        return(0);
    }


    caster->print("You cast a %s spell on %N.\n", res ? "resurrection" : "bloodfusion", target);

    prevLevel = target->getLevel();
    long expGain = full ? (target->statistics.getLastExperienceLoss()*4/5) : (target->statistics.getLastExperienceLoss());

    EffectInfo *effect = target->getEffect("death-sickness");
    if(effect) {
        if(full)
            target->removeEffect("death-sickness");
        else
            effect->setDuration(effect->getDuration() / 3);
    }

    target->cureDisease();
    target->curePoison();
    target->removeEffect("hold-person");
    target->removeEffect("petrification");
    target->removeEffect("confusion");
    target->removeEffect("drunkenness");

    target->clearFlag(P_KILLED_BY_MOB);
    target->setTickDamage(0);

    if(player)
        dec_daily(&player->daily[DL_RESURRECT]);
    dec_daily(&target->daily[DL_RESURRECT]);


    broadcast(caster->getSock(), caster->getRoomParent(), "%M casts a %s spell on %N.", caster, res ? "resurrection" : "bloodfusion", target);

    logn("log.resurrect", "%s(L:%d) %s %s(L%d:%d) %s.\n", caster->getCName(), caster->getLevel(),
        res ? "resurrected" : "fused", target->getCName(), prevLevel, target->getLevel(),
        res ? "from the dead" : "with new blood");

    if(res)
        broadcast("^R### %M just resurrected %s from the dead!", caster, target->getCName());
    else
        broadcast("^R### %M just fused %s with new blood!", caster, target->getCName());


    if(player && !player->isDm()) {
        t = time(0);
        caster->setFlag(P_NO_TICK_MP);
        // caster cannot tick MP for 20 mins online time
        caster->lasttime[LT_NOMPTICK].ltime = t;
        caster->lasttime[LT_NOMPTICK].interval = 120L;

        broadcast(caster->getSock(), caster->getRoomParent(), "%M collapses from exhaustion.", caster);
        caster->print("You collapse from exhaustion.\n");
        caster->knockUnconscious(120);

        caster->mp.setCur(0);
    }

    newRoom = target->getRecallRoom().loadRoom(target);
    if(newRoom) {
        target->deleteFromRoom();
        target->addToRoom(newRoom);
        target->doPetFollow();
    }

    target->print("You have been %s!\n", res ? "resurrected from the dead" : "fused with new blood");


    // Gain back 80% of lost experience

    target->addExperience(expGain);
    // See if we need to relevel
    target->checkLevel();

    target->hp.restore();
    target->mp.restore();
    target->pp.restore();

    target->computeAttackPower();
    target->computeAC();

    target->clearAsEnemy();
    target->save(true);
    updateRecentActivity();
    return(1);
}
Пример #5
0
int splFreeAction(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;
    Player  *pTarget=0;
    long    t = time(0);

    if(spellData->how != CastType::POTION && !player->isCt() && player->getClass() !=  CreatureClass::DRUID && player->getClass() !=  CreatureClass::CLERIC) {
        player->print("Your class is unable to cast that spell.\n");
        return(0);
    }


    if(cmnd->num == 2) {
        target = player;

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
            player->print("Free-action spell cast.\nYou can now move freely.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts a free-action spell on %sself.", player, player->himHer());
        } else if(spellData->how == CastType::POTION)
            player->print("You can now move freely.\n");

    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);

        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);

        if(!target || (target && target->isMonster())) {
            player->print("You don't see that person here.\n");
            return(0);
        }

        if(checkRefusingMagic(player, target))
            return(0);

        player->print("Free-action cast on %s.\n", target->getCName());
        target->print("%M casts a free-action spell on you.\n%s", player, "You can now move freely.\n");
        broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a free-action spell on %N.",player, target);
    }

    pTarget = target->getAsPlayer();

    if(pTarget) {
        pTarget->setFlag(P_FREE_ACTION);

        pTarget->lasttime[LT_FREE_ACTION].ltime = t;
        if(spellData->how == CastType::CAST) {
            pTarget->lasttime[LT_FREE_ACTION].interval = MAX(300, 900 +
                bonus((int) player->intelligence.getCur()) * 300);

            if(player->getRoomParent()->magicBonus()) {
                pTarget->print("The room's magical properties increase the power of your spell.\n");
                pTarget->lasttime[LT_FREE_ACTION].interval += 300L;
            }
        } else
            pTarget->lasttime[LT_FREE_ACTION].interval = 600;

        pTarget->clearFlag(P_STUNNED);
        pTarget->removeEffect("hold-person");
        pTarget->removeEffect("slow");

        pTarget->computeAC();
        pTarget->computeAttackPower();
    }
    return(1);
}
Пример #6
0
				atapi_xfermod = 0;
			}

//          printf( "atapi_r: atapi_xferlen=%d\n", atapi_xferlen );
			if( atapi_xferlen != 0 )
			{
				atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
				gdrom_alt_status = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
				atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
			}
			else
			{
				//mame_printf_debug("ATAPI: dropping DRQ\n");
				atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
				gdrom_alt_status = 0;
				atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
			}

			atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff;
			atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff;

			gdrom_raise_irq(machine);
		}

		if( atapi_data_ptr < atapi_data_len )
		{
			data = atapi_data[atapi_data_ptr++];
			data |= ( atapi_data[atapi_data_ptr++] << 8 );
			if( atapi_data_ptr >= atapi_data_len )
			{
//              printf( "atapi_r: read all bytes\n" );
				atapi_data_ptr = 0;
				atapi_data_len = 0;

				if( atapi_xferlen == 0 )
				{
					atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
					gdrom_alt_status = 0;
					atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
					gdrom_raise_irq(machine);
				}
			}
		}
		else
		{
			data = 0;
		}
	}
	else
	{
		reg = offset;

		// get read-only side of read-only/write-only registers from elsewhere
		if (reg == ATAPI_REG_FEATURES)
		{
			reg = ATAPI_REG_ERROR;
		}
		data = atapi_regs[reg];

		#if 0
		switch( reg )
		{
		case ATAPI_REG_DATA:
			printf( "atapi_r: data=%02x\n", data );
			break;
		case ATAPI_REG_ERROR:
			printf( "atapi_r: error=%02x\n", data );
			break;
		case ATAPI_REG_INTREASON:
			printf( "atapi_r: intreason=%02x\n", data );
			break;
		case ATAPI_REG_SAMTAG:
			printf( "atapi_r: samtag=%02x\n", data );
			break;
		case ATAPI_REG_COUNTLOW:
			printf( "atapi_r: countlow=%02x\n", data );
			break;
		case ATAPI_REG_COUNTHIGH:
			printf( "atapi_r: counthigh=%02x\n", data );
			break;
		case ATAPI_REG_DRIVESEL:
			printf( "atapi_r: drivesel=%02x\n", data );
			break;
		case ATAPI_REG_CMDSTATUS:
			printf( "atapi_r: cmdstatus=%02x\n", data );
			break;
		}
		#endif

		mame_printf_debug("ATAPI: read reg %d = %x (PC=%x)\n", reg, data, space.device().safe_pc());
	}

//  printf( "atapi_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
	return data;
}

static WRITE32_HANDLER( atapi_w )
{
	running_machine &machine = space.machine();
	int reg;

//  printf( "atapi_w( %08x, %08x, %08x )\n", offset, mem_mask, data );

	if (mem_mask == 0x0000ffff)	// word-wide command write
	{
//      printf("atapi_w: data=%04x\n", data );

//      printf("ATAPI: packet write %04x\n", data);
		atapi_data[atapi_data_ptr++] = data & 0xff;
		atapi_data[atapi_data_ptr++] = data >> 8;

		if (atapi_cdata_wait)
		{
//                  printf("ATAPI: waiting, ptr %d wait %d\n", atapi_data_ptr, atapi_cdata_wait);
			if (atapi_data_ptr == atapi_cdata_wait)
			{
				// send it to the device
				gdrom->WriteData( atapi_data, atapi_cdata_wait );

				// assert IRQ
				gdrom_raise_irq(machine);

				// not sure here, but clear DRQ at least?
				atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
			}
		}

		else if ( atapi_data_ptr == 12 )
		{
			int phase;

//          printf("atapi_w: command %02x\n", atapi_data[0]&0xff );

			// reset data pointer for reading SCSI results
			atapi_data_ptr = 0;
			atapi_data_len = 0;

			// send it to the SCSI device
			gdrom->SetCommand( atapi_data, 12 );
			gdrom->ExecCommand( &atapi_xferlen );
			gdrom->GetPhase( &phase );

			if (atapi_xferlen != -1)
			{
				printf("ATAPI: SCSI command %02x returned %d bytes from the device\n", atapi_data[0]&0xff, atapi_xferlen);

				// store the returned command length in the ATAPI regs, splitting into
Пример #7
0
int genericResist(Creature* player, cmd* cmnd, SpellData* spellData, Realm realm) {
    Creature* target=0;
    Player* pTarget=0;

    //int       lt = getRealmSpellLT(realm);
    bstring name = getRealmSpellName(realm);

    bstring effect = "resist-" + name;

    if(cmnd->num == 2) {
        target = player;
        pTarget = player->getAsPlayer();
        broadcast(player->getSock(), player->getParent(), "%M casts resist-%s.", player, name.c_str());

        if(spellData->how == CastType::CAST) {
            player->print("You cast a resist-%s spell.\n", name.c_str());
        }
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findPlayer(player, cmnd, 2);

        if(!target || !target->getAsPlayer()) {
            player->print("You don't see that player here.\n");
            return(0);
        }

        if(checkRefusingMagic(player, target))
            return(0);

        broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a resist-%s spell on %N.", player, name.c_str(), target);
        target->print("%M casts resist-%s on you.\n", player, name.c_str());

        if(spellData->how == CastType::CAST) {
            player->print("You cast a resist-%s spell on %N.\n", name.c_str(), target);

            if(player->getRoomParent()->magicBonus()) {
                player->print("The room's magical properties increase the power of your spell.\n");
            }
        } else {
            player->print("%M resists %s.\n", target, name.c_str());
        }
    }

    if(target->hasPermEffect(effect))  {
        player->print("The spell didn't take hold.\n");
        return(0);
    }


    if(spellData->how == CastType::CAST) {
        if(player->getRoomParent()->magicBonus()) {
            player->print("The room's magical properties increase the power of your spell.\n");
        }
        target->addEffect(effect, -2, -2, player, true, player);

    } else {
        target->addEffect(effect);
    }
    if(pTarget)
        pTarget->checkOppositeResistSpell(effect);

    return(1);
}