Finished the crafting start window system. Added PassiveGuildleveQuests and refactors the Quest object. Cleaned up how zone music is handled.

This commit is contained in:
Filip Maj 2021-02-26 20:53:42 -05:00
parent f4e2280de8
commit 605b4918e2
34 changed files with 7121 additions and 4533 deletions

View file

@ -363,7 +363,7 @@ namespace Meteor.Map.Actors
return packets;
}
public override bool Equals(Object obj)
public override bool Equals(object obj)
{
Actor actorObj = obj as Actor;
if (actorObj == null)
@ -508,7 +508,7 @@ namespace Meteor.Map.Actors
.Replace("Object", "Obj")
.Replace("Retainer", "Rtn")
.Replace("Standard", "Std");
className = Char.ToLowerInvariant(className[0]) + className.Substring(1);
className = char.ToLowerInvariant(className[0]) + className.Substring(1);
//Format Zone Name
string zoneName = zone.zoneName.Replace("Field", "Fld")
@ -524,7 +524,7 @@ namespace Meteor.Map.Actors
//Check if "normal"
zoneName = zoneName.Remove(zoneName.Length - 1, 1) + "P";
}
zoneName = Char.ToLowerInvariant(zoneName[0]) + zoneName.Substring(1);
zoneName = char.ToLowerInvariant(zoneName[0]) + zoneName.Substring(1);
try
{
@ -542,7 +542,7 @@ namespace Meteor.Map.Actors
if (zone is PrivateArea)
privLevel = ((PrivateArea)zone).GetPrivateAreaType();
actorName = String.Format("{0}_{1}_{2}@{3:X3}{4:X2}", className, zoneName, classNumber, zoneId, privLevel);
actorName = string.Format("{0}_{1}_{2}@{3:X3}{4:X2}", className, zoneName, classNumber, zoneId, privLevel);
}
public bool SetWorkValue(Player player, string name, string uiFunc, object value)
@ -553,8 +553,8 @@ namespace Meteor.Map.Actors
if (!(split[0].Equals("work") || split[0].Equals("charaWork") || split[0].Equals("playerWork") || split[0].Equals("npcWork")))
return false;
Object parentObj = null;
Object curObj = this;
object parentObj = null;
object curObj = this;
for (int i = 0; i < split.Length; i++)
{
//For arrays
@ -759,7 +759,7 @@ namespace Meteor.Map.Actors
{
if (target == null)
{
Program.Log.Error(String.Format("[{0} {1}] FindRandomPointAroundTarget: no target found!", this.actorId, this.customDisplayName));
Program.Log.Error(string.Format("[{0} {1}] FindRandomPointAroundTarget: no target found!", this.actorId, this.customDisplayName));
return GetPosAsVector3();
}
return FindRandomPoint(target.positionX, target.positionY, target.positionZ, minRadius, maxRadius);

View file

@ -48,7 +48,7 @@ namespace Meteor.Map.Actors
protected int halfWidth, halfHeight;
private Dictionary<uint, Director> currentDirectors = new Dictionary<uint, Director>();
private Object directorLock = new Object();
private object directorLock = new object();
private uint directorIdCount = 0;
protected Director mWeatherDirector;
@ -77,7 +77,7 @@ namespace Meteor.Map.Actors
this.displayNameId = 0;
this.customDisplayName = "_areaMaster";
this.actorName = String.Format("_areaMaster@{0:X5}", id << 8);
this.actorName = string.Format("_areaMaster@{0:X5}", id << 8);
this.classPath = classPath;
this.className = classPath.Substring(classPath.LastIndexOf("/") + 1);
@ -611,7 +611,7 @@ namespace Meteor.Map.Actors
public Director CreateGuildleveDirector(uint glid, byte difficulty, Player owner, params object[] args)
{
String directorScriptPath = "";
string directorScriptPath = "";
uint type = Server.GetGuildleveGamedata(glid).plateId;
@ -677,6 +677,11 @@ namespace Meteor.Map.Actors
return null;
}
public ushort GetCurrentMusic()
{
return bgmDay;
}
public override void Update(DateTime tick)
{
lock (mActorList)
@ -691,6 +696,5 @@ namespace Meteor.Map.Actors
}
}
}
}
}

View file

@ -32,7 +32,7 @@ namespace Meteor.Map.actors.area
private Director currentDirector;
private bool isContentFinished = false;
public static PrivateAreaContent CreateContentArea(String scriptPath)
public static PrivateAreaContent CreateContentArea(string scriptPath)
{
return null;
}

View file

