Skip to content

Commit

Permalink
[Quest API] Add SendIllusion overloads/parameters to Perl/Lua (EQEmu#…
Browse files Browse the repository at this point in the history
…3059)

* [Quest API] Add SendIllusion methods to Perl.

# Perl
- Add `$mob->SendIllusion(race, gender, texture, helmtexture, face, hairstyle, haircolor, beard, beardcolor, drakkin_heritage, drakkin_tattoo, drakkin_details, size, target)`.
- Add `$mob->SendIllusionPacket(illusion_table_ref)`.

* Change defaults.

* Remove debug message

* Cleanup.

* Cleanup

* Update perl_mob.cpp
  • Loading branch information
Kinglykrab authored and nytmyr committed Mar 24, 2023
1 parent 70b3b0d commit 0f23fbe
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 71 deletions.
166 changes: 101 additions & 65 deletions zone/lua_mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,153 +1567,189 @@ void Lua_Mob::SendIllusionPacket(luabind::adl::object illusion) {
return;
}

int race = RACE_DOUG_0;
int gender = 255;
int texture = 255;
int helmtexture = 255;
int haircolor = 255;
int beardcolor = 255;
int eyecolor1 = 255;
int eyecolor2 = 255;
int hairstyle = 255;
int luclinface = 255;
int beard = 255;
int aa_title = 255;
uint32 drakkin_heritage = 4294967295;
uint32 drakkin_tattoo = 4294967295;
uint32 drakkin_details = 4294967295;
float size = -1.0f;
uint16 race = self->GetRace();
uint8 gender = self->GetGender();
uint8 texture = self->GetTexture();
uint8 helmtexture = self->GetHelmTexture();
uint8 haircolor = self->GetHairColor();
uint8 beardcolor = self->GetBeardColor();
uint8 eyecolor1 = self->GetEyeColor1();
uint8 eyecolor2 = self->GetEyeColor2();
uint8 hairstyle = self->GetHairStyle();
uint8 luclinface = self->GetLuclinFace();
uint8 beard = self->GetBeard();
uint8 aa_title = 255;
uint32 drakkin_heritage = self->GetDrakkinHeritage();
uint32 drakkin_tattoo = self->GetDrakkinTattoo();
uint32 drakkin_details = self->GetDrakkinDetails();
float size = self->GetSize();
bool send_appearance_effects = true;
Lua_Client target = Lua_Client();

