I want to increase all creature damage by 10%
I tried this in BaseCreature:
Code:
public void SetDamage(int min, int max)
		{
			m_DamageMin = min;
			m_DamageMax = max + (max * 0.10);
		}


And got these Errors:
Code:
+ custom/BaseCreature.cs:
    CS0266: Line 3925: Cannot implicitly convert type 'double' to 'int'. An expl
icit conversion exists (are you missing a cast?)
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Hello again! Will this change effect creature spell damage or just melee? I have fumbled my way into a server thats almost what I was shooting for but creature melee damage is horrible. With gm leather armor all of the mid level creatures hit for 1 damage. The server is set to pre-aos so the armor is the classic type.
 
I do not know if anyone else will have this problem but if they do, this is what I did to correct it.

Code:
	public void SetDamage(int min, int max)
		{
			m_DamageMin = min + (min * 4);
			m_DamageMax = max + (max * 4);
		}
With this change along with a random critical strike code. I can no longer stand toe to toe with an ettin in gm leather armor while watching tv and updating my facebook status.
 
I do not know if anyone else will have this problem but if they do, this is what I did to correct it.

Code:
	public void SetDamage(int min, int max)
		{
			m_DamageMin = min + (min * 4);
			m_DamageMax = max + (max * 4);
		}
With this change along with a random critical strike code. I can no longer stand toe to toe with an ettin in gm leather armor while watching tv and updating my facebook status.

What you did here shows one of the fundamental quirks of C#. When you're multiplying by a static number like that you will end up with an integer value (no decimals!), however, say you wanted to only add 10% damage rather than 400% as you have, then you'd use what @Lokai has suggested.

The reason this happens is because you've added a decimal point (in your case it was 0.10), C# sees that as a double rather than an int, so you have to convert it back to an int (and that's why Lokai suggested you add (int) beforehand). What this will effectively do is just strip off everything after the decimal point (1.024 becomes 1; but 1.99 also becomes 1 - so be careful with that!).

I'd suggest keeping it as a double to add more flexibility and setting it as a private value for the class at the top. It's great if 4.0 was the EXACT value that worked out for you, but if you needed to tinker with it slightly you'd need to change it to a double (otherwise you can only put it up to 5 or down to 3).


Will this change effect creature spell damage or just melee?

Changing the creature damage where you have is only for melee. Creature spell damage is set elsewhere and calculated based on factors such as difference between the caster's evalint vs. the victim's magicresist.
 
Thanks everyone. I have been doing everything by trial and error as I go. I have no experience with C# so i have to rely a lot on luck, google, and you guys here. I dont think this changed the creatures min and max damage by 400%. The min/max on a skeleton before this change was 3 and 7. After i altered this its 15 and 35. Is that because I used a whole number instead of a decimal? Also, if my noobness has yet to surpass your patience, could you tell me what the benefit of making the class private? I am assuming that means instead of "public void" you mean to replace with "private void". Thanks again, I aspire to be a player more than a developer but I got frustrated with playing servers I liked just to have them disappear in a few months.
 
I dont think this changed the creatures min and max damage by 400%. The min/max on a skeleton before this change was 3 and 7. After i altered this its 15 and 35.

Well if it was originally 3-7 and now it's 15-35 then that's a 400% increase, or 500% of the original value. Maths!

Is that because I used a whole number instead of a decimal?

If you'd used a whole number or a decimal it wouldn't have mattered

Code:
m_DamageMax = max + (max * 4)
is the same as
Code:
m_DamageMax = max + (int)(max * 4.0)

But if you wanted 450% increase, you could only do that in the second case since the first one will throw a "Cannot implicitly convert an int to a double" error.

what the benefit of making the class private?

It's a coding convention more or less. Something that is "private" can only be accessed from functions located inside that class, whereas something that's "public" can be accessed (and changed!) by any code that calls your class by going myClass.privateVariable.

I could sit here and explain more fundamentals of programming to you, but I think this website does a pretty good job of it :)

http://programmers.stackexchange.com/questions/143736/why-do-we-need-private-variables
 
Back