public void Use(Creature creature, Skill skill, Packet packet)
{
var locationId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
var guild = creature.Guild;
var region = creature.Region;
var pos = new Position(locationId);
var creaturePos = creature.GetPosition();
// Check range
if (!creaturePos.InRange(pos, MaxStoneDistance))
{
creature.Unlock(Locks.Walk | Locks.Run);
Send.Notice(creature, Localization.Get("You're too far away."));
Send.SkillUseSilentCancel(creature);
return;
}
// Check distance to other stones
var otherStones = region.GetProps(a => a.HasTag("/guildstone/") && a.GetPosition().InRange(pos, MinStoneDistance));
if (otherStones.Count != 0)
{
creature.Unlock(Locks.Walk | Locks.Run);
Send.Notice(creature, Localization.Get("You're too close to another Guild Stone to put yours up."));
Send.SkillUseSilentCancel(creature);
return;
}
// Check street
if (creature.Region.IsOnStreet(pos))
{
Send.Notice(creature, Localization.Get("You can't place a Guild Stone on the street."));
Send.SkillUseSilentCancel(creature);
return;
}
// Place stone (from complete)
creature.Skills.Callback(skill.Info.Id, () =>
{
guild.Stone.PropId = GuildStonePropId.Normal;
guild.Stone.RegionId = region.Id;
guild.Stone.X = pos.X;
guild.Stone.Y = pos.Y;
guild.Stone.Direction = MabiMath.ByteToRadian(creature.Direction);
ChannelServer.Instance.GuildManager.SetStone(guild);
Send.Notice(NoticeType.Top, 20000, Localization.Get("{0} Guild has been formed. Guild Leader : {1}"), guild.Name, guild.LeaderName);
creature.Inventory.Remove(63041); // Guild Stone Installation Permit
});
// TODO: Skills that don't necessarily end in Use need a way to get
// back to Ready, we currently don't properly support that.
// Use will probably require a return value, like Prepare.
// Temporary solution: working with stacks.
skill.Stacks = 0;
Send.Echo(creature, Op.SkillUse, packet);
}