I am wanting to add special buffs for monsters on certain maps and I want those buffs to show up underneath the monsters name and not at the end. Ex; with Paragon title. And then I want those monsters to be able to have a limit of 3 buffs/titles from a list of buffs/titles that I create. Kind of how diablo 2/3 do their elite/champion spawns.
 
I got the titles to show up underneath monsters name using this method

if (IsParagon && IsBloodThirsty && IsFireImmune)
{
list.Add("Paragon, BloodThirsty, FireImmune");
}

else if
{
if (IsParagon && IsFireImmune)
{
list.Add("Paragon, FireImmune");
}

else if (IsBloodThirsty && IsFireImmune)
{
list.Add("BloodThirsty, FireImmune");
}

else (IsParagon && IsBloodThirsty)
{
list.Add("Paragon, BloodThirsty");
}
}

else
{
if (IsBloodThirsty)
{
list.Add("BloodThirsty");
}


else if(IsParagon)
{
list.Add("Paragon");
}

else if(IsFireImmune)
{
list.Add("FireImmune");
}
}

But I am wondering if there is an easier less lengthy method to do this using a switch block or some other way that the code can pick the titles from a list if a monster were to spawn with multiple titles and have them display next to each other underneath the monsters name.
 
C#:
    string prop = "";
    if (IsParagon)
    {
        AddToTextProperty(ref props, "Paragon");
    }
    if (IsFireImmune)
    {
        AddToTextProperty(ref props, "Fire Immune");
    }
    if (IsBloodThirsty)
    {
        AddToTextProperty(ref props, "Blood Thirsty");
    }
    list.Add(props);
}

private void AddToTextProperty(ref string props, string addition)
{
    if(String.IsNullOrWhiteSpace(props))
    {
        props = addition;
    }
    else
    {
        props += $", {addition}";
    }
}

Something like that, I guess
 
This works pretty well, only thing I am running into now is it will not show the other titles. When I add in a 2nd or third title they show up as {addition}. This is the code I have so it wouldn't give me any errors

string props = " ";
if (IsParagon)
{
AddToTextProperty(ref props, "Paragon");
}
if (IsFireImmune)
{
AddToTextProperty(ref props, "Fire Immune");
}
if (IsBloodThirsty)
{
AddToTextProperty(ref props, "Blood Thirsty");
}
list.Add(props);
}

private void AddToTextProperty(ref string props, string addition)
{
if(String.IsNullOrWhiteSpace(props))
{
props = addition;
}

else
{
props += " {addition}";
}
}

C#:
  string props = " ";
            if (IsParagon)
            {
                AddToTextProperty(ref props, "Paragon ");
            }
            if (IsFireImmune)
            {
                AddToTextProperty(ref props, "FireImmune ");
            }
            if (IsBloodThirsty)
            {
                AddToTextProperty(ref props, "BloodThirsty ");
            }
            list.Add(props);
        }

        private void AddToTextProperty(ref string props, string addition)
        {
            if(String.IsNullOrWhiteSpace(props))
            {
                props = addition;
            }
        
            else
            {
                props += addition;
            }
        }

This is what I got to work, thanks PyrO for the help. I'm garbage at creating anything but I can usually modify it somehow
 
Last edited:
well because thats not what I wrote ;) there is some different with the additional properties :p
 
I think it's safe to assume he isn't using an updated version of ServUO using CodeDom.
Post automatically merged:

maybe..

props += ", " + addition;

instead?
 
Well yes but if he had an error he should have said so, in his edit he somewhat fixed it himself, even though I wouldnt do it that way, but preferences are different ;)
Since it works for him and saves a lot of typing, job done :D
 
PyrO; I'm curious, what's the difference on a live-production-shard?
Does your method cause less lag?

or is just the professionalism appearance?
 
the Difference is that the version I posted would look like
"Paragon, Fire Immune, Blood Thirsty"

and his would be
" Paragon FireImmune BloodThirsty "

So its just the appearance yes, is my version more professional? Idk, but my reasoning is that I didnt add in a leading space and a following space.
So it may come to be off center if the following space is missed in another property.
In the end its not wrong, no real difference, just in my opinion a little cleaner.
 
When I read his reply I caught him saying this.. and how I came to the assumption.

This is the code I have so it wouldn't give me any errors
and he removed the token..

He can have the comma in the way I demonstrated.. but its just a suggestion regardless.
 
I took the $ out because it kept causing me an error. I also want the diablo 2/3 look where it just lists the monsters buffs and use of a comma seemed unneeded. I also made an extra change so the buff appears in a specific color.

13652
I do prefer to fix my own errors but as I stated before I am not great at creating my own code and need nudges in the right direction to get the ball rolling, then from there I can tweak it. This may not be the final version of it but I like to test some stuff out and see how it goes.
 
Also, just a little pointer there, since you added a lot of props to that one dragon.
You can use \n in the string to make it flip to a new line ;)

And its all good, what I gave you was a quick write up of one way to do it, you can do it how you want so yea :)
 
I haven't fully tested this since I don't have any monster spawns yet. Since all the buffs are fame based as of right now the chances of anything spawning with every buff should be super rare. I will probably create more buffs and see how often monsters spawn with multiple buffs and try to come up with a way to limit how many buffs they can spawn with.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back