From 53b1169fc90daabde97a3ca61b09f675fbab83df Mon Sep 17 00:00:00 2001 From: "Niko H." Date: Thu, 27 Feb 2025 14:39:08 +0200 Subject: [PATCH] aura fixes and server config --- doc/README.md | 5 +- src/Controls/ProcessCommand.js | 12 ++ src/Renderer/Entity/EntityAura.js | 195 +++++++++++++++++------------- 3 files changed, 124 insertions(+), 88 deletions(-) diff --git a/doc/README.md b/doc/README.md index 28ecf674..91e36f0f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -19,6 +19,8 @@ This guide has the goal to help you to Setup/Play RoBrowser. If there's any trou - [4.2 Serving Game: Development](#42-serving-game-development) - [4.3 Serving Game: using Browser](#43-serving-game-using-browser) - [5. Add game assets](#5-add-game-assets) + - [Local Assets](#local-assets) + - [Remote Client](#remote-client) - [6. Adding Custom Plugins](#6-adding-custom-plugins) - [7. ROBrowser Settings Overview](#7-robrowser-settings-overview) - [8. Play the Game](#8-play-the-game) @@ -319,7 +321,8 @@ function initialize() { renewal: true, // Must match your game server's type (true/false). When using clientinfo.xml you can add the true custom tag. packetKeys: false, // Packet encryption keys ( not implemented?? ) socketProxy: "ws://127.0.0.1:5999/", // The websocket proxy's address you set up previously for robrowser (wsproxy) - adminList: [2000000] // List admins' account IDs here like: [2000000, 2000001, 2000002 .... etc] + adminList: [2000000], // List admins' account IDs here like: [2000000, 2000001, 2000002 .... etc] + aura: { defaultLv: 99 } // optional aura levels }], // OTHER CONFIG - These can be part of the server config as well, thus making them adjustable per server diff --git a/src/Controls/ProcessCommand.js b/src/Controls/ProcessCommand.js index d2bf3e8b..b8e188c4 100644 --- a/src/Controls/ProcessCommand.js +++ b/src/Controls/ProcessCommand.js @@ -113,6 +113,12 @@ define(function (require) { ); MapPreferences.aura = isSimplified ? 1 : 2; MapPreferences.save(); + + var EntityManager = getModule("Renderer/EntityManager"); + var EffectManager = getModule("Renderer/EffectManager"); + EntityManager.forEach(function (entity) { + entity.aura.load(EffectManager); + }); return; }, }, @@ -131,6 +137,12 @@ define(function (require) { ); MapPreferences.aura = MapPreferences.aura ? 0 : 1; MapPreferences.save(); + + var EntityManager = getModule("Renderer/EntityManager"); + var EffectManager = getModule("Renderer/EffectManager"); + EntityManager.forEach(function (entity) { + entity.aura.load(EffectManager); + }); return; }, }, diff --git a/src/Renderer/Entity/EntityAura.js b/src/Renderer/Entity/EntityAura.js index 2353081d..42660e69 100644 --- a/src/Renderer/Entity/EntityAura.js +++ b/src/Renderer/Entity/EntityAura.js @@ -6,101 +6,122 @@ * This file is part of ROBrowser, (http://www.robrowser.com/). * * @author Gulfaraz Rahman + * + * @typedef {Object} TMapPreferencesAura + * @prop {number} aura - 0: no aura, 1: only aura, 2: aura and aura2 + * + * @typedef {Object} TAuraSettings - default settings for aura (can be overridden by server config) + * @prop {number} defaultLv - default aura level + * @prop {number} babyLv - Baby class aura level + * @prop {number} secondLv - Second class aura level + * @prop {number} thirdLv - Third class aura level + * @prop {number} homunLv - Homun class aura level + * @prop {number} bossLv - Boss class aura level */ -define(['DB/Effects/EffectConst', 'Preferences/Map'], -function(EffectConst, MapPreferences) -{ - 'use strict'; +define(['DB/Effects/EffectConst', 'Preferences/Map', 'Core/Configs'], + function (EffectConst, /** @type {TMapPreferencesAura} */MapPreferences, Configs) { + 'use strict'; - var normalEffects = [ - EffectConst.EF_LEVEL99, - EffectConst.EF_LEVEL99_2, - EffectConst.EF_LEVEL99_3 - ]; + /** @type {TAuraSettings} */ + var _auraSettings = { + defaultLv: 99, + // babyLv: 99, // TODO implement other aura levels + // secondLv: 99, + // thirdLv: 175, + // homunLv: 99, + // bossLv: 99, + }; - var simpleEffects = [ - EffectConst.EF_LEVEL99_3 - ]; + var normalEffects = [ + EffectConst.EF_LEVEL99, + EffectConst.EF_LEVEL99_2, + EffectConst.EF_LEVEL99_3 + ]; - /** - * Aura class - * - * @constructor - * @param {object} entity - */ - function Aura( entity ) - { - this.isLoaded = false; // to avoid duplicate aura effects - this.entity = entity; // reference to attached entity - this.lastAuraState = 0; // save last aura state to track changes on aura/aura2 command - } + var simpleEffects = [ + EffectConst.EF_LEVEL99_3 + ]; - /** - * Show aura - */ - Aura.prototype.load = function load( effectManager ) - { - // check if qualifies for aura and /aura2 preference - if( MapPreferences.aura > 0 && this.entity.clevel >= 99) { - // check if entity is visible - if(this.entity.isVisible()) { - // check if aura state has changed - if(this.lastAuraState !== MapPreferences.aura && this.isLoaded) - this.remove( effectManager ); - if(!this.isLoaded) { - // aura is already loaded - // select effects based on /aura preference - var effects = MapPreferences.aura < 2 ? simpleEffects : normalEffects; - // add aura effects - for (let effectIndex = 0; effectIndex < effects.length; effectIndex++) { - effectManager.spam( { - ownerAID: this.entity.GID, - position: this.entity.position, - effectId: effects[effectIndex] - } ); + /** + * Aura class + * + * @constructor + * @param {object} entity + */ + function Aura(entity) { + this.isLoaded = false; // to avoid duplicate aura effects + this.entity = entity; // reference to attached entity + this.lastAuraState = 0; // save last aura state to track changes on aura/aura2 command + } + + /** + * Show aura + */ + Aura.prototype.load = function load(effectManager) { + var server = Configs.getServer(); // find aura from servers config + + /** @type {TAuraSettings} - merge server aura config with default settings */ + var settings = server != null ? Object.assign({}, _auraSettings, server.aura) : Object.assign({}, _auraSettings); + + // check if qualifies for aura and /aura2 preference + if (MapPreferences.aura > 0 && this.entity.clevel >= settings.defaultLv) { + // check if entity is visible + if (this.entity.isVisible()) { + // check if aura state has changed + if (this.lastAuraState !== MapPreferences.aura && this.isLoaded) { + this.remove(effectManager); + } + if (!this.isLoaded) { + // aura is already loaded + // select effects based on /aura preference + var effects = MapPreferences.aura < 2 ? simpleEffects : normalEffects; + // add aura effects + for (let effectIndex = 0; effectIndex < effects.length; effectIndex++) { + effectManager.spam({ + ownerAID: this.entity.GID, + position: this.entity.position, + effectId: effects[effectIndex] + }); + } + // set flag to avoid duplicate aura effects + this.isLoaded = true; + // save current aura state + this.lastAuraState = MapPreferences.aura; } - // set flag to avoid duplicate aura effects - this.isLoaded = true; - // save current aura state - this.lastAuraState = MapPreferences.aura; + } else { + // remove aura if entity is invisible + this.remove(effectManager); } - } else { - // remove aura if entity is invisible - this.remove( effectManager ); + } else if (this.isLoaded) { + // remove aura if entity does not qualify + this.remove(effectManager); + // save current aura state + this.lastAuraState = MapPreferences.aura; } - } else if (this.isLoaded) { - // remove aura if entity does not qualify - this.remove( effectManager ); - // save current aura state - this.lastAuraState = MapPreferences.aura; - } - }; + }; - /** - * Hide aura - */ - Aura.prototype.remove = function remove( effectManager ) - { - // remove aura effects - effectManager.remove( null, this.entity.GID, normalEffects ); - // free aura - needs to be separate to avoid circular dependency - this.free(); - }; + /** + * Hide aura + */ + Aura.prototype.remove = function remove(effectManager) { + // remove aura effects + effectManager.remove(null, this.entity.GID, normalEffects); + // free aura - needs to be separate to avoid circular dependency + this.free(); + }; - /** - * Hide aura - */ - Aura.prototype.free = function free() - { - // reset flag to allow aura to be loaded - this.isLoaded = false; - }; + /** + * Hide aura + */ + Aura.prototype.free = function free() { + // reset flag to allow aura to be loaded + this.isLoaded = false; + }; - /** - * Export - */ - return function init() - { - this.aura = new Aura(this); - }; -}); + /** + * Export + */ + return function init() { + this.aura = new Aura(this); + }; + });