@ -33,14 +33,14 @@ namespace Meteor.Map.actors.area
{
Dictionary<string, Dictionary<uint, PrivateArea>> privateAreas = new Dictionary<string, Dictionary<uint, PrivateArea>>();
Dictionary<string, List<PrivateAreaContent>> contentAreas = new Dictionary<string, List<PrivateAreaContent>>();
Object contentAreasLock = new Object();
object contentAreasLock = new object();
public SharpNav.TiledNavMesh tiledNavMesh;
public SharpNav.NavMeshQuery navMeshQuery;
public Int64 pathCalls;
public Int64 prevPathCalls = 0;
public Int64 pathCallTime;
public long pathCalls;
public long prevPathCalls = 0;
public long pathCallTime;
public Zone(uint id, string zoneName, ushort regionId, string classPath, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isIsolated, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid, bool loadNavMesh = false)
: base(id, zoneName, regionId, classPath, bgmDay, bgmNight, bgmBattle, isIsolated, isInn, canRideChocobo, canStealth, isInstanceRaid)

View file

@ -152,7 +152,7 @@ namespace Meteor.Map.Actors
public uint extraUint;
public float extraFloat;
protected Dictionary<string, UInt64> tempVars = new Dictionary<string, UInt64>();
protected Dictionary<string, ulong> tempVars = new Dictionary<string, ulong>();
//Inventory
protected Dictionary<ushort, ItemPackage> itemPackages = new Dictionary<ushort, ItemPackage>();
@ -227,8 +227,8 @@ namespace Meteor.Map.Actors
{
if (!effect.GetHidden())
{
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.statusShownTime[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.statusShownTime[{0}]", i));
i++;
}
}
@ -908,9 +908,9 @@ namespace Meteor.Map.Actors
AddTP((int)Math.Ceiling(tpModifier * action.amount));
}
public UInt64 GetTempVar(string name)
public ulong GetTempVar(string name)
{
UInt64 retVal = 0;
ulong retVal = 0;
if (tempVars.TryGetValue(name, out retVal))
return retVal;
return 0;
@ -923,7 +923,7 @@ namespace Meteor.Map.Actors
tempVars[name] = val;
}
public void SetTempVar(string name, UInt64 val)
public void SetTempVar(string name, ulong val)
{
if (tempVars.ContainsKey(name))
tempVars[name] = val;
@ -994,7 +994,7 @@ namespace Meteor.Map.Actors
{
shouldSend = true;
charaWork.battleTemp.timingCommandFlag[i] = false;
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.timingCommandFlag[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.battleTemp.timingCommandFlag[{0}]", i));
}
}
@ -1025,7 +1025,7 @@ namespace Meteor.Map.Actors
if (this is Player)
{
var propPacketUtil = new ActorPropertyPacketUtil("charaWork/timingCommand", this);
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.timingCommandFlag[{0}]", procId));
propPacketUtil.AddProperty(string.Format("charaWork.battleTemp.timingCommandFlag[{0}]", procId));
((Player)this).QueuePackets(propPacketUtil.Done());
}
}

View file

@ -26,7 +26,7 @@ namespace Meteor.Map.actors.chara
//These will need to be redone at some point. remember to update tables in db.
//Consider using text_paramname sheet. that matches up with the stats on armor, but some things will need special handling
//Also, 0-35 should probably match with up BattleTemp
enum Modifier : UInt32
enum Modifier : uint
{
//These line up with ParamNames starting at 15001 and appear on gear
//Health

View file

@ -27,9 +27,9 @@ namespace Meteor.Map.actors.chara
class ModifierListEntry
{
public uint id;
public Int64 value;
public long value;
public ModifierListEntry(uint id, Int64 value)
public ModifierListEntry(uint id, long value)
{
this.id = id;
this.value = value;
@ -47,13 +47,13 @@ namespace Meteor.Map.actors.chara
mobModList = new Dictionary<uint, ModifierListEntry>();
}
public void AddModifier(uint id, Int64 val, bool isMobMod)
public void AddModifier(uint id, long val, bool isMobMod)
{
var list = isMobMod ? mobModList : modList;
list.Add(id, new ModifierListEntry(id, val));
}
public void SetModifier(uint id, Int64 val, bool isMobMod)
public void SetModifier(uint id, long val, bool isMobMod)
{
var list = isMobMod ? mobModList : modList;
if (list.ContainsKey(id))
@ -62,7 +62,7 @@ namespace Meteor.Map.actors.chara
list.Add(id, new ModifierListEntry(id, val));
}
public Int64 GetModifier(uint id, bool isMobMod)
public long GetModifier(uint id, bool isMobMod)
{
ModifierListEntry retVal;
var list = isMobMod ? mobModList : modList;

View file

@ -83,7 +83,7 @@ namespace Meteor.Map.Actors
public ModifierList genusMods;
public ModifierList spawnMods;
protected Dictionary<MobModifier, Int64> mobModifiers = new Dictionary<MobModifier, Int64>();
protected Dictionary<MobModifier, long> mobModifiers = new Dictionary<MobModifier, long>();
public BattleNpc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot,
ushort actorState, uint animationId, string customDisplayName)
@ -320,7 +320,7 @@ namespace Meteor.Map.Actors
}
else
{
var err = String.Format("[{0}][{1}] {2} {3} {4} {5} tried to die ded", actorId, GetUniqueId(), positionX, positionY, positionZ, GetZone().GetName());
var err = string.Format("[{0}][{1}] {2} {3} {4} {5} tried to die ded", actorId, GetUniqueId(), positionX, positionY, positionZ, GetZone().GetName());
Program.Log.Error(err);
//throw new Exception(err);
}
@ -434,20 +434,20 @@ namespace Meteor.Map.Actors
this.bnpcId = id;
}
public Int64 GetMobMod(MobModifier mobMod)
public long GetMobMod(MobModifier mobMod)
{
return GetMobMod((uint)mobMod);
}
public Int64 GetMobMod(uint mobModId)
public long GetMobMod(uint mobModId)
{
Int64 res;
long res;
if (mobModifiers.TryGetValue((MobModifier)mobModId, out res))
return res;
return 0;
}
public void SetMobMod(uint mobModId, Int64 val)
public void SetMobMod(uint mobModId, long val)
{
if (mobModifiers.ContainsKey((MobModifier)mobModId))
mobModifiers[(MobModifier)mobModId] = val;

View file

@ -81,7 +81,7 @@ namespace Meteor.Map.Actors
LoadNpcAppearance(actorClass.actorClassId);
className = actorClass.classPath.Substring(actorClass.classPath.LastIndexOf("/") + 1);
this.classPath = String.Format("{0}/{1}", actorClass.classPath.Substring(0, actorClass.classPath.LastIndexOf('/')).ToLower(), className);
this.classPath = string.Format("{0}/{1}", actorClass.classPath.Substring(0, actorClass.classPath.LastIndexOf('/')).ToLower(), className);
charaWork.battleSave.potencial = 1.0f;
@ -109,8 +109,8 @@ namespace Meteor.Map.Actors
isMapObj = false;
else
{
layout = (uint)(Int32)lParams[4].value;
instance = (uint)(Int32)lParams[5].value;
layout = (uint)(int)lParams[4].value;
instance = (uint)(int)lParams[5].value;
isStatic = true;
}
}
@ -236,7 +236,7 @@ namespace Meteor.Map.Actors
for (int i = 0; i < charaWork.property.Length; i++)
{
if (charaWork.property[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.property[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.property[{0}]", i));
}
//Parameters
@ -261,14 +261,14 @@ namespace Meteor.Map.Actors
for (int i = 0; i < charaWork.statusShownTime.Length; i++)
{
if (charaWork.statusShownTime[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.statusShownTime[{0}]", i));
}
//General Parameters
for (int i = 3; i < charaWork.battleTemp.generalParameter.Length; i++)
{
if (charaWork.battleTemp.generalParameter[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.generalParameter[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.battleTemp.generalParameter[{0}]", i));
}
propPacketUtil.AddProperty("npcWork.hateType");
@ -302,7 +302,7 @@ namespace Meteor.Map.Actors
public void LoadNpcAppearance(uint id)
{
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
using (MySqlConnection conn = new MySqlConnection(string.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{

View file

@ -39,7 +39,7 @@ namespace Meteor.Map.actors.chara.npc
{
this.retainerId = retainerId;
this.ownerPlayer = player;
this.actorName = String.Format("_rtnre{0:x7}", actorId);
this.actorName = string.Format("_rtnre{0:x7}", actorId);
itemPackages[ItemPackage.NORMAL] = new ItemPackage(this, MAXSIZE_INVENTORY_NORMAL, ItemPackage.NORMAL);
itemPackages[ItemPackage.CURRENCY_CRYSTALS] = new ItemPackage(this, MAXSIZE_INVENTORY_CURRANCY, ItemPackage.CURRENCY_CRYSTALS);

View file

@ -46,6 +46,7 @@ using Meteor.Map.packets.send.actor.battle;
using Meteor.Map.packets.receive.events;
using static Meteor.Map.LuaUtils;
using Meteor.Map.packets.send.actor.events;
using Meteor.Map.DataObjects;
namespace Meteor.Map.Actors
{
@ -146,7 +147,7 @@ namespace Meteor.Map.Actors
//Quest Actors (MUST MATCH playerWork.questScenario/questGuildleve)
public Quest[] questScenario = new Quest[16];
public uint[] questGuildleve = new uint[8];
public Quest[] questGuildleve = new Quest[8];
//Aetheryte
public uint homepoint = 0;
@ -161,6 +162,10 @@ namespace Meteor.Map.Actors
public Retainer currentSpawnedRetainer = null;
public bool sentRetainerSpawn = false;
//Crafting
public List<Recipe> recentRecipes = new List<Recipe>();
public List<Recipe> awardedRecipes = new List<Recipe>();
private List<Director> ownedDirectors = new List<Director>();
private Director loginInitDirector = null;
@ -173,7 +178,7 @@ namespace Meteor.Map.Actors
public Player(Session cp, uint actorID) : base(actorID)
{
playerSession = cp;
actorName = String.Format("_pc{0:00000000}", actorID);
actorName = string.Format("_pc{0:00000000}", actorID);
className = "Player";
moveSpeeds[0] = SetActorSpeedPacket.DEFAULT_STOP;
@ -274,6 +279,17 @@ namespace Meteor.Map.Actors
this.aiContainer = new AIContainer(this, new PlayerController(this), null, new TargetFind(this));
allegiance = CharacterTargetingAllegiance.Player;
CalculateBaseStats();
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(36));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(37));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(38));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(39));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(40));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(41));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(42));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(43));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(2));
AddRecentRecipe(Server.ResolveRecipe().GetRecipeByID(3));
}
public List<SubPacket> Create0x132Packets()
@ -402,7 +418,7 @@ namespace Meteor.Map.Actors
for (int i = 0; i < charaWork.property.Length; i++)
{
if (charaWork.property[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.property[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.property[{0}]", i));
}
//Parameters
@ -418,21 +434,21 @@ namespace Meteor.Map.Actors
for (int i = 0; i < charaWork.statusShownTime.Length; i++)
{
if (charaWork.statusShownTime[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.statusShownTime[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.statusShownTime[{0}]", i));
}
//General Parameters
for (int i = 3; i < charaWork.battleTemp.generalParameter.Length; i++)
{
if (charaWork.battleTemp.generalParameter[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.generalParameter[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.battleTemp.generalParameter[{0}]", i));
}
propPacketUtil.AddProperty("charaWork.battleTemp.castGauge_speed[0]");
propPacketUtil.AddProperty("charaWork.battleTemp.castGauge_speed[1]");
//Battle Save Skillpoint
propPacketUtil.AddProperty(String.Format("charaWork.battleSave.skillPoint[{0}]", charaWork.parameterSave.state_mainSkill[0] - 1));
propPacketUtil.AddProperty(string.Format("charaWork.battleSave.skillPoint[{0}]", charaWork.parameterSave.state_mainSkill[0] - 1));
//Commands
propPacketUtil.AddProperty("charaWork.commandBorder");
@ -443,12 +459,12 @@ namespace Meteor.Map.Actors
{
if (charaWork.command[i] != 0)
{
propPacketUtil.AddProperty(String.Format("charaWork.command[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.command[{0}]", i));
//Recast Timers
if (i >= charaWork.commandBorder)
{
propPacketUtil.AddProperty(String.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", i - charaWork.commandBorder));
propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i - charaWork.commandBorder));
propPacketUtil.AddProperty(string.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", i - charaWork.commandBorder));
propPacketUtil.AddProperty(string.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i - charaWork.commandBorder));
}
}
}
@ -457,32 +473,32 @@ namespace Meteor.Map.Actors
{
charaWork.commandCategory[i] = 1;
if (charaWork.commandCategory[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.commandCategory[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.commandCategory[{0}]", i));
}
for (int i = 0; i < charaWork.commandAcquired.Length; i++)
{
if (charaWork.commandAcquired[i] != false)
propPacketUtil.AddProperty(String.Format("charaWork.commandAcquired[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.commandAcquired[{0}]", i));
}
for (int i = 0; i < charaWork.additionalCommandAcquired.Length; i++)
{
if (charaWork.additionalCommandAcquired[i] != false)
propPacketUtil.AddProperty(String.Format("charaWork.additionalCommandAcquired[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.additionalCommandAcquired[{0}]", i));
}
for (int i = 0; i < charaWork.parameterSave.commandSlot_compatibility.Length; i++)
{
charaWork.parameterSave.commandSlot_compatibility[i] = true;
if (charaWork.parameterSave.commandSlot_compatibility[i])
propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", i));
}
for (int i = 0; i < charaWork.parameterSave.commandSlot_recastTime.Length; i++)
{
if (charaWork.parameterSave.commandSlot_recastTime[i] != 0)
propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", i));
}
//System
@ -505,25 +521,25 @@ namespace Meteor.Map.Actors
for (int i = 0; i < playerWork.questScenario.Length; i++)
{
if (playerWork.questScenario[i] != 0)
propPacketUtil.AddProperty(String.Format("playerWork.questScenario[{0}]", i));
propPacketUtil.AddProperty(string.Format("playerWork.questScenario[{0}]", i));
}
//Guildleve - Local
for (int i = 0; i < playerWork.questGuildleve.Length; i++)
{
if (playerWork.questGuildleve[i] != 0)
propPacketUtil.AddProperty(String.Format("playerWork.questGuildleve[{0}]", i));
propPacketUtil.AddProperty(string.Format("playerWork.questGuildleve[{0}]", i));
}
//Guildleve - Regional
for (int i = 0; i < work.guildleveId.Length; i++)
{
if (work.guildleveId[i] != 0)
propPacketUtil.AddProperty(String.Format("work.guildleveId[{0}]", i));
propPacketUtil.AddProperty(string.Format("work.guildleveId[{0}]", i));
if (work.guildleveDone[i] != false)
propPacketUtil.AddProperty(String.Format("work.guildleveDone[{0}]", i));
propPacketUtil.AddProperty(string.Format("work.guildleveDone[{0}]", i));
if (work.guildleveChecked[i] != false)
propPacketUtil.AddProperty(String.Format("work.guildleveChecked[{0}]", i));
propPacketUtil.AddProperty(string.Format("work.guildleveChecked[{0}]", i));
}
//Bazaar
@ -541,9 +557,9 @@ namespace Meteor.Map.Actors
for (int i = 0; i < playerWork.npcLinkshellChatCalling.Length; i++)
{
if (playerWork.npcLinkshellChatCalling[i] != false)
propPacketUtil.AddProperty(String.Format("playerWork.npcLinkshellChatCalling[{0}]", i));
propPacketUtil.AddProperty(string.Format("playerWork.npcLinkshellChatCalling[{0}]", i));
if (playerWork.npcLinkshellChatExtra[i] != false)
propPacketUtil.AddProperty(String.Format("playerWork.npcLinkshellChatExtra[{0}]", i));
propPacketUtil.AddProperty(string.Format("playerWork.npcLinkshellChatExtra[{0}]", i));
}
propPacketUtil.AddProperty("playerWork.restBonusExpRate");
@ -560,7 +576,7 @@ namespace Meteor.Map.Actors
public void SendSeamlessZoneInPackets()
{
QueuePacket(SetMusicPacket.BuildPacket(actorId, zone.bgmDay, SetMusicPacket.EFFECT_FADEIN));
QueuePacket(SetMusicPacket.BuildPacket(actorId, zone.GetCurrentMusic(), SetMusicPacket.EFFECT_FADEIN));
QueuePacket(SetWeatherPacket.BuildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1));
}
@ -583,7 +599,7 @@ namespace Meteor.Map.Actors
}
}
else
QueuePacket(SetMusicPacket.BuildPacket(actorId, zone.bgmDay, 0x01)); //Zone
QueuePacket(SetMusicPacket.BuildPacket(actorId, zone.GetCurrentMusic(), 0x01)); //Zone
QueuePacket(SetWeatherPacket.BuildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1));
@ -806,11 +822,6 @@ namespace Meteor.Map.Actors
Database.SavePlayerStatusEffects(this);
}
public Area GetZone()
{
return zone;
}
public void SendMessage(uint logType, string sender, string message)
{
QueuePacket(SendMessagePacket.BuildPacket(actorId, logType, sender, message));
@ -895,6 +906,12 @@ namespace Meteor.Map.Actors
QueuePacket(SetMusicPacket.BuildPacket(actorId, musicId, 1));
}
public void ResetMusic()
{
if (zone != null)
QueuePacket(SetMusicPacket.BuildPacket(actorId, zone.GetCurrentMusic(), 1));
}
public void SendMountAppearance()
{
if (mountState == 1)
@ -1193,7 +1210,7 @@ namespace Meteor.Map.Actors
propertyBuilder.NewTarget("playerWork/expBonus");
propertyBuilder.AddProperty("playerWork.restBonusExpRate");
propertyBuilder.NewTarget("charaWork/battleStateForSelf");
propertyBuilder.AddProperty(String.Format("charaWork.battleSave.skillPoint[{0}]", classId - 1));
propertyBuilder.AddProperty(string.Format("charaWork.battleSave.skillPoint[{0}]", classId - 1));
Database.LoadHotbar(this);
var time = Utils.UnixTimeStampUTC();
@ -1221,7 +1238,7 @@ namespace Meteor.Map.Actors
Database.PlayerCharacterUpdateClassLevel(this, classId, level);
charaWork.battleSave.skillLevel[classId - 1] = level;
ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("charaWork/stateForAll", this);
propertyBuilder.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId-1));
propertyBuilder.AddProperty(string.Format("charaWork.battleSave.skillLevel[{0}]", classId-1));
List<SubPacket> packets = propertyBuilder.Done();
QueuePackets(packets);
}
@ -1363,6 +1380,16 @@ namespace Meteor.Map.Actors
return -1;
}
public int GetFreeQuestGuildleveSlot()
{
for (int i = 0; i < questGuildleve.Length; i++)
{
if (questGuildleve[i] == null)
return i;
}
return -1;
}
public int GetFreeGuildleveSlot()
{
@ -1447,37 +1474,61 @@ namespace Meteor.Map.Actors
}
}
}
public void AddQuest(string name, bool isSilent = false)
{
Actor actor = Server.GetStaticActors(name);
AddQuestInternal(actor as Quest, isSilent);
}
public void AddQuest(uint id, bool isSilent = false)
{
Actor actor = Server.GetStaticActors((0xA0F00000 | id));
AddQuest(actor.actorName, isSilent);
AddQuestInternal(actor as Quest, isSilent);
}
public void AddQuest(string name, bool isSilent = false)
public void AddQuestGuildleve(uint id, byte difficulty)
{
Actor actor = Server.GetStaticActors(name);
if (actor == null)
Quest staticQuest = (Quest) Server.GetStaticActors((0xA0F00000 | id));
if (staticQuest == null)
return;
uint id = actor.actorId;
PassiveGuildleve newQuest = new PassiveGuildleve(staticQuest, this, difficulty);
int freeSlot = GetFreeQuestGuildleveSlot();
if (freeSlot == -1)
return;
playerWork.questGuildleve[freeSlot] = newQuest.actorId;
questGuildleve[freeSlot] = newQuest;
Database.SaveQuest(this, newQuest);
SendQuestGuildleveClientUpdate(freeSlot);
}
private void AddQuestInternal(Quest staticQuest, bool isSilent = false)
{
if (staticQuest == null)
return;
Scenario newQuest = new Scenario(staticQuest, this, null, 0, 0);
int freeSlot = GetFreeQuestSlot();
if (freeSlot == -1)
return;
playerWork.questScenario[freeSlot] = id;
questScenario[freeSlot] = new Quest(this, playerWork.questScenario[freeSlot], name, null, 0, 0);
Database.SaveQuest(this, questScenario[freeSlot]);
playerWork.questScenario[freeSlot] = newQuest.actorId;
questScenario[freeSlot] = newQuest;
Database.SaveQuest(this, newQuest);
SendQuestClientUpdate(freeSlot);
if (!isSilent)
{
SendGameMessage(Server.GetWorldManager().GetActor(), 25224, 0x20, (object)questScenario[freeSlot].GetQuestId());
questScenario[freeSlot].NextPhase(0);
}
(questScenario[freeSlot] as Scenario).NextPhase(0);
}
}
public void CompleteQuest(uint id)
@ -1541,9 +1592,9 @@ namespace Meteor.Map.Actors
{
if (questScenario[i] != null && questScenario[i].GetQuestId() == oldId)
{
Actor actor = Server.GetStaticActors((0xA0F00000 | newId));
Quest quest = Server.GetStaticActors((0xA0F00000 | newId)) as Quest;
playerWork.questScenario[i] = (0xA0F00000 | newId);
questScenario[i] = new Quest(this, playerWork.questScenario[i], actor.actorName, null, 0, 0);
questScenario[i] = new Scenario(quest, this, null, 0, 0);
Database.SaveQuest(this, questScenario[i]);
SendQuestClientUpdate(i);
break;
@ -1598,6 +1649,16 @@ namespace Meteor.Map.Actors
return null;
}
public Quest GetQuestGuildleve(uint id)
{
for (int i = 0; i < questGuildleve.Length; i++)
{
if (questGuildleve[i] != null && questGuildleve[i].actorId == (0xA0F00000 | id))
return questGuildleve[i];
}
return null;
}
public bool HasQuest(string name)
{
@ -1621,6 +1682,17 @@ namespace Meteor.Map.Actors
return false;
}
public bool HasQuestGuildleve(uint id)
{
for (int i = 0; i < questGuildleve.Length; i++)
{
if (questGuildleve[i] != null && questGuildleve[i].actorId == (0xA0F00000 | id))
return true;
}
return false;
}
public bool HasGuildleve(uint id)
{
for (int i = 0; i < work.guildleveId.Length; i++)
@ -1643,6 +1715,17 @@ namespace Meteor.Map.Actors
return -1;
}
public int GetQuestGuildleveSlot(uint id)
{
for (int i = 0; i < questGuildleve.Length; i++)
{
if (questGuildleve[i] != null && questGuildleve[i].actorId == (0xA0F00000 | id))
return i;
}
return -1;
}
public void SetNpcLS(uint npcLSId, uint state)
{
bool isCalling, isExtra;
@ -1679,30 +1762,36 @@ namespace Meteor.Map.Actors
Database.SaveNpcLS(this, npcLSId, isCalling, isExtra);
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("playerWork/npcLinkshellChat", this);
propPacketUtil.AddProperty(String.Format("playerWork.npcLinkshellChatExtra[{0}]", npcLSId));
propPacketUtil.AddProperty(String.Format("playerWork.npcLinkshellChatCalling[{0}]", npcLSId));
propPacketUtil.AddProperty(string.Format("playerWork.npcLinkshellChatExtra[{0}]", npcLSId));
propPacketUtil.AddProperty(string.Format("playerWork.npcLinkshellChatCalling[{0}]", npcLSId));
QueuePackets(propPacketUtil.Done());
}
private void SendQuestClientUpdate(int slot)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("playerWork/journal", this);
propPacketUtil.AddProperty(String.Format("playerWork.questScenario[{0}]", slot));
propPacketUtil.AddProperty(string.Format("playerWork.questScenario[{0}]", slot));
QueuePackets(propPacketUtil.Done());
}
private void SendQuestGuildleveClientUpdate(int slot)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("playerWork/journal", this);
propPacketUtil.AddProperty(string.Format("playerWork.questGuildleve[{0}]", slot));
QueuePackets(propPacketUtil.Done());
}
private void SendGuildleveClientUpdate(int slot)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("work/guildleve", this);
propPacketUtil.AddProperty(String.Format("work.guildleveId[{0}]", slot));
propPacketUtil.AddProperty(string.Format("work.guildleveId[{0}]", slot));
QueuePackets(propPacketUtil.Done());
}
private void SendGuildleveMarkClientUpdate(int slot)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("work/guildleve", this);
propPacketUtil.AddProperty(String.Format("work.guildleveDone[{0}]", slot));
propPacketUtil.AddProperty(String.Format("work.guildleveChecked[{0}]", slot));
propPacketUtil.AddProperty(string.Format("work.guildleveDone[{0}]", slot));
propPacketUtil.AddProperty(string.Format("work.guildleveChecked[{0}]", slot));
QueuePackets(propPacketUtil.Done());
}
@ -2034,10 +2123,35 @@ namespace Meteor.Map.Actors
retainerMeetingGroup = null;
}
}
public override void Update(DateTime tick)
public void AddRecentRecipe(Recipe recipe)
{
recentRecipes.Remove(recipe);
if (recentRecipes.Count > 8)
recentRecipes.RemoveAt(7);
recentRecipes.Add(recipe);
}
public List<Recipe> GetRecentRecipes()
{
return recentRecipes;
}
public void AddAwardedRecipe(Recipe recipe)
{
awardedRecipes.Remove(recipe);
if (awardedRecipes.Count > 8)
awardedRecipes.RemoveAt(7);
awardedRecipes.Add(recipe);
}
public List<Recipe> GetAwardedRecipes()
{
return awardedRecipes;
}
public override void Update(DateTime tick)
{
// Chocobo Rental Expirey
if (rentalExpireTime != 0)
{
@ -2048,7 +2162,7 @@ namespace Meteor.Map.Actors
{
rentalExpireTime = 0;
rentalMinLeft = 0;
ChangeMusic(GetZone().bgmDay);
ResetMusic();
SetMountState(0);
ChangeSpeed(0.0f, 2.0f, 5.0f, 5.0f);
ChangeState(0);
@ -2102,7 +2216,7 @@ namespace Meteor.Map.Actors
if (GetMod(i) != charaWork.battleTemp.generalParameter[i])
{
charaWork.battleTemp.generalParameter[i] = (short)GetMod(i);
propPacketUtil.AddProperty(String.Format("charaWork.battleTemp.generalParameter[{0}]", i));
propPacketUtil.AddProperty(string.Format("charaWork.battleTemp.generalParameter[{0}]", i));
}
}
@ -2149,8 +2263,8 @@ namespace Meteor.Map.Actors
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/command", this);
foreach (ushort slot in slotsToUpdate)
{
propPacketUtil.AddProperty(String.Format("charaWork.command[{0}]", slot));
propPacketUtil.AddProperty(String.Format("charaWork.commandCategory[{0}]", slot));
propPacketUtil.AddProperty(string.Format("charaWork.command[{0}]", slot));
propPacketUtil.AddProperty(string.Format("charaWork.commandCategory[{0}]", slot));
}
propPacketUtil.NewTarget("charaWork/commandDetailForSelf");
@ -2158,7 +2272,7 @@ namespace Meteor.Map.Actors
foreach (ushort slot in slotsToUpdate)
{
charaWork.parameterSave.commandSlot_compatibility[slot - charaWork.commandBorder] = charaWork.command[slot] != 0;
propPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", slot - charaWork.commandBorder));
propPacketUtil.AddProperty(string.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", slot - charaWork.commandBorder));
}
QueuePackets(propPacketUtil.Done());
@ -2172,8 +2286,8 @@ namespace Meteor.Map.Actors
foreach (ushort slot in slotsToUpdate)
{
recastPacketUtil.AddProperty(String.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", slot - charaWork.commandBorder));
recastPacketUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", slot - charaWork.commandBorder));
recastPacketUtil.AddProperty(string.Format("charaWork.parameterTemp.maxCommandRecastTime[{0}]", slot - charaWork.commandBorder));
recastPacketUtil.AddProperty(string.Format("charaWork.parameterSave.commandSlot_recastTime[{0}]", slot - charaWork.commandBorder));
}
QueuePackets(recastPacketUtil.Done());
@ -2595,7 +2709,7 @@ namespace Meteor.Map.Actors
charaWork.battleSave.skillPoint[classId - 1] = 0;
//send new level
ActorPropertyPacketUtil levelPropertyPacket = new ActorPropertyPacketUtil("charaWork/stateForAll", this);
levelPropertyPacket.AddProperty(String.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1));
levelPropertyPacket.AddProperty(string.Format("charaWork.battleSave.skillLevel[{0}]", classId - 1));
levelPropertyPacket.AddProperty("charaWork.parameterSave.state_mainSkillLevel");
QueuePackets(levelPropertyPacket.Done());
@ -2606,7 +2720,7 @@ namespace Meteor.Map.Actors
charaWork.battleSave.skillPoint[classId - 1] = Math.Min(charaWork.battleSave.skillPoint[classId - 1] + exp, MAXEXP[GetLevel() - 1]);
ActorPropertyPacketUtil expPropertyPacket = new ActorPropertyPacketUtil("charaWork/battleStateForSelf", this);
expPropertyPacket.AddProperty(String.Format("charaWork.battleSave.skillPoint[{0}]", classId - 1));
expPropertyPacket.AddProperty(string.Format("charaWork.battleSave.skillPoint[{0}]", classId - 1));
QueuePackets(expPropertyPacket.Done());
Database.SetExp(this, classId, charaWork.battleSave.skillPoint[classId - 1]);

View file

@ -239,7 +239,7 @@ namespace Meteor.Map.actors.director
//Format Class Name
string className = this.className;
className = Char.ToLowerInvariant(className[0]) + className.Substring(1);
className = char.ToLowerInvariant(className[0]) + className.Substring(1);
//Format Zone Name
string zoneName = zone.zoneName.Replace("Field", "Fld")
@ -255,7 +255,7 @@ namespace Meteor.Map.actors.director
//Check if "normal"
zoneName = zoneName.Remove(zoneName.Length - 1, 1) + "P";
}
zoneName = Char.ToLowerInvariant(zoneName[0]) + zoneName.Substring(1);
zoneName = char.ToLowerInvariant(zoneName[0]) + zoneName.Substring(1);
try
{
@ -273,7 +273,7 @@ namespace Meteor.Map.actors.director
if (zone is PrivateArea)
privLevel = ((PrivateArea)zone).GetPrivateAreaType();
actorName = String.Format("{0}_{1}_{2}@{3:X3}{4:X2}", className, zoneName, classNumber, zoneId, privLevel);
actorName = string.Format("{0}_{1}_{2}@{3:X3}{4:X2}", className, zoneName, classNumber, zoneId, privLevel);
}
public string GetScriptPath()
@ -283,7 +283,7 @@ namespace Meteor.Map.actors.director
private void LoadLuaScript()
{
string luaPath = String.Format(LuaEngine.FILEPATH_DIRECTORS, GetScriptPath());
string luaPath = string.Format(LuaEngine.FILEPATH_DIRECTORS, GetScriptPath());
directorScript = LuaEngine.LoadScript(luaPath);
if (directorScript == null)
Program.Log.Error("Could not find script for director {0}.", GetName());
@ -293,7 +293,7 @@ namespace Meteor.Map.actors.director
{
if (directorScript != null)
{
directorScript = LuaEngine.LoadScript(String.Format(LuaEngine.FILEPATH_DIRECTORS, directorScriptPath));
directorScript = LuaEngine.LoadScript(string.Format(LuaEngine.FILEPATH_DIRECTORS, directorScriptPath));
if (!directorScript.Globals.Get(funcName).IsNil())
{
DynValue result = directorScript.Call(directorScript.Globals[funcName], args);

View file

@ -137,7 +137,7 @@ namespace Meteor.Map.actors.director
if (wasCompleted)
{
Npc aetheryteNode = zone.SpawnActor(1200040, String.Format("{0}:warpExit", guildleveOwner.actorName), guildleveOwner.positionX, guildleveOwner.positionY, guildleveOwner.positionZ);
Npc aetheryteNode = zone.SpawnActor(1200040, string.Format("{0}:warpExit", guildleveOwner.actorName), guildleveOwner.positionX, guildleveOwner.positionY, guildleveOwner.positionZ);
AddMember(aetheryteNode);
foreach (Actor a in GetPlayerMembers())
@ -168,7 +168,7 @@ namespace Meteor.Map.actors.director
foreach (Actor p in GetPlayerMembers())
{
Player player = (Player)p;
player.ChangeMusic(player.GetZone().bgmDay);
player.ResetMusic();
}
}
@ -210,7 +210,7 @@ namespace Meteor.Map.actors.director
{
guildleveWork.aimNumNow[index] = value;
ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("guildleveWork/infoVariable", this);
propertyBuilder.AddProperty(String.Format("guildleveWork.aimNumNow[{0}]", index));
propertyBuilder.AddProperty(string.Format("guildleveWork.aimNumNow[{0}]", index));
SendPacketsToPlayers(propertyBuilder.Done());
}
@ -218,7 +218,7 @@ namespace Meteor.Map.actors.director
{
guildleveWork.uiState[index] = value;
ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("guildleveWork/infoVariable", this);
propertyBuilder.AddProperty(String.Format("guildleveWork.uiState[{0}]", index));
propertyBuilder.AddProperty(string.Format("guildleveWork.uiState[{0}]", index));
SendPacketsToPlayers(propertyBuilder.Done());
}
@ -228,9 +228,9 @@ namespace Meteor.Map.actors.director
guildleveWork.markerY[markerIndex] = y;
guildleveWork.markerZ[markerIndex] = z;
ActorPropertyPacketUtil propertyBuilder = new ActorPropertyPacketUtil("guildleveWork/marker", this);
propertyBuilder.AddProperty(String.Format("guildleveWork.markerX[{0}]", markerIndex));
propertyBuilder.AddProperty(String.Format("guildleveWork.markerY[{0}]", markerIndex));
propertyBuilder.AddProperty(String.Format("guildleveWork.markerZ[{0}]", markerIndex));
propertyBuilder.AddProperty(string.Format("guildleveWork.markerX[{0}]", markerIndex));
propertyBuilder.AddProperty(string.Format("guildleveWork.markerY[{0}]", markerIndex));
propertyBuilder.AddProperty(string.Format("guildleveWork.markerZ[{0}]", markerIndex));
SendPacketsToPlayers(propertyBuilder.Done());
}

View file

@ -0,0 +1,139 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using Meteor.Map.dataobjects;
using Meteor.Map.DataObjects;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Meteor.Map.Actors
{
class PassiveGuildleve : Quest
{
private Recipe targetRecipe;
private byte currentDifficulty;
private short numSuccesses;
private short currentAttempt;
private bool hasMaterials;
private PassiveGuildleveData passiveGLData;
public PassiveGuildleve(Quest staticQuest, Player owner, byte currentDifficulty)
: base(staticQuest, owner)
{
passiveGLData = Server.GetPassiveGLGamedata(GetQuestId());
targetRecipe = Server.ResolveRecipe().GetRecipeByItemID(passiveGLData.objectiveItemId[currentDifficulty]);
this.currentDifficulty = currentDifficulty;
currentAttempt = 0;
numSuccesses = 0;
hasMaterials = false;
}
public PassiveGuildleve(Quest staticQuest, Player owner, string questDataJson) : base(staticQuest, owner)
{
passiveGLData = Server.GetPassiveGLGamedata(GetQuestId());
Dictionary<string, object> questData = null;
if (questDataJson != null)
questData = JsonConvert.DeserializeObject<Dictionary<string, object>>(questDataJson);
if (questData == null)
questData = new Dictionary<string, object>();
currentDifficulty = questData.ContainsKey("currentDifficulty") ? (byte)questData["currentDifficulty"] : (byte)0;
currentAttempt = questData.ContainsKey("currentAttempt") ? (short)questData["currentAttempt"] : (short)0;
numSuccesses = questData.ContainsKey("numSuccesses") ? (short)questData["numSuccesses"] : (short)0;
hasMaterials = questData.ContainsKey("hasMaterials") ? (bool)questData["hasMaterials"] : false;
targetRecipe = Server.ResolveRecipe().GetRecipeByItemID(passiveGLData.objectiveItemId[currentDifficulty]);
}
public void CraftSuccess()
{
numSuccesses++;
currentAttempt++;
}
public void CraftFail()
{
currentAttempt++;
}
public Recipe GetRecipe()
{
return targetRecipe;
}
public int GetNumberOfSuccesses()
{
return numSuccesses;
}
public int GetRemainingMaterials()
{
return passiveGLData.numberOfAttempts[currentDifficulty] - currentAttempt;
}
public int GetCurrentAttempt()
{
return currentAttempt;
}
public int GetMaxAttempts()
{
return passiveGLData.numberOfAttempts[currentDifficulty];
}
public byte GetCurrentDifficulty()
{
return currentDifficulty;
}
public bool HasMaterials()
{
return hasMaterials;
}
public PassiveGuildleveData GetPassiveGLData()
{
return passiveGLData;
}
public override void SaveData()
{
Database.SaveQuest(owner, this);
}
public override string GetSerializedQuestData()
{
Dictionary<string, object> questData = new Dictionary<string, object>
{
{ "currentDifficulty", currentDifficulty },
{ "currentAttempt", currentAttempt },
{ "itemsCompleted", numSuccesses },
{ "hasMaterials", hasMaterials }
};
return JsonConvert.SerializeObject(questData, Formatting.Indented);
}
}
}

View file

@ -20,6 +20,7 @@ along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
*/
using Meteor.Map.lua;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -28,40 +29,18 @@ namespace Meteor.Map.Actors
{
class Quest : Actor
{
private Player owner;
private uint currentPhase = 0;
private uint questFlags = 0;
private Dictionary<string, Object> questData = new Dictionary<string, object>();
protected Player owner;
public Quest(uint actorID, string name)
: base(actorID)
{
actorName = name;
actorName = name;
}
public Quest(Player owner, uint actorID, string name, string questDataJson, uint questFlags, uint currentPhase)
: base(actorID)
public Quest(Quest staticQuest, Player owner) : base(staticQuest.actorId)
{
this.owner = owner;
actorName = name;
this.questFlags = questFlags;
if (questDataJson != null)
this.questData = JsonConvert.DeserializeObject<Dictionary<string, Object>>(questDataJson);
else
questData = null;
if (questData == null)
questData = new Dictionary<string, object>();
this.currentPhase = currentPhase;
}
public void SetQuestData(string dataName, object data)
{
questData[dataName] = data;
//Inform update
actorName = staticQuest.actorName;
}
public uint GetQuestId()
@ -69,81 +48,8 @@ namespace Meteor.Map.Actors
return actorId & 0xFFFFF;
}
public object GetQuestData(string dataName)
{
if (questData.ContainsKey(dataName))
return questData[dataName];
else
return null;
}
public void ClearQuestData()
{
questData.Clear();
}
public void ClearQuestFlags()
{
questFlags = 0;
}
public void SetQuestFlag(int bitIndex, bool value)
{
if (bitIndex >= 32)
{
Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId);
return;
}
int mask = 1 << bitIndex;
if (value)
questFlags |= (uint)(1 << bitIndex);
else
questFlags &= (uint)~(1 << bitIndex);
DoCompletionCheck();
}
public bool GetQuestFlag(int bitIndex)
{
if (bitIndex >= 32)
{
Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId);
return false;
}
else
return (questFlags & (1 << bitIndex)) == (1 << bitIndex);
}
public uint GetPhase()
{
return currentPhase;
}
public void NextPhase(uint phaseNumber)
{
currentPhase = phaseNumber;
owner.SendGameMessage(Server.GetWorldManager().GetActor(), 25116, 0x20, (object)GetQuestId());
SaveData();
DoCompletionCheck();
}
public uint GetQuestFlags()
{
return questFlags;
}
public string GetSerializedQuestData()
{
return JsonConvert.SerializeObject(questData, Formatting.Indented);
}
public void SaveData()
{
Database.SaveQuest(owner, this);
}
public virtual void SaveData() { }
public virtual string GetSerializedQuestData() { return null; }
public void DoCompletionCheck()
{
@ -161,5 +67,45 @@ namespace Meteor.Map.Actors
owner.SendGameMessage(owner, Server.GetWorldManager().GetActor(), 25236, 0x20, (object)GetQuestId());
}
public static Quest LoadQuestDB(Player player, MySqlDataReader reader)
{
uint questID = 0xA0F00000 | reader.GetUInt32("questId");
Quest staticQuest = Server.GetStaticActors(questID) as Quest;
string questData = null;
if (!reader.IsDBNull(reader.GetOrdinal("questData")))
questData = reader.GetString("questData");
else
questData = "{}";
if (staticQuest.IsScenario())
{
uint questFlags = 0;
uint currentPhase = 0;
if (!reader.IsDBNull(reader.GetOrdinal("questFlags")))
questFlags = reader.GetUInt32("questFlags");
if (!reader.IsDBNull(reader.GetOrdinal("currentPhase")))
currentPhase = reader.GetUInt32("currentPhase");
return new Scenario(staticQuest, player, questData, questFlags, currentPhase);
}
else if (staticQuest.IsCraftPassiveGuildleve())
{
return new PassiveGuildleve(staticQuest, player, questData);
}
throw new NotImplementedException("Unknown quest type added");
}
public bool IsScenario()
{
return !IsCraftPassiveGuildleve();
}
public bool IsCraftPassiveGuildleve()
{
return GetQuestId() > 120000 && GetQuestId() < 121024;
}
}
}

View file

@ -0,0 +1,140 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using Meteor.Map.lua;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace Meteor.Map.Actors
{
class Scenario : Quest
{
private uint currentPhase = 0;
private uint questFlags = 0;
private Dictionary<string, object> questData = new Dictionary<string, object>();
public Scenario(uint actorID, string name)
: base(actorID, name)
{
actorName = name;
}
public Scenario(Quest staticQuest, Player owner, string questDataJson, uint questFlags, uint currentPhase)
: base(staticQuest, owner)
{
this.questFlags = questFlags;
if (questDataJson != null)
this.questData = JsonConvert.DeserializeObject<Dictionary<string, object>>(questDataJson);
else
questData = null;
if (questData == null)
questData = new Dictionary<string, object>();
this.currentPhase = currentPhase;
}
public void SetQuestData(string dataName, object data)
{
questData[dataName] = data;
//Inform update
}
public object GetQuestData(string dataName)
{
if (questData.ContainsKey(dataName))
return questData[dataName];
else
return null;
}
public void ClearQuestData()
{
questData.Clear();
}
public void ClearQuestFlags()
{
questFlags = 0;
}
public void SetQuestFlag(int bitIndex, bool value)
{
if (bitIndex >= 32)
{
Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId);
return;
}
int mask = 1 << bitIndex;
if (value)
questFlags |= (uint)(1 << bitIndex);
else
questFlags &= (uint)~(1 << bitIndex);
DoCompletionCheck();
}
public bool GetQuestFlag(int bitIndex)
{
if (bitIndex >= 32)
{
Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId);
return false;
}
else
return (questFlags & (1 << bitIndex)) == (1 << bitIndex);
}
public uint GetPhase()
{
return currentPhase;
}
public void NextPhase(uint phaseNumber)
{
currentPhase = phaseNumber;
owner.SendGameMessage(Server.GetWorldManager().GetActor(), 25116, 0x20, (object)GetQuestId());
SaveData();
DoCompletionCheck();
}
public uint GetQuestFlags()
{
return questFlags;
}
public override string GetSerializedQuestData()
{
return JsonConvert.SerializeObject(questData, Formatting.Indented);
}
public override void SaveData()
{
Database.SaveQuest(owner, this);
}
}
}

View file

@ -59,8 +59,8 @@ namespace Meteor.Map.Actors
try
{
byte byteIn = binReader.ReadByte();
byte byteOut = (Byte)(byteIn ^ 0x73);
binWriter.Write((Byte)byteOut);
byte byteOut = (byte)(byteIn ^ 0x73);
binWriter.Write((byte)byteOut);
}
catch (EndOfStreamException) { break; }
}