mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-20 11:47:48 +00:00
stubbed some more functions from kj's ai stuff
- fixed some typos - cleaned some debug code
This commit is contained in:
parent
6b023ceb3c
commit
62055eff04
13 changed files with 97 additions and 223 deletions
|
@ -368,18 +368,12 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
zone.BroadcastPacketAroundActor(this, ChangeSpeedPacket);
|
zone.BroadcastPacketAroundActor(this, ChangeSpeedPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(DateTime tick)
|
public virtual void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
if (this is Character)
|
|
||||||
{
|
|
||||||
((Character)this).Update(tick);
|
|
||||||
}
|
|
||||||
else if (this is Zone)
|
|
||||||
{
|
|
||||||
((Zone)this).Update(tick);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void GenerateActorName(int actorNumber)
|
public void GenerateActorName(int actorNumber)
|
||||||
{
|
{
|
||||||
//Format Class Name
|
//Format Class Name
|
||||||
|
|
|
@ -531,7 +531,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(DateTime tick)
|
public override void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
lock (mActorList)
|
lock (mActorList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace FFXIVClassic_Map_Server.actors.area
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(DateTime tick)
|
public override void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
// todo: again, this is retarded but debug stuff
|
// todo: again, this is retarded but debug stuff
|
||||||
var diffTime = tick - lastUpdate;
|
var diffTime = tick - lastUpdate;
|
||||||
|
|
|
@ -171,35 +171,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
if (this.target != player)
|
if (this.target != player)
|
||||||
{
|
{
|
||||||
#region super important performance critical code
|
|
||||||
|
|
||||||
this.ChangeState(SetActorStatePacket.MAIN_STATE_MOUNTED);
|
|
||||||
|
|
||||||
var chatMode = Program.Random.Next(13);
|
|
||||||
var emphasis = Program.Random.Next(9);
|
|
||||||
var drag = Program.Random.Next(7);
|
|
||||||
|
|
||||||
chatMode = chatMode.Clamp(1, 12);
|
|
||||||
|
|
||||||
string oni = "ONI";
|
|
||||||
string chan = "CHA";
|
|
||||||
|
|
||||||
for (var i = 0; i < emphasis; ++i)
|
|
||||||
oni += "I";
|
|
||||||
|
|
||||||
for (var i = 0; i < drag; ++i)
|
|
||||||
chan += "A";
|
|
||||||
|
|
||||||
oni += "-";
|
|
||||||
chan += "N";
|
|
||||||
|
|
||||||
// imouto aggro
|
|
||||||
player.SendMessage((uint)chatMode, "Rowena", oni + chan);
|
|
||||||
// sing for onii
|
|
||||||
this.PlayAnimation(Program.Random.Next(0, 2) == 1 ? (uint)67111904 : (uint)67108902);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
this.moveState = player.moveState;
|
this.moveState = player.moveState;
|
||||||
|
@ -221,7 +192,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(DateTime tick)
|
public override void Update(DateTime tick)
|
||||||
{
|
{
|
||||||
// todo: actual ai controllers
|
// todo: actual ai controllers
|
||||||
// todo: mods to control different params instead of hardcode
|
// todo: mods to control different params instead of hardcode
|
||||||
|
|
|
@ -47,6 +47,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
controller.Update(tick);
|
controller.Update(tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CheckCompletedStates()
|
||||||
|
{
|
||||||
|
while (states.Count > 0 && states.Peek().IsCompleted())
|
||||||
|
{
|
||||||
|
states.Peek().Cleanup();
|
||||||
|
states.Pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void InterruptStates()
|
public void InterruptStates()
|
||||||
{
|
{
|
||||||
while (states.Count > 0 && states.Peek().CanInterrupt())
|
while (states.Count > 0 && states.Peek().CanInterrupt())
|
||||||
|
@ -73,13 +82,24 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
|
|
||||||
public bool CanChangeState()
|
public bool CanChangeState()
|
||||||
{
|
{
|
||||||
return states.Count == 0 || states.First().CanInterrupt();
|
return states.Count == 0 || states.Peek().CanInterrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeTarget(Character target)
|
||||||
|
{
|
||||||
|
if (controller != null)
|
||||||
|
{
|
||||||
|
controller.ChangeTarget(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeState(State state)
|
public void ChangeState(State state)
|
||||||
{
|
{
|
||||||
if (states.Count < 10)
|
if (GetCurrentState() != null)
|
||||||
{
|
{
|
||||||
|
if (states.Count <= 10)
|
||||||
|
{
|
||||||
|
CheckCompletedStates();
|
||||||
states.Push(state);
|
states.Push(state);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -87,6 +107,25 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
throw new Exception("shit");
|
throw new Exception("shit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ForceChangeState(State state)
|
||||||
|
{
|
||||||
|
if (states.Count <= 10)
|
||||||
|
{
|
||||||
|
CheckCompletedStates();
|
||||||
|
states.Push(state);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("force shit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public State GetCurrentState()
|
||||||
|
{
|
||||||
|
return states.Peek() ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime GetLatestUpdate()
|
public DateTime GetLatestUpdate()
|
||||||
{
|
{
|
||||||
|
@ -157,11 +196,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
InternalMobSkill(target, mobSkillId);
|
InternalMobSkill(target, mobSkillId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InternalEngage(Character target)
|
public void InternalChangeTarget(Character target)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool InternalEngage(Character target)
|
||||||
|
{
|
||||||
|
if (IsEngaged())
|
||||||
|
{
|
||||||
|
if (this.owner.target != target)
|
||||||
|
{
|
||||||
|
ChangeTarget(target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CanChangeState() || (GetCurrentState() != null && GetCurrentState().IsCompleted()))
|
||||||
|
{
|
||||||
|
ForceChangeState(new AttackState(this.owner, target));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void InternalDisengage()
|
public void InternalDisengage()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
private byte tier; // same effect with higher tier overwrites this
|
private byte tier; // same effect with higher tier overwrites this
|
||||||
private Dictionary<string, UInt64> variables; // list of variables which belong to this effect, to be set/retrieved with GetVariable(key), SetVariable(key, val)
|
private Dictionary<string, UInt64> variables; // list of variables which belong to this effect, to be set/retrieved with GetVariable(key), SetVariable(key, val)
|
||||||
private StatusEffectFlags flags; // death/erase/dispel etc
|
private StatusEffectFlags flags; // death/erase/dispel etc
|
||||||
private StatusEffectOverwrite overwrite; //
|
private StatusEffectOverwrite overwrite; // how to handle adding an effect with same id (see StatusEfectOverwrite)
|
||||||
|
|
||||||
public StatusEffect(Character owner, uint id, int magnitude, uint tickMs, uint durationMs, byte tier = 0)
|
public StatusEffect(Character owner, uint id, int magnitude, uint tickMs, uint durationMs, byte tier = 0)
|
||||||
{
|
{
|
||||||
|
@ -602,5 +602,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasStatusEffectsByFlag(uint flag)
|
||||||
|
{
|
||||||
|
foreach (var effect in effects)
|
||||||
|
{
|
||||||
|
if ((effect.GetFlags() & flag) > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||||
|
|
||||||
public virtual void ChangeTarget(Character target)
|
public virtual void ChangeTarget(Character target)
|
||||||
{
|
{
|
||||||
owner.aiContainer.InternalEngage(target);
|
owner.aiContainer.InternalChangeTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAutoAttackEnabled()
|
public bool IsAutoAttackEnabled()
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||||
public override bool Engage(Character target)
|
public override bool Engage(Character target)
|
||||||
{
|
{
|
||||||
// todo: check distance, last swing time, status effects
|
// todo: check distance, last swing time, status effects
|
||||||
|
this.owner.aiContainer.InternalEngage(target);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||||
base(owner, target)
|
base(owner, target)
|
||||||
{
|
{
|
||||||
this.startTime = DateTime.Now;
|
this.startTime = DateTime.Now;
|
||||||
|
// todo: should handle everything here instead of on next tick..
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnStart()
|
public override void OnStart()
|
||||||
|
@ -32,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||||
|
|
||||||
public override void OnComplete()
|
public override void OnComplete()
|
||||||
{
|
{
|
||||||
|
isCompleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void TryInterrupt()
|
public override void TryInterrupt()
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||||
|
|
||||||
protected SubPacket errorPacket;
|
protected SubPacket errorPacket;
|
||||||
|
|
||||||
|
protected bool isCompleted;
|
||||||
|
|
||||||
public State(Character owner, Character target)
|
public State(Character owner, Character target)
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
@ -31,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||||
public virtual void Update(DateTime tick) { }
|
public virtual void Update(DateTime tick) { }
|
||||||
public virtual void OnStart() { }
|
public virtual void OnStart() { }
|
||||||
public virtual void OnInterrupt() { }
|
public virtual void OnInterrupt() { }
|
||||||
public virtual void OnComplete() { }
|
public virtual void OnComplete() { isCompleted = true; }
|
||||||
|
|
||||||
public virtual void TryInterrupt() { }
|
public virtual void TryInterrupt() { }
|
||||||
|
|
||||||
|
@ -47,5 +49,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||||
this.interrupt = interrupt;
|
this.interrupt = interrupt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsCompleted()
|
||||||
|
{
|
||||||
|
return isCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
isStatic = true;
|
isStatic = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GenerateActorName((int)actorNumber);
|
||||||
this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(this));
|
this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,169 +0,0 @@
|
||||||
require("global");
|
|
||||||
|
|
||||||
properties = {
|
|
||||||
permissions = 0,
|
|
||||||
parameters = "ssss",
|
|
||||||
description =
|
|
||||||
[[
|
|
||||||
yolo
|
|
||||||
]],
|
|
||||||
}
|
|
||||||
|
|
||||||
local quests =
|
|
||||||
{
|
|
||||||
[111807] = { level = 25, weight = 4, rewardexp = 1080 },
|
|
||||||
[110868] = { level = 50, weight = 4, rewardexp = 4400 },
|
|
||||||
[111603] = { level = 22, weight = 5, rewardexp = 1100 },
|
|
||||||
[111602] = { level = 22, weight = 5, rewardexp = 1100 },
|
|
||||||
[111420] = { level = 45, weight = 5, rewardexp = 4450 },
|
|
||||||
[110811] = { level = 18, weight = 6, rewardexp = 780 },
|
|
||||||
[110814] = { level = 18, weight = 6, rewardexp = 780 },
|
|
||||||
[110707] = { level = 25, weight = 6, rewardexp = 1620 },
|
|
||||||
[110682] = { level = 34, weight = 6, rewardexp = 3180 },
|
|
||||||
[111202] = { level = 35, weight = 6, rewardexp = 3360 },
|
|
||||||
[111222] = { level = 35, weight = 6, rewardexp = 3360 },
|
|
||||||
[111302] = { level = 35, weight = 6, rewardexp = 3360 },
|
|
||||||
[111223] = { level = 40, weight = 6, rewardexp = 4260 },
|
|
||||||
[110819] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[111224] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[111225] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[110867] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[110869] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[110708] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[110627] = { level = 45, weight = 6, rewardexp = 5340 },
|
|
||||||
[111434] = { level = 50, weight = 6, rewardexp = 6600 },
|
|
||||||
[110850] = { level = 1, weight = 7, rewardexp = 40 },
|
|
||||||
[110851] = { level = 1, weight = 7, rewardexp = 40 },
|
|
||||||
[110841] = { level = 20, weight = 7, rewardexp = 1120 },
|
|
||||||
[110642] = { level = 20, weight = 7, rewardexp = 1120 },
|
|
||||||
[110840] = { level = 20, weight = 7, rewardexp = 1120 },
|
|
||||||
[110727] = { level = 21, weight = 7, rewardexp = 1401 },
|
|
||||||
[111221] = { level = 30, weight = 7, rewardexp = 2661 },
|
|
||||||
[111241] = { level = 30, weight = 7, rewardexp = 2661 },
|
|
||||||
[110687] = { level = 28, weight = 9, rewardexp = 2970 },
|
|
||||||
[110016] = { level = 34, weight = 50, rewardexp = 26500 },
|
|
||||||
[110017] = { level = 38, weight = 50, rewardexp = 32500 },
|
|
||||||
[110019] = { level = 46, weight = 50, rewardexp = 46000 }
|
|
||||||
};
|
|
||||||
|
|
||||||
local expTable = {
|
|
||||||
570, -- 1
|
|
||||||
700,
|
|
||||||
880,
|
|
||||||
1100,
|
|
||||||
1500,
|
|
||||||
1800,
|
|
||||||
2300,
|
|
||||||
3200,
|
|
||||||
4300,
|
|
||||||
5000, -- 10
|
|
||||||
5900,
|
|
||||||
6800,
|
|
||||||
7700,
|
|
||||||
8700,
|
|
||||||
9700,
|
|
||||||
11000,
|
|
||||||
12000,
|
|
||||||
13000,
|
|
||||||
15000,
|
|
||||||
16000, -- 20
|
|
||||||
20000,
|
|
||||||
22000,
|
|
||||||
23000,
|
|
||||||
25000,
|
|
||||||
27000,
|
|
||||||
29000,
|
|
||||||
31000,
|
|
||||||
33000,
|
|
||||||
35000,
|
|
||||||
38000, -- 30
|
|
||||||
45000,
|
|
||||||
47000,
|
|
||||||
50000,
|
|
||||||
53000,
|
|
||||||
56000,
|
|
||||||
59000,
|
|
||||||
62000,
|
|
||||||
65000,
|
|
||||||
68000,
|
|
||||||
71000, -- 40
|
|
||||||
74000,
|
|
||||||
78000,
|
|
||||||
81000,
|
|
||||||
85000,
|
|
||||||
89000,
|
|
||||||
92000,
|
|
||||||
96000,
|
|
||||||
100000,
|
|
||||||
100000,
|
|
||||||
110000 -- 50
|
|
||||||
};
|
|
||||||
|
|
||||||
local commandCost = {
|
|
||||||
["raise"] = 150,
|
|
||||||
["cure"] = 40,
|
|
||||||
["cura"] = 100,
|
|
||||||
["curaga"] = 150,
|
|
||||||
};
|
|
||||||
-- stone: (1, 9) (5, 12) (10, )
|
|
||||||
-- cure: (1, 5) (5, 6) (10, )
|
|
||||||
-- aero: (1, 9) (5, 12) (10, )
|
|
||||||
-- protect: (1, 9) (5, 12) (10, )
|
|
||||||
--[[
|
|
||||||
function onTrigger(player, argc, id, level, weight)
|
|
||||||
id = tonumber(id) or 111807;
|
|
||||||
level = tonumber(level) or quests[id].level;
|
|
||||||
weight = tonumber(weight) or quests[id].weight;
|
|
||||||
local messageId = MESSAGE_TYPE_SYSTEM_ERROR;
|
|
||||||
local sender = "yolo";
|
|
||||||
|
|
||||||
if id == 1 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local message = calcSkillPoint(player, level, weight);
|
|
||||||
if player then
|
|
||||||
player.SendMessage(messageId, sender, string.format("calculated %s | expected %s", message, quests[id].rewardexp));
|
|
||||||
end;
|
|
||||||
printf("calculated %s | expected %s", message, quests[id].rewardexp);
|
|
||||||
end;
|
|
||||||
]]
|
|
||||||
|
|
||||||
function onTrigger(player, argc, skillName, level)
|
|
||||||
local messageId = MESSAGE_TYPE_SYSTEM_ERROR;
|
|
||||||
local sender = "yolo";
|
|
||||||
if player then
|
|
||||||
local pos = player:GetPos();
|
|
||||||
local x = tonumber(pos[0]);
|
|
||||||
local y = tonumber(pos[1]);
|
|
||||||
local z = tonumber(pos[2]);
|
|
||||||
local rot = tonumber(pos[3]);
|
|
||||||
local zone = pos[4];
|
|
||||||
|
|
||||||
printf("%f %f %f", x, y, z);
|
|
||||||
--local x, y, z = player.GetPos();
|
|
||||||
for i = 1, 1 do
|
|
||||||
|
|
||||||
local actor = player.GetZone().SpawnActor(1000070, 'ass', x-(13 + 2*i), y, z);
|
|
||||||
|
|
||||||
actor.FollowTarget(player, 3.2);
|
|
||||||
end;
|
|
||||||
return;
|
|
||||||
end
|
|
||||||
level = tonumber(level) or 1;
|
|
||||||
if player then
|
|
||||||
player.SendMessage(messageId, sender, string.format("name %s | cost %d | level %u", skillName, calculateCommandCost(player, skillName, level), level));
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function calculateCommandCost(player, skillName, level)
|
|
||||||
if skillName and level and commandCost[skillName] then
|
|
||||||
return math.ceil((8000 + (level - 70) * 500) * (commandCost[skillName] * 0.001));
|
|
||||||
end;
|
|
||||||
return 1;
|
|
||||||
end
|
|
||||||
|
|
||||||
function calcSkillPoint(player, lvl, weight)
|
|
||||||
weight = weight / 100
|
|
||||||
|
|
||||||
return math.ceil(expTable[lvl] * weight)
|
|
||||||
end
|
|
|
@ -533,11 +533,11 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
LuaParam.Insert(1, i - (playerNull ? 2 : 0));
|
LuaParam.Insert(1, i - (playerNull ? 2 : 0));
|
||||||
|
|
||||||
// run the script
|
// run the script
|
||||||
script.Call(script.Globals["onTrigger"], LuaParam.ToArray());
|
//script.Call(script.Globals["onTrigger"], LuaParam.ToArray());
|
||||||
|
|
||||||
//Coroutine coroutine = script.CreateCoroutine(script.Globals["onTrigger"]).Coroutine;
|
Coroutine coroutine = script.CreateCoroutine(script.Globals["onTrigger"]).Coroutine;
|
||||||
//DynValue value = coroutine.Resume(LuaParam.ToArray());
|
DynValue value = coroutine.Resume(LuaParam.ToArray());
|
||||||
//GetInstance().ResolveResume(player, coroutine, value);
|
GetInstance().ResolveResume(player, coroutine, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue