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!

Small fix for CanBeDamaged function

pinco

Sorceror
Small fix for CanBeDamaged function

The canbedamaged function never control if the mobile is alive or not.

You can found the standard function in mobile.cs at line 4900 about...:
Code:
[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]virtual [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] CanBeDamaged()
{
[/SIZE][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] !m_Blessed;
}
[/SIZE]

overwrite the function with this new one:

Code:
[SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]virtual [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][SIZE=2] CanBeDamaged()
{
[/SIZE][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] !m_Blessed && Alive;
}
[/SIZE]

recompile and the bug is solve ;)
 

Greystar

Wanderer
pinco said:
I didn't like the overwrite if I can change the original...

I just responded the way I did since a modified core can prevent you from getting support, that is all. I don't care personally either way...
 

Shadow1980

Wanderer
pinco said:
I know, but in the copy & past the space was trimmed -.-

So you post a core change, imo a quite significant thing to do, and you don't even put down correct code.
It doesn't take all that much work to put the spaces back in...

I have to agree with Greystar / Phantom as well, why would you bother making a core change if you really don't have to??
 

pinco

Sorceror
1) I have corrected the post
2) I dont told you to do the modding, if you like it, do it, else do everything you want, we are in a free cuntry :p
3) I dont read posting limitation in this forum, if you dislike my suggestions I take for myself, no problem, I gain nothing to post here.
 

Shadow1980

Wanderer
pinco said:
1) I have corrected the post
2) I dont told you to do the modding, if you like it, do it, else do everything you want, we are in a free cuntry :p
3) I dont read posting limitation in this forum, if you dislike my suggestions I take for myself, no problem, I gain nothing to post here.

1) Good job.
2) I never said you shouldn't post the change, but when you do it's good to get it right.
3) Que?

psz said:
This forum is for discussing and posting core changes. That's what he did.

And we discussed it as well. I don't see the problem.

The only reason I replied is because I dislike it when people post a "fix" that can have a rather significant impact on somebodies files, and then don't even post correct code.
I know, people should be able to spot this themselves but we all know there are plenty of poeple here who only download/use other people their changes and files and who know practically nothing about RunUO or coding. Even though I personally think those people don't really belong in the community, we have to give them a chance to start somewhere and provide them with clear and accurate information. Nothing is worse then learning from incorrect code.
Just my 2 cents.
 

psz

Administrator
Incorrect code is a problem, yes.

As for severely impacting the code, that's kinda what the forum is for ;-> If someone's reading this forum, they are already editing the core most likely.
 

noobie

Wanderer
i think it is more "appropriate" to do it in the core logically..
if you are so afraid to modify it, why even does this forum exist :)
 

jpmythic

Sorceror
I know this is an Old Post, but I thought I'd mention that in AOS.cs:

Code:
		public static int Damage( Mobile m, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, bool keepAlive )
		{
			if ( m == null || m.Deleted || !m.Alive || damage <= 0 )
				return 0;

It does a basic check for Alive status on general Damage types.
BUT, changing it in BaseCreatures.cs can affect the majority of them, and then you can overide in the few others that Create Mobiles from Base Mobile.cs

Otherwise, you can just do it in the Core or Create your OWN Mobile.cs that
Inherets from Mobile.cs and takes the Place of Mobile.cs for the Other Files.
Altho I think this has been discussed many times before.

'my two cents worth'
 

Kamron

Knight
The reason why this was not put into the core is just for that reason. Maybe someone wants to make a dead mobile which can be damaged.... I dunno why, but just maybe. It is NOT a bug because the check is in AOS.cs like you stated, where if the CanBeDamaged function fails, the Alive check will correct it once they are attempted to be damaged.

mobile.Damage() -> Aos.Damage, so there is no reason for this modification at all.
 
Top