Spaces:
Running
Running
Update index.html
Browse files- index.html +108 -116
index.html
CHANGED
@@ -230,15 +230,18 @@
|
|
230 |
mesh.position.set(position.x, position.y, position.z);
|
231 |
mesh.rotation.set(rotation.x, rotation.y, rotation.z);
|
232 |
mesh.scale.set(scale.x, scale.y, scale.z);
|
233 |
-
mesh.castShadow = true;
|
|
|
234 |
return mesh;
|
235 |
}
|
236 |
|
237 |
function createGroundPlane(material = groundMaterial, size = 20) {
|
238 |
const groundGeo = new THREE.PlaneGeometry(size, size);
|
239 |
const ground = new THREE.Mesh(groundGeo, material);
|
240 |
-
ground.rotation.x = -Math.PI / 2;
|
241 |
-
ground.
|
|
|
|
|
242 |
return ground;
|
243 |
}
|
244 |
|
@@ -253,119 +256,119 @@
|
|
253 |
|
254 |
function createCityGatesAssembly() {
|
255 |
const group = new THREE.Group();
|
256 |
-
const gh=4, gw=1.5, gd=0.8, ah=1, aw=3;
|
257 |
const tlGeo = new THREE.BoxGeometry(gw, gh, gd);
|
258 |
-
group.add(createMesh(tlGeo, stoneMaterial, { x
|
259 |
const trGeo = new THREE.BoxGeometry(gw, gh, gd);
|
260 |
-
group.add(createMesh(trGeo, stoneMaterial, { x:(aw/2+gw/2), y:gh/2, z:0 }));
|
261 |
const aGeo = new THREE.BoxGeometry(aw, ah, gd);
|
262 |
-
group.add(createMesh(aGeo, stoneMaterial, { x:0, y:gh-ah/2, z:0 }));
|
263 |
-
const cs=0.4;
|
264 |
-
const cg = new THREE.BoxGeometry(cs, cs, gd*1.1);
|
265 |
-
for(let i
|
266 |
-
group.add(createMesh(cg.clone(), stoneMaterial, { x
|
267 |
-
group.add(createMesh(cg.clone(), stoneMaterial, { x:(aw/2+gw/2)+i*cs*0.7, y:gh+cs/2, z:0 }));
|
268 |
}
|
269 |
-
group.add(createMesh(cg.clone(), stoneMaterial, { x:0, y:gh+ah-cs/2, z:0 }));
|
270 |
group.add(createGroundPlane(stoneMaterial));
|
271 |
return group;
|
272 |
}
|
273 |
|
274 |
function createWeaponsmithAssembly() {
|
275 |
const group = new THREE.Group();
|
276 |
-
const bw=3, bh=2.5, bd=3.5;
|
277 |
const bGeo = new THREE.BoxGeometry(bw, bh, bd);
|
278 |
-
group.add(createMesh(bGeo, darkWoodMaterial, { x:0, y:bh/2, z:0 }));
|
279 |
-
const ch=3.5;
|
280 |
const cGeo = new THREE.CylinderGeometry(0.3, 0.4, ch, 8);
|
281 |
-
group.add(createMesh(cGeo, stoneMaterial, { x:bw*0.3, y:ch/2, z
|
282 |
group.add(createGroundPlane());
|
283 |
return group;
|
284 |
}
|
285 |
|
286 |
function createTempleAssembly() {
|
287 |
const group = new THREE.Group();
|
288 |
-
const bs=5, bsh=0.5, ch=3, cr=0.25, rh=0.5;
|
289 |
const bGeo = new THREE.BoxGeometry(bs, bsh, bs);
|
290 |
-
group.add(createMesh(bGeo, templeMaterial, { x:0, y:bsh/2, z:0 }));
|
291 |
const cGeo = new THREE.CylinderGeometry(cr, cr, ch, 12);
|
292 |
-
const cPos = [{x
|
293 |
-
cPos.forEach(p=>group.add(createMesh(cGeo.clone(), templeMaterial, { x:p.x, y:bsh+ch/2, z:p.z })));
|
294 |
-
const rGeo = new THREE.BoxGeometry(bs*0.9, rh, bs*0.9);
|
295 |
-
group.add(createMesh(rGeo, templeMaterial, { x:0, y:bsh+ch+rh/2, z:0 }));
|
296 |
group.add(createGroundPlane());
|
297 |
return group;
|
298 |
}
|
299 |
|
300 |
function createResistanceMeetingAssembly() {
|
301 |
const group = new THREE.Group();
|
302 |
-
const tw=2, th=0.8, td=1, tt=0.1;
|
303 |
const ttg = new THREE.BoxGeometry(tw, tt, td);
|
304 |
-
group.add(createMesh(ttg, woodMaterial, { x:0, y:th-tt/2, z:0 }));
|
305 |
-
const lh=th-tt, ls=0.1;
|
306 |
-
const lg=new THREE.BoxGeometry(ls, lh, ls);
|
307 |
-
const lofW=tw/2-ls*1.5;
|
308 |
-
const lofD=td/2-ls*1.5;
|
309 |
-
group.add(createMesh(lg, woodMaterial, { x
|
310 |
-
group.add(createMesh(lg.clone(), woodMaterial, { x:lofW, y:lh/2, z
|
311 |
-
group.add(createMesh(lg.clone(), woodMaterial, { x
|
312 |
-
group.add(createMesh(lg.clone(), woodMaterial, { x:lofW, y:lh/2, z:lofD }));
|
313 |
-
const ss=0.4;
|
314 |
-
const sg=new THREE.BoxGeometry(ss, ss*0.8, ss);
|
315 |
-
group.add(createMesh(sg, darkWoodMaterial, { x
|
316 |
-
group.add(createMesh(sg.clone(), darkWoodMaterial, { x:tw*0.6, y:ss*0.4, z:0 }));
|
317 |
group.add(createGroundPlane(stoneMaterial));
|
318 |
return group;
|
319 |
}
|
320 |
|
321 |
-
function createForestAssembly(tc=10, a=10) {
|
322 |
const group = new THREE.Group();
|
323 |
-
const cT=(x,z)=>{
|
324 |
-
const tg=new THREE.Group();
|
325 |
-
const th=Math.random()*1.5+2;
|
326 |
-
const tr=Math.random()*0.1+0.1;
|
327 |
-
const tGeo = new THREE.CylinderGeometry(tr*0.7, tr, th, 8);
|
328 |
-
tg.add(createMesh(tGeo, woodMaterial, {x:0, y:th/2, z:0}));
|
329 |
-
const fr=th*0.4+0.2;
|
330 |
-
const fGeo=new THREE.SphereGeometry(fr, 8, 6);
|
331 |
-
tg.add(createMesh(fGeo, leafMaterial, {x:0, y:th*0.9, z:0}));
|
332 |
-
tg.position.set(x,0,z);
|
333 |
return tg;
|
334 |
};
|
335 |
-
for(let i=0; i<tc; i++){
|
336 |
-
const x=(Math.random()-0.5)*a;
|
337 |
-
const z=(Math.random()-0.5)*a;
|
338 |
-
if(Math.sqrt(x*x+z*z)>1.0) group.add(cT(x,z));
|
339 |
}
|
340 |
-
group.add(createGroundPlane(groundMaterial, a*1.1));
|
341 |
return group;
|
342 |
}
|
343 |
|
344 |
function createRoadAmbushAssembly() {
|
345 |
const group = new THREE.Group();
|
346 |
-
const a=12;
|
347 |
const fg = createForestAssembly(8, a);
|
348 |
group.add(fg);
|
349 |
-
const rw=3, rl=a*1.2;
|
350 |
-
const rGeo=new THREE.PlaneGeometry(rw, rl);
|
351 |
-
const rMat=new THREE.MeshStandardMaterial({color:0x966F33, roughness:0.9});
|
352 |
-
const r=createMesh(rGeo, rMat, {x:0, y:0.01, z:0}, {x
|
353 |
-
r.receiveShadow=true;
|
354 |
group.add(r);
|
355 |
-
const rkGeo=new THREE.SphereGeometry(0.5, 5, 4);
|
356 |
-
const rkMat=new THREE.MeshStandardMaterial({color:0x666666, roughness:0.8});
|
357 |
-
group.add(createMesh(rkGeo, rkMat, {x:rw*0.7, y:0.25, z:1}, {y:Math.random()*Math.PI}));
|
358 |
-
group.add(createMesh(rkGeo.clone().scale(0.8,0.8,0.8), rkMat, {x
|
359 |
return group;
|
360 |
}
|
361 |
|
362 |
function createForestEdgeAssembly() {
|
363 |
const group = new THREE.Group();
|
364 |
-
const a=15;
|
365 |
const fg = createForestAssembly(15, a);
|
366 |
-
const ttr=[];
|
367 |
fg.children.forEach(c => {
|
368 |
-
if(c.type === 'Group' && c.position.x > 0) ttr.push(c);
|
369 |
});
|
370 |
ttr.forEach(t => fg.remove(t));
|
371 |
group.add(fg);
|
@@ -374,20 +377,20 @@
|
|
374 |
|
375 |
function createPrisonerCellAssembly() {
|
376 |
const group = new THREE.Group();
|
377 |
-
const cs=3, wh=2.5, wt=0.2, br=0.05, bsp=0.25;
|
378 |
-
const cfMat=stoneMaterial.clone();
|
379 |
cfMat.color.setHex(0x555555);
|
380 |
group.add(createGroundPlane(cfMat, cs));
|
381 |
-
const wbGeo=new THREE.BoxGeometry(cs, wh, wt);
|
382 |
-
group.add(createMesh(wbGeo, stoneMaterial, {x:0, y:wh/2, z
|
383 |
-
const wsGeo=new THREE.BoxGeometry(wt, wh, cs);
|
384 |
-
group.add(createMesh(wsGeo, stoneMaterial, {x
|
385 |
-
group.add(createMesh(wsGeo.clone(), stoneMaterial, {x:cs/2, y:wh/2, z:0}));
|
386 |
-
const bGeo=new THREE.CylinderGeometry(br, br, wh, 8);
|
387 |
-
const nb=Math.floor(cs/bsp);
|
388 |
-
for(let i=0; i<nb; i++){
|
389 |
-
const xp
|
390 |
-
group.add(createMesh(bGeo.clone(), metalMaterial, {x:xp, y:wh/2, z:cs/2}));
|
391 |
}
|
392 |
return group;
|
393 |
}
|
@@ -396,7 +399,7 @@
|
|
396 |
const group = new THREE.Group();
|
397 |
const boxGeo = new THREE.BoxGeometry(2, 2, 2);
|
398 |
group.add(createMesh(boxGeo, gameOverMaterial, { x: 0, y: 1, z: 0 }));
|
399 |
-
group.add(createGroundPlane(stoneMaterial.clone().set({color: 0x333333})));
|
400 |
return group;
|
401 |
}
|
402 |
|
@@ -480,7 +483,7 @@
|
|
480 |
return group;
|
481 |
}
|
482 |
|
483 |
-
function createOvergrownPathAssembly(treeCount=15, objectCount=30, creatureCount=0, lightIntensity=0.6) {
|
484 |
const group = new THREE.Group();
|
485 |
group.add(createGroundPlane(dirtMaterial, 15));
|
486 |
const forest = createForestAssembly(treeCount, 10);
|
@@ -570,7 +573,7 @@
|
|
570 |
return group;
|
571 |
}
|
572 |
|
573 |
-
function createMossyRavineAssembly(treeCount=10, objectCount=20, creatureCount=3, lightIntensity=0.5) {
|
574 |
const group = new THREE.Group();
|
575 |
group.add(createGroundPlane(groundMaterial, 20));
|
576 |
const forest = createForestAssembly(treeCount, 15);
|
@@ -597,7 +600,7 @@
|
|
597 |
return group;
|
598 |
}
|
599 |
|
600 |
-
function createRockyBadlandsAssembly(treeCount=5, objectCount=15, creatureCount=2, lightIntensity=1.2) {
|
601 |
const group = new THREE.Group();
|
602 |
group.add(createGroundPlane(crackedEarthMaterial, 25));
|
603 |
const sparseVeg = createForestAssembly(treeCount, 20);
|
@@ -618,7 +621,7 @@
|
|
618 |
return group;
|
619 |
}
|
620 |
|
621 |
-
function createMountainFortressAssembly(treeCount=3, objectCount=10, creatureCount=2, lightIntensity=0.8) {
|
622 |
const group = new THREE.Group();
|
623 |
group.add(createGroundPlane(stoneMaterial, 20));
|
624 |
const wallGeo = new THREE.BoxGeometry(15, 3, 0.5);
|
@@ -643,17 +646,17 @@
|
|
643 |
|
644 |
// Game Data
|
645 |
const itemsData = {
|
646 |
-
"Flaming Sword":{type:"weapon", description:"A fiery blade"},
|
647 |
-
"Whispering Bow":{type:"weapon", description:"A silent bow"},
|
648 |
-
"Guardian Shield":{type:"armor", description:"A protective shield"},
|
649 |
-
"Healing Light Spell":{type:"spell", description:"Mends minor wounds"},
|
650 |
-
"Shield of Faith Spell":{type:"spell", description:"Temporary shield"},
|
651 |
-
"Binding Runes Scroll":{type:"spell", description:"Binds an enemy"},
|
652 |
-
"Secret Tunnel Map":{type:"quest", description:"Shows a hidden path"},
|
653 |
-
"Poison Daggers":{type:"weapon", description:"Daggers with poison"},
|
654 |
-
"Master Key":{type:"quest", description:"Unlocks many doors"},
|
655 |
-
"Crude Dagger":{type:"weapon", description:"A roughly made dagger."},
|
656 |
-
"Scout's Pouch":{type:"quest", description:"Contains odds and ends."}
|
657 |
};
|
658 |
|
659 |
const gameData = {
|
@@ -682,14 +685,14 @@
|
|
682 |
"32": { title: "No Easier Path", content: `<p>You scan the cliffs intently but find no obviously easier routes.</p>`, options: [ { text: "Attempt the precarious descent (Dexterity Check)", check: { stat: 'dexterity', dc: 12, onFailure: 31 }, next: 30 } ], illustration: "scanning-sea-cliffs-no-other-paths-visible" },
|
683 |
"33": { title: "Smuggler's Steps?", content: `<p>Your keen eyes spot a series of barely visible handholds and steps carved into the rock...</p><p>(+15 XP)</p>`, options: [ { text: "Use the hidden steps (Easier Dex Check)", check: { stat: 'dexterity', dc: 8, onFailure: 31 }, next: 30 } ], illustration: "close-up-handholds-carved-in-cliff-face", reward: { xp: 15 } },
|
684 |
"35": { title: "Dark Cave", content: `<p>The cave smells of salt and decay. Water drips somewhere within.</p>`, options: [{ text: "Press deeper into the darkness", next: 99 } ], illustration: "dark-cave-entrance-dripping-water" },
|
685 |
-
"40": { title: "Overgrown Shrine", content: `<p>Wildflowers grow thick around a small stone shrine. It feels ancient and neglected.</p>`, options: [{ text: "Examine the carvings (Intelligence Check)", check:{stat:'intelligence', dc:11, onFailure: 401}, next: 400 } ], illustration: "overgrown-stone-shrine-wildflowers-close" },
|
686 |
"41": { title: "Rocky Badlands", content: `<p>The green hills give way to cracked earth and jagged rock formations under a harsh sun.</p>`, options: [{ text: "Scout ahead", next: 99 } ], illustration: "rocky-badlands-cracked-earth-harsh-sun" },
|
687 |
-
"190": { title: "Over the Rocks", content:"<p>With considerable effort, you manage to climb over the rockslide.</p><p>(+35 XP)</p>", options: [{text:"Continue up the path", next: 22}], illustration:"character-climbing-over-boulders", reward: {xp:35} },
|
688 |
-
"191": { title: "Climb Fails", content:"<p>The boulders are too unstable or sheer. You cannot climb them safely.</p>", options: [{text:"Search for another way around", next: 192}], illustration:"character-slipping-on-rockslide-boulders"},
|
689 |
-
"192": { title: "Detour Found", content:"<p>After some searching, you find a rough path leading around the rockslide, eventually rejoining the main trail.</p>", options: [{text:"Continue up the path", next: 22}], illustration:"rough-detour-path-around-rockslide"},
|
690 |
-
"21": { title: "Western Ridge", content:"<p>The ridge path is narrow and exposed, with strong winds threatening to push you off.</p>", options: [{text:"Proceed carefully (Dexterity Check)", check:{stat:'dexterity', dc: 14, onFailure: 211}, next: 22 } ], illustration:"narrow-windy-mountain-ridge-path" },
|
691 |
-
"22": { title: "Fortress Approach", content:"<p>You've navigated the treacherous paths and now stand near the outer walls of the dark fortress. Guards patrol the battlements.</p>", options: [{text:"Look for an unguarded entrance", next: 99}], illustration:"approaching-dark-fortress-walls-guards"},
|
692 |
-
"211": {title:"Lost Balance", content:"<p>A strong gust of wind catches you off guard, sending you tumbling down a steep slope! You lose 10 HP.</p>", options:[{text:"Climb back up and find another way", next: 17}], illustration:"character-falling-off-windy-ridge", hpLoss: 10},
|
693 |
"99": { title: "Game Over / To Be Continued...", content: "<p>Your adventure ends here (for now).</p>", options: [{ text: "Restart", next: 1 }], illustration: "game-over-generic", gameOver: true }
|
694 |
};
|
695 |
|
@@ -784,7 +787,7 @@
|
|
784 |
const roll = Math.floor(Math.random() * 20) + 1;
|
785 |
const totalResult = roll + modifier + accomplishmentBonus;
|
786 |
const dc = check.dc;
|
787 |
-
console.log(`Check: ${check.stat} (DC ${dc}) | Roll: ${roll} + Mod: ${modifier} + Acc: ${accomplishmentBonus} = ${
|
788 |
if (totalResult >= dc) {
|
789 |
nextPageId = optionNextPageId;
|
790 |
rollResultMessage = `<p class="roll-success"><em>Check Success! (${totalResult} vs DC ${dc})</em></p>`;
|
@@ -850,7 +853,7 @@
|
|
850 |
renderPageInternal(99, gameData[99], "<p><em>Error: Next page data missing!</em></p>" + levelUpMessage);
|
851 |
return;
|
852 |
}
|
853 |
-
renderPageInternal(nextPageId,
|
854 |
}
|
855 |
|
856 |
function renderPageInternal(pageId, pageData, message = "") {
|
@@ -884,7 +887,7 @@
|
|
884 |
const button = document.createElement('button');
|
885 |
button.classList.add('choice-button');
|
886 |
button.textContent = pageData.gameOver ? "Restart Adventure" : "The End";
|
887 |
-
button.onclick = () => handleChoiceClick({ nextPage: pageData.gameOver ?
|
888 |
choicesElement.appendChild(button);
|
889 |
if (!pageData.gameOver) choicesElement.insertAdjacentHTML('afterbegin', '<p><i>The path ends here.</i></p>');
|
890 |
}
|
@@ -1018,15 +1021,4 @@
|
|
1018 |
adjustLighting(illustrationKey);
|
1019 |
} catch (error) {
|
1020 |
console.error(`Error creating assembly for ${illustrationKey}:`, error);
|
1021 |
-
|
1022 |
-
scene.add(currentAssemblyGroup);
|
1023 |
-
}
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
function adjustLighting(illustrationKey) {
|
1027 |
-
scene.children.forEach(child => {
|
1028 |
-
if (child.isLight && child !== scene.children.find(c => c.isAmbientLight)) {
|
1029 |
-
scene.remove(child);
|
1030 |
-
}
|
1031 |
-
});
|
1032 |
-
const ambient
|
|
|
230 |
mesh.position.set(position.x, position.y, position.z);
|
231 |
mesh.rotation.set(rotation.x, rotation.y, rotation.z);
|
232 |
mesh.scale.set(scale.x, scale.y, scale.z);
|
233 |
+
mesh.castShadow = true;
|
234 |
+
mesh.receiveShadow = true;
|
235 |
return mesh;
|
236 |
}
|
237 |
|
238 |
function createGroundPlane(material = groundMaterial, size = 20) {
|
239 |
const groundGeo = new THREE.PlaneGeometry(size, size);
|
240 |
const ground = new THREE.Mesh(groundGeo, material);
|
241 |
+
ground.rotation.x = -Math.PI / 2;
|
242 |
+
ground.position.y = -0.05;
|
243 |
+
ground.receiveShadow = true;
|
244 |
+
ground.castShadow = false;
|
245 |
return ground;
|
246 |
}
|
247 |
|
|
|
256 |
|
257 |
function createCityGatesAssembly() {
|
258 |
const group = new THREE.Group();
|
259 |
+
const gh = 4, gw = 1.5, gd = 0.8, ah = 1, aw = 3;
|
260 |
const tlGeo = new THREE.BoxGeometry(gw, gh, gd);
|
261 |
+
group.add(createMesh(tlGeo, stoneMaterial, { x: -(aw / 2 + gw / 2), y: gh / 2, z: 0 }));
|
262 |
const trGeo = new THREE.BoxGeometry(gw, gh, gd);
|
263 |
+
group.add(createMesh(trGeo, stoneMaterial, { x: (aw / 2 + gw / 2), y: gh / 2, z: 0 }));
|
264 |
const aGeo = new THREE.BoxGeometry(aw, ah, gd);
|
265 |
+
group.add(createMesh(aGeo, stoneMaterial, { x: 0, y: gh - ah / 2, z: 0 }));
|
266 |
+
const cs = 0.4;
|
267 |
+
const cg = new THREE.BoxGeometry(cs, cs, gd * 1.1);
|
268 |
+
for (let i = -1; i <= 1; i += 2) {
|
269 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x: -(aw / 2 + gw / 2) + i * cs * 0.7, y: gh + cs / 2, z: 0 }));
|
270 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x: (aw / 2 + gw / 2) + i * cs * 0.7, y: gh + cs / 2, z: 0 }));
|
271 |
}
|
272 |
+
group.add(createMesh(cg.clone(), stoneMaterial, { x: 0, y: gh + ah - cs / 2, z: 0 }));
|
273 |
group.add(createGroundPlane(stoneMaterial));
|
274 |
return group;
|
275 |
}
|
276 |
|
277 |
function createWeaponsmithAssembly() {
|
278 |
const group = new THREE.Group();
|
279 |
+
const bw = 3, bh = 2.5, bd = 3.5;
|
280 |
const bGeo = new THREE.BoxGeometry(bw, bh, bd);
|
281 |
+
group.add(createMesh(bGeo, darkWoodMaterial, { x: 0, y: bh / 2, z: 0 }));
|
282 |
+
const ch = 3.5;
|
283 |
const cGeo = new THREE.CylinderGeometry(0.3, 0.4, ch, 8);
|
284 |
+
group.add(createMesh(cGeo, stoneMaterial, { x: bw * 0.3, y: ch / 2, z: -bd * 0.3 }));
|
285 |
group.add(createGroundPlane());
|
286 |
return group;
|
287 |
}
|
288 |
|
289 |
function createTempleAssembly() {
|
290 |
const group = new THREE.Group();
|
291 |
+
const bs = 5, bsh = 0.5, ch = 3, cr = 0.25, rh = 0.5;
|
292 |
const bGeo = new THREE.BoxGeometry(bs, bsh, bs);
|
293 |
+
group.add(createMesh(bGeo, templeMaterial, { x: 0, y: bsh / 2, z: 0 }));
|
294 |
const cGeo = new THREE.CylinderGeometry(cr, cr, ch, 12);
|
295 |
+
const cPos = [{ x: -bs / 3, z: -bs / 3 }, { x: bs / 3, z: -bs / 3 }, { x: -bs / 3, z: bs / 3 }, { x: bs / 3, z: bs / 3 }];
|
296 |
+
cPos.forEach(p => group.add(createMesh(cGeo.clone(), templeMaterial, { x: p.x, y: bsh + ch / 2, z: p.z })));
|
297 |
+
const rGeo = new THREE.BoxGeometry(bs * 0.9, rh, bs * 0.9);
|
298 |
+
group.add(createMesh(rGeo, templeMaterial, { x: 0, y: bsh + ch + rh / 2, z: 0 }));
|
299 |
group.add(createGroundPlane());
|
300 |
return group;
|
301 |
}
|
302 |
|
303 |
function createResistanceMeetingAssembly() {
|
304 |
const group = new THREE.Group();
|
305 |
+
const tw = 2, th = 0.8, td = 1, tt = 0.1;
|
306 |
const ttg = new THREE.BoxGeometry(tw, tt, td);
|
307 |
+
group.add(createMesh(ttg, woodMaterial, { x: 0, y: th - tt / 2, z: 0 }));
|
308 |
+
const lh = th - tt, ls = 0.1;
|
309 |
+
const lg = new THREE.BoxGeometry(ls, lh, ls);
|
310 |
+
const lofW = tw / 2 - ls * 1.5;
|
311 |
+
const lofD = td / 2 - ls * 1.5;
|
312 |
+
group.add(createMesh(lg, woodMaterial, { x: -lofW, y: lh / 2, z: -lofD }));
|
313 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x: lofW, y: lh / 2, z: -lofD }));
|
314 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x: -lofW, y: lh / 2, z: lofD }));
|
315 |
+
group.add(createMesh(lg.clone(), woodMaterial, { x: lofW, y: lh / 2, z: lofD }));
|
316 |
+
const ss = 0.4;
|
317 |
+
const sg = new THREE.BoxGeometry(ss, ss * 0.8, ss);
|
318 |
+
group.add(createMesh(sg, darkWoodMaterial, { x: -tw * 0.6, y: ss * 0.4, z: 0 }));
|
319 |
+
group.add(createMesh(sg.clone(), darkWoodMaterial, { x: tw * 0.6, y: ss * 0.4, z: 0 }));
|
320 |
group.add(createGroundPlane(stoneMaterial));
|
321 |
return group;
|
322 |
}
|
323 |
|
324 |
+
function createForestAssembly(tc = 10, a = 10) {
|
325 |
const group = new THREE.Group();
|
326 |
+
const cT = (x, z) => {
|
327 |
+
const tg = new THREE.Group();
|
328 |
+
const th = Math.random() * 1.5 + 2;
|
329 |
+
const tr = Math.random() * 0.1 + 0.1;
|
330 |
+
const tGeo = new THREE.CylinderGeometry(tr * 0.7, tr, th, 8);
|
331 |
+
tg.add(createMesh(tGeo, woodMaterial, { x: 0, y: th / 2, z: 0 }));
|
332 |
+
const fr = th * 0.4 + 0.2;
|
333 |
+
const fGeo = new THREE.SphereGeometry(fr, 8, 6);
|
334 |
+
tg.add(createMesh(fGeo, leafMaterial, { x: 0, y: th * 0.9, z: 0 }));
|
335 |
+
tg.position.set(x, 0, z);
|
336 |
return tg;
|
337 |
};
|
338 |
+
for (let i = 0; i < tc; i++) {
|
339 |
+
const x = (Math.random() - 0.5) * a;
|
340 |
+
const z = (Math.random() - 0.5) * a;
|
341 |
+
if (Math.sqrt(x * x + z * z) > 1.0) group.add(cT(x, z));
|
342 |
}
|
343 |
+
group.add(createGroundPlane(groundMaterial, a * 1.1));
|
344 |
return group;
|
345 |
}
|
346 |
|
347 |
function createRoadAmbushAssembly() {
|
348 |
const group = new THREE.Group();
|
349 |
+
const a = 12;
|
350 |
const fg = createForestAssembly(8, a);
|
351 |
group.add(fg);
|
352 |
+
const rw = 3, rl = a * 1.2;
|
353 |
+
const rGeo = new THREE.PlaneGeometry(rw, rl);
|
354 |
+
const rMat = new THREE.MeshStandardMaterial({ color: 0x966F33, roughness: 0.9 });
|
355 |
+
const r = createMesh(rGeo, rMat, { x: 0, y: 0.01, z: 0 }, { x: -Math.PI / 2 });
|
356 |
+
r.receiveShadow = true;
|
357 |
group.add(r);
|
358 |
+
const rkGeo = new THREE.SphereGeometry(0.5, 5, 4);
|
359 |
+
const rkMat = new THREE.MeshStandardMaterial({ color: 0x666666, roughness: 0.8 });
|
360 |
+
group.add(createMesh(rkGeo, rkMat, { x: rw * 0.7, y: 0.25, z: 1 }, { y: Math.random() * Math.PI }));
|
361 |
+
group.add(createMesh(rkGeo.clone().scale(0.8, 0.8, 0.8), rkMat, { x: -rw * 0.8, y: 0.2, z: -2 }, { y: Math.random() * Math.PI }));
|
362 |
return group;
|
363 |
}
|
364 |
|
365 |
function createForestEdgeAssembly() {
|
366 |
const group = new THREE.Group();
|
367 |
+
const a = 15;
|
368 |
const fg = createForestAssembly(15, a);
|
369 |
+
const ttr = [];
|
370 |
fg.children.forEach(c => {
|
371 |
+
if (c.type === 'Group' && c.position.x > 0) ttr.push(c);
|
372 |
});
|
373 |
ttr.forEach(t => fg.remove(t));
|
374 |
group.add(fg);
|
|
|
377 |
|
378 |
function createPrisonerCellAssembly() {
|
379 |
const group = new THREE.Group();
|
380 |
+
const cs = 3, wh = 2.5, wt = 0.2, br = 0.05, bsp = 0.25;
|
381 |
+
const cfMat = stoneMaterial.clone();
|
382 |
cfMat.color.setHex(0x555555);
|
383 |
group.add(createGroundPlane(cfMat, cs));
|
384 |
+
const wbGeo = new THREE.BoxGeometry(cs, wh, wt);
|
385 |
+
group.add(createMesh(wbGeo, stoneMaterial, { x: 0, y: wh / 2, z: -cs / 2 }));
|
386 |
+
const wsGeo = new THREE.BoxGeometry(wt, wh, cs);
|
387 |
+
group.add(createMesh(wsGeo, stoneMaterial, { x: -cs / 2, y: wh / 2, z: 0 }));
|
388 |
+
group.add(createMesh(wsGeo.clone(), stoneMaterial, { x: cs / 2, y: wh / 2, z: 0 }));
|
389 |
+
const bGeo = new THREE.CylinderGeometry(br, br, wh, 8);
|
390 |
+
const nb = Math.floor(cs / bsp);
|
391 |
+
for (let i = 0; i < nb; i++) {
|
392 |
+
const xp = -cs / 2 + (i + 0.5) * bsp;
|
393 |
+
group.add(createMesh(bGeo.clone(), metalMaterial, { x: xp, y: wh / 2, z: cs / 2 }));
|
394 |
}
|
395 |
return group;
|
396 |
}
|
|
|
399 |
const group = new THREE.Group();
|
400 |
const boxGeo = new THREE.BoxGeometry(2, 2, 2);
|
401 |
group.add(createMesh(boxGeo, gameOverMaterial, { x: 0, y: 1, z: 0 }));
|
402 |
+
group.add(createGroundPlane(stoneMaterial.clone().set({ color: 0x333333 })));
|
403 |
return group;
|
404 |
}
|
405 |
|
|
|
483 |
return group;
|
484 |
}
|
485 |
|
486 |
+
function createOvergrownPathAssembly(treeCount = 15, objectCount = 30, creatureCount = 0, lightIntensity = 0.6) {
|
487 |
const group = new THREE.Group();
|
488 |
group.add(createGroundPlane(dirtMaterial, 15));
|
489 |
const forest = createForestAssembly(treeCount, 10);
|
|
|
573 |
return group;
|
574 |
}
|
575 |
|
576 |
+
function createMossyRavineAssembly(treeCount = 10, objectCount = 20, creatureCount = 3, lightIntensity = 0.5) {
|
577 |
const group = new THREE.Group();
|
578 |
group.add(createGroundPlane(groundMaterial, 20));
|
579 |
const forest = createForestAssembly(treeCount, 15);
|
|
|
600 |
return group;
|
601 |
}
|
602 |
|
603 |
+
function createRockyBadlandsAssembly(treeCount = 5, objectCount = 15, creatureCount = 2, lightIntensity = 1.2) {
|
604 |
const group = new THREE.Group();
|
605 |
group.add(createGroundPlane(crackedEarthMaterial, 25));
|
606 |
const sparseVeg = createForestAssembly(treeCount, 20);
|
|
|
621 |
return group;
|
622 |
}
|
623 |
|
624 |
+
function createMountainFortressAssembly(treeCount = 3, objectCount = 10, creatureCount = 2, lightIntensity = 0.8) {
|
625 |
const group = new THREE.Group();
|
626 |
group.add(createGroundPlane(stoneMaterial, 20));
|
627 |
const wallGeo = new THREE.BoxGeometry(15, 3, 0.5);
|
|
|
646 |
|
647 |
// Game Data
|
648 |
const itemsData = {
|
649 |
+
"Flaming Sword": { type: "weapon", description: "A fiery blade" },
|
650 |
+
"Whispering Bow": { type: "weapon", description: "A silent bow" },
|
651 |
+
"Guardian Shield": { type: "armor", description: "A protective shield" },
|
652 |
+
"Healing Light Spell": { type: "spell", description: "Mends minor wounds" },
|
653 |
+
"Shield of Faith Spell": { type: "spell", description: "Temporary shield" },
|
654 |
+
"Binding Runes Scroll": { type: "spell", description: "Binds an enemy" },
|
655 |
+
"Secret Tunnel Map": { type: "quest", description: "Shows a hidden path" },
|
656 |
+
"Poison Daggers": { type: "weapon", description: "Daggers with poison" },
|
657 |
+
"Master Key": { type: "quest", description: "Unlocks many doors" },
|
658 |
+
"Crude Dagger": { type: "weapon", description: "A roughly made dagger." },
|
659 |
+
"Scout's Pouch": { type: "quest", description: "Contains odds and ends." }
|
660 |
};
|
661 |
|
662 |
const gameData = {
|
|
|
685 |
"32": { title: "No Easier Path", content: `<p>You scan the cliffs intently but find no obviously easier routes.</p>`, options: [ { text: "Attempt the precarious descent (Dexterity Check)", check: { stat: 'dexterity', dc: 12, onFailure: 31 }, next: 30 } ], illustration: "scanning-sea-cliffs-no-other-paths-visible" },
|
686 |
"33": { title: "Smuggler's Steps?", content: `<p>Your keen eyes spot a series of barely visible handholds and steps carved into the rock...</p><p>(+15 XP)</p>`, options: [ { text: "Use the hidden steps (Easier Dex Check)", check: { stat: 'dexterity', dc: 8, onFailure: 31 }, next: 30 } ], illustration: "close-up-handholds-carved-in-cliff-face", reward: { xp: 15 } },
|
687 |
"35": { title: "Dark Cave", content: `<p>The cave smells of salt and decay. Water drips somewhere within.</p>`, options: [{ text: "Press deeper into the darkness", next: 99 } ], illustration: "dark-cave-entrance-dripping-water" },
|
688 |
+
"40": { title: "Overgrown Shrine", content: `<p>Wildflowers grow thick around a small stone shrine. It feels ancient and neglected.</p>`, options: [{ text: "Examine the carvings (Intelligence Check)", check: { stat: 'intelligence', dc: 11, onFailure: 401 }, next: 400 } ], illustration: "overgrown-stone-shrine-wildflowers-close" },
|
689 |
"41": { title: "Rocky Badlands", content: `<p>The green hills give way to cracked earth and jagged rock formations under a harsh sun.</p>`, options: [{ text: "Scout ahead", next: 99 } ], illustration: "rocky-badlands-cracked-earth-harsh-sun" },
|
690 |
+
"190": { title: "Over the Rocks", content: "<p>With considerable effort, you manage to climb over the rockslide.</p><p>(+35 XP)</p>", options: [{ text: "Continue up the path", next: 22 }], illustration: "character-climbing-over-boulders", reward: { xp: 35 } },
|
691 |
+
"191": { title: "Climb Fails", content: "<p>The boulders are too unstable or sheer. You cannot climb them safely.</p>", options: [{ text: "Search for another way around", next: 192 }], illustration: "character-slipping-on-rockslide-boulders" },
|
692 |
+
"192": { title: "Detour Found", content: "<p>After some searching, you find a rough path leading around the rockslide, eventually rejoining the main trail.</p>", options: [{ text: "Continue up the path", next: 22 }], illustration: "rough-detour-path-around-rockslide" },
|
693 |
+
"21": { title: "Western Ridge", content: "<p>The ridge path is narrow and exposed, with strong winds threatening to push you off.</p>", options: [{ text: "Proceed carefully (Dexterity Check)", check: { stat: 'dexterity', dc: 14, onFailure: 211 }, next: 22 } ], illustration: "narrow-windy-mountain-ridge-path" },
|
694 |
+
"22": { title: "Fortress Approach", content: "<p>You've navigated the treacherous paths and now stand near the outer walls of the dark fortress. Guards patrol the battlements.</p>", options: [{ text: "Look for an unguarded entrance", next: 99 }], illustration: "approaching-dark-fortress-walls-guards" },
|
695 |
+
"211": { title: "Lost Balance", content: "<p>A strong gust of wind catches you off guard, sending you tumbling down a steep slope! You lose 10 HP.</p>", options: [{ text: "Climb back up and find another way", next: 17 }], illustration: "character-falling-off-windy-ridge", hpLoss: 10 },
|
696 |
"99": { title: "Game Over / To Be Continued...", content: "<p>Your adventure ends here (for now).</p>", options: [{ text: "Restart", next: 1 }], illustration: "game-over-generic", gameOver: true }
|
697 |
};
|
698 |
|
|
|
787 |
const roll = Math.floor(Math.random() * 20) + 1;
|
788 |
const totalResult = roll + modifier + accomplishmentBonus;
|
789 |
const dc = check.dc;
|
790 |
+
console.log(`Check: ${check.stat} (DC ${dc}) | Roll: ${roll} + Mod: ${modifier} + Acc: ${accomplishmentBonus} = ${totalResult}`);
|
791 |
if (totalResult >= dc) {
|
792 |
nextPageId = optionNextPageId;
|
793 |
rollResultMessage = `<p class="roll-success"><em>Check Success! (${totalResult} vs DC ${dc})</em></p>`;
|
|
|
853 |
renderPageInternal(99, gameData[99], "<p><em>Error: Next page data missing!</em></p>" + levelUpMessage);
|
854 |
return;
|
855 |
}
|
856 |
+
renderPageInternal(nextPageId, nextPageData, rollResultMessage + levelUpMessage);
|
857 |
}
|
858 |
|
859 |
function renderPageInternal(pageId, pageData, message = "") {
|
|
|
887 |
const button = document.createElement('button');
|
888 |
button.classList.add('choice-button');
|
889 |
button.textContent = pageData.gameOver ? "Restart Adventure" : "The End";
|
890 |
+
button.onclick = () => handleChoiceClick({ nextPage: pageData.gameOver ? 1 : 99 });
|
891 |
choicesElement.appendChild(button);
|
892 |
if (!pageData.gameOver) choicesElement.insertAdjacentHTML('afterbegin', '<p><i>The path ends here.</i></p>');
|
893 |
}
|
|
|
1021 |
adjustLighting(illustrationKey);
|
1022 |
} catch (error) {
|
1023 |
console.error(`Error creating assembly for ${illustrationKey}:`, error);
|
1024 |
+
current
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|