RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Custom Class Item (with Targon)

Thynro

Wanderer
Hey guys, I really tried to not ask for help but I just can't seem to get this script working right....

Maybe you guys can give me some pointers on it.

Code:
public override void OnDoubleClick(Mobile from)
        {
                    //from.SendMessage("You have double clicked me!");
            from.BeginTarget( 3, false, Server.Targeting.TargetFlags.None, new TargetStateCallback( InternalCallback ), this );
    }

As you may or may not know... I'm coming from the sphere community to Runuo (and I refuse to go back, runuo has so much potential) I just can't seem to figure out some triggers like on=@targon_char or many other functions...

What I want to do with this item script. Is easy really but I just don't know how to make it in C# and I have been trying most of the day. Trying to pinch target codes from others scripts to no prevail.



I want to...

Double click said item.

Have the item open up a target

where you can target a horse

make sure the said horse is tamed or belongs to the player If !(is.mypet) function?

if checks go through target the horse and proceed with the script (multiple forms of a horse would be nice)

Trigger an effect, a sound, and remove said target (the horse)
Then replace the horse with a new custom mobile mount that I scripted.

Make the newly created horse belong to the player

Take away the players karma by -1000 after getting the new custom mobile mount.



and finally... a trigger to check if the target is a horse. if not... display a message and kill the animal(target)



Here is the code in sphere. Hopefully it gives you an idea.

Code:
ON=@DCLICK
    TARGET
    RETURN 1
ON=@TARGON_CHAR
    IF ((<SRC.TARG.ISMYPET>) && !(<SRC.TARG.SERIAL>==<SRC.SERIAL>) && (<SRC.TARG.TEVENTS>==e_horses))
        IF !(<SRC.SKILLCLASS>==cl_Paladin)
            SRC.MESSAGE You are not a Paladin.
            SRC.MESSAGE Your attempt to use this on your horse causes it to faint dead away and the backlash takes it's toll.
            SRC.TARG.KILL
            SOUND=028
            SRC.HITS=(<SRC.HITS>-50)
            SRC.EFFECT=1,049b1,16,2
            SRC.UPDATE
            RETURN 1
        ELSE
            SRC.MESSAGE You watch as your mount glorifies in your sacrificial gift
            SRC.KARMA=(<SRC.KARMA>-1000)
            SRC.TARG.REMOVE
            SRC.NEWITEM=i_pet_horse
            SRC.ACT.MORE=Cust_Thessalian
            SRC.ACT.MORE2=04e4
            SRC.ACT.COLOR=0481
            SRC.ACT.NAME=Thessalian
            SRC.ACT.BOUNCE
            SRC.ACT.DCLICK
            SRC.EFFECT=1,049b1,16,2
            SOUND=021c
            RETURN 1
        ENDIF
    ELSE
        SRC.SYSMESSAGE You are NOT doing that!
    ENDIF
    RETURN 1

The Class functions I will script in later.
 

Soteric

Knight
You have described what you want step by step. Half of work is done. As far as I see you have already created a target and passed callback to be invoked when target response is received. Keep going. Check if targeted is a creature, then check if it has a ControlMaster. Post the code here if it doesn't work or you have compilation errors.
 

pooka01

Sorceror
Remember you can look at base scripts like plant bowl, sword cut target, animal taming target, etc...
 

Dian

Sorceror
You might look at the Scripts/Skills/AnimalLore.cs script for an example of what you are trying to do.
 

Thynro

Wanderer
I have been trying this... and it seems to have an error. Could you guys perhaps tell me why??

The error is
'Server.Items.ThessalianPost.OnDoubleClick(Server.Mobile)' must declare a body because it is not marked abstract, extern, or partial.

On this line here.

Code:
}
        public override void OnDoubleClick(Mobile from);
        public static TimeSpan OnUse(Mobile m)
        {

The Full Code is Here...

Code:
}
        public override void OnDoubleClick(Mobile from);
        public static TimeSpan OnUse(Mobile m)
        {
            m.Target = new InternalTarget();
            m.SendLocalizedMessage = ( "What do you want to target?" ); // What animal should I look at?
 
            return TimeSpan.FromSeconds(1.0);
        }
 
        private class InternalTarget : Target
        {
            public InternalTarget()
                : base(8, false, TargetFlags.None)
            {
            }
 
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!target.Body.IsHorse && !IsPet(target as BaseCreature) && !(target is Mobile))
                from.message = ("You have Targeted a Horse, Congratulations!"); //Send Message
                return;
                from.message = ("That is not a horse!");
                {
 
                }
            }
        }
    }
}
 

pooka01

Sorceror
public override void OnDoubleClick(Mobile from);

to

public override void OnDoubleClick(Mobile from) {}

or just remove ondouble click if it's not used.
 

Thynro

Wanderer
I want this to trigger when I double click a said item. which brings up a target. target a horse, run a few checks, or do something else.
Giving me alot of problems, wish I knew why. I been trying to figure it out.
 

siran

Sorceror
Thynro, this should do much of what you want:
Code:
public override void OnDoubleClick (Mobile from)
        {
            if (from.Mounted) // Take this out if you don't care if the player is mounted or not
            {
                from.SendLocalizedMessage (1010097); // You cannot use this while mounted
                return;
            }
            from.BeginTarget (-1, true, TargetFlags.None, new TargetCallback (InternalTarget));
            from.SendMessage ("Whatever you want the player to be told, if anything");
        }
        public virtual void InternalTarget(Mobile from, object targ)
        {
            if (targ is Horse)
            {
                Horse h = targ as Horse;
                Point3D loc = h.Location; // The horse's location, you will need this to determine where the effect will take place & where to make the new creature appear
                Map map = h.Map; // You need this too.  The full location is the Point3D plus the map
                if (h.Controlled && h.ControlMaster == from) // This checks if the horse is controlled (tamed) and if the owner is the player attempting the double clicking
               {
                    // Trigger an effect
                    Effects.SendLocationEffect (loc, map, 0x36b0, 9, 10, 0, 0); // This is the effect of an explosion potion, replace arguments as desired
                    // Play a Sound
                    Effects.PlaySound (loc, map, 0x307); // This is an explosion sound, happening where the horse is and anyone in range can hear it.  Replace arguments as desired
                    // Create the replacement creature
                    Unicorn u = new Unicorn (); // I'm using a unicorn, replace this with your custom creature
                    // Delete the horse
                    h.Delete ();
                    // Put the new creature in the world where the horse was
                    u.MoveToWorld (loc, map); // This puts your unicorn where the horse was
                    from.Karma -= 1000; // Subtracts 1000 from karma
                    if (from.Karma < -15000) // Check to make sure karma doesn't go below -15000, the lowest desired.  You could also establish a higher "floor" if you don't want this to make dread lords/ladies.
                        from.Karma = -15000;
               }
            }
            else
                from.SendLocalizedMessage (1062089); // You cannot use that here.
        }
 

Thynro

Wanderer
Amazing! Only one problem though. The new creature created isn't tamed by the player the from person who ran the trigger.

how would you even do that?

I tried this, but no go.

Code:
h.SetControlMaster(from); //Set new mount's master to the player

Nevermind, I just got it. Thank You so much guys!

Once again, proof that Runuo community is awesome.
 

siran

Sorceror
Amazing! Only one problem though. The new creature created isn't tamed by the player the from person who ran the trigger.

how would you even do that?

I tried this, but no go.

Code:
h.SetControlMaster(from); //Set new mount's master to the player

Nevermind, I just got it. Thank You so much guys!

Once again, proof that Runuo community is awesome.

u.Controlled = true;
u.ControlMaster = from;
 
Top