Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Saibot393 committed Nov 3, 2024
1 parent e899d7a commit 0ec3025
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 51 deletions.
19 changes: 17 additions & 2 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
"descrp" : "Wenn eine Figure gepackts wird, wird ein System abhängiger Effekt auf die Figur gesetzt"
},

"CustomGrapplingEffects" : {
"name" : "Eigene \"Gepackt\" Effekte",
"descrp" : "Effekte welche auf gepackte Figuren angewandt werden (Namen oder IDs, getrennt mit \";\")"
},

"StopGrappleonEffectRemoval" : {
"name" : "Stoppe Gepackt bei Effekt Entfernung",
"descrp" : "Ob Figuren frei gelassen werden sollen, wenn der \"Gepackt\" Effekt entfernt wird"
Expand Down Expand Up @@ -200,6 +205,11 @@
"name" : "Reitergrößen anpassungs Faktor",
"descrp" : "Der Faktor um welchen die Größe von reitenden Figuren angepasst wird wenn größer oder gleich groß der gerittenen Figur sind"
},

"RiderScaleFactor" : {
"name" : "Reiter Skalierung",
"descrp" : "Skalierung welche auf Reiter angewandt wird (nur graphisch)"
},

"MessagePopUps" : {
"name" : "Pop-up-Meldungen",
Expand Down Expand Up @@ -439,8 +449,8 @@
},

"WorldMEffectOverrideFlag" : {
"name" : "Überschreibe Welt-Reiteffekte",
"descrp" : "Überschreibt die Welt-Reiteffekte mit den oben festgelegten (anstatt sie zu erweitern)"
"name" : "Überschreibe Welteffekte",
"descrp" : "Überschreibt die Welteffekte mit den unten festgelegten (anstatt sie zu erweitern)"
},

"SelfApplyEffectsFlag" : {
Expand All @@ -458,6 +468,11 @@
"descrp" : "Ob diese Figur egriffen werden kann"
},

"MountingEffectsFlag" : {
"name" : "Ergreifen-Effekte",
"descrp" : "Effekte welche auf von dieser Figur ergriffene Figuren angewandt werden (Namen oder IDs, getrennt mit \";\")"
},

"CanbePilotedFlag" : {
"name" : "Kann gesteuert werden",
"descrp" : "Spieler können diese Figur Steuern, was es ihnen erlaubt sie zu bewegen ohne sie zu besitzen"
Expand Down
19 changes: 17 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
"descrp" : "If a token gets grappled, a system dependent effect will be applied to the token"
},

"CustomGrapplingEffects" : {
"name" : "Custom grappling effects",
"descrp" : "Effect that are applied to tokens when they are grappled (Names or IDs, seperated with \";\")"
},

"StopGrappleonEffectRemoval" : {
"name" : "Stop grapple on effect removal",
"descrp" : "If a token should be released as soon as the grapple effect is removed"
Expand Down Expand Up @@ -200,6 +205,11 @@
"name" : "Adjusted rider size factor",
"descrp" : "The factor by which the sizre of riders is adjusted in cases where they are greater or equal in size to the ridden token"
},

"RiderScaleFactor" : {
"name" : "Rider scale factor",
"descrp" : "Scale applied to riders (only graphical)"
},

"MessagePopUps" : {
"name" : "Message popups",
Expand Down Expand Up @@ -439,8 +449,8 @@
},

"WorldMEffectOverrideFlag" : {
"name" : "Override world riding effects",
"descrp" : "Overrides the world standard riding effects with the above set effects (instead of appending them)"
"name" : "Override world effects",
"descrp" : "Overrides the world standard effects with the below set effects (instead of appending them)"
},

"SelfApplyEffectsFlag" : {
Expand All @@ -458,6 +468,11 @@
"descrp" : "If this token can be grappled"
},

"GrapplingEffectsFlag" : {
"name" : "Grappling effects",
"descrp" : "Effects that are applied to graplle targets of this token (Names or IDs, seperated with \";\")"
},

