ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So I have an error in my evo script.
CS0508: Line 182: 'EvolutionDragon.Damage(int, Mobile)': return type must be 'int' to match overridden member 'BaseCreature.Damage(int, Mobile)'
This is the line in question:

public override int Damage( int amount, Mobile defender )

I have tried to change the 'defender' to 'from' but that didn't work. Or does anyone have a working evo dragon script that works with pub 57 so I can compare? I managed to fix a lot of my errors using winmerge. But this one has me stumped.

public override void Damage( int amount, Mobile defender )
{
int kpgainmin, kpgainmax;

if ( this.Stage == 1 )
{
if ( defender is BaseCreature )
{
BaseCreature bc = (BaseCreature)defender;

if ( bc.Controlled != true )
{
kpgainmin = 5 + ( bc.HitsMax ) / 10;
kpgainmax = 5 + ( bc.HitsMax ) / 5;

this.KP += Utility.RandomList( kpgainmin, kpgainmax );
}
}
 
kpgainmin and kpgainmax are int. If you perform math with division, they could return a value that is not int. Try this:

Code:
kpgainmin = Math.Round(5 + ( bc.HitsMax ) / 10);
kpgainmax = Math.Round(5 + ( bc.HitsMax ) / 5);

This should round those to their nearest int using regular grade-school rounding rules. You can also use Math.Ceiling() to always round up and Math.Floor to always round down if you prefer.
 
Try this one!
It won't open for me after I download it. Says it is in an unknown format or file is damaged
kpgainmin and kpgainmax are int. If you perform math with division, they could return a value that is not int. Try this:

Code:
kpgainmin = Math.Round(5 + ( bc.HitsMax ) / 10);
kpgainmax = Math.Round(5 + ( bc.HitsMax ) / 5);

This should round those to their nearest int using regular grade-school rounding rules. You can also use Math.Ceiling() to always round up and Math.Floor to always round down if you prefer.
This isn't the problem I am having though.
It's this line that's the issue:
public override void Damage( int amount, Mobile defender )
 
Last edited:
Back