Even if the item is invisible, if you are using an Xmlspawner, it will "see" the item anyway.

HHmm i think i explained myself wrong, i have a mushroom that is invisible for everyone (its like a trap) i want to make it visible for players that carry X item.

If im not wrong that involve playing with packets :) like this one

Code:
item.OPLPacket
have never done it before so is going to be hard hehe
 
You are still changing a property of said item (Visible=True/False), visible=true if player is carrying X item. :)
 
Take a look at how the Blocker and LOSBlockers work, they are invisible to all players, but can be seen by staff access. It would be a case of replacing the logic that checks for an accesslevel with logic that checks the player's pack for an item.
 
Ah yes, i finally made it, got a question, where is handled if a player can be seen or not while hidden? the CanSee method in playermobile?
 
It's more than likely all going to be in CanSee in Mobile, in the core.
I cant recompile, is there different way to handle it?

check this detect hidden script, it make hidden player visible for few seconds then they are hidden again.


Code:
//////////////////////////////////////////////////////////////////////
// Custom DetectHidden by ViWinfii
// Version 3.1415
// Date:  3-14-15
//////////////////////////////////////////////////////////////////////

using System;
using Server;
using Server.Multis;
using Server.Targeting;
using Server.Items;
using Server.Regions;
using System.Collections;
using System.Collections.Generic;
using Server.Mobiles;
using Server.Commands;
using Server.Factions;
using Server.Gumps;

namespace Server.SkillHandlers
{
    public class DetectHidden
    {
       
        public static void Initialize()
        {
            SkillInfo.Table[(int)SkillName.DetectHidden].Callback = new SkillUseCallback(OnUse);

            //CommandSystem.Register("detect", AccessLevel.Player, new CommandEventHandler(Detection));
            //CommandSystem.Register("reveal", AccessLevel.Player, new CommandEventHandler(Revealing));
        }

        public static TimeSpan OnUse(Mobile src)
        {
            //src.SendLocalizedMessage( 500819 );//Where will you search?
            //src.Target = new InternalTarget();
            src.CloseGump(typeof(DetectHiddenMenu));
            src.SendGump(new DetectHiddenMenu());
            return TimeSpan.FromSeconds(0.0);
        }
       
        //[Usage( "Detect" )]
        //[Description( "Allows you to detect hidden creatures near you. Does not require line of sight." )]
        public static void Detection(Mobile from)
        {
            Mobile src = from;

            if (DateTime.Now < src.NextSkillTime)
            {
                src.SendSkillMessage();
                return;
            }


            double srcSkill = src.Skills[SkillName.DetectHidden].Value;
            int range = (int)(srcSkill / 5.0);

            if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
                range /= 2;

            bool detectedanyone = false;
           
            if ( range > 0 )
            {
                ArrayList inRangeArray = new ArrayList();
               
                foreach ( Mobile trg in src.GetMobilesInRange( range ) )
                {
                    if( trg is PlayerMobile )
                    {
                        PlayerMobile test = trg as PlayerMobile;
                       
                        if ( trg.Hidden && src != trg )
                        {
                            double ss = srcSkill + Utility.Random( 21 ) - 10;
                            double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random( 21 ) - 10;
                            if ( (src.AccessLevel >= trg.AccessLevel) && (ss >= ts) )
                            {
                                detectedanyone = true;
                                Detecting(src, trg);
                                inRangeArray.Add(trg);
                            }
                        }
                    }
                }
               
                if(detectedanyone)
                    src.SendMessage("You detect someone nearby!");
                else
                    src.SendMessage("You didn't detect anyone nearby.");
               
                InternalTimer pause = new InternalTimer( src, inRangeArray );
                pause.Start();

                src.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(6.0);
               
            }
        }

        private static void Detecting(Mobile from, Mobile targ)
        {
           
            PlayerMobile pm = (PlayerMobile)targ;
           
            List<Mobile> list = pm.VisibilityList;
           
            list.Add( from );
           
            if ( Utility.InUpdateRange( from, targ ) )
            {
                if ( from.CanSee( targ ) )
                {
                    from.Send( new Network.MobileIncoming( from, targ ) );
                    //from.SendMessage("You have detected " + targ.Name);
                }
            }
        }

