Changeset View
Standalone View
binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js
Show All 40 Lines | StatusEffectsReceiver.prototype.ApplyStatus = function(effectData, attacker, attackerOwner, bonusMultiplier) | ||||
return { "inflictedStatuses": Object.keys(effectData) }; | return { "inflictedStatuses": Object.keys(effectData) }; | ||||
}; | }; | ||||
/** | /** | ||||
* Adds a status effect to the entity. | * Adds a status effect to the entity. | ||||
* | * | ||||
* @param {string} statusName - The name of the status effect. | * @param {string} statusName - The name of the status effect. | ||||
* @param {object} data - The various effects and timings. | * @param {object} data - The various effects and timings. | ||||
* @param {object} attackerData - The attacker and attackerOwner. | |||||
*/ | */ | ||||
StatusEffectsReceiver.prototype.AddStatus = function(statusName, data, attackerData) | StatusEffectsReceiver.prototype.AddStatus = function(statusName, data, attackerData) | ||||
{ | { | ||||
if (this.activeStatusEffects[statusName]) | if (this.activeStatusEffects[statusName]) | ||||
{ | { | ||||
// TODO: implement different behaviour when receiving the same status multiple times. | if (data.Stackability == "Ignore") | ||||
// For now, these are ignored. | |||||
return; | return; | ||||
if (data.Stackability == "Extend") | |||||
{ | |||||
this.activeStatusEffects[statusName].Duration += data.Duration; | |||||
return; | |||||
} | |||||
if (data.Stackability == "Replace") | |||||
this.RemoveStatus(statusName); | |||||
else if (data.Stackability == "Stack") | |||||
Silier: this can go without { } | |||||
{ | |||||
let i = 0; | |||||
let temp; | |||||
do | |||||
temp = statusName + "_" + i++; | |||||
Done Inline Actionsyou probably want i++, so _0 is considered as first option Silier: you probably want i++, so _0 is considered as first option | |||||
Done Inline ActionsActually only the second SE gets this postfix, hence I chose ++i, but I guess it doesn't matter and makes the linter happy :) Freagarach: Actually only the second SE gets this postfix, hence I chose `++i`, but I guess it doesn't… | |||||
while (!!this.activeStatusEffects[temp]); | |||||
StanUnsubmitted Not Done Inline Actionsdo you really need !! ? Stan: do you really need !! ? | |||||
wraitiiUnsubmitted Not Done Inline Actionsmeh... I would suggest UUID-like -> Timestamp + random bits, but I'm not sure it's actually faster in the general case. I'm not entirely convinced by status effects stacking, to be honest. Can you be "more" on fire? It also seems like it would be ugly GUI wise. Perhaps we could have "levels", where being "low-poison" and getting poisoned again moves you to "medium-poison" or something. But that seems like work for status effects v4. I would personally remove stacking effects for now, but I'm willing to be overruled by others (though @Angen seemed to agree that this looks meh earlier) wraitii: meh... I would suggest UUID-like -> Timestamp + random bits, but I'm not sure it's actually… | |||||
FreagarachAuthorUnsubmitted Not Done Inline ActionsYes, you can be more on fire ;) I've seen a piece of wood burn faster when lit on two sides ;) How is the level system different than stacking? Freagarach: Yes, you can be more on fire ;) I've seen a piece of wood burn faster when lit on two sides ;)… | |||||
wraitiiUnsubmitted Not Done Inline ActionsYou could define custom transitions with levels over stacking, or other interesting effects such as: That's impossible with stacking. wraitii: You could define custom transitions with levels over stacking, or other interesting effects… | |||||
statusName = temp; | |||||
} | |||||
} | } | ||||
this.activeStatusEffects[statusName] = {}; | this.activeStatusEffects[statusName] = {}; | ||||
let status = this.activeStatusEffects[statusName]; | let status = this.activeStatusEffects[statusName]; | ||||
Object.assign(status, data); | Object.assign(status, data); | ||||
if (status.Modifiers) | if (status.Modifiers) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |
this can go without { }