"CanbePilotedFlag" : {
"name" : "Can be piloted",
"descrp" : "Players can pilot this token, allowing them to move it even if they don't own it"
Expand Down
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "saibot"
}
],
"version": "3.0.7",
"version": "3.1.0",
"compatibility": {
"minimum": "10",
"verified": "12"
Expand Down Expand Up @@ -58,13 +58,13 @@
{
"id": "routinglib",
"type": "module",
"reason": "Recommended for the follow token feature (not necessary)",
"reason": "Recommended for the follow token feature (not required)",
"compatibility": {}
}
]
},
"url": "https://github.com/Saibot393/Rideable",
"download": "https://github.com/Saibot393/Rideable/archive/refs/tags/v3.0.7.zip",
"download": "https://github.com/Saibot393/Rideable/archive/refs/tags/v3.1.0.zip",
"manifest": "https://github.com/Saibot393/Rideable/releases/latest/download/module.json",
"readme": "https://github.com/Saibot393/Rideable/blob/main/README.md",
"changelog": "https://github.com/Saibot393/Rideable/blob/main/CHANGELOG.md",
Expand Down
24 changes: 15 additions & 9 deletions scripts/helpers/EffectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EffectManager {

if (!RideableFlags.OverrideWorldMEffects(pRidden)) {
//World Mounting effects
vRiderEffectNames = vRiderEffectNames.concat(RideableUtils.CustomWorldRidingEffects());
vRiderEffectNames.push(...RideableUtils.CustomWorldRidingEffects());

//Standard mounting effect
if (RideableUtils.isPf2e() && game.settings.get(cModuleName, "RidingSystemEffects")) {
Expand All @@ -56,19 +56,25 @@ class EffectManager {
}

if (RideableFlags.SelfApplyCustomEffects(pRider)) {
vRiderEffectNames.push(RideableFlags.MountingEffects(pRider));
vRiderEffectNames.push(...RideableFlags.MountingEffects(pRider));
}
}
else {
if (game.settings.get(cModuleName, "GrapplingSystemEffects")) {
if (RideableUtils.isPf2e()) {
vRiderEffectNames.push(cGrappledPf2eEffectID);
if (!RideableFlags.OverrideWorldMEffects(pRidden)) {
if (game.settings.get(cModuleName, "GrapplingSystemEffects")) {
if (RideableUtils.isPf2e()) {
vRiderEffectNames.push(cGrappledPf2eEffectID);
}

if (RideableCompUtils.hasactiveEffectModule()) {
vRiderEffectNames.push(cGrabbedEffectName);
}
}

if (RideableCompUtils.hasactiveEffectModule()) {
vRiderEffectNames.push(cGrabbedEffectName);
}
vRiderEffectNames.push(RideableUtils.CustomWorldGrapplingEffects());
}

vRiderEffectNames.push(RideableFlags.GrapplingEffects(pRidden));
}
}
}
Expand All @@ -87,7 +93,7 @@ class EffectManager {
let vRiders = RideableFlags.RiderTokens(pRidden).filter(vRider => !(RideableFlags.isGrappled(vRider)));

for (let i = 0; i < vRiders.length; i++) {
vMountEffectNames = vMountEffectNames.concat(RideableFlags.forMountEffects(vRiders[i]));
vMountEffectNames.push(...RideableFlags.forMountEffects(vRiders[i]));
}

EffectManager.applyRideableEffects(pRidden, vMountEffectNames, {forMountEffect : true});
Expand Down
42 changes: 32 additions & 10 deletions scripts/helpers/RideableFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const cRiderPositioningF = "RiderPositioningFlag"; //Flag that describes how the
const cSpawnRidersF = "SpawnRidersFlag"; //Flag that describes all riders that should spawn on creation (names or ids)
const cGrappledF = "GrappledFlag"; //Flag that describes, that this token is riding as a grabbled token
const ccanbeGrappledF = "canbeGrappledFlag"; //Flag that describes, that this token is riding as a grabbled token
const cGrapplingEffectsF = "GrapplingEffectsFlag"; // Flag to store grappling effects applied to targets
const cSizesaveF = "SizesaveFlag"; //Flag that can save the size of the token
const cScaleSizesaveF = "ScaleSizesaveFlag"; //Flag that can sace the scale size of the Token
const cRidersScaleF = "RidersScaleFlag"; //Flag to store the scale of riders of this token
Expand Down Expand Up @@ -55,7 +56,7 @@ const cPointEpsilon = 1;
const cPathMaxHistory = 100; //Maximum points saved in the path hsitory of a token

export {cCornermaxRiders};
export {cRidingF, cFamiliarRidingF, cRidersF, caddRiderHeightF, cMaxRiderF, cissetRideableF, cTokenFormF, cInsideMovementF, cRiderPositioningF, cSpawnRidersF, ccanbeGrappledF, cRidersScaleF, cCustomRidingheightF, cMountingEffectsF, cWorldMEffectOverrideF, cTileRideableNameF, cMountonEnterF, cGrapplePlacementF, cSelfApplyEffectsF, cAutoMountBlackListF, cAutoMountWhiteListF, cCanbePilotedF, cCheckPilotedCollisionF, cPilotedbyDefaultF, cforMountEffectsF, cRiderOffsetF, cRiderRotOffsetF, cUseRidingHeightF}
export {cRidingF, cFamiliarRidingF, cRidersF, caddRiderHeightF, cMaxRiderF, cissetRideableF, cTokenFormF, cInsideMovementF, cRiderPositioningF, cSpawnRidersF, ccanbeGrappledF, cRidersScaleF, cCustomRidingheightF, cMountingEffectsF, cWorldMEffectOverrideF, cTileRideableNameF, cMountonEnterF, cGrapplePlacementF, cSelfApplyEffectsF, cAutoMountBlackListF, cAutoMountWhiteListF, cCanbePilotedF, cCheckPilotedCollisionF, cPilotedbyDefaultF, cforMountEffectsF, cRiderOffsetF, cRiderRotOffsetF, cUseRidingHeightF, cGrapplingEffectsF}

//handels all reading and writing of flags (other scripts should not touch Rideable Flags (other than possible RiderCompUtils for special compatibilityflags)
class RideableFlags {
Expand Down Expand Up @@ -225,14 +226,14 @@ class RideableFlags {
static isPilotedby(pRidden, pPilot) {} //returns of pRidden is piloted by pPilot

//effects
static MountingEffects(pToken) {} //returns alls the effects pToken gives its Riders as array

static MountingEffectsstring(pToken) {} //returns alls the effects pToken gives its Riders
static MountingEffects(pToken) {} //returns all the effects pToken gives its Riders as array

static forMountEffects(pRider, pRaw = false) {} //returns the effects pRider applies to its mount

static OverrideWorldMEffects(pToken) {} //returns if this Token mounting effects override the world standard (or just add to it)

static GrapplingEffects(pToken, pRaw = false) {} //returns alls the effects pToken gives its Grapple Targets as array

static async MarkasRideableEffect(pEffect, pforMountEffect = false) {} //gives pEffect the appropiate Flag

static isRideableEffect(pEffect, pforMountEffect = false) {} //returns whether pEffect is flagged as RideableFlag
Expand Down Expand Up @@ -469,6 +470,19 @@ class RideableFlags {
return true; //default if anything fails
}

static #GrapplingEffectsFlag (pToken) {
//returns effects for grappling
let vFlag = this.#RideableFlags(pToken);

if (vFlag) {
if (vFlag.hasOwnProperty(cGrapplingEffectsF)) {
return vFlag.GrapplingEffectsFlag;
}
}

return ""; //default if anything fails
}

static #SizesaveFlag(pToken) {
//array of x,y size
let vFlag = this.#RideableFlags(pToken);
Expand Down Expand Up @@ -1522,7 +1536,7 @@ class RideableFlags {
let vScale = this.#RidersScaleFlag(pRidden);

if (pWithGlobalScale) {
vScale = vScale * game.settings.get(cModuleName, "FitRiderScaleFactor");
vScale = vScale * game.settings.get(cModuleName, "RiderScaleFactor");
}

if (vScale != undefined && vScale != 1) {
Expand Down Expand Up @@ -1632,14 +1646,14 @@ class RideableFlags {
}

//effects
static MountingEffects(pToken) {
static MountingEffects(pToken, pRaw = false) {
if (pRaw) {
return this.#MountingEffectsFlag(pToken);
}

return this.#MountingEffectsFlag(pToken).split(cDelimiter);
}

static MountingEffectsstring(pToken) {
return this.#MountingEffectsFlag(pToken);
}

static forMountEffects(pRider, pRaw = false) {
if (pRaw) {
return this.#forMountEffectsFlag(pRider);
Expand All @@ -1653,6 +1667,14 @@ class RideableFlags {
return this.#WorldMEffectOverrideFlag(pToken);
}

static GrapplingEffects(pToken, pRaw = false) {
if (pRaw) {
return this.#GrapplingEffectsFlag(pToken);
}

return this.#GrapplingEffectsFlag(pToken).split(cDelimiter);
}

static async MarkasRideableEffect(pEffect, pforMountEffect = false) {
let vFlagName = cRideableEffectF;

Expand Down
15 changes: 12 additions & 3 deletions scripts/settings/RideableSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ Hooks.once("init", () => { // game.settings.get(cModuleName, "")
default: false
});

game.settings.register(cModuleName, "CustomGrapplingEffects", {
name: Translate("Settings.CustomGrapplingEffects.name"),
hint: Translate("Settings.CustomGrapplingEffects.descrp"),
scope: "world",
config: RideableUtils.isPf2e() || RideableCompUtils.hasactiveEffectModule(),
type: String,
default: ""
});

game.settings.register(cModuleName, "StopGrappleonEffectRemoval", {
name: Translate("Settings.StopGrappleonEffectRemoval.name"),
hint: Translate("Settings.StopGrappleonEffectRemoval.descrp"),
Expand Down Expand Up @@ -271,9 +280,9 @@ Hooks.once("init", () => { // game.settings.get(cModuleName, "")
default: 0.65
});

game.settings.register(cModuleName, "FitRiderScaleFactor", {
name: Translate("Settings.FitRiderScaleFactor.name"),
hint: Translate("Settings.FitRiderScaleFactor.descrp"),
game.settings.register(cModuleName, "RiderScaleFactor", {
name: Translate("Settings.RiderScaleFactor.name"),
hint: Translate("Settings.RiderScaleFactor.descrp"),
scope: "world",
config: true,
type: Number,
Expand Down
51 changes: 30 additions & 21 deletions scripts/settings/RideableSheetSettings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RideableUtils, cModuleName, Translate } from "../utils/RideableUtils.js";
import { RideableFlags , cMaxRiderF, cissetRideableF, cTokenFormF, cInsideMovementF, cRiderPositioningF, cSpawnRidersF, ccanbeGrappledF, cRidersScaleF, cCustomRidingheightF, cMountingEffectsF, cWorldMEffectOverrideF, cTileRideableNameF, cMountonEnterF, cGrapplePlacementF, cSelfApplyEffectsF, cAutoMountBlackListF, cAutoMountWhiteListF, cCanbePilotedF, cCheckPilotedCollisionF, cPilotedbyDefaultF, cforMountEffectsF, cRiderOffsetF, cRiderRotOffsetF, cUseRidingHeightF} from "../helpers/RideableFlags.js";
import { RideableFlags , cMaxRiderF, cissetRideableF, cTokenFormF, cInsideMovementF, cRiderPositioningF, cSpawnRidersF, ccanbeGrappledF, cRidersScaleF, cCustomRidingheightF, cMountingEffectsF, cWorldMEffectOverrideF, cTileRideableNameF, cMountonEnterF, cGrapplePlacementF, cSelfApplyEffectsF, cAutoMountBlackListF, cAutoMountWhiteListF, cCanbePilotedF, cCheckPilotedCollisionF, cPilotedbyDefaultF, cforMountEffectsF, cRiderOffsetF, cRiderRotOffsetF, cUseRidingHeightF, cGrapplingEffectsF} from "../helpers/RideableFlags.js";
import { cTokenForms, cTileForms } from "../utils/GeometricUtils.js";
import { cPlacementPatterns, cGrapplePlacements } from "../RidingScript.js";
import { RideableCompUtils } from "../compatibility/RideableCompUtils.js";
Expand Down Expand Up @@ -216,15 +216,6 @@ class RideableSheetSettings {
}, `div[data-tab="${cModuleName}"]`);

if (RideableUtils.isPf2e() || RideableCompUtils.hasactiveEffectModule()) {
//Custom Mounting effects applied to Riders
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ cMountingEffectsF +".name"),
vhint : Translate("TokenSettings."+ cMountingEffectsF +".descrp"),
vtype : "text",
vwide : true,
vvalue : RideableFlags.MountingEffectsstring(pApp.document),
vflagname : cMountingEffectsF
}, `div[data-tab="${cModuleName}"]`);

//if custom Mounting effects should override world stndard
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ cWorldMEffectOverrideF +".name"),
vhint : Translate("TokenSettings."+ cWorldMEffectOverrideF +".descrp"),
Expand All @@ -233,6 +224,15 @@ class RideableSheetSettings {
vvalue : RideableFlags.OverrideWorldMEffects(pApp.document),
vflagname : cWorldMEffectOverrideF
}, `div[data-tab="${cModuleName}"]`);

//Custom Mounting effects applied to Riders
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ cMountingEffectsF +".name"),
vhint : Translate("TokenSettings."+ cMountingEffectsF +".descrp"),
vtype : "text",
vwide : true,
vvalue : RideableFlags.MountingEffects(pApp.document, true),
vflagname : cMountingEffectsF
}, `div[data-tab="${cModuleName}"]`);

if (!pisTile) {
//if custom Mounting effects should be self applied
Expand All @@ -251,20 +251,29 @@ class RideableSheetSettings {
vwide : true,
vvalue : RideableFlags.forMountEffects(pApp.document),
vflagname : cforMountEffectsF
}, `div[data-tab="${cModuleName}"]`);
}, `div[data-tab="${cModuleName}"]`);

if (game.settings.get(cModuleName, "Grappling")) {
//if this token can be grappled
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ ccanbeGrappledF +".name"),
vhint : Translate("TokenSettings."+ ccanbeGrappledF +".descrp"),
vtype : "checkbox",
vvalue : RideableFlags.canbeGrappled(pApp.document),
vflagname : ccanbeGrappledF
}, `div[data-tab="${cModuleName}"]`);

//effects applied to tokens grappled by this token
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ cGrapplingEffectsF +".name"),
vhint : Translate("TokenSettings."+ cGrapplingEffectsF +".descrp"),
vtype : "text",
vwide : true,
vvalue : RideableFlags.GrapplingEffects(pApp.document, true),
vflagname : cGrapplingEffectsF
}, `div[data-tab="${cModuleName}"]`);
}
}
}

