예제 #1
0
파일: zone.cpp 프로젝트: Elkazan/darkstar
void CZone::LoadZoneSettings()
{
    static const int8* Query =
        "SELECT "
          "zone.name,"
          "zone.zoneip,"
          "zone.zoneport,"
          "zone.music_day,"
          "zone.music_night,"
          "zone.battlesolo,"
          "zone.battlemulti,"
          "zone.tax,"
          "zone.misc,"
          "zone.navmesh,"
          "zone.zonetype,"
          "bcnm.name "
        "FROM zone_settings AS zone "
        "LEFT JOIN bcnm_info AS bcnm "
        "USING (zoneid) "
        "WHERE zoneid = %u "
        "LIMIT 1";

    if (Sql_Query(SqlHandle, Query, m_zoneID) != SQL_ERROR &&
        Sql_NumRows(SqlHandle) != 0 &&
        Sql_NextRow(SqlHandle) == SQL_SUCCESS)
    {
        m_zoneName.insert(0, Sql_GetData(SqlHandle,0));

        m_zoneIP   = inet_addr(Sql_GetData(SqlHandle,1));
        m_zonePort = (uint16)Sql_GetUIntData(SqlHandle,2);
        m_zoneMusic.m_songDay = (uint8)Sql_GetUIntData(SqlHandle, 3);   // background music (day)
        m_zoneMusic.m_songNight = (uint8)Sql_GetUIntData(SqlHandle, 4);   // background music (night)
        m_zoneMusic.m_bSongS = (uint8)Sql_GetUIntData(SqlHandle,5);   // solo battle music
        m_zoneMusic.m_bSongM = (uint8)Sql_GetUIntData(SqlHandle,6);   // party battle music
        m_tax = (uint16)(Sql_GetFloatData(SqlHandle,7) * 100);      // tax for bazaar
        m_miscMask = (uint16)Sql_GetUIntData(SqlHandle,8);
        m_useNavMesh = (bool)Sql_GetIntData(SqlHandle,9);

        m_zoneType = (ZONETYPE)Sql_GetUIntData(SqlHandle, 10);

        if (Sql_GetData(SqlHandle,11) != nullptr) // сейчас нельзя использовать bcnmid, т.к. они начинаются с нуля
        {
            m_BattlefieldHandler = new CBattlefieldHandler(m_zoneID);
        }
        if (m_miscMask & MISC_TREASURE)
        {
            m_TreasurePool = new CTreasurePool(TREASUREPOOL_ZONE);
        }
    }
    else
    {
        ShowFatalError(CL_RED"CZone::LoadZoneSettings: Cannot load zone settings (%u)\n" CL_RESET, m_zoneID);
    }
}
예제 #2
0
	// Check to see if there is a list for the zone if one exists return the ListID 
	int GridList(CCharEntity* PChar)
	{

		float POSX = PChar->loc.p.x;
		float POSY = PChar->loc.p.y;
		float POSZ = PChar->loc.p.z;
		int GRIDPOSX = (POSX + POSY) / 30;
		int GRIDPOSY = (POSZ + POSY) / 30;

		const int8* Query = "SELECT ListID, x, y \
							FROM fishing_grid \
							WHERE zone = %u \
							ORDER BY zone ASC";

		int32 ret = Sql_Query(SqlHandle, Query, PChar->getZone());

		if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				int32 GX = Sql_GetIntData(SqlHandle, 1);
				int32 GY = Sql_GetIntData(SqlHandle, 2);

				if (GX == GRIDPOSX && GY == GRIDPOSY)
				{
					return Sql_GetIntData(SqlHandle, 0);
				}

if (GX == -99 && GY == -99)
{
	if (GRIDPOSX != -99 && GRIDPOSY != -99)
	{
		return Sql_GetIntData(SqlHandle, 0);
	}

}
			}
		}

		return 0;
	}
예제 #3
0
	// make sure you can catch a fish with the current bait equipped
	bool BaitCheck(uint16 BaitID, uint32 FishID)
	{
		DSP_DEBUG_BREAK_IF(BaitID == NULL);
		DSP_DEBUG_BREAK_IF(FishID == NULL);

		const int8* Query = "SELECT baitid, fishid,rare \
							FROM fishing_bait \
							WHERE baitid = %u \
							ORDER BY baitid ASC";

		int32 ret = Sql_Query(SqlHandle, Query, BaitID);
		//ShowDebug(CL_CYAN"BaitID Record's found: %u \n" CL_RESET, Sql_NumRows(SqlHandle));

		if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				uint32 ent = Sql_GetIntData(SqlHandle, 1);
				uint32 rare = Sql_GetIntData(SqlHandle, 2);

				if (ent == FishID)
				{
					// rare chance 20%
					if (rare = 1 && rand()% 100 <= 20)
					{
						return false;
					}
					else
					{
						return true;
					}

				}
			}
		}

		return false;
	}
예제 #4
0
std::vector<ahItem*> CDataLoader::GetAHItemsToCategory(uint8 AHCategoryID, int8* OrderByString)
{
    ShowDebug("try find category %u\n", AHCategoryID);

    std::vector<ahItem*> ItemList;

    const char* fmtQuery = "SELECT item_basic.itemid, item_basic.stackSize, COUNT(*)-SUM(stack), SUM(stack) "
        "FROM item_basic "
        "LEFT JOIN auction_house ON item_basic.itemId = auction_house.itemid AND auction_house.buyer_name IS NULL "
        "LEFT JOIN item_armor ON item_basic.itemid = item_armor.itemid "
        "LEFT JOIN item_weapon ON item_basic.itemid = item_weapon.itemid "
        "WHERE aH = %u "
        "GROUP BY item_basic.itemid "
        "%s";

    int32 ret = Sql_Query(SqlHandle, fmtQuery, AHCategoryID, OrderByString);

    if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            ahItem* PAHItem = new ahItem;

            PAHItem->ItemID = Sql_GetIntData(SqlHandle, 0);

            PAHItem->SinglAmount = Sql_GetIntData(SqlHandle, 2);
            PAHItem->StackAmount = Sql_GetIntData(SqlHandle, 3);

            if (Sql_GetIntData(SqlHandle, 1) == 1)
            {
                PAHItem->StackAmount = -1;
            }

            ItemList.push_back(PAHItem);
        }
    }
    return ItemList;
}
예제 #5
0
파일: zone.cpp 프로젝트: ZeDingo/darkstar
void CZone::LoadZoneLines()
{
	static const int8 fmtQuery[] = "SELECT zoneline, tozone, tox, toy, toz, rotation FROM zonelines WHERE fromzone = %u";

	int32 ret = Sql_Query(SqlHandle, fmtQuery, m_zoneID);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			zoneLine_t* zl = new zoneLine_t;

			zl->m_zoneLineID = (uint32)Sql_GetIntData(SqlHandle,0);
			zl->m_toZone  = (uint16)Sql_GetIntData(SqlHandle,1);
			zl->m_toPos.x = Sql_GetFloatData(SqlHandle,2);
			zl->m_toPos.y = Sql_GetFloatData(SqlHandle,3);
			zl->m_toPos.z = Sql_GetFloatData(SqlHandle,4);
			zl->m_toPos.rotation = (uint8)Sql_GetIntData(SqlHandle,5);

			m_zoneLineList.push_back(zl);
		}
	}
}
예제 #6
0
// get broken rod info
	uint32 GetBrokenID(uint16 RodID)
	{
		const int8* Query = "SELECT rodid, brokenid \
							FROM fishing_rods \
							WHERE rodid = %u \
							ORDER BY rodid ASC";

		int32 ret = Sql_Query(SqlHandle, Query, RodID);
	
		if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				uint32 rod = Sql_GetIntData(SqlHandle,0);
				uint32 brokeid = Sql_GetIntData(SqlHandle, 1);
				
				if (rod == RodID)
				{
					return brokeid;
				}
			}
		}
		return -1;
	}
예제 #7
0
void LoadPet(CBattleEntity* PMaster, uint32 PetID, bool spawningFromZone)
{
	DSP_DEBUG_BREAK_IF(PetID >= g_PPetList.size());
	if(PMaster->GetMJob()!=JOB_DRG && PetID == PETID_WYVERN) {
		return;
	}

	Pet_t* PPetData = g_PPetList.at(PetID);

	if (PMaster->objtype == TYPE_PC)
		((CCharEntity*)PMaster)->petZoningInfo.petID = PetID;

	PETTYPE petType = PETTYPE_JUG_PET;

	if (PetID <= PETID_CAIT_SITH)
	{
		petType = PETTYPE_AVATAR;
	}
    //TODO: move this out of modifying the global pet list
	else if (PetID==PETID_WYVERN)
	{
		petType = PETTYPE_WYVERN;

		const int8* Query =
			"SELECT\
				pet_name.name,\
				char_pet.wyvernid\
			FROM pet_name, char_pet\
			WHERE pet_name.id = char_pet.wyvernid AND \
            char_pet.charid = %u";

		if ( Sql_Query(SqlHandle, Query, PMaster->id) != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				uint16 wyvernid = (uint16)Sql_GetIntData(SqlHandle, 1);

				if (wyvernid != 0)
				{
					g_PPetList.at(PetID)->name.clear();
					g_PPetList.at(PetID)->name.insert(0, Sql_GetData(SqlHandle, 0));
				}
			}
		}
	}
예제 #8
0
    /**************************************************************
    Called by ALL BCNMs to check winning conditions every tick. This
    is usually when all the monsters are defeated but can be other things
    (e.g. mob below X% HP, successful Steal, etc)
    ***************************************************************/
    bool meetsWinningConditions(CBattlefield* battlefield, time_point tick) {

        if (battlefield->won()) return true;

        //handle odd cases e.g. stop fight @ x% HP

        //handle Maat fights
        if (battlefield->locked && (battlefield->m_RuleMask & RULES_MAAT))
        {
            // survive for 5 mins
            if (battlefield->getPlayerMainJob() == JOB_WHM && (tick - battlefield->fightTick) > 5min)
                return true;

            if (battlefield->isEnemyBelowHPP(10))
                return true;


            if (battlefield->getPlayerMainJob() == JOB_THF && battlefield->m_EnemyList.at(0)->m_ItemStolen) //thf can win by stealing from maat only if maat not previously defeated
            {
                const int8* fmtQuery = "SELECT value FROM char_vars WHERE charid = %u AND varname = '%s' LIMIT 1;";
                int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->m_PlayerList.at(0)->id, "maatDefeated");
                if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) == 0)
                    return true;
                else if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
                {
                    int16 value = (int16)Sql_GetIntData(SqlHandle, 0);
                    if (value <= 0)
                        return true;
                }
            }
        }

        // savage
        if (battlefield->getID() == 961 && battlefield->isEnemyBelowHPP(30)) {
            return true;
        }

        //generic cases, kill all mobs
        if (battlefield->allEnemiesDefeated()) {
            return true;
        }
        return false;
    }
