Ejemplo n.º 1
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;
			}
		}
	}
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
void SpawnMobPet(CBattleEntity* PMaster, uint32 PetID)
{
	// this is ONLY used for mob smn elementals / avatars
	/*
	This should eventually be merged into one big spawn pet method.
	At the moment player pets and mob pets are totally different. We need a central place
	to manage pet families and spawn them.
	*/

	// grab pet info
	Pet_t* petData = g_PPetList.at(PetID);
	CMobEntity* PPet = (CMobEntity*)PMaster->PPet;

	PPet->look = petData->look;
	PPet->name = petData->name;
	PPet->m_EcoSystem = petData->EcoSystem;
	PPet->m_Family = petData->m_Family;
	PPet->m_Element = petData->m_Element;
	PPet->HPscale = petData->HPscale;
	PPet->MPscale = petData->MPscale;
	PPet->m_HasSpellScript = petData->hasSpellScript;

    // assuming elemental spawn
    PPet->setModifier(MOD_DMGPHYS,-50); //-50% PDT

	PPet->m_SpellListContainer = mobSpellList::GetMobSpellList(petData->spellList);

	PPet->setModifier(MOD_SLASHRES, petData->slashres);
	PPet->setModifier(MOD_PIERCERES,petData->pierceres);
	PPet->setModifier(MOD_HTHRES, petData->hthres);
	PPet->setModifier(MOD_IMPACTRES, petData->impactres);

    PPet->setModifier(MOD_FIREDEF,    petData->firedef); // These are stored as floating percentages
    PPet->setModifier(MOD_ICEDEF,     petData->icedef); // and need to be adjusted into modifier units.
    PPet->setModifier(MOD_WINDDEF,    petData->winddef); // Higher DEF = lower damage.
    PPet->setModifier(MOD_EARTHDEF,   petData->earthdef); // Negatives signify increased damage.
    PPet->setModifier(MOD_THUNDERDEF, petData->thunderdef); // Positives signify reduced damage.
    PPet->setModifier(MOD_WATERDEF,   petData->waterdef); // Ex: 125% damage would be 1.25, 50% damage would be 0.50
    PPet->setModifier(MOD_LIGHTDEF,   petData->lightdef); // (1.25 - 1) * -1000 = -250 DEF
    PPet->setModifier(MOD_DARKDEF,    petData->darkdef); // (0.50 - 1) * -1000 = 500 DEF

    PPet->setModifier(MOD_FIRERES,    petData->fireres); // These are stored as floating percentages
    PPet->setModifier(MOD_ICERES,     petData->iceres); // and need to be adjusted into modifier units.
    PPet->setModifier(MOD_WINDRES,    petData->windres); // Higher RES = lower damage.
    PPet->setModifier(MOD_EARTHRES,   petData->earthres); // Negatives signify lower resist chance.
    PPet->setModifier(MOD_THUNDERRES, petData->thunderres); // Positives signify increased resist chance.
    PPet->setModifier(MOD_WATERRES,   petData->waterres);
    PPet->setModifier(MOD_LIGHTRES,   petData->lightres);
    PPet->setModifier(MOD_DARKRES,    petData->darkres);
}