        private class InternalTimer : Timer
        {
            private Mobile m_From;
            private ArrayList m_InRange;

            public InternalTimer(Mobile from, ArrayList inRange2)
                : base(TimeSpan.FromSeconds(6.0))
            {
                m_From = from;
                m_InRange = inRange2;
            }

            protected override void OnTick()
            {
                foreach (Mobile target in m_InRange)
                {
                    Mobile TargetMobile = target;
                    PlayerMobile TargetPlayerMobile = target as PlayerMobile;

                    TargetPlayerMobile.VisibilityList.Remove(m_From);

                    if (TargetMobile.Hidden && m_From != TargetPlayerMobile)
                    {
                        if (!m_From.CanSee(TargetPlayerMobile) && Utility.InUpdateRange(m_From, TargetMobile))
                            m_From.Send(TargetPlayerMobile.RemovePacket);
                    }
                }
                m_InRange.Clear();
            }
        }
       
        //[Usage( "Reveal" )]
        //[Description( "Reveals creatures and traps that are hidden near you. Requires line of sight." )]
        public static void Revealing(Mobile from)
        {
            PlayerMobile m_From = from as PlayerMobile;
           
            m_From.RevealingAction();
           
            Rev(from, from);
        }
       
        private static void Rev( Mobile src, object targ )
        {
            if (DateTime.Now < src.NextSkillTime)
            {
                src.SendSkillMessage();
                return;
            }
           
            double srcSkill = src.Skills[SkillName.DetectHidden].Value;
            int range = (int)(srcSkill / 10.0);

            if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
                range = 0;

            bool foundAnyone = false;
            bool foundTrap = false;

            Point3D p;
            p = ((Mobile)targ).Location;

            BaseHouse house = BaseHouse.FindHouseAt( p, src.Map, 16 );
            bool inHouse = ( house != null && house.IsFriend( src ) );
           
            if ( inHouse )
                range = 22;
           
            if ( range > 0 )
            {
                foreach ( Mobile trg in src.GetMobilesInRange( range ) )
                {
                    if ( trg.Hidden && src != trg )
                    {
                        double ss = srcSkill + Utility.Random( 21 ) - 10;
                        double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random( 21 ) - 10;
                       
                        if ( (src.AccessLevel >= trg.AccessLevel) && ( (ss >= ts) || ( inHouse && house.IsInside( trg ) )) && (src.InLOS(trg)) )
                        {
                            trg.RevealingAction();
                            trg.SendLocalizedMessage( 500814 ); // You have been revealed!
                            foundAnyone = true;
                        }
                    }
                }

                if (Faction.Find(src) != null)
                {
                    IPooledEnumerable itemsInRange = src.Map.GetItemsInRange(p, range);

                    foreach (Item item in itemsInRange)
                    {
                        if (item is BaseFactionTrap)
                        {
                            BaseFactionTrap trap = (BaseFactionTrap)item;

                            if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
                            {
                                src.SendLocalizedMessage(1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)); // You reveal a trap placed by a faction:

                                trap.Visible = true;
                                trap.BeginConceal();

                                foundTrap = true;
                            }
                        }
                    }

                    itemsInRange.Free();
                }
            }

            if (!foundAnyone && !foundTrap)
            {
                src.SendLocalizedMessage(500817); // You can see nothing hidden there.
            }
            else
            {
                if (foundTrap)
                    src.SendMessage("You find a trap hidden in the shadows!");

                if (foundAnyone)
                    src.SendMessage("You find someone in the shadows!");
            }

            src.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(6.0);
        }
       
    }
}
 
I did something similar with players in party and hidden/stealth, I just used the visibility list that staff use when using the [vis command, player's stealth / hidden status isn't interrupted but the other players in the party can still see them.
 
Ahh yes ive made that command access level, so players in that region event can target their allies, how did u made the party thing? that would be even a better way :)
 