/************************************************************************
* *
* *
* *
************************************************************************/
void LoadEffectsParameters()
{
for (uint16 i = 0; i < MAX_EFFECTID; ++i)
{
EffectsParams[i].Flag = 0;
}
int32 ret = Sql_Query(SqlHandle, "SELECT id, name, flags, type, negative_id, overwrite, block_id, remove_id, element FROM status_effects WHERE id < %u", MAX_EFFECTID);
if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
{
while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
uint16 EffectID = (uint16)Sql_GetIntData(SqlHandle,0);
EffectsParams[EffectID].Name = Sql_GetData(SqlHandle,1);
EffectsParams[EffectID].Flag = Sql_GetIntData(SqlHandle,2);
EffectsParams[EffectID].Type = Sql_GetIntData(SqlHandle,3);
EffectsParams[EffectID].NegativeId = (EFFECT)Sql_GetIntData(SqlHandle,4);
EffectsParams[EffectID].Overwrite = (EFFECTOVERWRITE)Sql_GetIntData(SqlHandle,5);
EffectsParams[EffectID].BlockId = (EFFECT)Sql_GetIntData(SqlHandle,6);
EffectsParams[EffectID].RemoveId = (EFFECT)Sql_GetIntData(SqlHandle,7);
EffectsParams[EffectID].Element = Sql_GetIntData(SqlHandle,8);
}
}
}
예제 #10
0
    void LoadLinkshellList()
    {
	    int32 ret = Sql_Query(SqlHandle, "SELECT linkshellid, color, name, poster, message, messagetime FROM linkshells");

	    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	    {
		    while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		    {
			    CLinkshell* PLinkshell = new CLinkshell(Sql_GetUIntData(SqlHandle,0));
			
			    PLinkshell->setColor(Sql_GetIntData(SqlHandle,1));
                int8 EncodedName[16];
                EncodeStringLinkshell(Sql_GetData(SqlHandle,2), EncodedName);
                PLinkshell->setName(EncodedName);
                PLinkshell->setPoster(Sql_GetData(SqlHandle,3));
                PLinkshell->setMessage(Sql_GetData(SqlHandle,4));
                PLinkshell->setMessageTime(Sql_GetUIntData(SqlHandle,5));

                LinkshellList[PLinkshell->getID()] = PLinkshell;
		    }
	    }
    }
예제 #11
0
	void LoadConquestSystem()
	{
		int8 regNum = 0;
		const int8* Query =
        "SELECT region_id, region_control, sandoria_influence, bastok_influence, windurst_influence, beastmen_influence, graphics_arrows FROM conquest_system";

		int32 ret = Sql_Query(SqlHandle, Query);

		if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				g_Conquest[regNum][0] = (uint32)Sql_GetIntData(SqlHandle,0); // Region ID
				g_Conquest[regNum][1] = (uint32)Sql_GetIntData(SqlHandle,1); // Region Control
				g_Conquest[regNum][2] = (uint32)Sql_GetIntData(SqlHandle,2); // Influence of sandoria
				g_Conquest[regNum][3] = (uint32)Sql_GetIntData(SqlHandle,3); // Influence of bastok
				g_Conquest[regNum][4] = (uint32)Sql_GetIntData(SqlHandle,4); // Influence of windurst
				g_Conquest[regNum][5] = (uint32)Sql_GetIntData(SqlHandle,5); // Influence of beastmen
				g_Conquest[regNum][6] = (uint32)Sql_GetIntData(SqlHandle,6); // Number for graphics with arrows
				regNum++;
			}
		}
	}
예제 #12
0
void LoadNPCList()
{
    const int8* Query =
        "SELECT \
          zoneid,\
          npcid,\
          name,\
          pos_rot,\
          pos_x,\
          pos_y,\
          pos_z,\
          flag,\
          speed,\
          speedsub,\
          animation,\
          animationsub,\
          namevis,\
          status,\
          unknown,\
          look,\
          name_prefix \
        FROM npc_list \
        WHERE npcid < 1024;";

    int32 ret = Sql_Query(SqlHandle, Query);

    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);

            if (GetZone(ZoneID)->GetType() != ZONETYPE_DUNGEON_INSTANCED)
            {
                CNpcEntity* PNpc = new CNpcEntity;
                PNpc->targid = (uint16)Sql_GetUIntData(SqlHandle, 1);
                PNpc->id = (uint32)PNpc->targid + (ZoneID << 12) + 0x1000000;

                PNpc->name.insert(0, Sql_GetData(SqlHandle, 2));

                PNpc->loc.p.rotation = (uint8)Sql_GetIntData(SqlHandle, 3);
                PNpc->loc.p.x = Sql_GetFloatData(SqlHandle, 4);
                PNpc->loc.p.y = Sql_GetFloatData(SqlHandle, 5);
                PNpc->loc.p.z = Sql_GetFloatData(SqlHandle, 6);
                PNpc->loc.p.moving = (uint16)Sql_GetUIntData(SqlHandle, 7);

                PNpc->m_TargID = (uint32)Sql_GetUIntData(SqlHandle, 7) >> 16; // вполне вероятно

                PNpc->speed = (uint8)Sql_GetIntData(SqlHandle, 8);
                PNpc->speedsub = (uint8)Sql_GetIntData(SqlHandle, 9);
                PNpc->animation = (uint8)Sql_GetIntData(SqlHandle, 10);
                PNpc->animationsub = (uint8)Sql_GetIntData(SqlHandle, 11);

                PNpc->namevis = (uint8)Sql_GetIntData(SqlHandle, 12);
                PNpc->status = (STATUSTYPE)Sql_GetIntData(SqlHandle, 13);
                PNpc->unknown = (uint32)Sql_GetUIntData(SqlHandle, 14);

                PNpc->name_prefix = (uint8)Sql_GetIntData(SqlHandle, 16);

                memcpy(&PNpc->look, Sql_GetData(SqlHandle, 15), 20);

                GetZone(ZoneID)->InsertNPC(PNpc);
                luautils::OnNpcSpawn(PNpc);
            }
        }
    }
