예제 #1
0
BotItemsSelector::ItemAndGoalWeights BotItemsSelector::ComputeAmmoWeights( const gsitem_t *item ) const {
	if( Inventory()[item->tag] < item->inventory_max ) {
		float quantityFactor = 1.0f - Inventory()[item->tag] / (float)item->inventory_max;
		if( quantityFactor > 0 ) {
			quantityFactor = 1.0f / Q_RSqrt( quantityFactor );
		}

		for( int weapon = WEAP_GUNBLADE; weapon < WEAP_TOTAL; weapon++ ) {
			// TODO: Preache
			const gsitem_t *weaponItem = GS_FindItemByTag( weapon );
			if( weaponItem->ammo_tag == item->tag ) {
				if( Inventory()[weaponItem->tag] ) {
					switch( weaponItem->tag ) {
						case WEAP_ELECTROBOLT:
							return ItemAndGoalWeights( quantityFactor, quantityFactor );
						case WEAP_LASERGUN:
							return ItemAndGoalWeights( quantityFactor * 1.1f, quantityFactor );
						case WEAP_PLASMAGUN:
							return ItemAndGoalWeights( quantityFactor * 1.1f, quantityFactor );
						case WEAP_ROCKETLAUNCHER:
							return ItemAndGoalWeights( quantityFactor, quantityFactor );
						default:
							return ItemAndGoalWeights( 0.5f * quantityFactor, quantityFactor );
					}
				}
				return ItemAndGoalWeights( quantityFactor * 0.33f, quantityFactor * 0.5f );
			}
		}
	}
	return ItemAndGoalWeights( 0.0, 0.0f );
}
예제 #2
0
파일: buysell.cpp 프로젝트: Ablu/invertika
int BuySell::registerPlayerItems()
{
    int nbItemsToSell = 0;
    if (mSell)
    {
        for (int i = 0; i < EQUIPMENT_SLOTS; ++i)
        {
            int id = Inventory(mChar).getItem(i);
            int nb = Inventory(mChar).count(id);
            if (nb > 0)
            {
                int cost = -1;
                if (ItemManager::getItem(id))
                    cost = ItemManager::getItem(id)->getCost();
                if (cost > 0)
                {
                    TradedItem it = { id, nb, cost };
                    mItems.push_back(it);
                    nbItemsToSell++;
                }
            }
        }
    }
    return nbItemsToSell;
}
예제 #3
0
void GameHandler::tokenMatched(GameClient *computer, Character *character)
{
    computer->character = character;
    computer->status = CLIENT_CONNECTED;

    character->setClient(computer);

    MessageOut result(GPMSG_CONNECT_RESPONSE);

    if (!GameState::insert(character))
    {
        result.writeByte(ERRMSG_SERVER_FULL);
        kill(character);
        delete character;
        computer->disconnect(result);
        return;
    }

    result.writeByte(ERRMSG_OK);
    computer->send(result);

    // Force sending the whole character to the client.
    Inventory(character).sendFull();
    for (int i = 0; i < CHAR_ATTR_NB; ++i)
    {
        character->updateDerivedAttributes(i);
    }
    std::map<int, int>::const_iterator skill_it;
    for (skill_it = character->getSkillBegin(); skill_it != character->getSkillEnd(); skill_it++)
    {
        character->updateDerivedAttributes(skill_it->first);
    }
}
예제 #4
0
void PharmacyManagement::initUI()
{
	Receipt();
	Check();
	Inventory();
	Statistics();
}
예제 #5
0
void Creature::load(const JsonBox::Value& v, EntityManager* mgr)
{
	JsonBox::Object o = v.getObject();
	this->name = o["name"].getString();
	this->hp = o["hp"].getInteger();
	if(o.find("hp_max") != o.end())
	{
		this->maxHp = o["hp_max"].getInteger();
	}
	else
	{
		this->maxHp = hp;
	}
	this->strength = o["strength"].getInteger();
	this->agility = o["agility"].getInteger();
	this->evasion = o["evasion"].getDouble();
	this->xp = o["xp"].getInteger();

	if(o.find("inventory") != o.end())
	{
		this->inventory = Inventory(o["inventory"], mgr);
	}
	if(o.find("equipped_weapon") != o.end())
	{
		std::string equippedWeaponName = o["equipped_weapon"].getString();
		this->equippedWeapon = equippedWeaponName == "nullptr" ? nullptr : mgr->getEntity<Weapon>(equippedWeaponName);
	}
	if(o.find("equipped_armor") != o.end())
	{
		std::string equippedArmorName = o["equipped_armor"].getString();
		this->equippedArmor = equippedArmorName == "nullptr" ? nullptr : mgr->getEntity<Armor>(equippedArmorName);
	}

	return;
}
예제 #6
0
Container::Container(Drawable* drawable, const Inventory& inv) : MapObject(drawable) {

   // Set the Inventory as the Provided Inventory.
   this->inv = Inventory(inv);

   // Construct the Animation and Dialog Interactions.
   Uint16 priority = 0;
   bool isHandledOnce = true;

   AnimationInteraction* ai = new AnimationInteraction(
        priority
      , isHandledOnce
      , "TreasureChestOpened"
   );

   // Add the Animation Interaciton.
   this->addInteraction((Interaction*) ai);

   std::string msg = "You got the " + inv.toString() + ".";
   DialogInteraction* di = new DialogInteraction(
        ++priority
      , isHandledOnce
      , msg
   );

   // Add the Dialog Interaciton.
   this->addInteraction((Interaction*) di);

}
예제 #7
0
void GameHandler::tokenMatched(GameClient *computer, Character *character)
{
    computer->character = character;
    computer->status = CLIENT_CONNECTED;

    character->setClient(computer);

    MessageOut result(GPMSG_CONNECT_RESPONSE);

    if (!GameState::insert(character))
    {
        result.writeInt8(ERRMSG_SERVER_FULL);
        kill(character);
        delete character;
        computer->disconnect(result);
        return;
    }
    // Trigger login script bind
    character->triggerLoginCallback();

    result.writeInt8(ERRMSG_OK);
    computer->send(result);

    // Force sending the whole character to the client.
    Inventory(character).sendFull();
    character->modifiedAllAttribute();
}
예제 #8
0
BotItemsSelector::ItemAndGoalWeights BotItemsSelector::ComputeWeaponWeights( const gsitem_t *item, bool onlyGotGB ) const {
	if( Inventory()[item->tag] ) {
		// TODO: Precache
		const gsitem_t *ammo = GS_FindItemByTag( item->ammo_tag );
		if( Inventory()[ammo->tag] >= ammo->inventory_max ) {
			return ItemAndGoalWeights( 0, 0 );
		}

		float ammoQuantityFactor = 1.0f - Inventory()[ammo->tag] / (float)ammo->inventory_max;
		if( ammoQuantityFactor > 0 ) {
			ammoQuantityFactor = 1.0f / Q_RSqrt( ammoQuantityFactor );
		}

		switch( item->tag ) {
			case WEAP_ELECTROBOLT:
				return ItemAndGoalWeights( ammoQuantityFactor, 0.5f * ammoQuantityFactor );
			case WEAP_LASERGUN:
				return ItemAndGoalWeights( ammoQuantityFactor * 1.1f, 0.6f * ammoQuantityFactor );
			case WEAP_PLASMAGUN:
				return ItemAndGoalWeights( ammoQuantityFactor * 1.1f, 0.6f * ammoQuantityFactor );
			case WEAP_ROCKETLAUNCHER:
				return ItemAndGoalWeights( ammoQuantityFactor, 0.5f * ammoQuantityFactor );
			default:
				return ItemAndGoalWeights( 0.75f * ammoQuantityFactor, 0.75f * ammoQuantityFactor );
		}
	}

	// We may consider plasmagun in a bot's hand as a top tier weapon too
	const int topTierWeapons[4] = { WEAP_ELECTROBOLT, WEAP_LASERGUN, WEAP_ROCKETLAUNCHER, WEAP_PLASMAGUN };

	// TODO: Precompute
	float topTierWeaponGreed = 0.0f;
	for( int i = 0; i < 4; ++i ) {
		if( !Inventory()[topTierWeapons[i]] ) {
			topTierWeaponGreed += 1.0f;
		}
	}

	for( int i = 0; i < 4; ++i ) {
		if( topTierWeapons[i] == item->tag ) {
			float weight = ( onlyGotGB ? 2.0f : 0.9f ) + ( topTierWeaponGreed - 1.0f ) / 3.0f;
			return ItemAndGoalWeights( weight, weight );
		}
	}

	return onlyGotGB ? ItemAndGoalWeights( 1.5f, 2.0f ) : ItemAndGoalWeights( 0.75f, 0.75f );
}
예제 #9
0
int main()
{
	Weapon sword  = Weapon("Steel Sword", 35,100,10,0,"sword",1);
	Item * sPtr = &sword;
	Inventory inv = Inventory(sPtr);
	Inventory * invPtr = &inv;
	Character chris  = Character("Chris", "Thief", "Human", 23,invPtr);
	chris.getInventory()->addItem(sword);
	chris.printStats();
}
예제 #10
0
파일: Atlas.cpp 프로젝트: strap8/TestRGP
void buildatlas_area(std::vector<Area>& atlas,
	std::vector<Item>& items, std::vector<Weapon>& weapons,
	std::vector<Armour>& armour, std::vector<Creature>& creatures)
{
	// Area definitions are somewhat more complicated:
	atlas.push_back(Area(Dialogue(			// Standard dialogue definiton
		"You are in room 1",				// Description
		{ "Go to room 2", "Search" }),		// Choices
		Inventory(							// Area inventory
	{
		std::make_pair(&items[0], 5)	// Pair of item and quantity

	},
	{
		std::make_pair(&weapons[0], 1),	// Pair of weapon and quantity
		std::make_pair(&weapons[1], 1)
	},

	{
		std::make_pair(&armour[0], 1),
		std::make_pair(&armour[1], 1)// Pair of armour and quantity
	}),
	{									// Creatures
	}));

	atlas.push_back(Area(Dialogue(
		"You are in room 2",
		{ "Go to room 1", "Search" }),
		Inventory(
	{
		std::make_pair(&items[0], 10),
		std::make_pair(&items[1], 1)
	},
	{
	},
	{
	}),
	{
		&creatures[0]
	}));

	return;
}
예제 #11
0
void DrugStorageManagement::initUI()
{
	
    Storage();
    Allot();
	Inventory();
	Check();
	Pricing();
	Statistics();
}
예제 #12
0
void GameHandler::handleUnequip(GameClient &client, MessageIn &message)
{
    const int itemInstance = message.readInt16();
    if (!Inventory(client.character).unequip(itemInstance))
    {
        MessageOut msg(GPMSG_SAY);
        msg.writeInt16(0); // From the server
        msg.writeString("Unable to unequip.");
        client.send(msg);
    }
}
예제 #13
0
Character::Character(MessageIn &msg):
    Being(OBJECT_CHARACTER),
    mClient(NULL),
    mConnected(true),
    mTransactionHandler(NULL),
    mSpecialUpdateNeeded(false),
    mDatabaseID(-1),
    mHairStyle(0),
    mHairColor(0),
    mLevel(1),
    mLevelProgress(0),
    mUpdateLevelProgress(false),
    mRecalculateLevel(true),
    mParty(0),
    mTransaction(TRANS_NONE),
    mTalkNpcId(0),
    mNpcThread(0),
    mKnuckleAttackInfo(0)
{
    const AttributeManager::AttributeScope &attr =
                           attributeManager->getAttributeScope(CharacterScope);
    LOG_DEBUG("Character creation: initialisation of "
              << attr.size() << " attributes.");
    for (AttributeManager::AttributeScope::const_iterator it1 = attr.begin(),
         it1_end = attr.end(); it1 != it1_end; ++it1)
        mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second)));

    setWalkMask(Map::BLOCKMASK_WALL);
    setBlockType(BLOCKTYPE_CHARACTER);

    // Get character data.
    mDatabaseID = msg.readInt32();
    setName(msg.readString());
    deserializeCharacterData(*this, msg);
    mOld = getPosition();
    Inventory(this).initialize();
    modifiedAllAttribute();
    setSize(16);

    // Default knuckle attack
    int damageBase = this->getModifiedAttribute(ATTR_STR);
    int damageDelta = damageBase / 2;
    Damage knuckleDamage;
    knuckleDamage.skill = skillManager->getDefaultSkillId();
    knuckleDamage.base = damageBase;
    knuckleDamage.delta = damageDelta;
    knuckleDamage.cth = 2;
    knuckleDamage.element = ELEMENT_NEUTRAL;
    knuckleDamage.type = DAMAGE_PHYSICAL;
    knuckleDamage.range = DEFAULT_TILE_LENGTH;

    mKnuckleAttackInfo = new AttackInfo(0, knuckleDamage, 7, 3, 0);
    addAttack(mKnuckleAttackInfo);
}
예제 #14
0
void GameHandler::handlePickup(GameClient &client, MessageIn &message)
{
    const int x = message.readInt16();
    const int y = message.readInt16();
    const Point ppos =
            client.character->getComponent<ActorComponent>()->getPosition();

    // TODO: use a less arbitrary value.
    if (std::abs(x - ppos.x) + std::abs(y - ppos.y) < 48)
    {
        MapComposite *map = client.character->getMap();
        Point ipos(x, y);
        for (FixedActorIterator i(map->getAroundPointIterator(ipos, 0)); i; ++i)
        {
            Entity *o = *i;
            Point opos = o->getComponent<ActorComponent>()->getPosition();

            if (o->getType() == OBJECT_ITEM && opos.x == x && opos.y == y)
            {
                ItemComponent *item = o->getComponent<ItemComponent>();
                ItemClass *ic = item->getItemClass();
                int amount = item->getAmount();

                if (!Inventory(client.character).insert(ic->getDatabaseID(),
                                                        amount))
                {
                    GameState::remove(o);

                    // We only do this when items are to be kept in memory
                    // between two server restart.
                    if (!Configuration::getValue("game_floorItemDecayTime", 0))
                    {
                        // Remove the floor item from map
                        accountHandler->removeFloorItems(map->getID(),
                                                         ic->getDatabaseID(),
                                                         amount, x, y);
                    }

                    // log transaction
                    std::stringstream str;
                    str << "User picked up item " << ic->getDatabaseID()
                        << " at " << opos.x << "x" << opos.y;
                    auto *characterComponent = client.character
                            ->getComponent<CharacterComponent>();
                    accountHandler->sendTransaction(
                            characterComponent->getDatabaseID(),
                            TRANS_ITEM_PICKUP, str.str()
                                                   );
                }
                break;
            }
        }
    }
}
예제 #15
0
void GameHandler::handleMoveItem(GameClient &client, MessageIn &message)
{
    const int slot1 = message.readInt16();
    const int slot2 = message.readInt16();
    const int amount = message.readInt16();

    Inventory(client.character).move(slot1, slot2, amount);
    // log transaction
    std::stringstream str;
    str << "User moved item "
        << " from slot " << slot1 << " to slot " << slot2;
    accountHandler->sendTransaction(client.character->getDatabaseID(),
                                    TRANS_ITEM_MOVE, str.str());
}
예제 #16
0
CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
    mClient(nullptr),
    mConnected(true),
    mTransactionHandler(nullptr),
    mDatabaseID(-1),
    mHairStyle(0),
    mHairColor(0),
    mSendAttributePointsStatus(false),
    mAttributePoints(0),
    mCorrectionPoints(0),
    mSendAbilityCooldown(false),
    mParty(0),
    mTransaction(TRANS_NONE),
    mTalkNpcId(0),
    mNpcThread(0),
    mBaseEntity(&entity)
{
    auto *beingComponent = entity.getComponent<BeingComponent>();

    auto &attributeScope = attributeManager->getAttributeScope(CharacterScope);
    LOG_DEBUG("Character creation: initialisation of "
              << attributeScope.size() << " attributes.");
    for (auto &attribute : attributeScope)
        beingComponent->createAttribute(attribute);

    auto *actorComponent = entity.getComponent<ActorComponent>();
    actorComponent->setWalkMask(Map::BLOCKMASK_WALL);
    actorComponent->setBlockType(BLOCKTYPE_CHARACTER);
    actorComponent->setSize(16);


    auto *abilityComponent = new AbilityComponent();
    entity.addComponent(abilityComponent);
    abilityComponent->signal_ability_changed.connect(
            sigc::mem_fun(this, &CharacterComponent::abilityStatusChanged));
    abilityComponent->signal_global_cooldown_activated.connect(
            sigc::mem_fun(this,
                          &CharacterComponent::abilityCooldownActivated));

    // Get character data.
    mDatabaseID = msg.readInt32();
    beingComponent->setName(msg.readString());

    deserialize(entity, msg);

    Inventory(&entity, mPossessions).initialize();

    beingComponent->signal_attribute_changed.connect(sigc::mem_fun(
            this, &CharacterComponent::attributeChanged));
}
예제 #17
0
파일: buysell.cpp 프로젝트: Ablu/invertika
bool BuySell::registerItem(int id, int amount, int cost)
{
    if (mSell)
    {
        int nb = Inventory(mChar).count(id);
        if (nb == 0)
            return false;
        if (!amount || nb < amount)
            amount = nb;
    }

    TradedItem it = { id, amount, cost };
    mItems.push_back(it);
    return true;
}
예제 #18
0
Inventory InventoryDAOMySQL::getInventoryById(const int &id)
{
    MySQLManager::ConnectionHolder ch(MySQLManager::getInstance());
    std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(INVENTORY_BY_ID));

    ps->setInt(1, id);

    std::unique_ptr<sql::ResultSet> res(ps->executeQuery());

    if(!res->next())
    {
        throw DAOException("Inventory not found!");
    }
    return Inventory(res->getInt(1), res->getInt(2), res->getInt(3), res->getString(4));
}
예제 #19
0
std::vector<Inventory> InventoryDAOMySQL::getInventoryByUserId(const int &userId)
{
    MySQLManager::ConnectionHolder ch(MySQLManager::getInstance());
    std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(INVENTORIES_BY_USERID));

    ps->setInt(1, userId);

    std::unique_ptr<sql::ResultSet> res(ps->executeQuery());

    std::vector<Inventory> inventories;
    while(res->next())
    {
        inventories.push_back(Inventory(res->getInt(1), res->getInt(2), res->getInt(3), res->getString(4)));
    }
    return inventories;
}
예제 #20
0
std::vector<Inventory> InventoryDAOMySQL::searchInventoryByGtin(const int &userId, const std::string &gtin)
{
    MySQLManager::ConnectionHolder ch(MySQLManager::getInstance());
    std::unique_ptr<sql::PreparedStatement> ps(ch.conn->prepareStatement(INVENTORIES_SEARCH_GTIN));

    ps->setInt(1, userId);
    ps->setString(2, "%" + gtin + "%");

    std::unique_ptr<sql::ResultSet> res(ps->executeQuery());

    std::vector<Inventory> inventories;
    while(res->next())
    {
        inventories.push_back(Inventory(res->getInt(1), res->getInt(2), res->getInt(3), res->getString(4)));
    }
    return inventories;
}
예제 #21
0
파일: buysell.cpp 프로젝트: Ablu/manaserv
bool BuySell::registerItem(unsigned id, int amount, int cost)
{
    if (mSell)
    {
        int nb = Inventory(mChar).count(id);
        if (nb == 0)
            return false;
        if (!amount || nb < amount)
            amount = nb;
    }

    TradedItem item;
    item.itemId = id;
    item.amount = amount;
    item.cost = cost;
    mItems.push_back(item);
    return true;
}
예제 #22
0
Character::Character(MessageIn &msg):
    Being(OBJECT_CHARACTER),
    mClient(NULL),
    mConnected(true),
    mTransactionHandler(NULL),
    mSpecialUpdateNeeded(false),
    mDatabaseID(-1),
    mHairStyle(0),
    mHairColor(0),
    mLevel(1),
    mLevelProgress(0),
    mUpdateLevelProgress(false),
    mRecalculateLevel(true),
    mParty(0),
    mTransaction(TRANS_NONE),
    mTalkNpcId(0),
    mNpcThread(0)
{
    const AttributeManager::AttributeScope &attr =
                           attributeManager->getAttributeScope(CharacterScope);
    LOG_DEBUG("Character creation: initialisation of "
              << attr.size() << " attributes.");
    for (AttributeManager::AttributeScope::const_iterator it1 = attr.begin(),
         it1_end = attr.end(); it1 != it1_end; ++it1)
        mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second)));

    setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER);

    // Get character data.
    mDatabaseID = msg.readInt32();
    setName(msg.readString());
    deserializeCharacterData(*this, msg);
    mOld = getPosition();
    Inventory(this).initialize();
    modifiedAllAttribute();
    setSize(16);
}
예제 #23
0
void BotItemsSelector::UpdateInternalItemAndGoalWeights() {
	memset( internalEntityWeights, 0, sizeof( internalEntityWeights ) );
	memset( internalPickupGoalWeights, 0, sizeof( internalPickupGoalWeights ) );

	// Compute it once, not on each loop step
	bool onlyGotGB = true;
	for( int weapon = WEAP_GUNBLADE + 1; weapon < WEAP_TOTAL; ++weapon ) {
		if( Inventory()[weapon] ) {
			onlyGotGB = false;
			break;
		}
	}

	const auto levelTime = level.time;
	auto *navEntitiesRegistry = NavEntitiesRegistry::Instance();
	for( auto it = navEntitiesRegistry->begin(), end = navEntitiesRegistry->end(); it != end; ++it ) {
		const NavEntity *goalEnt = *it;
		// Picking clients as goal entities is currently disabled
		if( goalEnt->IsClient() ) {
			continue;
		}

		// Do not even try to compute a weight for the disabled item
		if( disabledForSelectionUntil[goalEnt->Id()] >= levelTime ) {
			internalEntityWeights[goalEnt->Id()] = 0;
			internalPickupGoalWeights[goalEnt->Id()] = 0;
			continue;
		}

		if( goalEnt->Item() ) {
			ItemAndGoalWeights weights = ComputeItemWeights( goalEnt->Item(), onlyGotGB );
			internalEntityWeights[goalEnt->Id()] = weights.itemWeight;
			internalPickupGoalWeights[goalEnt->Id()] = weights.goalWeight;
		}
	}
}
예제 #24
0
파일: command.cpp 프로젝트: Ablu/invertika
static void item(Character *, Character *q, ItemClass *it, int nb)
{
    Inventory(q).insert(it->getDatabaseID(), nb);
}
예제 #25
0
CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
    mClient(NULL),
    mConnected(true),
    mTransactionHandler(NULL),
    mSpecialUpdateNeeded(false),
    mDatabaseID(-1),
    mHairStyle(0),
    mHairColor(0),
    mLevel(1),
    mLevelProgress(0),
    mUpdateLevelProgress(false),
    mRecalculateLevel(true),
    mParty(0),
    mTransaction(TRANS_NONE),
    mTalkNpcId(0),
    mNpcThread(0),
    mKnuckleAttackInfo(0),
    mBaseEntity(&entity)
{
    auto *beingComponent = entity.getComponent<BeingComponent>();

    const AttributeManager::AttributeScope &attributes =
                           attributeManager->getAttributeScope(CharacterScope);
    LOG_DEBUG("Character creation: initialisation of "
              << attributes.size() << " attributes.");
    for (auto attributeScope : attributes)
        beingComponent->createAttribute(attributeScope.first,
                                        *attributeScope.second);

    auto *actorComponent = entity.getComponent<ActorComponent>();
    actorComponent->setWalkMask(Map::BLOCKMASK_WALL);
    actorComponent->setBlockType(BLOCKTYPE_CHARACTER);
    actorComponent->setSize(16);


    CombatComponent *combatcomponent = new CombatComponent(entity);
    entity.addComponent(combatcomponent);
    combatcomponent->getAttacks().attack_added.connect(
            sigc::mem_fun(this, &CharacterComponent::attackAdded));
    combatcomponent->getAttacks().attack_removed.connect(
            sigc::mem_fun(this, &CharacterComponent::attackRemoved));

    // Default knuckle attack
    int damageBase = beingComponent->getModifiedAttribute(ATTR_STR);
    int damageDelta = damageBase / 2;
    Damage knuckleDamage;
    knuckleDamage.skill = skillManager->getDefaultSkillId();
    knuckleDamage.base = damageBase;
    knuckleDamage.delta = damageDelta;
    knuckleDamage.cth = 2;
    knuckleDamage.element = ELEMENT_NEUTRAL;
    knuckleDamage.type = DAMAGE_PHYSICAL;
    knuckleDamage.range = DEFAULT_TILE_LENGTH;

    mKnuckleAttackInfo = new AttackInfo(0, knuckleDamage, 7, 3, 0);
    combatcomponent->addAttack(mKnuckleAttackInfo);

    // Get character data.
    mDatabaseID = msg.readInt32();
    beingComponent->setName(msg.readString());

    CharacterData characterData(&entity, this);
    deserializeCharacterData(characterData, msg);

    Inventory(&entity, mPossessions).initialize();
    modifiedAllAttributes(entity);;

    beingComponent->signal_attribute_changed.connect(sigc::mem_fun(
            this, &CharacterComponent::attributeChanged));
}
예제 #26
0
파일: command.cpp 프로젝트: Ablu/invertika
static void money(Character *, Character *q, int nb)
{
    Inventory(q).changeMoney(nb);
}
예제 #27
0
void Verb_Parser(int *tokens)

