mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
stubbed item use state (needs to actually look up the item and get its reuse stuff)
- added tables to load mobs from (probably dont import besides server_battlenpc_genus.sql) - added field to server_battle_commands for commands usable by both monsters and players (probably arent any really)
This commit is contained in:
@@ -93,6 +93,23 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
}
|
||||
}
|
||||
|
||||
public void InternalUseItem(Character target, uint slot, uint itemId)
|
||||
{
|
||||
// todo: can allies use items?
|
||||
if (owner is Player)
|
||||
{
|
||||
if (CanChangeState())
|
||||
{
|
||||
ChangeState(new ItemState((Player)owner, target, (ushort)slot, itemId));
|
||||
}
|
||||
else
|
||||
{
|
||||
// You cannot use that item now.
|
||||
((Player)owner).SendGameMessage(Server.GetWorldManager().GetActor(), 32544, 0x20, itemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearStates()
|
||||
{
|
||||
while (states.Count > 0)
|
||||
@@ -107,9 +124,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
public Controller GetController()
|
||||
public T GetController<T>() where T : Controller
|
||||
{
|
||||
return controller;
|
||||
return controller as T;
|
||||
}
|
||||
|
||||
public TargetFind GetTargetFind()
|
||||
@@ -190,13 +207,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool IsSpawned()
|
||||
{
|
||||
// todo: set a flag when finished spawning
|
||||
return !IsDead();
|
||||
}
|
||||
|
||||
public bool IsEngaged()
|
||||
{
|
||||
// todo: check this is legit
|
||||
return owner.currentMainState == SetActorStatePacket.MAIN_STATE_ACTIVE;
|
||||
}
|
||||
|
||||
@@ -260,6 +275,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
InternalMobSkill(target, mobSkillId);
|
||||
}
|
||||
|
||||
public void UseItem(Character target, uint slot, uint itemId)
|
||||
{
|
||||
if (controller != null)
|
||||
controller.UseItem(target, slot, itemId);
|
||||
}
|
||||
public void InternalChangeTarget(Character target)
|
||||
{
|
||||
// targets are changed in the controller
|
||||
|
@@ -44,6 +44,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
Miss = 0x08
|
||||
}
|
||||
|
||||
public enum BattleCommandValidUser : byte
|
||||
{
|
||||
All,
|
||||
Player,
|
||||
Monster
|
||||
}
|
||||
|
||||
class BattleCommand
|
||||
{
|
||||
public ushort id;
|
||||
@@ -75,6 +82,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
public int aoeRange;
|
||||
|
||||
public TargetFind targetFind;
|
||||
public BattleCommandValidUser validUser;
|
||||
|
||||
public BattleCommand(ushort id, string name)
|
||||
{
|
||||
@@ -100,12 +108,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool IsValidTarget(Character user, Character target)
|
||||
{
|
||||
// todo: set box length..
|
||||
targetFind = new TargetFind(user);
|
||||
|
||||
if (aoeType == TargetFindAOEType.Box)
|
||||
{
|
||||
// todo: read box width from sql
|
||||
targetFind.SetAOEBox(validTarget, aoeTarget, range, aoeRange);
|
||||
}
|
||||
else
|
||||
|
@@ -125,6 +125,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
this.param = param != -1.0f ? param : 0.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call this to prepare Box AOE
|
||||
/// </summary>
|
||||
/// <param name="validTarget"></param>
|
||||
/// <param name="aoeTarget"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <param name="width"></param>
|
||||
public void SetAOEBox(ValidTarget validTarget, TargetFindAOETarget aoeTarget, float length, float width)
|
||||
{
|
||||
this.validTarget = validTarget;
|
||||
@@ -272,7 +279,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
{
|
||||
foreach (var actorId in party.members)
|
||||
{
|
||||
AddTarget(owner.zone.FindActorInArea(actorId) as Character, withPet);
|
||||
AddTarget(owner.zone.FindActorInArea<Character>(actorId), withPet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,9 +380,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
private bool IsWithinCircle(Character target, float maxDistance)
|
||||
{
|
||||
// todo: make y diff modifiable?
|
||||
if (Math.Abs(owner.positionX - target.positionY) > 6.0f)
|
||||
return false;
|
||||
|
||||
if (this.targetPosition == null)
|
||||
this.targetPosition = aoeTarget == TargetFindAOETarget.Self ? owner.GetPosAsVector3() : masterTarget.GetPosAsVector3();
|
||||
|
||||
return target.GetPosAsVector3().IsWithinCircle(targetPosition, param);
|
||||
}
|
||||
|
||||
@@ -393,9 +403,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
// if character is a player owned pet, treat as a player
|
||||
if (target.aiContainer != null)
|
||||
{
|
||||
var controller = target.aiContainer.GetController();
|
||||
if (controller != null && controller is PetController)
|
||||
return ((PetController)controller).GetPetMaster();
|
||||
var controller = target.aiContainer.GetController<PetController>();
|
||||
if (controller != null)
|
||||
return controller.GetPetMaster();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
|
||||
public override void Update(DateTime tick)
|
||||
{
|
||||
lastUpdate = tick;
|
||||
// todo: handle aggro/deaggro and other shit here
|
||||
if (owner.aiContainer.IsEngaged())
|
||||
{
|
||||
@@ -104,8 +105,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
owner.aiContainer.pathFind.PreparePath(owner.spawnX, owner.spawnY, owner.spawnZ, 1.5f, 10);
|
||||
neutralTime = lastActionTime;
|
||||
owner.hateContainer.ClearHate();
|
||||
owner.ResetMoveSpeeds();
|
||||
owner.moveState = 1;
|
||||
lua.LuaEngine.CallLuaBattleFunction(owner, "onDisengage", owner, target, Utils.UnixTimeStampUTC(battleStartTime));
|
||||
lua.LuaEngine.CallLuaBattleFunction(owner, "onDisengage", owner, target, Utils.UnixTimeStampUTC(lastUpdate));
|
||||
}
|
||||
|
||||
public override void Cast(Character target, uint spellId)
|
||||
@@ -143,7 +145,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
if (tick >= waitTime)
|
||||
{
|
||||
// todo: aggro cooldown
|
||||
neutralTime = tick.AddSeconds(3);
|
||||
neutralTime = tick.AddSeconds(5);
|
||||
if (owner.aiContainer.pathFind.IsFollowingPath())
|
||||
{
|
||||
owner.aiContainer.pathFind.FollowPath();
|
||||
|
@@ -29,6 +29,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
public abstract void Cast(Character target, uint spellId);
|
||||
public virtual void WeaponSkill(Character target, uint weaponSkillId) { }
|
||||
public virtual void MonsterSkill(Character target, uint mobSkillId) { }
|
||||
public virtual void UseItem(Character target, uint slot, uint itemId) { }
|
||||
public abstract void Ability(Character target, uint abilityId);
|
||||
public abstract void RangedAttack(Character target);
|
||||
public virtual void Spawn() { }
|
||||
|
@@ -87,5 +87,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void UseItem(Character target, uint slot, uint itemId)
|
||||
{
|
||||
owner.aiContainer.InternalUseItem(target, slot, itemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
: base(owner, null)
|
||||
{
|
||||
owner.Disengage();
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD);
|
||||
owner.ChangeState(SetActorStatePacket.MAIN_STATE_DEAD2);
|
||||
canInterrupt = false;
|
||||
startTime = tick;
|
||||
despawnTime = startTime.AddSeconds(timeToFadeOut);
|
||||
|
23
FFXIVClassic Map Server/actors/chara/ai/state/ItemState.cs
Normal file
23
FFXIVClassic Map Server/actors/chara/ai/state/ItemState.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.actors.chara.player;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
{
|
||||
class ItemState : State
|
||||
{
|
||||
ItemData item;
|
||||
new Player owner;
|
||||
public ItemState(Player owner, Character target, ushort slot, uint itemId) :
|
||||
base(owner, target)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user