예제 #13
0
CMobEntity* InstantiateAlly(uint32 groupid, uint16 zoneID, CInstance* instance)
{
	const char* Query =
		"SELECT zoneid, name, \
		respawntime, spawntype, dropid, mob_groups.HP, mob_groups.MP, minLevel, maxLevel, \
		modelid, mJob, sJob, cmbSkill, cmbDmgMult, cmbDelay, behavior, links, mobType, immunity, \
		systemid, mobsize, speed, \
		STR, DEX, VIT, AGI, `INT`, MND, CHR, EVA, DEF, \
		Slash, Pierce, H2H, Impact, \
		Fire, Ice, Wind, Earth, Lightning, Water, Light, Dark, Element, \
		mob_pools.familyid, name_prefix, entityFlags, animationsub, \
		(mob_family_system.HP / 100), (mob_family_system.MP / 100), hasSpellScript, spellList, ATT, ACC, mob_groups.poolid, \
		allegiance, namevis, aggro, mob_pools.skill_list_id, mob_pools.true_detection, mob_family_system.detects, packet_name \
		FROM mob_groups INNER JOIN mob_pools ON mob_groups.poolid = mob_pools.poolid \
		INNER JOIN mob_family_system ON mob_pools.familyid = mob_family_system.familyid \
		WHERE mob_groups.groupid = %u";

	int32 ret = Sql_Query(SqlHandle, Query, groupid);

	CMobEntity* PMob = nullptr;

	if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		if (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			PMob = new CMobEntity;
            PMob->PInstance = instance;

			PMob->name.insert(0, (const char*)Sql_GetData(SqlHandle, 1));
            PMob->packetName.insert(0, (const char*)Sql_GetData(SqlHandle, 61));

			PMob->m_RespawnTime = Sql_GetUIntData(SqlHandle, 2) * 1000;
			PMob->m_SpawnType = (SPAWNTYPE)Sql_GetUIntData(SqlHandle, 3);
			PMob->m_DropID = Sql_GetUIntData(SqlHandle, 4);

			PMob->HPmodifier = (uint32)Sql_GetIntData(SqlHandle, 5);
			PMob->MPmodifier = (uint32)Sql_GetIntData(SqlHandle, 6);

			PMob->m_minLevel = (uint8)Sql_GetIntData(SqlHandle, 7);
			PMob->m_maxLevel = (uint8)Sql_GetIntData(SqlHandle, 8);

			memcpy(&PMob->look, Sql_GetData(SqlHandle, 9), 23);

			PMob->SetMJob(Sql_GetIntData(SqlHandle, 10));
			PMob->SetSJob(Sql_GetIntData(SqlHandle, 11));

			PMob->m_Weapons[SLOT_MAIN]->setMaxHit(1);
			PMob->m_Weapons[SLOT_MAIN]->setSkillType(Sql_GetIntData(SqlHandle, 12));
			PMob->m_dmgMult = Sql_GetUIntData(SqlHandle, 13);
			PMob->m_Weapons[SLOT_MAIN]->setDelay((Sql_GetIntData(SqlHandle, 14) * 1000) / 60);
			PMob->m_Weapons[SLOT_MAIN]->setBaseDelay((Sql_GetIntData(SqlHandle, 14) * 1000) / 60);

			PMob->m_Behaviour = (uint16)Sql_GetIntData(SqlHandle, 15);
			PMob->m_Link = (uint8)Sql_GetIntData(SqlHandle, 16);
			PMob->m_Type = (uint8)Sql_GetIntData(SqlHandle, 17);
			PMob->m_Immunity = (IMMUNITY)Sql_GetIntData(SqlHandle, 18);
			PMob->m_EcoSystem = (ECOSYSTEM)Sql_GetIntData(SqlHandle, 19);
			PMob->m_ModelSize = (uint8)Sql_GetIntData(SqlHandle, 10);

			PMob->speed = (uint8)Sql_GetIntData(SqlHandle, 21);
			PMob->speedsub = (uint8)Sql_GetIntData(SqlHandle, 21);

			/*if(PMob->speed != 0)
			{
			PMob->speed += map_config.speed_mod;
			// whats this for?
			PMob->speedsub += map_config.speed_mod;
			}*/

			PMob->strRank = (uint8)Sql_GetIntData(SqlHandle, 22);
			PMob->dexRank = (uint8)Sql_GetIntData(SqlHandle, 23);
			PMob->vitRank = (uint8)Sql_GetIntData(SqlHandle, 24);
			PMob->agiRank = (uint8)Sql_GetIntData(SqlHandle, 25);
			PMob->intRank = (uint8)Sql_GetIntData(SqlHandle, 26);
			PMob->mndRank = (uint8)Sql_GetIntData(SqlHandle, 27);
			PMob->chrRank = (uint8)Sql_GetIntData(SqlHandle, 28);
			PMob->evaRank = (uint8)Sql_GetIntData(SqlHandle, 29);
			PMob->defRank = (uint8)Sql_GetIntData(SqlHandle, 30);
			PMob->attRank = (uint8)Sql_GetIntData(SqlHandle, 52);
			PMob->accRank = (uint8)Sql_GetIntData(SqlHandle, 53);

			PMob->setModifier(Mod::SLASHRES, (uint16)(Sql_GetFloatData(SqlHandle, 31) * 1000));
			PMob->setModifier(Mod::PIERCERES, (uint16)(Sql_GetFloatData(SqlHandle, 32) * 1000));
			PMob->setModifier(Mod::HTHRES, (uint16)(Sql_GetFloatData(SqlHandle, 33) * 1000));
			PMob->setModifier(Mod::IMPACTRES, (uint16)(Sql_GetFloatData(SqlHandle, 34) * 1000));

			PMob->setModifier(Mod::FIRERES, (int16)((Sql_GetFloatData(SqlHandle, 35) - 1) * -100)); // These are stored as floating percentages
			PMob->setModifier(Mod::ICERES, (int16)((Sql_GetFloatData(SqlHandle, 36) - 1) * -100)); // and need to be adjusted into modifier units.
			PMob->setModifier(Mod::WINDRES, (int16)((Sql_GetFloatData(SqlHandle, 37) - 1) * -100)); // Higher RES = lower damage.
			PMob->setModifier(Mod::EARTHRES, (int16)((Sql_GetFloatData(SqlHandle, 38) - 1) * -100)); // Negatives signify lower resist chance.
			PMob->setModifier(Mod::THUNDERRES, (int16)((Sql_GetFloatData(SqlHandle, 39) - 1) * -100)); // Positives signify increased resist chance.
			PMob->setModifier(Mod::WATERRES, (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -100));
			PMob->setModifier(Mod::LIGHTRES, (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -100));
			PMob->setModifier(Mod::DARKRES, (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -100));

			PMob->m_Element = (uint8)Sql_GetIntData(SqlHandle, 43);
			PMob->m_Family = (uint16)Sql_GetIntData(SqlHandle, 44);
			PMob->m_name_prefix = (uint8)Sql_GetIntData(SqlHandle, 45);
			PMob->m_flags = (uint32)Sql_GetIntData(SqlHandle, 46);

			//Special sub animation for Mob (yovra, jailer of love, phuabo)
			// yovra 1: en hauteur, 2: en bas, 3: en haut
			// phuabo 1: sous l'eau, 2: sort de l'eau, 3: rentre dans l'eau
			PMob->animationsub = (uint32)Sql_GetIntData(SqlHandle, 47);

			// Setup HP / MP Stat Percentage Boost
			PMob->HPscale = Sql_GetFloatData(SqlHandle, 48);
			PMob->MPscale = Sql_GetFloatData(SqlHandle, 49);

			// Check if we should be looking up scripts for this mob
			PMob->m_HasSpellScript = (uint8)Sql_GetIntData(SqlHandle, 50);

			PMob->m_SpellListContainer = mobSpellList::GetMobSpellList(Sql_GetIntData(SqlHandle, 51));

			PMob->m_Pool = Sql_GetUIntData(SqlHandle, 54);

			PMob->allegiance = Sql_GetUIntData(SqlHandle, 55);
			PMob->namevis = Sql_GetUIntData(SqlHandle, 56);
			PMob->m_Aggro = Sql_GetUIntData(SqlHandle, 57);
			PMob->m_MobSkillList = Sql_GetUIntData(SqlHandle, 58);
			PMob->m_TrueDetection = Sql_GetUIntData(SqlHandle, 59);
			PMob->m_Detects = Sql_GetUIntData(SqlHandle, 60);

			// must be here first to define mobmods
			mobutils::InitializeMob(PMob, zoneutils::GetZone(zoneID));

			zoneutils::GetZone(zoneID)->InsertPET(PMob);

			luautils::OnMobInitialize(PMob);
            luautils::ApplyMixins(PMob);

			PMob->saveModifiers();
			PMob->saveMobModifiers();
		}
	}
	return PMob;
}
예제 #14
0
/*
Loads up custom mob mods from mob_pool_mods and mob_family_mods table. This will allow you to customize
a mobs regen rate, magic defense, triple attack rate from a table instead of hardcoding it.

Usage:

	Evil weapons have a magic defense boost. So pop that into mob_family_mods table.
	Goblin Diggers have a vermin killer trait, so find its poolid and put it in mod_pool_mods table.

*/
void LoadCustomMods()
{

	// load family mods
	const char QueryFamilyMods[] = "SELECT familyid, modid, value, is_mob_mod FROM mob_family_mods;";

    int32 ret = Sql_Query(SqlHandle, QueryFamilyMods);

	if(ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			ModsList_t* familyMods = GetMobFamilyMods(Sql_GetUIntData(SqlHandle,0), true);

			CModifier* mod = new CModifier(static_cast<Mod>(Sql_GetUIntData(SqlHandle,1)));
			mod->setModAmount(Sql_GetIntData(SqlHandle,2));

			int8 isMobMod = Sql_GetIntData(SqlHandle,3);
			if(isMobMod == 1)
			{
				familyMods->mobMods.push_back(mod);
			}
			else
			{
				familyMods->mods.push_back(mod);
			}
		}
	}

	// load pool mods
	const char QueryPoolMods[] = "SELECT poolid, modid, value, is_mob_mod FROM mob_pool_mods;";

    ret = Sql_Query(SqlHandle, QueryPoolMods);

	if(ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			uint16 pool = Sql_GetUIntData(SqlHandle,0);
			ModsList_t* poolMods = GetMobPoolMods(pool, true);

			Mod id = static_cast<Mod>(Sql_GetUIntData(SqlHandle,1));


			CModifier* mod = new CModifier(id);
			mod->setModAmount(Sql_GetUIntData(SqlHandle,2));

			int8 isMobMod = Sql_GetIntData(SqlHandle,3);
			if(isMobMod == 1)
			{
				poolMods->mobMods.push_back(mod);
			}
			else
			{
				poolMods->mods.push_back(mod);
			}
		}
	}

	// load spawn mods
	const char QuerySpawnMods[] = "SELECT mobid, modid, value, is_mob_mod FROM mob_spawn_mods;";

    ret = Sql_Query(SqlHandle, QuerySpawnMods);

	if(ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
			ModsList_t* spawnMods = GetMobSpawnMods(Sql_GetUIntData(SqlHandle,0), true);

			CModifier* mod = new CModifier(static_cast<Mod>(Sql_GetUIntData(SqlHandle,1)));
			mod->setModAmount(Sql_GetUIntData(SqlHandle,2));

			int8 isMobMod = Sql_GetIntData(SqlHandle,3);
			if(isMobMod == 1)
			{
				spawnMods->mobMods.push_back(mod);
			}
			else
			{
				spawnMods->mods.push_back(mod);
			}
		}
	}
}
예제 #15
0
bool CheckFisherLuck(CCharEntity* PChar)
{
	if (PChar->UContainer->GetType() != UCONTAINER_EMPTY)
	{
		ShowDebug(CL_CYAN"Player cannot fish! UContainer is not empty\n" CL_RESET);
		return false;
	}

	CItemFish* PFish = nullptr;
	CItemWeapon* WeaponItem = nullptr;

	WeaponItem = (CItemWeapon*)PChar->getEquip(SLOT_RANGED);	

	DSP_DEBUG_BREAK_IF(WeaponItem == nullptr);
	DSP_DEBUG_BREAK_IF(WeaponItem->isType(ITEM_WEAPON) == false);
	DSP_DEBUG_BREAK_IF(WeaponItem->getSkillType() != SKILL_FSH);

	uint16 RodID = WeaponItem->getID();

	WeaponItem = (CItemWeapon*)PChar->getEquip(SLOT_AMMO);	
							
	DSP_DEBUG_BREAK_IF(WeaponItem == nullptr);
	DSP_DEBUG_BREAK_IF(WeaponItem->isType(ITEM_WEAPON) == false);
	DSP_DEBUG_BREAK_IF(WeaponItem->getSkillType() != SKILL_FSH);

	uint16 LureID = WeaponItem->getID();

	int32 FishingChance = WELL512::irand()%100;

	if (FishingChance <= 20)
	{
		const int8* Query = 
            "SELECT "
                "fish.fishid,"      // 0
                "fish.max,"         // 1
                "fish.watertype,"   // 2
                "fish.size,"        // 3
                "fish.stamina,"     // 4
                "fish.log,"         // 5
                "fish.quest,"       // 6
                "rod.flag "         // 7
            "FROM fishing_zone AS zone "
			"INNER JOIN fishing_rod  AS rod  USING (fishid) "
			"INNER JOIN fishing_lure AS lure USING (fishid) "
			"INNER JOIN fishing_fish AS fish USING (fishid) "
			"WHERE zone.zoneid = %u AND rod.rodid = %u AND lure.lureid = %u AND lure.luck = 0";

		int32 ret = Sql_Query(SqlHandle, Query, PChar->getZone(), RodID, LureID);

		if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
            while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
                // ловля предметов, необходимых для поисков

                uint8 logid = (uint8)Sql_GetIntData(SqlHandle,5);
                uint8 quest = (uint8)Sql_GetIntData(SqlHandle,6);

                if(logid < MAX_QUESTAREA && quest < MAX_QUESTID)
	            {
		            uint8 current  = PChar->m_questLog[logid].current [quest/8] & (1 << (quest % 8));
		            uint8 complete = PChar->m_questLog[logid].complete[quest/8] & (1 << (quest % 8));

                    if (complete == 0 && current != 0)
                    {
		                PFish = new CItemFish(*itemutils::GetItemPointer(Sql_GetIntData(SqlHandle,0)));

					    PChar->UContainer->SetType(UCONTAINER_FISHING);
					    PChar->UContainer->SetItem(0, PFish);
					    break;
                    }
	            }
                // TODO: ловля простых предметов
            }
		}						
	}
	else
	{
		const int8* Query = 
            "SELECT "
                "fish.fishid,"      // 0
                "fish.min,"         // 1
                "fish.max,"         // 2
                "fish.size,"        // 3
                "fish.stamina,"     // 4
                "fish.watertype,"   // 5
                "rod.flag, "         // 6
                "lure.luck "        // 7
            "FROM fishing_zone AS zone "
            "INNER JOIN fishing_rod  AS rod  USING (fishid) "
			"INNER JOIN fishing_lure AS lure USING (fishid) "
			"INNER JOIN fishing_fish AS fish USING (fishid) "
			"WHERE zone.zoneid = %u AND rod.rodid = %u AND lure.lureid = %u AND lure.luck != 0 "
			"ORDER BY luck"; 
		
		int32 ret = Sql_Query(SqlHandle, Query, PChar->getZone(), RodID, LureID);

		if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			int32 FisherLuck = 0;
			int32 FishingChance = WELL512::irand()%1000;

			while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
			{
				FisherLuck += Sql_GetIntData(SqlHandle,7);

				if (FishingChance <= FisherLuck)
				{
					PFish = new CItemFish(*itemutils::GetItemPointer(Sql_GetIntData(SqlHandle,0)));

					PChar->UContainer->SetType(UCONTAINER_FISHING);
					PChar->UContainer->SetItem(0, PFish);
					break;
				}	
			}
		}
	}

	return (PFish != nullptr);
}
예제 #16
0
std::list<SearchEntity*> CDataLoader::GetPlayersList(search_req sr, int* count)
{
    std::list<SearchEntity*> PlayersList;
    std::string filterQry = "";
    if (sr.jobid > 0 && sr.jobid < 21){
        filterQry.append(" AND ");
        filterQry.append(" mjob = ");
        filterQry.append(std::to_string(static_cast<unsigned long long>(sr.jobid)));
    }
    if (sr.zoneid[0] > 0) {
        string_t zoneList;
        int i = 1;
        zoneList.append(std::to_string(static_cast<unsigned long long>(sr.zoneid[0])));
        while (i < 10 && sr.zoneid[i] != 0)
        {
            zoneList.append(", ");
            zoneList.append(std::to_string(static_cast<unsigned long long>(sr.zoneid[i])));
            i++;
        }
        filterQry.append(" AND ");
        filterQry.append("(pos_zone IN (");
        filterQry.append(zoneList);
        filterQry.append(") OR (pos_zone = 0 AND pos_prevzone IN (");
        filterQry.append(zoneList);
        filterQry.append("))) ");
    }

    std::string fmtQuery = "SELECT charid, partyid, charname, pos_zone, pos_prevzone, nation, rank_sandoria, rank_bastok, rank_windurst, race, nameflags, mjob, sjob, mlvl, slvl "
        "FROM accounts_sessions "
        "LEFT JOIN accounts_parties USING (charid) "
        "LEFT JOIN chars USING (charid) "
        "LEFT JOIN char_look USING (charid) "
        "LEFT JOIN char_stats USING (charid) "
        "LEFT JOIN char_profile USING(charid) "
        "WHERE charname IS NOT NULL ";
    fmtQuery.append(filterQry);
    fmtQuery.append(" ORDER BY charname ASC");

    int32 ret = Sql_Query(SqlHandle, fmtQuery.c_str());

    if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        int totalResults = 0; //gives ALL matching criteria (total)
        int visibleResults = 0; //capped at first 20
        while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            SearchEntity* PPlayer = new SearchEntity;
            memset(PPlayer, 0, sizeof(SearchEntity));

            memcpy(PPlayer->name, Sql_GetData(SqlHandle, 2), 15);

            PPlayer->id = (uint32)Sql_GetUIntData(SqlHandle, 0);
            PPlayer->zone = (uint16)Sql_GetIntData(SqlHandle, 3);
            PPlayer->prevzone = (uint16)Sql_GetIntData(SqlHandle, 4);
            PPlayer->nation = (uint8)Sql_GetIntData(SqlHandle, 5);
            PPlayer->mjob = (uint8)Sql_GetIntData(SqlHandle, 11);
            PPlayer->sjob = (uint8)Sql_GetIntData(SqlHandle, 12);
            PPlayer->mlvl = (uint8)Sql_GetIntData(SqlHandle, 13);
            PPlayer->slvl = (uint8)Sql_GetIntData(SqlHandle, 14);
            PPlayer->race = (uint8)Sql_GetIntData(SqlHandle, 9);
            PPlayer->rank = (uint8)Sql_GetIntData(SqlHandle, 6 + PPlayer->nation);

            PPlayer->zone = (PPlayer->zone == 0 ? PPlayer->prevzone : PPlayer->zone);

            uint32 partyid = (uint32)Sql_GetUIntData(SqlHandle, 1);
            uint32 nameflag = (uint32)Sql_GetUIntData(SqlHandle, 10);

            if (partyid == PPlayer->id) PPlayer->flags1 |= 0x0008;
            if (nameflag & FLAG_AWAY)   PPlayer->flags1 |= 0x0100;
            if (nameflag & FLAG_DC)     PPlayer->flags1 |= 0x0800;
            if (partyid != 0)           PPlayer->flags1 |= 0x2000;
            if (nameflag & FLAG_ANON)   PPlayer->flags1 |= 0x4000;
            if (nameflag & FLAG_INVITE) PPlayer->flags1 |= 0x8000;

            PPlayer->flags2 = PPlayer->flags1;

            // TODO: search comments

            // filter by job
            if (sr.jobid > 0 && sr.jobid != PPlayer->mjob)
                continue;

            // filter by nation
            if (sr.nation != 255 && sr.nation != PPlayer->nation)
                continue;

            // filter by race
            if (sr.race != 255)
            {
                // hume (male/female)
                if (sr.race == 0 && (PPlayer->race != 1 && PPlayer->race != 2))
                    continue;
                // elvaan (male/female)
                else if (sr.race == 1 && (PPlayer->race != 3 && PPlayer->race != 4))
                    continue;
                // tarutaru (male/female)
                else if (sr.race == 2 && (PPlayer->race != 5 && PPlayer->race != 6))
                    continue;
                // mithra (female only)
                else if (sr.race == 3 && PPlayer->race != 7)
                    continue;
                // galka (male only)
                else if (sr.race == 4 && PPlayer->race != 8)
                    continue;
            }

            // filter by rank
            if (sr.minRank > 0 && sr.maxRank >= sr.minRank)
            {
                if (PPlayer->rank < sr.minRank || PPlayer->rank > sr.maxRank)
                    continue;
            }

            // filter by flag (away, seek party etc.)
            if (sr.flags != 0 && !(PPlayer->flags2 & sr.flags))
                continue;

            // filter by level
            if (sr.minlvl > 0 && sr.maxlvl >= sr.minlvl){
                if (PPlayer->mlvl < sr.minlvl || PPlayer->mlvl > sr.maxlvl)
                    continue;
            }

            // filter by name
            if (sr.nameLen > 0){
                string_t dbname;
                dbname.insert(0, (char*)PPlayer->name);

                //can't be this name, too long
                if (sr.nameLen > dbname.length()){
                    continue;
                }
                bool validName = true;
                for (int i = 0; i < sr.nameLen; i++){
                    //convert to lowercase for both
                    if (tolower(sr.name[i]) != tolower(PPlayer->name[i])){
                        validName = false;
                        break;
                    }
                }
                if (!validName){
                    continue;
                }
            }
            // dont show hidden gm
            if (nameflag & FLAG_ANON && nameflag & FLAG_GM)
            {
                continue;
            }
            if (visibleResults < 20){
                PlayersList.push_back(PPlayer);
                visibleResults++;
            }
            totalResults++;
        }
        if (totalResults > 0){
            *count = totalResults;
        }
        ShowMessage("Found %i results, displaying %i. \n", totalResults, visibleResults);
    }

    return PlayersList;
}
예제 #17
0
void CTransportHandler::InitializeTransport()
{
    DSP_DEBUG_BREAK_IF(TransportList.size() != 0);

    const int8* fmtQuery = "SELECT id, transport, door, dock_x, dock_y, dock_z, dock_rot, boundary, zone, anim_arrive, anim_depart, time_offset, time_interval, time_waiting, time_anim_arrive, time_anim_depart  FROM transport;";

	int32 ret = Sql_Query(SqlHandle, fmtQuery);

	if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		{
            Transport_t* PTransport = new Transport_t;

            PTransport->Dock.zone = zoneutils::GetZone((Sql_GetUIntData(SqlHandle,1) >> 12) & 0x0FFF);
            PTransport->Dock.p.x  = Sql_GetFloatData(SqlHandle,3);
            PTransport->Dock.p.y  = Sql_GetFloatData(SqlHandle,4);
            PTransport->Dock.p.z  = Sql_GetFloatData(SqlHandle,5);
            PTransport->Dock.p.rotation = (uint8) Sql_GetIntData(SqlHandle,6);
            PTransport->Dock.boundary   = (uint16)Sql_GetIntData(SqlHandle,7);
            PTransport->Dock.prevzone   = (uint8) Sql_GetIntData(SqlHandle,8);

            PTransport->PDoorNPC      = zoneutils::GetEntity(Sql_GetUIntData(SqlHandle,2), TYPE_NPC);
            PTransport->PTransportNPC = zoneutils::GetEntity(Sql_GetUIntData(SqlHandle,1), TYPE_SHIP);

            PTransport->AnimationArrive = (uint8)Sql_GetIntData(SqlHandle, 9);
            PTransport->AnimationDepart = (uint8)Sql_GetIntData(SqlHandle,10);

            PTransport->TimeOffset   = (uint16)Sql_GetIntData(SqlHandle,11);
            PTransport->TimeInterval = (uint16)Sql_GetIntData(SqlHandle,12);
            PTransport->TimeWaiting  = (uint16)Sql_GetIntData(SqlHandle,13);
            PTransport->TimeAnimationArrive = (uint16)Sql_GetIntData(SqlHandle,14);
            PTransport->TimeAnimationDepart = (uint16)Sql_GetIntData(SqlHandle,15);

            if (PTransport->PDoorNPC == NULL ||
                PTransport->PTransportNPC == NULL)
            {
                ShowError("Transport <%u>: transport or door not found\n", (uint8)Sql_GetIntData(SqlHandle,0));
                delete PTransport;
                continue;
            }
            if (PTransport->TimeAnimationArrive < 10)
            {
                ShowError("Transport <%u>: time_anim_arrive must be > 10\n", (uint8)Sql_GetIntData(SqlHandle,0));
                delete PTransport;
                continue;
            }
            if (PTransport->TimeInterval < PTransport->TimeAnimationArrive + PTransport->TimeWaiting + PTransport->TimeAnimationDepart)
            {
                ShowError("Transport <%u>: time_interval must be > time_anim_arrive + time_waiting + time_anim_depart\n", (uint8)Sql_GetIntData(SqlHandle,0));
                delete PTransport;
                continue;
            }
            PTransport->PTransportNPC->name.resize(8);
            TransportList.push_back(PTransport);
        }
    }
}
예제 #18
0
    void LoadItemList()
	{
		PROFILE_FUNC();
	    memset(g_pItemList,0,sizeof(g_pItemList));
	    memset(g_pDropList,0,sizeof(g_pDropList));

	    const int8* Query =    
            "SELECT "
                "b.itemId,"         //  0
                "b.name,"           //  1
                "b.stackSize,"      //  2
                "b.flags,"          //  3
                "b.aH,"             //  4
                "b.BaseSell,"       //  5
			    "b.subid,"          //  6

                "u.validTargets,"   //  7
                "u.activation,"     //  8
                "u.animation,"      //  9
                "u.animationTime,"  // 10
                "u.maxCharges,"     // 11
                "u.useDelay,"       // 12
                "u.reuseDelay,"     // 13
                "u.aoe,"            // 14
								       
                "a.level,"          // 15
                "a.jobs,"           // 16
                "a.MId,"            // 17
                "a.shieldSize,"     // 18
                "a.scriptType,"     // 19
                "a.slot,"           // 20
                "a.rslot,"          // 21

			    "w.skill,"          // 22
				"w.subskill,"       // 23
                "w.delay,"          // 24
                "w.dmg,"            // 25
                "w.dmgType,"        // 26
                "w.hit,"            // 27
                "w.unlock_index,"   // 28
								       
                "f.storage,"        // 29
                "f.moghancement,"   // 30
                "f.element,"        // 31
                "f.aura,"           // 32

                "p.slot,"           // 33
                "p.element "        // 34
		    "FROM item_basic AS b "
		    "LEFT JOIN item_usable AS u USING (itemId) "
		    "LEFT JOIN item_armor  AS a USING (itemId) "
		    "LEFT JOIN item_weapon AS w USING (itemId) "
		    "LEFT JOIN item_furnishing AS f USING (itemId) "
            "LEFT JOIN item_puppet AS p USING (itemId) "
		    "WHERE itemId < %u;";

	    int32 ret = Sql_Query(SqlHandle, Query, MAX_ITEMID);

	    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	    {
		    while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		    {
			    CItem* PItem = CreateItem(Sql_GetUIntData(SqlHandle,0));

			    if(PItem != NULL)
			    {
				    PItem->setName(Sql_GetData(SqlHandle,1));
				    PItem->setStackSize(Sql_GetUIntData(SqlHandle,2));
				    PItem->setFlag(Sql_GetUIntData(SqlHandle,3));
				    PItem->setAHCat(Sql_GetUIntData(SqlHandle,4));
				    PItem->setBasePrice(Sql_GetUIntData(SqlHandle,5));
					PItem->setSubID(Sql_GetUIntData(SqlHandle,6));
				
				    if (PItem->isType(ITEM_GENERAL))
				    {

				    }
				    if (PItem->isType(ITEM_USABLE))
				    {
					    ((CItemUsable*)PItem)->setValidTarget(Sql_GetUIntData(SqlHandle,7));
					    ((CItemUsable*)PItem)->setActivationTime(Sql_GetUIntData(SqlHandle,8)*1000);
					    ((CItemUsable*)PItem)->setAnimationID(Sql_GetUIntData(SqlHandle,9));
					    ((CItemUsable*)PItem)->setAnimationTime(Sql_GetUIntData(SqlHandle,10)*1000);
					    ((CItemUsable*)PItem)->setMaxCharges(Sql_GetUIntData(SqlHandle,11));
					    ((CItemUsable*)PItem)->setCurrentCharges(Sql_GetUIntData(SqlHandle,11));
					    ((CItemUsable*)PItem)->setUseDelay(Sql_GetUIntData(SqlHandle,12));
					    ((CItemUsable*)PItem)->setReuseDelay(Sql_GetUIntData(SqlHandle,13));
                        ((CItemUsable*)PItem)->setAoE(Sql_GetUIntData(SqlHandle,14));
				    }
				    if (PItem->isType(ITEM_PUPPET))
				    {
                        ((CItemPuppet*)PItem)->setEquipSlot(Sql_GetUIntData(SqlHandle,33));
                        ((CItemPuppet*)PItem)->setElementSlots(Sql_GetUIntData(SqlHandle,34));
				    }
				    if (PItem->isType(ITEM_ARMOR))
				    {
					    ((CItemArmor*)PItem)->setReqLvl(Sql_GetUIntData(SqlHandle,15));
					    ((CItemArmor*)PItem)->setJobs(Sql_GetUIntData(SqlHandle,16));
					    ((CItemArmor*)PItem)->setModelId(Sql_GetUIntData(SqlHandle,17));
					    ((CItemArmor*)PItem)->setShieldSize(Sql_GetUIntData(SqlHandle,18));
					    ((CItemArmor*)PItem)->setScriptType(Sql_GetUIntData(SqlHandle,19));
					    ((CItemArmor*)PItem)->setEquipSlotId(Sql_GetUIntData(SqlHandle,20));
					    ((CItemArmor*)PItem)->setRemoveSlotId(Sql_GetUIntData(SqlHandle,21));

					    if (((CItemArmor*)PItem)->getValidTarget() != 0)
					    {
						    ((CItemArmor*)PItem)->setSubType(ITEM_CHARGED);
					    }
				    }
				    if (PItem->isType(ITEM_WEAPON))
				    {
						((CItemWeapon*)PItem)->setSkillType(Sql_GetUIntData(SqlHandle,22));
						((CItemWeapon*)PItem)->setSubSkillType(Sql_GetUIntData(SqlHandle,23));
					    ((CItemWeapon*)PItem)->setDelay((Sql_GetIntData(SqlHandle,24)*1000)/60);
					    ((CItemWeapon*)PItem)->setDamage(Sql_GetUIntData(SqlHandle,25));
					    ((CItemWeapon*)PItem)->setDmgType(Sql_GetUIntData(SqlHandle,26));
                        ((CItemWeapon*)PItem)->setMaxHit(Sql_GetUIntData(SqlHandle,27));
                        ((CItemWeapon*)PItem)->setUnlockable(Sql_GetUIntData(SqlHandle,28));
				    }
				    if (PItem->isType(ITEM_FURNISHING))
				    {
					    ((CItemFurnishing*)PItem)->setStorage(Sql_GetUIntData(SqlHandle,29));
					    ((CItemFurnishing*)PItem)->setMoghancement(Sql_GetUIntData(SqlHandle,30));
					    ((CItemFurnishing*)PItem)->setElement(Sql_GetUIntData(SqlHandle,31));
					    ((CItemFurnishing*)PItem)->setAura(Sql_GetUIntData(SqlHandle,32));
				    }
				    g_pItemList[PItem->getID()] = PItem;
			    }
		    }
	    }
	
	    ret = Sql_Query(SqlHandle,"SELECT itemId, modId, value FROM item_mods WHERE itemId IN (SELECT itemId FROM item_basic LEFT JOIN item_armor USING (itemId))");
	    
	    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	    {
		    while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		    {
			    uint16 ItemID = (uint16)Sql_GetUIntData(SqlHandle,0);
			    uint16 modID  = (uint16)Sql_GetUIntData(SqlHandle,1);
			    int16  value  = (int16) Sql_GetIntData (SqlHandle,2);

			    if ((g_pItemList[ItemID] != NULL) && g_pItemList[ItemID]->isType(ITEM_ARMOR))
			    {
                    ((CItemArmor*)g_pItemList[ItemID])->addModifier(new CModifier(modID,value));
			    }
		    }
	    }

	    ret = Sql_Query(SqlHandle,"SELECT itemId, modId, value, latentId, latentParam FROM item_latents WHERE itemId IN (SELECT itemId FROM item_basic LEFT JOIN item_armor USING (itemId))");
	    
	    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	    {
		    while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) 
		    {
			    uint16 ItemID = (uint16)Sql_GetUIntData(SqlHandle,0);
			    uint16 modID  = (uint16)Sql_GetUIntData(SqlHandle,1);
			    int16  value  = (int16) Sql_GetIntData (SqlHandle,2);
				uint16 latentId = (uint16) Sql_GetIntData(SqlHandle,3);
				uint16 latentParam = (uint16) Sql_GetIntData(SqlHandle,4);

			    if ((g_pItemList[ItemID] != NULL) && g_pItemList[ItemID]->isType(ITEM_ARMOR))
			    {
                    ((CItemArmor*)g_pItemList[ItemID])->addLatent(new CLatentEffect((LATENT)latentId, latentParam, 0, modID, value));
			    }
		    }
	    }
    }
