Page 1 of 2
Problem with a virtual function
PostPosted: Fri Aug 12, 2011 4:13 pm
by Argo
Hey Gents,
got a little problem here which i need a bit of help for.
in GameNPC.cs we got this function
- Code: Select all
public virtual void AutoSetStats()
{
Strength = (short)( 20 + Level * 6 );
Constitution = (short)(30);
Dexterity = (short)(30);
Quickness = (short)(30);
Intelligence = (short)(30);
Empathy = (short)(30);
Piety = (short)(30);
Charisma = (short)(30);
}
This is perfect i thought and took this for my little nifty plan and did this:
- Code: Select all
namespace DOL.GS.Scripts
{
/// <summary>
/// This class overrides all stats for all Non Player Characters like
/// Monsters, Merchants, Guards, Steeds ...
/// </summary>
public class GameNPCOverride : GameNPC
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
const short AutoSetStatsMultiplier = 11;
public override void AutoSetStats()
{
Strength = (short)(20 + Level * 10 * AutoSetStatsMultiplier);
Quickness = (short)(60 + Level * 3);
Constitution = (short)(60 + Level * 3);
Dexterity = (short)(60 + Level * 3);
Intelligence = (short)(60 + Level * 3);
Empathy = (short)(60 + Level * 3);
Piety = (short)(60 + Level * 3);
Charisma = (short)(60 + Level * 3);
}
}
}
Thought this would workout perfect.... but no it won't. Could not find a method to override...... ?????
Where is the error in my way of thinking ? As far as i know you can override a virtual function, thus why can't the proggie find Autosetstats in gamenpc.cs for override ?
I am greatful for any advice.
kind regards
Argo
Re: Problem with a virtual function
PostPosted: Fri Aug 12, 2011 4:20 pm
by Tolakram
Looks ok to me. /shrug

Re: Problem with a virtual function
PostPosted: Fri Aug 12, 2011 4:24 pm
by geshi
Have you tried closing the entire solution down and re-opening it? sometimes (for me anyhow) it doesn't load the entire solution so things like this appear...
Re: Problem with a virtual function
PostPosted: Fri Aug 12, 2011 7:09 pm
by Argo
ok, now he goes trough the build but another problem occurs. None of the stats gets changed when i am ingame. Funny thing is, when i change it directly in gamenpc.cs it works flawless, but it shouldn't be done there. i wanna override it since i want this to be my class for whatever changes i wanna make on the mobs in the gameworld.
Re: Problem with a virtual function
PostPosted: Fri Aug 12, 2011 9:43 pm
by Graveen
Argo, can you put a log.Debug() or log.Warning() into your autosetstats to see if you trigger it correctly ?
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 12:18 am
by Argo
Argo, can you put a log.Debug() or log.Warning() into your autosetstats to see if you trigger it correctly ?
This is what it looks now. It doesn't give me any errors and it is not triggered at all. Dunno why. OH and don't wonder about the serverproperty, i created this tonight
- Code: Select all
namespace DOL.GS
{
/// <summary>
/// This class overrides all stats for all Non Player Characters like
/// Monsters, Merchants, Guards, Steeds ...
/// </summary>
public class GameNPCOverride : GameNPC
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public override void AutoSetStats()
{
log.Warn("ENTERING PUBLIC OVERRIDE VOID AUTOSETSTATS");
Strength = (short)(20 + Level * 10 * ServerProperties.Properties.AUTO_SET_STATS_MULTIPLIER);
Quickness = (short)(60 + Level * 3);
Constitution = (short)(60 + Level * 3);
Dexterity = (short)(60 + Level * 3);
Intelligence = (short)(60 + Level * 3);
Empathy = (short)(60 + Level * 3);
Piety = (short)(60 + Level * 3);
Charisma = (short)(60 + Level * 3);
}
}
}
If you wanna use it, here is the created Serverproperty:
- Code: Select all
INSERT INTO `serverproperty` (`Category`, `Key`, `Description`, `DefaultValue`, `Value`, `ServerProperty_ID`) VALUES ('rates', 'mob_damage_multiplier', 'How hard will mobs hit?', '12', '10', '64a6387d-c9ba-4c55-8a36-bf136f684617');
serverproperty.cs
- Code: Select all
/// <summary>
/// How much damage do the mobs dish out to the player
/// </summary>
[ServerProperty("rates", "mob_damage_multiplier", "How hard will mobs hit?", (short)12)]
public static short AUTO_SET_STATS_MULTIPLIER = 12;
On a short sidenote, with this damagemultiplier does daoc feel like in the old days, you never know if you will win or lose the fight. Blue = win, yellow = win but could sometimes also a lose, orange is mostly lose, red and purple..... hey don't even considder trying

