mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Minifig editing
This commit is contained in:
parent
82a1c8a765
commit
6500b62c52
@ -74,65 +74,127 @@ public:
|
||||
*/
|
||||
uint64_t GetLastLogin() const { return m_LastLogin; }
|
||||
|
||||
/**
|
||||
* Gets the default shirt color for this character
|
||||
* @return the default shirt color ID
|
||||
*/
|
||||
uint32_t GetShirtColor() const { return m_ShirtColor; }
|
||||
|
||||
/**
|
||||
* Gets the default hair style for this character
|
||||
* @return the default hair style ID
|
||||
*/
|
||||
uint32_t GetShirtStyle() const { return m_ShirtStyle; }
|
||||
/**
|
||||
* Gets the default shirt color for this character
|
||||
* @return the default shirt color ID
|
||||
*/
|
||||
uint32_t GetShirtColor() const { return m_ShirtColor; }
|
||||
|
||||
/**
|
||||
* Gets the default pants color for this character
|
||||
* @return the default pants color ID
|
||||
*/
|
||||
uint32_t GetPantsColor() const { return m_PantsColor; }
|
||||
/**
|
||||
* Gets the default hair style for this character
|
||||
* @return the default hair style ID
|
||||
*/
|
||||
uint32_t GetShirtStyle() const { return m_ShirtStyle; }
|
||||
|
||||
/**
|
||||
* Gets the default hair color for this character
|
||||
* @return the default hair color ID
|
||||
*/
|
||||
uint32_t GetHairColor() const { return m_HairColor; }
|
||||
/**
|
||||
* Gets the default pants color for this character
|
||||
* @return the default pants color ID
|
||||
*/
|
||||
uint32_t GetPantsColor() const { return m_PantsColor; }
|
||||
|
||||
/**
|
||||
* Gets the default hair style of this character
|
||||
* @return the default hair style ID
|
||||
*/
|
||||
uint32_t GetHairStyle() const { return m_HairStyle; }
|
||||
/**
|
||||
* Gets the default hair color for this character
|
||||
* @return the default hair color ID
|
||||
*/
|
||||
uint32_t GetHairColor() const { return m_HairColor; }
|
||||
|
||||
/**
|
||||
* Gets the eyes config for this character
|
||||
* @return the eyes config ID
|
||||
*/
|
||||
uint32_t GetEyes() const { return m_Eyes; }
|
||||
/**
|
||||
* Gets the default hair style of this character
|
||||
* @return the default hair style ID
|
||||
*/
|
||||
uint32_t GetHairStyle() const { return m_HairStyle; }
|
||||
|
||||
/**
|
||||
* Gets the eyebrows config for this character
|
||||
* @return the eyebrow config ID
|
||||
*/
|
||||
uint32_t GetEyebrows() const { return m_Eyebrows; }
|
||||
/**
|
||||
* Gets the eyes config for this character
|
||||
* @return the eyes config ID
|
||||
*/
|
||||
uint32_t GetEyes() const { return m_Eyes; }
|
||||
|
||||
/**
|
||||
* Get the mouth of this character
|
||||
* @return the mouth ID
|
||||
*/
|
||||
uint32_t GetMouth() const { return m_Mouth; }
|
||||
/**
|
||||
* Gets the eyebrows config for this character
|
||||
* @return the eyebrow config ID
|
||||
*/
|
||||
uint32_t GetEyebrows() const { return m_Eyebrows; }
|
||||
|
||||
/**
|
||||
* Gets the left hand color of this character
|
||||
* @return the left hand color ID
|
||||
*/
|
||||
uint32_t GetLeftHand() const { return m_LeftHand; }
|
||||
/**
|
||||
* Get the mouth of this character
|
||||
* @return the mouth ID
|
||||
*/
|
||||
uint32_t GetMouth() const { return m_Mouth; }
|
||||
|
||||
/**
|
||||
* Gets the left hand color of this character
|
||||
* @return the left hand color ID
|
||||
*/
|
||||
uint32_t GetLeftHand() const { return m_LeftHand; }
|
||||
|
||||
/**
|
||||
* Gets the right hand color of this character
|
||||
* @return the right hand color ID
|
||||
*/
|
||||
uint32_t GetRightHand() const { return m_RightHand; }
|
||||
|
||||
/**
|
||||
* Sets the default shirt color for this character
|
||||
* @param color the shirt color ID to set
|
||||
*/
|
||||
void SetShirtColor(uint32_t color) { m_ShirtColor = color; }
|
||||
|
||||
/**
|
||||
* Sets the default shirt style for this character
|
||||
* @param style the shirt style ID to set
|
||||
*/
|
||||
void SetShirtStyle(uint32_t style) { m_ShirtStyle = style; }
|
||||
|
||||
/**
|
||||
* Sets the default pants color for this character
|
||||
* @param color the pants color ID to set
|
||||
*/
|
||||
void SetPantsColor(uint32_t color) { m_PantsColor = color; }
|
||||
|
||||
/**
|
||||
* Sets the default hair color for this character
|
||||
* @param color the hair color ID to set
|
||||
*/
|
||||
void SetHairColor(uint32_t color) { m_HairColor = color; }
|
||||
|
||||
/**
|
||||
* Sets the default hair style for this character
|
||||
* @param style the hair style ID to set
|
||||
*/
|
||||
void SetHairStyle(uint32_t style) { m_HairStyle = style; }
|
||||
|
||||
/**
|
||||
* Sets the eyes config for this character
|
||||
* @param eyes the eyes config ID to set
|
||||
*/
|
||||
void SetEyes(uint32_t eyes) { m_Eyes = eyes; }
|
||||
|
||||
/**
|
||||
* Sets the eyebrows config for this character
|
||||
* @param eyebrows the eyebrows config ID to set
|
||||
*/
|
||||
void SetEyebrows(uint32_t eyebrows) { m_Eyebrows = eyebrows; }
|
||||
|
||||
/**
|
||||
* Sets the mouth config for this character
|
||||
* @param mouth the mouth config ID to set
|
||||
*/
|
||||
void SetMouth(uint32_t mouth) { m_Mouth = mouth; }
|
||||
|
||||
/**
|
||||
* Sets the left hand color for this character
|
||||
* @param color the left hand color ID to set
|
||||
*/
|
||||
void SetLeftHand(uint32_t leftHand) { m_LeftHand = leftHand; }
|
||||
|
||||
/**
|
||||
* Sets the right hand color for this character
|
||||
* @param color the right hand color ID to set
|
||||
*/
|
||||
void SetRightHand(uint32_t rightHand) { m_RightHand = rightHand; }
|
||||
|
||||
/**
|
||||
* Gets the right hand color of this character
|
||||
* @return the right hand color ID
|
||||
*/
|
||||
uint32_t GetRightHand() const { return m_RightHand; }
|
||||
|
||||
/**
|
||||
* Whether this character has visited a certain zone
|
||||
|
@ -352,6 +352,26 @@ void CharacterComponent::LoadFromXML() {
|
||||
}
|
||||
|
||||
void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
tinyxml2::XMLElement* minifig = doc->FirstChildElement("obj")->FirstChildElement("mf");
|
||||
if (!minifig) {
|
||||
Game::logger->Log("CharacterComponent", "Failed to find mf tag while updating XML!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// write minifig information that might have been changed by commands
|
||||
|
||||
minifig->SetAttribute("es", m_Character->GetEyebrows());
|
||||
minifig->SetAttribute("ess", m_Character->GetEyes());
|
||||
minifig->SetAttribute("hc", m_Character->GetHairColor());
|
||||
minifig->SetAttribute("hs", m_Character->GetHairStyle());
|
||||
minifig->SetAttribute("l", m_Character->GetPantsColor());
|
||||
minifig->SetAttribute("lh", m_Character->GetLeftHand());
|
||||
minifig->SetAttribute("ms", m_Character->GetMouth());
|
||||
minifig->SetAttribute("rh", m_Character->GetRightHand());
|
||||
minifig->SetAttribute("t", m_Character->GetShirtColor());
|
||||
|
||||
// done with minifig
|
||||
|
||||
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||
if (!character) {
|
||||
Game::logger->Log("CharacterComponent", "Failed to find char tag while updating XML!\n");
|
||||
|
@ -259,11 +259,12 @@ public:
|
||||
*/
|
||||
void UpdatePlayerStatistic(StatisticID updateID, uint64_t updateValue = 1);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Character info regarding this character, including clothing styles, etc.
|
||||
*/
|
||||
Character* m_Character;
|
||||
Character* m_Character;
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* Whether this character is racing
|
||||
|
@ -407,6 +407,50 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
stmt->execute();
|
||||
delete stmt;
|
||||
|
||||
if (chatCommand == "setMinifig" && args.size() == 2 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_FORUM_MODERATOR) { // could break characters so only allow if GM > 0
|
||||
int32_t minifigItemId;
|
||||
if (!GeneralUtils::TryParse(args[1], minifigItemId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
|
||||
return;
|
||||
}
|
||||
EntityManager::Instance()->DestructEntity(entity, sysAddr);
|
||||
auto* charComp = entity->GetComponent<CharacterComponent>();
|
||||
std::string lowerName = args[0];
|
||||
if (lowerName.empty()) return;
|
||||
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
|
||||
if (lowerName == "eyebrows") {
|
||||
charComp->m_Character->SetEyebrows(minifigItemId);
|
||||
} else if (lowerName == "eyes") {
|
||||
charComp->m_Character->SetEyes(minifigItemId);
|
||||
} else if (lowerName == "haircolor") {
|
||||
charComp->m_Character->SetHairColor(minifigItemId);
|
||||
} else if (lowerName == "hairstyle") {
|
||||
charComp->m_Character->SetHairStyle(minifigItemId);
|
||||
} else if (lowerName == "pants") {
|
||||
charComp->m_Character->SetPantsColor(minifigItemId);
|
||||
} else if (lowerName == "lefthand") {
|
||||
charComp->m_Character->SetLeftHand(minifigItemId);
|
||||
} else if (lowerName == "mouth") {
|
||||
charComp->m_Character->SetMouth(minifigItemId);
|
||||
} else if (lowerName == "righthand") {
|
||||
charComp->m_Character->SetRightHand(minifigItemId);
|
||||
} else if (lowerName == "shirt") {
|
||||
charComp->m_Character->SetShirtColor(minifigItemId);
|
||||
} else if (lowerName == "hands") {
|
||||
charComp->m_Character->SetLeftHand(minifigItemId);
|
||||
charComp->m_Character->SetRightHand(minifigItemId);
|
||||
} else {
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig item to change, try one of the following: Eyebrows, Eyes, HairColor, HairStyle, Pants, LeftHand, Mouth, RightHand, Shirt, Hands");
|
||||
return;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(lowerName) + u" set to " + (GeneralUtils::to_u16string(minifigItemId)));
|
||||
|
||||
GameMessages::SendToggleGMInvis(entity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); // need to retoggle because it gets reenabled on creation of new character
|
||||
}
|
||||
|
||||
if (chatCommand == "list-spawns" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
for (const auto& pair : EntityManager::Instance()->GetSpawnPointEntities()) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(pair.first));
|
||||
@ -429,6 +473,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
entity->GetCharacter()->UnlockEmote(emoteID);
|
||||
}
|
||||
|
||||
if (chatCommand == "force-save" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
}
|
||||
|
||||
if (chatCommand == "kill" && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Brutally murdering that player, if online on this server.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user