ServUO Version
Publish 57
Ultima Expansion
Endless Journey
How can I accept a bank check for a certain amount as a quest item turn in?
Adding it as the following does not seem to work as it's looking for an amount rather than the item if that makes sense..
C#:
AddObjective(new ObtainObjective(typeof(BankCheck), "Building Fund", 500000));
 
You can create a new class that inherits from ObtainObjective, and override IsObjective(Item item) to determine whether the item passes the criteria:

C#:
public override bool IsObjective(Item item)
{
    if (!base.IsObjective(item))
        return false;

    if (item is BankCheck check && check.Worth == MaxProgress)
        return true;

    return false;
}

Ex. BankCheckObjective : ObtainObjective
 
Probably doing something wrong I'm sure.. but
C#:
error CS0115: 'SecondHouseQuest.IsObjective(Item)': no suitable method found to override [C:\ServUO\Scripts\Scripts.csproj]
 
You can create a new class that inherits from ObtainObjective, and override IsObjective(Item item) to determine whether the item passes the criteria:

Ex. BankCheckObjective : ObtainObjective
The IsObjective method would be overridden in your new BankCheckObjective class, not the quest class itself.
When you add your objective to the quest, you would do 'new BankCheckObjective(...)` instead of 'new ObtainObjective(...)'
 
The IsObjective method would be overridden in your new BankCheckObjective class, not the quest class itself.
When you add your objective to the quest, you would do 'new BankCheckObjective(...)` instead of 'new ObtainObjective(...)'
So I would be adding this?
C#:
AddObjective(new BankCheckObjective(typeof(BankCheck), "Building Fund", 500000));
 
Yes, but you need to code the BankCheckObjective so that you can use it.

This is pretty much the only existing example of a system that creates a custom ObtainObjective in a simple enough way to get started as a reference :)
 
So something like this I assume? It compiles but I can't turn in the quest..
C#:
        private class InternalObjective : ObtainObjective
        {
            public InternalObjective()
                : base(typeof(BankCheck), "Building Fund", 500000)
            {
            }

            public override bool IsObjective(Item item)
            {
                if (base.IsObjective(item))
                {
                    if (item is BankCheck check && check.Worth == MaxProgress)
                        return true;
                }

                return false;
            }

            public override void Serialize(GenericWriter writer)
            {
                base.Serialize(writer);

                writer.WriteEncodedInt(0); // version
            }

            public override void Deserialize(GenericReader reader)
            {
                base.Deserialize(reader);

                int version = reader.ReadEncodedInt();
            }
        }

        public SecondHouseQuest() : base()
        {
            AddObjective(new ObtainObjective(typeof(IronIngot), "Nails", 1000));
            AddObjective(new ObtainObjective(typeof(Log), "Lumber", 350));
            AddObjective(new ObtainObjective(typeof(BankCheck), "Building Fund", 500000));
            AddReward(new BaseReward(typeof(ExtraHouseDeed), "+1 Extra House"));
        }
 
Do you need to mark the check as a quest item via the context menu before you can turn it in?
 
Do you need to mark the check as a quest item via the context menu before you can turn it in?
I did mark it yes, but unless I make the check "amount" 500000 I can't turn it in. I assume it's still thinking there should be a "stack" of items.
 
Try this :)
C#:
        private class InternalObjective : ObtainObjective
        {
            public InternalObjective()
                : base(typeof(BankCheck), "Building Fund", 1)
            {
            }

            public override bool IsObjective(Item item)
            {
                if (base.IsObjective(item))
                {
                    if (item is BankCheck check && check.Worth == 500000)
                        return true;
                }

                return false;
            }

            public override void Serialize(GenericWriter writer)
            {
                base.Serialize(writer);

                writer.WriteEncodedInt(0); // version
            }

            public override void Deserialize(GenericReader reader)
            {
                base.Deserialize(reader);

                int version = reader.ReadEncodedInt();
            }
        }

        public SecondHouseQuest() : base()
        {
            AddObjective(new ObtainObjective(typeof(IronIngot), "Nails", 1000));
            AddObjective(new ObtainObjective(typeof(Log), "Lumber", 350));
            AddObjective(new ObtainObjective(typeof(BankCheck), "Building Fund", 500000));
            AddReward(new BaseReward(typeof(ExtraHouseDeed), "+1 Extra House"));
        }
 
My bad, I missed that part at the bottom :p
C#:
        public SecondHouseQuest() : base()
        {
            AddObjective(new ObtainObjective(typeof(IronIngot), "Nails", 1000));
            AddObjective(new ObtainObjective(typeof(Log), "Lumber", 350));
            AddObjective(new InternalObjective()); // Building Fund

            AddReward(new BaseReward(typeof(ExtraHouseDeed), "+1 Extra House"));
        }
 
Back