{
	switch(tokens[0])
	{
	case Action_move:
		{
			Move(tokens);
			break;
		}
	case Action_pick:
		{
			Pick(tokens);
			break;
		}
	case Action_put:
		{
			Put(tokens);
			break;
		}
	case Action_look:
		{
			Look(tokens);
			break;
		}
	case Action_inventory:
		{
			Inventory(tokens);
			break;
		}
	case Action_examine:
		{
			Examine(tokens);
			break;
		}
	case Action_talk:
		{
			Talk(tokens);
			break;
		}
	case Action_save:
		{
			Save(tokens);
			break;
		}
	case Action_restore:
		{
			Restore(tokens);
			break;
		}
	case Action_exit:
		{
			Exit(tokens);
			break;
		}
	default:
		{
			printf("You must start a sentence with an action verb.\n");
			break;
		}
	}
}
예제 #28
0
static void handleItem(Character *player, std::string &args)
{
    Character *other;
    ItemClass *ic;
    int value = 0;

    // get arguments
    std::string character = getArgument(args);
    std::string itemclass = getArgument(args);
    std::string valuestr = getArgument(args);

    // check all arguments are there
    if (character.empty() || itemclass.empty())
    {
        say("Invalid number of arguments given.", player);
        say("Usage: @item <character> <item> [amount]", player);
        return;
    }

    // if it contains # that means the player
    if (character == "#")
    {
        other = player;
    }
    else
    {
        // check for valid player
        other = gameHandler->getCharacterByNameSlow(character);
        if (!other)
        {
            say("Invalid character or they are offline", player);
            return;
        }
    }

    // identify the item type
    if (utils::isNumeric(itemclass))
    {
        int id = utils::stringToInt(itemclass);
        ic = itemManager->getItem(id);
    }
    else
    {
        ic = itemManager->getItemByName(itemclass);
    }
    if (!ic)
    {
        say("Invalid item", player);
        return;
    }

    //identify the amount
    if  (valuestr.empty())
    {
        value = 1;
    }
    else if (utils::isNumeric(valuestr))
    {
        value = utils::stringToInt(valuestr);
    }
    // check for valid amount
    if (value <= 0)
    {
        say("Invalid number of items", player);
        return;
    }

    // insert the item into the inventory
    Inventory(other).insert(ic->getDatabaseID(), value);

    // log transaction
    std::stringstream str;
    str << "User created item " << ic->getDatabaseID();
    accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_ITEM, str.str());
}
예제 #29
0
파일: player.cpp 프로젝트: Faultless/Dawn
Player::Player()
	:	inventory( Inventory( 10, 4, this ) )
{
	setName("Enylyn");
	movementSpeed = 1;
}
예제 #30
0
/* Constructor */
Container::Container(Drawable* drawable) : MapObject(drawable) {
   this->inv = Inventory();
}