[Commands] Cleanup #randomizefeatures Command. (#2118)

- Cleanup messages and logic.
- Make #randomizefeatures function for Iksar and Vah Shir.
This commit is contained in:
Kinglykrab 2022-05-06 20:42:34 -04:00 committed by GitHub
parent 2f962c2c8a
commit 6e15fae6a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 239 additions and 189 deletions

View File

@ -2,17 +2,33 @@
void command_randomfeatures(Client *c, const Seperator *sep)
{
Mob *target = c->GetTarget();
if (!target) {
c->Message(Chat::White, "Error: This command requires a target");
if (!c->GetTarget()) {
c->Message(Chat::White, "You must have a target to use this command.");
return;
}
else {
if (target->RandomizeFeatures()) {
c->Message(Chat::White, "Features Randomized");
}
else {
c->Message(Chat::White, "This command requires a Playable Race as the target");
}
auto target = c->GetTarget();
if (target->RandomizeFeatures()) {
c->Message(
Chat::White,
fmt::format(
"{} ({}) has had their features randomized.",
target->GetCleanName(),
target->GetID()
).c_str()
);
} else {
c->Message(
Chat::White,
fmt::format(
"{} ({}) is not a player race, their race is {} ({}).",
target->GetCleanName(),
target->GetID(),
GetRaceIDName(target->GetRace()),
target->GetRace()
).c_str()
);
}
}

View File

@ -2609,194 +2609,223 @@ void Mob::SendIllusionPacket(
bool Mob::RandomizeFeatures(bool send_illusion, bool set_variables)
{
if (IsPlayerRace(GetRace())) {
uint8 Gender = GetGender();
uint8 Texture = 0xFF;
uint8 HelmTexture = 0xFF;
uint8 HairColor = 0xFF;
uint8 BeardColor = 0xFF;
uint8 EyeColor1 = 0xFF;
uint8 EyeColor2 = 0xFF;
uint8 HairStyle = 0xFF;
uint8 LuclinFace = 0xFF;
uint8 Beard = 0xFF;
uint32 DrakkinHeritage = 0xFFFFFFFF;
uint32 DrakkinTattoo = 0xFFFFFFFF;
uint32 DrakkinDetails = 0xFFFFFFFF;
uint8 current_gender = GetGender();
uint8 new_texture = 0xFF;
uint8 new_helm_texture = 0xFF;
uint8 new_hair_color = 0xFF;
uint8 new_beard_color = 0xFF;
uint8 new_eye_color_one = 0xFF;
uint8 new_eye_color_two = 0xFF;
uint8 new_hair_style = 0xFF;
uint8 new_luclin_face = 0xFF;
uint8 new_beard = 0xFF;
uint32 new_drakkin_heritage = 0xFFFFFFFF;
uint32 new_drakkin_tattoo = 0xFFFFFFFF;
uint32 new_drakkin_details = 0xFFFFFFFF;
// Set some common feature settings
EyeColor1 = zone->random.Int(0, 9);
EyeColor2 = zone->random.Int(0, 9);
LuclinFace = zone->random.Int(0, 7);
new_eye_color_one = zone->random.Int(0, 9);
new_eye_color_two = zone->random.Int(0, 9);
new_luclin_face = zone->random.Int(0, 7);
// Adjust all settings based on the min and max for each feature of each race and gender
switch (GetRace()) {
case HUMAN:
HairColor = zone->random.Int(0, 19);
if (Gender == MALE) {
BeardColor = HairColor;
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case BARBARIAN:
HairColor = zone->random.Int(0, 19);
LuclinFace = zone->random.Int(0, 87);
if (Gender == MALE) {
BeardColor = HairColor;
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case ERUDITE:
if (Gender == MALE) {
BeardColor = zone->random.Int(0, 19);
Beard = zone->random.Int(0, 5);
LuclinFace = zone->random.Int(0, 57);
}
if (Gender == FEMALE) {
LuclinFace = zone->random.Int(0, 87);
}
break;
case WOOD_ELF:
HairColor = zone->random.Int(0, 19);
if (Gender == MALE) {
HairStyle = zone->random.Int(0, 3);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case HIGH_ELF:
HairColor = zone->random.Int(0, 14);
if (Gender == MALE) {
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case DARK_ELF:
HairColor = zone->random.Int(13, 18);
if (Gender == MALE) {
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case HALF_ELF:
HairColor = zone->random.Int(0, 19);
if (Gender == MALE) {
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case DWARF:
HairColor = zone->random.Int(0, 19);
BeardColor = HairColor;
if (Gender == MALE) {
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
LuclinFace = zone->random.Int(0, 17);
}
break;
case TROLL:
EyeColor1 = zone->random.Int(0, 10);
EyeColor2 = zone->random.Int(0, 10);
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 3);
HairColor = zone->random.Int(0, 23);
}
break;
case OGRE:
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 3);
HairColor = zone->random.Int(0, 23);
}
break;
case HALFLING:
HairColor = zone->random.Int(0, 19);
if (Gender == MALE) {
BeardColor = HairColor;
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case GNOME:
HairColor = zone->random.Int(0, 24);
if (Gender == MALE) {
BeardColor = HairColor;
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == FEMALE) {
HairStyle = zone->random.Int(0, 2);
}
break;
case IKSAR:
case VAHSHIR:
break;
case FROGLOK:
LuclinFace = zone->random.Int(0, 9);
case DRAKKIN:
HairColor = zone->random.Int(0, 3);
BeardColor = HairColor;
EyeColor1 = zone->random.Int(0, 11);
EyeColor2 = zone->random.Int(0, 11);
LuclinFace = zone->random.Int(0, 6);
DrakkinHeritage = zone->random.Int(0, 6);
DrakkinTattoo = zone->random.Int(0, 7);
DrakkinDetails = zone->random.Int(0, 7);
if (Gender == MALE) {
Beard = zone->random.Int(0, 12);
HairStyle = zone->random.Int(0, 8);
}
if (Gender == FEMALE) {
Beard = zone->random.Int(0, 3);
HairStyle = zone->random.Int(0, 7);
}
break;
default:
break;
case HUMAN:
new_hair_color = zone->random.Int(0, 19);
if (current_gender == MALE) {
new_beard_color = new_hair_color;
new_hair_style = zone->random.Int(0, 3);
new_beard = zone->random.Int(0, 5);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case BARBARIAN:
new_hair_color = zone->random.Int(0, 19);
new_luclin_face = zone->random.Int(0, 87);
if (current_gender == MALE) {
new_beard_color = new_hair_color;
new_hair_style = zone->random.Int(0, 3);
new_beard = zone->random.Int(0, 5);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case ERUDITE:
if (current_gender == MALE) {
new_beard_color = zone->random.Int(0, 19);
new_beard = zone->random.Int(0, 5);
new_luclin_face = zone->random.Int(0, 57);
} else if (current_gender == FEMALE) {
new_luclin_face = zone->random.Int(0, 87);
}
break;
case WOOD_ELF:
new_hair_color = zone->random.Int(0, 19);
if (current_gender == MALE) {
new_hair_style = zone->random.Int(0, 3);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case HIGH_ELF:
new_hair_color = zone->random.Int(0, 14);
if (current_gender == MALE) {
new_hair_style = zone->random.Int(0, 3);
new_luclin_face = zone->random.Int(0, 37);
new_beard_color = new_hair_color;
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case DARK_ELF:
new_hair_color = zone->random.Int(13, 18);
if (current_gender == MALE) {
new_hair_style = zone->random.Int(0, 3);
new_luclin_face = zone->random.Int(0, 37);
new_beard_color = new_hair_color;
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case HALF_ELF:
new_hair_color = zone->random.Int(0, 19);
if (current_gender == MALE) {
new_hair_style = zone->random.Int(0, 3);
new_luclin_face = zone->random.Int(0, 37);
new_beard_color = new_hair_color;
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case DWARF:
new_hair_color = zone->random.Int(0, 19);
new_beard_color = new_hair_color;
if (current_gender == MALE) {
new_hair_style = zone->random.Int(0, 3);
new_beard = zone->random.Int(0, 5);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
new_luclin_face = zone->random.Int(0, 17);
}
break;
case TROLL:
new_eye_color_one = zone->random.Int(0, 10);
new_eye_color_two = zone->random.Int(0, 10);
if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 3);
new_hair_color = zone->random.Int(0, 23);
}
break;
case OGRE:
if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 3);
new_hair_color = zone->random.Int(0, 23);
}
break;
case HALFLING:
new_hair_color = zone->random.Int(0, 19);
if (current_gender == MALE) {
new_beard_color = new_hair_color;
new_hair_style = zone->random.Int(0, 3);
new_beard = zone->random.Int(0, 5);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case GNOME:
new_hair_color = zone->random.Int(0, 24);
if (current_gender == MALE) {
new_beard_color = new_hair_color;
new_hair_style = zone->random.Int(0, 3);
new_beard = zone->random.Int(0, 5);
} else if (current_gender == FEMALE) {
new_hair_style = zone->random.Int(0, 2);
}
break;
case IKSAR:
case VAHSHIR:
new_luclin_face = zone->random.Int(0, 7);
break;
case FROGLOK:
new_luclin_face = zone->random.Int(0, 9);
break;
case DRAKKIN:
new_hair_color = zone->random.Int(0, 3);
new_beard_color = new_hair_color;
new_eye_color_one = zone->random.Int(0, 11);
new_eye_color_two = zone->random.Int(0, 11);
new_luclin_face = zone->random.Int(0, 6);
new_drakkin_heritage = zone->random.Int(0, 6);
new_drakkin_tattoo = zone->random.Int(0, 7);
new_drakkin_details = zone->random.Int(0, 7);
if (current_gender == MALE) {
new_beard = zone->random.Int(0, 12);
new_hair_style = zone->random.Int(0, 8);
} else if (current_gender == FEMALE) {
new_beard = zone->random.Int(0, 3);
new_hair_style = zone->random.Int(0, 7);
}
break;
default:
break;
}
if (set_variables) {
haircolor = HairColor;
beardcolor = BeardColor;
eyecolor1 = EyeColor1;
eyecolor2 = EyeColor2;
hairstyle = HairStyle;
luclinface = LuclinFace;
beard = Beard;
drakkin_heritage = DrakkinHeritage;
drakkin_tattoo = DrakkinTattoo;
drakkin_details = DrakkinDetails;
haircolor = new_hair_color;
beardcolor = new_beard_color;
eyecolor1 = new_eye_color_one;
eyecolor2 = new_eye_color_two;
hairstyle = new_hair_style;
luclinface = new_luclin_face;
beard = new_beard;
drakkin_heritage = new_drakkin_heritage;
drakkin_tattoo = new_drakkin_tattoo;
drakkin_details = new_drakkin_details;
}
if (send_illusion) {
SendIllusionPacket(GetRace(), Gender, Texture, HelmTexture, HairColor, BeardColor,
EyeColor1, EyeColor2, HairStyle, LuclinFace, Beard, 0xFF, DrakkinHeritage,
DrakkinTattoo, DrakkinDetails);
SendIllusionPacket(
GetRace(),
current_gender,
new_texture,
new_helm_texture,
new_hair_color,
new_beard_color,
new_eye_color_one,
new_eye_color_two,
new_hair_style,
new_luclin_face,
new_beard,
0xFF,
new_drakkin_heritage,
new_drakkin_tattoo,
new_drakkin_details
);
}
return true;
@ -2807,8 +2836,13 @@ bool Mob::RandomizeFeatures(bool send_illusion, bool set_variables)
bool Mob::IsPlayerRace(uint16 in_race) {
if ((in_race >= HUMAN && in_race <= GNOME) || in_race == IKSAR || in_race == VAHSHIR || in_race == FROGLOK || in_race == DRAKKIN)
{
if (
(in_race >= HUMAN && in_race <= GNOME) ||
in_race == IKSAR ||
in_race == VAHSHIR ||
in_race == FROGLOK ||
in_race == DRAKKIN
) {
return true;
}