RhinoVT
Posts: 2
Joined: Fri 19 May 2023, 22:04

Re: Share your Foundry use ideas

Mon 10 Jul 2023, 18:11

Is anyone using Combat Carousel or Carousel Combat tracker in their games? I'm trying to figure out a better way to manage combat and open to any and all suggestions.
 
thomas_edin
Posts: 2
Joined: Sat 12 Apr 2025, 15:15

Re: Share your Foundry use ideas - NV with green light

Sat 12 Apr 2025, 15:17

// Get the selected token
let token = canvas.tokens.controlled[0];
if (!token) {
ui.notifications.warn("No token selected!");
return;
}

// Determine if it's daylight based on the scene's darkness level
let isDaylight = canvas.scene.darkness < 0.4; // Adjust the threshold as needed

// Get the current vision mode
let currentVisionMode = token.document.sight.visionMode || "basic"; // Default to 'basic' if undefined

// Determine the new vision mode and corresponding vision range
let newVisionMode, visionRange;
if (isDaylight) {
newVisionMode = "basic";
visionRange = 100; // Adjust this value as needed for daylight vision range
fov = 180;
} else {
if (currentVisionMode === "lightAmplification") {
newVisionMode = "basic";
visionRange = 2; // Low light environment without enhancements
fov = 180;
} else {
newVisionMode = "lightAmplification";
visionRange = 30; // Night vision range
fov = 45;
}
}

// Update the token's vision mode and sight range
await token.document.update({
"sight.visionMode": newVisionMode,
"sight.range": visionRange,
"sight.brightSight": 1 // No bright sight for either mode
});

// Notify the user of the vision mode change
ChatMessage.create({
content: `${token.name} toggles to ${newVisionMode} with vision range of ${visionRange} meters.`,
whisper: [game.user.id]
});

Who is online

Users browsing this forum: No registered users and 10 guests