1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[UltimaLive] StaticProcess 2015-02-06

"Framework" to deal with static/unstatic operations

  1. Gargouille
    Requirements:
    [Ultima Live]
    In addition to UltimaLive, Praxiis gave us some harvestables trees, letting us chop static trees into unstatic logs...

    Then I need the same kind of job for flowers and plants harvesting... I first try to use Praxiis's work, but finaly I create that "Framework" which I use after for my plant-harvesting system.

    I use an Interface,
    Code:
    public interface IStaticProcessable
    {
    int OnMapStaticID { get; }
    }
    Her you can give any item a corresponding static-id, which is tested by static/unstatic operatioons.

    .SpoilerTarget" style="padding-top: 0px; padding-bottom: 0px; font-family: Calibri, 'Trebuchet MS', Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-stretch: normal; line-height: 21px; color: rgb(0, 0, 0); border-width: 1px; border-style: solid; border-color: rgb(255, 255, 255) rgb(221, 221, 235) rgb(179, 179, 189); border-radius: 7px; -webkit-box-shadow: rgb(200, 200, 210) 0px 1px 4px 0px; box-shadow: rgb(200, 200, 210) 0px 1px 4px 0px; text-shadow: transparent 0px 0px 0px, white 0px -1px 2px; outline: none; cursor: pointer; height: 23px; background: url(http://www.playuo.org/emu/styles/dxf/xenforo/gradients/form-button-white-25px.png) 50% 0% repeat-x rgb(220, 220, 235);">Spoiler: For example:
    In a Mushroom class with ItemID X
    public int OnMapStaticID { get { return X; } }
    will allow you to get an unstatic mushroom when targeting a static mushroom

    In a BananaTree class with ItemID BananaTreeID
    public int OnMapStaticID { get { return BananID; } }
    will let you have a banana when targeting a bananatree

    That script does 2 things
    - store locations, and then respawn of statics you "harvest" (or change in any way)
    - give some usable methods, all taking an "object targeted" as argument, as you got in any end-targeting method

    Here the methods:

    public static Type GetExtractType(Mobile from, object target)
    return the Type of the object that could be extract from static

    public static Item ExtractItemFromTarget(Mobile from, object target)
    return un unstatic Item, UltimaLive-deleting the targeted statictarget

    public static void Delete(Map m, StaticTarget st)
    Just delete the targeted statictarget

    public static bool UnFreeze(Mobile from, ref object target)
    Unfreeze the targeted statictarget into an unstatic Item (corresponding to IStaticProcessable.OnMapStaticID)

    public static void Respawn(Map m, object o, int id, TimeSpan delay)
    public static void Respawn(Map m, IPoint3D loc, int id, TimeSpan delay)
    public static void Respawn(Map m, StaticTarget st, TimeSpan delay)
    Let you define when the "harvested static" must be "respawned"

    In the Zip, I give my plant-harvest-system, to let you see how I use that "framework".