예제 #19
0
    void LoadAbilitiesList()
    {
        // TODO: добавить поле message в таблицу

        memset(PAbilityList, 0, sizeof(PAbilityList));

        const int8* Query =
            "SELECT "
            "abilityId,"
            "IFNULL(min_id,0),"
            "name,"
            "job,"
            "level,"
            "validTarget,"
            "recastTime,"
            "message1, "
            "message2, "
            "animation,"
            "animationTime,"
            "castTime,"
            "actionType,"
            "`range`,"
            "isAOE,"
            "recastId,"
            "CE,"
            "VE, "
            "meritModID, "
            "addType, "
            "required_expansion "
            "FROM abilities LEFT JOIN (SELECT mob_skill_name, MIN(mob_skill_id) AS min_id "
            "FROM mob_skills GROUP BY mob_skill_name) mob_skills_1 ON "
            "abilities.name = mob_skills_1.mob_skill_name "
            "WHERE job < %u AND abilityId < %u "
            "ORDER BY job, level ASC";

        int32 ret = Sql_Query(SqlHandle, Query, MAX_JOBTYPE, MAX_ABILITY_ID);

        if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
        {
            while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
            {
                int8* expansionCode;
                Sql_GetData(SqlHandle, 20, &expansionCode, nullptr);

                if (luautils::IsExpansionEnabled(expansionCode) == false) {
                    continue;
                }

                CAbility* PAbility = new CAbility(Sql_GetIntData(SqlHandle, 0));

                PAbility->setMobSkillID(Sql_GetIntData(SqlHandle, 1));
                PAbility->setName(Sql_GetData(SqlHandle, 2));
                PAbility->setJob((JOBTYPE)Sql_GetIntData(SqlHandle, 3));
                PAbility->setLevel(Sql_GetIntData(SqlHandle, 4));
                PAbility->setValidTarget(Sql_GetIntData(SqlHandle, 5));
                PAbility->setRecastTime(Sql_GetIntData(SqlHandle, 6));
                PAbility->setMessage(Sql_GetIntData(SqlHandle, 7));
                //PAbility->setMessage(Sql_GetIntData(SqlHandle,8));
                PAbility->setAnimationID(Sql_GetIntData(SqlHandle, 9));
                PAbility->setAnimationTime(std::chrono::milliseconds(Sql_GetIntData(SqlHandle, 10)));
                PAbility->setCastTime(std::chrono::milliseconds(Sql_GetIntData(SqlHandle, 11)));
                PAbility->setActionType(static_cast<ACTIONTYPE>(Sql_GetUIntData(SqlHandle, 12)));
                PAbility->setRange(Sql_GetFloatData(SqlHandle, 13));
                PAbility->setAOE(Sql_GetIntData(SqlHandle, 14));
                PAbility->setRecastId(Sql_GetIntData(SqlHandle, 15));
                PAbility->setCE(Sql_GetIntData(SqlHandle, 16));
                PAbility->setVE(Sql_GetIntData(SqlHandle, 17));
                PAbility->setMeritModID(Sql_GetIntData(SqlHandle, 18));
                PAbility->setAddType(Sql_GetUIntData(SqlHandle, 19));

                PAbilityList[PAbility->getID()] = PAbility;
                PAbilitiesList[PAbility->getJob()].push_back(PAbility);
            }
        }

        const int8* Query2 = "SELECT recastId, job, level, maxCharges, chargeTime, meritModId FROM abilities_charges ORDER BY job, level ASC;";

        ret = Sql_Query(SqlHandle, Query2);

        if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
        {
            while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
            {
                Charge_t* PCharge = new Charge_t;
                PCharge->ID = Sql_GetUIntData(SqlHandle, 0);
                PCharge->job = (JOBTYPE)Sql_GetUIntData(SqlHandle, 1);
                PCharge->level = Sql_GetUIntData(SqlHandle, 2);
                PCharge->maxCharges = Sql_GetUIntData(SqlHandle, 3);
                PCharge->chargeTime = Sql_GetUIntData(SqlHandle, 4);
                PCharge->merit = Sql_GetUIntData(SqlHandle, 5);

                PChargesList.push_back(PCharge);
            }
        }
    }
