Iomega0318

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
Is there anything that does splash damage, or splash heal, trying to find something to borrow some code from but I can't think of anything that does this.

What I'm trying to do is throw a potion and cause an area of effect to happen.
 
Explosion potions would be the closest thing I would imagine and it would already contain the code for throwing it and showing the animation.
 
Hmm I kinda got it to half work but I'm trying to target a creature and it is set to player mobile, I added in some code and it crashed..
C#:
Unable to cast object of type 'Server.Mobiles.PlayerMobile' to type 'Server.Mobiles.BaseCreature'
so changed the list to BaseCreature instead of Mobile and got:
C#:
Argument 1: cannot convert from 'Server.Mobile' to 'Server.Mobiles.BaseCreature'
from:
C#:
            if (from != null && damageThrower && !list.Contains(from))
            {
                list.Add(from);
            }
Messing with the BaseExplosionPotion.
 
Unfortunately despite still using RunUO, I did make this a while back. Not sure if its exactly what you're looking for. But who knows, maybe it might help better guide you in the direction you wanna go in.
 

Attachments

  • IbongAdarna (healing bird).cs
    7.2 KB · Views: 9
Hmm I kinda got it to half work but I'm trying to target a creature and it is set to player mobile, I added in some code and it crashed..
C#:
Unable to cast object of type 'Server.Mobiles.PlayerMobile' to type 'Server.Mobiles.BaseCreature'
so changed the list to BaseCreature instead of Mobile and got:
C#:
Argument 1: cannot convert from 'Server.Mobile' to 'Server.Mobiles.BaseCreature'
from:
C#:
            if (from != null && damageThrower && !list.Contains(from))
            {
                list.Add(from);
            }
Messing with the BaseExplosionPotion.
So, are you trying to have the BaseCreature be the one throwing the potion? If so, similar to the thread about paragons, you would need to cast Mobile as BaseCreature;

if (from is BaseCreature);
BaseCreature bc = (BaseCreature)from;

or use pattern matching if you're able meaning;

if (from is BaseCreature bc);

Otherwise, explosion potions and your potion should already damage creatures as well as able to be set as the target.
 
No the target would be BaseCreature, I just assumed the list in the explosion potion was only for Player Mobiles from the crash. I put my paragon code in the list to apply it to the list lol that's what caused my crash. Thanks Zig I'll check it out.
 
No the target would be BaseCreature, I just assumed the list in the explosion potion was only for Player Mobiles from the crash. I put my paragon code in the list to apply it to the list lol that's what caused my crash. Thanks Zig I'll check it out.
Ah, ok. The reason you're getting the PlayerMobile cast to type BaseCreature then is because the !list.Contains(from) is adding the person throwing the potion to the list. This is done with explosion potion so that the thrower will still be damaged if standing too close.

So what you would need to do is, make the foreach only look for each BaseCreature in the list and either IsParagon or !IsParagon depending on which you're wanting that particular potion to use.
Paragon Splash:
foreach (BaseCreature bc in list)
{
    if (!bc.IsParagon && !bc.Controlled)
    {
        IsParagon = true;
        from.SendMessage("The effects of the potion turn all of the creatures into paragons.");
    }
}

The SpellHelper.AcquireIndirectTargets will add all mobiles to the list with the foreach ensuring it is only BaseCreatures that are not paragon will be affected. If you want pets affected, simple removed the !bc.Controlled to have them turn into paragons as well.

You can remove this code since you do not want the person throwing the potion added to the list for any reason.
Remove This Code:
            if (from != null && damageThrower && !list.Contains(from))
            {
                list.Add(from);
            }
 
Last edited:
Ah, ok. The reason you're getting the PlayerMobile cast to type BaseCreature then is because the !list.Contains(from) is adding the person throwing the potion to the list. This is done with explosion potion so that the thrower will still be damaged if standing too close.

So what you would need to do is, make the foreach only look for each BaseCreature in the list and either IsParagon or !IsParagon depending on which you're wanting that particular potion to use.
Paragon Splash:
foreach (BaseCreature bc in list)
{
    if (!bc.IsParagon && !bc.Controlled)
    {
        IsParagon = true;
        from.SendMessage("The effects of the potion turn all of the creatures into paragons.");
    }
}

The SpellHelper.AcquireIndirectTargets will add all mobiles to the list with the foreach ensuring it is only BaseCreatures that are not paragon will be affected. If you want pets affected, simple removed the !bc.Controlled to have them turn into paragons as well.

You can remove this code since you do not want the person throwing the potion added to the list for any reason.
Remove This Code:
            if (from != null && damageThrower && !list.Contains(from))
            {
                list.Add(from);
            }
That makes sense now, thank you.
Last question, I have it working now but the message spams for each mobile in the list is there a way to display the message only once?
 
Last edited:
That makes sense now, thank you.
Last question, I have it working now but the message spams for each mobile in the list is there a way to display the message only once?
Simple way would be to set up an int to keep track like so;


Keep Track:
//this is outside foreach
int msgcount = 0;

//this is inside foreach
if (list.Count >= 1 && msgcount == 0)
{
    from.SendMessage("Message here");
    msgcount++;
}

I believe that should work anyway.
 
Simple way would be to set up an int to keep track like so;


Keep Track:
//this is outside foreach
int msgcount = 0;

//this is inside foreach
if (list.Count >= 1 && msgcount == 0)
{
    from.SendMessage("Message here");
    msgcount++;
}

I believe that should work anyway.
That did the trick! Thank you!
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back