opening quest stuff

This commit is contained in:
yogurt 2017-10-10 13:32:47 -05:00
parent 9fc99faa5c
commit 92de857cda
49 changed files with 873 additions and 88 deletions

View file

@ -817,27 +817,27 @@ namespace FFXIVClassic_Map_Server
{
if (reader.Read())
{
player.charaWork.battleSave.skillPoint[Player.CLASSID_PUG - 1] = reader.GetInt16("pug");
player.charaWork.battleSave.skillPoint[Player.CLASSID_GLA - 1] = reader.GetInt16("gla");
player.charaWork.battleSave.skillPoint[Player.CLASSID_MRD - 1] = reader.GetInt16("mrd");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ARC - 1] = reader.GetInt16("arc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_LNC - 1] = reader.GetInt16("lnc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_PUG - 1] = reader.GetInt32("pug");
player.charaWork.battleSave.skillPoint[Player.CLASSID_GLA - 1] = reader.GetInt32("gla");
player.charaWork.battleSave.skillPoint[Player.CLASSID_MRD - 1] = reader.GetInt32("mrd");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ARC - 1] = reader.GetInt32("arc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_LNC - 1] = reader.GetInt32("lnc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_THM - 1] = reader.GetInt16("thm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CNJ - 1] = reader.GetInt16("cnj");
player.charaWork.battleSave.skillPoint[Player.CLASSID_THM - 1] = reader.GetInt32("thm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CNJ - 1] = reader.GetInt32("cnj");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CRP - 1] = reader.GetInt16("crp");
player.charaWork.battleSave.skillPoint[Player.CLASSID_BSM - 1] = reader.GetInt16("bsm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ARM - 1] = reader.GetInt16("arm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_GSM - 1] = reader.GetInt16("gsm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_LTW - 1] = reader.GetInt16("ltw");
player.charaWork.battleSave.skillPoint[Player.CLASSID_WVR - 1] = reader.GetInt16("wvr");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ALC - 1] = reader.GetInt16("alc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CUL - 1] = reader.GetInt16("cul");
player.charaWork.battleSave.skillPoint[Player.CLASSID_MIN - 1] = reader.GetInt16("min");
player.charaWork.battleSave.skillPoint[Player.CLASSID_BTN - 1] = reader.GetInt16("btn");
player.charaWork.battleSave.skillPoint[Player.CLASSID_FSH - 1] = reader.GetInt16("fsh");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CRP - 1] = reader.GetInt32("crp");
player.charaWork.battleSave.skillPoint[Player.CLASSID_BSM - 1] = reader.GetInt32("bsm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ARM - 1] = reader.GetInt32("arm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_GSM - 1] = reader.GetInt32("gsm");
player.charaWork.battleSave.skillPoint[Player.CLASSID_LTW - 1] = reader.GetInt32("ltw");
player.charaWork.battleSave.skillPoint[Player.CLASSID_WVR - 1] = reader.GetInt32("wvr");
player.charaWork.battleSave.skillPoint[Player.CLASSID_ALC - 1] = reader.GetInt32("alc");
player.charaWork.battleSave.skillPoint[Player.CLASSID_CUL - 1] = reader.GetInt32("cul");
player.charaWork.battleSave.skillPoint[Player.CLASSID_MIN - 1] = reader.GetInt32("min");
player.charaWork.battleSave.skillPoint[Player.CLASSID_BTN - 1] = reader.GetInt32("btn");
player.charaWork.battleSave.skillPoint[Player.CLASSID_FSH - 1] = reader.GetInt32("fsh");
}
}

View file

@ -1291,7 +1291,9 @@ namespace FFXIVClassic_Map_Server
{
Program.Tick = DateTime.Now;
foreach (Zone zone in zoneList.Values)
{
zone.Update(Program.Tick);
}
Program.LastTick = Program.Tick;
}
}

View file

@ -438,6 +438,9 @@ namespace FFXIVClassic_Map_Server.Actors
updateFlags = ActorUpdateFlags.None;
zone.BroadcastPacketsAroundActor(this, packets);
SetActorPropetyPacket hpInfo = new SetActorPropetyPacket("charaWork/exp");
hpInfo.AddTarget();
}
}

View file

@ -489,13 +489,14 @@ namespace FFXIVClassic_Map_Server.Actors
zoneId = actorId;
Npc npc;
if (isMob)
npc = new BattleNpc(mActorList.Count + 1, actorClass, uniqueId, this, x, y, z, rot, state, animId, null);
else
npc = new Npc(mActorList.Count + 1, actorClass, uniqueId, this, x, y, z, rot, state, animId, null);
npc.LoadEventConditions(actorClass.eventConditions);
npc.SetMaxHP(300);
npc.SetHP(300);
AddActorToZone(npc);

