public override void OnCombatantChange()
{
if (Combatant == null && !Controlled && ControlMaster == null && this.Alive)
{
BaseCreature bc = this as BaseCreature;
Point3D from = bc.Location;
Point3D to = bc.Home;
Effects.SendLocationParticles(EffectItem.Create(from, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
Effects.SendLocationParticles(EffectItem.Create(to, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
bc.PlaySound(510);
bc.Location = bc.Home;
}
}
Wow! I tested it and it works perfectly! As you said, when the creature doesn't fight, it goes back to its original position. I'm sorry, but is there a way to get him back when he's more than a certain distance away during the fight? I'm sorry to have bothered you.You can try a method like this (not tested):
I think when the creature is not fighting,will go home.Sorry,edited with the if.C#:public override void OnCombatantChange() { if (Combatant == null && !Controlled && ControlMaster == null) { BaseCreature bc = this as BaseCreature; Point3D from = bc.Location; Point3D to = bc.Home; Effects.SendLocationParticles(EffectItem.Create(from, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023); Effects.SendLocationParticles(EffectItem.Create(to, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); bc.PlaySound(510); bc.Location = bc.Home; } }
public override void OnThink()
{
base.OnThink();
if (this.InRange(this.Home, 25))
this.MoveToWorld(Home, this.Map);
}
Oh, I tested this. When monsters try to move somewhere, they seem to come home as soon as they move.What's the problem?Ok,you can give a try with this:
Not tested,i think when the creature go 25 tiles ahead his home,creature auto-return to home location.C#:public override void OnThink() { base.OnThink(); if (this.InRange(this.Home, 25)) this.MoveToWorld(Home, this.Map); }
You can test with 2-3 tiles,so change the 25,and test 2-4 to see if it works.
You can also add the particles and sounds in the other code,or just use the two methods in the same script..
You don't have to be sorry at all. Rather, thank you so much for answering quickly. It works perfectly well and has been tested. Thanks to this, we can deploy guards comfortably in the village. Thank you from the bottom of my heart!Holy!!!So sorry,try add "!" in this line:
C#:if (!this.InRange(this.Home, 25))
It can be used for monsters in the "Mobiles" folder as well as for npc.what .cs file did you put this into?
You can try a method like this (not tested):
I think when the creature is not fighting,will go home.Sorry,edited with the if.C#:public override void OnCombatantChange() { if (Combatant == null && !Controlled && ControlMaster == null && this.Alive) { BaseCreature bc = this as BaseCreature; Point3D from = bc.Location; Point3D to = bc.Home; Effects.SendLocationParticles(EffectItem.Create(from, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023); Effects.SendLocationParticles(EffectItem.Create(to, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); bc.PlaySound(510); bc.Location = bc.Home; } }
Long time no see. I have a question. If you kill a monster when you apply the above script, you will have a problem returning to where the monster's body is respawn. Is there a way to solve this?public override void OnCombatantChange()
{
if (Combatant == null && !Controlled && ControlMaster == null && this.Alive)
{
BaseCreature bc = this as BaseCreature;
Point3D from = bc.Location;
Point3D to = bc.Home;
Effects.SendLocationParticles(EffectItem.Create(from, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
Effects.SendLocationParticles(EffectItem.Create(to, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
bc.PlaySound(510);
bc.Location = bc.Home;
}
}
It's okay! You can take your time! I'm always free! Thank you so much for your care.Ouch,i will get an eye on this tonight,sorry now i cant.
Thank you for your quick reply! But I don't know how to use this item. Can you tell me how to use it?You can place this in-game:
Credits from this tile are to tass23.
Oh! Thank you for telling me how to use it. But the problem I'm having is that when a monster moves from the Respawn location dies, the corpse teleports to the home instead of the corpse forming at the location where it moves. Is there a way to solve the problem?Sure,this is just a tile,you can place some of them at floor,if the mob try to moveover the tile,he come to his Home location.
Aha! I didn't have enough understanding. I've figured out how to apply it. Thank you from the bottom of my heart!Yes,just remove the code and use this tile.
I'm so sorry! I have one more question. Can I have the above script triggered five minutes after the battle? I'm wondering if there's a way to invoke it five minutes after the battle, instead of invoking it as soon as it's over! If that's possible, I think we can get the body back to the groove after the set time. I'm sorry to keep bothering you.You can try a method like this (not tested):
I think when the creature is not fighting,will go home.Sorry,edited with the if.C#:public override void OnCombatantChange() { if (Combatant == null && !Controlled && ControlMaster == null && this.Alive) { BaseCreature bc = this as BaseCreature; Point3D from = bc.Location; Point3D to = bc.Home; Effects.SendLocationParticles(EffectItem.Create(from, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023); Effects.SendLocationParticles(EffectItem.Create(to, bc.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); bc.PlaySound(510); bc.Location = bc.Home; } }
We use essential cookies to make this site work, and optional cookies to enhance your experience.