예제 #20
0
void LoadMOBList()
{
    const int8* Query =
        "SELECT zoneid, name, mobid, pos_rot, pos_x, pos_y, pos_z, \
			respawntime, spawntype, dropid, mob_groups.HP, mob_groups.MP, minLevel, maxLevel, \
			modelid, mJob, sJob, cmbSkill, cmbDmgMult, cmbDelay, behavior, links, mobType, immunity, \
			systemid, mobsize, speed, \
			STR, DEX, VIT, AGI, `INT`, MND, CHR, EVA, DEF, \
			Slash, Pierce, H2H, Impact, \
			Fire, Ice, Wind, Earth, Lightning, Water, Light, Dark, Element, \
			mob_pools.familyid, name_prefix, unknown, animationsub, \
			(mob_family_system.HP / 100), (mob_family_system.MP / 100), hasSpellScript, spellList, ATT, ACC, mob_groups.poolid \
			FROM mob_groups INNER JOIN mob_pools ON mob_groups.poolid = mob_pools.poolid \
			INNER JOIN mob_spawn_points ON mob_groups.groupid = mob_spawn_points.groupid \
			INNER JOIN mob_family_system ON mob_pools.familyid = mob_family_system.familyid \
			WHERE NOT (pos_x = 0 AND pos_y = 0 AND pos_z = 0);";

    int32 ret = Sql_Query(SqlHandle, Query);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
        	uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);
			CMobEntity* PMob = new CMobEntity;

			PMob->name.insert(0,Sql_GetData(SqlHandle,1));
			PMob->id = (uint32)Sql_GetUIntData(SqlHandle,2);
			PMob->targid = (uint16)PMob->id & 0x0FFF;

			PMob->m_SpawnPoint.rotation = (uint8)Sql_GetIntData(SqlHandle,3);
			PMob->m_SpawnPoint.x = Sql_GetFloatData(SqlHandle,4);
			PMob->m_SpawnPoint.y = Sql_GetFloatData(SqlHandle,5);
			PMob->m_SpawnPoint.z = Sql_GetFloatData(SqlHandle,6);

			PMob->m_RespawnTime = Sql_GetUIntData(SqlHandle,7) * 1000;
			PMob->m_SpawnType   = (SPAWNTYPE)Sql_GetUIntData(SqlHandle,8);
			PMob->m_DropID		= Sql_GetUIntData(SqlHandle,9);

			PMob->HPmodifier = (uint32)Sql_GetIntData(SqlHandle,10);
			PMob->MPmodifier = (uint32)Sql_GetIntData(SqlHandle,11);

			PMob->m_minLevel = (uint8)Sql_GetIntData(SqlHandle,12);
			PMob->m_maxLevel = (uint8)Sql_GetIntData(SqlHandle,13);

			memcpy(&PMob->look,Sql_GetData(SqlHandle,14),23);

			PMob->SetMJob(Sql_GetIntData(SqlHandle,15));
			PMob->SetSJob(Sql_GetIntData(SqlHandle,16));

			PMob->m_Weapons[SLOT_MAIN]->setMaxHit(1);
			PMob->m_Weapons[SLOT_MAIN]->setSkillType(Sql_GetIntData(SqlHandle,17));
			PMob->m_dmgMult = Sql_GetUIntData(SqlHandle, 18);
			PMob->m_Weapons[SLOT_MAIN]->setDelay((Sql_GetIntData(SqlHandle,19) * 1000)/60);
			PMob->m_Weapons[SLOT_MAIN]->setBaseDelay((Sql_GetIntData(SqlHandle,19) * 1000)/60);

			PMob->m_Behaviour  = (uint16)Sql_GetIntData(SqlHandle,20);
			PMob->m_Link       = (uint8)Sql_GetIntData(SqlHandle,21);
			PMob->m_Type       = (uint8)Sql_GetIntData(SqlHandle,22);
			PMob->m_Immunity   = (IMMUNITY)Sql_GetIntData(SqlHandle,23);
			PMob->m_EcoSystem  = (ECOSYSTEM)Sql_GetIntData(SqlHandle,24);
			PMob->m_ModelSize += (uint8)Sql_GetIntData(SqlHandle,25);

			PMob->speed    = (uint8)Sql_GetIntData(SqlHandle,26);
			PMob->speedsub = (uint8)Sql_GetIntData(SqlHandle,26);

			/*if(PMob->speed != 0)
			{
				PMob->speed += map_config.speed_mod;
                // whats this for?
				PMob->speedsub += map_config.speed_mod;
			}*/

            PMob->strRank = (uint8)Sql_GetIntData(SqlHandle,27);
            PMob->dexRank = (uint8)Sql_GetIntData(SqlHandle,28);
            PMob->vitRank = (uint8)Sql_GetIntData(SqlHandle,29);
            PMob->agiRank = (uint8)Sql_GetIntData(SqlHandle,30);
            PMob->intRank = (uint8)Sql_GetIntData(SqlHandle,31);
            PMob->mndRank = (uint8)Sql_GetIntData(SqlHandle,32);
            PMob->chrRank = (uint8)Sql_GetIntData(SqlHandle,33);
            PMob->evaRank = (uint8)Sql_GetIntData(SqlHandle,34);
            PMob->defRank = (uint8)Sql_GetIntData(SqlHandle,35);
            PMob->attRank = (uint8)Sql_GetIntData(SqlHandle,57);
            PMob->accRank = (uint8)Sql_GetIntData(SqlHandle,58);

			PMob->setModifier(MOD_SLASHRES, (uint16)(Sql_GetFloatData(SqlHandle,36) * 1000));
			PMob->setModifier(MOD_PIERCERES,(uint16)(Sql_GetFloatData(SqlHandle,37) * 1000));
			PMob->setModifier(MOD_HTHRES,   (uint16)(Sql_GetFloatData(SqlHandle,38) * 1000));
			PMob->setModifier(MOD_IMPACTRES,(uint16)(Sql_GetFloatData(SqlHandle,39) * 1000));

            PMob->setModifier(MOD_FIREDEF,    (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -1000)); // These are stored as floating percentages
            PMob->setModifier(MOD_ICEDEF,     (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -1000)); // and need to be adjusted into modifier units.
            PMob->setModifier(MOD_WINDDEF,    (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -1000)); // Higher DEF = lower damage.
            PMob->setModifier(MOD_EARTHDEF,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -1000)); // Negatives signify increased damage.
            PMob->setModifier(MOD_THUNDERDEF, (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -1000)); // Positives signify reduced damage.
            PMob->setModifier(MOD_WATERDEF,   (int16)((Sql_GetFloatData(SqlHandle, 45) - 1) * -1000)); // Ex: 125% damage would be 1.25, 50% damage would be 0.50
            PMob->setModifier(MOD_LIGHTDEF,   (int16)((Sql_GetFloatData(SqlHandle, 46) - 1) * -1000)); // (1.25 - 1) * -1000 = -250 DEF
            PMob->setModifier(MOD_DARKDEF,    (int16)((Sql_GetFloatData(SqlHandle, 47) - 1) * -1000)); // (0.50 - 1) * -1000 = 500 DEF

            PMob->setModifier(MOD_FIRERES,    (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -100)); // These are stored as floating percentages
            PMob->setModifier(MOD_ICERES,     (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -100)); // and need to be adjusted into modifier units.
            PMob->setModifier(MOD_WINDRES,    (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -100)); // Higher RES = lower damage.
            PMob->setModifier(MOD_EARTHRES,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -100)); // Negatives signify lower resist chance.
            PMob->setModifier(MOD_THUNDERRES, (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -100)); // Positives signify increased resist chance.
            PMob->setModifier(MOD_WATERRES,   (int16)((Sql_GetFloatData(SqlHandle, 45) - 1) * -100));
            PMob->setModifier(MOD_LIGHTRES,   (int16)((Sql_GetFloatData(SqlHandle, 46) - 1) * -100));
            PMob->setModifier(MOD_DARKRES,    (int16)((Sql_GetFloatData(SqlHandle, 47) - 1) * -100));

			PMob->m_Element = (uint8)Sql_GetIntData(SqlHandle,48);
			PMob->m_Family = (uint16)Sql_GetIntData(SqlHandle,49);
			PMob->m_name_prefix = (uint8)Sql_GetIntData(SqlHandle,50);
			PMob->m_unknown = (uint32)Sql_GetIntData(SqlHandle,51);

			//Special sub animation for Mob (yovra, jailer of love, phuabo)
			// yovra 1: en hauteur, 2: en bas, 3: en haut
			// phuabo 1: sous l'eau, 2: sort de l'eau, 3: rentre dans l'eau
			PMob->animationsub = (uint32)Sql_GetIntData(SqlHandle,52);

			// Setup HP / MP Stat Percentage Boost
			PMob->HPscale = Sql_GetFloatData(SqlHandle,53);
			PMob->MPscale = Sql_GetFloatData(SqlHandle,54);

			PMob->PBattleAI = new CAIMobDummy(PMob);

			if (PMob->m_AllowRespawn = PMob->m_SpawnType == SPAWNTYPE_NORMAL)
			{
				PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
			}

			// Check if we should be looking up scripts for this mob
			PMob->m_HasSpellScript = (uint8)Sql_GetIntData(SqlHandle,55);

			PMob->m_SpellListContainer = mobSpellList::GetMobSpellList(Sql_GetIntData(SqlHandle,56));

			PMob->m_Pool = Sql_GetUIntData(SqlHandle,59);

            // must be here first to define mobmods
			mobutils::InitializeMob(PMob, GetZone(ZoneID));

            GetZone(ZoneID)->InsertMOB(PMob);

            luautils::OnMobInitialize(PMob);

            PMob->saveModifiers();
            PMob->saveMobModifiers();
		}
	}

	// attach pets to mobs
	const int8* PetQuery =
		"SELECT zoneid, mob_mobid, pet_offset \
		FROM mob_pets \
		LEFT JOIN mob_spawn_points ON mob_pets.mob_mobid = mob_spawn_points.mobid \
		LEFT JOIN mob_groups ON mob_spawn_points.groupid = mob_groups.groupid;";

	ret = Sql_Query(SqlHandle, PetQuery);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
        	uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);
			uint32 masterid = (uint32)Sql_GetUIntData(SqlHandle,1);
			uint32 petid = masterid + (uint32)Sql_GetUIntData(SqlHandle,2);

			CMobEntity* PMaster = (CMobEntity*)GetZone(ZoneID)->GetEntity(masterid & 0x0FFF, TYPE_MOB);
			CMobEntity* PPet = (CMobEntity*)GetZone(ZoneID)->GetEntity(petid & 0x0FFF, TYPE_MOB);

			if(PMaster == NULL)
			{
				ShowError("zoneutils::loadMOBList PMaster is null. masterid: %d. Make sure x,y,z are not zeros, and that all entities are entered in the database!\n", masterid);
			}
			else if(PPet == NULL)
			{
				ShowError("zoneutils::loadMOBList PPet is null. petid: %d. Make sure x,y,z are not zeros!\n", petid);
			}
			else if(masterid == petid)
			{
				ShowError("zoneutils::loadMOBList Master and Pet are the same entity: %d\n", masterid);
			}
			else
			{
				// pet is always spawned by master
				PPet->m_AllowRespawn = false;
				PPet->m_SpawnType = SPAWNTYPE_SCRIPTED;
				PPet->PBattleAI->SetCurrentAction(ACTION_NONE);
				PPet->SetDespawnTimer(0);

				PMaster->PPet = PPet;
				PPet->PMaster = PMaster;
			}
		}
	}
}
예제 #21
0
CConquestPacket::CConquestPacket(CCharEntity * PChar) 
{
	this->type = 0x5E; 
	this->size = 0x5A;

    const int8* Query = "SELECT region_id, region_control, region_control_prev, \
                         sandoria_influence, bastok_influence, windurst_influence, \
                         beastmen_influence FROM conquest_system;";

    int32 ret = Sql_Query(SqlHandle, Query);

    uint8 sandoria_regions = 0;
    uint8 bastok_regions = 0;
    uint8 windurst_regions = 0;
    uint8 sandoria_prev = 0;
    uint8 bastok_prev = 0;
    uint8 windurst_prev = 0;

    if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            int regionid = Sql_GetIntData(SqlHandle, 0);
            int region_control = Sql_GetIntData(SqlHandle, 1);
            int region_control_prev = Sql_GetIntData(SqlHandle, 2);

            if (region_control == 0)
                sandoria_regions++;
            else if (region_control == 1)
                bastok_regions++;
            else if (region_control == 2)
                windurst_regions++;

            if (region_control_prev == 0)
                sandoria_prev++;
            else if (region_control_prev == 1)
                bastok_prev++;
            else if (region_control_prev == 2)
                windurst_prev++;

            int32 san_inf = Sql_GetIntData(SqlHandle, 3);
            int32 bas_inf = Sql_GetIntData(SqlHandle, 4);
            int32 win_inf = Sql_GetIntData(SqlHandle, 5);
            int32 bst_inf = Sql_GetIntData(SqlHandle, 6);
            WBUFB(data,0x1A+(regionid*4)-4) = conquest::GetInfluenceRanking(san_inf, bas_inf, win_inf, bst_inf);
            WBUFB(data,0x1B+(regionid*4)-4) = conquest::GetInfluenceRanking(san_inf, bas_inf, win_inf);
            WBUFB(data,0x1C+(regionid*4)-4) = conquest::GetInfluenceGraphics(san_inf, bas_inf, win_inf, bst_inf);
            WBUFB(data,0x1D+(regionid*4)-4) = region_control+1;

            int64 total = san_inf + bas_inf + win_inf;
            int64 totalBeastmen = total + bst_inf;

            if (PChar->loc.zone->GetRegionID() == regionid)
            {
                WBUFB(data, (0x86)-4) = (san_inf*100) / (totalBeastmen == 0 ? 1 : totalBeastmen);
                WBUFB(data, (0x87)-4) = (bas_inf*100) / (totalBeastmen == 0 ? 1 : totalBeastmen);
                WBUFB(data, (0x88)-4) = (win_inf*100) / (totalBeastmen == 0 ? 1 : totalBeastmen);
                WBUFB(data, (0x89)-4) = (san_inf*100) / (total == 0 ? 1 : total);
                WBUFB(data, (0x8A)-4) = (bas_inf*100) / (total == 0 ? 1 : total);
                WBUFB(data, (0x8B)-4) = (win_inf*100) / (total == 0 ? 1 : total);
                WBUFB(data, (0x94)-4) = (bst_inf*100) / (totalBeastmen == 0 ? 1 : totalBeastmen);
            }
        }
    }

	WBUFB(data,(0x04)-4) = conquest::GetBalance(sandoria_regions, bastok_regions, windurst_regions, sandoria_prev, bastok_prev, windurst_prev);
    WBUFB(data,(0x05)-4) = conquest::GetAlliance(sandoria_regions, bastok_regions, windurst_regions, sandoria_prev, bastok_prev, windurst_prev);

	WBUFB(data,(0x8C)-4) = conquest::GetNexTally();
    WBUFL(data,(0x90)-4) = charutils::GetPoints(PChar, charutils::GetConquestPointsName(PChar).c_str());
	WBUFB(data,(0x9C)-4) = 0x01;

	//uint8 packet[] = 
    //{
	//    0x80, 0x78, 0x52, 0x03, 0x1a, 0x46, 0x04, 0x00, 0x42, 0x46, 0x04, 0x00, 0x65, 0x3d, 0x04, 0x00
    //};
	//memcpy(data+(0xA0)-4, &packet, 16);

	WBUFB(data,(0xA0)-4) = 16; // Situation: mamool ja niveau -> (1) 16 (2) 32 (3) 48 (4) 64 (5) 80 (6) 96 (7) 112 (8) 128
	WBUFB(data,(0xA1)-4) = 17; // Situation: mercenaire trolls niveau -> 1~12 la suite avec un autre 
	WBUFB(data,(0xA2)-4) = 0; // Situation: mamool ja status du siege -> (0) entrainement > (1) en marche > (2) attaque > (3) retraite | (4) defense (5) preparation
	WBUFB(data,(0xA3)-4) = 4; // Situation: undead status du siege ? (3) defense (4) entrainement (5) defense

	WBUFB(data,(0xA4)-4) = 0; // mamool ja: (13) preparation (26) attaque (32) entrainement
	WBUFB(data,(0xA5)-4) = 0; // mamool ja: forces ennemies (1=32)
	WBUFB(data,(0xA6)-4) = 0; // mamool ja: miroir archaique (1=2)
	WBUFB(data,(0xA7)-4) = 0;

	WBUFB(data,(0xA8)-4) = 0; // trolls: forces ennemies (66=8)
	WBUFB(data,(0xA9)-4) = 0; // trolls: (70) attaque
	WBUFB(data,(0xAA)-4) = 0; // trolls: miroir archaique (4=8)
	WBUFB(data,(0xAB)-4) = 0;
	WBUFB(data,(0xAC)-4) = 0; // undead: forces ennemies (101=12)
	WBUFB(data,(0xAD)-4) = 0; // undead: (61) preparation
	WBUFB(data,(0xAE)-4) = 0; // undead: miroir archaique (4=8)
	WBUFB(data,(0xAF)-4) = 0;

	WBUFL(data,(0xB0)-4) = charutils::GetPoints(PChar, "imperial_standing");
}
예제 #22
0
std::list<SearchEntity*> CDataLoader::GetLinkshellList(uint32 LinkshellID)
{
    std::list<SearchEntity*> LinkshellList;
    const char* fmtQuery = "SELECT charid, partyid, charname, pos_zone, nation, rank_sandoria, rank_bastok, rank_windurst, race, nameflags, mjob, sjob, "
        "mlvl, slvl, linkshellid1, linkshellid2, "
        "linkshellrank1, linkshellrank2 "
        "FROM accounts_sessions "
        "LEFT JOIN accounts_parties USING (charid) "
        "LEFT JOIN chars USING (charid) "
        "LEFT JOIN char_look USING (charid) "
        "LEFT JOIN char_stats USING (charid) "
        "LEFT JOIN char_profile USING(charid) "
        "WHERE linkshellid1 = %u OR linkshellid2 = %u "
        "ORDER BY charname ASC "
        "LIMIT 18";

    int32 ret = Sql_Query(SqlHandle, fmtQuery, LinkshellID, LinkshellID);

    if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            SearchEntity* PPlayer = new SearchEntity;
            memset(PPlayer, 0, sizeof(SearchEntity));

            memcpy(PPlayer->name, Sql_GetData(SqlHandle, 2), 15);

            PPlayer->id = (uint32)Sql_GetUIntData(SqlHandle, 0);
            PPlayer->zone = (uint16)Sql_GetIntData(SqlHandle, 3);
            PPlayer->nation = (uint8)Sql_GetIntData(SqlHandle, 4);
            PPlayer->mjob = (uint8)Sql_GetIntData(SqlHandle, 10);
            PPlayer->sjob = (uint8)Sql_GetIntData(SqlHandle, 11);
            PPlayer->mlvl = (uint8)Sql_GetIntData(SqlHandle, 12);
            PPlayer->slvl = (uint8)Sql_GetIntData(SqlHandle, 13);
            PPlayer->race = (uint8)Sql_GetIntData(SqlHandle, 8);
            PPlayer->rank = (uint8)Sql_GetIntData(SqlHandle, 5 + PPlayer->nation);
            PPlayer->linkshellid1 = Sql_GetIntData(SqlHandle, 14);
            PPlayer->linkshellid2 = Sql_GetIntData(SqlHandle, 15);
            PPlayer->linkshellrank1 = Sql_GetIntData(SqlHandle, 16);
            PPlayer->linkshellrank2 = Sql_GetIntData(SqlHandle, 17);

            uint32 partyid = (uint32)Sql_GetUIntData(SqlHandle, 1);
            uint32 nameflag = (uint32)Sql_GetUIntData(SqlHandle, 9);

            if (partyid == PPlayer->id) PPlayer->flags1 |= 0x0008;
            if (nameflag & FLAG_AWAY)   PPlayer->flags1 |= 0x0100;
            if (nameflag & FLAG_DC)     PPlayer->flags1 |= 0x0800;
            if (partyid != 0)           PPlayer->flags1 |= 0x2000;
            if (nameflag & FLAG_ANON)   PPlayer->flags1 |= 0x4000;
            if (nameflag & FLAG_INVITE) PPlayer->flags1 |= 0x8000;

            PPlayer->flags2 = PPlayer->flags1;

            LinkshellList.push_back(PPlayer);
        }
    }

    return LinkshellList;
}
예제 #23
0
// rod break and line break code
	int Breakage(CCharEntity* PChar, uint16 FishID)
	{
		uint8  SlotID = PChar->equip[SLOT_RANGED];
		CItem* PRod = PChar->getStorage(LOC_INVENTORY)->GetItem(SlotID);

		DSP_DEBUG_BREAK_IF(PRod == NULL);

		int RodBeakType = 0;
		uint16 BrokenRodID = GetBrokenID(PRod->getID());
		
		if (BrokenRodID == -1)
		{
			ShowDebug(CL_CYAN"RodID not found Please check the database: %u \n" CL_RESET);
		}

		const int8* Query = "SELECT rodid, fishid, break_type, loose_catch \
							FROM fishing_rod_breakage \
							WHERE fishid = %u \
							ORDER BY rodid ASC";

		int32 ret = Sql_Query(SqlHandle, Query, FishID);
		
		if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
		{
			while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
			{
				uint16 ent = Sql_GetIntData(SqlHandle, 0);
				int32 break_type = Sql_GetIntData(SqlHandle, 2);
				int32 loose_catch = Sql_GetIntData(SqlHandle, 3);

				if (PRod->getID() == ent)
				{
		
					if (break_type > 0 && loose_catch > 0)
					{
						// 40% chance to break the rod and 60% chance to break the line
						if (rand() % 100 <= 60)
						{
							// break line only
							RodBeakType = 2;
						}
						else
						{
							// break rod
							RodBeakType = 1;
						}
					}

					if (break_type == 1 && loose_catch == 0)
					{
						// break rod
						RodBeakType = 1;
					}
					
					if (break_type == 2 && loose_catch == 0)
					{
						// break line
						RodBeakType = 2;
					}

					if (break_type == 0 && loose_catch == 1)
					{
						// loose catch
						RodBeakType = 3;
					}

				}
			}
		}

		// RodBeakType 0 = none ( Ebishu & Judges rod is not breakable )
		// RodBeakType 1 = rod 
		// RodBeakType 2 = line
		// RodBeakType 3 = loose catch
		if (BrokenRodID > 0 && RodBeakType == 1)
		{
			// 30% chance to loose your bait / Lure on a rod break
			if (rand()% + 100 <= 30)
			{
				LureLoss(PChar, true);
			}
			else
			{
				LureLoss(PChar, false);
			}
			
			charutils::EquipItem(PChar, 0, SLOT_RANGED);
			charutils::UpdateItem(PChar, LOC_INVENTORY, SlotID, -1);
			charutils::AddItem(PChar, LOC_INVENTORY, BrokenRodID, 1);			
			return 1;
		}

		if (RodBeakType == 2)
		{
			LureLoss(PChar, true);
			return 2;
		}

		// 20% chance to loose your catch
		if (RodBeakType == 3 && rand()% + 100 <= 20)
		{
			return 3;
		}

		return 0;
	}