Tested it meanwhile on Gamenpc.cs and fought a few mobs in my OF zone.... AWESOME experience
kind regards
Argo
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 3:17 am
by Ephemeral
Are you trying to assume that this 'Override' class is going to act the same as the serverproperty that allows you to choose a GamePlayer override for the server to use?
Because you can't just do that, there is no available option at the moment to choose such a thing.
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 8:47 am
by Argo
I am trying to override the
- Code: Select all
public virtual void AutoSetStats()
{
.
.
.
}
in gamenpc.cs
by
- Code: Select all
Public override void AutoSetStats()
{
.
.
.
}
in gamenpcoverride.cs, which should work actually but doesn't.
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 11:04 am
by geshi
Yea but you did /mob create DOL.GS.Scripts.GameNPCOverride right? or /mob class DOL.GS.Scritps.GameNPCOverride ?
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 11:28 am
by Argo
Yea but you did /mob create DOL.GS.Scripts.GameNPCOverride right? or /mob class DOL.GS.Scritps.GameNPCOverride ?
The plan is not to create any new mob with it, the plan is to beef the stats of the existing mobs in albion. thus those mobs that have as class DOL.GS.GameNPC but instead of using the autosetstats function in GameNPC.cs i wanna override it with my class GameNPCOverride and beef up only the stats that are written in autosetstats
to be clear, all i wanna do is overriding the method autosetstats in gamenpc.cs without changing a mobs class and withouth creating any new mob. all i want is using my autosetstats instead of the one in GameNPC.cs.
kind regards
Argo
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 11:37 am
by geshi
Well that's not really possible.. you have to change the mob class..
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 12:33 pm
by Tolakram
Yes argo, you would have to change the mob class for all mobs.
we currently have
'npc', 'mob_damage_increase_perlevel', 'How much damage to increase per level', '0', '5'
'npc', 'mob_damage_increase_startlevel', 'What level to start increasing mob damage.', '30', '45'
I suggest making it a double and having the default value be 1.0, placing it with the other damage properties
- Code: Select all
[ServerProperty("npc", "mob_autoset_str_multiplier", "Multiplier to use when auto-setting STR stat.", 1.0)]
public static double MOB_AUTOSET_STR_MULTIPLIER;
Do not assign the static double a value or it can never be changed via server properties.

Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 1:39 pm
by Argo
Yes argo, you would have to change the mob class for all mobs.
we currently have
'npc', 'mob_damage_increase_perlevel', 'How much damage to increase per level', '0', '5'
'npc', 'mob_damage_increase_startlevel', 'What level to start increasing mob damage.', '30', '45'
I suggest making it a double and having the default value be 1.0, placing it with the other damage properties
- Code: Select all
[ServerProperty("npc", "mob_autoset_str_multiplier", "Multiplier to use when auto-setting STR stat.", 1.0)]
public static double MOB_AUTOSET_STR_MULTIPLIER;
Do not assign the static double a value or it can never be changed via server properties.

Thx Tola, i'll try it that way

Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 1:52 pm
by Argo
Do not assign the static double a value or it can never be changed via server properties.

BTW:
- Code: Select all
/// <summary>
/// Under level 35 mount speed, live like = 135
/// </summary>
[ServerProperty("rates", "mount_under_level_35_speed", "What is the speed of player controlled mounts under level 35?", (short)135)]
public static short MOUNT_UNDER_LEVEL_35_SPEED = 135;
/// <summary>
/// Over level 35 mount speed, live like = 145
/// </summary>
[ServerProperty("rates", "mount_over_level_35_speed", "What is the speed of player controlled mounts over level 35?", (short)145)]
public static short MOUNT_OVER_LEVEL_35_SPEED = 145;
This is how i found it in serverproperty.cs, and that's why i assigned a value to my sp, but reading your comment, i asume that whoever did it for mount, did it wrong ?
kind regards
Argo
Re: Problem with a virtual function
PostPosted: Sat Aug 13, 2011 2:52 pm
by geshi
Hmm that was me I think.. I remember testing it and it worked fine
