Skip to content

Commit

Permalink
new town + a few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
orion3dgames committed May 26, 2024
1 parent b357f5d commit 009b59c
Show file tree
Hide file tree
Showing 13 changed files with 867 additions and 54 deletions.
Binary file added construction/Map.afdesign
Binary file not shown.
740 changes: 740 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

Binary file added public/models/environment/_lh_town.glb
Binary file not shown.
Binary file modified public/models/environment/lh_town.glb
Binary file not shown.
Binary file modified public/models/navmesh/lh_town.glb
Binary file not shown.
8 changes: 6 additions & 2 deletions src/client/Controllers/AssetsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ export class AssetsController {
// add water
if (this._game.currentLocation.waterPlane) {
var waterMesh = CreateGround("waterMesh", { width: 512, height: 512, subdivisions: 32 }, this._game.scene);
waterMesh.position = new Vector3(0, -0.25, 0);
waterMesh.position = new Vector3(0, -0.50, 0);
var water = new StandardMaterial("water");
water.diffuseTexture = new Texture("textures/waterbump.jpg");

let waterTexture = new Texture("textures/waterbump.jpg");
waterTexture.uScale = 40;
waterTexture.vScale = 40
water.diffuseTexture = waterTexture;
waterMesh.material = water;
}

Expand Down
1 change: 1 addition & 0 deletions src/client/Controllers/UI/Panels/Panel_Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Panel_Dialog extends Panel {
dialogTextBlock.text = dialogText;
}

console.log(currentDialog);
// create any quest buttons
if (currentDialog.quests) {
let q = 1;
Expand Down
32 changes: 17 additions & 15 deletions src/client/Entities/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { UserInterface } from "../../client/Controllers/UserInterface";
import State from "../../client/Screens/Screens";
import { Ability, ServerMsg } from "../../shared/types";
import { GameScene } from "../Screens/GameScene";
import { Mesh } from "@babylonjs/core/Meshes/mesh";

export class Player extends Entity {
public game;
Expand Down Expand Up @@ -242,21 +243,6 @@ export class Player extends Entity {
// process player movement
this.moveController.processMove();

///////////// ENVIRONMENT LOD ///////////////////////////
// only show meshes close to us
/*
let currentPos = this.getPosition();
let key = "ENV_" + this._game.currentLocation.mesh;
let allMeshes = this._game._loadedAssets[key]?.loadedMeshes ?? [];
allMeshes.forEach((element) => {
let distanceTo = Vector3.Distance(element.getAbsolutePosition(), currentPos);
if (distanceTo < this._game.config.PLAYER_VIEW_DISTANCE) {
element.setEnabled(true);
} else {
element.setEnabled(false);
}
});*/

///////////// ABILITY & CASTING EVENTS ///////////////////////////
// if digit pressed
if (this._input.digit_pressed > 0 && !this.isCasting) {
Expand Down Expand Up @@ -335,6 +321,22 @@ export class Player extends Entity {
if (this.closestEntityDistance > 5 && this.closestEntity.interactableButtons) {
this._ui.panelDialog.close();
}

///////////// ENVIRONMENT LOD ///////////////////////////
// only show meshes close to us
let currentPos = this.getPosition();
let key = "ENV_" + this._game.currentLocation.mesh;
let allMeshes = this._game._loadedAssets[key]?.loadedMeshes ?? [];
allMeshes.forEach((element) => {
if(element.name !== '__root__'){
let distanceTo = Vector3.Distance(element.getAbsolutePosition(), currentPos);
if (distanceTo < 40) {
element.setEnabled(true);
} else {
element.setEnabled(false);
}
}
});
}
}

Expand Down
23 changes: 18 additions & 5 deletions src/client/Entities/Player/PlayerCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,26 @@ export class PlayerCamera {
}

public update(): void {

let preventVertical = false;

// rotate camera around the Y position if right click is true
if (this._input.middle_click) {
const rotationX =
Math.abs(this._camRoot.rotation.x + this._input.movementY) < 0.5 ? this._camRoot.rotation.x + this._input.movementY : this._camRoot.rotation.x;
const rotationY = this._camRoot.rotation.y + this._input.movementX;
this._camRoot.rotation = new Vector3(rotationX, rotationY, 0);
if (!this._input.middle_click) {
return;
}

// only do vertical if allowed
let rotationX = 0;
if(!preventVertical){
rotationX = Math.abs(this._camRoot.rotation.x + this._input.movementY) < 0.5 ? this._camRoot.rotation.x + this._input.movementY : this._camRoot.rotation.x;
}

// set horizontal rotation
const rotationY = this._camRoot.rotation.y + this._input.movementX;

// apply canmera rotation
this._camRoot.rotation = new Vector3(rotationX, rotationY, 0);

}

public zoom(deltaY): void {
Expand Down
6 changes: 3 additions & 3 deletions src/server/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ class Database {
this.generateStatPoint(),
"lh_town",

"0",
"0",
"0",
"6.18",
"0.1",
"-11.21",
"1.72",

"1",
Expand Down
2 changes: 2 additions & 0 deletions src/server/GameData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class GameData {
}

public static load(type) {

let returnData;
switch (type) {
case "abilities":
Expand All @@ -50,6 +51,7 @@ export class GameData {
break;
case "quests":
returnData = QuestsDB ?? false;
break;
case "help":
returnData = HelpDB ?? false;
break;
Expand Down
6 changes: 6 additions & 0 deletions src/server/data/HelpDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ let HelpDB = {
description: "Please press and hold the left mouse button and move your mouse to move your character. Release the left mouse button to stop.",
align: "left",
},
{
type: "section",
title: "Camera Controls",
description: "You can press the middle click of the mouse and drag the mouse to rotate the camera.",
align: "left",
},
{
type: "section",
title: "How to attack?",
Expand Down
103 changes: 74 additions & 29 deletions src/server/data/LocationsDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let LocationsDB = {
interactive: [
{
type: "zone_change",
from: new Vector3(13.87, 0, -29.84),
from: new Vector3(13.82, 0.1, -33.46),
to_map: "lh_dungeon_01",
to_vector: new Vector3(0, 0, 0),
},
Expand All @@ -39,24 +39,56 @@ let LocationsDB = {
},
],
spawns: [

{
key: "lh_town_intro",
type: "area",
behaviour: "patrol",
aggressive: true,
canAttack: true,
points: [
new Vector3(33.93, 0.1, 0.31),
new Vector3(44.67, 0.1, -8.61),
new Vector3(53.21, 0.1, 0.45),
new Vector3(50.13, 0.1, 11.68)
],
amount: 10,
race: "male_mage",
material: 0,
name: "Thief",
baseHealth: 40,
baseSpeed: Speed.VERY_SLOW,
equipment: [
{
key: "sword_01",
slot: PlayerSlots.WEAPON,
},
],
},

{
key: "lh_town_thief",
type: "global",
type: "area",
behaviour: "patrol",
aggressive: false,
canAttack: true,
points: [new Vector3(5.38, 0.01, -1.3), new Vector3(15.53, 0.01, -8.95), new Vector3(-4.72, 0.01, -2.28)],
amount: 120,
points: [
new Vector3(39.35, 0.1, 39.11),
new Vector3(60.81, 0.1, 22.54),
new Vector3(67.49, 0.1, 39.73),
new Vector3(86.13, 0.17, 38.12),
new Vector3(69.02, 0.1, 55.81),
new Vector3(53.82, 0.1, 57.89),
new Vector3(45.52, 0.1, 46.68),
new Vector3(37.82, 0.1, 52.82)
],
amount: 10,
race: "male_mage",
material: 1,
name: "Thief",
baseHealth: 40,
baseSpeed: Speed.VERY_SLOW,
equipment: [
{
key: "shield_01",
slot: PlayerSlots.OFF_HAND,
},
{
key: "sword_01",
slot: PlayerSlots.WEAPON,
Expand All @@ -71,18 +103,18 @@ let LocationsDB = {
aggressive: true,
canAttack: true,
points: [
new Vector3(-7, 0, -19),
new Vector3(-10.42, 0.01, -27.33),
new Vector3(-18, 0, -27),
new Vector3(-12, 0, -34),
new Vector3(-9.8, 0, -27),
new Vector3(-6, 0, -23),
new Vector3(-18, 0, -18),
new Vector3(-22.33, 0.01, -21.03),
new Vector3(-8.8, 0.01, -22.39),
new Vector3(-8.51, 0.01, -14.93),
new Vector3(47.33, 0.1, 82.32),
new Vector3(31.38, 0.1, 92.21),
new Vector3(13.38, 0.1, 77.76),
new Vector3(23.24, 0.1, 63.66),
new Vector3(-1.81, 0.1, 66.85),
new Vector3(-4.56, 0.1, 81.26),
new Vector3(8.97, 0.1, 93.21),
new Vector3(34.44, 0.1, 97.1),
new Vector3(-15.45, 0.1, 73.79),
new Vector3(4.56, 0.1, 68.85)
],
amount: 50,
amount: 10,
race: "male_rogue",
material: 2,
name: "Bandit",
Expand Down Expand Up @@ -110,9 +142,9 @@ let LocationsDB = {
behaviour: "idle",
aggressive: false,
canAttack: false,
points: [new Vector3(38.7, 3.51, -11.81)],
rotation: 3.12,
amount: 0,
points: [new Vector3(40.32, 0.1, 20.88)],
rotation: 1.85,
amount: 1,
race: "male_knight",
material: 0,
name: "Alexander The Righteous",
Expand All @@ -127,16 +159,29 @@ let LocationsDB = {
],
},
},
{
key: "lh_town_market_01",
type: "static",
behaviour: "idle",
aggressive: false,
canAttack: false,
points: [new Vector3(9.65, 0.1, 35.11)],
rotation: 1.85,
amount: 2,
race: "male_mage",
material: 1,
name: "Karack",
},
{
key: "spawn_04",
type: "static",
behaviour: "idle",
aggressive: false,
canAttack: false,
points: [new Vector3(9.67, 0, -28.58)],
points: [new Vector3(7.45, 0.1, -28.12)],
rotation: 3.12,
amount: 1,
race: "male_knight",
amount: 2,
race: "male_mage",
material: 2,
name: "Kilhiam ",
equipment: [],
Expand Down Expand Up @@ -180,8 +225,8 @@ let LocationsDB = {
behaviour: "idle",
aggressive: false,
canAttack: false,
points: [new Vector3(4.17, 0.01, -29.07)],
rotation: 3.12,
points: [new Vector3(17.96, 0.1, 0.76)],
rotation: 1.34,
radius: 0,
amount: 1,
race: "male_knight",
Expand All @@ -207,8 +252,8 @@ let LocationsDB = {
behaviour: "idle",
aggressive: false,
canAttack: false,
points: [new Vector3(12.94, 0.01, -20.27)],
rotation: 1.5,
points: [new Vector3(30.05, 0.1, -23.74)],
rotation: 3.14,
radius: 0,
amount: 1,
race: "male_knight",
Expand Down

0 comments on commit 009b59c

Please sign in to comment.