Erevan
Sorceror
edit: i apologize to anyone who read this prior to my edit.. posted the wrong code.. this flu is not conducive to posting on a forum!
for something so simple, i'm (shamefully) baffled that i can't seem to figure this out..
i'm attempting to create an altar, that when double-clicked, will present a target cursor, and players will have to target a treasure map in their pack (the tmap has no requirements.. it can be used/unused, any facet, any level). if not, the player will be prompted to target a tmap. once they target the tmap, they will have 30 seconds (haven't added the timer yet) to target a world map. once they target the world map, both maps should have been consumed, the player's hits set to 1, and a new map (CorgulMap) added to their pack. this is a jerry-rigged version of the system outlined here:http://uo2.stratics.com/monsters/corgul-the-soulbinder
for whatever reason, i have completely boggled the targeting portion of this and can't seem to figure it out. shouldn't come as any surprise, as this is one of the more complicated scripts i've tried my own hand at. certainly looks as though i'll have to walk through this step by step.
what it does CURRENTLY:
for something so simple, i'm (shamefully) baffled that i can't seem to figure this out..
i'm attempting to create an altar, that when double-clicked, will present a target cursor, and players will have to target a treasure map in their pack (the tmap has no requirements.. it can be used/unused, any facet, any level). if not, the player will be prompted to target a tmap. once they target the tmap, they will have 30 seconds (haven't added the timer yet) to target a world map. once they target the world map, both maps should have been consumed, the player's hits set to 1, and a new map (CorgulMap) added to their pack. this is a jerry-rigged version of the system outlined here:http://uo2.stratics.com/monsters/corgul-the-soulbinder
for whatever reason, i have completely boggled the targeting portion of this and can't seem to figure it out. shouldn't come as any surprise, as this is one of the more complicated scripts i've tried my own hand at. certainly looks as though i'll have to walk through this step by step.
what it does CURRENTLY:
- Db-clicking works fine
- Targeting the Treasure Map returns (the first else statement that sends the message "You must target a treasure map first.")
- Targeting any other map gives me the same message.. so it's not recognizing the Treasure Map
- recognize the treasure map.. then 'continue' (allowing the player to dbl-click the altar once more for another targeting cursor, and then they can target the WORLD map)
Code:
using System;
using Server;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Mobiles;
using Server.ContextMenus;
using Server.Prompts;
using Server.Targeting;
using Server.Network;
namespace Server.Items
{
public class CorgulAltar : Item
{
[Constructable]
public CorgulAltar()
: base(0x35EF)
{
this.Name = "Sacrificial Altar";
this.Hue = 2075;
this.Movable = false;
}
public override void OnDoubleClick(Mobile from)
{
from.SendMessage("Your offering will be consumed by the altar if the sacrifice is accepted. You will then have 30 seconds to re-use the shrine to collect your new map and pay the blood cost.");
from.Target = new InternalTarget(this);
}
private class InternalTarget : Target
{
private CorgulAltar m_Item;
public InternalTarget(CorgulAltar item)
: base(2, false, TargetFlags.None)
{
m_Item = item;
}
protected override void OnTarget(Mobile from, object targeted)
{
PlayerMobile pm = from as PlayerMobile;
if (m_Item.Deleted)
return;
WorldMap wmap = targeted as WorldMap;
TreasureMap tmap = targeted as TreasureMap;
if (null == wmap || null == tmap)
{
from.SendMessage("You may only target a world map or treasure map...");
return;
}
if (targeted is TreasureMap)
{
from.SendMessage("Your offering has been accepted. The price of blood will be taken when you sacrifice your “world map”.");
tmap.Delete();
}
else
{
from.SendMessage("You must target a treasure map first.");
return;
}
if (targeted is WorldMap)
{
from.SendMessage("Your final offering has been accepted and the blood cost has been collected.");
from.Hits = 1;
from.AddToBackpack(new CorgulMap());
wmap.Delete();
}
else
{
from.SendMessage("You must target a world map.");
return;
}
}
}
public CorgulAltar(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();
}
}
}