View file

@ -152,6 +152,7 @@ namespace FFXIVClassic_Map_Server.actors.area
contentAreas.Add(areaName, new List<PrivateAreaContent>());
PrivateAreaContent contentArea = new PrivateAreaContent(this, classPath, areaName, 1, director, starterPlayer);
contentAreas[areaName].Add(contentArea);
return contentArea;
}
}
@ -167,6 +168,15 @@ namespace FFXIVClassic_Map_Server.actors.area
public override void Update(DateTime tick)
{
base.Update(tick);
foreach (var a in privateAreas.Values)
foreach(var b in a.Values)
b.Update(tick);
foreach (var a in contentAreas.Values)
foreach (var b in a)
{
b.Update(tick);
}
// todo: again, this is retarded but debug stuff
var diffTime = tick - lastUpdate;

View file

@ -401,6 +401,7 @@ namespace FFXIVClassic_Map_Server.Actors
aiContainer.Engage(zone.FindActorInArea<Character>(targid));
}
}
return false;
}
@ -470,7 +471,7 @@ namespace FFXIVClassic_Map_Server.Actors
public bool IsAlive()
{
return !aiContainer.IsDead() && GetHP() > 0;
return !aiContainer.IsDead();// && GetHP() > 0;
}
public short GetHP()
@ -511,7 +512,7 @@ namespace FFXIVClassic_Map_Server.Actors
public byte GetHPP()
{
return (byte)((charaWork.parameterSave.hp[0] / charaWork.parameterSave.hpMax[0]) * 100);
return (byte)(charaWork.parameterSave.hp[0] == 0 ? 0 : (charaWork.parameterSave.hp[0] / charaWork.parameterSave.hpMax[0]) * 100);
}
public void SetHP(uint hp)
@ -570,7 +571,11 @@ namespace FFXIVClassic_Map_Server.Actors
public void AddTP(int tp)
{
charaWork.parameterTemp.tp = (short)((charaWork.parameterTemp.tp + tp).Clamp(0, 3000));
tpBase = (ushort) charaWork.parameterTemp.tp;
updateFlags |= ActorUpdateFlags.HpTpMp;
if (tpBase >= 1000)
lua.LuaEngine.GetInstance().OnSignal("tpOver1000");
}
public void DelHP(int hp)
@ -638,6 +643,9 @@ namespace FFXIVClassic_Map_Server.Actors
target.DelHP(action.amount);
if (target is BattleNpc)
((BattleNpc)target).lastAttacker = this;
AddTP(115);
target.AddTP(100);
}
public virtual void OnCast(State state, BattleAction[] actions, ref BattleAction[] errors)

View file

@ -233,7 +233,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
if (mpCost != 0)
return (ushort)Math.Ceiling((cost * mpCost * 0.001));
return tpCost;
return mpCost != 0 ? (ushort)Math.Ceiling((cost * mpCost * 0.001)) : (ushort)0;
}
public List<Character> GetTargets()

View file

@ -194,7 +194,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
protected virtual void DoCombatTick(DateTime tick, List<Character> contentGroupCharas = null)
{
HandleHate();
// todo: magic/attack/ws cooldowns etc
if (TryDeaggro())
{

View file

@ -44,7 +44,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
var pos = new Vector3(owner.positionX, owner.positionY, owner.positionZ);
var dest = new Vector3(x, y, z);
var zone = (Zone)owner.GetZone();
Zone zone;
if (owner.GetZone() is PrivateArea || owner.GetZone() is PrivateAreaContent)
zone = (Zone)((PrivateArea)owner.GetZone()).GetParentZone();
else
zone = (Zone)owner.GetZone();
var sw = new System.Diagnostics.Stopwatch();
sw.Start();

View file

@ -106,7 +106,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
var errors = (BattleAction[])actions.Clone();
owner.OnWeaponSkill(this, actions, ref errors);
owner.DoBattleAction(skill.id, 0, actions);
owner.DoBattleAction(skill.id, skill.battleAnimation, actions);
}
public override void TryInterrupt()

View file

@ -298,7 +298,13 @@ namespace FFXIVClassic_Map_Server.Actors
// onDeath(monster, player, killer)
lua.LuaEngine.CallLuaBattleFunction(this, "onDeath", this, partyMember, lastAttacker);
// <actor> defeat/defeats <target>
((Player)lastAttacker).QueuePacket(BattleActionX01Packet.BuildPacket(lastAttacker.actorId, 0, 0, new BattleAction(actorId, 30108, 0)));
if (lastAttacker is Player)
((Player)lastAttacker).QueuePacket(BattleActionX01Packet.BuildPacket(lastAttacker.actorId, 0, 0, new BattleAction(actorId, 30108, 0)));
if(partyMember is Player)
((Player)partyMember).AddExp(1500, (byte)partyMember.GetJob(), 5);
}
}
else
@ -311,8 +317,10 @@ namespace FFXIVClassic_Map_Server.Actors
positionUpdates?.Clear();
aiContainer.InternalDie(tick, despawnTime);
this.ResetMoveSpeeds();
// todo: reset cooldowns
lua.LuaEngine.GetInstance().OnSignal("mobkill");
}
else
{

View file

@ -80,7 +80,7 @@ namespace FFXIVClassic_Map_Server.Actors
charaWork.parameterSave.hpMax[0] = 80;
}
for (int i = 0; i < 32; i++ )
charaWork.property[i] = (byte)(((int)actorClass.propertyFlags >> i) & 1);
charaWork.property[i] = (byte)(((int)actorClass.propertyFlags >> i) & 1);
npcWork.pushCommand = actorClass.pushCommand;
npcWork.pushCommandSub = actorClass.pushCommandSub;

