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!

Mobile Death

MarciXs

Sorceror
Mobile Death

why is it that Region.OnDeath( this ); happens before OnDeath( c ); ? What's the exact reason for it?

I mean if you check in your region for alive Mobiles. It will say it's alive cause Alive is set to false when the body is a ghost... and that happens only during OnDeath. So just wondering why? why not
OnDeath(c)
Region.OnDeath(this) ?
 

Pure Insanity

Sorceror
Do do all the needed work before adding the loot to the corpse. OnDeath( c ) is to add loot, the c variable is a container. Perhaps it needs to dish out exp or w/e to the person that killed it first? Then it'll add the loot to the corpse.
 

MarciXs

Sorceror
James420;858035 said:
Do do all the needed work before adding the loot to the corpse. OnDeath( c ) is to add loot, the c variable is a container. Perhaps it needs to dish out exp or w/e to the person that killed it first? Then it'll add the loot to the corpse.

See my problem is this
public class MyREgion : BaseRegion
{
public override void OnDeath(Mobile m)
{
if(!m.Alive)
m.Resurrect(); // Won't work cause the mobile is still alive...

}
And I know that PlayerDeath event but see the thing is I don't want to use it cause. I find it pointless to check if that's the mobile I need I mean. Imagine I had 100 players playing. To iterate through 100 players every time and see if he/she is at the right region(meaning any of those players can die, basically going through Region Check-ups on a Mobile who isn't even where I need it to be...)... it's just pointless... I know that there are other ways to resurrect with the OnBeforeDeath etc. Different ways... but It's not the resurrection that I need it's the reason for this. Like why is it the way it is? If you check the OnDeath(c) there's nothing that can't be done before the REgion death ... Like basically why is the Mobile supposed to be alive when he's dead in the region?

Code:
public virtual void OnDeath( Container c )
		{
			int sound = this.GetDeathSound();

			if( sound >= 0 )
				Effects.PlaySound( this, this.Map, sound );

			if( !m_Player )
			{
				Delete();
			}
			else
			{
				Send( DeathStatus.Instantiate( true ) );

				Warmode = false;

				BodyMod = 0;
				//Body = this.Female ? 0x193 : 0x192;
				Body = this.Race.GhostBody( this );

				Item deathShroud = new Item( 0x204E );

				deathShroud.Movable = false;
				deathShroud.Layer = Layer.OuterTorso;

				AddItem( deathShroud );

				m_Items.Remove( deathShroud );
				m_Items.Insert( 0, deathShroud );

				Poison = null;
				Combatant = null;

				Hits = 0;
				Stam = 0;
				Mana = 0;

				EventSink.InvokePlayerDeath( new PlayerDeathEventArgs( this ) );

				ProcessDeltaQueue();

				Send( DeathStatus.Instantiate( false ) );

				CheckStatTimers();
			}
		}
 

Pure Insanity

Sorceror
Sure there is an easier way, but there's also a bunch of other ways to do something like this.

Could have it add an invisible item to the players body or bag when they enter the region, remove it when they leave. That item could be set movable and blessed so it stays with the person, and then use that item to auto res people. There are plenty of items already made and posted you could use to res the person. But doing it this way, would mean you could simply use the Enter and Exit methods of the region.
 

MarciXs

Sorceror
James420;858060 said:
Sure there is an easier way, but there's also a bunch of other ways to do something like this.

Could have it add an invisible item to the players body or bag when they enter the region, remove it when they leave. That item could be set movable and blessed so it stays with the person, and then use that item to auto res people. There are plenty of items already made and posted you could use to res the person. But doing it this way, would mean you could simply use the Enter and Exit methods of the region.

That's the thing James I don't need invisible items...And as I said before I don't need the resurrection as much as the answer why is it the way it is? It's one part of the mystery that I've found regarding Regions. The other is that if you had Region A and Region B and inside region's A OnEnter you would move the player m.MoveToWorld to the Region B area the player got stuck between those two regions. If he said something he doubled it. Like saying bank makes your character to say bank twice... do it more times and you'll get an disconnect for too much data pending(meaning enter/leave about 10 times will make you say the same text as many times)...

But in any case I'll have this my first ever Core mod now... as it's made my life much easier.
 

Tabain

Sorceror
It's so you can do things like having regions where you can't die.

Why are you trying to resurrect somebody in the same method that kills it, or better yet, check if they're alive in code that can only be executed before they die? Just do whatever you want and then return the base ondeath method and the person will die after that.
 

MarciXs

Sorceror
Tabain;858249 said:
It's so you can do things like having regions where you can't die.

Why are you trying to resurrect somebody in the same method that kills it, or better yet, check if they're alive in code that can only be executed before they die? Just do whatever you want and then return the base ondeath method and the person will die after that.

The person doesn't die in the region that's the thing..what I mean was as far as I know you can't stop person from dying with Region.OnDeath method... And can I just make clear that it's not about resurrecting the person?
let's image I'm building some system okay ..
I've simplified it as much as I can...
public class CatchMeGame
{
private RegiSystem _Reg;
public CatchMeGame(RegiSystem r)
{
_Reg = r;

}
public bool CheckWin() // if one is alive the game is over, basically one wins...
{
int d = 0; // hurray for dirty code
foreach(Mobile m in _Reg.GetMobiles())
{
if(m is PlayerMobile && m.Alive)
{
d+=1;
}
}
return (d==1);
}

}

now best place to check their death is where? Listen to every player's death handler? This is a game that would happen in just one small area. Here we go then
public class RegiSystem : BaseRegion
{
public override void OnDeath(Mobile m)
{
/* it would get the reference to the Catch me from a added attribute to the region which it would get from a static list that held all of the "games"...*/
this.Game.CheckWin(); // < this would never be true.. Cause if there are two people playing both of them are always alive inside the region...
// You might say okay why not do CheckWin(Mobile exlude) ... but see that's just a way out of it. Now I had // to do if(m is PlayerMobile && m != exlude)
// The question is why does it has to be that in Region the character dies first?

}

}
 

Tabain

Sorceror
Best place to put it is in OnBeforeDeath and return so they won't die. Then teleport them outside of the region, and check win conditions in the region.
 

MarciXs

Sorceror
Tabain;858302 said:
Best place to put it is in OnBeforeDeath and return so they won't die. Then teleport them outside of the region, and check win conditions in the region.

OnBeforeDeath what for..? First off, how can I tell the player is dead? If I have a list of mobiles. To check for Alive property no? So how would OnBeforeDeath help? It wouldn't solve anything... I mean without going the weird way of checking CheckWin(Mobile theExcludedOne) ...

See you don't quite understand what I'm trying to say. You think that I need some help with a script but in reality, all I want to know is why is the Mobile "dead" in the region before he/she is actually dead. Meaning the Alive is false and not "kind of dead".
All I want to know is why
Region.OnDeath(Mobile m)
happens before (from Mobile) OnDeath(Container c) and not the other way around?
 
it is checking the region 1st, just does not "kill" them yet, it passes along the stuff so they get processed by the mobile ondeath then, etc

just do something liek this in your region:

Code:
		public override void OnDeath( Mobile m )
		{
			if ( m is PlayerMobile )
			{
				m.X = 1234; //place for waiting for end, etc
				m.Y = 234;
				m.Z = 0;
			}
			else base.OnDeath( m )
		}

and they should not die
 

MarciXs

Sorceror
Lord_Greywolf;858332 said:
it is checking the region 1st, just does not "kill" them yet, it passes along the stuff so they get processed by the mobile ondeath then, etc

just do something liek this in your region:

Code:
		public override void OnDeath( Mobile m )
		{
			if ( m is PlayerMobile )
			{
				m.X = 1234; //place for waiting for end, etc
				m.Y = 234;
				m.Z = 0;
			}
			else base.OnDeath( m )
		}

and they should not die
I know that the mobile isn't dead in OnDeath method that's the whole post is about. Why should the player be alive but dead inside the region? What's the exact point of it?
I mean why shouldn't the Region have a method that tells that an Mobile has actually died there?

hmm, I haven't tried the code but for what I understand there's no way to stop the player from dying in OnDeath method... I mean even if you would return it(the OnDeath) it doesn't mean that OnDeath(Container c) insde Mobile won't proceed...
I mean it's
Region.OnDeath(this) <-- return it if you like but
OnDeath(c) < -- will proceed anyway...
 

Jeff

Lord
if you want to stop a mobile from being killed you have to override Kill and return before base.Kill happens...


the order is Kill -> Region.OnDeath -> m.OnDeath
 

MarciXs

Sorceror
Jeff;858371 said:
if you want to stop a mobile from being killed you have to override Kill and return before base.Kill happens...


the order is Kill -> Region.OnDeath -> m.OnDeath

And yet nobody has explained why is the order the way it is for the Region.OnDeath and m.OnDeath ... why isn't it Kill>m.OnDeath(..)>Region.OnDeath(m) That's what I made this post about :(
 

Jeff

Lord
MarciXs;858373 said:
And yet nobody has explained why is the order the way it is for the Region.OnDeath and m.OnDeath ... why isn't it Kill>m.OnDeath(..)>Region.OnDeath(m) That's what I made this post about :(

Because it wasn't coded that way... Do you really need a reason? If you don't like it, change it...
 
try my code in the region script for it
it should never get to the ondeath in mobile (or playermobile) because it is no longer being passed on
 

Tabain

Sorceror
It's coded that way because it makes no sense to first run the base code that kills the mobile and then run any region code, as the region code would be pretty much useless if it can't intercept the death event.

You've got about 3 different ways of doing what you want so far without changing the priority of core code.

For the hell of it, here's another way to do it:

Use an eventsink.
 
Top