mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 15:00:25 +00:00
[Quest API] Add CloneAppearance() to Perl/Lua. (#2531)
* [Quest API] Add CloneAppearance() to Perl/Lua. # Perl - Add `$client->CloneAppearance(other)` to Perl. - Add `$client->CloneAppearance(other, clone_name)` to Perl. # Lua - Add `client:CloneAppearance(other)` to Lua. - Add `client:CloneAppearance(other, clone_name)` to Lua. # Notes - Allows operators to easily clone appearance between mobs in a script without relying on a plugin or module. * Update mob_appearance.cpp * Update mob.cpp
This commit is contained in:
+105
@@ -6899,3 +6899,108 @@ std::string Mob::GetMobDescription()
|
||||
GetID()
|
||||
);
|
||||
}
|
||||
|
||||
uint8 Mob::ConvertItemTypeToSkillID(uint8 item_type)
|
||||
{
|
||||
if (item_type >= EQ::item::ItemTypeCount) {
|
||||
return EQ::skills::SkillHandtoHand;
|
||||
}
|
||||
|
||||
std::map<uint8, uint8> convert_item_types_map = {
|
||||
{ EQ::item::ItemType1HSlash, EQ::skills::Skill1HSlashing },
|
||||
{ EQ::item::ItemType2HSlash, EQ::skills::Skill2HSlashing },
|
||||
{ EQ::item::ItemType1HPiercing, EQ::skills::Skill1HPiercing },
|
||||
{ EQ::item::ItemType2HPiercing, EQ::skills::Skill2HPiercing },
|
||||
{ EQ::item::ItemType1HBlunt, EQ::skills::Skill1HBlunt },
|
||||
{ EQ::item::ItemType2HBlunt, EQ::skills::Skill2HBlunt },
|
||||
{ EQ::item::ItemTypeBow, EQ::skills::SkillArchery },
|
||||
{ EQ::item::ItemTypeSmallThrowing, EQ::skills::SkillThrowing },
|
||||
{ EQ::item::ItemTypeLargeThrowing, EQ::skills::SkillThrowing },
|
||||
{ EQ::item::ItemTypeShield, EQ::skills::SkillBash },
|
||||
{ EQ::item::ItemTypeArmor, EQ::skills::SkillHandtoHand },
|
||||
{ EQ::item::ItemTypeMartial, EQ::skills::SkillHandtoHand }
|
||||
};
|
||||
|
||||
const auto& s = convert_item_types_map.find(item_type);
|
||||
if (s != convert_item_types_map.end()) {
|
||||
return s->second;
|
||||
}
|
||||
|
||||
return EQ::skills::SkillHandtoHand;
|
||||
}
|
||||
|
||||
void Mob::CloneAppearance(Mob* other, bool clone_name)
|
||||
{
|
||||
if (!other) {
|
||||
return;
|
||||
}
|
||||
|
||||
SendIllusionPacket(
|
||||
other->GetRace(),
|
||||
other->GetGender(),
|
||||
other->GetTexture(),
|
||||
other->GetHelmTexture(),
|
||||
other->GetHairColor(),
|
||||
other->GetBeardColor(),
|
||||
other->GetEyeColor1(),
|
||||
other->GetEyeColor2(),
|
||||
other->GetHairStyle(),
|
||||
other->GetBeard(),
|
||||
0xFF,
|
||||
other->GetRace() == DRAKKIN ? other->GetDrakkinHeritage() : 0xFFFFFFFF,
|
||||
other->GetRace() == DRAKKIN ? other->GetDrakkinTattoo() : 0xFFFFFFFF,
|
||||
other->GetRace() == DRAKKIN ? other->GetDrakkinDetails() : 0xFFFFFFFF,
|
||||
other->GetSize()
|
||||
);
|
||||
|
||||
for (
|
||||
uint8 slot = EQ::textures::armorHead;
|
||||
slot <= EQ::textures::armorFeet;
|
||||
slot++
|
||||
) {
|
||||
auto color = 0;
|
||||
auto material = 0;
|
||||
if (other->IsClient()) {
|
||||
color = other->CastToClient()->GetEquipmentColor(slot);
|
||||
material = other->CastToClient()->GetEquipmentMaterial(slot);
|
||||
} else {
|
||||
color = other->GetArmorTint(slot);
|
||||
material = !slot ? other->GetHelmTexture() : other->GetTexture();
|
||||
}
|
||||
|
||||
WearChange(slot, material, color);
|
||||
}
|
||||
|
||||
WearChange(
|
||||
EQ::textures::weaponPrimary,
|
||||
other->GetEquipmentMaterial(EQ::textures::weaponPrimary),
|
||||
other->GetEquipmentColor(EQ::textures::weaponPrimary)
|
||||
);
|
||||
|
||||
WearChange(
|
||||
EQ::textures::weaponSecondary,
|
||||
other->GetEquipmentMaterial(EQ::textures::weaponSecondary),
|
||||
other->GetEquipmentColor(EQ::textures::weaponSecondary)
|
||||
);
|
||||
|
||||
if (IsNPC()) {
|
||||
auto primary_skill = (
|
||||
other->IsNPC() ?
|
||||
other->CastToNPC()->GetPrimSkill() :
|
||||
ConvertItemTypeToSkillID(other->GetEquipmentType(EQ::textures::weaponSecondary))
|
||||
);
|
||||
|
||||
auto secondary_skill = (
|
||||
other->IsNPC() ?
|
||||
other->CastToNPC()->GetSecSkill() :
|
||||
ConvertItemTypeToSkillID(other->GetEquipmentType(EQ::textures::weaponSecondary))
|
||||
);
|
||||
|
||||
CastToNPC()->SetPrimSkill(primary_skill);
|
||||
CastToNPC()->SetSecSkill(secondary_skill);
|
||||
}
|
||||
|
||||
if (clone_name) {
|
||||
TempName(other->GetCleanName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user