View file

@ -234,7 +234,7 @@ namespace FFXIVClassic_Map_Server.Actors
charaWork.commandBorder = 0x20;
charaWork.parameterTemp.tp = 3000;
charaWork.parameterTemp.tp = 0;
Database.LoadPlayerCharacter(this);
lastPlayTimeUpdate = Utils.UnixTimeStampUTC();
@ -1777,9 +1777,13 @@ namespace FFXIVClassic_Map_Server.Actors
propPacketUtil.AddProperty($"charaWork.parameterSave.state_mainSkillLevel");
packets.AddRange(propPacketUtil.Done());
}
base.PostUpdate(tick, packets);
SetActorPropetyPacket hpInfo = new SetActorPropetyPacket("charaWork/exp");
hpInfo.AddTarget();
QueuePacket(hpInfo.BuildPacket(actorId));
}
public override void Die(DateTime tick)
@ -1813,19 +1817,20 @@ namespace FFXIVClassic_Map_Server.Actors
ActorPropertyPacketUtil compatibiltyUtil = new ActorPropertyPacketUtil("charaWork/commandDetailForSelf", this);
foreach (ushort slot in slotsToUpdate)
{
propPacketUtil.AddProperty(String.Format("charaWork.command[{0}]", slot));
propPacketUtil.AddProperty(String.Format("charaWork.commandCategory[{0}]", slot));
propPacketUtil.AddProperty($"charaWork.command[{slot}]");
propPacketUtil.AddProperty($"charaWork.commandCategory[{slot}]");
}
propPacketUtil.NewTarget("charaWork/commandDetailForSelf");
//Enable or disable slots based on whether there is an ability in that slot
foreach (ushort slot in slotsToUpdate)
{
charaWork.parameterSave.commandSlot_compatibility[slot - charaWork.commandBorder] = charaWork.command[slot] != 0;
compatibiltyUtil.AddProperty(String.Format("charaWork.parameterSave.commandSlot_compatibility[{0}]", slot - charaWork.commandBorder));
propPacketUtil.AddProperty($"charaWork.parameterSave.commandSlot_compatibility[{slot - charaWork.commandBorder}]");
}
QueuePackets(propPacketUtil.Done());
QueuePackets(compatibiltyUtil.Done());
//QueuePackets(compatibiltyUtil.Done());
}
//Update recast timers for the passed in hotbar slots
@ -1874,6 +1879,7 @@ namespace FFXIVClassic_Map_Server.Actors
uint recastEnd = Utils.UnixTimeStampUTC() + maxRecastTime;
List<ushort> slotsToUpdate = new List<ushort>();
Database.EquipAbility(this, classId, (ushort) (hotbarSlot - charaWork.commandBorder), commandId, recastEnd);
//If the class we're equipping for is the current class (need to find out if state_mainSkill is supposed to change when you're a job)
//then equip the ability in charawork.commands and save in databse, otherwise just save in database
if (classId == charaWork.parameterSave.state_mainSkill[0])
@ -1887,7 +1893,6 @@ namespace FFXIVClassic_Map_Server.Actors
UpdateHotbar(slotsToUpdate);
}
Database.EquipAbility(this, classId, (ushort) (hotbarSlot - charaWork.commandBorder), commandId, recastEnd);
if(printMessage)
SendGameMessage(Server.GetWorldManager().GetActor(), 30603, 0x20, 0, commandId);
@ -2184,6 +2189,8 @@ namespace FFXIVClassic_Map_Server.Actors
{
((BattleNpc)target).hateContainer.UpdateHate(this, action.amount);
}
LuaEngine.GetInstance().OnSignal("playerAttack");
}
public override void OnCast(State state, BattleAction[] actions, ref BattleAction[] errors)
@ -2213,7 +2220,6 @@ namespace FFXIVClassic_Map_Server.Actors
exp += (int) Math.Ceiling((exp * bonusPercent / 100.0f));
//You earn [exp](+[bonusPercent]%) experience point(s).
SendGameMessage(this, Server.GetWorldManager().GetActor(), 33934, 0x44, this, 0, 0, 0, 0, 0, 0, 0, 0, 0, exp, "", bonusPercent);
bool leveled = false;
int diff = MAXEXP[GetLevel() - 1] - charaWork.battleSave.skillPoint[classId - 1];
//While there is enough experience to level up, keep leveling up, unlocking skills and removing experience from exp until we don't have enough to level up
@ -2314,5 +2320,21 @@ namespace FFXIVClassic_Map_Server.Actors
return charaWork.parameterSave.state_mainSkill[0];
}
public void hpstuff(uint hp)
{
SetMaxHP(hp);
SetHP(hp);
mpMaxBase = (ushort)hp;
charaWork.parameterSave.mpMax = (short)hp;
charaWork.parameterSave.mp = (short)hp;
AddTP(0);
//SendCharaExpInfo();
//ActorPropertyPacketUtil exp = new ActorPropertyPacketUtil("charaWork/exp", this);
SetActorPropetyPacket hpInfo = new SetActorPropetyPacket("charaWork/exp");
hpInfo.AddTarget();
QueuePacket(hpInfo.BuildPacket(actorId));
}
}
}

