INFORMATION
This code will give you the option to make a attribute randomized each time a item is created.
IMPLEMENTATION
Find this in Item.cpp:
After that code add this:
Find this in Items.h:
Below that code add this:
Find this in Items.cpp:
Below that add this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
Find this in Items.cpp:
Replace with this:
EXAMPLE
In this example there is 50% chance that the item will have extra attack and it will be random 10-30 and the attack is random between 5-8.
Attributes that have Random_min/Random_max suppport:
- Armor
- Defense
- ExtraDefense
- Attack
- ExtraAttack
- AttackSpeed
- Charges
Attributes that have Chance support:
- ExtraDefense
- ExtraAttack
- AttackSpeed
NOTES
When done Rebuild All!!
This code will give you the option to make a attribute randomized each time a item is created.
IMPLEMENTATION
Find this in Item.cpp:
Code:
setDefaultDuration();
if(it.isFluidContainer() || it.isSplash())
setFluidType(amount);
else if(it.stackable && amount)
count = amount;
else if(it.charges && amount)
setCharges(amount);
After that code add this:
Code:
//NEW - RANDOM
if(it.armorRndMin > -1 && it.armorRndMax > it.armorRndMin)
setAttribute("armor", it.armorRndMin + rand() % (it.armorRndMax+1 - it.armorRndMin));
if(it.defenseRndMin > -1 && it.defenseRndMax > it.defenseRndMin)
setAttribute("defense", it.defenseRndMin + rand() % (it.defenseRndMax+1 - it.defenseRndMin));
if(it.extraDefenseRndMin > -1 && it.extraDefenseRndMax > it.extraDefenseRndMin)
if(it.extraDefenseChance == -1 || (it.extraDefenseChance >= rand() % 101) )
setAttribute("extradefense", it.extraDefenseRndMin + rand() % (it.extraDefenseRndMax+1 - it.extraDefenseRndMin));
if(it.attackRndMin > -1 && it.attackRndMax > it.attackRndMin)
setAttribute("attack", it.attackRndMin + rand() % (it.attackRndMax - it.attackRndMin));
if(it.extraAttackRndMin > -1 && it.extraAttackRndMax > it.extraAttackRndMin)
if(it.extraAttackChance == -1 || (it.extraAttackChance >= rand() % 101) )
setAttribute("extraattack", it.extraAttackRndMin + rand() % (it.extraAttackRndMax+1 - it.extraAttackRndMin));
if(it.chargesRndMin > -1 && it.chargesRndMax > it.chargesRndMin)
setAttribute("charges", it.chargesRndMin + rand() % (it.chargesRndMax+1 - it.chargesRndMin));
if(it.attackSpeedRndMin > -1 && it.attackSpeedRndMax > it.attackSpeedRndMin)
if(it.attackSpeedChance == -1 || (it.attackSpeedChance >= rand() % 101) )
setAttribute("attackSpeed", it.attackSpeedRndMin + rand() % (it.attackSpeedRndMax+1 - it.attackSpeedRndMin) );
//NEW - RANDOM
Find this in Items.h:
Code:
int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance,
runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder;
Below that code add this:
Code:
//NEW - RANDOM
int32_t armorRndMin, armorRndMax, defenseRndMin, defenseRndMax, extraDefenseRndMin, extraDefenseRndMax, attackRndMin, attackRndMax, extraAttackRndMin,
extraAttackRndMax, chargesRndMin, chargesRndMax, attackSpeedRndMin, attackSpeedRndMax;
int32_t extraAttackChance, extraDefenseChance, attackSpeedChance;
//NEW - RANDOM
Find this in Items.cpp:
Code:
corpseType = RACE_NONE;
fluidSource = FLUID_NONE;
clientCharges = false;
allowDistRead = false;
Below that add this:
Code:
//NEW - RANDOM
armorRndMin = -1;
armorRndMax = -1;
defenseRndMin = -1;
defenseRndMax = -1;
extraDefenseRndMin = -1;
extraDefenseRndMax = -1;
attackRndMin = -1;
attackRndMax = -1;
extraAttackRndMin = -1;
extraAttackRndMax = -1;
chargesRndMin = -1;
chargesRndMax = -1;
attackSpeedRndMin = -1;
attackSpeedRndMax = -1;
attackSpeedChance = -1;
extraAttackChance = -1;
extraDefenseChance = -1;
//NEW - RANDOM
Find this in Items.cpp:
Code:
else if(tmpStrValue == "armor")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.armor = intValue;
Replace with this:
Code:
else if(tmpStrValue == "armor")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.armor = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.armorRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.armorRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "defense")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.defense = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "defense")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.defense = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.defenseRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.defenseRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.extraDefenseChance = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.extraDefenseChance = intValue;
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.extraDefense = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.extraDefenseRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.extraDefenseRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "attack")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.attack = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "attack")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.attack = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.attackRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.attackRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "extraattack" || tmpStrValue == "extraatk")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.extraAttackChance = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "extraattack" || tmpStrValue == "extraatk")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.extraAttackChance = intValue;
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.extraAttack = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.extraAttackRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.extraAttackRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "attackspeed")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.attackSpeedChance = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "attackspeed")
{
if(readXMLInteger(itemAttributesNode, "chance", intValue))
it.attackSpeedChance = intValue;
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.attackSpeed = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.attackSpeedRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.attackSpeedRndMax = intValue;
}
Find this in Items.cpp:
Code:
else if(tmpStrValue == "charges")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.charges = intValue;
}
Replace with this:
Code:
else if(tmpStrValue == "charges")
{
if(readXMLInteger(itemAttributesNode, "value", intValue))
it.charges = intValue;
if(readXMLInteger(itemAttributesNode, "random_min", intValue))
it.chargesRndMin = intValue;
if(readXMLInteger(itemAttributesNode, "random_max", intValue))
it.chargesRndMax = intValue;
}
EXAMPLE
Code:
<item id="2380" article="a" name="hand axe">
<attribute key="weight" value="1800" />
<attribute key="defense" value="5" />
<attribute key="attack" random_min="5" random_max="8" />
<attribute key="extraattack" chance="50" random_min="10" random_max="30" />
<attribute key="weaponType" value="axe" />
</item>
Attributes that have Random_min/Random_max suppport:
- Armor
- Defense
- ExtraDefense
- Attack
- ExtraAttack
- AttackSpeed
- Charges
Attributes that have Chance support:
- ExtraDefense
- ExtraAttack
- AttackSpeed
NOTES
When done Rebuild All!!
Last edited: