コード例 #1
0
ファイル: Forge.cpp プロジェクト: justinabrahms/avendar
AFFECT_DATA * Forge::FindNameEffect(const CHAR_DATA & ch)
{
    for (AFFECT_DATA * paf(get_affect(&ch, gsn_forgeweapon)); paf != NULL; paf = get_affect(&ch, gsn_forgeweapon, paf))
    {
        if (paf->location == APPLY_HIDE)
            return paf;
    }

    return NULL;
}
コード例 #2
0
bool spell_causticblast(int sn, int level, CHAR_DATA * ch, void * vo, int target)
{
    CHAR_DATA *victim = (CHAR_DATA *) vo;
    int dam(dice(level, 4));

    // Blast them
    act("$n unleashes a blast of hissing acid upon $N!", ch, NULL, victim, TO_NOTVICT);
    act("You unleash a blast of hissing acid upon $N!", ch, NULL, victim, TO_CHAR);
    act("$n unleashes a blast of hissing acid upon you!", ch, NULL, victim, TO_VICT);
    
    if (saves_spell(level, ch, victim, DAM_ACID))
    {
        damage_old(ch, victim, dam / 2, sn, DAM_ACID, true);
        return true;
    }

    damage_old(ch, victim, dam, sn, DAM_ACID, true);
    if (!IS_VALID(victim) || victim->in_room != ch->in_room)
        return true;

    act("The acid eats away at you, leaving painful, ugly scars!", victim, NULL, NULL, TO_CHAR);
    act("The acid eats away at $m, leaving painful, ugly scars!", victim, NULL, NULL, TO_ROOM);
    
    // Apply -charisma
    AFFECT_DATA af = {0};
    af.where    = TO_AFFECTS;
    af.type     = sn;
    af.level    = level;
    af.duration = level / 2;
    af.location = APPLY_CHR;
    af.modifier = -1;
    affect_to_char(victim, &af);

    // Apply burning
    for (AFFECT_DATA * paf(get_affect(victim, sn)); paf != NULL; paf = get_affect(victim, sn, paf))
    {
        if (paf->location == APPLY_NONE)
        {
            paf->duration = UMAX(2, paf->duration);
            paf->modifier = UMIN(100, paf->modifier + 1);
            return true;
        }
    }

    af.duration = 2;
    af.location = APPLY_NONE;
    af.modifier = 1;
    affect_to_char(victim, &af);
    return true;
}
コード例 #3
0
ファイル: Drakes.cpp プロジェクト: justinabrahms/avendar
int Drakes::SpecialCount(CHAR_DATA & drake, Special special)
{
    // Verify that this is a drake
    if (!IS_NPC(&drake) || drake.pIndexData->vnum != MOB_VNUM_DRAKE)
        return 0;

    // Find the wakened stone effect
    AFFECT_DATA * paf(get_affect(&drake, gsn_wakenedstone));
    if (paf == NULL)
        return 0;

    // Get the stone type from the effect and look up the info
    const Info * info(Lookup(paf->modifier));
    if (info == NULL)
    {
        bug("Failed to find stone in Drakes::SpecialCount [%d]", paf->modifier);
        return 0;
    }

    // Run down the specials, tallying them up
    int total(0);
    for (size_t i(0); i < info->specials.size(); ++i)
    {
        if (info->specials[i].type == special && info->specials[i].age <= paf->level)
            total += info->specials[i].amount;
    }

    return total;
}
コード例 #4
0
ファイル: Weave.cpp プロジェクト: justinabrahms/avendar
void Weave::UpdateAttunementsFor(CHAR_DATA & ch, int count)
{
    // Determine the modifier from the count
    static const int BaseValue = 15;
    int modifier(0);
  
    // Only allow non-zero modifiers if the skill is actually possessed
    if (get_skill(&ch, gsn_attunefount) > 0)
    {
        if (count > BaseValue)
        {
            // Anything over 15 founts is only worth a single point
            modifier = (count - BaseValue);
            count = BaseValue;
        }

        // This is a reduced formula using summations so it may not be clear what is going on:
        // Basically, the first fount is worth 2 * BaseValue, the next is worth 2 * (BaseValue - 1), the next 2 * (BaseValue - 2), and so on, until eventually they are worth exactly 1 each
        // So for BV = 15, the values are 30, 28, 26, 24, ..., 6, 4, 2, 1, 1, 1, ...
        modifier += (2 * ((BaseValue * count) - ((count * (count - 1)) / 2)));
    }

    // Compare the new modifier to the existing to see whether there is any change
    int prevModifier(0);
    AFFECT_DATA * paf(get_affect(&ch, gsn_attunefount));
    if (paf != NULL) prevModifier = paf->modifier;
    if (prevModifier == modifier)
        return;

    // Character needs a change; strip any existing effect and add the new one if appropriate
    affect_strip(&ch, gsn_attunefount);
    if (modifier == 0)
        send_to_char("You feel the last of your attunements leave you.\n", &ch);
    else
    {
        // Prepare the effect
        AFFECT_DATA af = {0};
        af.where    = TO_AFFECTS;
        af.type     = gsn_attunefount;
        af.duration = -1;
        af.modifier = modifier;
        af.location = APPLY_HIT;
        affect_to_char(&ch, &af);
    
        af.location = APPLY_MANA;
        affect_to_char(&ch, &af);

        // Adjust for gains (ignore losses)
        if (prevModifier < modifier)
        {
            ch.hit += (modifier - prevModifier);
            ch.mana += (modifier - prevModifier);
        }

        // Send an echo
        send_to_char("You feel the power of your attunements shift.\n", &ch);
    }
}
コード例 #5
0
ファイル: commands.cpp プロジェクト: stefanludlow/shadows2011
void
show_to_watchers (CHAR_DATA * ch, char *command)
{
	CHAR_DATA *tch;
	AFFECTED_TYPE *af;
	char buf[MAX_STRING_LENGTH];

	if ((af = get_affect (ch, MAGIC_WATCH1)))
	{
		if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t))
			affect_remove (ch, af);
		else
		{
			tch = (CHAR_DATA *) af->a.spell.t;
			sprintf (buf, "%s:  %s\n", GET_NAME (ch), command);
			send_to_char (buf, tch);
		}
	}

	if ((af = get_affect (ch, MAGIC_WATCH2)))
	{
		if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t))
			affect_remove (ch, af);
		else
		{
			tch = (CHAR_DATA *) af->a.spell.t;
			sprintf (buf, "%s:  %s\n", GET_NAME (ch), command);
			send_to_char (buf, tch);
		}
	}

	if ((af = get_affect (ch, MAGIC_WATCH3)))
	{
		if (!is_he_somewhere ((CHAR_DATA *) af->a.spell.t))
			affect_remove (ch, af);
		else
		{
			tch = (CHAR_DATA *) af->a.spell.t;
			sprintf (buf, "%s:  %s\n", GET_NAME (ch), command);
			send_to_char (buf, tch);
		}
	}
}
コード例 #6
0
ファイル: Drakes.cpp プロジェクト: justinabrahms/avendar
bool Drakes::IsMinimumAge(const CHAR_DATA & drake, Age age)
{
    // Verify that this is a drake
    if (!IS_NPC(&drake) || drake.pIndexData->vnum == MOB_VNUM_DRAKE)
        return false;

    // Find the wakened stone effect
    AFFECT_DATA * paf(get_affect(&drake, gsn_wakenedstone));
    if (paf == NULL)
        return false;

    // Check the age
    return (paf->level >= age);
}
コード例 #7
0
void handle_waterwheel_crystal_destroyed(CHAR_DATA & ch, OBJ_DATA & obj)
{
    // Look for the effect
    AFFECT_DATA * paf(get_obj_affect(&obj, gsn_constructwaterwheel));
    if (paf == NULL)
        return;

    // Echoes
    act("As you destroy $p, a surge of energy rushes from it and into you!", &ch, &obj, NULL, TO_CHAR);
    act("As $n destroys $p, a flash of blue light shines out from it, focused on $m!", &ch, &obj, NULL, TO_ROOM);

    // Strip the effect from the char if present
    for (AFFECT_DATA * waf(get_affect(&ch, gsn_constructwaterwheel)); waf != NULL; waf = get_affect(&ch, gsn_constructwaterwheel, waf))
    {
        if (waf->location == APPLY_MANA)
        {
            affect_remove(&ch, waf);
            break;
        }
    }

    // Determine modifier
    int modifier(paf->duration);
    if (number_percent() <= get_skill(&ch, gsn_stonecraft))
        check_improve(&ch, NULL, gsn_stonecraft, true, 4);
    else
    {
        check_improve(&ch, NULL, gsn_stonecraft, false, 4);
        modifier /= 2;
    }

    // Grant the new effect
    AFFECT_DATA af = {0};
    af.where    = TO_AFFECTS;
    af.type     = gsn_constructwaterwheel;
    af.level    = paf->level;
    af.modifier = UMAX(1, modifier);
    af.duration = af.modifier;
    af.location = APPLY_MANA;
    affect_to_char(&ch, &af);
}
コード例 #8
0
ファイル: Forge.cpp プロジェクト: justinabrahms/avendar
void Forge::CreateWeapon(CHAR_DATA & ch, const char * argument)
{
    // Perform basic skill check
    int skill(get_skill(&ch, gsn_forgeweapon));
    if (skill <= 0)
    {
        send_to_char("Huh?\n", &ch);
        return;
    }

    // Check for cooldown
    for (AFFECT_DATA * paf(get_affect(&ch, gsn_forgeweapon)); paf != NULL; paf = get_affect(&ch, gsn_forgeweapon, paf))
    {
        if (paf->point == NULL && paf->location == APPLY_NONE)
        {
            send_to_char("You are not ready for the trying process of forging another weapon just yet.\n", &ch);
            return;
        }
    }

    // Check for naming
    AFFECT_DATA * nameAff(FindNameEffect(ch));
    if (nameAff != NULL)
    {
        OBJ_DATA * nameObj(FindNameableObject(ch, *nameAff));
        if (nameObj != NULL)
        {
            act("You must first confer a true Name upon $p.", &ch, nameObj, NULL, TO_CHAR);
            return;
        }
        
        // No longer has the obj, so just clean up the effect and move on
        affect_remove(&ch, nameAff);
    }

    // Get the weapon type name
    char arg[MAX_INPUT_LENGTH];
    argument = one_argument(argument, arg);
    if (arg[0] == '\0')
    {
        send_to_char("Which type of weapon did you wish to forge?\n", &ch);
        return;
    }

    // Begin building the context, starting with the weapon type
    std::auto_ptr<ForgeContext> context(new ForgeContext);
    context->skill = skill;
    context->weaponInfo = LookupWeapon(arg);
    if (context->weaponInfo == NULL)
    {
        send_to_char("You do not know how to make weapons of that type.\n", &ch);
        return;
    }

    // Check for mana
    int manaCost(skill_table[gsn_forgeweapon].min_mana);
    if (ch.mana < manaCost)
    {
        send_to_char("You are too weary to forge a weapon right now.\n", &ch);
        return;
    }

    // Get the first object
    std::vector<OBJ_DATA*> baseObjects;
    if (!ObtainBaseObject(*context, baseObjects, ch, argument))
        return;

    // Check for an alloy
    argument = one_argument(argument, arg);
    if (arg[0] != '\0' && !str_prefix(arg, "alloy"))
    {
        if (!ObtainBaseObject(*context, baseObjects, ch, argument))
            return;

        argument = one_argument(argument, arg);
    }

    // Check for name
    if (arg[0] != '\0' && !str_prefix(arg, "name"))
    {
        // Verify max mana
        if (ch.max_mana < NamingManaCost)
        {
            send_to_char("You lack the will to speak a true Name.\n", &ch);
            return;
        }

        // Verify lava forge
        if (ch.in_room == NULL || !room_is_affected(ch.in_room, gsn_lavaforge))
        {
            send_to_char("You may only confer a true Name from the heat of the earth itself, at a lava forge.\n", &ch);
            return;
        }

        context->named = true;
        argument = one_argument(argument, arg);
    }

    // Check for superfluous arguments
    if (arg[0] != '\0')
    {
        send_to_char("Syntax: forgeweapon <type> <base_object> [alloy <base_object>] [name]\n", &ch);
        return;
    }

    // Check for sufficient weight
    if (context->weight < context->weaponInfo->minWeight)
    {
        std::ostringstream mess;
        mess << "Forging a " << context->weaponInfo->name << " requires more raw material than that!\n";
        send_to_char(mess.str().c_str(), &ch);
        return;
    }

    // Build object list to help with echoes
    std::ostringstream objMess;
    objMess << baseObjects[0]->short_descr;
    for (size_t i(1); (i + 1) < baseObjects.size(); ++i)
        objMess << ", " << baseObjects[i]->short_descr;

    if (baseObjects.size() > 1)
        objMess << " and " << baseObjects[baseObjects.size() - 1]->short_descr;

    std::string objList(objMess.str());

    // Perform initial echoes
    std::ostringstream mess;
    mess << "With a blast of heat and flame, you render down " << objList << " into a liquid mass of metal.";
    act(mess.str().c_str(), &ch, NULL, NULL, TO_CHAR);

    mess.str("");
    mess << "With a blast of heat and flame, $n renders down " << objList << " into a liquid mass of metal.";
    act(mess.str().c_str(), &ch, NULL, NULL, TO_ROOM);

    // Destroy the objects
    for (size_t i(0); i < baseObjects.size(); ++i)
        extract_obj(baseObjects[i]);

    // Set up the echo affect callbacks
    struct CallbackHandler
    {
        static bool HandleMove(CHAR_DATA * ch, ROOM_INDEX_DATA *, EchoAffect *, void * tag)
        {
            HandleCancel(ch, tag);
            return true;
        }

        static bool HandlePositionChange(CHAR_DATA * ch, int newPos, EchoAffect *, void * tag)
        {
            HandleCancel(ch, tag);
            return true;
        }

        static bool HandleCast(CHAR_DATA * ch, int, int, void *, int, EchoAffect *, void * tag)
        {
            HandleCancel(ch, tag);
            return true;
        }

        static bool CheckFailure(CHAR_DATA * ch, EchoAffect *, void * tag)
        {
            // Check for skill
            ForgeContext * context(static_cast<ForgeContext*>(tag));
            if (number_percent() <= context->skill)
            {    
                check_improve(ch, NULL, gsn_forgeweapon, true, 6);
                return false;
            }

            // Failed; increase the flaw count
            ++context->flaws;
            if (number_percent() <= context->flaws * 25)
            {
                // Fatal error
                act("You lose focus on your work, destroying it completely!", ch, NULL, NULL, TO_CHAR);
                act("$n loses focus on $s work, destroying it completely!", ch, NULL, NULL, TO_ROOM);
                check_improve(ch, NULL, gsn_forgeweapon, false, 6);
                delete context;
                return true;
            }

            // Non-fatal error
            act("You make a small error while folding the metal, introducing a slight flaw into the weapon.", ch, NULL, NULL, TO_CHAR);
            check_improve(ch, NULL, gsn_forgeweapon, false, 6);
            return false;
        }

        static bool Finish(CHAR_DATA * ch, EchoAffect *, void * tag)
        {
            std::auto_ptr<ForgeContext> context(static_cast<ForgeContext*>(tag));
            CompleteWeapon(*ch, *context);
            return false;
        }

        private:
            static void HandleCancel(CHAR_DATA * ch, void * tag)
            {
                std::auto_ptr<ForgeContext> context(static_cast<ForgeContext*>(tag));
                send_to_char("You abandon your efforts at the forge, letting the partially-worked metal run away to uselessness.\n", ch);
                act("$n abandons $s efforts at the forge, allowing the partially-worked metal to run away uselessly.", ch, NULL, NULL, TO_ROOM);
            }
    };

    // Prepare the echoAffect
    EchoAffect * echoAff(new EchoAffect(1));
    echoAff->SetPositionCallback(&CallbackHandler::HandlePositionChange);
    echoAff->SetMoveCallback(&CallbackHandler::HandleMove);
    echoAff->SetCastCallback(&CallbackHandler::HandleCast);

    // Add in lines
    echoAff->AddLine(&CallbackHandler::CheckFailure,
                    "Working the mass carefully, you begin to shape the metal.",
                    "Working the mass carefully, $n begins to shape the metal.");

    mess.str("");
    mess << "As you fold the metal over itself time and again, it starts to take on the distinctive shape of a ";
    mess << context->weaponInfo->name << ".";

    std::ostringstream omess;
    omess << "As $n folds the metal over itself time and again, it starts to take on the distinctive shape of a ";
    omess << context->weaponInfo->name << ".";

    echoAff->AddLine(&CallbackHandler::CheckFailure, mess.str().c_str(), omess.str().c_str());
    echoAff->AddLine(&CallbackHandler::CheckFailure,
                    "Molding the weapon with magic and skill, you bring your work near completion.",
                    "Molding the weapon with magic and skill, $n brings $s work near completion.");

    echoAff->AddLine(&CallbackHandler::Finish, "");

    // Finish applying the effect
    echoAff->SetTag(context.release());
    EchoAffect::ApplyToChar(&ch, echoAff);

    // Apply a cooldown
    AFFECT_DATA af = {0};
    af.where    = TO_AFFECTS;
    af.type     = gsn_forgeweapon;
    af.location = APPLY_NONE;
    af.duration = 60;
    af.level    = ch.level;
    affect_to_char(&ch, &af);

    // Charge mana and lag
    expend_mana(&ch, manaCost);
    WAIT_STATE(&ch, skill_table[gsn_forgeweapon].beats);
}
コード例 #9
0
ファイル: commands.cpp プロジェクト: stefanludlow/shadows2011
void
command_interpreter (CHAR_DATA * ch, char *argument)
{
	char buf[MAX_STRING_LENGTH];
	char *command_args, *p, *social_args;
	int cmd_level = 0;
	int i = 0, echo = 1;
	AFFECTED_TYPE *craft_affect = NULL;
	AFFECTED_TYPE *af;
	ALIAS_DATA *alias;
	extern int second_affect_active;

	if (!ch)
		return;

	*buf = '\0';

	p = argument;

	while (*p == ' ')
		p++;

	if (strchr (p, '%'))
	{
		send_to_char ("Input with the '%' character is not permitted.\n", ch);
		return;
	}

	if (strchr (p, '#') && IS_MORTAL (ch) && strncmp (p, "ge", 2) != 0
		&& strncmp (p, "buy", 3) != 0)
	{
		send_to_char ("Input with the '#' character is not permitted.\n", ch);
		return;
	}

	if (IS_MORTAL (ch) && strchr (p, '$'))
	{
		send_to_char ("Input with the '$' character is not permitted.\n", ch);
		return;
	}

	std::multimap<int, room_prog>::iterator it;
	if (IS_NPC(ch))
		it = mob_prog_list.find(ch->mob->nVirtual); 
	if (IS_NPC(ch) && !get_second_affect (ch, SA_DOANYWAY, 0) && it != mob_prog_list.end())
	{
		if (m_prog(ch, p))
		{
			return;
		}
	}
	std::pair<std::multimap<int, room_prog>::iterator, std::multimap<int, room_prog>::iterator> pair;

	if (ch->right_hand && !get_second_affect (ch, SA_DOANYWAY, 0))
	{
		pair = obj_prog_list.equal_range(ch->right_hand->nVirtual);
		for (it = pair.first; it != pair.second; it++)
		{
			if (it->second.type != 1 && it->second.type != 3 && it->second.type != 5)
				continue;
			if (o_prog(ch, p, it->second))
				return;
		}
	}
	if (ch->left_hand && !get_second_affect (ch, SA_DOANYWAY, 0))
	{
		pair = obj_prog_list.equal_range(ch->left_hand->nVirtual);
		for (it = pair.first; it != pair.second; it++)
		{
			if (it->second.type != 1 && it->second.type != 3 && it->second.type != 5)
				continue;
			if (o_prog(ch, p, it->second))
				return;
		}
	}
	for (OBJ_DATA *tobj = ch->equip; tobj; tobj = tobj->next_content)
	{
		if (get_second_affect (ch, SA_DOANYWAY, 0))
			break;

		pair = obj_prog_list.equal_range(tobj->nVirtual);
		for (it = pair.first; it != pair.second; it++)
		{
			if (it->second.type != 2 && it->second.type != 3 && it->second.type != 5)
				continue;
			if (o_prog(ch, p, it->second))
				return;
		}

	}

	/* this is where it crashes on the hour - Grommit */

	if (!ch->room )
	{
		std::ostringstream stream;
		stream << "Error in command_interpreter:commands.cpp. Command \"" << 
			argument << "\" called by \"" << ch->tname << "\" with null room. Previously in "
			<< (ch->last_room) << " entering null room from the " << (dirs[ch->from_dir]) << ".";

		system_log(stream.str().c_str(),true);
		return;
	}

	/* end grommit diagnostics to avoid segfaulting on the below for loop */

	for (OBJ_DATA *tobj = ch->room->contents; tobj; tobj = tobj->next_content)
	{
		if (get_second_affect (ch, SA_DOANYWAY, 0))
			break;

		pair = obj_prog_list.equal_range(tobj->nVirtual);
		for (it = pair.first; it != pair.second; it++)
		{
			if (it->second.type != 4 && it->second.type != 5)
				continue;
			if (o_prog(ch, p, it->second))
				return;
		}

	}

	for (CHAR_DATA *temp_char = ch->room->people; temp_char; temp_char = temp_char->next_in_room)
	{
		if (get_second_affect (ch, SA_DOANYWAY, 0))
			break;

		if (temp_char == ch)
			continue;

		if (!IS_NPC(temp_char))
			continue;

		pair = mob_prog_list.equal_range(temp_char->mob->nVirtual);

		for (it = pair.first; it != pair.second; ++it)
		{
			if (m_prog(ch, p, it->second))
				return;
		}
	}

	if (ch->room && ch->room->prg && !get_second_affect(ch, SA_DOANYWAY, 0) && r_program (ch, p))
	{
		if (!IS_NPC (ch)
			|| (ch->desc && (ch->pc && str_cmp (ch->pc->account_name, "Guest"))))
		{
			player_log (ch, "[RPROG]", p);
		}
		if (!IS_SET (commands[i].flags, C_NWT))
			show_to_watchers (ch, argument);
		return;
	}
	if (get_second_affect(ch, SA_DOANYWAY, 0))
		remove_second_affect(get_second_affect(ch, SA_DOANYWAY, 0));

	if (!IS_MORTAL (ch) && !str_cmp (argument, "sho wl"))
	{
		send_to_char
			("Heh heh. Glad I added in this check, aren't we? No shouting for you.\n",
			ch);
		return;
	}

	if (ch->desc)
	{
		last_descriptor = ch->desc;
		sprintf (full_last_command, "Last Command Issued, by %s [%d]: %s",
			ch->tname, ch->in_room, argument);
		sprintf (last_command, "%s", argument);
	}

	social_args = argument;

	command_args = one_argument (argument, buf);

	if (!*buf)
		return;

	while (*command_args == ' ')
		command_args++;

	if (ch->pc && !GET_FLAG (ch, FLAG_ALIASING))
	{

		if ((alias = is_alias (ch, buf)))
		{

			ch->flags |= FLAG_ALIASING;

			while (alias)
			{

				command_interpreter (ch, alias->line);

				if (ch->deleted)
					return;

				alias = alias->next_line;
			}

			ch->flags &= ~FLAG_ALIASING;

			return;
		}
	}

	for (i = 1; *commands[i].command; i++)
		if (is_abbrev (buf, commands[i].command))
			break;

	if ((craft_affect = is_craft_command (ch, argument)))
		i = 0;

	if (IS_SET (commands[i].flags, C_IMP)) {
		cmd_level = 6;
	}
	else if (IS_SET (commands[i].flags, C_LV5)) {
		cmd_level = 5;
	}
	else if (IS_SET (commands[i].flags, C_LV4)) {
		cmd_level = 4;
	}
	else if (IS_SET (commands[i].flags, C_LV3)) {
		cmd_level = 3;
	}
	else if (IS_SET (commands[i].flags, C_LV2)) {
		cmd_level = 2;
	}
	else if (IS_SET (commands[i].flags, C_LV1)) {
		cmd_level = 1;
	}

	if (IS_SET (commands[i].flags, C_GDE)
		&& (IS_NPC (ch) || (!ch->pc->is_guide && !ch->pc->level)))
	{
		send_to_char ("Eh?\n\r", ch);
		return;
	}
	/* 
	Need to pass the CHAR_DATA pointer for the person who made the command and modify
	the following line to test the commanding char's trust against the trust level for
	the command.  - Methuselah
	*/

	if ((!*commands[i].command) 
		|| (cmd_level > GET_TRUST (ch)))
	{
		if (!social (ch, argument))
		{
			echo = number (1, 9);
			if (echo == 1)
				send_to_char ("Eh?\n\r", ch);
			else if (echo == 2)
				send_to_char ("Huh?\n\r", ch);
			else if (echo == 3)
				send_to_char ("I'm afraid that just isn't possible...\n\r", ch);
			else if (echo == 4)
				send_to_char ("I don't recognize that command.\n\r", ch);
			else if (echo == 5)
				send_to_char ("What?\n\r", ch);
			else if (echo == 6)
				send_to_char
				("Perhaps you should try typing it a different way?\n\r", ch);
			else if (echo == 7)
				send_to_char
				("Try checking your typing - I don't recognize it.\n\r", ch);
			else if (echo == 8)
				send_to_char
				("That isn't a recognized command, craft, or social.\n\r", ch);
			else
				send_to_char ("Hmm?\n\r", ch);
		}
		else
		{
			if (!IS_SET (commands[i].flags, C_NWT))
				show_to_watchers (ch, argument);
		}
		return;
	}

	if (ch->stun)
	{
		send_to_char ("You're still reeling.\n", ch);
		return;
	}

	if (ch->roundtime)
	{
		sprintf (buf, "You'll need to wait another %d seconds.\n",
			ch->roundtime);
		send_to_char (buf, ch);
		return;
	}

	if (IS_SET (commands[i].flags, C_WLK) &&
		(ch->moves || GET_FLAG (ch, FLAG_LEAVING)
		|| GET_FLAG (ch, FLAG_ENTERING)))
	{
		send_to_char ("Stop traveling first.\n\r", ch);
		return;
	}

	if (IS_SET (commands[i].flags, C_MNT) && IS_RIDER (ch))
	{
		send_to_char ("Get off your mount first.\n", ch);
		return;
	}

	if (commands[i].min_position > GET_POS (ch))
	{
		switch (GET_POS (ch))
		{
		case DEAD:
			if (IS_MORTAL (ch))
			{
				send_to_char ("You are dead.  You can't do that.\n\r", ch);
				return;
			}
		case UNCON:
		case MORT:
			send_to_char ("You're seriously wounded and unconscious.\n\r", ch);
			return;

		case STUN:
			send_to_char ("You're too stunned to do that.\n\r", ch);
			return;

		case SLEEP:
			send_to_char ("You can't do that while sleeping.\n\r", ch);
			return;

		case REST:
			send_to_char ("You can't do that while lying down.\n\r", ch);
			return;

		case SIT:
			send_to_char ("You can't do that while sitting.\n\r", ch);
			return;

		case FIGHT:
			send_to_char ("No way! You are fighting for your life!\n\r", ch);
			return;
		}

		return;
	}

	if (!IS_NPC (ch) && ch->pc->create_state == STATE_DIED &&
		!IS_SET (commands[i].flags, C_DOA))
	{
		send_to_char ("You can't do that when you're dead.\n\r", ch);
		return;
	}

	if (!IS_SET (commands[i].flags, C_BLD) && is_blind (ch))
	{
		if (get_equip (ch, WEAR_BLINDFOLD))
			send_to_char ("You can't do that while blindfolded.\n\r", ch);
		else
			send_to_char ("You can't do that while blind.\n\r", ch);
		return;
	}

	if ((af = get_affect (ch, MAGIC_AFFECT_PARALYSIS)) &&
		!IS_SET (commands[i].flags, C_PAR) && IS_MORTAL (ch))
	{
		send_to_char ("You can't move.\n", ch);
		return;
	}

	if (IS_SUBDUEE (ch) && !IS_SET (commands[i].flags, C_SUB) && !cmd_level)
	{
		act ("$N won't let you.", false, ch, 0, ch->subdue, TO_CHAR);
		return;
	}

	/* Most commands break delays */

	if (ch->delay && !IS_SET (commands[i].flags, C_DEL))
		break_delay (ch);

	/* Send this command to the log */
	if (!second_affect_active && (!IS_NPC (ch) || ch->desc))
	{
		if (IS_SET (commands[i].flags, C_NLG))
			;
		else if (i > 0)
		{			/* Log craft commands separately. */
			if (!str_cmp (commands[i].command, "."))
				player_log (ch, "say", command_args);
			else if (!str_cmp (commands[i].command, ","))
				player_log (ch, "emote", command_args);
			else if (!str_cmp (commands[i].command, ":"))
				player_log (ch, "emote", command_args);
			else if (!str_cmp (commands[i].command, ";"))
				player_log (ch, "wiznet", command_args);
			else
				player_log (ch, commands[i].command, command_args);
		}
	}

	if (IS_MORTAL (ch) && get_affect (ch, MAGIC_HIDDEN) &&
		!IS_SET (commands[i].flags, C_HID) &&
		skill_level (ch, SKILL_SNEAK, 0) < number (1, MAX(100, skill_level(ch, SKILL_SNEAK, 0))) &&
		would_reveal (ch))
	{
		remove_affect_type (ch, MAGIC_HIDDEN);
		act ("$n reveals $mself.", true, ch, 0, 0, TO_ROOM | _ACT_FORMAT);
		act ("Your actions have compromised your concealment.", true, ch, 0, 0,
			TO_CHAR);
	}

	/* Execute command */

	if (!IS_SET (commands[i].flags, C_NWT))
		show_to_watchers (ch, social_args);

	if (!i)			/* craft_command */
		craft_command (ch, command_args, craft_affect);
	else

		(*commands[i].proc) (ch, command_args, 0);

	last_descriptor = NULL;
}
コード例 #10
0
void do_constructwaterwheel(CHAR_DATA * ch, char * argument)
{
    // Check for skill
    int skill(get_skill(ch, gsn_constructwaterwheel));
    if (skill <= 0)
    {
        send_to_char("Huh?\n", ch);
        return;
    }

    // Check cooldown
    for (AFFECT_DATA * paf(get_affect(ch, gsn_constructwaterwheel)); paf != NULL; paf = get_affect(ch, gsn_constructwaterwheel, paf))
    {
        if (paf->location == APPLY_NONE)
        {
            send_to_char("You are not ready to construct another waterwheel yet.\n", ch);
            return;
        }
    }

    // Basic room checking
    if (ch->in_room == NULL || (ch->in_room->sector_type != SECT_WATER_SWIM && ch->in_room->sector_type != SECT_WATER_NOSWIM))
    {
        send_to_char("You may only construct a waterwheel on a river.\n", ch);
        return;
    }

    // Verify this room is a river
    unsigned int waterCount(0);
    for (unsigned int i(0); i <= Direction::Up; ++i)
    {
        ROOM_INDEX_DATA * room(Direction::Adjacent(*ch->in_room, static_cast<Direction::Value>(i)));
        if (room != NULL && (room->sector_type == SECT_WATER_SWIM || room->sector_type == SECT_WATER_NOSWIM))
            ++waterCount;
    }

    if (waterCount < 1 || waterCount > 2)
    {
        send_to_char("You may only construct a waterwheel on a river.\n", ch);
        return;
    }

    // Verify that there is not already a waterwheel here
    for (OBJ_DATA * obj(ch->in_room->contents); obj != NULL; obj = obj->next_content)
    {
        if (obj->pIndexData->vnum == OBJ_VNUM_WATERWHEEL)
        {
            send_to_char("There is already a waterwheel collecting the power of the river here.\n", ch);
            return;
        }
    }

    // Verify sufficient mana
    if (ch->mana < skill_table[gsn_constructwaterwheel].min_mana)
    {
        send_to_char("You are too weary to construct a waterwheel right now.\n", ch);
        return;
    }

    // Charge mana and lag
    expend_mana(ch, skill_table[gsn_constructwaterwheel].min_mana);
    WAIT_STATE(ch, skill_table[gsn_constructwaterwheel].beats);

    // Skill check
    if (number_percent() > skill)
    {
        check_improve(ch, NULL, gsn_constructwaterwheel, false, 1);
        act("You try to construct a waterwheel, but botch it completely.", ch, NULL, NULL, TO_CHAR);
        act("$n holds out a palm to the earth of the riverbank, but nothing happens.", ch, NULL, NULL, TO_ROOM);
        return;
    }

    check_improve(ch, NULL, gsn_constructwaterwheel, true, 1);

    // Create the waterwheel
    OBJ_DATA * wheel(create_object(get_obj_index(OBJ_VNUM_WATERWHEEL), 0));
    wheel->level = ch->level;
    wheel->timer = 200 + (ch->level * 6);
    obj_to_room(wheel, ch->in_room);

    // Echoes
    act("You seize hold of the earth of the riverbank with pure magic, reshaping it to your will!", ch, NULL, NULL, TO_CHAR);
    act("$n holds out a palm to the earth of the riverbank, which begins to reshape itself in response!", ch, NULL, NULL, TO_ROOM);
    act("In just moments there stands a functioning waterwheel, which begins to crank from the force of the river!", ch, NULL, NULL, TO_ALL);

    // Apply cooldown
    AFFECT_DATA af = {0};
    af.where    = TO_AFFECTS;
    af.type     = gsn_constructwaterwheel;
    af.location = APPLY_NONE;
    af.level    = ch->level;
    af.duration = 360 - (UMAX(0, skill - 70) * 2);
    affect_to_char(ch, &af);
}
コード例 #11
0
std::pair<int, std::string> char_data::reportWhere(bool checkClan, int RPP, std::string whichClan) {

	bool underwater = (room->sector_type == SECT_RIVER
		|| room->sector_type == SECT_LAKE
		|| room->sector_type == SECT_OCEAN
		|| room->sector_type == SECT_REEF
		|| room->sector_type == SECT_UNDERWATER);

	int characterNameColour = 0;

	if ((pc && pc->level > 0 && !fighting)) {
		characterNameColour = 5;
	}
	else if (fighting) {
		characterNameColour = 1;
	}
	else if (underwater) {
		characterNameColour = 4;
	}
	else if (IS_SET (flags, FLAG_ISADMIN)) {
		characterNameColour = 6;
	}
	else if (IS_SET (plr_flags, NEW_PLAYER_TAG)) {
		characterNameColour = 2;
	}
	else if (IS_GUIDE (this)) { //If the person is a guide
		characterNameColour = 3;
	}
	else {
		characterNameColour = 0;
	}

	char characterState = '_';

	switch (GET_POS (this)) {
		case POSITION_DEAD:
		case POSITION_MORTALLYW:
			characterState = 'X';
			break;
		case POSITION_UNCONSCIOUS:
		case POSITION_STUNNED:
			characterState = 'U';
			break;
		case POSITION_SLEEPING:
			characterState = 's';
			break;
		default:
			if (!IS_NPC (this) && !desc && !pc->admin_loaded) {
				characterState = 'L';
			}
			else if (IS_SET (act, PLR_QUIET) && !IS_NPC (this)) {
				characterState = 'e';
			}
			else if (get_affect (this, MAGIC_HIDDEN)) {
				characterState = 'h';
			}
			else if (desc && desc->idle) {
				characterState = 'i';
			}
	}

	std::stringstream reportStream;

	reportStream << "#" << characterNameColour;

	int blankLineSize = 15;  // 15 characters alloted to display the name, down from 17
	if (tname)
	  {
	    blankLineSize -= strlen(tname);
	  }

	if (blankLineSize < 1) {
	  std::string tempString = tname;  //never true on null string, as it would still be 15
		reportStream << tempString.substr(0,15);
	}
	else {
	  reportStream << ((tname) ? tname : "(null)");
		for (size_t i = 0; i < blankLineSize; i++) {
			reportStream << " ";
		}
	}

	if (RPP < 0) {
		if (aur < 10) {
			reportStream << "#3[ " << aur << "]";
		}
		else {
			reportStream << "#3[" << aur << "]";
		}
	}
	else if (RPP < 10) {
		reportStream << "#3[ " << RPP << "]";
	}
	else {
		reportStream << "#3[" << RPP << "]";
	}

	reportStream << " #0" << characterState;
	reportStream << (getNaughtyFlag() ? "#1!" : "#0_");	// Flag to watch player for bad behaviour
	reportStream << (getRPFlag() ? "#2R" : "#0_");	// Flag to watch player for possible award
	reportStream << (getPlotFlag() ? "#3P" : "#0_") << " ";	// Flag to indicate player is in a plot

	char roomBuffer[MAX_STRING_LENGTH];

	// [rnum and char name]
	sprintf (roomBuffer, "#2[%6d]#6 %s#0", room->nVirtual, room->name);
	reportStream << roomBuffer;

	return std::make_pair(room->nVirtual, reportStream.str());
}
コード例 #12
0
ファイル: somatics.cpp プロジェクト: nuggs/RPI-Engine
void
soma_ten_second_affect (CHAR_DATA * ch, AFFECTED_TYPE * af)
{
  int save = 0, stat = 0;
  char *locat = NULL;
  char buf2[MAX_STRING_LENGTH];
  char buf[MAX_STRING_LENGTH];
  
  stat = GET_CON (ch);
  if ((number (1, 1000) > af->a.soma.atm_power)
      || (number (1, (stat > 20) ? stat : 20) <= stat))
    return;

  switch (af->type)
    {
      /*    case SOMA_MUSCULAR_CRAMP:       sprintf(buf2,"a muscle cramp"); break;
         case SOMA_MUSCULAR_TWITCHING:      sprintf(buf2,"twitching"); break;
         case SOMA_MUSCULAR_TREMOR: sprintf(buf2,"tremors"); break;
         case SOMA_MUSCULAR_PARALYSIS:      sprintf(buf2,"paralysis"); break;
         case SOMA_DIGESTIVE_ULCER: sprintf(buf2,"stomach ulcer"); break; 
         case SOMA_DIGESTIVE_VOMITING:      sprintf(buf2,"vomiting"); break;
         case SOMA_DIGESTIVE_BLEEDING:      sprintf(buf2,"vomiting blood"); break; 
         case SOMA_EYE_BLINDNESS:   sprintf(buf2,"blindness"); break;
         case SOMA_EYE_BLURRED:             sprintf(buf2,"blurred vision"); break;
         case SOMA_EYE_DOUBLE:              sprintf(buf2,"double vision"); break;
         case SOMA_EYE_DILATION:            sprintf(buf2,"dilated pupils"); break; 
         case SOMA_EYE_CONTRACTION: sprintf(buf2,"contracted pupils"); break; 
         case SOMA_EYE_LACRIMATION: sprintf(buf2,"lacrimation"); break;
         case SOMA_EYE_PTOSIS:              sprintf(buf2,"ptosis"); break;
         case SOMA_EAR_TINNITUS:            sprintf(buf2,"tinnitus"); break;
         case SOMA_EAR_DEAFNESS:            sprintf(buf2,"deafness"); break;
         case SOMA_EAR_EQUILLIBRIUM:        sprintf(buf2,"ear imbalance"); break;
         case SOMA_NOSE_ANOSMIA:            sprintf(buf2,"anosmia"); break;
         case SOMA_NOSE_RHINITIS:   sprintf(buf2,"rhinitis"); break;
         case SOMA_MOUTH_SALIVATION:        sprintf(buf2,"salivation"); break;
         case SOMA_MOUTH_TOOTHACHE: sprintf(buf2,"toothache"); break;
         case SOMA_MOUTH_DRYNESS:   sprintf(buf2,"dry mouth"); break;
         case SOMA_MOUTH_HALITOSIS: sprintf(buf2,"halitosis"); break;
         case SOMA_CHEST_DIFFICULTY:        sprintf(buf2,"difficulty breathing"); break;
         case SOMA_CHEST_RAPIDBREATH:       sprintf(buf2,"rapid breathing"); break;
         case SOMA_CHEST_SLOWBREATH:        sprintf(buf2,"shallow breathing"); break;
         case SOMA_CHEST_FLUID:             sprintf(buf2,"fluidous lungs"); break;
         case SOMA_CHEST_PALPITATIONS:      sprintf(buf2,"heart palpitations"); break; */

    case SOMA_CHEST_COUGHING:

      stat = GET_WIL (ch);
      save = number (1, (stat > 20) ? stat : 20);

      if (get_affect (ch, MAGIC_HIDDEN) && would_reveal (ch))
	{
	  if (save > stat)
	    {
	      remove_affect_type (ch, MAGIC_HIDDEN);
	      act ("$n reveals $mself with an audible cough.", true, ch, 0, 0,
		   TO_ROOM);
	    }
	  else if (save > (stat / 2))
	    {
	      act ("You hear a muffled sound from somewhere nearby.", true,
		   ch, 0, 0, TO_ROOM);
	    }
	}
      else if ((save <= stat) && (save > (stat / 2)))
	{
	  act ("$n tries to stifle a cough.", true, ch, 0, 0, TO_ROOM);
	}

      if (save > stat)
	{
	  act ("You cough audibly.", true, ch, 0, 0, TO_CHAR);
	}
      else
	{
	  act ("You try to stifle a cough silently.", true, ch, 0, 0,
	       TO_CHAR);
	}
      break;

	case SOMA_CHEST_WHEEZING:

      stat = GET_WIL (ch);
      save = number (1, (stat > 20) ? stat : 20);

      if (get_affect (ch, MAGIC_HIDDEN) && would_reveal (ch))
	{
	  if (save > stat)
	    {
	      remove_affect_type (ch, MAGIC_HIDDEN);
	      act ("$n reveals $mself with an audible wheeze.", true, ch, 0, 0,
		   TO_ROOM);
	    }
	  else if (save > (stat / 2))
	    {
	      act ("You hear a muffled sound from somewhere nearby.", true,
		   ch, 0, 0, TO_ROOM);
	    }
	}
      else if ((save <= stat) && (save > (stat / 2)))
	{
	  act ("$n tries to stifle their wheezing.", true, ch, 0, 0, TO_ROOM);
	}

      if (save > stat)
	{
	  act ("You wheeze audibly.", true, ch, 0, 0, TO_CHAR);
	}
      else
	{
	  act ("You try to stifle your wheezing.", true, ch, 0, 0,
	       TO_CHAR);
	}
      break;


	case SOMA_NERVES_HEADACHE:

      stat = GET_WIL (ch);
      save = number (1, (stat > 20) ? stat : 20);

      if (save > stat)
	{
	  act ("Your head pounds with a headache.", true, ch, 0, 0, TO_CHAR);
	}
      else
	{
	  act ("You manage to ignore the pounding in your head.", true, ch, 0, 0,
	       TO_CHAR);
	}
      break;

	case SOMA_MUSCULAR_CRAMP:
	
			stat = GET_WIL (ch);
      save = number (1, (stat > 20) ? stat : 20);
			locat = expand_wound_loc(figure_location(ch, number(0,2)));

      if (save > stat)
				{
				sprintf(buf, "You get an intense cramp in your %s which persist for several minutes beofre finally relaxing\n", locat);
	  		act (buf, true, ch, 0, 0, TO_CHAR);
	  		 act ("$n suddenly cringes in pain.", true, ch, 0, 0, TO_ROOM);
				}
      else
				{
				sprintf(buf, "You get an intense cramp in your %s, but you shake it off quickly\n", locat);
	  		act (buf, true, ch, 0, 0, TO_CHAR);
	  		act ("$n suddenly cringes in pain, but quickly recovers.", true, ch, 0, 0, TO_ROOM);
				}
      break;

     
    case SOMA_MUSCULAR_TWITCHING:
    	stat = GET_WIL (ch);
      save = number (1, (stat > 20) ? stat : 20);
			locat = expand_wound_loc(figure_location(ch, number(0,2)));
			
      if (save > stat)
				{
				sprintf(buf, "You feel a strong twitching in your %s which persist for several minutes before finally relaxing\n", locat);
	  		act (buf, true, ch, 0, 0, TO_CHAR);
	  		sprintf(buf2, "$n suddenly cringes in pain, as $s %s twitches.", locat);
	  		act (buf2, true, ch, 0, 0, TO_ROOM);
				}
      else
				{
				sprintf(buf, "You feel a strong twitching in your %s, but you control it quickly\n", locat);
	  		act (buf, true, ch, 0, 0, TO_CHAR);
	  		sprintf(buf2, "$n cringes in pain, as $s %s twitches momentarily.", locat);
	  		act (buf2, true, ch, 0, 0, TO_ROOM);
	  		
				}
      break;      
      

      /*  case SOMA_CHEST_PNEUMONIA:      sprintf(buf2,"pneumonia"); break;
         case SOMA_NERVES_PSYCHOSIS:      sprintf(buf2,"psychosis"); break;
         case SOMA_NERVES_DELIRIUM:       sprintf(buf2,"delerium "); break;
         case SOMA_NERVES_COMA:           sprintf(buf2,"a comatose state"); break;
         case SOMA_NERVES_CONVULSIONS:    sprintf(buf2,"convulsions"); break;
         case SOMA_NERVES_CONFUSION:      sprintf(buf2,"confusion"); break;
         case SOMA_NERVES_PARETHESIAS:    sprintf(buf2,"parethesias"); break;
         case SOMA_NERVES_ATAXIA: sprintf(buf2,"ataxia"); break;
         case SOMA_NERVES_EQUILLIBRIUM:   sprintf(buf2,"nervous imbalance"); break;
         case SOMA_SKIN_CYANOSIS: sprintf(buf2,"cyanosis of the skin"); break;
         case SOMA_SKIN_DRYNESS:          sprintf(buf2,"dryness of the skin"); break;
         case SOMA_SKIN_CORROSION:        sprintf(buf2,"corrosion of the skin"); break;
         case SOMA_SKIN_JAUNDICE: sprintf(buf2,"jaundice of the skin"); break;
         case SOMA_SKIN_REDNESS:          sprintf(buf2,"redness of the skin"); break;
         case SOMA_SKIN_RASH:             sprintf(buf2,"a rash on the skin"); break;
         case SOMA_SKIN_HAIRLOSS: sprintf(buf2,"hairloss"); break;
         case SOMA_SKIN_EDEMA:            sprintf(buf2,"edema of the skin"); break;
         case SOMA_SKIN_BURNS:            sprintf(buf2,"burns on the skin"); break;
         case SOMA_SKIN_PALLOR:           sprintf(buf2,"pallor of the skin"); break;
         case SOMA_SKIN_SWEATING: sprintf(buf2,"the sweats"); break;
         case SOMA_GENERAL_WEIGHTLOSS:    sprintf(buf2,"weight loss"); break;
         case SOMA_GENERAL_LETHARGY:      sprintf(buf2,"lethargy"); break;
         case SOMA_GENERAL_APPETITELOSS:  sprintf(buf2,"appetite loss"); break;
         case SOMA_GENERAL_PRESSUREDROP:  sprintf(buf2,"low blood pressure"); break;
         case SOMA_GENERAL_PRESSURERISE:  sprintf(buf2,"high blood pressure"); break;
         case SOMA_GENERAL_FASTPULSE:     sprintf(buf2,"a fast pulse"); break;
         case SOMA_GENERAL_SLOWPULSE:     sprintf(buf2,"a slow pulse"); break;
         case SOMA_GENERAL_HYPERTHERMIA:  sprintf(buf2,"hyperthermia"); break;
         case SOMA_GENERAL_HYPOTHERMIA:   sprintf(buf2,"hypothermia"); break;
       */
    default:
      break;
    }
}