just hooked into the join party and leave party

im not being able to make that hook myself, got lots of errors im trying to add it to the OnAccept method

Code:
    public void OnAccept( Mobile from, bool force )
        {
            Faction ourFaction = Faction.Find( m_Leader );
            Faction theirFaction = Faction.Find( from );

            if ( !force && ourFaction != null && theirFaction != null && ourFaction != theirFaction )
                return;

                ///////////////see hidden party members///////////////////
                        List<Mobile> list = from.VisibilityList;   
                        Party p = Get( from );
                            list.Add( p );
                   
                       

                        if ( Utility.InUpdateRange( p, from ) )
                        {
                            NetState ns = p.NetState;

                            if (ns != null)
                            {
                                if (p.CanSee(from))
                                {
                                    if (ns.StygianAbyss)
                                        ns.Send(new MobileIncoming(p ,from));
                                    else
                                        ns.Send(new MobileIncomingOld(p,from));

                                    if (ObjectPropertyList.Enabled)
                                    {
                                        ns.Send(m.OPLPacket);

                                        foreach (Item item in from.Items)
                                            ns.Send(item.OPLPacket);
                                    }
                                }
                                else
                                {
                                    ns.Send(from.RemovePacket);
                                }
                            }
                        }
                   
                /////////////// end see ally////////////////////
           
            //  : joined the party.
            SendToAll( new MessageLocalizedAffix( Serial.MinusOne, -1, MessageType.Label, 0x3B2, 3, 1008094, "", AffixType.Prepend | AffixType.System, from.Name, "" ) );

            from.SendLocalizedMessage( 1005445 ); // You have been added to the party.

            m_Candidates.Remove( from );
            Add( from );
        }
errors:
Errors:
+ Engines/Party/Party.cs:
CS1061: Line 210: 'Server.Mobile' does not contain a definition for 'Visibil
ityList' and no extension method 'VisibilityList' accepting a first argument of
type 'Server.Mobile' could be found (are you missing a using directive or an ass
embly reference?)
CS1502: Line 212: The best overloaded method match for 'System.Collections.G
eneric.List<Server.Mobile>.Add(Server.Mobile)' has some invalid arguments
CS1503: Line 212: Argument '1': cannot convert from 'Server.Engines.PartySys
tem.Party' to 'Server.Mobile'
CS1502: Line 216: The best overloaded method match for 'Server.Utility.InUpd
ateRange(Server.Point3D, Server.Point3D)' has some invalid arguments
CS1503: Line 216: Argument '1': cannot convert from 'Server.Engines.PartySys
tem.Party' to 'Server.Point3D'
CS1503: Line 216: Argument '2': cannot convert from 'Server.Mobile' to 'Serv
er.Point3D'
CS1061: Line 218: 'Server.Engines.PartySystem.Party' does not contain a defi
nition for 'NetState' and no extension method 'NetState' accepting a first argum
ent of type 'Server.Engines.PartySystem.Party' could be found (are you missing a
using directive or an assembly reference?)
CS1061: Line 222: 'Server.Engines.PartySystem.Party' does not contain a defi
nition for 'CanSee' and no extension method 'CanSee' accepting a first argument
of type 'Server.Engines.PartySystem.Party' could be found (are you missing a usi
ng directive or an assembly reference?)
CS1502: Line 225: The best overloaded method match for 'Server.Network.Mobil
eIncoming.MobileIncoming(Server.Mobile, Server.Mobile)' has some invalid argumen
ts
CS1503: Line 225: Argument '1': cannot convert from 'Server.Engines.PartySys
tem.Party' to 'Server.Mobile'
CS1502: Line 227: The best overloaded method match for 'Server.Network.Mobil
eIncomingOld.MobileIncomingOld(Server.Mobile, Server.Mobile)' has some invalid a
rguments
CS1503: Line 227: Argument '1': cannot convert from 'Server.Engines.PartySys
tem.Party' to 'Server.Mobile'
CS0103: Line 231: The name 'm' does not exist in the current context
 
Last edited:
Back