bala1412

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
I was wondering if there is an example of a script that teleports or returns to its original location if you move away from where monsters or npc are being created beyond a certain range.
 
You can try a method like this (not tested):

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;
           }
        }
I think when the creature is not fighting,will go home.Sorry,edited with the if.
 
Last edited:
You can try a method like this (not tested):

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;
           }
        }
I think when the creature is not fighting,will go home.Sorry,edited with the if.
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.
 
Ok,you can give a try with this:

C#:
public override void OnThink()
{
  base.OnThink();
  if (this.InRange(this.Home, 25))
      this.MoveToWorld(Home, this.Map);
}
Not tested,i think when the creature go 25 tiles ahead his home,creature auto-return to home location.
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..
 
Ok,you can give a try with this:

C#:
public override void OnThink()
{
  base.OnThink();
  if (this.InRange(this.Home, 25))
      this.MoveToWorld(Home, this.Map);
}
Not tested,i think when the creature go 25 tiles ahead his home,creature auto-return to home location.
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..
Oh, I tested this. When monsters try to move somewhere, they seem to come home as soon as they move.What's the problem?
 
Holy!!!So sorry,try add "!" in this line:

C#:
if (!this.InRange(this.Home, 25))
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!
 
You can try a method like this (not tested):

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;
           }
        }
I think when the creature is not fighting,will go home.Sorry,edited with the if.
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?
 
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.
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?
 
You can try a method like this (not tested):

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;
           }
        }
I think when the creature is not fighting,will go home.Sorry,edited with the if.
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.
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back