Skip to content

Commit

Permalink
Merge pull request #15 from Gugu42/develop
Browse files Browse the repository at this point in the history
Labor consumption, DoodadFuncLootItem, unit no longer regen HP
  • Loading branch information
atel0 authored Feb 5, 2019
2 parents 230a970 + 617b2b7 commit a0646ca
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 9 deletions.
1 change: 1 addition & 0 deletions AAEmu.Game/Core/Managers/SkillManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public void Load()
template.ChannelingCancelable = reader.GetBoolean("channeling_cancelable", true);
template.TargetOffsetAngle = reader.GetFloat("target_offset_angle");
template.TargetOffsetDistance = reader.GetFloat("target_offset_distance");
template.ActabilityGroupId = reader.GetInt32("actability_group_id", 0);
template.PlotOnly = reader.GetBoolean("plot_only", true);
template.SkillControllerAtEnd = reader.GetBoolean("skill_controller_at_end", true);
template.EndSkillController = reader.GetBoolean("end_skill_controller", true);
Expand Down
4 changes: 2 additions & 2 deletions AAEmu.Game/Core/Network/Game/GamePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public override PacketStream Encode()
}

if (!(TypeId == 0x013 && Level == 2) && !(TypeId == 0x066 && Level == 1))
_log.Debug("GamePacket: S->C\n{0}", ps);
_log.Debug("GamePacket: S->C type {0:X}\n{1}", TypeId, ps);

return ps;
}

public override PacketBase<GameConnection> Decode(PacketStream ps)
{
if (!(TypeId == 0x012 && Level == 2) && !(TypeId == 0x088 && Level == 1))
_log.Debug("GamePacket: C->S\n{0}", ps);
_log.Debug("GamePacket: C->S type {0:X}\n{1}", TypeId, ps);

try
{
Expand Down
13 changes: 13 additions & 0 deletions AAEmu.Game/Models/Game/Char/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,19 @@ public void ChangeMoney(SlotType typeTo, int amount)
}
}

public void ChangeLabor(short change, int actabilityId) {
var actabilityChange = 0;
byte actabilityStep = 0;
if (actabilityId > 0) {
actabilityChange = Math.Abs(change);
actabilityStep = Actability.Actabilities[(uint)actabilityId].Step;
Actability.AddPoint((uint)actabilityId, actabilityChange);
}

LaborPower += change;
SendPacket(new SCCharacterLaborPowerChangedPacket(change, actabilityId, actabilityChange, actabilityStep));
}