예제 #24
0
	bool CheckFisherLuck(CCharEntity* PChar)
	{
		if (PChar->UContainer->GetType() != UCONTAINER_EMPTY)
		{
			ShowDebug(CL_CYAN"Player cannot fish! UContainer is not empty\n" CL_RESET);
			return false;
		}

		CItemFish* PFish = NULL;
		CItemWeapon* WeaponItem = NULL;

		WeaponItem = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[SLOT_RANGED]);

		DSP_DEBUG_BREAK_IF(WeaponItem == NULL);
		DSP_DEBUG_BREAK_IF(WeaponItem->isType(ITEM_WEAPON) == false);
		DSP_DEBUG_BREAK_IF(WeaponItem->getSkillType() != SKILL_FSH);

		uint16 RodID = WeaponItem->getID();

		WeaponItem = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[SLOT_AMMO]);

		DSP_DEBUG_BREAK_IF(WeaponItem == NULL);
		DSP_DEBUG_BREAK_IF(WeaponItem->isType(ITEM_WEAPON) == false);
		DSP_DEBUG_BREAK_IF(WeaponItem->getSkillType() != SKILL_FSH);

		uint16 LureID = WeaponItem->getID();

		int FishingChance = rand() % 100;

		int ListID = GridList(PChar);

		if (ListID == 0)
		{
			ShowDebug(CL_CYAN"Fish list not found for Zone: %u \n" CL_RESET, PChar->getZone());
		}

		if (ListID > 0 && FishingChance <= 50)
		{
			const int8* Query = "SELECT ListID, EntityID \
								FROM fishing_list \
								WHERE ListID = %u \
								ORDER BY ListID ASC";

			int32 ret = Sql_Query(SqlHandle, Query, ListID);

			int RC = 0;
			// this will pick a random  number from range 1 to max record count
			int RID = rand() % Sql_NumRows(SqlHandle) + 1;
			
			if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
			{
				while (Sql_NextRow(SqlHandle) == SQL_SUCCESS)
				{
					RC = RC + 1;
					uint32 EntityID = Sql_GetIntData(SqlHandle, 1);
					
					if (RC == RID)
					{
						// Gil
						if (EntityID == 0x0000FFFF)
						{   
							// do not change this item number this is a place holder ID for gil
							PFish = new CItemFish(*itemutils::GetItemPointer(14117));
							PChar->UContainer->SetType(UCONTAINER_FISHING);
							PChar->UContainer->SetItem(0, PFish);
							catchtype[0] = 2;
							break;
						}
						// Monster
						if (EntityID == 0x0001046A)
						{
							GetMobInfo(PChar);
							if (IsSpawned(mobid[0]) == false && mobid[0] > 0)
							{
								// do not change this item number this is a place holder ID for mobs
								PFish = new CItemFish(*itemutils::GetItemPointer(14117));
								PChar->UContainer->SetType(UCONTAINER_FISHING);
								PChar->UContainer->SetItem(0, PFish);
								break;
							}
						}
						if (EntityID != 0x0000FFFF || EntityID != 0x0001046A)
						{
							// get fish or item for returned record if its not a monster or gil
							GetOtherInfo(EntityID);
							// Fish
							if (catchtype[0] == 0)
							{
								// will create a fish entity if the bait can be used to catch the fish 
								if (BaitCheck(LureID, EntityID) == true)
								{
									PFish = new CItemFish(*itemutils::GetItemPointer(EntityID));
									PChar->UContainer->SetType(UCONTAINER_FISHING);
									PChar->UContainer->SetItem(0, PFish);
									break;
								}
							}
							// Item
							if (catchtype[0] == 1)
							{
								PFish = new CItemFish(*itemutils::GetItemPointer(EntityID));
								PChar->UContainer->SetType(UCONTAINER_FISHING);
								PChar->UContainer->SetItem(0, PFish);
								break;
							}
						}

					}

					if(RC == Sql_NumRows(SqlHandle))
					{
						break;
					}

				}

			}
		}

		return (PFish != NULL);
	}
