mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 17:58:20 +00:00
Merge branch 'DarkflameUniverse:main' into main
This commit is contained in:
commit
2b92bbc45f
@ -123,6 +123,9 @@ make_directory(${CMAKE_BINARY_DIR}/res)
|
||||
# Create a /locale directory
|
||||
make_directory(${CMAKE_BINARY_DIR}/locale)
|
||||
|
||||
# Create a /logs directory
|
||||
make_directory(${CMAKE_BINARY_DIR}/logs)
|
||||
|
||||
# Copy ini files on first build
|
||||
if (NOT EXISTS ${PROJECT_BINARY_DIR}/authconfig.ini)
|
||||
configure_file(
|
||||
|
@ -236,6 +236,8 @@ The client script for the survival minigame has a bug in it which can cause the
|
||||
* Change `PlayerReady(self)` to `onPlayerReady(self)`
|
||||
* Save the file, overriding readonly mode if required
|
||||
|
||||
If you still experience the bug, try deleting/renaming `res/pack/scripts.pak`.
|
||||
|
||||
### Brick-By-Brick building
|
||||
|
||||
Brick-By-Brick building requires `PATCHSERVERIP=0:` in the `boot.cfg` to point to a HTTP server which always returns `HTTP 404 - Not Found` for all requests. This can be achieved by pointing it to `localhost` while having `sudo python -m http.server 80` running in the background.
|
||||
|
@ -45,6 +45,7 @@ int main(int argc, char** argv) {
|
||||
dConfig config("authconfig.ini");
|
||||
Game::config = &config;
|
||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||
|
||||
//Connect to the MySQL Database
|
||||
std::string mysql_host = config.GetValue("mysql_host");
|
||||
@ -152,11 +153,13 @@ int main(int argc, char** argv) {
|
||||
dLogger * SetupLogger() {
|
||||
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
|
||||
bool logToConsole = false;
|
||||
bool logDebugStatements = false;
|
||||
#ifdef _DEBUG
|
||||
logToConsole = true;
|
||||
logDebugStatements = true;
|
||||
#endif
|
||||
|
||||
return new dLogger(logPath, logToConsole);
|
||||
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||
}
|
||||
|
||||
void HandlePacket(Packet* packet) {
|
||||
|
@ -48,6 +48,7 @@ int main(int argc, char** argv) {
|
||||
dConfig config("chatconfig.ini");
|
||||
Game::config = &config;
|
||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||
|
||||
//Connect to the MySQL Database
|
||||
std::string mysql_host = config.GetValue("mysql_host");
|
||||
@ -159,11 +160,13 @@ int main(int argc, char** argv) {
|
||||
dLogger * SetupLogger() {
|
||||
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
|
||||
bool logToConsole = false;
|
||||
bool logDebugStatements = false;
|
||||
#ifdef _DEBUG
|
||||
logToConsole = true;
|
||||
logDebugStatements = true;
|
||||
#endif
|
||||
|
||||
return new dLogger(logPath, logToConsole);
|
||||
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||
}
|
||||
|
||||
void HandlePacket(Packet* packet) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "dLogger.h"
|
||||
|
||||
dLogger::dLogger(const std::string& outpath, bool logToConsole) {
|
||||
dLogger::dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements) {
|
||||
m_logToConsole = logToConsole;
|
||||
m_logDebugStatements = logDebugStatements;
|
||||
m_outpath = outpath;
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -24,39 +25,25 @@ dLogger::~dLogger() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void dLogger::LogBasic(const std::string & message) {
|
||||
LogBasic(message.c_str());
|
||||
}
|
||||
|
||||
void dLogger::LogBasic(const char * format, ...) {
|
||||
void dLogger::vLog(const char* format, va_list args) {
|
||||
#ifdef _WIN32
|
||||
time_t t = time(NULL);
|
||||
struct tm time;
|
||||
localtime_s(&time, &t);
|
||||
|
||||
char timeStr[70];
|
||||
|
||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
||||
|
||||
char message[2048];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsprintf_s(message, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (m_logToConsole) std::cout << "[" << "time machine broke" << "] " << message;
|
||||
mFile << "[" << "time" << "] " << message;
|
||||
if (m_logToConsole) std::cout << "[" << timeStr << "] " << message;
|
||||
mFile << "[" << timeStr << "] " << message;
|
||||
#else
|
||||
time_t t = time(NULL);
|
||||
struct tm * time = localtime(&t);
|
||||
char timeStr[70];
|
||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
||||
|
||||
char message[2048];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsprintf(message, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (m_logToConsole) {
|
||||
fputs("[", stdout);
|
||||
@ -76,62 +63,42 @@ void dLogger::LogBasic(const char * format, ...) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void dLogger::LogBasic(const char * format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vLog(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void dLogger::LogBasic(const std::string & message) {
|
||||
LogBasic(message.c_str());
|
||||
}
|
||||
|
||||
void dLogger::Log(const char * className, const char * format, ...) {
|
||||
#ifdef _WIN32
|
||||
time_t t = time(NULL);
|
||||
struct tm time;
|
||||
localtime_s(&time, &t);
|
||||
|
||||
char timeStr[70];
|
||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
||||
|
||||
char message[2048];
|
||||
va_list args;
|
||||
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||
va_start(args, format);
|
||||
vsprintf_s(message, format, args);
|
||||
|
||||
vLog(log.c_str(), args);
|
||||
va_end(args);
|
||||
|
||||
if (m_logToConsole) std::cout << "[" << timeStr << "] [" << className << "]: " << message;
|
||||
mFile << "[" << timeStr << "] [" << className << "]: " << message;
|
||||
#else
|
||||
time_t t = time(NULL);
|
||||
struct tm * time = localtime(&t);
|
||||
char timeStr[70];
|
||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
||||
|
||||
char message[2048];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsprintf(message, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (m_logToConsole) {
|
||||
fputs("[", stdout);
|
||||
fputs(timeStr, stdout);
|
||||
fputs("] ", stdout);
|
||||
fputs("[", stdout);
|
||||
fputs(className, stdout);
|
||||
fputs("]: ", stdout);
|
||||
fputs(message, stdout);
|
||||
}
|
||||
|
||||
if (fp != NULL) {
|
||||
fputs("[", fp);
|
||||
fputs(timeStr, fp);
|
||||
fputs("] ", fp);
|
||||
fputs("[", fp);
|
||||
fputs(className, fp);
|
||||
fputs("]: ", fp);
|
||||
fputs(message, fp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void dLogger::Log(const std::string & className, const std::string & message) {
|
||||
Log(className.c_str(), message.c_str());
|
||||
}
|
||||
|
||||
void dLogger::LogDebug(const char * className, const char * format, ...) {
|
||||
if (!m_logDebugStatements) return;
|
||||
va_list args;
|
||||
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||
va_start(args, format);
|
||||
vLog(log.c_str(), args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void dLogger::LogDebug(const std::string & className, const std::string & message) {
|
||||
LogDebug(className.c_str(), message.c_str());
|
||||
}
|
||||
|
||||
void dLogger::Flush() {
|
||||
#ifdef _WIN32
|
||||
mFile.flush();
|
||||
|
@ -7,21 +7,26 @@
|
||||
|
||||
class dLogger {
|
||||
public:
|
||||
dLogger(const std::string& outpath, bool logToConsole);
|
||||
dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements);
|
||||
~dLogger();
|
||||
|
||||
void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; }
|
||||
void SetLogDebugStatements(bool logDebugStatements) { m_logDebugStatements = logDebugStatements; }
|
||||
void vLog(const char* format, va_list args);
|
||||
|
||||
void LogBasic(const std::string& message);
|
||||
void LogBasic(const char* format, ...);
|
||||
void Log(const char* className, const char* format, ...);
|
||||
void Log(const std::string& className, const std::string& message);
|
||||
void LogDebug(const std::string& className, const std::string& message);
|
||||
void LogDebug(const char* className, const char* format, ...);
|
||||
|
||||
void Flush();
|
||||
|
||||
const bool GetIsLoggingToConsole() const { return m_logToConsole; }
|
||||
|
||||
private:
|
||||
bool m_logDebugStatements;
|
||||
bool m_logToConsole;
|
||||
std::string m_outpath;
|
||||
std::ofstream mFile;
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
*/
|
||||
uint64_t GetLastLogin() const { return m_LastLogin; }
|
||||
|
||||
|
||||
/**
|
||||
* Gets the default shirt color for this character
|
||||
* @return the default shirt color ID
|
||||
@ -134,6 +135,67 @@ public:
|
||||
*/
|
||||
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; }
|
||||
|
||||
|
||||
/**
|
||||
* Whether this character has visited a certain zone
|
||||
* @param mapID the ID of the zone to check for
|
||||
|
@ -1644,6 +1644,26 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
||||
droppedLoot.erase(objectID);
|
||||
}
|
||||
|
||||
bool Entity::CanPickupCoins(uint64_t count) {
|
||||
if (!IsPlayer()) return false;
|
||||
auto* player = static_cast<Player*>(this);
|
||||
auto droppedCoins = player->GetDroppedCoins();
|
||||
if (count > droppedCoins) {
|
||||
return false;
|
||||
} else {
|
||||
player->SetDroppedCoins(droppedCoins - count);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RegisterCoinDrop(uint64_t count) {
|
||||
if (!IsPlayer()) return;
|
||||
auto* player = static_cast<Player*>(this);
|
||||
auto droppedCoins = player->GetDroppedCoins();
|
||||
droppedCoins += count;
|
||||
player->SetDroppedCoins(droppedCoins);
|
||||
}
|
||||
|
||||
void Entity::AddChild(Entity* child) {
|
||||
m_ChildEntities.push_back(child);
|
||||
}
|
||||
@ -1768,6 +1788,7 @@ void Entity::HandleTriggerCommand(std::string id, std::string target, std::strin
|
||||
else if (argArray[0] == "repulse") effectType = 2;
|
||||
else if (argArray[0] == "gravity") effectType = 3;
|
||||
else if (argArray[0] == "friction") effectType = 4;
|
||||
|
||||
phanPhys->SetEffectType(effectType);
|
||||
phanPhys->SetDirectionalMultiplier(std::stof(argArray[1]));
|
||||
if (argArray.size() > 4) {
|
||||
@ -1781,6 +1802,10 @@ void Entity::HandleTriggerCommand(std::string id, std::string target, std::strin
|
||||
phanPhys->SetMin(std::stoi(argArray[6]));
|
||||
phanPhys->SetMax(std::stoi(argArray[7]));
|
||||
}
|
||||
|
||||
if (target == "self") {
|
||||
EntityManager::Instance()->ConstructEntity(this);
|
||||
}
|
||||
}
|
||||
else if (id == "updateMission") {
|
||||
CDMissionTasksTable* missionTasksTable = CDClientManager::Instance()->GetTable<CDMissionTasksTable>("MissionTasks");
|
||||
|
@ -202,6 +202,9 @@ public:
|
||||
void AddLootItem(const Loot::Info& info);
|
||||
void PickupItem(const LWOOBJID& objectID);
|
||||
|
||||
bool CanPickupCoins(uint64_t count);
|
||||
void RegisterCoinDrop(uint64_t count);
|
||||
|
||||
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
||||
void TriggerEvent(std::string eveneventtID, Entity* optionalTarget = nullptr);
|
||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||
|
@ -24,6 +24,7 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
|
||||
m_GMLevel = m_Character->GetGMLevel();
|
||||
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
||||
m_DroppedLoot = {};
|
||||
m_DroppedCoins = 0;
|
||||
|
||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
||||
@ -290,6 +291,14 @@ const std::vector<Player*>& Player::GetAllPlayers()
|
||||
return m_Players;
|
||||
}
|
||||
|
||||
uint64_t Player::GetDroppedCoins() {
|
||||
return m_DroppedCoins;
|
||||
}
|
||||
|
||||
void Player::SetDroppedCoins(uint64_t value) {
|
||||
m_DroppedCoins = value;
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
Game::logger->Log("Player", "Deleted player\n");
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
|
||||
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
|
||||
|
||||
uint64_t GetDroppedCoins();
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
@ -52,6 +54,8 @@ public:
|
||||
|
||||
void SetGhostOverride(bool value);
|
||||
|
||||
void SetDroppedCoins(uint64_t value);
|
||||
|
||||
/**
|
||||
* Wrapper for sending an in-game mail.
|
||||
*
|
||||
@ -126,5 +130,7 @@ private:
|
||||
|
||||
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
||||
|
||||
uint64_t m_DroppedCoins;
|
||||
|
||||
static std::vector<Player*> m_Players;
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
||||
includeFaction = 1;
|
||||
}
|
||||
|
||||
for (auto validTarget : context->GetValidTargets(m_ignoreFaction , includeFaction))
|
||||
for (auto validTarget : context->GetValidTargets(m_ignoreFaction , includeFaction, m_TargetSelf == 1))
|
||||
{
|
||||
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
||||
|
||||
@ -155,4 +155,6 @@ void AreaOfEffectBehavior::Load()
|
||||
this->m_ignoreFaction = GetInt("ignore_faction");
|
||||
|
||||
this->m_includeFaction = GetInt("include_faction");
|
||||
|
||||
this->m_TargetSelf = GetInt("target_self");
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ public:
|
||||
|
||||
int32_t m_includeFaction;
|
||||
|
||||
int32_t m_TargetSelf;
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
|
@ -325,7 +325,7 @@ void BehaviorContext::Reset()
|
||||
this->scheduledUpdates.clear();
|
||||
}
|
||||
|
||||
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction) const
|
||||
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf) const
|
||||
{
|
||||
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
||||
|
||||
@ -353,7 +353,7 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && !entity->HasComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS) && targets.empty()))
|
||||
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && targets.empty()))
|
||||
{
|
||||
DestroyableComponent* destroyableComponent;
|
||||
if (!entity->TryGetComponent(COMPONENT_TYPE_DESTROYABLE, destroyableComponent))
|
||||
@ -362,12 +362,11 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
||||
}
|
||||
|
||||
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
|
||||
|
||||
for (auto* candidate : entities)
|
||||
{
|
||||
const auto id = candidate->GetObjectID();
|
||||
|
||||
if (destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction))
|
||||
if ((id != entity->GetObjectID() || targetSelf) && destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction))
|
||||
{
|
||||
targets.push_back(id);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ struct BehaviorContext
|
||||
|
||||
void Reset();
|
||||
|
||||
std::vector<LWOOBJID> GetValidTargets(int32_t ignoreFaction = 0, int32_t includeFaction = 0) const;
|
||||
std::vector<LWOOBJID> GetValidTargets(int32_t ignoreFaction = 0, int32_t includeFaction = 0, const bool targetSelf = false) const;
|
||||
|
||||
explicit BehaviorContext(LWOOBJID originator, bool calculation = false);
|
||||
|
||||
|
@ -1,44 +1,81 @@
|
||||
#include "ForceMovementBehavior.h"
|
||||
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "ControllablePhysicsComponent.h"
|
||||
#include "EntityManager.h"
|
||||
|
||||
void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
||||
{
|
||||
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY)
|
||||
{
|
||||
void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t handle;
|
||||
|
||||
bitStream->Read(handle);
|
||||
|
||||
context->RegisterSyncBehavior(handle, this, branch);
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
uint32_t next;
|
||||
|
||||
bitStream->Read(next);
|
||||
|
||||
LWOOBJID target;
|
||||
|
||||
bitStream->Read(target);
|
||||
|
||||
auto* behavior = CreateBehavior(next);
|
||||
|
||||
branch.target = target;
|
||||
|
||||
auto* behavior = CreateBehavior(next);
|
||||
behavior->Handle(context, bitStream, branch);
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
|
||||
if (casterEntity != nullptr) {
|
||||
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
|
||||
if (m_Forward == 1) {
|
||||
controllablePhysicsComponent->SetVelocity(controllablePhysicsComponent->GetRotation().GetForwardVector() * 25);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(casterEntity);
|
||||
}
|
||||
}
|
||||
|
||||
const auto skillHandle = context->GetUniqueSkillId();
|
||||
bitStream->Write(skillHandle);
|
||||
|
||||
context->SyncCalculation(skillHandle, this->m_Duration, this, branch);
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::Load()
|
||||
{
|
||||
this->m_hitAction = GetAction("hit_action");
|
||||
|
||||
this->m_hitEnemyAction = GetAction("hit_action_enemy");
|
||||
|
||||
this->m_hitFactionAction = GetAction("hit_action_faction");
|
||||
this->m_Duration = GetFloat("duration");
|
||||
this->m_Forward = GetFloat("forward");
|
||||
this->m_Left = GetFloat("left");
|
||||
this->m_Yaw = GetFloat("yaw");
|
||||
}
|
||||
|
||||
void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto* casterEntity = EntityManager::Instance()->GetEntity(context->caster);
|
||||
if (casterEntity != nullptr) {
|
||||
auto* controllablePhysicsComponent = casterEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
|
||||
controllablePhysicsComponent->SetPosition(controllablePhysicsComponent->GetPosition() + controllablePhysicsComponent->GetVelocity() * m_Duration);
|
||||
controllablePhysicsComponent->SetVelocity({});
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(casterEntity);
|
||||
}
|
||||
}
|
||||
|
||||
this->m_hitAction->Calculate(context, bitStream, branch);
|
||||
this->m_hitEnemyAction->Calculate(context, bitStream, branch);
|
||||
this->m_hitEnemyAction->Calculate(context, bitStream, branch);
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ public:
|
||||
|
||||
Behavior* m_hitFactionAction;
|
||||
|
||||
float_t m_Duration;
|
||||
float_t m_Forward;
|
||||
float_t m_Left;
|
||||
float_t m_Yaw;
|
||||
|
||||
/*
|
||||
* Inherited
|
||||
*/
|
||||
@ -18,8 +23,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void Calculate(BehaviorContext *context, RakNet::BitStream *bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void SyncCalculation(BehaviorContext *context, RakNet::BitStream *bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||
|
||||
void Load() override;
|
||||
|
@ -129,6 +129,9 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
|
||||
BaseCombatAIComponent::~BaseCombatAIComponent() {
|
||||
if (m_dpEntity)
|
||||
dpWorld::Instance().RemoveEntity(m_dpEntity);
|
||||
|
||||
if (m_dpEntityEnemy)
|
||||
dpWorld::Instance().RemoveEntity(m_dpEntityEnemy);
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
|
@ -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;
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* Whether this character is racing
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "NiQuaternion.h"
|
||||
#include "tinyxml2.h"
|
||||
#include "Component.h"
|
||||
#include "dpCollisionChecks.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
|
||||
class Entity;
|
||||
class dpEntity;
|
||||
@ -218,6 +220,13 @@ public:
|
||||
*/
|
||||
bool GetStatic() const { return m_Static; }
|
||||
|
||||
/**
|
||||
* Returns the Physics entity for the component
|
||||
* @return Physics entity for the component
|
||||
*/
|
||||
|
||||
dpEntity* GetdpEntity() const { return m_dpEntity; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The entity that owns this component
|
||||
|
@ -110,6 +110,13 @@ public:
|
||||
*/
|
||||
void SetEffectType(uint32_t type);
|
||||
|
||||
/**
|
||||
* Returns the Physics entity for the component
|
||||
* @return Physics entity for the component
|
||||
*/
|
||||
|
||||
dpEntity* GetdpEntity() const { return m_dpEntity; }
|
||||
|
||||
/**
|
||||
* Spawns an object at each of the vertices for debugging purposes
|
||||
*/
|
||||
|
@ -1031,6 +1031,10 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
|
||||
entity->AddLootItem(info);
|
||||
}
|
||||
|
||||
if (item == LOT_NULL && currency != 0) {
|
||||
entity->RegisterCoinDrop(currency);
|
||||
}
|
||||
|
||||
if (spawnPos != NiPoint3::ZERO) {
|
||||
bUsePosition = true;
|
||||
|
||||
@ -5232,9 +5236,13 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent
|
||||
unsigned int currency;
|
||||
inStream->Read(currency);
|
||||
|
||||
if (currency == 0) return;
|
||||
|
||||
auto* ch = entity->GetCharacter();
|
||||
if (entity->CanPickupCoins(currency)) {
|
||||
ch->SetCoins(ch->GetCoins() + currency);
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) {
|
||||
LWOOBJID killerID;
|
||||
|
@ -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.");
|
||||
|
||||
|
@ -72,6 +72,7 @@ int main(int argc, char** argv) {
|
||||
dConfig config("masterconfig.ini");
|
||||
Game::config = &config;
|
||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||
|
||||
//Connect to CDClient
|
||||
try {
|
||||
@ -326,11 +327,13 @@ dLogger* SetupLogger() {
|
||||
std::string logPath =
|
||||
"./logs/MasterServer_" + std::to_string(time(nullptr)) + ".log";
|
||||
bool logToConsole = false;
|
||||
bool logDebugStatements = false;
|
||||
#ifdef _DEBUG
|
||||
logToConsole = true;
|
||||
logDebugStatements = true;
|
||||
#endif
|
||||
|
||||
return new dLogger(logPath, logToConsole);
|
||||
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||
}
|
||||
|
||||
void HandlePacket(Packet* packet) {
|
||||
|
24
dScripts/BuccaneerValiantShip.cpp
Normal file
24
dScripts/BuccaneerValiantShip.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "BuccaneerValiantShip.h"
|
||||
#include "SkillComponent.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
void BuccaneerValiantShip::OnStartup(Entity* self) {
|
||||
const auto skill = 982;
|
||||
const auto behavior = 20577;
|
||||
const auto skillCastTimer = 1.0F;
|
||||
|
||||
self->AddCallbackTimer(skillCastTimer, [self]() {
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
auto* owner = self->GetOwner();
|
||||
|
||||
if (skillComponent != nullptr && owner != nullptr) {
|
||||
skillComponent->CalculateBehavior(skill, behavior, LWOOBJID_EMPTY, true, false, owner->GetObjectID());
|
||||
|
||||
// Kill self if missed
|
||||
const auto selfSmashTimer = 1.1F;
|
||||
self->AddCallbackTimer(selfSmashTimer, [self]() {
|
||||
self->Kill();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
6
dScripts/BuccaneerValiantShip.h
Normal file
6
dScripts/BuccaneerValiantShip.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "CppScripts.h"
|
||||
|
||||
class BuccaneerValiantShip : public CppScripts::Script {
|
||||
void OnStartup(Entity *self) override;
|
||||
};
|
@ -261,6 +261,7 @@
|
||||
#include "PersonalFortress.h"
|
||||
#include "PropertyDevice.h"
|
||||
#include "ImaginationBackpackHealServer.h"
|
||||
#include "BuccaneerValiantShip.h"
|
||||
|
||||
// Survival scripts
|
||||
#include "AgSurvivalStromling.h"
|
||||
@ -774,6 +775,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
script = new PropertyDevice();
|
||||
else if (scriptName == "scripts\\02_server\\Map\\General\\L_IMAG_BACKPACK_HEALS_SERVER.lua")
|
||||
script = new ImaginationBackpackHealServer();
|
||||
else if (scriptName == "scripts\\EquipmentScripts\\BuccaneerValiantShip.lua")
|
||||
script = new BuccaneerValiantShip();
|
||||
|
||||
//Ignore these scripts:
|
||||
else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua")
|
||||
@ -782,7 +785,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
||||
script = invalidToReturn;
|
||||
else if (script == invalidToReturn) {
|
||||
if (scriptName.length() > 0)
|
||||
Game::logger->Log("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
||||
Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
||||
// information not really needed for sys admins but is for developers
|
||||
|
||||
script = invalidToReturn;
|
||||
}
|
||||
|
@ -50,19 +50,19 @@ void NsTokenConsoleServer::OnUse(Entity* self, Entity* user)
|
||||
|
||||
if (character->GetPlayerFlag(46))
|
||||
{
|
||||
inventoryComponent->AddItem(8321, 1);
|
||||
inventoryComponent->AddItem(8321, 5);
|
||||
}
|
||||
else if (character->GetPlayerFlag(47))
|
||||
{
|
||||
inventoryComponent->AddItem(8318, 1);
|
||||
inventoryComponent->AddItem(8318, 5);
|
||||
}
|
||||
else if (character->GetPlayerFlag(48))
|
||||
{
|
||||
inventoryComponent->AddItem(8320, 1);
|
||||
inventoryComponent->AddItem(8320, 5);
|
||||
}
|
||||
else if (character->GetPlayerFlag(49))
|
||||
{
|
||||
inventoryComponent->AddItem(8319, 1);
|
||||
inventoryComponent->AddItem(8319, 5);
|
||||
}
|
||||
|
||||
missionComponent->ForceProgressTaskType(863, 1, 1, false);
|
||||
|
@ -136,6 +136,7 @@ int main(int argc, char** argv) {
|
||||
dConfig config("worldconfig.ini");
|
||||
Game::config = &config;
|
||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||
if (config.GetValue("disable_chat") == "1") chatDisabled = true;
|
||||
|
||||
// Connect to CDClient
|
||||
@ -503,11 +504,13 @@ int main(int argc, char** argv) {
|
||||
dLogger * SetupLogger(int zoneID, int instanceID) {
|
||||
std::string logPath = "./logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log";
|
||||
bool logToConsole = false;
|
||||
bool logDebugStatements = false;
|
||||
#ifdef _DEBUG
|
||||
logToConsole = true;
|
||||
logDebugStatements = true;
|
||||
#endif
|
||||
|
||||
return new dLogger(logPath, logToConsole);
|
||||
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||
}
|
||||
|
||||
void HandlePacketChat(Packet* packet) {
|
||||
|
@ -19,6 +19,9 @@ max_clients=999
|
||||
# 0 or 1, should log to console
|
||||
log_to_console=1
|
||||
|
||||
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||
log_debug_statements=0
|
||||
|
||||
# 0 or 1, should ignore playkeys
|
||||
# If 1 everyone with an account will be able to login, regardless of if they have a key or not
|
||||
dont_use_keys=0
|
||||
|
@ -19,5 +19,8 @@ max_clients=999
|
||||
# 0 or 1, should log to console
|
||||
log_to_console=1
|
||||
|
||||
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||
log_debug_statements=0
|
||||
|
||||
# 0 or 1, should not compile chat hash map to file
|
||||
dont_generate_dcf=0
|
||||
|
@ -35,5 +35,8 @@ max_clients=999
|
||||
# 0 or 1, should log to console
|
||||
log_to_console=1
|
||||
|
||||
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||
log_debug_statements=0
|
||||
|
||||
# 0 or 1, should autostart auth, chat, and char servers
|
||||
prestart_servers=1
|
||||
|
@ -20,6 +20,9 @@ max_clients=999
|
||||
# 0 or 1, should log to console
|
||||
log_to_console=1
|
||||
|
||||
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||
log_debug_statements=0
|
||||
|
||||
# 0 or 1, should not compile chat hash map to file
|
||||
dont_generate_dcf=0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user