public void SetAction(byte slot, ActionSlotType type, uint actionId)
{
Slots[slot].Type = type;
Expand Down
16 changes: 16 additions & 0 deletions AAEmu.Game/Models/Game/DoodadObj/Funcs/DoodadFuncLootItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using AAEmu.Commons.Utils;
using AAEmu.Game.Core.Helper;
using AAEmu.Game.Core.Managers;
using AAEmu.Game.Models.Game.Char;
using AAEmu.Game.Models.Game.DoodadObj.Templates;
using AAEmu.Game.Models.Game.Items;
using AAEmu.Game.Models.Game.Units;

namespace AAEmu.Game.Models.Game.DoodadObj.Funcs
Expand All @@ -15,6 +20,17 @@ public class DoodadFuncLootItem : DoodadFuncTemplate

public override void Use(Unit caster, Doodad owner, uint skillId)
{
Character character = (Character) caster;
if (character == null) return;

int chance = Rand.Next(0, 10000);
if (chance > Percent) return;

int count = Rand.Next(CountMin, CountMax);

Item item = ItemManager.Instance.Create(ItemId, count, 0);
InventoryHelper.AddItemAndUpdateClient(character, item);

_log.Debug("DoodadFuncLootItem");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class DoodadFuncLootPack : DoodadFuncTemplate

public override void Use(Unit caster, Doodad owner, uint skillId)
{
_log.Debug("DoodadFuncLootPack");
_log.Debug("DoodadFuncLootPack : LootPackId {0}, SkillId {1}", LootPackId, skillId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DoodadFuncRatioChange : DoodadFuncTemplate

public override void Use(Unit caster, Doodad owner, uint skillId)
{
_log.Debug("DoodadFuncRatioChange");
_log.Debug("DoodadFuncRatioChange : Ratio {0}, NextPhase {1}, SkillId {2}", Ratio, NextPhase, skillId);
}
}
}
7 changes: 6 additions & 1 deletion AAEmu.Game/Models/Game/DoodadObj/Funcs/DoodadFuncTimer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using AAEmu.Game.Core.Managers;
using AAEmu.Game.Core.Managers.UnitManagers;
using AAEmu.Game.Models.Game.DoodadObj.Templates;
using AAEmu.Game.Models.Game.Units;
using AAEmu.Game.Models.Tasks.Doodads;
Expand All @@ -17,7 +18,11 @@ public class DoodadFuncTimer : DoodadFuncTemplate

public override void Use(Unit caster, Doodad owner, uint skillId)
{
_log.Debug("DoodadFuncTimer");
_log.Debug("DoodadFuncTimer : NextPhase {0}, SkillId {1}", NextPhase, skillId);

//This is a temporary fix. We need to find how to properly call the next function.
var nextFunc = DoodadManager.Instance.GetFunc(owner.FuncGroupId, skillId);
if (nextFunc != null) nextFunc.Use(caster, owner, skillId);

if (Delay > 0)
{
Expand Down
7 changes: 7 additions & 0 deletions AAEmu.Game/Models/Game/Skills/Skill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using AAEmu.Game.Core.Managers.Id;
using AAEmu.Game.Core.Managers.World;
using AAEmu.Game.Core.Packets.G2C;
using AAEmu.Game.Models.Game.Char;
using AAEmu.Game.Models.Game.Faction;
using AAEmu.Game.Models.Game.Skills.Effects;
using AAEmu.Game.Models.Game.Skills.Plots;
Expand Down Expand Up @@ -313,6 +314,12 @@ public void Apply(Unit caster, SkillCaster casterCaster, BaseUnit target, SkillC
effect.Template?.Apply(caster, casterCaster, target, targetCaster, new CastSkill(Template.Id, TlId), this, DateTime.Now);
}

if (Template.ConsumeLaborPower > 0) {
if (caster is Character character) {
character.ChangeLabor((short)-Template.ConsumeLaborPower, Template.ActabilityGroupId);
}
}

caster.BroadcastPacket(new SCSkillEndedPacket(TlId), true);
TlIdManager.Instance.ReleaseId(TlId);
TlId = 0;
Expand Down
1 change: 1 addition & 0 deletions AAEmu.Game/Models/Game/Skills/Templates/SkillTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class SkillTemplate
public bool ChannelingCancelable { get; set; }
public float TargetOffsetAngle { get; set; }
public float TargetOffsetDistance { get; set; }
public int ActabilityGroupId { get; set; }
public bool PlotOnly { get; set; }
public bool SkillControllerAtEnd { get; set; }
public bool EndSkillController { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions AAEmu.Game/Models/Game/Units/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public virtual void ReduceCurrentHp(Unit attacker, int value)
if (Hp == 0)
return;
Hp = Math.Max(Hp - value, 0);
if (Hp == 0)
if (Hp == 0) {
DoDie(attacker);
else
StopRegen();
} else
StartRegen();
BroadcastPacket(new SCUnitPointsPacket(ObjId, Hp, Mp), true);
}
Expand Down
7 changes: 5 additions & 2 deletions AAEmu.Game/Scripts/Commands/AddItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ public void Execute(Character character, string[] args)
{
if (args.Length == 0)
{
character.SendMessage("[Items] /add_item <itemId> <count?>");
character.SendMessage("[Items] /add_item <itemId> <count?> <grade?>");
return;
}

var itemId = uint.Parse(args[0]);
var count = 1;
byte grade = 0;
if (args.Length > 1)
count = int.Parse(args[1]);
var item = ItemManager.Instance.Create(itemId, count, 0, true);
if (args.Length > 2)
grade = byte.Parse(args[2]);
var item = ItemManager.Instance.Create(itemId, count, grade, true);
if (item == null)
{
character.SendMessage("Item cannot be created");
Expand Down
30 changes: 30 additions & 0 deletions AAEmu.Game/Scripts/Commands/AddLabor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using AAEmu.Game.Core.Managers;
using AAEmu.Game.Models.Game;
using AAEmu.Game.Models.Game.Char;

namespace AAEmu.Game.Scripts.Commands
{
public class AddLabor : ICommand
{
public void OnLoad()
{
CommandManager.Instance.Register("add_labor", this);
}

public void Execute(Character character, string[] args)
{
if (args.Length == 0)
{
character.SendMessage("[Labor] /add_labor <count> <actability id?>");
return;
}

var count = short.Parse(args[0]);
var actability = 0;
if (args.Length > 1)
actability = int.Parse(args[1]);

character.ChangeLabor(count, actability);
}
}
}

0 comments on commit a0646ca

Please sign in to comment.