auto cur = illusion["race"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
race = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
race = luabind::object_cast<uint16>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["gender"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
gender = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
gender = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["texture"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
texture = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
texture = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["helmtexture"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
helmtexture = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
helmtexture = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["haircolor"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
haircolor = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
haircolor = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["beardcolor"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
beardcolor = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
beardcolor = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["eyecolor1"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
eyecolor1 = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
eyecolor1 = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["eyecolor2"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
eyecolor2 = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
eyecolor2 = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["hairstyle"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
hairstyle = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
hairstyle = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["luclinface"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
luclinface = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
luclinface = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["beard"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
beard = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
beard = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["aa_title"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
aa_title = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
aa_title = luabind::object_cast<uint8>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["drakkin_heritage"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
drakkin_heritage = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
drakkin_heritage = luabind::object_cast<uint32>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["drakkin_tattoo"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
drakkin_tattoo = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
drakkin_tattoo = luabind::object_cast<uint32>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["drakkin_details"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
drakkin_details = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed &) {
drakkin_details = luabind::object_cast<uint32>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["size"];
if(luabind::type(cur) != LUA_TNIL) {
if (luabind::type(cur) != LUA_TNIL) {
try {
size = luabind::object_cast<float>(cur);
} catch(luabind::cast_failed &) {
} catch (luabind::cast_failed &) {
}
}

self->SendIllusionPacket(race, gender, texture, helmtexture, haircolor, beardcolor, eyecolor1, eyecolor2, hairstyle, luclinface,
beard, aa_title, drakkin_heritage, drakkin_tattoo, drakkin_details, size);
cur = illusion["send_appearance_effects"];
if (luabind::type(cur) != LUA_TNIL) {
try {
send_appearance_effects = luabind::object_cast<bool>(cur);
} catch (luabind::cast_failed &) {
}
}

cur = illusion["target"];
if (luabind::type(cur) != LUA_TNIL) {
try {
target = luabind::object_cast<Lua_Client>(cur);
} catch (luabind::cast_failed &) {
}
}

self->SendIllusionPacket(
race,
gender,
texture,
helmtexture,
haircolor,
beardcolor,
eyecolor1,
eyecolor2,
hairstyle,
luclinface,
beard,
aa_title,
drakkin_heritage,
drakkin_tattoo,
drakkin_details,
size,
send_appearance_effects,
target
);
}

void Lua_Mob::ChangeRace(int in) {
Expand Down
17 changes: 12 additions & 5 deletions zone/mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ Mob::Mob(
}

Mob::~Mob()
{
{
quest_manager.stopalltimers(this);

mMovementManager->RemoveMob(this);
Expand Down Expand Up @@ -2523,7 +2523,8 @@ void Mob::SendIllusionPacket(
uint32 in_drakkin_tattoo,
uint32 in_drakkin_details,
float in_size,
bool send_appearance_effects
bool send_appearance_effects,
Client* target
)
{
uint8 new_texture = in_texture;
Expand Down Expand Up @@ -2626,7 +2627,12 @@ void Mob::SendIllusionPacket(
is->drakkin_details = new_drakkin_details;
is->size = size;

entity_list.QueueClients(this, outapp);
if (!target) {
entity_list.QueueClients(this, outapp);
} else {
target->QueuePacket(outapp, false);
}

safe_delete(outapp);

/* Refresh armor and tints after send illusion packet */
Expand All @@ -2637,7 +2643,7 @@ void Mob::SendIllusionPacket(
}

LogSpells(
"Illusion: Race [{}] Gender [{}] Texture [{}] HelmTexture [{}] HairColor [{}] BeardColor [{}] EyeColor1 [{}] EyeColor2 [{}] HairStyle [{}] Face [{}] DrakkinHeritage [{}] DrakkinTattoo [{}] DrakkinDetails [{}] Size [{}]",
"Illusion: Race [{}] Gender [{}] Texture [{}] HelmTexture [{}] HairColor [{}] BeardColor [{}] EyeColor1 [{}] EyeColor2 [{}] HairStyle [{}] Face [{}] DrakkinHeritage [{}] DrakkinTattoo [{}] DrakkinDetails [{}] Size [{}] Target [{}]",
race,
gender,
new_texture,
Expand All @@ -2651,7 +2657,8 @@ void Mob::SendIllusionPacket(
new_drakkin_heritage,
new_drakkin_tattoo,
new_drakkin_details,
size
size,
target ? target->GetCleanName() : "No Target"
);
}

Expand Down
3 changes: 2 additions & 1 deletion zone/mob.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,8 @@ class Mob : public Entity {
uint32 in_drakkin_tattoo = 0xFFFFFFFF,
uint32 in_drakkin_details = 0xFFFFFFFF,
float in_size = -1.0f,
bool send_appearance_effects = true
bool send_appearance_effects = true,
Client* target = nullptr
);
void CloneAppearance(Mob* other, bool clone_name = false);
void SetFaceAppearance(const FaceChange_Struct& face, bool skip_sender = false);
Expand Down
52 changes: 52 additions & 0 deletions zone/perl_mob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,56 @@ void Perl_Mob_SendIllusion(Mob* self, uint16 race, uint8 gender, uint8 texture,
self->SendIllusionPacket(race, gender, texture, helmtexture, haircolor, beardcolor, 0xFF, 0xFF, hairstyle, face, beard, 0xFF, drakkin_heritage, drakkin_tattoo, drakkin_details, size);
}

void Perl_Mob_SendIllusion(Mob* self, uint16 race, uint8 gender, uint8 texture, uint8 helmtexture, uint8 face, uint8 hairstyle, uint8 haircolor, uint8 beard, uint8 beardcolor, uint32 drakkin_heritage, uint32 drakkin_tattoo, uint32 drakkin_details, float size, Client* target) // @categories Script Utility
{
self->SendIllusionPacket(race, gender, texture, helmtexture, haircolor, beardcolor, 0xFF, 0xFF, hairstyle, face, beard, 0xFF, drakkin_heritage, drakkin_tattoo, drakkin_details, size, true, target);
}

void Perl_Mob_SendIllusionPacket(Mob* self, perl::reference table_ref)
{
perl::hash table = table_ref;

uint16 race = table.exists("race") ? table["race"] : self->GetRace();
uint8 gender = table.exists("gender") ? table["gender"] : self->GetGender();
uint8 texture = table.exists("texture") ? table["texture"] : self->GetTexture();
uint8 helmtexture = table.exists("helmtexture") ? table["helmtexture"] : self->GetHelmTexture();
uint8 haircolor = table.exists("haircolor") ? table["haircolor"] : self->GetHairColor();
uint8 beardcolor = table.exists("beardcolor") ? table["beardcolor"] : self->GetBeardColor();
uint8 eyecolor1 = table.exists("eyecolor1") ? table["eyecolor1"] : self->GetEyeColor1();
uint8 eyecolor2 = table.exists("eyecolor2") ? table["eyecolor2"] : self->GetEyeColor2();
uint8 hairstyle = table.exists("hairstyle") ? table["hairstyle"] : self->GetHairStyle();
uint8 luclinface = table.exists("luclinface") ? table["luclinface"] : self->GetLuclinFace();
uint8 beard = table.exists("beard") ? table["beard"] : self->GetBeard();
uint8 aa_title = table.exists("aa_title") ? table["aa_title"] : 255;
uint32 drakkin_heritage = table.exists("drakkin_heritage") ? table["drakkin_heritage"] : self->GetDrakkinHeritage();
uint32 drakkin_tattoo = table.exists("drakkin_tattoo") ? table["drakkin_tattoo"] : self->GetDrakkinTattoo();
uint32 drakkin_details = table.exists("drakkin_details") ? table["drakkin_details"] : self->GetDrakkinDetails();
float size = table.exists("size") ? table["size"] : self->GetSize();
bool send_appearance_effects = table.exists("send_appearance_effects") ? table["send_appearance_effects"] : true;
Client* target = table.exists("target") ? static_cast<Client *>(table["target"]) : nullptr;

self->SendIllusionPacket(
race,
gender,
texture,
helmtexture,
haircolor,
beardcolor,
eyecolor1,
eyecolor2,
hairstyle,
luclinface,
beard,
aa_title,
drakkin_heritage,
drakkin_tattoo,
drakkin_details,
size,
send_appearance_effects,
target
);
}

void Perl_Mob_CameraEffect(Mob* self, uint32 duration) // @categories Script Utility
{
self->CameraEffect(duration, 0.03125f);
Expand Down Expand Up @@ -3382,6 +3432,8 @@ void perl_register_mob()
package.add("SendIllusion", (void(*)(Mob*, uint16, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint32, uint32))&Perl_Mob_SendIllusion);
package.add("SendIllusion", (void(*)(Mob*, uint16, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint32, uint32, uint32))&Perl_Mob_SendIllusion);
package.add("SendIllusion", (void(*)(Mob*, uint16, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint32, uint32, uint32, float))&Perl_Mob_SendIllusion);
package.add("SendIllusion", (void(*)(Mob*, uint16, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint32, uint32, uint32, float, Client*))&Perl_Mob_SendIllusion);
package.add("SendIllusionPacket", (void(*)(Mob*, perl::reference))&Perl_Mob_SendIllusionPacket);
package.add("SendTo", &Perl_Mob_SendTo);
package.add("SendToFixZ", &Perl_Mob_SendToFixZ);
package.add("SendWearChange", &Perl_Mob_SendWearChange);
Expand Down

0 comments on commit 0f23fbe

Please sign in to comment.