Problem with a virtual function

Get support with your problems on Storm

Moderators: Project Admin, Support Team

Problem with a virtual function

Postby Argo » Fri Aug 12, 2011 4:13 pm

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
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby Tolakram » Fri Aug 12, 2011 4:20 pm

Looks ok to me. /shrug :(
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Problem with a virtual function

Postby geshi » Fri Aug 12, 2011 4:24 pm

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...
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm

Re: Problem with a virtual function

Postby Argo » Fri Aug 12, 2011 7:09 pm

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.
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby Graveen » Fri Aug 12, 2011 9:43 pm

Argo, can you put a log.Debug() or log.Warning() into your autosetstats to see if you trigger it correctly ?
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12661
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Problem with a virtual function

Postby Argo » Sat Aug 13, 2011 12:18 am

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 :D
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 :mrgreen: Tested it meanwhile on Gamenpc.cs and fought a few mobs in my OF zone.... AWESOME experience :mrgreen:
kind regards
Argo
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby Ephemeral » Sat Aug 13, 2011 3:17 am

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.
"The swarm is always smarter, faster and more adept than any actor which seeks to thwart it."
C++, Java, C#, VB.NET, ASM.
Current Project:
Engine Developer for The Red Solstice
User avatar
Ephemeral
DOL Freak
 
Posts: 554
Joined: Wed Mar 30, 2011 12:23 am

Re: Problem with a virtual function

Postby Argo » Sat Aug 13, 2011 8:47 am

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.
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby geshi » Sat Aug 13, 2011 11:04 am

Yea but you did /mob create DOL.GS.Scripts.GameNPCOverride right? or /mob class DOL.GS.Scritps.GameNPCOverride ?
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm

Re: Problem with a virtual function

Postby Argo » Sat Aug 13, 2011 11:28 am

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
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby geshi » Sat Aug 13, 2011 11:37 am

Well that's not really possible.. you have to change the mob class..
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm

Re: Problem with a virtual function

Postby Tolakram » Sat Aug 13, 2011 12:33 pm

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. ;)
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Problem with a virtual function

Postby Argo » Sat Aug 13, 2011 1:39 pm

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 :)
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby Argo » Sat Aug 13, 2011 1:52 pm

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 ? :mrgreen:

kind regards
Argo
Möge Gott sein zwischen Dir und dem Leid, an allen dunklen und verlassenen Orten, die Du erreichen wirst.
Argo
Server Team
 
Posts: 1760
Joined: Thu Sep 18, 2008 6:21 pm
Location: Berlin, Germany

Re: Problem with a virtual function

Postby geshi » Sat Aug 13, 2011 2:52 pm

Hmm that was me I think.. I remember testing it and it worked fine :shock:
geshi
Contributor
 
Posts: 1826
Joined: Tue Oct 21, 2008 9:16 pm


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 0 guests