예제 #25
0
파일: currency1.cpp 프로젝트: Ex0r/darkstar
CCurrencyPacket1::CCurrencyPacket1(CCharEntity* PChar)
{
	this->type = 0x13;
	this->size = 0x6F;

    const char* query = "SELECT sandoria_cp, bastok_cp, windurst_cp, beastman_seal, kindred_seal, kindred_crest, \
                        high_kindred_crest, sacred_kindred_crest, ancient_beastcoin, valor_point, scyld, \
                        guild_fishing, guild_woodworking, guild_smithing, guild_goldsmithing, guild_weaving, \
                        guild_leathercraft, guild_bonecraft, guild_alchemy, guild_cooking, cinder, fire_fewell, \
                        ice_fewell, wind_fewell, earth_fewell, lightning_fewell, water_fewell, light_fewell, \
                        dark_fewell, ballista_point, fellow_point, chocobuck_sandoria, chocobuck_bastok, chocobuck_windurst, \
                        research_mark, tunnel_worm, morion_worm, phantom_worm, moblin_marble, infamy, prestige, \
                        legion_point, spark_of_eminence, shining_star, imperial_standing, leujaoam_assault_point, \
                        mamool_assault_point, lebros_assault_point, periqia_assault_point, ilrusi_assault_point, \
                        nyzul_isle_assault_point, zeni_point, jetton, therion_ichor, allied_notes, cruor, resistance_credit, \
                        dominion_note, fifth_echelon_trophy, fourth_echelon_trophy, third_echelon_trophy, second_echelon_trophy, \
                        first_echelon_trophy, cave_points, id_tags, op_credits, traverser_stones, voidstones, kupofried_corundums, \
                        pheromone_sacks FROM char_points WHERE charid = %d";

    int ret = Sql_Query(SqlHandle, query, PChar->id);
    if (ret != SQL_ERROR && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
    {
        WBUFL(data, (0x04)-4) = Sql_GetIntData(SqlHandle, 0);
        WBUFL(data, (0x08)-4) = Sql_GetIntData(SqlHandle, 1);
        WBUFL(data, (0x0C)-4) = Sql_GetIntData(SqlHandle, 2);

        WBUFW(data, (0x10)-4) = Sql_GetUIntData(SqlHandle, 3);
        WBUFW(data, (0x12)-4) = Sql_GetUIntData(SqlHandle, 4);
        WBUFW(data, (0x14)-4) = Sql_GetUIntData(SqlHandle, 5);
        WBUFW(data, (0x16)-4) = Sql_GetUIntData(SqlHandle, 6);
        WBUFW(data, (0x18)-4) = Sql_GetUIntData(SqlHandle, 7);
        WBUFW(data, (0x1A)-4) = Sql_GetUIntData(SqlHandle, 8);
        WBUFW(data, (0x1C)-4) = Sql_GetUIntData(SqlHandle, 9);
        WBUFW(data, (0x1E)-4) = Sql_GetUIntData(SqlHandle, 10);

        WBUFL(data, (0x20)-4) = Sql_GetIntData(SqlHandle, 11);
        WBUFL(data, (0x24)-4) = Sql_GetIntData(SqlHandle, 12);
        WBUFL(data, (0x28)-4) = Sql_GetIntData(SqlHandle, 13);
        WBUFL(data, (0x2C)-4) = Sql_GetIntData(SqlHandle, 14);
        WBUFL(data, (0x30)-4) = Sql_GetIntData(SqlHandle, 15);
        WBUFL(data, (0x34)-4) = Sql_GetIntData(SqlHandle, 16);
        WBUFL(data, (0x38)-4) = Sql_GetIntData(SqlHandle, 17);
        WBUFL(data, (0x3C)-4) = Sql_GetIntData(SqlHandle, 18);
        WBUFL(data, (0x40)-4) = Sql_GetIntData(SqlHandle, 19);

        WBUFL(data, (0x44)-4) = Sql_GetIntData(SqlHandle, 20);
        WBUFB(data, (0x48)-4) = Sql_GetUIntData(SqlHandle, 21);
        WBUFB(data, (0x49)-4) = Sql_GetUIntData(SqlHandle, 22);
        WBUFB(data, (0x4A)-4) = Sql_GetUIntData(SqlHandle, 23);
        WBUFB(data, (0x4B)-4) = Sql_GetUIntData(SqlHandle, 24);
        WBUFB(data, (0x4C)-4) = Sql_GetUIntData(SqlHandle, 25);
        WBUFB(data, (0x4D)-4) = Sql_GetUIntData(SqlHandle, 26);
        WBUFB(data, (0x4E)-4) = Sql_GetUIntData(SqlHandle, 27);
        WBUFB(data, (0x4F)-4) = Sql_GetUIntData(SqlHandle, 28);

        WBUFL(data, (0x50)-4) = Sql_GetIntData(SqlHandle, 29);
        WBUFL(data, (0x54)-4) = Sql_GetIntData(SqlHandle, 30);
        WBUFW(data, (0x58)-4) = Sql_GetUIntData(SqlHandle, 31);
        WBUFW(data, (0x5A)-4) = Sql_GetUIntData(SqlHandle, 32);
        WBUFW(data, (0x5C)-4) = Sql_GetUIntData(SqlHandle, 33);
        // daily tally (2 byte)
        WBUFL(data, (0x60)-4) = Sql_GetIntData(SqlHandle, 34);
        WBUFB(data, (0x64)-4) = Sql_GetUIntData(SqlHandle, 35);
        WBUFB(data, (0x65)-4) = Sql_GetUIntData(SqlHandle, 36);
        WBUFB(data, (0x66)-4) = Sql_GetUIntData(SqlHandle, 37);
        WBUFL(data, (0x68)-4) = Sql_GetIntData(SqlHandle, 38);

        WBUFW(data, (0x6C)-4) = Sql_GetUIntData(SqlHandle, 39);
        WBUFW(data, (0x6E)-4) = Sql_GetUIntData(SqlHandle, 40);

        WBUFL(data, (0x70)-4) = Sql_GetIntData(SqlHandle, 41);
        WBUFL(data, (0x74)-4) = Sql_GetIntData(SqlHandle, 42);
        WBUFL(data, (0x78)-4) = Sql_GetIntData(SqlHandle, 43);

        WBUFL(data, (0x7C)-4) = Sql_GetIntData(SqlHandle, 44);
        WBUFL(data, (0x80)-4) = Sql_GetIntData(SqlHandle, 45);
        WBUFL(data, (0x84)-4) = Sql_GetIntData(SqlHandle, 46);
        WBUFL(data, (0x88)-4) = Sql_GetIntData(SqlHandle, 47);
        WBUFL(data, (0x8C)-4) = Sql_GetIntData(SqlHandle, 48);
        WBUFL(data, (0x90)-4) = Sql_GetIntData(SqlHandle, 49);
        WBUFL(data, (0x94)-4) = Sql_GetIntData(SqlHandle, 50);
        WBUFL(data, (0x98)-4) = Sql_GetIntData(SqlHandle, 51);
        WBUFL(data, (0x9C)-4) = Sql_GetIntData(SqlHandle, 52);
        WBUFL(data, (0xA0)-4) = Sql_GetIntData(SqlHandle, 53);

        WBUFL(data, (0xA4)-4) = Sql_GetIntData(SqlHandle, 54);

        // AMAN vouchers
        // unity accolades

        WBUFL(data, (0xAC)-4) = Sql_GetIntData(SqlHandle, 55);
        WBUFL(data, (0xB0)-4) = Sql_GetIntData(SqlHandle, 56);
        WBUFL(data, (0xB4)-4) = Sql_GetIntData(SqlHandle, 57);
        WBUFB(data, (0xB8)-4) = Sql_GetUIntData(SqlHandle, 58);
        WBUFB(data, (0xB9)-4) = Sql_GetUIntData(SqlHandle, 59);
        WBUFB(data, (0xBA)-4) = Sql_GetUIntData(SqlHandle, 60);
        WBUFB(data, (0xBB)-4) = Sql_GetUIntData(SqlHandle, 61);
        WBUFB(data, (0xBC)-4) = Sql_GetUIntData(SqlHandle, 62);

        WBUFB(data, (0xBD)-4) = Sql_GetUIntData(SqlHandle, 63);

        WBUFB(data, (0xBE)-4) = Sql_GetUIntData(SqlHandle, 64);

        WBUFB(data, (0xBF)-4) = Sql_GetUIntData(SqlHandle, 65);

        WBUFL(data, (0xC0)-4) = Sql_GetIntData(SqlHandle, 66);
        WBUFL(data, (0xC4)-4) = Sql_GetIntData(SqlHandle, 67);
        WBUFL(data, (0xC8)-4) = Sql_GetIntData(SqlHandle, 68);

        WBUFB(data, (0xCC)-4) = Sql_GetUIntData(SqlHandle, 69);
    }
}