Skip to content

Commit

Permalink
(feat) You can now change virtual server without a need to reconnect …
Browse files Browse the repository at this point in the history
…with Homecoming.
  • Loading branch information
DamianQualshy committed Nov 17, 2024
1 parent 0a33495 commit 838d04b
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 15 deletions.
20 changes: 20 additions & 0 deletions Homecoming/Scripts/Client/CLocalPlayer.nut
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,26 @@ class LocalPlayer {
return this.pos;
}

function setWaypoint(wp){
local wp_pos = getWaypoint(convert(wp, "string"))

if(wp_pos != null){
this.setPosition(
wp_pos.x,
wp_pos.y,
wp_pos.z,
0
);
} else {
this.setPosition(
0.0,
0.0,
0.0,
0
);
}
}


function giveItem(instance, amount){
_giveItem(this.id, instance, amount);
Expand Down
28 changes: 23 additions & 5 deletions Homecoming/Scripts/Client/CMainMenu.nut
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,21 @@ function launchMenuScene(toggle){
menuCollection.setVisible(toggle);

if(toggle){
Chat.setVisible(false);
Chat.clear();
timeCollection.setVisible(false);

if(getPlayerPosition(heroId) != getWaypoint("TOT")) Player[heroId].setWaypoint("TOT");

setHudMode(HUD_ALL, HUD_MODE_HIDDEN);
setDayLength(10000);

disableControls(true);
disableMusicSystem(true);

Camera.movementEnabled = false;
Camera.modeChangeEnabled = false;

Sword.addToWorld();
calculateSwordOffset();
addEventHandler("onRender", menuSwordScene);
Expand Down Expand Up @@ -180,12 +195,19 @@ function menuChangeVisibility(toggle){
menuGUI.play.setColor({r = 255, g = 255, b = 255, a = 255});
}

if(toggle) calculateSwordOffset();
if(toggle) {
updateDiscordState(format("In Main Menu"));
calculateSwordOffset();
}
}

JoinMenuMessage.bind(function(message){
launchMenuScene(true);

Music.setVolume(100);
Music.looping = true;
Music.play();

menuGUI.settings.setDisabled(true);
menuGUI.options.setDisabled(true);

Expand All @@ -194,10 +216,6 @@ JoinMenuMessage.bind(function(message){
local versionDrawSize = menuGUI.version.getSizePx();
menuGUI.version.setPositionPx(nax(8192 - anx(versionDrawSize.height + versionDrawSize.width)), nay(8192 - versionDrawSize.width));
menuGUI.version.setDisabled(true);

Music.setVolume(100);
Music.looping = true;
Music.play();
});

addEventHandler("GUI.onClick", function(self){
Expand Down
2 changes: 1 addition & 1 deletion Homecoming/Scripts/Client/CMainMenu/Appearance.nut
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ local creatorGUI = {

function toggleCreator(toggle){
creatorCollection.setVisible(toggle);
updateDiscordState(format("Creating a character..."));

local xardasWaypoint = {
x = 29628.5
Expand Down Expand Up @@ -255,7 +256,6 @@ function toggleCreator(toggle){
Player[heroId].setScale(heroId, _scale.x, _scale.y, _scale.z, _scale.f);

}
updateDiscordState(format("%s (Creating a Character...)", getPlayerName(heroId)));
} else {
setPlayerAngle(heroId, xardasWaypoint.a);
}
Expand Down
1 change: 1 addition & 0 deletions Homecoming/Scripts/Client/CSelectClass.nut
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local function updateClassInfo(class_id){
if(class_id > _classLen - 1) class_id = 0;

selectedClass = class_id;
updateDiscordState(format("Picking a class..."));

local ui = selectClassGUI;
local info = _classWorld[selectedClass];
Expand Down
1 change: 1 addition & 0 deletions Homecoming/Scripts/Client/CServerList.nut
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ local serverListScroll = serverGUI.list.scrollbar.range;

function showServerList(toggle){
serverCollection.setVisible(toggle);
updateDiscordState(format("Choosing a server..."));

if(toggle){
addEventHandler("GUI.onMouseIn", srvListMouseIn);
Expand Down
4 changes: 2 additions & 2 deletions Homecoming/Scripts/Client/Client.nut
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
addEventHandler("onInit", function(){
clearMultiplayerMessages();

setHudMode(HUD_ALL, HUD_MODE_HIDDEN);
/* setHudMode(HUD_ALL, HUD_MODE_HIDDEN);
setDayLength(10000);
disableControls(true);
disableMusicSystem(true);
Camera.movementEnabled = false;
Camera.modeChangeEnabled = false;
Camera.modeChangeEnabled = false; */

disableKey(KEY_F1, true);
disableKey(KEY_F2, true);
Expand Down
10 changes: 9 additions & 1 deletion Homecoming/Scripts/Client/Interface.nut
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ addEventHandler("onKeyDown", function(key){
break;

case KEY_F3:
toggleAnim(!animCollection.getVisible());
toggleAnim(!animCollection.getVisible());
break;

case KEY_F4:
if(animCollection.getVisible()) return;
NetStats.setVisible(!NetStats.visible)
break;

case KEY_F9:
if(animCollection.getVisible()) return;
local disconnectFromVirtual = ServerLeaveMessage(heroId, Player[heroId].getVirtualWorld()).serialize();
disconnectFromVirtual.send(RELIABLE);

launchMenuScene(true);
break;

case KEY_ESCAPE:
if(animCollection.getVisible()) return;
// CIngame.nut
Expand Down
21 changes: 15 additions & 6 deletions Homecoming/Scripts/Server/HeroClass/Prototype.nut
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,21 @@ class PrototypeHero {
function setWaypoint(wp){
local wp_pos = getWaypoint(this.world, convert(wp, "string"));

this.setPosition(
wp_pos.x,
wp_pos.y,
wp_pos.z,
0
);
if(wp_pos != null){
this.setPosition(
wp_pos.x,
wp_pos.y,
wp_pos.z,
0
);
} else {
this.setPosition(
0.0,
0.0,
0.0,
0
);
}
}

function respawn(){
Expand Down

0 comments on commit 838d04b

Please sign in to comment.