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!

Setting a flag for house deed or houseplacement tool

Status
Not open for further replies.

Justin Davis

Wanderer
Hello, What I'm trying to do is have both House deeds and House placement tool available.

If you use the house placement tool you pay more for houses but you get all the money back, if you place with a deed you only get half back the money back.

Example: you would pay 44k for a Stone Plaster House deed, if you demolish you get 22k back.

If you place it with the House Placement tool you Pay 65k at house creation gump but you will get all 65k back if you demolish.

I alreasy have the Deeds and house Placement tool setup for different prices and have the vendors selling both.

What I need help in is to setup a flag in one of the scripts to differentiate between the two,
deed vrs house placement tool, upon creation, So the actual house knows what set it, deed or house placement tool upon demolish, and can give back different funds depending on what you used to create it.

I need to create a helper method or getter setter upon creation and either set a var or a bool inside but I don't know the files structure all that well, "where everything lives" and need to some advise on where I should set this.

I guess it could be set in Houses.cs and feed it to HouseDemolishGump.cs? I haven't seen anything on this at all and don't know if the logic can be implemented because it was not meant to do this. I'm new to RunUO so any advice would be helpful in leading me where I need to write that code.

Thanks
Justin
 

Enroq

Sorceror
It's easily doable, the logic is what you're changing so it matters not what its' original purpose was.

Step One: Add a boolean to your BaseHouse. You can either make it private and create an accessor or make it public.
Step Two: Find Deeds.cs in the multis folder and inside you'll find the method OnPlacement() - here is where you will set the boolean true.
Step Three: Find where players are refunded upon demolishcheck if the boolean is true, then divide it by two. The method should be like OnDelete or OnAfterDelete, and if it's not it'll by called by one of those.
 

Justin Davis

Wanderer
Thanks for the help so far Enroq,

I went to those places and set that up, but in deeds.cs that OnPlacement( Mobile from, Point3D p ) method is sitting in an abstract Class called HouseDeed. there are actually two Classes in the deeds.cs

public abstract class HouseDeed : Item

public class HousePlacementTarget : MultiTarget

I can't make an object reference to that method: OnPlacement( Mobile from, Point3D p )
from the public class: HouseDemolishGump : Gump

It can't because you can't do that with an abstract Class, and you can't change it from abstract to something else because it breaks other stuff.

I can see it "reference it" from the other Class file HouseDemolishGump but it's saying it needs an object reference like this

var deedsRef = new HouseDeed();

which you can't do with abstract, it will tell you can't create an instance of the abstract class. So I would need to know from HouseDemolishGump Class, how do I get to that bool I set in OnPlacement( Mobile from, Point3D p ) in the deeds.cs HouseDeed Class?
 

Enroq

Sorceror
I'm not sure what you're looking at. This is what mine looks like.
Code:
public void OnPlacement( Mobile from, Point3D p )
        {
            if ( Deleted )
                return;
 
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse( from ) )
            {
                from.SendLocalizedMessage( 501271 ); // You already own a house, you may not place another!
            }
            else
            {
                ArrayList toMove;
                Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z );
                HousePlacementResult res = HousePlacement.Check( from, m_MultiID, center, out toMove );
 
                switch ( res )
                {
                    case HousePlacementResult.Valid:
                    {
                        BaseHouse house = GetHouse( from );
                        house.MoveToWorld( center, from.Map );
                        Delete();
 
                        for ( int i = 0; i < toMove.Count; ++i )
                        {
                            object o = toMove[i];
 
                            if ( o is Mobile )
                                ((Mobile)o).Location = house.BanLocation;
                            else if ( o is Item )
                                ((Item)o).Location = house.BanLocation;
                        }
 
                        break;
                    }
                    case HousePlacementResult.BadItem:
                    case HousePlacementResult.BadLand:
                    case HousePlacementResult.BadStatic:
                    case HousePlacementResult.BadRegionHidden:
                    {
                        from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                        break;
                    }
                    case HousePlacementResult.NoSurface:
                    {
                        from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
                        break;
                    }
                    case HousePlacementResult.BadRegion:
                    {
                        from.SendLocalizedMessage( 501265 ); // Housing cannot be created in this area.
                        break;
                    }
                }
            }
        }
    }
 

Enroq

Sorceror
Honestly, I really don't understand what's going on. Are you trying to tell me that it looks the same?

Add this to BaseHouse.cs where the rest are declared.

Code:
        private bool fromDeed = false;
 
        public bool IsFromDeed
        {
            get { return fromDeed; }
            set { fromDeed = value; }
        }

Change this in Deeds.cs:

Code:
                    BaseHouse house = GetHouse( from );
                        house.MoveToWorld( center, from.Map );
                        Delete();

to this:

Code:
                        BaseHouse house = GetHouse( from );
                        house.MoveToWorld( center, from.Map );
 
                        house.IsFromDeed = true;
 
                        Delete();
 

Justin Davis

Wanderer
Yes those parts you wrote above I have pretty much close to the same, and ready to go, it's the call from HouseDemolishGump : Gump to the bool inside thats getting me. I have a Using statement to deed.cs but what about the rest of the path?

That whole OnPlacement( Mobile from, Point3D p ) is sitting in an abstract class which I cant make a new instance of in HouseDemolishGump because it's abstract, there are actually two Classes sitting in deeds.cs so the path is throwing my off.

