Beispiel #1
0
Item* Creature::dropCorpse()
{
	Item* splash = NULL;
	if(getRace() == RACE_VENOM)
		splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_SLIME);
	else if(getRace() == RACE_BLOOD)
		splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);

	Tile* tile = getParentTile();
	if(splash){
		if(g_game.internalAddItem(NULL, tile, splash, INDEX_WHEREEVER, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE) == RET_NOERROR){
			g_game.startDecay(splash);
		}
		else{
			g_game.FreeThing(splash);
		}
	}

	Item* corpse = createCorpse();
	if(corpse){
		if(g_game.internalAddItem(NULL, tile, corpse, INDEX_WHEREEVER, FLAG_IGNOREBLOCKITEM | FLAG_IGNOREBLOCKCREATURE) == RET_NOERROR){
			dropLoot(corpse->getContainer());
			g_game.startDecay(corpse);
			return corpse;
		}
		else{
			g_game.FreeThing(corpse);
		}
	}

	return NULL;
}
Beispiel #2
0
std::string Character::getDescription()
{
  std::string str = colorToStr(TCODColor::darkerTurquoise, true)
      + "Class: " + (getRace() == Race::NoRace ? "" : Race2Str(getRace()) + " ")
      + CharacterClass2Str( getClass() ) +"\n \n"
      + colorToStr(TCODColor::darkTurquoise, true) + "AB: +" + toStr( getBaseAttackBonus() ) + "\n"
      + colorToStr(TCODColor::darkTurquoise, true) + "AC: " + toStr( getArmorClass() ) + "\n";

  return str;
}
Beispiel #3
0
void PNJ::setRandomName(){
	std::string cast;
	
	std::srand((unsigned int)std::time(0));
	const int taille = 150; // Taille des fichiers de nom
	int random_variable = (std::rand() % taille) +1;

	std::string characterRace = getRace()->getRaceName();
	char* raceFile;
	if(characterRace == "Dwarf"){
		cast = "NameGenerator/Orc"+sexe+"Names.txt";
	}
	else{
		cast = "NameGenerator/"+characterRace+sexe+"Names.txt";
	}
	raceFile = (char*)cast.c_str();
	std::ifstream file(raceFile, std::ios::in);

	if(file){
		std::string chaine;
		for(int i = 0; i < random_variable; i++){
			file >> chaine;
		}
		name = chaine;
	}
	else{
Beispiel #4
0
 //--------------------------------------------- SUPPLY USED ------------------------------------------------
 int PlayerImpl::supplyUsed() const
 {
   BWAPI::Race r = getRace();
   if ( r < 0 || r >= 3 )
     return 0;
   return self->supplyUsed[r];
 }
Beispiel #5
0
int main(int argc, char *argv[])
{
    //oldCall(argc, argv);
    std::string strategy;
    std::string race;
    std::string unit;
    int timeLimit = 1200;
    int population=120000;
    if (argc < 4)
    {
        std::cerr << "Usage: ./bin/runme [Unit] [Strategy] [Timelimit]" << std::endl;
        return -1;
    } else
    {
        unit = argv[1];
        strategy = argv[2];
        timeLimit = atoi(argv[3]);
        if (argc >= 5) {

            population = atoi(argv[4]);
        }
    }
    race = getRace(unit);
    std::cout << unit << "\t" << strategy << "\t" << race << std::endl;

    auto startTime = std::chrono::system_clock::now().time_since_epoch().count();
    startBuildListOptimizer(race, strategy, unit, timeLimit, population);
    auto endTime =  std::chrono::system_clock::now().time_since_epoch().count();
    std::cout << "Required the following time to run: " << (endTime-startTime)*std::chrono::system_clock::period::num/std::chrono::system_clock::period::den << "s" << std::endl;
    std::cout << "Number of threads used: " << std::to_string(std::thread::hardware_concurrency()+1) << std::endl;

    return  0;
}
uint32 Player::GetInitialFactionId()
{
    PlayerCreateInfo * pci = objmgr.GetPlayerCreateInfo(getRace(), getClass());
    if( pci )
        return pci->factiontemplate;
    else
        return 35;
}
Beispiel #7
0
uint32 Corpse::getFaction() const
{
    if (const uint8 race = getRace())
    {
        if (const ChrRacesEntry* raceEntry = sChrRacesStore.LookupEntry(race))
            return raceEntry->FactionID;
    }
    return 0;
}
Beispiel #8
0
bool Creature::dropCorpse()
{
	if (!lootDrop && getMonster() && !(master && master->getPlayer())) {
		if (master) {
			//scripting event - onDeath
			CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);

			for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) {
				(*it)->executeOnDeath(this, NULL, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
			}
		}

		g_game.addMagicEffect(getPosition(), NM_ME_POFF);
	} else {
		Item* splash = NULL;

		switch (getRace()) {
			case RACE_VENOM:
				splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN);
				break;

			case RACE_BLOOD:
				splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);
				break;

			default:
				break;
		}

		Tile* tile = getTile();

		if (splash) {
			g_game.internalAddItem(tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
			g_game.startDecay(splash);
		}

		Item* corpse = getCorpse();

		if (corpse) {
			g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
			g_game.startDecay(corpse);
		}

		//scripting event - onDeath
		CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);

		for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) {
			(*it)->executeOnDeath(this, corpse, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
		}

		if (corpse) {
			dropLoot(corpse->getContainer());
		}
	}

	return true;
}
Beispiel #9
0
void CPlayer::FakeDisplayID()
{
    if (NativeTeam())
        return;

    PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(), getClass());
    if (!info)
    {
        for (auto i = 0; i < MAX_CLASSES; ++i)
        {
            info = sObjectMgr.GetPlayerInfo(getRace(), i);
            if (info)
                break;
        }
    }

    if (!info)
    {
        sLog.outError("Player %u has incorrect race/class pair. Can't init display ids.", GetGUIDLow());
        return;
    }

    // reset scale before reapply auras
    SetObjectScale(DEFAULT_OBJECT_SCALE);

    uint8 gender = getGender();
    switch (gender)
    {
    case GENDER_FEMALE:
        SetDisplayId(info->displayId_f);
        SetNativeDisplayId(info->displayId_f);
        break;
    case GENDER_MALE:
        SetDisplayId(info->displayId_m);
        SetNativeDisplayId(info->displayId_m);
        break;
    default:
        sLog.outError("Invalid gender %u for player", gender);
        return;
    }

    SetUInt32Value(PLAYER_BYTES, getFPlayerBytes());
    SetUInt32Value(PLAYER_BYTES_2, getFPlayerBytes2());
}
Beispiel #10
0
void Creature::dropCorpse(DeathList deathList)
{
	if(master && !g_config.getBool(ConfigManager::SUMMONS_DROP_CORPSE))
	{
		g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_POFF);
		return;
	}

	Item* corpse = createCorpse(deathList);
	if(corpse)
		corpse->setParent(VirtualCylinder::virtualCylinder);

	bool deny = false;
	CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
	for(CreatureEventList::iterator it = deathEvents.begin(); it != deathEvents.end(); ++it)
	{
		if(!(*it)->executeDeath(this, corpse, deathList) && !deny)
			deny = true;
	}

	if(!corpse)
		return;

	corpse->setParent(NULL);
	if(deny)
		return;

	Tile* tile = getTile();
	if(!tile)
		return;

	Item* splash = NULL;
	switch(getRace())
	{
		case RACE_VENOM:
			splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN);
			break;

		case RACE_BLOOD:
			splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);
			break;

		default:
			break;
	}

	if(splash)
	{
		g_game.internalAddItem(NULL, tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
		g_game.startDecay(splash);
	}

	g_game.internalAddItem(NULL, tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
	dropLoot(corpse->getContainer());
	g_game.startDecay(corpse);
}
Beispiel #11
0
bool Creature::dropCorpse(Creature* lastHitCreature, Creature* mostDamageCreature, bool lastHitUnjustified, bool mostDamageUnjustified)
{
	if (!lootDrop && getMonster()) {
		if (master) {
			//scripting event - onDeath
			const CreatureEventList& deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
			for (CreatureEvent* deathEvent : deathEvents) {
				deathEvent->executeOnDeath(this, nullptr, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
			}
		}

		g_game.addMagicEffect(getPosition(), CONST_ME_POFF);
	} else {
		Item* splash;
		switch (getRace()) {
			case RACE_VENOM:
				splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN);
				break;

			case RACE_BLOOD:
				splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);
				break;

			default:
				splash = nullptr;
				break;
		}

		Tile* tile = getTile();

		if (splash) {
			g_game.internalAddItem(tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
			g_game.startDecay(splash);
		}

		Item* corpse = getCorpse(lastHitCreature, mostDamageCreature);
		if (corpse) {
			g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
			g_game.startDecay(corpse);
		}

		//scripting event - onDeath
		for (CreatureEvent* deathEvent : getCreatureEvents(CREATURE_EVENT_DEATH)) {
			deathEvent->executeOnDeath(this, corpse, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
		}

		if (corpse) {
			dropLoot(corpse->getContainer(), lastHitCreature);
		}
	}

	return true;
}
Beispiel #12
0
WorldPacket CPlayer::BuildNameQuery()
{
    WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 4 + 4 + 4 + 10));
    data << GetObjectGuid();      // player guid
    data << GetName();            // player name
    data << uint8(0);                       // realm name
    data << uint32(getRace());    // player race
    data << uint32(getGender());  // player gender
    data << uint32(getClass());   // player class
    data << uint8(0);                       // is not declined

    return data;
}
Beispiel #13
0
	void loadCompositions()
	{
		auto enemy = util::game::getEnemy();

		auto directory = "ai-data\\" + enemy->getRace().getName() + "\\compositions\\";
		fs::path path = fs::path(directory);
		std::vector<fs::path> compFiles;
		util::data::getFiles(path, ".comp", compFiles);
		
		std::cout << "Loading Compositions...  (" << compFiles.size() << ")\n";

		for each(auto compPath in compFiles)
		{
			UsedComposition usedComposition = util::data::deserializeComposition(directory + compPath.string());			
			compositionSet.push_back(usedComposition);
		}
Beispiel #14
0
void Player::FitPlayerInTeam(bool action, Battleground* pBattleGround)
{
    if (!pBattleGround)
        pBattleGround = GetBattleground();

    if ((!pBattleGround || pBattleGround->isArena()) && action)
        return;

    if(!IsPlayingNative() && action)
        setFactionForRace(getRace());
    else
        setFactionForRace(getORace());

    if (action)
        SetForgetBGPlayers(true);
    else
        SetForgetInListPlayers(true);

    MorphFit(action);

    if (pBattleGround && action)
        SendChatMessage("%sYou are playing for the %s%s in this %s", MSG_COLOR_WHITE, GetTeam() == ALLIANCE ? MSG_COLOR_DARKBLUE"alliance" : MSG_COLOR_RED"horde", MSG_COLOR_WHITE, pBattleGround->GetName());
}
Beispiel #15
0
std::string Monster::to_string() const {
    return "Monster of race " + std::to_string((int)getRace()) + "(" + std::to_string(getId()) + ")";
}
Beispiel #16
0
uint16_t Character::getMaxAttributePoints() const {
    return Data::RaceAttributes.getMaxAttributePoints(getRace());
}
Beispiel #17
0
bool Character::isBaseAttributeValid(Character::attributeIndex attribute, Attribute::attribute_t value) const {
    return Data::RaceAttributes.isBaseAttributeInLimits(getRace(), attribute, value);
}