Kamras
Member
So I'm terrible with timers, for some reason or another, I always end up in circles. Here is my Flight Item, I use this instead of the traditional methods to active flight for a gargoyle, I would like to cause this effect to it.
Start Flight Item (Double Click),
Flight permitted for up to 15 minutes, then force land if 15 minute timer is reached.
If gargoyle toon lands, start counting back the timer to add more flight time.
So basically trying to implement the idea of rest for flight.
Any suggestion to get the above effects?
Start Flight Item (Double Click),
Flight permitted for up to 15 minutes, then force land if 15 minute timer is reached.
If gargoyle toon lands, start counting back the timer to add more flight time.
So basically trying to implement the idea of rest for flight.
Any suggestion to get the above effects?
Code:
using System;
using Server;
using Server.Multis;
using Server.Network;
using Server.Items;
using Server.Spells;
using Server.Targeting;
using Server.Commands;
using Server.Mobiles;
using Server.Engines.Quests;
namespace Server.Items
{
public class FlightItem : Item
{
[Constructable]
public FlightItem() : base( 0x5726 )
{
Movable = true;
Weight = 0.0;
Name = "Toggle Flight";
LootType = LootType.Blessed;
Hue = 6;
}
public override void OnDoubleClick( Mobile from )
{
if (from.Flying == false)
{
BlockMountType type = BaseMount.GetMountPrevention(from);
if (from.IsBodyMod && !(from.BodyMod == 666 || from.BodyMod == 667))
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "You can't fly in your current form!"); // You can't fly in your current form!
}
else if (!from.Alive)
{
from.SendMessage("You may not fly while dead."); // You may not fly while dead.
}
else if (type != BlockMountType.None)
{
switch (type)
{
case BlockMountType.Dazed:
from.SendMessage("You are still too dazed to fly.");
break; // You are still too dazed to fly.
case BlockMountType.BolaRecovery:
from.SendMessage("You cannot fly while recovering from a bola throw.");
break; // You cannot fly while recovering from a bola throw.
case BlockMountType.DismountRecovery:
from.SendMessage("You cannot fly while recovering from a dismount maneuver.");
break; // You cannot fly while recovering from a dismount maneuver.
}
return;
}
else
{
from.Freeze(TimeSpan.FromSeconds(1));
from.RevealingAction();
from.Animate(60, 10, 1, true, false, 0);
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "You are flying!");
from.Flying = true;
BuffInfo.AddBuff(from, new BuffInfo(BuffIcon.Fly, 1112567));
}
}
else
{
from.Freeze(TimeSpan.FromSeconds(1));
from.RevealingAction();
from.Animate(61, 10, 1, true, false, 0);
BuffInfo.RemoveBuff(from, BuffIcon.Fly);
from.Flying = false;
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "You've Landed!");
}
}
public virtual bool Accepted
{
get
{
return this.Deleted;
}
}
public override bool DropToWorld(Mobile from, Point3D p)
{
bool ret = base.DropToWorld(from, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "You feel silly for wanting to drop something so useful...");
return false;
}
}
else
{
return ret;
}
}
public override bool DropToMobile(Mobile from, Mobile target, Point3D p)
{
bool ret = base.DropToMobile(from, target, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "This cannot be traded!");
return false;
}
}
else
{
return ret;
}
}
public override bool DropToItem(Mobile from, Item target, Point3D p)
{
bool ret = base.DropToItem(from, target, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "This can only exist on the top level of the backpack!");
return false;
}
}
else
{
return ret;
}
}
public FlightItem( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}