diff --git a/Data/scripts/base/chara/npc/object/ObjectBed.lua b/Data/scripts/base/chara/npc/object/ObjectBed.lua index 42108e2d..4fea605b 100644 --- a/Data/scripts/base/chara/npc/object/ObjectBed.lua +++ b/Data/scripts/base/chara/npc/object/ObjectBed.lua @@ -1,23 +1,63 @@ require ("global") +DREAM_ITEM = { + {[1] = 3010419, [2] = 3010420, [3] = 3010421}, -- Mizzenmast/Roost/Hourglass Biscuit + 3010003, -- Boiled Egg + 3010101, -- Grilled Carp + 3010001, -- Meat Miq'abob + 3010402, -- Ginger Cookie + 3020001, -- Potion + 3020101, -- Ether + 1000003, -- 5x Crystal Shards (Fire) + 1000004, -- 5x Crystal Shards (Ice) + 1000005, -- 5x Crystal Shards (Wind) + 1000006, -- 5x Crystal Shards (Earth) + 1000007, -- 5x Crystal Shards (Lightning) + 1000008 -- 5x Crystal Shards (Water) +} + function init(npc) return false, false, 0, 0; end function onEventStarted(player, npc, triggerName) - - choice = callClientFunction(player, "askLogout", player); + local choice = callClientFunction(player, "askLogout", player); + -- Quit if (choice == 2) then player:SetSleeping(); player:QuitGame(); + -- Logout elseif (choice == 3) then player:SetSleeping(); player:Logout(); + -- Heck the bed elseif (choice == 4) then - player:SendMessage(33, "", "Heck the bed"); + -- Give items based on dream + local dreamCode = player:GetLoginDreamCode(); + if (dreamCode >= 21 and dreamCode <= 33) then + local innCode = player:GetInnCode(); + local itemCode = DREAM_ITEM[dreamCode - 20]; + + -- Get biscuit for inn + if (dreamCode == 21) then + itemCode = itemCode[innCode]; + end + + -- If crystals you get x5 otherwise x1. + if (dreamCode > = 28 and dreamCode <= 33) then + player:AddItem(itemCode, 5); + else + player:AddItem(itemCode, 1); + end + + -- Clear the code so they player doesn't keep getting things + player:SetLoginDreamCode(0); + else + -- Otherwise show standard message + player:SendGameMessage(player, npc, 7, 0x20); + end end player:EndEvent(); - end \ No newline at end of file diff --git a/Data/scripts/base/chara/npc/object/OpeningTownEventKeeper.lua b/Data/scripts/base/chara/npc/object/OpeningTownEventKeeper.lua index d654d212..bb33ec75 100644 --- a/Data/scripts/base/chara/npc/object/OpeningTownEventKeeper.lua +++ b/Data/scripts/base/chara/npc/object/OpeningTownEventKeeper.lua @@ -5,14 +5,5 @@ function init(npc) end function onEventStarted(player, npc, eventType, eventName) - - if (eventType == ETYPE_PUSH) then - if (eventName == "caution") then - worldMaster = GetWorldMaster(); - player:SendGameMessage(player, worldMaster, 34109, 0x20); - elseif (eventName == "exit") then - GetWorldManager():DoPlayerMoveInZone(player, 5.36433, 196, 133.656, -2.84938); - end - end player:EndEvent(); end \ No newline at end of file diff --git a/Data/scripts/base/chara/npc/object/PrivateAreaPastExit.lua b/Data/scripts/base/chara/npc/object/PrivateAreaPastExit.lua index 446fd05d..c15e7030 100644 --- a/Data/scripts/base/chara/npc/object/PrivateAreaPastExit.lua +++ b/Data/scripts/base/chara/npc/object/PrivateAreaPastExit.lua @@ -27,10 +27,10 @@ function onEventStarted(player, privAreaExit, eventType, eventName) -- If you can leave, warp to public zone and show message. if (area.CanExitPrivateArea()) then player:SendGameMessage(player, GetWorldMaster(), 34110, MESSAGE_TYPE_SYSTEM); -- You have left the instance. - GetWorldManager():WarpToPublicArea(player); + --GetWorldManager():WarpToPublicArea(player); -- Otherwise warp back to the center of the zone. else - GetWorldManager():WarpToCharaPosition(player, privAreaExit); + --GetWorldManager():WarpToCharaPosition(player, privAreaExit); end end end diff --git a/Data/scripts/commands/gm/nudgenpc.lua b/Data/scripts/commands/gm/nudgenpc.lua index e1719e5f..67e49c93 100644 --- a/Data/scripts/commands/gm/nudgenpc.lua +++ b/Data/scripts/commands/gm/nudgenpc.lua @@ -127,7 +127,7 @@ function onTrigger(player, argc, arg1, arg2) targetActor:SetPos(px, y, pz, rot, true, player); message = string.format("Moved %s @ %f, %f, %f, %f", targetActor:GetUniqueId(), px, y, pz, rot); elseif direction == 3 then - targetActor:SetPos(x, y, z, distance, true, player); + targetActor:SetPos(x, y, z, angle + distance, true, player); message = string.format("Moved %s @ %f, %f, %f, %f", targetActor:GetUniqueId(), x, y, z, distance); else local px = x - distance * math.cos(angle); diff --git a/Data/scripts/commands/gm/setpopulacepos.lua b/Data/scripts/commands/gm/setpopulacepos.lua index d8bc0199..db8fb037 100644 --- a/Data/scripts/commands/gm/setpopulacepos.lua +++ b/Data/scripts/commands/gm/setpopulacepos.lua @@ -23,7 +23,7 @@ function onTrigger(player, argc, name, posX, posY, posZ, rotation) actor = player.CurrentArea:FindActorInZoneByUniqueID(name); if (actor ~= nil) then - actor:SetPos(x,y,z,rot,true); + actor:SetPos(x,y,z,rot,true, player); player:SendMessage(0x20, "", string.format("Moved %s @ %f, %f, %f, %f", name, x, y, z, rot)); else player:SendMessage(0x20, "", string.format("Could not find %s.", name)); diff --git a/Data/scripts/player.lua b/Data/scripts/player.lua index ae821bbf..00923093 100644 --- a/Data/scripts/player.lua +++ b/Data/scripts/player.lua @@ -3,7 +3,7 @@ require("global"); local initClassItems, initRaceItems; function onBeginLogin(player) - --New character, set the initial quest + -- New character, set the initial quest if (player:GetPlayTime(false) == 0) then initialTown = player:GetInitialTown(); if (initialTown == 1 and player:HasQuest(110001) == false) then @@ -18,8 +18,29 @@ function onBeginLogin(player) end end + + -- Set Dream Packet if waking up in the inn + if (player.CurrentArea.ZoneId == 244) then + local dreamCode = 35; + + -- In Plain Sight wakeup dream + if (player:HasItem(10011243) and not player:HasQuest(110829)) then + dreamCode = 1; + -- The Usual Suspect wakeup dream + elseif (player:HasItem(10011252) and not player:HasQuest(110849)) then + dreamCode = 2; + -- Nael Van Darnus nightmare + elseif (player:???) then + dreamCode = 20; + -- Random item + elseif (player:???) then + dreamCode = math.random(21, 33); + end + + player:SetLoginDreamCode(dreamCode); + end - --For Opening. Set Director and reset position incase d/c + -- For Opening. Set Director and reset position incase d/c if (player:HasQuest(110001) == true and player.CurrentArea.ZoneId == 193) then director = player.CurrentArea:CreateDirector("OpeningDirector", false); player:AddDirector(director); diff --git a/Map Server/Actors/Chara/Player/Player.cs b/Map Server/Actors/Chara/Player/Player.cs index a79367aa..ed318610 100644 --- a/Map Server/Actors/Chara/Player/Player.cs +++ b/Map Server/Actors/Chara/Player/Player.cs @@ -119,6 +119,7 @@ namespace Meteor.Map.Actors public uint lastPlayTimeUpdate; public bool isGM = false; public bool isZoneChanging = true; + public byte LoginDreamCode = 0; //Trading private Player otherTrader = null; @@ -420,7 +421,7 @@ namespace Meteor.Map.Actors for (int i = 0; i < 2048; i++) testComplete[i] = true; QueuePacket(cutsceneBookPacket.BuildPacket(Id, SNpcNickname, SNpcSkin, SNpcPersonality, SNpcCoordinate, testComplete)); - QueuePacket(SetPlayerDreamPacket.BuildPacket(Id, 0x16, GetInnCode())); + QueuePacket(SetPlayerDreamPacket.BuildPacket(Id, LoginDreamCode, GetInnCode())); } return subpackets; @@ -869,6 +870,16 @@ namespace Meteor.Map.Actors return 0; } + public void SetLoginDreamCode(byte code) + { + LoginDreamCode = code; + } + + public byte GetLoginDreamCode() + { + return LoginDreamCode; + } + public void SetSleeping() { playerSession.LockUpdates(true); @@ -2196,7 +2207,7 @@ namespace Meteor.Map.Actors currentEventName = ""; currentEventType = 0; currentEventRunning = null; - } + } public void BroadcastCountdown(byte countdownLength, ulong syncTime) {