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?
}
}