diff --git a/FFXIVClassic Map Server/actors/area/Area.cs b/FFXIVClassic Map Server/actors/area/Area.cs index 756893aa..c56414b1 100644 --- a/FFXIVClassic Map Server/actors/area/Area.cs +++ b/FFXIVClassic Map Server/actors/area/Area.cs @@ -467,6 +467,11 @@ namespace FFXIVClassic_Map_Server.Actors RemoveActorFromZone(FindActorInZoneByUniqueID(uniqueId)); } + public void DespawnActor(Actor actor) + { + RemoveActorFromZone(actor); + } + public Director GetWeatherDirector() { return mWeatherDirector; diff --git a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs index 05b694b0..6650e72b 100644 --- a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs +++ b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs @@ -396,6 +396,11 @@ namespace FFXIVClassic_Map_Server.Actors player.QueuePacket(PlayBGAnimation.BuildPacket(actorId, player.actorId, animationName)); } + public void Despawn() + { + zone.DespawnActor(this); + } + public void Update(double deltaTime) { LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime); diff --git a/FFXIVClassic Map Server/actors/director/Director.cs b/FFXIVClassic Map Server/actors/director/Director.cs index 6f382fe1..5dfb492e 100644 --- a/FFXIVClassic Map Server/actors/director/Director.cs +++ b/FFXIVClassic Map Server/actors/director/Director.cs @@ -123,6 +123,7 @@ namespace FFXIVClassic_Map_Server.actors.director public void EndDirector() { isDeleting = true; + if (this is GuildleveDirector) ((GuildleveDirector)this).EndGuildleveDirector(); diff --git a/FFXIVClassic Map Server/actors/director/GuildleveDirector.cs b/FFXIVClassic Map Server/actors/director/GuildleveDirector.cs index 9c440474..e1d00a63 100644 --- a/FFXIVClassic Map Server/actors/director/GuildleveDirector.cs +++ b/FFXIVClassic Map Server/actors/director/GuildleveDirector.cs @@ -23,6 +23,8 @@ namespace FFXIVClassic_Map_Server.actors.director public GuildleveData guildleveData; public GuildleveWork guildleveWork = new GuildleveWork(); + public bool isEnded = false; + public GuildleveDirector(uint id, Area zone, string directorPath, uint guildleveId, byte selectedDifficulty, Player guildleveOwner, params object[] args) : base(id, zone, directorPath, args) { @@ -83,9 +85,27 @@ namespace FFXIVClassic_Map_Server.actors.director public void EndGuildleve(bool wasCompleted) { + if (isEnded) + return; + isEnded = true; + if (wasCompleted) { + foreach (Actor a in GetPlayerMembers()) + { + Player player = (Player)a; + player.PlayAnimation(0x02000002); + player.ChangeMusic(81); + player.SendGameMessage(Server.GetWorldManager().GetActor(), 50023, 0x20, (object)(int)guildleveId); + player.SendDataPacket("attention", Server.GetWorldManager().GetActor(), "", 50023, (object)(int)guildleveId); + } + } + foreach (Actor a in GetNpcMembers()) + { + Npc npc = (Npc)a; + npc.Despawn(); + RemoveMember(a); } guildleveWork.startTime = 0; @@ -96,6 +116,11 @@ namespace FFXIVClassic_Map_Server.actors.director propertyBuilder.AddProperty("guildleveWork.startTime"); SendPacketsToPlayers(propertyBuilder.Done()); + if (wasCompleted) + { + Npc aetheryteNode = zone.SpawnActor(1200040, String.Format("{0}:warpExit", guildleveOwner.actorName), guildleveOwner.positionX, guildleveOwner.positionY, guildleveOwner.positionZ); + contentGroup.AddMember(aetheryteNode); + } } public void AbandonGuildleve() diff --git a/FFXIVClassic Map Server/actors/group/ContentGroup.cs b/FFXIVClassic Map Server/actors/group/ContentGroup.cs index 0c8b9a82..11b6a0c7 100644 --- a/FFXIVClassic Map Server/actors/group/ContentGroup.cs +++ b/FFXIVClassic Map Server/actors/group/ContentGroup.cs @@ -134,7 +134,11 @@ namespace FFXIVClassic_Map_Server.actors.group Session s = Server.GetServer().GetSession(members[i]); if (s != null) s.GetActor().SetCurrentContentGroup(null); + Actor a = director.GetZone().FindActorInArea(members[i]); + if (a is Npc) + ((Npc)a).Despawn(); members.Remove(members[i]); + i--; } Server.GetWorldManager().DeleteContentGroup(groupIndex); } diff --git a/data/scripts/base/chara/npc/object/GuildleveWarpPoint.lua b/data/scripts/base/chara/npc/object/GuildleveWarpPoint.lua new file mode 100644 index 00000000..1c0dc221 --- /dev/null +++ b/data/scripts/base/chara/npc/object/GuildleveWarpPoint.lua @@ -0,0 +1,43 @@ +--[[ + +GuildleveWarpPoint Script + +Functions: + +eventGuildleveReward(glId, completionTimeSec, completeReward, difficultyBonus, faction, gil???, factionBonus, RewardId1, RewardAmount1, RewardId2, RewardAmount2, difficulty) - Open Reward Dialog +eventTalkGuildleveWarp(returnAetheryteID1, returnAetheryte2) - Opens choice menu +--]] + +require ("global") +require ("aetheryte") +require ("utils") + +function init(npc) + return false, false, 0, 0; +end + +function onEventStarted(player, npc, triggerName) + local currentGLDirector = player:GetGuildleveDirector(); + local glData = currentGLDirector.guildleveData; + + callClientFunction(player, "eventGuildleveReward", currentGLDirector.guildleveId, 0x26, 24, 24, 0, 0, 0, 0, 0, 0, 0, 4); + + local choice = callClientFunction(player, "eventTalkGuildleveWarp", glData.aetheryte, 0); + + if (choice == 3) then + local destination = aetheryteTeleportPositions[glData.aetheryte]; + if (destination ~= nil) then + randoPos = getRandomPointInBand(destination[2], destination[4], 3, 5); + rotation = getAngleFacing(randoPos.x, randoPos.y, destination[2], destination[4]); + GetWorldManager():DoZoneChange(player, destination[1], nil, 0, 2, randoPos.x, destination[3], randoPos.y, rotation); + currentGLDirector:EndDirector(); + end + elseif (choice == 4) then + currentGLDirector:EndDirector(); + end + + player:EndEvent(); +end + +--50023: GL COMPLETE! +--50132: You earn faction credits from X \ No newline at end of file diff --git a/data/scripts/directors/Guildleve/PrivateGLBattleOrbNormal.lua b/data/scripts/directors/Guildleve/PrivateGLBattleOrbNormal.lua index 37b9648f..6a9cdb81 100644 --- a/data/scripts/directors/Guildleve/PrivateGLBattleOrbNormal.lua +++ b/data/scripts/directors/Guildleve/PrivateGLBattleOrbNormal.lua @@ -28,5 +28,10 @@ function main(thisDirector) thisDirector:UpdateAimNumNow(0, 2); wait(3); thisDirector:UpdateAimNumNow(0, 3); + wait(3); + thisDirector:UpdateAimNumNow(0, 4); + + wait(2); + thisDirector:EndGuildleve(true); end