View file

@ -103,7 +103,7 @@ namespace FFXIVClassic_Map_Server.actors.director
List<LuaParam> lparams = CallLuaScript("init", args2);
if (lparams.Count >= 1 && lparams[0].value is string)
if (lparams != null && lparams.Count >= 1 && lparams[0].value is string)
{
classPath = (string)lparams[0].value;
className = classPath.Substring(classPath.LastIndexOf("/") + 1);
@ -270,6 +270,7 @@ namespace FFXIVClassic_Map_Server.actors.director
{
if (directorScript != null)
{
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

@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.actors.group
{
if (actor == null)
return;
members.Add(actor.actorId);
if (actor is Character)

View file

@ -93,7 +93,7 @@ namespace FFXIVClassic_Map_Server.Actors
return false;
}
else
return (questFlags & (1 << bitIndex)) == (1 << bitIndex);
return (questFlags & (1 << bitIndex)) == (1 << bitIndex);
}
public uint GetPhase()

View file

@ -224,7 +224,7 @@ namespace FFXIVClassic_Map_Server.lua
Program.Log.Error($"LuaEngine.CallLuaBattleCommandFunction [{functionName}] {e.Message}");
}
DynValue res = new DynValue();
if (!script.Globals.Get(functionName).IsNil())
{
res = script.Call(script.Globals.Get(functionName), args);
@ -234,7 +234,27 @@ namespace FFXIVClassic_Map_Server.lua
}
else
{
Program.Log.Error($"LuaEngine.CallLuaBattleCommandFunction [{command.name}] Unable to find script {path}");
path = $"./scripts/commands/{folder}/default.lua";
//Program.Log.Error($"LuaEngine.CallLuaBattleCommandFunction [{command.name}] Unable to find script {path}");
var script = LoadGlobals();
try
{
script.DoFile(path);
}
catch (Exception e)
{
Program.Log.Error($"LuaEngine.CallLuaBattleCommandFunction [{functionName}] {e.Message}");
}
DynValue res = new DynValue();
DynValue r = script.Globals.Get(functionName);
if (!script.Globals.Get(functionName).IsNil())
{
res = script.Call(script.Globals.Get(functionName), args);
if (res != null)
return (int)res.Number;
}
}
return -1;
}
@ -461,6 +481,7 @@ namespace FFXIVClassic_Map_Server.lua
Coroutine coroutine = script.CreateCoroutine(script.Globals[funcName]).Coroutine;
DynValue value = coroutine.Resume(args2);
ResolveResume(player, coroutine, value);
}
else
{

View file

@ -25,6 +25,7 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.battle
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)sourceActorId);
binWriter.Write((UInt32)animationId);
//Missing... last value is float, string in here as well?