if (!pisTile) {
//if this token can be grappled
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ ccanbeGrappledF +".name"),
vhint : Translate("TokenSettings."+ ccanbeGrappledF +".descrp"),
vtype : "checkbox",
vvalue : RideableFlags.canbeGrappled(pApp.document),
vflagname : ccanbeGrappledF
}, `div[data-tab="${cModuleName}"]`);
}

//if this token can be piloted
RideableSheetSettings.AddHTMLOption(pHTML, {vlabel : Translate("TokenSettings."+ cCanbePilotedF +".name"),
vhint : Translate("TokenSettings."+ cCanbePilotedF +".descrp"),
Expand Down
8 changes: 7 additions & 1 deletion scripts/utils/RideableUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class RideableUtils {

static CustomWorldRidingEffects() {} //returns all World setting Riding effects

static CustomWorldGrapplingEffects() {} //returns all World setting Grappling effects

//IMPLEMENTATIONS

//Identification
Expand Down Expand Up @@ -489,7 +491,11 @@ class RideableUtils {

static CustomWorldRidingEffects() {
return game.settings.get(cModuleName, "CustomRidingEffects").split(cDelimiter);
} //returns all World setting Riding effects
}

static CustomWorldGrapplingEffects() {
return game.settings.get(cModuleName, "CustomGrapplingEffects").split(cDelimiter);
}
}

//for easy translation
Expand Down

0 comments on commit 0ec3025

Please sign in to comment.