What I am trying to do is make it so when a player does a critical hit I want the damage modifier to pick up on the players critical damage attribute ( had to create a new attribute list because AosAttribute list was full so it is named CustomAttributes ). What I am not sure of is how do I get the code to point back at the attackers current critical damage bonus.

[article]
// crit chance = 20%
int critChanceBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritChance);
if (critChanceBonus > 20)
critChanceBonus = 20;
//crit damage bonus 200%
int critDamageBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritDamage);
if (critDamageBonus > 200)
critDamageBonus = 200;

int baseCritDamage = 0;
//critChanceBonus += attacker.Luck / 100;
//critical hit attack bonus here
int baseCritChance = 0;
if (baseCritChance + critChanceBonus > Utility.Random(100) && attacker.Combatant != null && damage > 0)
{
attacker.SendMessage("You made a critical strike!");
critDamageBonus = ?????
}
[/article]
 
This is what I ended up with, but this critical hit system sometimes doesn't seem to work for some reason. Sometimes I can get it to work if I move some of the lines of code around but as it stands right now I'm not getting any critical hits.

[article]
// crit chance = 20%
int critChanceBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritChance);
if (critChanceBonus > 20)
critChanceBonus = 20;
//crit damage bonus 200%
int critDamageBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritDamage);
if (critDamageBonus > 200)
critDamageBonus = 200;
//critChanceBonus += attacker.Luck / 100;
//critical hit attack bonus here
int baseCritChance = 0;
int baseCritDamage = 50;
if (baseCritChance + critChanceBonus > Utility.Random(100) && attacker.Combatant != null && damage > 0)
{
attacker.SendMessage("You made a critical strike!");
damageBonus += (baseCritDamage + critDamageBonus);
}
[/article]
 
Still having issues with this, basically I want the base critical hit chance to be 0 for everything and only be increased by items. But If i do | int basecritchance = 0 | i will not get any critical hits at all, even with an item that raises it. I also tried something like this
Code:
// crit chance = 20%
            int critChanceBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritChance);
            if (critChanceBonus > 20)
                critChanceBonus = 20;
           
            //crit damage bonus 200%
            int critDamageBonus = CustomAttributes.GetValue(attacker, CustomAttribute.CritDamage);
            if (critDamageBonus > 200)
                critDamageBonus = 200;
           
           
                    //critChanceBonus += attacker.Luck / 100;
                    //critical hit attack bonus here
            int baseCritChance = critChanceBonus;
            int baseCritDamage = critDamageBonus;
            if (critChanceBonus > Utility.Random(100) && attacker.Combatant != null && damage > 0)
                {
                    attacker.SendMessage("You made a critical strike!");
                    damageBonus = critDamageBonus;
                }

But I still do not get any critical hits. If anyone could point me in the correct direction it would be much appreciated.
 
Make sure that CustomAttributes.GetValue(attacker, CustomAttribute.CritChance); actually gives you the proper amount of % you have on your equipment
 
Safe to say that it isn't. I have 20% crit chance on my weapon and still not getting any critical hits. I have added my custom attributes to my AOS.cs and xmlaosattributes.cs to match my other attributes, and still nothing. I feel like I am maybe missing a location that it needs to be in.

Noticed in some of the base scripts that it has some thing like

Code:
if (m_SetAttributes == null)
            {
                m_SetAttributes = new AosAttributes(this);
            }

Do I maybe need to add in something like

Code:
if (m_SetCustomAttributes == null)
            {
                m_SetCustomAttributes = new CustomAttributes(this);
            }
 
Last edited:
I have this line of code there already, but for whatever reason it isn’t being pulled. I’m not sure but I feel like the issue lies within the fact that I had to create a new attribute list to put it under. If I could figure out how to put everything under the aosattributes list it would work fine, but I am unsure how to go past 0x8000000 under the public enum within the aos.cs. I created the new attribute list in hope of creating new attributes to add a more dynamic system later on.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back