You have to go through the abstract Class HouseDeed to get to the OnPlacement( Mobile from, Point3D p ) method right? Path wise that is.

I also set a var = the OnPlacement( Mobile from, Point3D p ) then tried to access the variable but did't work, it said you are trying to access a method in an abstract class or something close to that. Thanks again for looking. Very much appreciated.
 

Enroq

Sorceror
It'd be much easier if you'd just post the code you're trying to run.

I'm not sure why you're trying to do all that but all you need to do is this:

Change:
Code:
if ( m_House.IsAosRules )
                        {
                            if ( m_House.Price > 0 )
                                toGive = new BankCheck( m_House.Price );
                            else
                                toGive = m_House.GetDeed();
                        }
                        else
                        {
                            toGive = m_House.GetDeed();
 
                            if ( toGive == null && m_House.Price > 0 )
                                toGive = new BankCheck( m_House.Price );
                        }

To :
Code:
                        if ( m_House.IsAosRules )
                        {
                            if (m_House.Price > 0)
                            {
                                toGive = new BankCheck(m_House.Price);

                                if (m_House.IsFromDeed == true)
                                    toGive = new BankCheck((int)(m_House.Price / 2));
                                else
                                    toGive = m_House.GetDeed();
                            }
                        }
                        else
                        {
                            toGive = m_House.GetDeed();

                            if (toGive == null && m_House.Price > 0)
                            {
                                toGive = new BankCheck(m_House.Price);

                                if (m_House.IsFromDeed)
                                    toGive = new BankCheck((int)(m_House.Price / 2));
                            }
                        }
 

Justin Davis

Wanderer
It'd be much easier if you'd just post the code you're trying to run.




OK, this is in BaseHouse.CS

private bool m_usedTool = true;

public bool UsedHouseTool //NEW CODE
{
get { return m_usedTool; }
set { m_usedTool = value; }
}



And this is in Deeds.cs

case HousePlacementResult.Valid:
{
BaseHouse house = GetHouse(from);
house.MoveToWorld(center, from.Map);

house.UsedHouseTool = true;

Delete();


and this is in HouseDemolishGump.cs

var fromBaseHouse = new BaseHouse { };
if (m_House.IsAosRules && fromBaseHouse.UsedHouseTool == true)
{
if (m_House.Price > 0)
toGive = new BankCheck(m_House.Price);
else
toGive = new BankCheck(m_House.Price / 2);

}

Says cannot create an instance of an abstract class. Thanks
 

Enroq

Sorceror
First, if you're going to tell me you know, every time I answer a question, stop asking questions. Second, it's done, just copy and paste.
 

Justin Davis

Wanderer
First, if you're going to tell me you know, every time I answer a question, stop asking questions. Second, it's done, just copy and paste.

Umm, I'm not done, and I don't know, I meant I figured I was wrong, I'm still working on the call, but as always thanks for taking the look.
 

Enroq

Sorceror
I still don't understand - I compiled it, and it works just as you described? Am I missing something?
 

Justin Davis

Wanderer
This is the part that is hanging me up. The path from HouseDemolishGump
Server.Multis.BaseHouse.UsedHouseTool == true

Server.Multis being the namespace, I've got a using statement up top for that.
BaseHouse being the Class
UsedHouseTool being the getter setter

if (m_House.IsAosRules && BaseHouse.UsedHouseTool == true)
{
if (m_House.Price > 0)
toGive = new BankCheck(m_House.Price);
else
toGive = new BankCheck(m_House.Price / 2);

}

Says An object reference is required for the non static field, I made the getter setter static from BaseHouse but still giving me the same message.
 

Enroq

Sorceror
I'm running code I gave you, and it produces no errors and provides the features requested. If you're not going to use the code provided, I'm not going to sit here and debug for you.
 

Justin Davis

Wanderer
I'm running code I gave you, and it produces no errors and provides the features requested. If you're not going to use the code provided, I'm not going to sit here and debug for you.

Sorry man, didn't ask you to debug
 

Enroq

Sorceror
That's true, you didn't ask me to debug. You basically asked for someone to write you code, which normally people don't do. I was trying to be nice, but good luck. Even though it's right there.
 

Justin Davis

Wanderer
That's true, you didn't ask me to debug. You basically asked for someone to write you code, which normally people don't do. I was trying to be nice, but good luck. Even though it's right there.

I never asked you to write any code man, I posted my OP and you answered? where above have I asked you to write any code? I wrote my own and you wrote yours and you helped me along and I said thanks, yes yours runs through the server clean but ingame when you demolish from house deed you get no money back so it's not correct yet, it's ok I'm debugging it and appreciate the help you have given.
 

Twlizer

Sorceror
I wouldn't help this guy he has smarted off to everyone trying to help him.

specifically Justin Davis

Just my opinion
 

Justin Davis

Wanderer
Twilzer Wrote:
I wouldn't help this guy he has smarted off to everyone trying to help him.

specifically Justin Davis

Just my opinion

SECURITY! LOL, man some of the egos in here are to much man... Twilzer are you internet stalking me? Well have a good time with that and Happy Mother's day to you Twilzer :)
 
Status
Not open for further replies.
Top