Switch random function to std::mt19937

Added class EQEmu::Random
Functions:
EQEmu::Random::Int(int low, int high)
EQEmu::Random::Real(double low, double high)
EQEmu::Random::Roll(int required)
EQEmu::Random::Roll(double required)
EQEmu::Random::Reseed()

For zone, you will access the random object through the zone object
ex.
	zone->random.Int(0, 100);

Int returns a random int between low and high
Real returns a random double between low and high
Roll(int) returns true if Int(0, 99) < required is true
Roll(double) returns true if Real(0.0, 1.0) <= required is true
This commit is contained in:
Michael Cook (mackal) 2014-12-01 18:13:12 -05:00
parent a59cdc2c89
commit 395be050a3
42 changed files with 683 additions and 799 deletions

View File

@ -168,6 +168,7 @@ SET(common_headers
ptimer.h
queue.h
races.h
random.h
rdtsc.h
rulesys.h
ruletypes.h

View File

@ -54,20 +54,6 @@
#include <errno.h>
#endif
static bool WELLRNG_init = false;
static int state_i = 0;
static unsigned int STATE[R];
static unsigned int z0, z1, z2;
unsigned int (*WELLRNG19937)(void);
static unsigned int case_1 (void);
static unsigned int case_2 (void);
static unsigned int case_3 (void);
static unsigned int case_4 (void);
static unsigned int case_5 (void);
static unsigned int case_6 (void);
uint32 rnd_hash(time_t t, clock_t c);
void oneseed(const uint32 seed);
void CoutTimestamp(bool ms) {
time_t rawtime;
struct tm* gmt_t;
@ -179,41 +165,6 @@ const char * itoa(int num, char* a,int b) {
}
#endif
/*
* generate a random integer in the range low-high this
* should be used instead of the rand()%limit method
*/
int MakeRandomInt(int low, int high)
{
if(low >= high)
return(low);
//return (rand()%(high-low+1) + (low));
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
}
unsigned int randomnum = ((WELLRNG19937)());
if(randomnum == 0xffffffffUL)
return high;
return int ((randomnum / (double)0xffffffffUL) * (high - low + 1) + low);
}
double MakeRandomFloat(double low, double high)
{
if(low >= high)
return(low);
//return (rand() / (double)RAND_MAX * (high - low) + low);
if(!WELLRNG_init) {
WELLRNG_init = true;
oneseed( rnd_hash( time(nullptr), clock() ) );
WELLRNG19937 = case_1;
}
return ((WELLRNG19937)() / (double)0xffffffffUL * (high - low) + low);
}
uint32 rnd_hash( time_t t, clock_t c )
{
// Get a uint32 from t and c
@ -239,111 +190,6 @@ uint32 rnd_hash( time_t t, clock_t c )
return ( h1 + differ++ ) ^ h2;
}
void oneseed( const uint32 seed )
{
// Initialize generator state with seed
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register int j = 0;
STATE[j] = seed & 0xffffffffUL;
for (j = 1; j < R; j++)
{
STATE[j] = ( 1812433253UL * ( STATE[j-1] ^ (STATE[j-1] >> 30) ) + j ) & 0xffffffffUL;
}
}
// WELL RNG code
/* ***************************************************************************** */
/* Copyright: Francois Panneton and Pierre L'Ecuyer, University of Montreal */
/* Makoto Matsumoto, Hiroshima University */
/* Notice: This code can be used freely for personal, academic, */
/* or non-commercial purposes. For commercial purposes, */
/* please contact P. L'Ecuyer at: lecuyer@iro.UMontreal.ca */
/* A modified "maximally equidistributed" implementation */
/* by Shin Harase, Hiroshima University. */
/* ***************************************************************************** */
unsigned int case_1 (void){
// state_i == 0
z0 = (VRm1Under & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0Under = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = R - 1;
WELLRNG19937 = case_3;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_2 (void){
// state_i == 1
z0 = (VRm1 & MASKL) | (VRm2Under & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i = 0;
WELLRNG19937 = case_1;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_3 (void){
// state_i+M1 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1Over);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M1 < R)
WELLRNG19937 = case_5;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_4 (void){
// state_i+M3 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M3 < R)
WELLRNG19937 = case_6;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
static unsigned int case_5 (void){
// state_i+M2 >= R
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2Over) ^ MAT0POS (1, VM3Over);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i + M2 < R)
WELLRNG19937 = case_4;
return (STATE[state_i] ^ (newVM2Over & BITMASK));
}
static unsigned int case_6 (void){
// 2 <= state_i <= (R - M3 - 1)
z0 = (VRm1 & MASKL) | (VRm2 & MASKU);
z1 = MAT0NEG (-25, V0) ^ MAT0POS (27, VM1);
z2 = MAT3POS (9, VM2) ^ MAT0POS (1, VM3);
newV1 = z1 ^ z2;
newV0 = MAT1 (z0) ^ MAT0NEG (-9, z1) ^ MAT0NEG (-21, z2) ^ MAT0POS (21, newV1);
state_i--;
if (state_i == 1)
WELLRNG19937 = case_2;
return (STATE[state_i] ^ (newVM2 & BITMASK));
}
// end WELL RNG code
float EQ13toFloat(int d)
{
return ( float(d)/float(1<<2));

67
common/random.h Normal file
View File

@ -0,0 +1,67 @@
#ifndef __random_h__
#define __random_h__
#include <random>
#include <utility>
/* This uses mt19937 seeded with the std::random_device
* The idea is to have this be included as a member of another class
* so mocking out for testing is easier
* If you need to reseed random.Reseed()
* Eventually this should be derived from an abstract base class
*/
namespace EQEmu {
class Random {
public:
// AKA old MakeRandomInt
const int Int(int low, int high)
{
if (low > high)
std::swap(low, high);
return std::uniform_int_distribution<int>(low, high)(m_gen); // [low, high]
}
// AKA old MakeRandomFloat
const double Real(double low, double high)
{
if (low > high)
std::swap(low, high);
return std::uniform_real_distribution<double>(low, high)(m_gen); // [low, high)
}
// example Roll(50) would have a 50% success rate
// Roll(100) 100%, etc
// valid values 0-100 (well, higher works too but ...)
const bool Roll(const int required)
{
return Int(0, 99) < required;
}
// valid values 0.0 - 1.0
const bool Roll(const double required)
{
return Real(0.0, 1.0) <= required;
}
void Reseed()
{
// We could do the seed_seq thing here too if we need better seeding
// but that is mostly overkill for us, so just seed once
std::random_device rd;
m_gen.seed(rd());
}
Random()
{
Reseed();
}
private:
std::mt19937 m_gen;
};
}
#endif /* !__random_h__ */

View File

@ -389,7 +389,7 @@ void Client::GenerateKey()
'6', '7', '8', '9'
};
key.append((const char*)&key_selection[MakeRandomInt(0, 35)], 1);
key.append((const char*)&key_selection[random.Int(0, 35)], 1);
count++;
}
}

View File

@ -22,6 +22,7 @@
#include "../common/opcodemgr.h"
#include "../common/eq_stream_type.h"
#include "../common/eq_stream_factory.h"
#include "../common/random.h"
#ifndef WIN32
#include "eq_crypto_api.h"
#endif
@ -129,6 +130,8 @@ public:
* Gets the connection for this client.
*/
EQStream *GetConnection() { return connection; }
EQEmu::Random random;
private:
EQStream *connection;
ClientVersion version;

View File

@ -4,6 +4,7 @@
#include "../common/rulesys.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h"
#include "../common/random.h"
#include "adventure.h"
#include "adventure_manager.h"
#include "worlddb.h"
@ -14,6 +15,7 @@
extern ZSList zoneserver_list;
extern ClientList client_list;
extern AdventureManager adventure_manager;
extern EQEmu::Random emu_random;
Adventure::Adventure(AdventureTemplate *t)
{
@ -392,8 +394,8 @@ void Adventure::MoveCorpsesToGraveyard()
for (auto iter = dbid_list.begin(); iter != dbid_list.end(); ++iter)
{
float x = GetTemplate()->graveyard_x + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float y = GetTemplate()->graveyard_y + MakeRandomFloat(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float x = GetTemplate()->graveyard_x + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float y = GetTemplate()->graveyard_y + emu_random.Real(-GetTemplate()->graveyard_radius, GetTemplate()->graveyard_radius);
float z = GetTemplate()->graveyard_z;
query = StringFormat("UPDATE character_corpses "

View File

@ -3,6 +3,7 @@
#include "../common/string_util.h"
#include "../common/servertalk.h"
#include "../common/rulesys.h"
#include "../common/random.h"
#include "adventure.h"
#include "adventure_manager.h"
#include "worlddb.h"
@ -14,6 +15,7 @@
extern ZSList zoneserver_list;
extern ClientList client_list;
extern EQEmu::Random emu_random;
AdventureManager::AdventureManager()
{
@ -325,7 +327,7 @@ void AdventureManager::CalculateAdventureRequestReply(const char *data)
if(eligible_adventures.size() > 0)
{
ea_iter = eligible_adventures.begin();
int c_index = MakeRandomInt(0, (eligible_adventures.size()-1));
int c_index = emu_random.Int(0, (eligible_adventures.size()-1));
for(int i = 0; i < c_index; ++i)
{
++ea_iter;

View File

@ -15,6 +15,7 @@
#include "../common/extprofile.h"
#include "../common/string_util.h"
#include "../common/clientversions.h"
#include "../common/random.h"
#include "client.h"
#include "worlddb.h"
@ -61,6 +62,7 @@ std::vector<RaceClassCombos> character_create_race_class_combos;
extern ZSList zoneserver_list;
extern LoginServerList loginserverlist;
extern ClientList client_list;
extern EQEmu::Random emu_random;
extern uint32 numclients;
extern volatile bool RunLoops;
@ -519,7 +521,7 @@ bool Client::HandleGenerateRandomNamePacket(const EQApplicationPacket *app) {
char cons[48]="bcdfghjklmnpqrstvwxzybcdgklmnprstvwbcdgkpstrkd";
char rndname[17]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
char paircons[33]="ngrkndstshthphsktrdrbrgrfrclcr";
int rndnum=MakeRandomInt(0, 75),n=1;
int rndnum=emu_random.Int(0, 75),n=1;
bool dlc=false;
bool vwl=false;
bool dbl=false;
@ -540,18 +542,18 @@ bool Client::HandleGenerateRandomNamePacket(const EQApplicationPacket *app) {
rndname[0]=vowels[rndnum];
vwl=true;
}
int namlen=MakeRandomInt(5, 10);
int namlen=emu_random.Int(5, 10);
for (int i=n;i<namlen;i++)
{
dlc=false;
if (vwl) //last char was a vowel
{ // so pick a cons or cons pair
rndnum=MakeRandomInt(0, 62);
rndnum=emu_random.Int(0, 62);
if (rndnum>46)
{ // pick a cons pair
if (i>namlen-3) // last 2 chars in name?
{ // name can only end in cons pair "rk" "st" "sh" "th" "ph" "sk" "nd" or "ng"
rndnum=MakeRandomInt(0, 7)*2;
rndnum=emu_random.Int(0, 7)*2;
}
else
{ // pick any from the set
@ -569,12 +571,12 @@ bool Client::HandleGenerateRandomNamePacket(const EQApplicationPacket *app) {
}
else
{ // select a vowel
rndname[i]=vowels[MakeRandomInt(0, 16)];
rndname[i]=vowels[emu_random.Int(0, 16)];
}
vwl=!vwl;
if (!dbl && !dlc)
{ // one chance at double letters in name
if (!MakeRandomInt(0, i+9)) // chances decrease towards end of name
if (!emu_random.Int(0, i+9)) // chances decrease towards end of name
{
rndname[i+1]=rndname[i];
dbl=true;
@ -831,7 +833,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) {
QueuePacket(outapp);
safe_delete(outapp);
int MailKey = MakeRandomInt(1, INT_MAX);
int MailKey = emu_random.Int(1, INT_MAX);
database.SetMailKey(charid, GetIP(), MailKey);
@ -1242,8 +1244,8 @@ void Client::ZoneUnavail() {
bool Client::GenPassKey(char* key) {
char* passKey=nullptr;
*passKey += ((char)('A'+((int)MakeRandomInt(0, 25))));
*passKey += ((char)('A'+((int)MakeRandomInt(0, 25))));
*passKey += ((char)('A'+((int)emu_random.Int(0, 25))));
*passKey += ((char)('A'+((int)emu_random.Int(0, 25))));
memcpy(key, passKey, strlen(passKey));
return true;
}

View File

@ -69,6 +69,7 @@
#include "../common/emu_tcp_server.h"
#include "../common/patches/patches.h"
#include "../common/random.h"
#include "zoneserver.h"
#include "console.h"
#include "login_server.h"
@ -97,6 +98,7 @@ UCSConnection UCSLink;
QueryServConnection QSLink;
LauncherList launcher_list;
AdventureManager adventure_manager;
EQEmu::Random emu_random;
volatile bool RunLoops = true;
uint32 numclients = 0;
uint32 numzones = 0;

View File

@ -24,10 +24,12 @@
#include "world_config.h"
#include "../common/servertalk.h"
#include "../common/string_util.h"
#include "../common/random.h"
extern uint32 numzones;
extern bool holdzones;
extern ConsoleList console_list;
extern EQEmu::Random emu_random;
void CatchSignal(int sig_num);
ZSList::ZSList()
@ -565,7 +567,7 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip
safe_delete(tmp);
return;
}
uint32 z = MakeRandomInt(0, y-1);
uint32 z = emu_random.Int(0, y-1);
ServerPacket* pack = new ServerPacket(ServerOP_ZoneReboot, sizeof(ServerZoneReboot_Struct));
ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*) pack->pBuffer;

View File

@ -329,7 +329,7 @@ bool Mob::CheckWillAggro(Mob *mob) {
||
(
fv == FACTION_THREATENLY
&& MakeRandomInt(0,99) < THREATENLY_ARRGO_CHANCE - heroicCHA_mod
&& zone->random.Roll(THREATENLY_ARRGO_CHANCE - heroicCHA_mod)
)
)
)
@ -1254,7 +1254,7 @@ bool Mob::PassCharismaCheck(Mob* caster, Mob* spellTarget, uint16 spell_id) {
return true;
//1: The mob has a default 25% chance of being allowed a resistance check against the charm.
if (MakeRandomInt(0, 99) > RuleI(Spells, CharmBreakCheckChance))
if (zone->random.Int(0, 99) > RuleI(Spells, CharmBreakCheckChance))
return true;
if (RuleB(Spells, CharismaCharmDuration))
@ -1273,7 +1273,7 @@ bool Mob::PassCharismaCheck(Mob* caster, Mob* spellTarget, uint16 spell_id) {
//3: At maxed ability, Total Domination has a 50% chance of preventing the charm break that otherwise would have occurred.
int16 TotalDominationBonus = caster->aabonuses.CharmBreakChance + caster->spellbonuses.CharmBreakChance + caster->itembonuses.CharmBreakChance;
if (MakeRandomInt(0, 99) < TotalDominationBonus)
if (zone->random.Int(0, 99) < TotalDominationBonus)
return true;
}

View File

@ -339,7 +339,7 @@ bool Mob::CheckHitChance(Mob* other, SkillUseTypes skillinuse, int Hand, int16 c
// Did we hit?
//
float tohit_roll = MakeRandomFloat(0, 100);
float tohit_roll = zone->random.Real(0, 100);
mlog(COMBAT__TOHIT, "Final hit chance: %.2f%%. Hit roll %.2f", chancetohit, tohit_roll);
@ -415,7 +415,7 @@ bool Mob::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte)
//Live AA - HightenedAwareness
int BlockBehindChance = aabonuses.BlockBehind + spellbonuses.BlockBehind + itembonuses.BlockBehind;
if (BlockBehindChance && (BlockBehindChance > MakeRandomInt(1, 100))){
if (BlockBehindChance && zone->random.Roll(BlockBehindChance)) {
bBlockFromRear = true;
if (spellbonuses.BlockBehind || itembonuses.BlockBehind)
@ -508,7 +508,7 @@ bool Mob::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte)
}
if(damage > 0){
roll = MakeRandomFloat(0,100);
roll = zone->random.Real(0,100);
if(roll <= RollTable[0]){
damage = -3;
}
@ -674,7 +674,7 @@ void Mob::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit, ExtraAttac
if (acfail>100) acfail=100;
}
if (acfail<=0 || MakeRandomInt(0, 100)>acfail) {
if (acfail<=0 || zone->random.Int(0, 100)>acfail) {
float acreduction=1;
int acrandom=300;
if (database.GetVariable("ACreduction", tmp, 9))
@ -693,7 +693,7 @@ void Mob::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit, ExtraAttac
damage -= (int32) (GetAC() * acreduction/100.0f);
}
if (acrandom>0) {
damage -= (myac * MakeRandomInt(0, acrandom) / 10000);
damage -= (myac * zone->random.Int(0, acrandom) / 10000);
}
if (damage<1) damage=1;
mlog(COMBAT__DAMAGE, "AC Damage Reduction: fail chance %d%%. Failed. Reduction %.3f%%, random %d. Resulting damage %d.", acfail, acreduction, acrandom, damage);
@ -721,8 +721,8 @@ int32 Mob::GetMeleeMitDmg(Mob *attacker, int32 damage, int32 minhit,
float mit_rating, float atk_rating)
{
float d = 10.0;
float mit_roll = MakeRandomFloat(0, mit_rating);
float atk_roll = MakeRandomFloat(0, atk_rating);
float mit_roll = zone->random.Real(0, mit_rating);
float atk_roll = zone->random.Real(0, atk_rating);
if (atk_roll > mit_roll) {
float a_diff = atk_roll - mit_roll;
@ -771,8 +771,8 @@ int32 Client::GetMeleeMitDmg(Mob *attacker, int32 damage, int32 minhit,
dmg_bonus -= dmg_bonus * (itembonuses.MeleeMitigation / 100.0);
dmg_interval -= dmg_interval * spellMeleeMit;
float mit_roll = MakeRandomFloat(0, mit_rating);
float atk_roll = MakeRandomFloat(0, atk_rating);
float mit_roll = zone->random.Real(0, mit_rating);
float atk_roll = zone->random.Real(0, atk_rating);
if (atk_roll > mit_roll) {
float a_diff = atk_roll - mit_roll;
@ -1272,7 +1272,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
if(RuleB(Combat, UseIntervalAC))
damage = max_hit;
else
damage = MakeRandomInt(min_hit, max_hit);
damage = zone->random.Int(min_hit, max_hit);
damage = mod_client_damage(damage, skillinuse, Hand, weapon, other);
@ -1314,7 +1314,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
OffhandRiposteFail *= -1; //Live uses a negative value for this.
if (OffhandRiposteFail &&
(OffhandRiposteFail > 99 || (MakeRandomInt(0, 100) < OffhandRiposteFail))) {
(OffhandRiposteFail > 99 || zone->random.Roll(OffhandRiposteFail))) {
damage = 0; // Counts as a miss
slippery_attack = true;
} else
@ -1330,7 +1330,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b
if (((damage < 0) || slippery_attack) && !bRiposte && !IsStrikethrough) { // Hack to still allow Strikethrough chance w/ Slippery Attacks AA
int32 bonusStrikeThrough = itembonuses.StrikeThrough + spellbonuses.StrikeThrough + aabonuses.StrikeThrough;
if(bonusStrikeThrough && (MakeRandomInt(0, 100) < bonusStrikeThrough)) {
if(bonusStrikeThrough && zone->random.Roll(bonusStrikeThrough)) {
Message_StringID(MT_StrikeThrough, STRIKETHROUGH_STRING); // You strike through your opponents defenses!
Attack(other, Hand, false, true); // Strikethrough only gives another attempted hit
return false;
@ -1843,7 +1843,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
if(RuleB(Combat, UseIntervalAC))
damage = (max_dmg+eleBane);
else
damage = MakeRandomInt((min_dmg+eleBane),(max_dmg+eleBane));
damage = zone->random.Int((min_dmg+eleBane),(max_dmg+eleBane));
//check if we're hitting above our max or below it.
@ -3438,17 +3438,16 @@ bool Client::CheckDoubleAttack(bool tripleAttack) {
chance *= float(100.0f+triple_bonus)/100.0f; //Apply modifiers.
}
if((MakeRandomFloat(0, 1) < chance))
if(zone->random.Roll(chance))
return true;
return false;
}
bool Client::CheckDoubleRangedAttack() {
int32 chance = spellbonuses.DoubleRangedAttack + itembonuses.DoubleRangedAttack + aabonuses.DoubleRangedAttack;
if(chance && (MakeRandomInt(0, 100) < chance))
if(chance && zone->random.Roll(chance))
return true;
return false;
@ -3632,7 +3631,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons
}
}
if (stun_chance && MakeRandomInt(0, 99) < stun_chance) {
if (stun_chance && zone->random.Roll(stun_chance)) {
// Passed stun, try to resist now
int stun_resist = itembonuses.StunResist + spellbonuses.StunResist;
int frontal_stun_resist = itembonuses.FrontalStunResist + spellbonuses.FrontalStunResist;
@ -3645,18 +3644,18 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons
// frontal stun check for ogres/bonuses
if (((GetBaseRace() == OGRE && IsClient()) ||
(frontal_stun_resist && MakeRandomInt(0, 99) < frontal_stun_resist)) &&
(frontal_stun_resist && zone->random.Roll(frontal_stun_resist))) &&
!attacker->BehindMob(this, attacker->GetX(), attacker->GetY())) {
mlog(COMBAT__HITS, "Frontal stun resisted. %d chance.", frontal_stun_resist);
} else {
// Normal stun resist check.
if (stun_resist && MakeRandomInt(0, 99) < stun_resist) {
if (stun_resist && zone->random.Roll(stun_resist)) {
if (IsClient())
Message_StringID(MT_Stun, SHAKE_OFF_STUN);
mlog(COMBAT__HITS, "Stun Resisted. %d chance.", stun_resist);
} else {
mlog(COMBAT__HITS, "Stunned. %d resist chance.", stun_resist);
Stun(MakeRandomInt(0, 2) * 1000); // 0-2 seconds
Stun(zone->random.Int(0, 2) * 1000); // 0-2 seconds
}
}
} else {
@ -3937,7 +3936,7 @@ void Mob::TryDefensiveProc(const ItemInst* weapon, Mob *on, uint16 hand) {
for (int i = 0; i < MAX_PROCS; i++) {
if (IsValidSpell(DefensiveProcs[i].spellID)) {
float chance = ProcChance * (static_cast<float>(DefensiveProcs[i].chance)/100.0f);
if ((MakeRandomFloat(0, 1) <= chance)) {
if (zone->random.Roll(chance)) {
ExecWeaponProc(nullptr, DefensiveProcs[i].spellID, on);
CheckNumHitsRemaining(NUMHIT_DefensiveSpellProcs,0,DefensiveProcs[i].base_spellID);
}
@ -3999,7 +3998,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on
if (weapon->Proc.Type == ET_CombatProc) {
float WPC = ProcChance * (100.0f + // Proc chance for this weapon
static_cast<float>(weapon->ProcRate)) / 100.0f;
if (MakeRandomFloat(0, 1) <= WPC) { // 255 dex = 0.084 chance of proc. No idea what this number should be really.
if (zone->random.Roll(WPC)) { // 255 dex = 0.084 chance of proc. No idea what this number should be really.
if (weapon->Proc.Level > ourlevel) {
mlog(COMBAT__PROCS,
"Tried to proc (%s), but our level (%d) is lower than required (%d)",
@ -4037,7 +4036,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on
if (aug->Proc.Type == ET_CombatProc) {
float APC = ProcChance * (100.0f + // Proc chance for this aug
static_cast<float>(aug->ProcRate)) / 100.0f;
if (MakeRandomFloat(0, 1) <= APC) {
if (zone->random.Roll(APC)) {
if (aug->Proc.Level > ourlevel) {
if (IsPet()) {
Mob *own = GetOwner();
@ -4090,7 +4089,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on,
if (!rangedattk) {
// Perma procs (AAs)
if (PermaProcs[i].spellID != SPELL_UNKNOWN) {
if (MakeRandomInt(0, 99) < PermaProcs[i].chance) { // TODO: Do these get spell bonus?
if (zone->random.Roll(PermaProcs[i].chance)) { // TODO: Do these get spell bonus?
mlog(COMBAT__PROCS,
"Permanent proc %d procing spell %d (%d percent chance)",
i, PermaProcs[i].spellID, PermaProcs[i].chance);
@ -4105,7 +4104,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on,
// Spell procs (buffs)
if (SpellProcs[i].spellID != SPELL_UNKNOWN) {
float chance = ProcChance * (static_cast<float>(SpellProcs[i].chance) / 100.0f);
if (MakeRandomFloat(0, 1) <= chance) {
if (zone->random.Roll(chance)) {
mlog(COMBAT__PROCS,
"Spell proc %d procing spell %d (%.2f percent chance)",
i, SpellProcs[i].spellID, chance);
@ -4121,7 +4120,7 @@ void Mob::TrySpellProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on,
// ranged spell procs (buffs)
if (RangedProcs[i].spellID != SPELL_UNKNOWN) {
float chance = ProcChance * (static_cast<float>(RangedProcs[i].chance) / 100.0f);
if (MakeRandomFloat(0, 1) <= chance) {
if (zone->random.Roll(chance)) {
mlog(COMBAT__PROCS,
"Ranged proc %d procing spell %d (%.2f percent chance)",
i, RangedProcs[i].spellID, chance);
@ -4189,7 +4188,7 @@ void Mob::TryPetCriticalHit(Mob *defender, uint16 skill, int32 &damage)
critChance /= 100;
if(MakeRandomFloat(0, 1) < critChance)
if(zone->random.Roll(critChance))
{
critMod += GetCritDmgMob(skill) * 2; // To account for base crit mod being 200 not 100
damage = (damage * critMod) / 100;
@ -4228,7 +4227,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
int32 SlayRateBonus = aabonuses.SlayUndead[0] + itembonuses.SlayUndead[0] + spellbonuses.SlayUndead[0];
if (SlayRateBonus) {
float slayChance = static_cast<float>(SlayRateBonus) / 10000.0f;
if (MakeRandomFloat(0, 1) < slayChance) {
if (zone->random.Roll(slayChance)) {
int32 SlayDmgBonus = aabonuses.SlayUndead[1] + itembonuses.SlayUndead[1] + spellbonuses.SlayUndead[1];
damage = (damage * SlayDmgBonus * 2.25) / 100;
if (GetGender() == 1) // female
@ -4299,7 +4298,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
critChance /= 100;
if(MakeRandomFloat(0, 1) < critChance)
if(zone->random.Roll(critChance))
{
uint32 critMod = 200;
bool crip_success = false;
@ -4312,7 +4311,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
if (!IsBerserk() && !IsBerskerSPA)
critChance *= float(CripplingBlowChance)/100.0f;
if ((IsBerserk() || IsBerskerSPA) || MakeRandomFloat(0, 1) < critChance) {
if ((IsBerserk() || IsBerskerSPA) || zone->random.Roll(critChance)) {
critMod = 400;
crip_success = true;
}
@ -4322,7 +4321,7 @@ void Mob::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage, ExtraAttack
damage = damage * critMod / 100;
bool deadlySuccess = false;
if (deadlyChance && MakeRandomFloat(0, 1) < static_cast<float>(deadlyChance) / 100.0f) {
if (deadlyChance && zone->random.Roll(static_cast<float>(deadlyChance) / 100.0f)) {
if (BehindMob(defender, GetX(), GetY())) {
damage *= deadlyMod;
deadlySuccess = true;
@ -4369,7 +4368,7 @@ bool Mob::TryFinishingBlow(Mob *defender, SkillUseTypes skillinuse)
//Proc Chance value of 500 = 5%
uint32 ProcChance = (aabonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0])/10;
if(FB_Level && FB_Dmg && (defender->GetLevel() <= FB_Level) && (ProcChance >= MakeRandomInt(0, 1000))){
if(FB_Level && FB_Dmg && (defender->GetLevel() <= FB_Level) && (ProcChance >= zone->random.Int(0, 1000))){
entity_list.MessageClose_StringID(this, false, 200, MT_CritMelee, FINISHING_BLOW, GetName());
DoSpecialAttackDamage(defender, skillinuse, FB_Dmg, 1, -1, 10, false, false);
return true;
@ -4396,7 +4395,7 @@ void Mob::DoRiposte(Mob* defender) {
defender->itembonuses.DoubleRiposte;
//Live AA - Double Riposte
if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) {
if(DoubleRipChance && zone->random.Roll(DoubleRipChance)) {
mlog(COMBAT__ATTACKS, "Preforming a double riposed (%d percent chance)", DoubleRipChance);
defender->Attack(this, MainPrimary, true);
if (HasDied()) return;
@ -4407,7 +4406,7 @@ void Mob::DoRiposte(Mob* defender) {
DoubleRipChance = defender->aabonuses.GiveDoubleRiposte[1];
if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) {
if(DoubleRipChance && zone->random.Roll(DoubleRipChance)) {
mlog(COMBAT__ATTACKS, "Preforming a return SPECIAL ATTACK (%d percent chance)", DoubleRipChance);
if (defender->GetClass() == MONK)
@ -4519,7 +4518,6 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (spellbonuses.LimitToSkill[skill]){
for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc &&
(!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e]))
|| (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e]))) {
@ -4528,7 +4526,6 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
ProcMod = 0;
for (int i = 0; i < EFFECT_COUNT; i++) {
if (spells[base_spell_id].effectid[i] == SE_SkillProc) {
proc_spell_id = spells[base_spell_id].base[i];
ProcMod = static_cast<float>(spells[base_spell_id].base2[i]);
@ -4538,7 +4535,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (CanProc && spells[base_spell_id].base[i] == skill && IsValidSpell(proc_spell_id)) {
float final_chance = chance * (ProcMod / 100.0f);
if (MakeRandomFloat(0, 1) <= final_chance) {
if (zone->random.Roll(final_chance)) {
ExecWeaponProc(nullptr, proc_spell_id, on);
CheckNumHitsRemaining(NUMHIT_OffensiveSpellProcs,0, base_spell_id);
CanProc = false;
@ -4558,7 +4555,6 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (itembonuses.LimitToSkill[skill]){
CanProc = true;
for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc &&
(!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e]))
|| (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e]))) {
@ -4567,7 +4563,6 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
ProcMod = 0;
for (int i = 0; i < EFFECT_COUNT; i++) {
if (spells[base_spell_id].effectid[i] == SE_SkillProc) {
proc_spell_id = spells[base_spell_id].base[i];
ProcMod = static_cast<float>(spells[base_spell_id].base2[i]);
@ -4577,7 +4572,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (CanProc && spells[base_spell_id].base[i] == skill && IsValidSpell(proc_spell_id)) {
float final_chance = chance * (ProcMod / 100.0f);
if (MakeRandomFloat(0, 1) <= final_chance) {
if (zone->random.Roll(final_chance)) {
ExecWeaponProc(nullptr, proc_spell_id, on);
CanProc = false;
break;
@ -4602,7 +4597,6 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
uint32 slot = 0;
for(int e = 0; e < MAX_SKILL_PROCS; e++){
if (CanProc &&
(!Success && aabonuses.SkillProc[e])
|| (Success && aabonuses.SkillProcSuccess[e])){
@ -4630,7 +4624,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui
if (CanProc && base1 == skill && IsValidSpell(proc_spell_id)) {
float final_chance = chance * (ProcMod / 100.0f);
if (MakeRandomFloat(0, 1) <= final_chance) {
if (zone->random.Roll(final_chance)) {
ExecWeaponProc(nullptr, proc_spell_id, on);
CanProc = false;
break;
@ -4653,11 +4647,8 @@ float Mob::GetSkillProcChances(uint16 ReuseTime, uint16 hand) {
float ProcChance = 0;
if (!ReuseTime && hand) {
weapon_speed = GetWeaponSpeedbyHand(hand);
ProcChance = static_cast<float>(weapon_speed) * (RuleR(Combat, AvgProcsPerMinute) / 60000.0f);
if (hand != MainPrimary)
ProcChance /= 2;
}
@ -4670,26 +4661,25 @@ float Mob::GetSkillProcChances(uint16 ReuseTime, uint16 hand) {
bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) {
/*Dev Quote 2010: http://forums.station.sony.com/eq/posts/list.m?topic_id=161443
The Viscid Roots AA does the following: Reduces the chance for root to break by X percent.
There is no distinction of any kind between the caster inflicted damage, or anyone
else's damage. There is also no distinction between Direct and DOT damage in the root code.
/*Dev Quote 2010: http://forums.station.sony.com/eq/posts/list.m?topic_id=161443
The Viscid Roots AA does the following: Reduces the chance for root to break by X percent.
There is no distinction of any kind between the caster inflicted damage, or anyone
else's damage. There is also no distinction between Direct and DOT damage in the root code.
/* General Mechanics
- Check buffslot to make sure damage from a root does not cancel the root
- If multiple roots on target, always and only checks first root slot and if broken only removes that slots root.
- Only roots on determental spells can be broken by damage.
General Mechanics
- Check buffslot to make sure damage from a root does not cancel the root
- If multiple roots on target, always and only checks first root slot and if broken only removes that slots root.
- Only roots on determental spells can be broken by damage.
- Root break chance values obtained from live parses.
*/
*/
if (!attacker || !spellbonuses.Root[0] || spellbonuses.Root[1] < 0)
return false;
return false;
if (IsDetrimentalSpell(spellbonuses.Root[1]) && spellbonuses.Root[1] != buffslot){
if (IsDetrimentalSpell(spellbonuses.Root[1]) && spellbonuses.Root[1] != buffslot){
int BreakChance = RuleI(Spells, RootBreakFromSpells);
int BreakChance = RuleI(Spells, RootBreakFromSpells);
BreakChance -= BreakChance*buffs[spellbonuses.Root[1]].RootBreakChance/100;
BreakChance -= BreakChance*buffs[spellbonuses.Root[1]].RootBreakChance/100;
int level_diff = attacker->GetLevel() - GetLevel();
//Use baseline if level difference <= 1 (ie. If target is (1) level less than you, or equal or greater level)
@ -4703,10 +4693,10 @@ bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) {
else if (level_diff > 21)
BreakChance = (BreakChance * 20) /100; //Decrease by 80%;
if (BreakChance < 1)
BreakChance = 1;
if (BreakChance < 1)
BreakChance = 1;
if (MakeRandomInt(0, 99) < BreakChance) {
if (zone->random.Roll(BreakChance)) {
if (!TryFadeEffect(spellbonuses.Root[1])) {
BuffFadeBySlot(spellbonuses.Root[1]);

View File

@ -775,49 +775,49 @@ void Bot::GenerateAppearance() {
// Randomize facial appearance
int iFace = 0;
if(this->GetRace() == 2) { // Barbarian w/Tatoo
iFace = MakeRandomInt(0, 79);
iFace = zone->random.Int(0, 79);
}
else {
iFace = MakeRandomInt(0, 7);
iFace = zone->random.Int(0, 7);
}
int iHair = 0;
int iBeard = 0;
int iBeardColor = 1;
if(this->GetRace() == 522) {
iHair = MakeRandomInt(0, 8);
iBeard = MakeRandomInt(0, 11);
iBeardColor = MakeRandomInt(0, 3);
iHair = zone->random.Int(0, 8);
iBeard = zone->random.Int(0, 11);
iBeardColor = zone->random.Int(0, 3);
}
else if(this->GetGender()) {
iHair = MakeRandomInt(0, 2);
iHair = zone->random.Int(0, 2);
if(this->GetRace() == 8) { // Dwarven Females can have a beard
if(MakeRandomInt(1, 100) < 50) {
if(zone->random.Int(1, 100) < 50) {
iFace += 10;
}
}
}
else {
iHair = MakeRandomInt(0, 3);
iBeard = MakeRandomInt(0, 5);
iBeardColor = MakeRandomInt(0, 19);
iHair = zone->random.Int(0, 3);
iBeard = zone->random.Int(0, 5);
iBeardColor = zone->random.Int(0, 19);
}
int iHairColor = 0;
if(this->GetRace() == 522) {
iHairColor = MakeRandomInt(0, 3);
iHairColor = zone->random.Int(0, 3);
}
else {
iHairColor = MakeRandomInt(0, 19);
iHairColor = zone->random.Int(0, 19);
}
uint8 iEyeColor1 = (uint8)MakeRandomInt(0, 9);
uint8 iEyeColor1 = (uint8)zone->random.Int(0, 9);
uint8 iEyeColor2 = 0;
if(this->GetRace() == 522) {
iEyeColor1 = iEyeColor2 = (uint8)MakeRandomInt(0, 11);
iEyeColor1 = iEyeColor2 = (uint8)zone->random.Int(0, 11);
}
else if(MakeRandomInt(1, 100) > 96) {
iEyeColor2 = MakeRandomInt(0, 9);
else if(zone->random.Int(1, 100) > 96) {
iEyeColor2 = zone->random.Int(0, 9);
}
else {
iEyeColor2 = iEyeColor1;
@ -827,9 +827,9 @@ void Bot::GenerateAppearance() {
int iTattoo = 0;
int iDetails = 0;
if(this->GetRace() == 522) {
iHeritage = MakeRandomInt(0, 6);
iTattoo = MakeRandomInt(0, 7);
iDetails = MakeRandomInt(0, 7);
iHeritage = zone->random.Int(0, 6);
iTattoo = zone->random.Int(0, 7);
iDetails = zone->random.Int(0, 7);
}
this->luclinface = iFace;
@ -3098,7 +3098,7 @@ bool Bot::CheckBotDoubleAttack(bool tripleAttack) {
chance *= float(100.0f+triple_bonus)/100.0f; //Apply modifiers.
}
if((MakeRandomFloat(0, 1) < chance))
if((zone->random.Real(0, 1) < chance))
return true;
return false;
@ -3148,7 +3148,7 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes
if(RuleB(Combat, UseIntervalAC))
damage = max_hit;
else
damage = MakeRandomInt(min_hit, max_hit);
damage = zone->random.Int(min_hit, max_hit);
if(!other->CheckHitChance(this, skillinuse, Hand, chance_mod)) {
damage = 0;
@ -3203,7 +3203,7 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes
if (damage > 0)
CheckNumHitsRemaining(NUMHIT_OutgoingHitSuccess);
if((skillinuse == SkillDragonPunch) && GetAA(aaDragonPunch) && MakeRandomInt(0, 99) < 25){
if((skillinuse == SkillDragonPunch) && GetAA(aaDragonPunch) && zone->random.Int(0, 99) < 25){
SpellFinished(904, other, 10, 0, -1, spells[904].ResistDiff);
other->Stun(100);
}
@ -3483,7 +3483,7 @@ void Bot::AI_Process() {
meleeDistance = meleeDistance * .30;
}
else {
meleeDistance *= (float)MakeRandomFloat(.50, .85);
meleeDistance *= (float)zone->random.Real(.50, .85);
}
bool atArcheryRange = IsArcheryRange(GetTarget());
@ -3616,7 +3616,7 @@ void Bot::AI_Process() {
if (GetTarget() && flurrychance)
{
if(MakeRandomInt(0, 100) < flurrychance)
if(zone->random.Int(0, 100) < flurrychance)
{
Message_StringID(MT_NPCFlurry, YOU_FLURRY);
Attack(GetTarget(), MainPrimary, false);
@ -3633,7 +3633,7 @@ void Bot::AI_Process() {
wpn->GetItem()->ItemType == ItemType2HBlunt ||
wpn->GetItem()->ItemType == ItemType2HPiercing )
{
if(MakeRandomInt(0, 100) < ExtraAttackChanceBonus)
if(zone->random.Int(0, 100) < ExtraAttackChanceBonus)
{
Attack(GetTarget(), MainPrimary, false);
}
@ -3678,7 +3678,7 @@ void Bot::AI_Process() {
int32 DWBonus = spellbonuses.DualWieldChance + itembonuses.DualWieldChance;
DualWieldProbability += DualWieldProbability*float(DWBonus)/ 100.0f;
float random = MakeRandomFloat(0, 1);
float random = zone->random.Real(0, 1);
if (random < DualWieldProbability){ // Max 78% of DW
@ -3912,7 +3912,7 @@ void Bot::PetAIProcess() {
if (botPet->GetTarget()) // Do we still have a target?
{
// We're a pet so we re able to dual attack
int32 RandRoll = MakeRandomInt(0, 99);
int32 RandRoll = zone->random.Int(0, 99);
if (botPet->CanThisClassDoubleAttack() && (RandRoll < (botPet->GetLevel() + NPCDualAttackModifier)))
{
if(botPet->Attack(botPet->GetTarget(), MainPrimary))
@ -3945,7 +3945,7 @@ void Bot::PetAIProcess() {
//aa_chance += botPet->GetOwner()->GetAA(aaCompanionsAlacrity) * 3;
if (MakeRandomInt(1, 100) < aa_chance)
if (zone->random.Int(1, 100) < aa_chance)
Flurry(nullptr);
}
@ -3955,12 +3955,12 @@ void Bot::PetAIProcess() {
if(botPet->GetOwner()->GetLevel() >= 24)
{
float DualWieldProbability = (botPet->GetSkill(SkillDualWield) + botPet->GetLevel()) / 400.0f;
DualWieldProbability -= MakeRandomFloat(0, 1);
DualWieldProbability -= zone->random.Real(0, 1);
if(DualWieldProbability < 0){
botPet->Attack(botPet->GetTarget(), MainSecondary);
if (botPet->CanThisClassDoubleAttack())
{
int32 RandRoll = MakeRandomInt(0, 99);
int32 RandRoll = zone->random.Int(0, 99);
if (RandRoll < (botPet->GetLevel() + 20))
{
botPet->Attack(botPet->GetTarget(), MainSecondary);
@ -6213,7 +6213,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
if(RuleB(Combat, UseIntervalAC))
damage = max_hit;
else
damage = MakeRandomInt(min_hit, max_hit);
damage = zone->random.Int(min_hit, max_hit);
mlog(COMBAT__DAMAGE, "Damage calculated to %d (min %d, max %d, str %d, skill %d, DMG %d, lv %d)",
damage, min_hit, max_hit, GetSTR(), GetSkill(skillinuse), weapon_damage, GetLevel());
@ -6258,7 +6258,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
OffhandRiposteFail *= -1; //Live uses a negative value for this.
if (OffhandRiposteFail &&
(OffhandRiposteFail > 99 || (MakeRandomInt(0, 100) < OffhandRiposteFail))) {
(OffhandRiposteFail > 99 || (zone->random.Int(0, 100) < OffhandRiposteFail))) {
damage = 0; // Counts as a miss
slippery_attack = true;
} else
@ -6274,7 +6274,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
if (((damage < 0) || slippery_attack) && !FromRiposte && !IsStrikethrough) { // Hack to still allow Strikethrough chance w/ Slippery Attacks AA
int32 bonusStrikeThrough = itembonuses.StrikeThrough + spellbonuses.StrikeThrough + aabonuses.StrikeThrough;
if(bonusStrikeThrough && (MakeRandomInt(0, 100) < bonusStrikeThrough)) {
if(bonusStrikeThrough && (zone->random.Int(0, 100) < bonusStrikeThrough)) {
Message_StringID(MT_StrikeThrough, STRIKETHROUGH_STRING); // You strike through your opponents defenses!
Attack(other, Hand, false, true); // Strikethrough only gives another attempted hit
return false;
@ -6623,7 +6623,7 @@ int32 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id)
{
if(type == focusTriggerOnCast)
{
if(MakeRandomInt(0, 100) <= base1){
if(zone->random.Int(0, 100) <= base1){
value = base2;
}
@ -6646,7 +6646,7 @@ int32 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id)
{
if(type == focusBlockNextSpell)
{
if(MakeRandomInt(1, 100) <= base1)
if(zone->random.Int(1, 100) <= base1)
value = 1;
}
break;
@ -6670,7 +6670,7 @@ int32 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id)
int32 cast_time = GetActSpellCasttime(spell_id, spells[spell_id].cast_time);
GetSympatheticProcChances(ProcBonus, ProcChance, cast_time, ProcRateMod);
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Real(0, 1) <= ProcChance)
value = focus_id;
else
@ -7147,7 +7147,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -7165,7 +7165,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -7183,7 +7183,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -7273,7 +7273,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
{
if(bottype == BotfocusTriggerOnCast)
if(MakeRandomInt(0, 100) <= focus_spell.base[i])
if(zone->random.Int(0, 100) <= focus_spell.base[i])
value = focus_spell.base2[i];
else
@ -7293,7 +7293,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
{
if(bottype == BotfocusBlockNextSpell)
{
if(MakeRandomInt(1, 100) <= focus_spell.base[i])
if(zone->random.Int(1, 100) <= focus_spell.base[i])
value = 1;
}
break;
@ -7313,7 +7313,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel
float ProcChance = GetSympatheticProcChances(spell_id, focus_spell.base[i]);
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Real(0, 1) <= ProcChance)
value = focus_id;
else
@ -7503,7 +7503,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte)
//Live AA - HightenedAwareness
int BlockBehindChance = aabonuses.BlockBehind + spellbonuses.BlockBehind + itembonuses.BlockBehind;
if (BlockBehindChance && (BlockBehindChance > MakeRandomInt(1, 100))){
if (BlockBehindChance && (BlockBehindChance > zone->random.Int(1, 100))){
bBlockFromRear = true;
if (spellbonuses.BlockBehind || itembonuses.BlockBehind)
@ -7595,7 +7595,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte)
if(damage > 0)
{
roll = MakeRandomFloat(0,100);
roll = zone->random.Real(0,100);
if(roll <= RollTable[0]){
damage = -3;
}
@ -7662,7 +7662,7 @@ bool Bot::TryFinishingBlow(Mob *defender, SkillUseTypes skillinuse)
uint32 damage = aabonuses.FinishingBlow[1];
uint16 levelreq = aabonuses.FinishingBlowLvl[0];
if(defender->GetLevel() <= levelreq && (chance >= MakeRandomInt(0, 1000))){
if(defender->GetLevel() <= levelreq && (chance >= zone->random.Int(0, 1000))){
mlog(COMBAT__ATTACKS, "Landed a finishing blow: levelreq at %d, other level %d", levelreq , defender->GetLevel());
entity_list.MessageClose_StringID(this, false, 200, MT_CritMelee, FINISHING_BLOW, GetName());
defender->Damage(this, damage, SPELL_UNKNOWN, skillinuse);
@ -7690,7 +7690,7 @@ void Bot::DoRiposte(Mob* defender) {
defender->GetSpellBonuses().GiveDoubleRiposte[0] +
defender->GetItemBonuses().GiveDoubleRiposte[0];
if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) {
if(DoubleRipChance && (DoubleRipChance >= zone->random.Int(0, 100))) {
mlog(COMBAT__ATTACKS, "Preforming a double riposte (%d percent chance)", DoubleRipChance);
defender->Attack(this, MainPrimary, true);
@ -7700,7 +7700,7 @@ void Bot::DoRiposte(Mob* defender) {
//Coded narrowly: Limit to one per client. Limit AA only. [1 = Skill Attack Chance, 2 = Skill]
DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[1];
if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) {
if(DoubleRipChance && (DoubleRipChance >= zone->random.Int(0, 100))) {
if (defender->GetClass() == MONK)
defender->MonkSpecialAttack(this, defender->GetAABonuses().GiveDoubleRiposte[2]);
else if (defender->IsBot())
@ -7766,7 +7766,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage,
int kb_chance = 25;
kb_chance += kb_chance*(100-aabonuses.SpecialAttackKBProc[0])/100;
if (MakeRandomInt(0, 99) < kb_chance)
if (zone->random.Int(0, 99) < kb_chance)
SpellFinished(904, who, 10, 0, -1, spells[904].ResistDiff);
//who->Stun(100); Kayen: This effect does not stun on live, it only moves the NPC.
}
@ -7807,7 +7807,7 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) {
//Live AA - Seized Opportunity
int FrontalBSChance = itembonuses.FrontalBackstabChance + spellbonuses.FrontalBackstabChance + aabonuses.FrontalBackstabChance;
if (FrontalBSChance && (FrontalBSChance > MakeRandomInt(0, 100)))
if (FrontalBSChance && (FrontalBSChance > zone->random.Int(0, 100)))
bCanFrontalBS = true;
}
@ -7821,7 +7821,7 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) {
!other->CastToNPC()->IsEngaged() && // not aggro
other->GetHP()<=32000
&& other->IsNPC()
&& MakeRandomFloat(0, 99) < chance // chance
&& zone->random.Real(0, 99) < chance // chance
) {
entity_list.MessageClose_StringID(this, false, 200, MT_CritMelee, ASSASSINATES, GetName());
RogueAssassinate(other);
@ -7832,12 +7832,12 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) {
float DoubleAttackProbability = (GetSkill(SkillDoubleAttack) + GetLevel()) / 500.0f; // 62.4 max
// Check for double attack with main hand assuming maxed DA Skill (MS)
if(MakeRandomFloat(0, 1) < DoubleAttackProbability) // Max 62.4 % chance of DA
if(zone->random.Real(0, 1) < DoubleAttackProbability) // Max 62.4 % chance of DA
{
if(other->GetHP() > 0)
RogueBackstab(other,false,ReuseTime);
if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100))
if (tripleChance && other->GetHP() > 0 && tripleChance > zone->random.Int(0, 100))
RogueBackstab(other,false,ReuseTime);
}
}
@ -7851,11 +7851,11 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) {
if (level > 54) {
float DoubleAttackProbability = (GetSkill(SkillDoubleAttack) + GetLevel()) / 500.0f; // 62.4 max
// Check for double attack with main hand assuming maxed DA Skill (MS)
if(MakeRandomFloat(0, 1) < DoubleAttackProbability) // Max 62.4 % chance of DA
if(zone->random.Real(0, 1) < DoubleAttackProbability) // Max 62.4 % chance of DA
if(other->GetHP() > 0)
RogueBackstab(other,true, ReuseTime);
if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100))
if (tripleChance && other->GetHP() > 0 && tripleChance > zone->random.Int(0, 100))
RogueBackstab(other,false,ReuseTime);
}
}
@ -7929,7 +7929,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime)
if(RuleB(Combat, UseIntervalAC))
ndamage = max_hit;
else
ndamage = MakeRandomInt(min_hit, max_hit);
ndamage = zone->random.Int(min_hit, max_hit);
}
}
@ -8036,7 +8036,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
canBash = true;
}
if(!canBash || MakeRandomInt(0, 100) > 25) { //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
if(!canBash || zone->random.Int(0, 100) > 25) { //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
skill_to_use = SkillKick;
}
else {
@ -8117,7 +8117,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetBashDamage();
else
dmg = MakeRandomInt(1, GetBashDamage());
dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -8164,7 +8164,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
//Live parses show around 55% Triple 35% Double 10% Single, you will always get first hit.
while(AtkRounds > 0) {
if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){
if (GetTarget() && (AtkRounds == 1 || zone->random.Int(0,100) < 75)){
DoSpecialAttackDamage(GetTarget(), SkillFrenzy, max_dmg, min_dmg, max_dmg , reuse, true);
}
AtkRounds--;
@ -8192,7 +8192,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetKickDamage();
else
dmg = MakeRandomInt(1, GetKickDamage());
dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -8215,18 +8215,18 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
//Live AA - Technique of Master Wu
uint32 bDoubleSpecialAttack = itembonuses.DoubleSpecialAttack + spellbonuses.DoubleSpecialAttack + aabonuses.DoubleSpecialAttack;
if( bDoubleSpecialAttack && (bDoubleSpecialAttack >= 100 || bDoubleSpecialAttack > MakeRandomInt(0,100))) {
if( bDoubleSpecialAttack && (bDoubleSpecialAttack >= 100 || bDoubleSpecialAttack > zone->random.Int(0,100))) {
int MonkSPA [5] = { SkillFlyingKick, SkillDragonPunch, SkillEagleStrike, SkillTigerClaw, SkillRoundKick };
MonkSpecialAttack(target, MonkSPA[MakeRandomInt(0,4)]);
MonkSpecialAttack(target, MonkSPA[zone->random.Int(0,4)]);
int TripleChance = 25;
if (bDoubleSpecialAttack > 100)
TripleChance += TripleChance*(100-bDoubleSpecialAttack)/100;
if(TripleChance > MakeRandomInt(0,100)) {
MonkSpecialAttack(target, MonkSPA[MakeRandomInt(0,4)]);
if(TripleChance > zone->random.Int(0,100)) {
MonkSpecialAttack(target, MonkSPA[zone->random.Int(0,4)]);
}
}
@ -8259,7 +8259,7 @@ bool Bot::TryHeadShot(Mob* defender, SkillUseTypes skillInUse) {
// WildcardX: These chance formula's below are arbitrary. If someone has a better formula that is more
// consistent with live, feel free to update these.
float AttackerChance = 0.20f + ((float)(rangerLevel - 51) * 0.005f);
float DefenderChance = (float)MakeRandomFloat(0.00f, 1.00f);
float DefenderChance = (float)zone->random.Real(0.00f, 1.00f);
if(AttackerChance > DefenderChance) {
mlog(COMBAT__ATTACKS, "Landed a headshot: Attacker chance was %f and Defender chance was %f.", AttackerChance, DefenderChance);
// WildcardX: At the time I wrote this, there wasnt a string id for something like HEADSHOT_BLOW
@ -8734,14 +8734,14 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) {
if (spell_id == SPELL_IMP_HARM_TOUCH && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0))
chance = 100;
if (MakeRandomInt(1,100) <= chance){
if (zone->random.Int(1,100) <= chance){
Critical = true;
ratio += itembonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncrease + aabonuses.SpellCritDmgIncrease;
ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack;
}
else if (GetClass() == WIZARD && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (MakeRandomInt(1,100) <= RuleI(Spells, WizCritChance))) {
ratio = MakeRandomInt(1,100); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio.
else if (GetClass() == WIZARD && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (zone->random.Int(1,100) <= RuleI(Spells, WizCritChance))) {
ratio = zone->random.Int(1,100); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio.
Critical = true;
}
@ -8820,7 +8820,7 @@ int32 Bot::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalHealDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalHealDecay);
if(chance && (MakeRandomInt(0,99) < chance)) {
if(chance && (zone->random.Int(0,99) < chance)) {
Critical = true;
modifier = 2; //At present time no critical heal amount modifier SPA exists.
}
@ -8851,7 +8851,7 @@ int32 Bot::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalRegenDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalRegenDecay);
if(chance && (MakeRandomInt(0,99) < chance))
if(chance && (zone->random.Int(0,99) < chance))
return (value * 2);
}
@ -8950,7 +8950,7 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) {
// Formula = Unknown exact, based off a random percent chance up to mana cost(after focuses) of the cast spell
if(this->itembonuses.Clairvoyance && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5)
{
int32 mana_back = this->itembonuses.Clairvoyance * MakeRandomInt(1, 100) / 100;
int32 mana_back = this->itembonuses.Clairvoyance * zone->random.Int(1, 100) / 100;
// Doesnt generate mana, so best case is a free spell
if(mana_back > cost)
mana_back = cost;
@ -8963,7 +8963,7 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) {
// WildcardX
float PercentManaReduction = 0;
float SpecializeSkill = GetSpecializeSkillValue(spell_id);
int SuccessChance = MakeRandomInt(0, 100);
int SuccessChance = zone->random.Int(0, 100);
float bonus = 1.0;
switch(GetAA(aaSpellCastingMastery))
@ -9015,7 +9015,7 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) {
if(focus_redux > 0)
{
PercentManaReduction += MakeRandomFloat(1, (double)focus_redux);
PercentManaReduction += zone->random.Real(1, (double)focus_redux);
}
cost -= (cost * (PercentManaReduction / 100));
@ -15580,7 +15580,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl
return false;
if (iChance < 100) {
uint8 tmp = MakeRandomInt(1, 100);
uint8 tmp = zone->random.Int(1, 100);
if (tmp > iChance)
return false;
}

View File

@ -13,7 +13,7 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
return false;
if (iChance < 100) {
if (MakeRandomInt(0, 100) > iChance){
if (zone->random.Int(0, 100) > iChance){
return false;
}
}
@ -485,7 +485,7 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
if(botClass == PALADIN)
stunChance = 50;
if(!tar->GetSpecialAbility(UNSTUNABLE) && !tar->IsStunned() && (MakeRandomInt(1, 100) <= stunChance)) {
if(!tar->GetSpecialAbility(UNSTUNABLE) && !tar->IsStunned() && (zone->random.Int(1, 100) <= stunChance)) {
botSpell = GetBestBotSpellForStunByTargetType(this, ST_Target);
}
}
@ -1843,7 +1843,7 @@ std::string Bot::GetBotMagicianPetType(Bot* botCaster) {
result = std::string("SumEarth");
else if(botCaster->GetLevel() < 30) {
// Under level 30
int counter = MakeRandomInt(0, 3);
int counter = zone->random.Int(0, 3);
switch(counter) {
case 0:
@ -1865,7 +1865,7 @@ std::string Bot::GetBotMagicianPetType(Bot* botCaster) {
}
else {
// Over level 30
int counter = MakeRandomInt(0, 4);
int counter = zone->random.Int(0, 4);
switch(counter) {
case 0:

View File

@ -2328,7 +2328,7 @@ bool Client::CheckIncreaseSkill(SkillUseTypes skillid, Mob *against_who, int cha
if(Chance < 1)
Chance = 1; // Make it always possible
if(MakeRandomFloat(0, 99) < Chance)
if(zone->random.Real(0, 99) < Chance)
{
SetSkill(skillid, GetRawSkill(skillid) + 1);
_log(SKILLS__GAIN, "Skill %d at value %d successfully gain with %.4f%%chance (mod %d)", skillid, skillval, Chance, chancemodi);
@ -2356,7 +2356,7 @@ void Client::CheckLanguageSkillIncrease(uint8 langid, uint8 TeacherSkill) {
int32 Chance = 5 + ((TeacherSkill - LangSkill)/10); // greater chance to learn if teacher's skill is much higher than yours
Chance = (Chance * RuleI(Character, SkillUpModifier)/100);
if(MakeRandomFloat(0,100) < Chance) { // if they make the roll
if(zone->random.Real(0,100) < Chance) { // if they make the roll
IncreaseLanguageSkill(langid); // increase the language skill by 1
_log(SKILLS__GAIN, "Language %d at value %d successfully gain with %.4f%%chance", langid, LangSkill, Chance);
}
@ -4904,7 +4904,7 @@ int Client::LDoNChest_SkillCheck(NPC *target, int skill)
chance = 100.0f - base_difficulty;
}
float d100 = (float)MakeRandomFloat(0, 100);
float d100 = (float)zone->random.Real(0, 100);
if(d100 <= chance)
return 1;
@ -7608,9 +7608,9 @@ void Client::GarbleMessage(char *message, uint8 variance)
const char alpha_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // only change alpha characters for now
for (size_t i = 0; i < strlen(message); i++) {
uint8 chance = (uint8)MakeRandomInt(0, 115); // variation just over worst possible scrambling
uint8 chance = (uint8)zone->random.Int(0, 115); // variation just over worst possible scrambling
if (isalpha(message[i]) && (chance <= variance)) {
uint8 rand_char = (uint8)MakeRandomInt(0,51); // choose a random character from the alpha list
uint8 rand_char = (uint8)zone->random.Int(0,51); // choose a random character from the alpha list
message[i] = alpha_list[rand_char];
}
}
@ -7728,7 +7728,7 @@ void Client::SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, ui
// If our result is truncated, then double a mob's value every once and a while to equal what they would have got
else
{
if (MakeRandomInt(0, 100) < faction_mod)
if (zone->random.Int(0, 100) < faction_mod)
npc_value[i] *= 2;
}
}
@ -7821,11 +7821,11 @@ void Client::MerchantRejectMessage(Mob *merchant, int primaryfaction)
}
// If no primary faction or biggest influence is your faction hit
if (primaryfaction <= 0 || lowestvalue == tmpFactionValue) {
merchant->Say_StringID(MakeRandomInt(WONT_SELL_DEEDS1, WONT_SELL_DEEDS6));
merchant->Say_StringID(zone->random.Int(WONT_SELL_DEEDS1, WONT_SELL_DEEDS6));
} else if (lowestvalue == fmod.race_mod) { // race biggest
// Non-standard race (ex. illusioned to wolf)
if (GetRace() > PLAYER_RACE_COUNT) {
messageid = MakeRandomInt(1, 3); // these aren't sequential StringIDs :(
messageid = zone->random.Int(1, 3); // these aren't sequential StringIDs :(
switch (messageid) {
case 1:
messageid = WONT_SELL_NONSTDRACE1;
@ -7842,7 +7842,7 @@ void Client::MerchantRejectMessage(Mob *merchant, int primaryfaction)
}
merchant->Say_StringID(messageid);
} else { // normal player races
messageid = MakeRandomInt(1, 4);
messageid = zone->random.Int(1, 4);
switch (messageid) {
case 1:
messageid = WONT_SELL_RACE1;
@ -7863,7 +7863,7 @@ void Client::MerchantRejectMessage(Mob *merchant, int primaryfaction)
merchant->Say_StringID(messageid, itoa(GetRace()));
}
} else if (lowestvalue == fmod.class_mod) {
merchant->Say_StringID(MakeRandomInt(WONT_SELL_CLASS1, WONT_SELL_CLASS5), itoa(GetClass()));
merchant->Say_StringID(zone->random.Int(WONT_SELL_CLASS1, WONT_SELL_CLASS5), itoa(GetClass()));
}
return;
}
@ -7966,7 +7966,7 @@ void Client::TryItemTick(int slot)
if(zone->tick_items.count(iid) > 0)
{
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot <= EmuConstants::EQUIPMENT_END) )
if( GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot <= EmuConstants::EQUIPMENT_END) )
{
ItemInst* e_inst = (ItemInst*)inst;
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot);
@ -7985,7 +7985,7 @@ void Client::TryItemTick(int slot)
if(zone->tick_items.count(iid) > 0)
{
if( GetLevel() >= zone->tick_items[iid].level && MakeRandomInt(0, 100) >= (100 - zone->tick_items[iid].chance) )
if( GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) )
{
ItemInst* e_inst = (ItemInst*)a_inst;
parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot);

View File

@ -2953,7 +2953,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app)
if ((PrimaryWeapon && PrimaryWeapon->GetItem()->ItemType == ItemType1HPiercing) ||
(SecondaryWeapon && SecondaryWeapon->GetItem()->ItemType == ItemType1HPiercing)) {
float SuccessChance = (GetSkill(SkillApplyPoison) + GetLevel()) / 400.0f;
double ChanceRoll = MakeRandomFloat(0, 1);
double ChanceRoll = zone->random.Real(0, 1);
CheckIncreaseSkill(SkillApplyPoison, nullptr, 10);
@ -3642,14 +3642,14 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app)
return;
}
int RandomChance = MakeRandomInt(0, 100);
int RandomChance = zone->random.Int(0, 100);
int ChanceToAttack = 0;
if (GetLevel() > GetTarget()->GetLevel())
ChanceToAttack = MakeRandomInt(0, 15);
ChanceToAttack = zone->random.Int(0, 15);
else
ChanceToAttack = MakeRandomInt(((this->GetTarget()->GetLevel() - this->GetLevel()) * 10) - 5, ((this->GetTarget()->GetLevel() - this->GetLevel()) * 10));
ChanceToAttack = zone->random.Int(((this->GetTarget()->GetLevel() - this->GetLevel()) * 10) - 5, ((this->GetTarget()->GetLevel() - this->GetLevel()) * 10));
if (ChanceToAttack < 0)
ChanceToAttack = -ChanceToAttack;
@ -3668,7 +3668,7 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app)
if (RandomChance < ChanceToBeg)
{
brs->Amount = MakeRandomInt(1, 10);
brs->Amount = zone->random.Int(1, 10);
// This needs some work to determine how much money they can beg, based on skill level etc.
if (CurrentSkill < 50)
{
@ -4550,7 +4550,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
delta_heading = ppu->delta_heading;
if(IsTracking() && ((x_pos!=ppu->x_pos) || (y_pos!=ppu->y_pos))){
if(MakeRandomFloat(0, 100) < 70)//should be good
if(zone->random.Real(0, 100) < 70)//should be good
CheckIncreaseSkill(SkillTracking, nullptr, -20);
}
@ -5252,16 +5252,16 @@ void Client::Handle_OP_DisarmTraps(const EQApplicationPacket *app)
if (trap && trap->detected)
{
int uskill = GetSkill(SkillDisarmTraps);
if ((MakeRandomInt(0, 49) + uskill) >= (MakeRandomInt(0, 49) + trap->skill))
if ((zone->random.Int(0, 49) + uskill) >= (zone->random.Int(0, 49) + trap->skill))
{
Message(MT_Skills, "You disarm a trap.");
trap->disarmed = true;
trap->chkarea_timer.Disable();
trap->respawn_timer.Start((trap->respawn_time + MakeRandomInt(0, trap->respawn_var)) * 1000);
trap->respawn_timer.Start((trap->respawn_time + zone->random.Int(0, trap->respawn_var)) * 1000);
}
else
{
if (MakeRandomInt(0, 99) < 25){
if (zone->random.Int(0, 99) < 25){
Message(MT_Skills, "You set off the trap while trying to disarm it!");
trap->Trigger(this);
}
@ -5622,7 +5622,7 @@ void Client::Handle_OP_FeignDeath(const EQApplicationPacket *app)
secfeign = 0;
uint16 totalfeign = primfeign + secfeign;
if (MakeRandomFloat(0, 160) > totalfeign) {
if (zone->random.Real(0, 160) > totalfeign) {
SetFeigned(false);
entity_list.MessageClose_StringID(this, false, 200, 10, STRING_FEIGNFAILED, GetName());
}
@ -7886,7 +7886,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app)
p_timers.Start(pTimerHide, reuse - 1);
float hidechance = ((GetSkill(SkillHide) / 250.0f) + .25) * 100;
float random = MakeRandomFloat(0, 100);
float random = zone->random.Real(0, 100);
CheckIncreaseSkill(SkillHide, nullptr, 5);
if (random < hidechance) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct));
@ -7910,7 +7910,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app)
Mob *evadetar = GetTarget();
if (!auto_attack && (evadetar && evadetar->CheckAggro(this)
&& evadetar->IsNPC())) {
if (MakeRandomInt(0, 260) < (int)GetSkill(SkillHide)) {
if (zone->random.Int(0, 260) < (int)GetSkill(SkillHide)) {
msg->string_id = EVADE_SUCCESS;
RogueEvade(evadetar);
}
@ -9293,11 +9293,11 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app)
int mendhp = GetMaxHP() / 4;
int currenthp = GetHP();
if (MakeRandomInt(0, 199) < (int)GetSkill(SkillMend)) {
if (zone->random.Int(0, 199) < (int)GetSkill(SkillMend)) {
int criticalchance = spellbonuses.CriticalMend + itembonuses.CriticalMend + aabonuses.CriticalMend;
if (MakeRandomInt(0, 99) < criticalchance){
if (zone->random.Int(0, 99) < criticalchance){
mendhp *= 2;
Message_StringID(4, MEND_CRITICAL);
}
@ -9312,7 +9312,7 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app)
0 skill - 25% chance to worsen
20 skill - 23% chance to worsen
50 skill - 16% chance to worsen */
if ((GetSkill(SkillMend) <= 75) && (MakeRandomInt(GetSkill(SkillMend), 100) < 75) && (MakeRandomInt(1, 3) == 1))
if ((GetSkill(SkillMend) <= 75) && (zone->random.Int(GetSkill(SkillMend), 100) < 75) && (zone->random.Int(1, 3) == 1))
{
SetHP(currenthp > mendhp ? (GetHP() - mendhp) : 1);
SendHPUpdate();
@ -11213,7 +11213,7 @@ void Client::Handle_OP_RandomReq(const EQApplicationPacket *app)
randLow = 0;
randHigh = 100;
}
randResult = MakeRandomInt(randLow, randHigh);
randResult = zone->random.Int(randLow, randHigh);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RandomReply, sizeof(RandomReply_Struct));
RandomReply_Struct* rr = (RandomReply_Struct*)outapp->pBuffer;
@ -11703,7 +11703,7 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app)
if (trap && trap->skill > 0) {
int uskill = GetSkill(SkillSenseTraps);
if ((MakeRandomInt(0, 99) + uskill) >= (MakeRandomInt(0, 99) + trap->skill*0.75))
if ((zone->random.Int(0, 99) + uskill) >= (zone->random.Int(0, 99) + trap->skill*0.75))
{
float xdif = trap->x - GetX();
float ydif = trap->y - GetY();
@ -12446,7 +12446,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app)
// 1199 I don't have time for that now. etc
if (!tmp->CastToNPC()->IsMerchantOpen()) {
tmp->Say_StringID(MakeRandomInt(1199, 1202));
tmp->Say_StringID(zone->random.Int(1199, 1202));
action = 0;
}
@ -12501,7 +12501,7 @@ void Client::Handle_OP_Sneak(const EQApplicationPacket *app)
CheckIncreaseSkill(SkillSneak, nullptr, 5);
}
float hidechance = ((GetSkill(SkillSneak) / 300.0f) + .25) * 100;
float random = MakeRandomFloat(0, 99);
float random = zone->random.Real(0, 99);
if (!was && random < hidechance) {
sneaking = true;
}

View File

@ -436,7 +436,7 @@ bool Client::Process() {
if (auto_attack_target && flurrychance)
{
if(MakeRandomInt(0, 99) < flurrychance)
if(zone->random.Int(0, 99) < flurrychance)
{
Message_StringID(MT_NPCFlurry, YOU_FLURRY);
Attack(auto_attack_target, MainPrimary, false);
@ -453,7 +453,7 @@ bool Client::Process() {
wpn->GetItem()->ItemType == ItemType2HBlunt ||
wpn->GetItem()->ItemType == ItemType2HPiercing )
{
if(MakeRandomInt(0, 99) < ExtraAttackChanceBonus)
if(zone->random.Int(0, 99) < ExtraAttackChanceBonus)
{
Attack(auto_attack_target, MainPrimary, false);
}
@ -498,7 +498,7 @@ bool Client::Process() {
int16 DWBonus = spellbonuses.DualWieldChance + itembonuses.DualWieldChance;
DualWieldProbability += DualWieldProbability*float(DWBonus)/ 100.0f;
float random = MakeRandomFloat(0, 1);
float random = zone->random.Real(0, 1);
CheckIncreaseSkill(SkillDualWield, auto_attack_target, -10);
if (random < DualWieldProbability){ // Max 78% of DW
if(CheckAAEffect(aaEffectRampage)) {
@ -1003,7 +1003,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
if (fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required)
continue;
handychance = MakeRandomInt(0, merlist.size() + tmp_merlist.size() - 1);
handychance = zone->random.Int(0, merlist.size() + tmp_merlist.size() - 1);
item = database.GetItem(ml.item);
if (item) {
@ -1079,7 +1079,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
zone->tmpmerchanttable[npcid] = tmp_merlist;
if (merch != nullptr && handyitem) {
char handy_id[8] = { 0 };
int greeting = MakeRandomInt(0, 4);
int greeting = zone->random.Int(0, 4);
int greet_id = 0;
switch (greeting) {
case 1:
@ -1640,7 +1640,7 @@ void Client::OPGMTraining(const EQApplicationPacket *app)
// welcome message
if (pTrainer && pTrainer->IsNPC())
{
pTrainer->Say_StringID(MakeRandomInt(1204, 1207), GetCleanName());
pTrainer->Say_StringID(zone->random.Int(1204, 1207), GetCleanName());
}
}
@ -1667,7 +1667,7 @@ void Client::OPGMEndTraining(const EQApplicationPacket *app)
// goodbye message
if (pTrainer->IsNPC())
{
pTrainer->Say_StringID(MakeRandomInt(1208, 1211), GetCleanName());
pTrainer->Say_StringID(zone->random.Int(1208, 1211), GetCleanName());
}
}

View File

@ -5003,157 +5003,157 @@ void command_randomfeatures(Client *c, const Seperator *sep)
uint32 DrakkinDetails = 0xFFFFFFFF;
// Set some common feature settings
EyeColor1 = MakeRandomInt(0, 9);
EyeColor2 = MakeRandomInt(0, 9);
LuclinFace = MakeRandomInt(0, 7);
EyeColor1 = zone->random.Int(0, 9);
EyeColor2 = zone->random.Int(0, 9);
LuclinFace = zone->random.Int(0, 7);
// Adjust all settings based on the min and max for each feature of each race and gender
switch (Race)
{
case 1: // Human
HairColor = MakeRandomInt(0, 19);
HairColor = zone->random.Int(0, 19);
if (Gender == 0) {
BeardColor = HairColor;
HairStyle = MakeRandomInt(0, 3);
Beard = MakeRandomInt(0, 5);
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 2: // Barbarian
HairColor = MakeRandomInt(0, 19);
LuclinFace = MakeRandomInt(0, 87);
HairColor = zone->random.Int(0, 19);
LuclinFace = zone->random.Int(0, 87);
if (Gender == 0) {
BeardColor = HairColor;
HairStyle = MakeRandomInt(0, 3);
Beard = MakeRandomInt(0, 5);
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 3: // Erudite
if (Gender == 0) {
BeardColor = MakeRandomInt(0, 19);
Beard = MakeRandomInt(0, 5);
LuclinFace = MakeRandomInt(0, 57);
BeardColor = zone->random.Int(0, 19);
Beard = zone->random.Int(0, 5);
LuclinFace = zone->random.Int(0, 57);
}
if (Gender == 1) {
LuclinFace = MakeRandomInt(0, 87);
LuclinFace = zone->random.Int(0, 87);
}
break;
case 4: // WoodElf
HairColor = MakeRandomInt(0, 19);
HairColor = zone->random.Int(0, 19);
if (Gender == 0) {
HairStyle = MakeRandomInt(0, 3);
HairStyle = zone->random.Int(0, 3);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 5: // HighElf
HairColor = MakeRandomInt(0, 14);
HairColor = zone->random.Int(0, 14);
if (Gender == 0) {
HairStyle = MakeRandomInt(0, 3);
LuclinFace = MakeRandomInt(0, 37);
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 6: // DarkElf
HairColor = MakeRandomInt(13, 18);
HairColor = zone->random.Int(13, 18);
if (Gender == 0) {
HairStyle = MakeRandomInt(0, 3);
LuclinFace = MakeRandomInt(0, 37);
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 7: // HalfElf
HairColor = MakeRandomInt(0, 19);
HairColor = zone->random.Int(0, 19);
if (Gender == 0) {
HairStyle = MakeRandomInt(0, 3);
LuclinFace = MakeRandomInt(0, 37);
HairStyle = zone->random.Int(0, 3);
LuclinFace = zone->random.Int(0, 37);
BeardColor = HairColor;
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 8: // Dwarf
HairColor = MakeRandomInt(0, 19);
HairColor = zone->random.Int(0, 19);
BeardColor = HairColor;
if (Gender == 0) {
HairStyle = MakeRandomInt(0, 3);
Beard = MakeRandomInt(0, 5);
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
LuclinFace = MakeRandomInt(0, 17);
HairStyle = zone->random.Int(0, 2);
LuclinFace = zone->random.Int(0, 17);
}
break;
case 9: // Troll
EyeColor1 = MakeRandomInt(0, 10);
EyeColor2 = MakeRandomInt(0, 10);
EyeColor1 = zone->random.Int(0, 10);
EyeColor2 = zone->random.Int(0, 10);
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 3);
HairColor = MakeRandomInt(0, 23);
HairStyle = zone->random.Int(0, 3);
HairColor = zone->random.Int(0, 23);
}
break;
case 10: // Ogre
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 3);
HairColor = MakeRandomInt(0, 23);
HairStyle = zone->random.Int(0, 3);
HairColor = zone->random.Int(0, 23);
}
break;
case 11: // Halfling
HairColor = MakeRandomInt(0, 19);
HairColor = zone->random.Int(0, 19);
if (Gender == 0) {
BeardColor = HairColor;
HairStyle = MakeRandomInt(0, 3);
Beard = MakeRandomInt(0, 5);
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 12: // Gnome
HairColor = MakeRandomInt(0, 24);
HairColor = zone->random.Int(0, 24);
if (Gender == 0) {
BeardColor = HairColor;
HairStyle = MakeRandomInt(0, 3);
Beard = MakeRandomInt(0, 5);
HairStyle = zone->random.Int(0, 3);
Beard = zone->random.Int(0, 5);
}
if (Gender == 1) {
HairStyle = MakeRandomInt(0, 2);
HairStyle = zone->random.Int(0, 2);
}
break;
case 128: // Iksar
case 130: // VahShir
break;
case 330: // Froglok
LuclinFace = MakeRandomInt(0, 9);
LuclinFace = zone->random.Int(0, 9);
case 522: // Drakkin
HairColor = MakeRandomInt(0, 3);
HairColor = zone->random.Int(0, 3);
BeardColor = HairColor;
EyeColor1 = MakeRandomInt(0, 11);
EyeColor2 = MakeRandomInt(0, 11);
LuclinFace = MakeRandomInt(0, 6);
DrakkinHeritage = MakeRandomInt(0, 6);
DrakkinTattoo = MakeRandomInt(0, 7);
DrakkinDetails = MakeRandomInt(0, 7);
EyeColor1 = zone->random.Int(0, 11);
EyeColor2 = zone->random.Int(0, 11);
LuclinFace = zone->random.Int(0, 6);
DrakkinHeritage = zone->random.Int(0, 6);
DrakkinTattoo = zone->random.Int(0, 7);
DrakkinDetails = zone->random.Int(0, 7);
if (Gender == 0) {
Beard = MakeRandomInt(0, 12);
HairStyle = MakeRandomInt(0, 8);
Beard = zone->random.Int(0, 12);
HairStyle = zone->random.Int(0, 8);
}
if (Gender == 1) {
Beard = MakeRandomInt(0, 3);
HairStyle = MakeRandomInt(0, 7);
Beard = zone->random.Int(0, 3);
HairStyle = zone->random.Int(0, 7);
}
break;
default:
@ -10443,6 +10443,7 @@ void command_distance(Client *c, const Seperator *sep) {
void command_cvs(Client *c, const Seperator *sep)
{
c->Message(0, "%f %d", zone->random.Real(0.0f, 1.0f), zone->random.Int(0, 100));
if(c)
{
ServerPacket *pack = new ServerPacket(ServerOP_ClientVersionSummary, sizeof(ServerRequestClientVersionSummary_Struct));

View File

@ -63,22 +63,17 @@ int32 NPC::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) {
int ratio = 0;
if (spells[spell_id].buffduration == 0) {
chance += spellbonuses.CriticalSpellChance + spellbonuses.FrenziedDevastation;
if (chance && MakeRandomInt(1,100) <= chance){
if (chance && zone->random.Roll(chance)) {
ratio += spellbonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncNoStack;
value += (value*ratio)/100;
entity_list.MessageClose_StringID(this, true, 100, MT_SpellCrits, OTHER_CRIT_BLAST, GetCleanName(), itoa(-value));
}
}
else {
chance += spellbonuses.CriticalDoTChance;
if (chance && MakeRandomInt(1,100) <= chance){
if (chance && zone->random.Roll(chance)) {
ratio += spellbonuses.DotCritDmgIncrease;
value += (value*ratio)/100;
}
@ -119,14 +114,14 @@ int32 Client::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) {
if (spell_id == SPELL_IMP_HARM_TOUCH && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0))
chance = 100;
if (MakeRandomInt(1,100) <= chance){
if (zone->random.Roll(chance)) {
Critical = true;
ratio += itembonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncrease + aabonuses.SpellCritDmgIncrease;
ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack;
}
else if (GetClass() == WIZARD && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (MakeRandomInt(1,100) <= RuleI(Spells, WizCritChance))) {
ratio += MakeRandomInt(20,70); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed)
else if (GetClass() == WIZARD && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (zone->random.Roll(RuleI(Spells, WizCritChance)))) {
ratio += zone->random.Int(20,70); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed)
Critical = true;
}
@ -196,19 +191,13 @@ int32 Client::GetActDoTDamage(uint16 spell_id, int32 value, Mob* target) {
value_BaseEffect = value + (value*GetFocusEffect(focusFcBaseEffects, spell_id)/100);
if (chance > 0 && (MakeRandomInt(1, 100) <= chance)) {
if (chance > 0 && (zone->random.Roll(chance))) {
int32 ratio = 200;
ratio += itembonuses.DotCritDmgIncrease + spellbonuses.DotCritDmgIncrease + aabonuses.DotCritDmgIncrease;
value = value_BaseEffect*ratio/100;
value += int(value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100)*ratio/100;
value += int(value_BaseEffect*GetFocusEffect(focusFcDamagePctCrit, spell_id)/100)*ratio/100;
value += int(value_BaseEffect*target->GetVulnerability(this, spell_id, 0)/100)*ratio/100;
extra_dmg = target->GetFcDamageAmtIncoming(this, spell_id) +
int(GetFocusEffect(focusFcDamageAmtCrit, spell_id)*ratio/100) +
GetFocusEffect(focusFcDamageAmt, spell_id);
@ -224,15 +213,10 @@ int32 Client::GetActDoTDamage(uint16 spell_id, int32 value, Mob* target) {
return value;
}
value = value_BaseEffect;
value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id)/100;
value += value_BaseEffect*GetFocusEffect(focusFcDamagePctCrit, spell_id)/100;
value += value_BaseEffect*target->GetVulnerability(this, spell_id, 0)/100;
extra_dmg = target->GetFcDamageAmtIncoming(this, spell_id) +
GetFocusEffect(focusFcDamageAmtCrit, spell_id) +
GetFocusEffect(focusFcDamageAmt, spell_id);
@ -284,15 +268,13 @@ int32 NPC::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
//Allow for critical heal chance if NPC is loading spell effect bonuses.
if (AI_HasSpellsEffects()){
if(spells[spell_id].buffduration < 1) {
if(spellbonuses.CriticalHealChance && (MakeRandomInt(0,99) < spellbonuses.CriticalHealChance)) {
if(spellbonuses.CriticalHealChance && (zone->random.Roll(spellbonuses.CriticalHealChance))) {
value = value*2;
entity_list.MessageClose_StringID(this, true, 100, MT_SpellCrits, OTHER_CRIT_HEAL, GetCleanName(), itoa(value));
}
}
else if(spellbonuses.CriticalHealOverTime && (MakeRandomInt(0,99) < spellbonuses.CriticalHealOverTime)) {
else if(spellbonuses.CriticalHealOverTime && (zone->random.Roll(spellbonuses.CriticalHealOverTime))) {
value = value*2;
}
}
@ -326,7 +308,7 @@ int32 Client::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalHealDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalHealDecay);
if(chance && (MakeRandomInt(0,99) < chance)) {
if(chance && (zone->random.Roll(chance))) {
Critical = true;
modifier = 2; //At present time no critical heal amount modifier SPA exists.
}
@ -360,7 +342,7 @@ int32 Client::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalRegenDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalRegenDecay);
if(chance && (MakeRandomInt(0,99) < chance))
if(chance && zone->random.Roll(chance))
return (value * 2);
}
@ -379,7 +361,7 @@ int32 Client::GetActSpellCost(uint16 spell_id, int32 cost)
// Formula = Unknown exact, based off a random percent chance up to mana cost(after focuses) of the cast spell
if(this->itembonuses.Clairvoyance && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5)
{
int16 mana_back = this->itembonuses.Clairvoyance * MakeRandomInt(1, 100) / 100;
int16 mana_back = this->itembonuses.Clairvoyance * zone->random.Int(1, 100) / 100;
// Doesnt generate mana, so best case is a free spell
if(mana_back > cost)
mana_back = cost;
@ -392,7 +374,7 @@ int32 Client::GetActSpellCost(uint16 spell_id, int32 cost)
// WildcardX
float PercentManaReduction = 0;
float SpecializeSkill = GetSpecializeSkillValue(spell_id);
int SuccessChance = MakeRandomInt(0, 100);
int SuccessChance = zone->random.Int(0, 100);
float bonus = 1.0;
switch(GetAA(aaSpellCastingMastery))
@ -444,7 +426,7 @@ int32 Client::GetActSpellCost(uint16 spell_id, int32 cost)
if(focus_redux > 0)
{
PercentManaReduction += MakeRandomFloat(1, (double)focus_redux);
PercentManaReduction += zone->random.Real(1, (double)focus_redux);
}
cost -= (cost * (PercentManaReduction / 100));

View File

@ -1521,7 +1521,7 @@ XS(XS__ChooseRandom)
if (items < 1)
Perl_croak(aTHX_ "Usage: ChooseRandom(... list ...)");
int index = MakeRandomInt(0, items-1);
int index = zone->random.Int(0, items-1);
SV *tmp = ST(0);
ST(0) = ST(index);

View File

@ -628,7 +628,7 @@ void EntityList::AddCorpse(Corpse *corpse, uint32 in_id)
void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
{
npc->SetID(GetFreeID());
npc->SetMerchantProbability((uint8) MakeRandomInt(0, 99));
npc->SetMerchantProbability((uint8) zone->random.Int(0, 99));
parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0);
uint16 emoteid = npc->GetEmoteID();
@ -1570,7 +1570,7 @@ Client *EntityList::GetRandomClient(float x, float y, float z, float Distance, C
if (ClientsInRange.empty())
return nullptr;
return ClientsInRange[MakeRandomInt(0, ClientsInRange.size() - 1)];
return ClientsInRange[zone->random.Int(0, ClientsInRange.size() - 1)];
}
Corpse *EntityList::GetCorpseByOwner(Client *client)
@ -2890,7 +2890,7 @@ void EntityList::ClearFeignAggro(Mob *targ)
it->second->RemoveFromHateList(targ);
if (targ->IsClient()) {
if (it->second->GetLevel() >= 35 && MakeRandomInt(1, 100) <= 60)
if (it->second->GetLevel() >= 35 && zone->random.Roll(60))
it->second->AddFeignMemory(targ->CastToClient());
else
targ->CastToClient()->RemoveXTarget(it->second, false);
@ -4505,7 +4505,7 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
selection.push_back(j);
while (selection.size() > 0 && count > 0) {
int k = MakeRandomInt(0, selection.size() - 1);
int k = zone->random.Int(0, selection.size() - 1);
counts[selection[k]]++;
count--;
selection.erase(selection.begin() + k);
@ -4687,6 +4687,6 @@ Mob *EntityList::GetTargetForVirus(Mob *spreader, int range)
if(TargetsInRange.size() == 0)
return nullptr;
return TargetsInRange[MakeRandomInt(0, TargetsInRange.size() - 1)];
return TargetsInRange[zone->random.Int(0, TargetsInRange.size() - 1)];
}

View File

@ -186,8 +186,8 @@ void Mob::CalculateNewFearpoint()
{
int ran = 250 - (loop*2);
loop++;
ranx = GetX()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
rany = GetY()+MakeRandomInt(0, ran-1)-MakeRandomInt(0, ran-1);
ranx = GetX()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
rany = GetY()+zone->random.Int(0, ran-1)-zone->random.Int(0, ran-1);
ranz = FindGroundZ(ranx,rany);
if (ranz == -999999)
continue;

View File

@ -83,7 +83,7 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) {
ret = 0;
uint32 rindex = MakeRandomInt(1, chancepool);
uint32 rindex = zone->random.Int(1, chancepool);
for(int i = 0; i < index; i++) {
if(rindex <= chance[i]) {
@ -136,7 +136,7 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id,
if (index <= 0)
return 0;
uint32 random = MakeRandomInt(1, chancepool);
uint32 random = zone->random.Int(1, chancepool);
for (int i = 0; i < index; i++)
{
if (random > chance[i])
@ -258,18 +258,18 @@ void Client::GoFish()
fishing_skill = 100+((fishing_skill-100)/2);
}
if (MakeRandomInt(0,175) < fishing_skill) {
if (zone->random.Int(0,175) < fishing_skill) {
uint32 food_id = 0;
//25% chance to fish an item.
if (MakeRandomInt(0, 399) <= fishing_skill ) {
if (zone->random.Int(0, 399) <= fishing_skill ) {
uint32 npc_id = 0;
uint8 npc_chance = 0;
food_id = database.GetZoneFishing(m_pp.zone_id, fishing_skill, npc_id, npc_chance);
//check for add NPC
if(npc_chance > 0 && npc_id) {
if(npc_chance < MakeRandomInt(0, 99)) {
if(npc_chance < zone->random.Int(0, 99)) {
const NPCType* tmp = database.GetNPCType(npc_id);
if(tmp != nullptr) {
NPC* npc = new NPC(tmp, nullptr, GetX()+3, GetY(), GetZ(), GetHeading(), FlyMode3);
@ -289,7 +289,7 @@ void Client::GoFish()
DeleteItemInInventory(bslot, 1, true); //do we need client update?
if(food_id == 0) {
int index = MakeRandomInt(0, MAX_COMMON_FISH_IDS-1);
int index = zone->random.Int(0, MAX_COMMON_FISH_IDS-1);
food_id = common_fish_ids[index];
}
@ -324,11 +324,11 @@ void Client::GoFish()
else
{
//chance to use bait when you dont catch anything...
if (MakeRandomInt(0, 4) == 1) {
if (zone->random.Int(0, 4) == 1) {
DeleteItemInInventory(bslot, 1, true); //do we need client update?
Message_StringID(MT_Skills, FISHING_LOST_BAIT); //You lost your bait!
} else {
if (MakeRandomInt(0, 15) == 1) //give about a 1 in 15 chance to spill your beer. we could make this a rule, but it doesn't really seem worth it
if (zone->random.Int(0, 15) == 1) //give about a 1 in 15 chance to spill your beer. we could make this a rule, but it doesn't really seem worth it
//TODO: check for & consume an alcoholic beverage from inventory when this triggers, and set it as a rule that's disabled by default
Message_StringID(MT_Skills, FISHING_SPILL_BEER); //You spill your beer while bringing in your line.
else
@ -341,7 +341,7 @@ void Client::GoFish()
//chance to break fishing pole...
//this is potentially exploitable in that they can fish
//and then swap out items in primary slot... too lazy to fix right now
if (MakeRandomInt(0, 49) == 1) {
if (zone->random.Int(0, 49) == 1) {
Message_StringID(MT_Skills, FISHING_POLE_BROKE); //Your fishing pole broke!
DeleteItemInInventory(MainPrimary, 0, true);
}
@ -370,18 +370,18 @@ void Client::ForageItem(bool guarantee) {
};
// these may need to be fine tuned, I am just guessing here
if (guarantee || MakeRandomInt(0,199) < skill_level) {
if (guarantee || zone->random.Int(0,199) < skill_level) {
uint32 foragedfood = 0;
uint32 stringid = FORAGE_NOEAT;
if (MakeRandomInt(0,99) <= 25) {
if (zone->random.Roll(25)) {
foragedfood = database.GetZoneForage(m_pp.zone_id, skill_level);
}
//not an else in case theres no DB food
if(foragedfood == 0) {
uint8 index = 0;
index = MakeRandomInt(0, MAX_COMMON_FOOD_IDS-1);
index = zone->random.Int(0, MAX_COMMON_FOOD_IDS-1);
foragedfood = common_food_ids[index];
}
@ -438,7 +438,7 @@ void Client::ForageItem(bool guarantee) {
}
int ChanceSecondForage = aabonuses.ForageAdditionalItems + itembonuses.ForageAdditionalItems + spellbonuses.ForageAdditionalItems;
if(!guarantee && MakeRandomInt(0,99) < ChanceSecondForage) {
if(!guarantee && zone->random.Roll(ChanceSecondForage)) {
Message_StringID(MT_Skills, FORAGE_MASTERY);
ForageItem(true);
}

View File

@ -485,7 +485,7 @@ Mob *HateList::GetRandom()
}
auto iterator = list.begin();
int random = MakeRandomInt(0, count - 1);
int random = zone->random.Int(0, count - 1);
for (int i = 0; i < random; i++)
++iterator;

View File

@ -49,15 +49,15 @@ void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* ite
if (lts->mincash == lts->maxcash)
cash = lts->mincash;
else
cash = MakeRandomInt(lts->mincash, lts->maxcash);
cash = zone->random.Int(lts->mincash, lts->maxcash);
if (cash != 0) {
if (lts->avgcoin != 0) {
//this is some crazy ass stuff... and makes very little sense... dont use it, k?
uint32 mincoin = (uint32) (lts->avgcoin * 0.75 + 1);
uint32 maxcoin = (uint32) (lts->avgcoin * 1.25 + 1);
*copper = MakeRandomInt(mincoin, maxcoin);
*silver = MakeRandomInt(mincoin, maxcoin);
*gold = MakeRandomInt(mincoin, maxcoin);
*copper = zone->random.Int(mincoin, maxcoin);
*silver = zone->random.Int(mincoin, maxcoin);
*gold = zone->random.Int(mincoin, maxcoin);
if(*copper > cash) { *copper = cash; }
cash -= *copper;
if(*silver>(cash/10)) { *silver = (cash/10); }
@ -92,7 +92,7 @@ void ZoneDatabase::AddLootTableToNPC(NPC* npc,uint32 loottable_id, ItemList* ite
float drop_chance = 0.0f;
if(ltchance > 0.0 && ltchance < 100.0) {
drop_chance = MakeRandomFloat(0.0, 100.0);
drop_chance = zone->random.Real(0.0, 100.0);
}
if (ltchance != 0.0 && (ltchance == 100.0 || drop_chance < ltchance)) {
@ -118,7 +118,7 @@ void ZoneDatabase::AddLootDropToNPC(NPC* npc,uint32 lootdrop_id, ItemList* iteml
uint8 limit = 0;
// Start at a random point in itemlist.
uint32 item = MakeRandomInt(0, lds->NumEntries-1);
uint32 item = zone->random.Int(0, lds->NumEntries-1);
// Main loop.
for (uint32 i=0; i<lds->NumEntries;)
{
@ -137,7 +137,7 @@ void ZoneDatabase::AddLootDropToNPC(NPC* npc,uint32 lootdrop_id, ItemList* iteml
float drop_chance = 0.0;
if(thischance != 100.0)
drop_chance = MakeRandomFloat(0.0, 100.0);
drop_chance = zone->random.Real(0.0, 100.0);
#if EQDEBUG>=11
LogFile->write(EQEMuLog::Debug, "Drop chance for npc: %s, this chance:%f, drop roll:%f", npc->GetName(), thischance, drop_chance);
@ -282,7 +282,7 @@ void NPC::AddLootDrop(const Item_Struct *item2, ItemList* itemlist, int16 charge
eslot = MaterialPrimary;
}
else if (foundslot == MainSecondary
&& (GetOwner() != nullptr || (GetLevel() >= 13 && MakeRandomInt(0,99) < NPC_DW_CHANCE) || (item2->Damage==0)) &&
&& (GetOwner() != nullptr || (GetLevel() >= 13 && zone->random.Roll(NPC_DW_CHANCE)) || (item2->Damage==0)) &&
(item2->ItemType == ItemType1HSlash || item2->ItemType == ItemType1HBlunt || item2->ItemType == ItemTypeShield ||
item2->ItemType == ItemType1HPiercing))
{

View File

@ -170,49 +170,49 @@ void Merc::GenerateAppearance() {
// Randomize facial appearance
int iFace = 0;
if(this->GetRace() == 2) { // Barbarian w/Tatoo
iFace = MakeRandomInt(0, 79);
iFace = zone->random.Int(0, 79);
}
else {
iFace = MakeRandomInt(0, 7);
iFace = zone->random.Int(0, 7);
}
int iHair = 0;
int iBeard = 0;
int iBeardColor = 1;
if(this->GetRace() == 522) {
iHair = MakeRandomInt(0, 8);
iBeard = MakeRandomInt(0, 11);
iBeardColor = MakeRandomInt(0, 3);
iHair = zone->random.Int(0, 8);
iBeard = zone->random.Int(0, 11);
iBeardColor = zone->random.Int(0, 3);
}
else if(this->GetGender()) {
iHair = MakeRandomInt(0, 2);
iHair = zone->random.Int(0, 2);
if(this->GetRace() == 8) { // Dwarven Females can have a beard
if(MakeRandomInt(1, 100) < 50) {
if(zone->random.Roll(50)) {
iFace += 10;
}
}
}
else {
iHair = MakeRandomInt(0, 3);
iBeard = MakeRandomInt(0, 5);
iBeardColor = MakeRandomInt(0, 19);
iHair = zone->random.Int(0, 3);
iBeard = zone->random.Int(0, 5);
iBeardColor = zone->random.Int(0, 19);
}
int iHairColor = 0;
if(this->GetRace() == 522) {
iHairColor = MakeRandomInt(0, 3);
iHairColor = zone->random.Int(0, 3);
}
else {
iHairColor = MakeRandomInt(0, 19);
iHairColor = zone->random.Int(0, 19);
}
uint8 iEyeColor1 = (uint8)MakeRandomInt(0, 9);
uint8 iEyeColor1 = (uint8)zone->random.Int(0, 9);
uint8 iEyeColor2 = 0;
if(this->GetRace() == 522) {
iEyeColor1 = iEyeColor2 = (uint8)MakeRandomInt(0, 11);
iEyeColor1 = iEyeColor2 = (uint8)zone->random.Int(0, 11);
}
else if(MakeRandomInt(1, 100) > 96) {
iEyeColor2 = MakeRandomInt(0, 9);
else if(zone->random.Int(1, 100) > 96) {
iEyeColor2 = zone->random.Int(0, 9);
}
else {
iEyeColor2 = iEyeColor1;
@ -222,9 +222,9 @@ void Merc::GenerateAppearance() {
int iTattoo = 0;
int iDetails = 0;
if(this->GetRace() == 522) {
iHeritage = MakeRandomInt(0, 6);
iTattoo = MakeRandomInt(0, 7);
iDetails = MakeRandomInt(0, 7);
iHeritage = zone->random.Int(0, 6);
iTattoo = zone->random.Int(0, 7);
iDetails = zone->random.Int(0, 7);
}
this->luclinface = iFace;
@ -1523,7 +1523,7 @@ void Merc::AI_Process() {
meleeDistance = meleeDistance * .30;
}
else {
meleeDistance *= (float)MakeRandomFloat(.50, .85);
meleeDistance *= (float)zone->random.Real(.50, .85);
}
if(IsMercCaster() && GetLevel() > 12) {
if(IsMercCasterCombatRange(GetTarget()))
@ -1624,7 +1624,7 @@ void Merc::AI_Process() {
if (GetTarget() && flurrychance)
{
if(MakeRandomInt(0, 100) < flurrychance)
if(zone->random.Roll(flurrychance))
{
Message_StringID(MT_NPCFlurry, YOU_FLURRY);
Attack(GetTarget(), MainPrimary, false);
@ -1635,7 +1635,7 @@ void Merc::AI_Process() {
int16 ExtraAttackChanceBonus = spellbonuses.ExtraAttackChance + itembonuses.ExtraAttackChance + aabonuses.ExtraAttackChance;
if (GetTarget() && ExtraAttackChanceBonus) {
if(MakeRandomInt(0, 100) < ExtraAttackChanceBonus)
if(zone->random.Roll(ExtraAttackChanceBonus))
{
Attack(GetTarget(), MainPrimary, false);
}
@ -1669,10 +1669,8 @@ void Merc::AI_Process() {
int16 DWBonus = spellbonuses.DualWieldChance + itembonuses.DualWieldChance;
DualWieldProbability += DualWieldProbability*float(DWBonus)/ 100.0f;
float random = MakeRandomFloat(0, 1);
// Max 78% of DW
if (random < DualWieldProbability)
if (zone->random.Roll(DualWieldProbability))
{
Attack(GetTarget(), MainSecondary); // Single attack with offhand
@ -1934,7 +1932,7 @@ bool EntityList::Merc_AICheckCloseBeneficialSpells(Merc* caster, uint8 iChance,
return false;
if (iChance < 100) {
int8 tmp = MakeRandomInt(1, 100);
int8 tmp = zone->random.Int(1, 100);
if (tmp > iChance)
return false;
}
@ -2030,7 +2028,7 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) {
return false;
if (iChance < 100) {
if (MakeRandomInt(0, 100) > iChance){
if (zone->random.Int(0, 100) > iChance){
return false;
}
}
@ -2315,14 +2313,14 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) {
if(selectedMercSpell.spellid == 0 && !tar->GetSpecialAbility(UNSTUNABLE) && !tar->IsStunned()) {
uint8 stunChance = 15;
if(MakeRandomInt(1, 100) <= stunChance) {
if(zone->random.Roll(stunChance)) {
selectedMercSpell = GetBestMercSpellForStun(this);
}
}
if(selectedMercSpell.spellid == 0) {
uint8 lureChance = 25;
if(MakeRandomInt(1, 100) <= lureChance) {
if(zone->random.Roll(lureChance)) {
selectedMercSpell = GetBestMercSpellForNukeByTargetResists(this, tar);
}
}
@ -2742,14 +2740,14 @@ int32 Merc::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) {
int32 ratio = RuleI(Spells, BaseCritRatio); //Critical modifier is applied from spell effects only. Keep at 100 for live like criticals.
if (MakeRandomInt(1,100) <= chance){
if (zone->random.Roll(chance)) {
Critical = true;
ratio += itembonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncrease + aabonuses.SpellCritDmgIncrease;
ratio += itembonuses.SpellCritDmgIncNoStack + spellbonuses.SpellCritDmgIncNoStack + aabonuses.SpellCritDmgIncNoStack;
}
else if (GetClass() == CASTERDPS && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (MakeRandomInt(1,100) <= RuleI(Spells, WizCritChance))) {
ratio = MakeRandomInt(1,100); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio.
else if (GetClass() == CASTERDPS && (GetLevel() >= RuleI(Spells, WizCritLevel)) && (zone->random.Roll(RuleI(Spells, WizCritChance)))) {
ratio = zone->random.Int(1,100); //Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio.
Critical = true;
}
@ -2833,7 +2831,7 @@ int32 Merc::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalHealDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalHealDecay);
if(chance && (MakeRandomInt(0,99) < chance)) {
if(chance && zone->random.Roll(chance)) {
Critical = true;
modifier = 2; //At present time no critical heal amount modifier SPA exists.
}
@ -2864,7 +2862,7 @@ int32 Merc::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target) {
if (spellbonuses.CriticalRegenDecay)
chance += GetDecayEffectValue(spell_id, SE_CriticalRegenDecay);
if(chance && (MakeRandomInt(0,99) < chance))
if(chance && zone->random.Roll(chance))
return (value * 2);
}
@ -2876,7 +2874,7 @@ int32 Merc::GetActSpellCost(uint16 spell_id, int32 cost)
// Formula = Unknown exact, based off a random percent chance up to mana cost(after focuses) of the cast spell
if(this->itembonuses.Clairvoyance && spells[spell_id].classes[(GetClass()%16) - 1] >= GetLevel() - 5)
{
int16 mana_back = this->itembonuses.Clairvoyance * MakeRandomInt(1, 100) / 100;
int16 mana_back = this->itembonuses.Clairvoyance * zone->random.Int(1, 100) / 100;
// Doesnt generate mana, so best case is a free spell
if(mana_back > cost)
mana_back = cost;
@ -2893,7 +2891,7 @@ int32 Merc::GetActSpellCost(uint16 spell_id, int32 cost)
if(focus_redux > 0)
{
PercentManaReduction += MakeRandomFloat(1, (double)focus_redux);
PercentManaReduction += zone->random.Real(1, (double)focus_redux);
}
cost -= (cost * (PercentManaReduction / 100));
@ -3825,17 +3823,17 @@ MercSpell Merc::GetBestMercSpellForAENuke(Merc* caster, Mob* tar) {
}
//check of we even want to cast an AE nuke
if(MakeRandomInt(1, 100) <= initialCastChance) {
if(zone->random.Roll(initialCastChance)) {
result = GetBestMercSpellForAERainNuke(caster, tar);
//check if we have a spell & allow for other AE nuke types
if(result.spellid == 0 && MakeRandomInt(1, 100) <= castChanceFalloff) {
if(result.spellid == 0 && zone->random.Roll(castChanceFalloff)) {
result = GetBestMercSpellForPBAENuke(caster, tar);
//check if we have a spell & allow for other AE nuke types
if(result.spellid == 0 && MakeRandomInt(1, 100) <= castChanceFalloff) {
if(result.spellid == 0 && zone->random.Roll(castChanceFalloff)) {
result = GetBestMercSpellForTargetedAENuke(caster, tar);
}
@ -3879,7 +3877,7 @@ MercSpell Merc::GetBestMercSpellForTargetedAENuke(Merc* caster, Mob* tar) {
&& !IsPBAENukeSpell(mercSpellListItr->spellid) && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
uint8 numTargets = 0;
if(CheckAENuke(caster, tar, mercSpellListItr->spellid, numTargets)) {
if(numTargets >= numTargetsCheck && MakeRandomInt(1, 100) <= castChance) {
if(numTargets >= numTargetsCheck && zone->random.Roll(castChance)) {
result.spellid = mercSpellListItr->spellid;
result.stance = mercSpellListItr->stance;
result.type = mercSpellListItr->type;
@ -3929,7 +3927,7 @@ MercSpell Merc::GetBestMercSpellForPBAENuke(Merc* caster, Mob* tar) {
if(IsPBAENukeSpell(mercSpellListItr->spellid) && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
uint8 numTargets = 0;
if(CheckAENuke(caster, caster, mercSpellListItr->spellid, numTargets)) {
if(numTargets >= numTargetsCheck && MakeRandomInt(1, 100) <= castChance) {
if(numTargets >= numTargetsCheck && zone->random.Roll(castChance)) {
result.spellid = mercSpellListItr->spellid;
result.stance = mercSpellListItr->stance;
result.type = mercSpellListItr->type;
@ -3976,7 +3974,7 @@ MercSpell Merc::GetBestMercSpellForAERainNuke(Merc* caster, Mob* tar) {
for(std::list<MercSpell>::iterator mercSpellListItr = mercSpellList.begin(); mercSpellListItr != mercSpellList.end(); ++mercSpellListItr) {
// Assuming all the spells have been loaded into this list by level and in descending order
if(IsAERainNukeSpell(mercSpellListItr->spellid) && MakeRandomInt(1, 100) <= castChance && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
if(IsAERainNukeSpell(mercSpellListItr->spellid) && zone->random.Roll(castChance) && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
uint8 numTargets = 0;
if(CheckAENuke(caster, tar, mercSpellListItr->spellid, numTargets)) {
if(numTargets >= numTargetsCheck) {
@ -4015,7 +4013,7 @@ MercSpell Merc::GetBestMercSpellForNuke(Merc* caster) {
for(std::list<MercSpell>::iterator mercSpellListItr = mercSpellList.begin(); mercSpellListItr != mercSpellList.end(); ++mercSpellListItr) {
// Assuming all the spells have been loaded into this list by level and in descending order
if(IsPureNukeSpell(mercSpellListItr->spellid) && !IsAENukeSpell(mercSpellListItr->spellid)
&& MakeRandomInt(1, 100) <= castChance && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
&& zone->random.Roll(castChance) && CheckSpellRecastTimers(caster, mercSpellListItr->spellid)) {
result.spellid = mercSpellListItr->spellid;
result.stance = mercSpellListItr->stance;
result.type = mercSpellListItr->type;
@ -4447,7 +4445,7 @@ bool Merc::CheckConfidence() {
ConfidenceLossChance = 25 - ( 5 * (GetTierID() - 1));
}
if(MakeRandomInt(0 ,100) < ConfidenceLossChance) {
if(zone->random.Roll(ConfidenceLossChance)) {
result = false;
}
@ -4593,7 +4591,7 @@ void Merc::DoClassAttacks(Mob *target) {
break;
case TANK:{
if(level >= RuleI(Combat, NPCBashKickLevel)){
if(MakeRandomInt(0, 100) > 25) //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
if(zone->random.Int(0, 100) > 25) //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
{
DoAnim(animKick);
int32 dmg = 0;
@ -4606,7 +4604,7 @@ void Merc::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetKickDamage();
else
dmg = MakeRandomInt(1, GetKickDamage());
dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -4628,7 +4626,7 @@ void Merc::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetBashDamage();
else
dmg = MakeRandomInt(1, GetBashDamage());
dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -4756,7 +4754,7 @@ const char* Merc::GetRandomName(){
bool valid = false;
while(!valid) {
int rndnum=MakeRandomInt(0, 75),n=1;
int rndnum=zone->random.Int(0, 75),n=1;
bool dlc=false;
bool vwl=false;
bool dbl=false;
@ -4777,18 +4775,18 @@ const char* Merc::GetRandomName(){
rndname[0]=vowels[rndnum];
vwl=true;
}
int namlen=MakeRandomInt(5, 10);
int namlen=zone->random.Int(5, 10);
for (int i=n;i<namlen;i++)
{
dlc=false;
if (vwl) //last char was a vowel
{ // so pick a cons or cons pair
rndnum=MakeRandomInt(0, 62);
rndnum=zone->random.Int(0, 62);
if (rndnum>46)
{ // pick a cons pair
if (i>namlen-3) // last 2 chars in name?
{ // name can only end in cons pair "rk" "st" "sh" "th" "ph" "sk" "nd" or "ng"
rndnum=MakeRandomInt(0, 7)*2;
rndnum=zone->random.Int(0, 7)*2;
}
else
{ // pick any from the set
@ -4806,12 +4804,12 @@ const char* Merc::GetRandomName(){
}
else
{ // select a vowel
rndname[i]=vowels[MakeRandomInt(0, 16)];
rndname[i]=vowels[zone->random.Int(0, 16)];
}
vwl=!vwl;
if (!dbl && !dlc)
{ // one chance at double letters in name
if (!MakeRandomInt(0, i+9)) // chances decrease towards end of name
if (!zone->random.Int(0, i+9)) // chances decrease towards end of name
{
rndname[i+1]=rndname[i];
dbl=true;

View File

@ -2356,7 +2356,7 @@ uint32 Mob::RandomTimer(int min,int max) {
int r = 14000;
if(min != 0 && max != 0 && min < max)
{
r = MakeRandomInt(min, max);
r = zone->random.Int(min, max);
}
return r;
}
@ -2753,7 +2753,7 @@ void Mob::ExecWeaponProc(const ItemInst *inst, uint16 spell_id, Mob *on) {
if(IsClient())
twinproc_chance = CastToClient()->GetFocusEffect(focusTwincast, spell_id);
if(twinproc_chance && (MakeRandomInt(0,99) < twinproc_chance))
if(twinproc_chance && zone->random.Roll(twinproc_chance))
twinproc = true;
if (IsBeneficialSpell(spell_id)) {
@ -3098,7 +3098,7 @@ bool Mob::TrySpellTrigger(Mob *target, uint32 spell_id, int effect)
{
if (spells[spell_id].effectid[i] == SE_SpellTrigger)
{
if(MakeRandomInt(0, trig_chance) <= spells[spell_id].base[i])
if(zone->random.Int(0, trig_chance) <= spells[spell_id].base[i])
{
// If we trigger an effect then its over.
if (IsValidSpell(spells[spell_id].base2[i])){
@ -3118,7 +3118,7 @@ bool Mob::TrySpellTrigger(Mob *target, uint32 spell_id, int effect)
// if the chances don't add to 100, then each effect gets a chance to fire, chance for no trigger as well.
else
{
if(MakeRandomInt(0, 100) <= spells[spell_id].base[effect])
if(zone->random.Int(0, 100) <= spells[spell_id].base[effect])
{
if (IsValidSpell(spells[spell_id].base2[effect])){
SpellFinished(spells[spell_id].base2[effect], target, 10, 0, -1, spells[spells[spell_id].base2[effect]].ResistDiff);
@ -3223,7 +3223,7 @@ void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id)
if (focus > 0)
{
if(MakeRandomInt(0, 100) <= focus)
if(zone->random.Roll(focus))
{
Message(MT_Spells,"You twincast %s!",spells[spell_id].name);
SpellFinished(spell_id, target, 10, 0, -1, spells[spell_id].ResistDiff);
@ -3242,7 +3242,7 @@ void Mob::TryTwincast(Mob *caster, Mob *target, uint32 spell_id)
int32 focus = CalcFocusEffect(focusTwincast, buffs[i].spellid, spell_id);
if(focus > 0)
{
if(MakeRandomInt(0, 100) <= focus)
if(zone->random.Roll(focus))
{
SpellFinished(spell_id, target, 10, 0, -1, spells[spell_id].ResistDiff);
}
@ -4023,7 +4023,7 @@ void Mob::TrySpellOnKill(uint8 level, uint16 spell_id)
{
if (IsValidSpell(spells[spell_id].base2[i]) && spells[spell_id].max[i] <= level)
{
if(MakeRandomInt(0,99) < spells[spell_id].base[i])
if(zone->random.Roll(spells[spell_id].base[i]))
SpellFinished(spells[spell_id].base2[i], this, 10, 0, -1, spells[spells[spell_id].base2[i]].ResistDiff);
}
}
@ -4038,17 +4038,17 @@ void Mob::TrySpellOnKill(uint8 level, uint16 spell_id)
for(int i = 0; i < MAX_SPELL_TRIGGER*3; i+=3) {
if(aabonuses.SpellOnKill[i] && IsValidSpell(aabonuses.SpellOnKill[i]) && (level >= aabonuses.SpellOnKill[i + 2])) {
if(MakeRandomInt(0, 99) < static_cast<int>(aabonuses.SpellOnKill[i + 1]))
if(zone->random.Roll(static_cast<int>(aabonuses.SpellOnKill[i + 1])))
SpellFinished(aabonuses.SpellOnKill[i], this, 10, 0, -1, spells[aabonuses.SpellOnKill[i]].ResistDiff);
}
if(itembonuses.SpellOnKill[i] && IsValidSpell(itembonuses.SpellOnKill[i]) && (level >= itembonuses.SpellOnKill[i + 2])){
if(MakeRandomInt(0, 99) < static_cast<int>(itembonuses.SpellOnKill[i + 1]))
if(zone->random.Roll(static_cast<int>(itembonuses.SpellOnKill[i + 1])))
SpellFinished(itembonuses.SpellOnKill[i], this, 10, 0, -1, spells[aabonuses.SpellOnKill[i]].ResistDiff);
}
if(spellbonuses.SpellOnKill[i] && IsValidSpell(spellbonuses.SpellOnKill[i]) && (level >= spellbonuses.SpellOnKill[i + 2])) {
if(MakeRandomInt(0, 99) < static_cast<int>(spellbonuses.SpellOnKill[i + 1]))
if(zone->random.Roll(static_cast<int>(spellbonuses.SpellOnKill[i + 1])))
SpellFinished(spellbonuses.SpellOnKill[i], this, 10, 0, -1, spells[aabonuses.SpellOnKill[i]].ResistDiff);
}
@ -4065,19 +4065,19 @@ bool Mob::TrySpellOnDeath()
for(int i = 0; i < MAX_SPELL_TRIGGER*2; i+=2) {
if(IsClient() && aabonuses.SpellOnDeath[i] && IsValidSpell(aabonuses.SpellOnDeath[i])) {
if(MakeRandomInt(0, 99) < static_cast<int>(aabonuses.SpellOnDeath[i + 1])) {
if(zone->random.Roll(static_cast<int>(aabonuses.SpellOnDeath[i + 1]))) {
SpellFinished(aabonuses.SpellOnDeath[i], this, 10, 0, -1, spells[aabonuses.SpellOnDeath[i]].ResistDiff);
}
}
if(itembonuses.SpellOnDeath[i] && IsValidSpell(itembonuses.SpellOnDeath[i])) {
if(MakeRandomInt(0, 99) < static_cast<int>(itembonuses.SpellOnDeath[i + 1])) {
if(zone->random.Roll(static_cast<int>(itembonuses.SpellOnDeath[i + 1]))) {
SpellFinished(itembonuses.SpellOnDeath[i], this, 10, 0, -1, spells[itembonuses.SpellOnDeath[i]].ResistDiff);
}
}
if(spellbonuses.SpellOnDeath[i] && IsValidSpell(spellbonuses.SpellOnDeath[i])) {
if(MakeRandomInt(0, 99) < static_cast<int>(spellbonuses.SpellOnDeath[i + 1])) {
if(zone->random.Roll(static_cast<int>(spellbonuses.SpellOnDeath[i + 1]))) {
SpellFinished(spellbonuses.SpellOnDeath[i], this, 10, 0, -1, spells[spellbonuses.SpellOnDeath[i]].ResistDiff);
}
}
@ -4240,7 +4240,7 @@ bool Mob::TryReflectSpell(uint32 spell_id)
int chance = itembonuses.reflect_chance + spellbonuses.reflect_chance + aabonuses.reflect_chance;
if(chance && MakeRandomInt(0, 99) < chance)
if(chance && zone->random.Roll(chance))
return true;
return false;

View File

@ -57,7 +57,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
return false;
if (iChance < 100) {
if (MakeRandomInt(0, 100) >= iChance)
if (zone->random.Int(0, 100) >= iChance)
return false;
}
@ -94,7 +94,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
dist2 <= spells[AIspells[i].spellid].range*spells[AIspells[i].spellid].range
)
&& (mana_cost <= GetMana() || GetMana() == GetMaxMana())
&& (AIspells[i].time_cancast + (MakeRandomInt(0, 4) * 1000)) <= Timer::GetCurrentTime() //break up the spelling casting over a period of time.
&& (AIspells[i].time_cancast + (zone->random.Int(0, 4) * 1000)) <= Timer::GetCurrentTime() //break up the spelling casting over a period of time.
) {
#if MobAI_DEBUG_Spells >= 21
@ -126,7 +126,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
}
case SpellType_Root: {
Mob *rootee = GetHateRandom();
if (rootee && !rootee->IsRooted() && MakeRandomInt(0, 99) < 50
if (rootee && !rootee->IsRooted() && zone->random.Roll(50)
&& rootee->DontRootMeBefore() < Timer::GetCurrentTime()
&& rootee->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0
) {
@ -165,7 +165,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
}
case SpellType_InCombatBuff: {
if(MakeRandomInt(0, 99) < 50)
if(zone->random.Roll(50))
{
AIDoSpellCast(i, tar, mana_cost);
return true;
@ -184,7 +184,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
case SpellType_Slow:
case SpellType_Debuff: {
Mob * debuffee = GetHateRandom();
if (debuffee && manaR >= 10 && MakeRandomInt(0, 99 < 70) &&
if (debuffee && manaR >= 10 && zone->random.Roll(70) &&
debuffee->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0) {
if (!checked_los) {
if (!CheckLosFN(debuffee))
@ -198,7 +198,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
}
case SpellType_Nuke: {
if (
manaR >= 10 && MakeRandomInt(0, 99) < 70
manaR >= 10 && zone->random.Roll(70)
&& tar->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0
) {
if(!checked_los) {
@ -212,7 +212,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
break;
}
case SpellType_Dispel: {
if(MakeRandomInt(0, 99) < 15)
if(zone->random.Roll(15))
{
if(!checked_los) {
if(!CheckLosFN(tar))
@ -228,7 +228,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
break;
}
case SpellType_Mez: {
if(MakeRandomInt(0, 99) < 20)
if(zone->random.Roll(20))
{
Mob * mezTar = nullptr;
mezTar = entity_list.GetTargetForMez(this);
@ -244,7 +244,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
case SpellType_Charm:
{
if(!IsPet() && MakeRandomInt(0, 99) < 20)
if(!IsPet() && zone->random.Roll(20))
{
Mob * chrmTar = GetHateRandom();
if(chrmTar && chrmTar->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0)
@ -258,7 +258,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
case SpellType_Pet: {
//keep mobs from recasting pets when they have them.
if (!IsPet() && !GetPetID() && MakeRandomInt(0, 99) < 25) {
if (!IsPet() && !GetPetID() && zone->random.Roll(25)) {
AIDoSpellCast(i, tar, mana_cost);
return true;
}
@ -266,7 +266,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
}
case SpellType_Lifetap: {
if (GetHPRatio() <= 95
&& MakeRandomInt(0, 99) < 50
&& zone->random.Roll(50)
&& tar->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0
) {
if(!checked_los) {
@ -282,7 +282,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
case SpellType_Snare: {
if (
!tar->IsRooted()
&& MakeRandomInt(0, 99) < 50
&& zone->random.Roll(50)
&& tar->DontSnareMeBefore() < Timer::GetCurrentTime()
&& tar->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0
) {
@ -300,7 +300,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) {
}
case SpellType_DOT: {
if (
MakeRandomInt(0, 99) < 60
zone->random.Roll(60)
&& tar->DontDotMeBefore() < Timer::GetCurrentTime()
&& tar->CanBuffStack(AIspells[i].spellid, GetLevel(), true) >= 0
) {
@ -369,7 +369,7 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float
return false;
if (iChance < 100) {
uint8 tmp = MakeRandomInt(0, 99);
uint8 tmp = zone->random.Int(0, 99);
if (tmp >= iChance)
return false;
}
@ -687,7 +687,7 @@ void Client::AI_SpellCast()
}
else
{
uint32 idx = MakeRandomInt(0, (valid_spells.size()-1));
uint32 idx = zone->random.Int(0, (valid_spells.size()-1));
spell_to_cast = valid_spells[idx];
slot_to_use = slots[idx];
}
@ -875,7 +875,7 @@ void Client::AI_Process()
if (flurrychance)
{
if(MakeRandomInt(0, 100) < flurrychance)
if(zone->random.Roll(flurrychance))
{
Message_StringID(MT_NPCFlurry, YOU_FLURRY);
Attack(GetTarget(), MainPrimary, false);
@ -892,7 +892,7 @@ void Client::AI_Process()
wpn->GetItem()->ItemType == ItemType2HBlunt ||
wpn->GetItem()->ItemType == ItemType2HPiercing )
{
if(MakeRandomInt(0, 100) < ExtraAttackChanceBonus)
if(zone->random.Roll(ExtraAttackChanceBonus))
{
Attack(GetTarget(), MainPrimary, false);
}
@ -931,7 +931,7 @@ void Client::AI_Process()
int16 DWBonus = spellbonuses.DualWieldChance + itembonuses.DualWieldChance;
DualWieldProbability += DualWieldProbability*float(DWBonus)/ 100.0f;
if(MakeRandomFloat(0.0, 1.0) < DualWieldProbability)
if(zone->random.Roll(DualWieldProbability))
{
Attack(GetTarget(), MainSecondary);
if(CheckDoubleAttack())
@ -1191,7 +1191,7 @@ void Mob::AI_Process() {
//we use this random value in three comparisons with different
//thresholds, and if its truely random, then this should work
//out reasonably and will save us compute resources.
int32 RandRoll = MakeRandomInt(0, 99);
int32 RandRoll = zone->random.Int(0, 99);
if ((CanThisClassDoubleAttack() || GetSpecialAbility(SPECATK_TRIPLE)
|| GetSpecialAbility(SPECATK_QUAD))
//check double attack, this is NOT the same rules that clients use...
@ -1215,7 +1215,7 @@ void Mob::AI_Process() {
int flurry_chance = GetSpecialAbilityParam(SPECATK_FLURRY, 0);
flurry_chance = flurry_chance > 0 ? flurry_chance : RuleI(Combat, NPCFlurryChance);
if (MakeRandomInt(0, 99) < flurry_chance) {
if (zone->random.Roll(flurry_chance)) {
ExtraAttackOptions opts;
int cur = GetSpecialAbilityParam(SPECATK_FLURRY, 2);
if (cur > 0)
@ -1257,7 +1257,7 @@ void Mob::AI_Process() {
int16 flurry_chance = owner->aabonuses.PetFlurry +
owner->spellbonuses.PetFlurry + owner->itembonuses.PetFlurry;
if (flurry_chance && (MakeRandomInt(0, 99) < flurry_chance))
if (flurry_chance && zone->random.Roll(flurry_chance))
Flurry(nullptr);
}
}
@ -1266,7 +1266,7 @@ void Mob::AI_Process() {
{
int rampage_chance = GetSpecialAbilityParam(SPECATK_RAMPAGE, 0);
rampage_chance = rampage_chance > 0 ? rampage_chance : 20;
if(MakeRandomInt(0, 99) < rampage_chance) {
if(zone->random.Roll(rampage_chance)) {
ExtraAttackOptions opts;
int cur = GetSpecialAbilityParam(SPECATK_RAMPAGE, 2);
if(cur > 0) {
@ -1305,7 +1305,7 @@ void Mob::AI_Process() {
{
int rampage_chance = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 0);
rampage_chance = rampage_chance > 0 ? rampage_chance : 20;
if(MakeRandomInt(0, 99) < rampage_chance) {
if(zone->random.Roll(rampage_chance)) {
ExtraAttackOptions opts;
int cur = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 2);
if(cur > 0) {
@ -1349,13 +1349,12 @@ void Mob::AI_Process() {
//can only dual wield without a weapon if your a monk
if(GetSpecialAbility(SPECATK_INNATE_DW) || (GetEquipment(MaterialSecondary) != 0 && GetLevel() > 29) || myclass == MONK || myclass == MONKGM) {
float DualWieldProbability = (GetSkill(SkillDualWield) + GetLevel()) / 400.0f;
if(MakeRandomFloat(0.0, 1.0) < DualWieldProbability)
if(zone->random.Roll(DualWieldProbability))
{
Attack(target, MainSecondary);
if (CanThisClassDoubleAttack())
{
int32 RandRoll = MakeRandomInt(0, 99);
if (RandRoll < (GetLevel() + 20))
if (zone->random.Roll(GetLevel() + 20))
{
Attack(target, MainSecondary);
}
@ -1619,12 +1618,12 @@ void NPC::AI_DoMovement() {
)
{
float movedist = roambox_distance*roambox_distance;
float movex = MakeRandomFloat(0, movedist);
float movex = zone->random.Real(0, movedist);
float movey = movedist - movex;
movex = sqrtf(movex);
movey = sqrtf(movey);
movex *= MakeRandomInt(0, 1) ? 1 : -1;
movey *= MakeRandomInt(0, 1) ? 1 : -1;
movex *= zone->random.Int(0, 1) ? 1 : -1;
movey *= zone->random.Int(0, 1) ? 1 : -1;
roambox_movingto_x = GetX() + movex;
roambox_movingto_y = GetY() + movey;
//Try to calculate new coord using distance.
@ -1635,9 +1634,9 @@ void NPC::AI_DoMovement() {
//New coord is still invalid, ignore distance and just pick a new random coord.
//If we're here we may have a roambox where one side is shorter than the specified distance. Commons, Wkarana, etc.
if (roambox_movingto_x > roambox_max_x || roambox_movingto_x < roambox_min_x)
roambox_movingto_x = MakeRandomFloat(roambox_min_x+1,roambox_max_x-1);
roambox_movingto_x = zone->random.Real(roambox_min_x+1,roambox_max_x-1);
if (roambox_movingto_y > roambox_max_y || roambox_movingto_y < roambox_min_y)
roambox_movingto_y = MakeRandomFloat(roambox_min_y+1,roambox_max_y-1);
roambox_movingto_y = zone->random.Real(roambox_min_y+1,roambox_max_y-1);
}
mlog(AI__WAYPOINTS, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)",
@ -1879,7 +1878,7 @@ void Mob::AI_Event_NoLongerEngaged() {
if (minLastFightingDelayMoving == maxLastFightingDelayMoving)
pLastFightingDelayMoving += minLastFightingDelayMoving;
else
pLastFightingDelayMoving += MakeRandomInt(minLastFightingDelayMoving, maxLastFightingDelayMoving);
pLastFightingDelayMoving += zone->random.Int(minLastFightingDelayMoving, maxLastFightingDelayMoving);
// So mobs don't keep running as a ghost until AIwalking_timer fires
// if they were moving prior to losing all hate
if(IsMoving()){

View File

@ -293,7 +293,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float
if(trap_list.size() > 0)
{
std::list<LDoNTrapTemplate*>::iterator trap_list_iter = trap_list.begin();
std::advance(trap_list_iter, MakeRandomInt(0, trap_list.size() - 1));
std::advance(trap_list_iter, zone->random.Int(0, trap_list.size() - 1));
LDoNTrapTemplate* tt = (*trap_list_iter);
if(tt)
{
@ -550,10 +550,10 @@ void NPC::AddCash(uint16 in_copper, uint16 in_silver, uint16 in_gold, uint16 in_
}
void NPC::AddCash() {
copper = MakeRandomInt(1, 100);
silver = MakeRandomInt(1, 50);
gold = MakeRandomInt(1, 10);
platinum = MakeRandomInt(1, 5);
copper = zone->random.Int(1, 100);
silver = zone->random.Int(1, 50);
gold = zone->random.Int(1, 10);
platinum = zone->random.Int(1, 5);
}
void NPC::RemoveCash() {
@ -1372,7 +1372,7 @@ void NPC::PickPocket(Client* thief) {
return;
}
if(MakeRandomInt(0, 100) > 95){
if(zone->random.Roll(5)) {
AddToHateList(thief, 50);
Say("Stop thief!");
thief->Message(13, "You are noticed trying to steal!");
@ -1401,7 +1401,7 @@ void NPC::PickPocket(Client* thief) {
memset(charges,0,50);
//Determine wheter to steal money or an item.
bool no_coin = ((money[0] + money[1] + money[2] + money[3]) == 0);
bool steal_item = (MakeRandomInt(0, 99) < 50 || no_coin);
bool steal_item = (zone->random.Roll(50) || no_coin);
if (steal_item)
{
ItemList::iterator cur,end;
@ -1431,7 +1431,7 @@ void NPC::PickPocket(Client* thief) {
}
if (x > 0)
{
int random = MakeRandomInt(0, x-1);
int random = zone->random.Int(0, x-1);
inst = database.CreateItem(steal_items[random], charges[random]);
if (inst)
{
@ -1466,7 +1466,7 @@ void NPC::PickPocket(Client* thief) {
}
if (!steal_item) //Steal money
{
uint32 amt = MakeRandomInt(1, (steal_skill/25)+1);
uint32 amt = zone->random.Int(1, (steal_skill/25)+1);
int steal_type = 0;
if (!money[0])
{
@ -1481,7 +1481,7 @@ void NPC::PickPocket(Client* thief) {
}
}
if (MakeRandomInt(0, 100) <= stealchance)
if (zone->random.Roll(stealchance))
{
switch (steal_type)
{
@ -1962,7 +1962,7 @@ void NPC::ModifyNPCStat(const char *identifier, const char *newValue)
void NPC::LevelScale() {
uint8 random_level = (MakeRandomInt(level, maxlevel));
uint8 random_level = (zone->random.Int(level, maxlevel));
float scaling = (((random_level / (float)level) - 1) * (scalerate / 100.0f));

View File

@ -441,8 +441,8 @@ void Object::RandomSpawn(bool send_packet) {
if(!m_ground_spawn)
return;
m_data.x = MakeRandomFloat(m_min_x, m_max_x);
m_data.y = MakeRandomFloat(m_min_y, m_max_y);
m_data.x = zone->random.Real(m_min_x, m_max_x);
m_data.y = zone->random.Real(m_min_y, m_max_y);
respawn_timer.Disable();
if(send_packet) {

View File

@ -1344,7 +1344,7 @@ PathNode* PathManager::FindPathNodeByCoordinates(float x, float y, float z)
int PathManager::GetRandomPathNode()
{
return MakeRandomInt(0, Head.PathNodeCount - 1);
return zone->random.Int(0, Head.PathNodeCount - 1);
}

View File

@ -109,7 +109,7 @@ const char *GetRandPetName()
"Zibann","Zibarer","Zibartik","Zibekn","Zibn","Zibobn","Zobaner","Zobann",
"Zobarn","Zober","Zobn","Zonanab","Zonaner","Zonann","Zonantik","Zonarer",
"Zonartik","Zonobn","Zonobtik","Zontik","Ztik" };
int r = MakeRandomInt(0, (sizeof(petnames)/sizeof(const char *))-1);
int r = zone->random.Int(0, (sizeof(petnames)/sizeof(const char *))-1);
printf("Pet being created: %s\n",petnames[r]); // DO NOT COMMENT THIS OUT!
return petnames[r];
}

View File

@ -109,7 +109,7 @@ uint32 Spawn2::resetTimer()
if (variance_ != 0) {
int var_over_2 = (variance_ * 1000) / 2;
rspawn = MakeRandomInt(rspawn - var_over_2, rspawn + var_over_2);
rspawn = zone->random.Int(rspawn - var_over_2, rspawn + var_over_2);
//put a lower bound on it, not a lot of difference below 100, so set that as the bound.
if(rspawn < 100)
@ -126,7 +126,7 @@ uint32 Spawn2::despawnTimer(uint32 despawn_timer)
if (variance_ != 0) {
int var_over_2 = (variance_ * 1000) / 2;
dspawn = MakeRandomInt(dspawn - var_over_2, dspawn + var_over_2);
dspawn = zone->random.Int(dspawn - var_over_2, dspawn + var_over_2);
//put a lower bound on it, not a lot of difference below 100, so set that as the bound.
if(dspawn < 100)

View File

@ -25,8 +25,10 @@
#include "zonedb.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h"
#include "zone.h"
extern EntityList entity_list;
extern Zone* zone;
SpawnEntry::SpawnEntry( uint32 in_NPCType, int in_chance, uint8 in_npc_spawn_limit ) {
NPCType = in_NPCType;
@ -77,7 +79,7 @@ uint32 SpawnGroup::GetNPCType() {
int32 roll = 0;
roll = MakeRandomInt(0, totalchance-1);
roll = zone->random.Int(0, totalchance-1);
cur = possible.begin();
end = possible.end();

View File

@ -155,7 +155,7 @@ void Mob::DoSpecialAttackDamage(Mob *who, SkillUseTypes skill, int32 max_damage,
int kb_chance = 25;
kb_chance += kb_chance*(100-aabonuses.SpecialAttackKBProc[0])/100;
if (MakeRandomInt(0, 99) < kb_chance)
if (zone->random.Roll(kb_chance))
SpellFinished(904, who, 10, 0, -1, spells[904].ResistDiff);
//who->Stun(100); Kayen: This effect does not stun on live, it only moves the NPC.
}
@ -256,7 +256,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) {
if(RuleB(Combat, UseIntervalAC))
ht = dmg = GetBashDamage();
else
ht = dmg = MakeRandomInt(1, GetBashDamage());
ht = dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -295,8 +295,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) {
//Live parses show around 55% Triple 35% Double 10% Single, you will always get first hit.
while(AtkRounds > 0) {
if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){
if (GetTarget() && (AtkRounds == 1 || zone->random.Roll(75))) {
DoSpecialAttackDamage(GetTarget(), SkillFrenzy, max_dmg, min_dmg, max_dmg , ReuseTime, true);
}
AtkRounds--;
@ -333,7 +332,7 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) {
if(RuleB(Combat, UseIntervalAC))
ht = dmg = GetKickDamage();
else
ht = dmg = MakeRandomInt(1, GetKickDamage());
ht = dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -348,18 +347,18 @@ void Client::OPCombatAbility(const EQApplicationPacket *app) {
//Live AA - Technique of Master Wu
int wuchance = itembonuses.DoubleSpecialAttack + spellbonuses.DoubleSpecialAttack + aabonuses.DoubleSpecialAttack;
if (wuchance) {
if (wuchance >= 100 || wuchance > MakeRandomInt(0, 99)) {
if (wuchance >= 100 || zone->random.Roll(wuchance)) {
int MonkSPA [5] = { SkillFlyingKick, SkillDragonPunch, SkillEagleStrike, SkillTigerClaw, SkillRoundKick };
int extra = 1;
// always 1/4 of the double attack chance, 25% at rank 5 (100/4)
if (wuchance / 4 > MakeRandomInt(0, 99))
if (zone->random.Roll(wuchance / 4))
extra++;
// They didn't add a string ID for this.
std::string msg = StringFormat("The spirit of Master Wu fills you! You gain %d additional attack(s).", extra);
// live uses 400 here -- not sure if it's the best for all clients though
SendColoredText(400, msg);
while (extra) {
MonkSpecialAttack(GetTarget(), MonkSPA[MakeRandomInt(0, 4)]);
MonkSpecialAttack(GetTarget(), MonkSPA[zone->random.Int(0, 4)]);
extra--;
}
}
@ -484,7 +483,7 @@ int Mob::MonkSpecialAttack(Mob* other, uint8 unchecked_type)
if(RuleB(Combat, UseIntervalAC))
ht = ndamage = max_dmg;
else
ht = ndamage = MakeRandomInt(min_dmg, max_dmg);
ht = ndamage = zone->random.Int(min_dmg, max_dmg);
}
else{
ht = max_dmg;
@ -525,12 +524,11 @@ void Mob::TryBackstab(Mob *other, int ReuseTime) {
//Live AA - Seized Opportunity
int FrontalBSChance = itembonuses.FrontalBackstabChance + spellbonuses.FrontalBackstabChance + aabonuses.FrontalBackstabChance;
if (FrontalBSChance && (FrontalBSChance > MakeRandomInt(0, 100)))
if (FrontalBSChance && zone->random.Roll(FrontalBSChance))
bCanFrontalBS = true;
}
if (bIsBehind || bCanFrontalBS){ // Player is behind other OR can do Frontal Backstab
if (bCanFrontalBS)
CastToClient()->Message(0,"Your fierce attack is executed with such grace, your target did not see it coming!");
@ -541,7 +539,7 @@ void Mob::TryBackstab(Mob *other, int ReuseTime) {
if(other->GetHP() > 0)
RogueBackstab(other,false,ReuseTime);
if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100))
if (tripleChance && other->GetHP() > 0 && zone->random.Roll(tripleChance))
RogueBackstab(other,false,ReuseTime);
}
}
@ -562,7 +560,7 @@ void Mob::TryBackstab(Mob *other, int ReuseTime) {
if(other->GetHP() > 0)
RogueBackstab(other,true, ReuseTime);
if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100))
if (tripleChance && other->GetHP() > 0 && zone->random.Roll(tripleChance))
RogueBackstab(other,false,ReuseTime);
}
@ -640,7 +638,7 @@ void Mob::RogueBackstab(Mob* other, bool min_damage, int ReuseTime)
if(RuleB(Combat, UseIntervalAC))
ndamage = max_hit;
else
ndamage = MakeRandomInt(min_hit, max_hit);
ndamage = zone->random.Int(min_hit, max_hit);
}
}
}
@ -793,7 +791,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) {
//EndlessQuiver AA base1 = 100% Chance to avoid consumption arrow.
int ChanceAvoidConsume = aabonuses.ConsumeProjectile + itembonuses.ConsumeProjectile + spellbonuses.ConsumeProjectile;
if (!ChanceAvoidConsume || (ChanceAvoidConsume < 100 && MakeRandomInt(0,99) > ChanceAvoidConsume)){
if (!ChanceAvoidConsume || (ChanceAvoidConsume < 100 && zone->random.Int(0,99) > ChanceAvoidConsume)){
DeleteItemInInventory(ammo_slot, 1, true);
mlog(COMBAT__RANGED, "Consumed one arrow from slot %d", ammo_slot);
} else {
@ -920,11 +918,10 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Ite
bool dobonus = false;
if(GetClass() == RANGER && GetLevel() > 50){
int bonuschance = RuleI(Combat, ArcheryBonusChance);
bonuschance = mod_archery_bonus_chance(bonuschance, RangeWeapon);
if( !RuleB(Combat, UseArcheryBonusRoll) || (MakeRandomInt(1, 100) < bonuschance)){
if( !RuleB(Combat, UseArcheryBonusRoll) || zone->random.Roll(bonuschance)){
if(RuleB(Combat, ArcheryBonusRequiresStationary)){
if(other->IsNPC() && !other->IsMoving() && !other->IsRooted())
dobonus = true;
@ -949,7 +946,7 @@ void Mob::DoArcheryAttackDmg(Mob* other, const ItemInst* RangeWeapon, const Ite
if(RuleB(Combat, UseIntervalAC))
TotalDmg = MaxDmg;
else
TotalDmg = MakeRandomInt(1, MaxDmg);
TotalDmg = zone->random.Int(1, MaxDmg);
int minDmg = 1;
if(GetLevel() > 25){
@ -1218,7 +1215,7 @@ void NPC::RangedAttack(Mob* other)
if(RuleB(Combat, UseIntervalAC))
TotalDmg = MaxDmg;
else
TotalDmg = MakeRandomInt(MinDmg, MaxDmg);
TotalDmg = zone->random.Int(MinDmg, MaxDmg);
TotalDmg += TotalDmg * GetSpecialAbilityParam(SPECATK_RANGED_ATK, 3) / 100; //Damage modifier
@ -1262,7 +1259,7 @@ uint16 Mob::GetThrownDamage(int16 wDmg, int32& TotalDmg, int& minDmg) {
if(RuleB(Combat, UseIntervalAC))
TotalDmg = MaxDmg;
else
TotalDmg = MakeRandomInt(1, MaxDmg);
TotalDmg = zone->random.Int(1, MaxDmg);
minDmg = 1;
if(GetLevel() > 25){
@ -1680,7 +1677,7 @@ void NPC::DoClassAttacks(Mob *target) {
}
case WARRIOR: case WARRIORGM:{
if(level >= RuleI(Combat, NPCBashKickLevel)){
if(MakeRandomInt(0, 100) > 25){ //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
if(zone->random.Roll(75)) { //tested on live, warrior mobs both kick and bash, kick about 75% of the time, casting doesn't seem to make a difference.
DoAnim(animKick);
int32 dmg = 0;
@ -1692,7 +1689,7 @@ void NPC::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetKickDamage();
else
dmg = MakeRandomInt(1, GetKickDamage());
dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -1713,7 +1710,7 @@ void NPC::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetBashDamage();
else
dmg = MakeRandomInt(1, GetBashDamage());
dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -1741,7 +1738,7 @@ void NPC::DoClassAttacks(Mob *target) {
reuse = FrenzyReuseTime * 1000;
while(AtkRounds > 0) {
if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){
if (GetTarget() && (AtkRounds == 1 || zone->random.Roll(75))) {
DoSpecialAttackDamage(GetTarget(), SkillFrenzy, max_dmg, min_dmg, -1 , reuse, true);
}
AtkRounds--;
@ -1766,7 +1763,7 @@ void NPC::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetKickDamage();
else
dmg = MakeRandomInt(1, GetKickDamage());
dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -1791,7 +1788,7 @@ void NPC::DoClassAttacks(Mob *target) {
if(RuleB(Combat, UseIntervalAC))
dmg = GetBashDamage();
else
dmg = MakeRandomInt(1, GetBashDamage());
dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -1900,7 +1897,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte)
if(RuleB(Combat, UseIntervalAC))
dmg = GetBashDamage();
else
dmg = MakeRandomInt(1, GetBashDamage());
dmg = zone->random.Int(1, GetBashDamage());
}
}
@ -1937,7 +1934,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte)
//Live parses show around 55% Triple 35% Double 10% Single, you will always get first hit.
while(AtkRounds > 0) {
if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){
if (GetTarget() && (AtkRounds == 1 || zone->random.Roll(75))) {
DoSpecialAttackDamage(GetTarget(), SkillFrenzy, max_dmg, min_dmg, max_dmg , ReuseTime, true);
}
AtkRounds--;
@ -1964,7 +1961,7 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte)
if(RuleB(Combat, UseIntervalAC))
dmg = GetKickDamage();
else
dmg = MakeRandomInt(1, GetKickDamage());
dmg = zone->random.Int(1, GetKickDamage());
}
}
@ -1984,17 +1981,17 @@ void Client::DoClassAttacks(Mob *ca_target, uint16 skill, bool IsRiposte)
//Live AA - Technique of Master Wu
int wuchance = itembonuses.DoubleSpecialAttack + spellbonuses.DoubleSpecialAttack + aabonuses.DoubleSpecialAttack;
if (wuchance) {
if (wuchance >= 100 || wuchance > MakeRandomInt(0, 99)) {
if (wuchance >= 100 || zone->random.Roll(wuchance)) {
int MonkSPA [5] = { SkillFlyingKick, SkillDragonPunch, SkillEagleStrike, SkillTigerClaw, SkillRoundKick };
int extra = 1;
if (wuchance / 4 > MakeRandomInt(0, 99))
if (zone->random.Roll(wuchance / 4))
extra++;
// They didn't add a string ID for this.
std::string msg = StringFormat("The spirit of Master Wu fills you! You gain %d additional attack(s).", extra);
// live uses 400 here -- not sure if it's the best for all clients though
SendColoredText(400, msg);
while (extra) {
MonkSpecialAttack(ca_target, MonkSPA[MakeRandomInt(0, 4)]);
MonkSpecialAttack(ca_target, MonkSPA[zone->random.Int(0, 4)]);
extra--;
}
}
@ -2078,7 +2075,7 @@ void Mob::Taunt(NPC* who, bool always_succeed, float chance_bonus) {
tauntchance /= 100.0f;
if (tauntchance > MakeRandomFloat(0, 1)) {
if (tauntchance > zone->random.Real(0, 1)) {
if (hate_top && hate_top != this){
newhate = (who->GetNPCHate(hate_top) - who->GetNPCHate(this)) + 1;
who->CastToNPC()->AddToHateList(this, newhate);
@ -2134,7 +2131,7 @@ void Mob::InstillDoubt(Mob *who) {
//target's counters
value -= target->GetLevel()*4 + who->GetWIS()/4;
if (MakeRandomInt(0,99) < value) {
if (zone->random.Roll(value)) {
//temporary hack...
//cast fear on them... should prolly be a different spell
//and should be un-resistable.
@ -2143,7 +2140,7 @@ void Mob::InstillDoubt(Mob *who) {
} else {
Message_StringID(4,NOT_SCARING);
//Idea from WR:
/* if (target->IsNPC() && MakeRandomInt(0,99) < 10 ) {
/* if (target->IsNPC() && zone->random.Int(0,99) < 10 ) {
entity_list.MessageClose(target, false, 50, MT_NPCRampage, "%s lashes out in anger!",target->GetName());
//should we actually do this? and the range is completely made up, unconfirmed
entity_list.AEAttack(target, 50);
@ -2166,7 +2163,7 @@ uint32 Mob::TryHeadShot(Mob* defender, SkillUseTypes skillInUse) {
if(HeadShot_Dmg && HeadShot_Level && (defender->GetLevel() <= HeadShot_Level)){
float ProcChance = GetSpecialProcChances(MainRange);
if(ProcChance > MakeRandomFloat(0,1))
if(zone->random.Roll(ProcChance))
return HeadShot_Dmg;
}
}
@ -2232,7 +2229,7 @@ uint32 Mob::TryAssassinate(Mob* defender, SkillUseTypes skillInUse, uint16 Reuse
else
ProcChance = GetAssassinateProcChances(ReuseTime);
if(ProcChance > MakeRandomFloat(0,1))
if(zone->random.Roll(ProcChance))
return Assassinate_Dmg;
}
}
@ -2323,7 +2320,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes
if(RuleB(Combat, UseIntervalAC))
damage = max_hit;
else
damage = MakeRandomInt(min_hit, max_hit);
damage = zone->random.Int(min_hit, max_hit);
if(!other->CheckHitChance(this, skillinuse, Hand, chance_mod)) {
damage = 0;
@ -2362,7 +2359,7 @@ void Mob::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillUseTypes
int kb_chance = 25;
kb_chance += kb_chance*(100-aabonuses.SpecialAttackKBProc[0])/100;
if (MakeRandomInt(0, 99) < kb_chance)
if (zone->random.Roll(kb_chance))
SpellFinished(904, other, 10, 0, -1, spells[904].ResistDiff);
}

View File

@ -455,7 +455,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
if(IsClient())
{
if(MakeRandomInt(0, 99) < RuleI(Spells, SuccorFailChance)) { //2% Fail chance by default
if(zone->random.Roll(RuleI(Spells, SuccorFailChance))) { //2% Fail chance by default
if(IsClient()) {
CastToClient()->Message_StringID(MT_SpellFailure,SUCCOR_FAIL);
@ -710,7 +710,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
if (IsClient())
stun_resist += aabonuses.StunResist;
if (stun_resist <= 0 || MakeRandomInt(0,99) >= stun_resist) {
if (stun_resist <= 0 || zone->random.Int(0,99) >= stun_resist) {
mlog(COMBAT__HITS, "Stunned. We had %d percent resist chance.", stun_resist);
if (caster->IsClient())
@ -1033,7 +1033,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
#endif
if(!spellbonuses.AntiGate){
if(MakeRandomInt(0, 99) < effect_value)
if(zone->random.Roll(effect_value))
Gate();
else
caster->Message_StringID(MT_SpellFailure,GATE_FAIL);
@ -1477,14 +1477,14 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
int bonus = 0;
if (caster){
bonus = caster->spellbonuses.IncreaseChanceMemwipe +
bonus = caster->spellbonuses.IncreaseChanceMemwipe +
caster->itembonuses.IncreaseChanceMemwipe +
caster->aabonuses.IncreaseChanceMemwipe;
}
wipechance += wipechance*bonus/100;
if(MakeRandomInt(0, 99) < wipechance)
if(zone->random.Roll(wipechance))
{
if(IsAIControlled())
{
@ -1597,7 +1597,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
if(IsClient()) {
if (MakeRandomInt(0, 99) > spells[spell_id].base[i]) {
if (zone->random.Int(0, 99) > spells[spell_id].base[i]) {
CastToClient()->SetFeigned(false);
entity_list.MessageClose_StringID(this, false, 200, 10, STRING_FEIGNFAILED, GetName());
}
@ -2187,7 +2187,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Fading Memories");
#endif
if(MakeRandomInt(0, 99) < spells[spell_id].base[i] ) {
if(zone->random.Roll(spells[spell_id].base[i])) {
if(caster && caster->IsClient())
caster->CastToClient()->Escape();
@ -2713,7 +2713,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
int32 newhate = GetHateAmount(caster) + effect_value;
if (newhate < 1)
SetHate(caster,1);
else
else
SetHate(caster,newhate);
}
}
@ -2724,7 +2724,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
if (buffslot >= 0)
break;
if(!spells[spell_id].uninterruptable && IsCasting() && MakeRandomInt(0, 100) <= spells[spell_id].base[i])
if(!spells[spell_id].uninterruptable && IsCasting() && zone->random.Roll(spells[spell_id].base[i]))
InterruptSpell();
break;
@ -2746,8 +2746,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
case SE_ApplyEffect: {
if (caster && IsValidSpell(spells[spell_id].base2[i])){
if(MakeRandomInt(0, 100) <= spells[spell_id].base[i])
if(zone->random.Roll(spells[spell_id].base[i]))
caster->SpellFinished(spells[spell_id].base2[i], this, 10, 0, -1, spells[spells[spell_id].base2[i]].ResistDiff);
}
break;
@ -3209,7 +3208,7 @@ snare has both of them negative, yet their range should work the same:
break;
}
case 123: // added 2/6/04
result = MakeRandomInt(ubase, abs(max));
result = zone->random.Int(ubase, abs(max));
break;
case 124: // check sign
@ -3582,7 +3581,7 @@ void Mob::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
wipechance += wipechance*bonus/100;
if(MakeRandomInt(0, 99) < wipechance)
if(zone->random.Roll(wipechance))
{
if(IsAIControlled())
{
@ -3602,13 +3601,11 @@ void Mob::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
}
case SE_Root: {
/* Root formula derived from extensive personal live parses - Kayen
ROOT has a 70% chance to do a resist check to break.
*/
if (MakeRandomInt(0, 99) < RuleI(Spells, RootBreakCheckChance)){
if (zone->random.Roll(RuleI(Spells, RootBreakCheckChance))) {
float resist_check = ResistSpell(spells[spell_id].resisttype, spell_id, caster, 0,0,0,0,true);
if(resist_check == 100)
@ -3623,8 +3620,7 @@ void Mob::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
case SE_Fear:
{
if (MakeRandomInt(0, 99) < RuleI(Spells, FearBreakCheckChance)){
if (zone->random.Roll(RuleI(Spells, FearBreakCheckChance))) {
float resist_check = ResistSpell(spells[spell_id].resisttype, spell_id, caster);
if(resist_check == 100)
@ -3664,7 +3660,7 @@ void Mob::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
break_chance -= (2 * (((double)GetSkill(SkillDivination) + ((double)GetLevel() * 3.0)) / 650.0));
}
if(MakeRandomFloat(0.0, 100.0) < break_chance)
if(zone->random.Real(0.0, 100.0) < break_chance)
{
BuffModifyDurationBySpellID(spell_id, 3);
}
@ -3684,7 +3680,7 @@ void Mob::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
{
if(IsCasting())
{
if(MakeRandomInt(0, 100) <= spells[spell_id].base[i])
if(zone->random.Roll(spells[spell_id].base[i]))
{
InterruptSpell();
}
@ -4582,11 +4578,9 @@ int16 Client::CalcAAFocus(focusType type, uint32 aa_ID, uint16 spell_id)
case SE_TriggerOnCast:
if(type == focusTriggerOnCast){
if(MakeRandomInt(0, 100) <= base1){
if(zone->random.Roll(base1)) {
value = base2;
}
else{
} else {
value = 0;
LimitFailure = true;
}
@ -4600,7 +4594,7 @@ int16 Client::CalcAAFocus(focusType type, uint32 aa_ID, uint16 spell_id)
case SE_BlockNextSpellFocus:
if(type == focusBlockNextSpell){
if(MakeRandomInt(1, 100) <= base1)
if(zone->random.Roll(base1))
value = 1;
}
break;
@ -4955,7 +4949,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -4974,7 +4968,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -4993,7 +4987,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
value = focus_spell.base[i];
}
else {
value = MakeRandomInt(focus_spell.base[i], focus_spell.base2[i]);
value = zone->random.Int(focus_spell.base[i], focus_spell.base2[i]);
}
}
break;
@ -5062,7 +5056,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
case SE_TriggerOnCast:
if(type == focusTriggerOnCast){
if(MakeRandomInt(1, 100) <= focus_spell.base[i])
if(zone->random.Roll(focus_spell.base[i]))
value = focus_spell.base2[i];
else
value = 0;
@ -5071,7 +5065,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo
case SE_BlockNextSpellFocus:
if(type == focusBlockNextSpell){
if(MakeRandomInt(1, 100) <= focus_spell.base[i])
if(zone->random.Roll(focus_spell.base[i]))
value = 1;
}
break;
@ -5219,12 +5213,9 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
if (TempItem && TempItem->Focus.Effect > 0 && IsValidSpell(TempItem->Focus.Effect)) {
proc_spellid = CalcFocusEffect(type, TempItem->Focus.Effect, spell_id);
if (IsValidSpell(proc_spellid)){
ProcChance = GetSympatheticProcChances(spell_id, spells[TempItem->Focus.Effect].base[0], TempItem->ProcRate);
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Roll(ProcChance))
SympatheticProcList.push_back(proc_spellid);
}
}
@ -5240,14 +5231,10 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
{
const Item_Struct* TempItemAug = aug->GetItem();
if (TempItemAug && TempItemAug->Focus.Effect > 0 && IsValidSpell(TempItemAug->Focus.Effect)) {
proc_spellid = CalcFocusEffect(type, TempItemAug->Focus.Effect, spell_id);
if (IsValidSpell(proc_spellid)){
ProcChance = GetSympatheticProcChances(spell_id, spells[TempItemAug->Focus.Effect].base[0], TempItemAug->ProcRate);
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Roll(ProcChance))
SympatheticProcList.push_back(proc_spellid);
}
}
@ -5275,8 +5262,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
if (IsValidSpell(proc_spellid)){
ProcChance = GetSympatheticProcChances(spell_id, spells[focusspellid].base[0]);
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Roll(ProcChance))
SympatheticProcList.push_back(proc_spellid);
}
}
@ -5302,10 +5288,8 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
proc_spellid = CalcAAFocus(type, aa_AA, spell_id);
if (IsValidSpell(proc_spellid)){
ProcChance = GetSympatheticProcChances(spell_id, GetAABase1(aa_AA, 1));
if(MakeRandomFloat(0, 1) <= ProcChance)
if(zone->random.Roll(ProcChance))
SympatheticProcList.push_back(proc_spellid);
}
}
@ -5313,7 +5297,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) {
if (SympatheticProcList.size() > 0)
{
uint8 random = MakeRandomInt(0, SympatheticProcList.size()-1);
uint8 random = zone->random.Int(0, SympatheticProcList.size()-1);
int FinalSympatheticProc = SympatheticProcList[random];
SympatheticProcList.clear();
return FinalSympatheticProc;
@ -5672,7 +5656,7 @@ bool Mob::TryDivineSave()
*/
int32 SuccessChance = aabonuses.DivineSaveChance[0] + itembonuses.DivineSaveChance[0] + spellbonuses.DivineSaveChance[0];
if (SuccessChance && MakeRandomInt(0, 100) <= SuccessChance)
if (SuccessChance && zone->random.Roll(SuccessChance))
{
SetHP(1);
@ -5731,7 +5715,7 @@ bool Mob::TryDeathSave() {
if (SuccessChance > 95)
SuccessChance = 95;
if(SuccessChance >= MakeRandomInt(0, 100)) {
if(zone->random.Roll(SuccessChance)) {
if(spellbonuses.DeathSave[0] == 2)
HealAmt = RuleI(Spells, DivineInterventionHeal); //8000HP is how much LIVE Divine Intervention max heals
@ -5762,7 +5746,7 @@ bool Mob::TryDeathSave() {
if (SuccessChance > 95)
SuccessChance = 95;
if(SuccessChance >= MakeRandomInt(0, 100)) {
if(zone->random.Roll(SuccessChance)) {
if(spellbonuses.DeathSave[0] == 2)
HealAmt = RuleI(Spells, DivineInterventionHeal);
@ -6064,7 +6048,7 @@ bool Mob::TryDispel(uint8 caster_level, uint8 buff_level, int level_modifier){
else if (dispel_chance < 10)
dispel_chance = 10;
if (MakeRandomInt(0,99) < dispel_chance)
if (zone->random.Roll(dispel_chance))
return true;
else
return false;

View File

@ -178,7 +178,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot,
if(IsClient()){
int chance = CastToClient()->GetFocusEffect(focusFcMute, spell_id);
if (MakeRandomInt(0,99) < chance){
if (zone->random.Roll(chance)) {
Message_StringID(13, SILENCED_STRING);
if(IsClient())
CastToClient()->SendSpellBarEnable(spell_id);
@ -697,7 +697,7 @@ bool Client::CheckFizzle(uint16 spell_id)
specialize = specialize * 1.3;
break;
}
if(((specialize/6.0f) + 15.0f) < MakeRandomFloat(0, 100)) {
if(((specialize/6.0f) + 15.0f) < zone->random.Real(0, 100)) {
specialize *= SPECIALIZE_FIZZLE / 200.0f;
} else {
specialize = 0.0f;
@ -739,7 +739,7 @@ bool Client::CheckFizzle(uint16 spell_id)
}
*/
float fizzle_roll = MakeRandomFloat(0, 100);
float fizzle_roll = zone->random.Real(0, 100);
mlog(SPELLS__CASTING, "Check Fizzle %s spell %d fizzlechance: %0.2f%% diff: %0.2f roll: %0.2f", GetName(), spell_id, fizzlechance, diff, fizzle_roll);
@ -1028,7 +1028,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot,
mlog(SPELLS__CASTING, "Checking Interruption: spell x: %f spell y: %f cur x: %f cur y: %f channelchance %f channeling skill %d\n", GetSpellX(), GetSpellY(), GetX(), GetY(), channelchance, GetSkill(SkillChanneling));
if(!spells[spell_id].uninterruptable && MakeRandomFloat(0, 100) > channelchance) {
if(!spells[spell_id].uninterruptable && zone->random.Real(0, 100) > channelchance) {
mlog(SPELLS__CASTING_ERR, "Casting of %d canceled: interrupted.", spell_id);
InterruptSpell();
return;
@ -1044,7 +1044,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, uint16 slot,
// first check for component reduction
if(IsClient()) {
int reg_focus = CastToClient()->GetFocusEffect(focusReagentCost,spell_id);
if(MakeRandomInt(1, 100) <= reg_focus) {
if(zone->random.Roll(reg_focus)) {
mlog(SPELLS__CASTING, "Spell %d: Reagent focus item prevented reagent consumption (%d chance)", spell_id, reg_focus);
} else {
if(reg_focus > 0)
@ -4204,7 +4204,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use
{
IsFear = true;
int fear_resist_bonuses = CalcFearResistChance();
if(MakeRandomInt(0, 99) < fear_resist_bonuses)
if(zone->random.Roll(fear_resist_bonuses))
{
mlog(SPELLS__RESISTS, "Resisted spell in fear resistance, had %d chance to resist", fear_resist_bonuses);
return 0;
@ -4215,14 +4215,14 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use
//Check for Spell Effect specific resistance chances (ie AA Mental Fortitude)
int se_resist_bonuses = GetSpellEffectResistChance(spell_id);
if(se_resist_bonuses && (MakeRandomInt(0, 99) < se_resist_bonuses))
if(se_resist_bonuses && zone->random.Roll(se_resist_bonuses))
{
return 0;
}
// Check for Chance to Resist Spell bonuses (ie Sanctification Discipline)
int resist_bonuses = CalcResistChanceBonus();
if(resist_bonuses && (MakeRandomInt(0, 99) < resist_bonuses))
if(resist_bonuses && zone->random.Roll(resist_bonuses))
{
mlog(SPELLS__RESISTS, "Resisted spell in sanctification, had %d chance to resist", resist_bonuses);
return 0;
@ -4448,7 +4448,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use
}
//Finally our roll
int roll = MakeRandomInt(0, 200);
int roll = zone->random.Int(0, 200);
if(roll > resist_chance)
{
return 100;
@ -4665,7 +4665,7 @@ void Mob::Stun(int duration)
if(IsValidSpell(casting_spell_id) && !spells[casting_spell_id].uninterruptable) {
int persistent_casting = spellbonuses.PersistantCasting + itembonuses.PersistantCasting + aabonuses.PersistantCasting;
if(MakeRandomInt(0,99) > persistent_casting)
if(zone->random.Int(0,99) > persistent_casting)
InterruptSpell();
}

View File

@ -923,7 +923,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
_log(TRADESKILLS__TRACE, "...Current skill: %d , Trivial: %d , Success chance: %f percent", user_skill , spec->trivial , chance);
_log(TRADESKILLS__TRACE, "...Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR());
float res = MakeRandomFloat(0, 99);
float res = zone->random.Real(0, 99);
int aa_chance = 0;
//AA modifiers
@ -1057,7 +1057,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
chance = mod_tradeskill_chance(chance, spec);
if (((spec->tradeskill==75) || GetGM() || (chance > res)) || MakeRandomInt(0, 99) < aa_chance){
if (((spec->tradeskill==75) || GetGM() || (chance > res)) || zone->random.Roll(aa_chance)) {
success_modifier = 1;
if(over_trivial < 0)
@ -1127,7 +1127,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
uint8 sc = 0;
while(itr != spec->salvage.end()) {
for(sc = 0; sc < itr->second; sc++)
if(MakeRandomInt(0,99) < SalvageChance)
if(zone->random.Roll(SalvageChance))
SummonItem(itr->first, 1);
++itr;
}
@ -1153,7 +1153,7 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float
//In stage2 the only thing that matters is your current unmodified skill.
//If you want to customize here you probbably need to implement your own
//formula instead of tweaking the below one.
if (chance_stage1 > MakeRandomFloat(0, 99)) {
if (chance_stage1 > zone->random.Real(0, 99)) {
if (current_raw_skill < 15) {
//Always succeed
chance_stage2 = 100;
@ -1168,7 +1168,7 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float
chance_stage2 = mod_tradeskill_skillup(chance_stage2);
if (chance_stage2 > MakeRandomFloat(0, 99)) {
if (chance_stage2 > zone->random.Real(0, 99)) {
//Only if stage1 and stage2 succeeded you get a skillup.
SetSkill(tradeskill, current_raw_skill + 1);

View File

@ -144,7 +144,7 @@ void Trap::Trigger(Mob* trigger)
{
if ((tmp = database.GetNPCType(effectvalue)))
{
NPC* new_npc = new NPC(tmp, 0, x-5+MakeRandomInt(0, 10), y-5+MakeRandomInt(0, 10), z-5+MakeRandomInt(0, 10), MakeRandomInt(0, 249), FlyMode3);
NPC* new_npc = new NPC(tmp, 0, x-5+zone->random.Int(0, 10), y-5+zone->random.Int(0, 10), z-5+zone->random.Int(0, 10), zone->random.Int(0, 249), FlyMode3);
new_npc->AddLootTable();
entity_list.AddNPC(new_npc);
new_npc->AddToHateList(trigger,1);
@ -165,7 +165,7 @@ void Trap::Trigger(Mob* trigger)
{
if ((tmp = database.GetNPCType(effectvalue)))
{
NPC* new_npc = new NPC(tmp, 0, x-2+MakeRandomInt(0, 5), y-2+MakeRandomInt(0, 5), z-2+MakeRandomInt(0, 5), MakeRandomInt(0, 249), FlyMode3);
NPC* new_npc = new NPC(tmp, 0, x-2+zone->random.Int(0, 5), y-2+zone->random.Int(0, 5), z-2+zone->random.Int(0, 5), zone->random.Int(0, 249), FlyMode3);
new_npc->AddLootTable();
entity_list.AddNPC(new_npc);
new_npc->AddToHateList(trigger,1);
@ -185,10 +185,10 @@ void Trap::Trigger(Mob* trigger)
{
EQApplicationPacket* outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
CombatDamage_Struct* a = (CombatDamage_Struct*)outapp->pBuffer;
int dmg = MakeRandomInt(effectvalue, effectvalue2);
int dmg = zone->random.Int(effectvalue, effectvalue2);
trigger->SetHP(trigger->GetHP() - dmg);
a->damage = dmg;
a->sequence = MakeRandomInt(0, 1234567);
a->sequence = zone->random.Int(0, 1234567);
a->source = GetHiddenTrigger()!=nullptr ? GetHiddenTrigger()->GetID() : trigger->GetID();
a->spellid = 0;
a->target = trigger->GetID();
@ -197,7 +197,7 @@ void Trap::Trigger(Mob* trigger)
safe_delete(outapp);
}
}
respawn_timer.Start((respawn_time + MakeRandomInt(0, respawn_var)) * 1000);
respawn_timer.Start((respawn_time + zone->random.Int(0, respawn_var)) * 1000);
chkarea_timer.Disable();
disarmed = true;
}
@ -250,7 +250,7 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
if ((xdiff*xdiff + ydiff*ydiff) <= maxdist
&& zdiff < trap->maxzdiff)
{
if (MakeRandomInt(0,100) < trap->chance)
if (zone->random.Roll(trap->chance))
return(cur);
else
savemob = cur;

View File

@ -270,7 +270,7 @@ void NPC::CalculateNewWaypoint()
if(closest.size() != 0)
{
iter = closest.begin();
std::advance(iter, MakeRandomInt(0, closest.size() - 1));
std::advance(iter, zone->random.Int(0, closest.size() - 1));
cur_wp = (*iter).index;
}
@ -278,7 +278,7 @@ void NPC::CalculateNewWaypoint()
}
case 2: //random
{
cur_wp = MakeRandomInt(0, Waypoints.size() - 1);
cur_wp = zone->random.Int(0, Waypoints.size() - 1);
if(cur_wp == old_wp)
{
if(cur_wp == (Waypoints.size() - 1))
@ -339,7 +339,7 @@ void NPC::CalculateNewWaypoint()
if(closest.size() != 0)
{
iter = closest.begin();
std::advance(iter, MakeRandomInt(0, closest.size() - 1));
std::advance(iter, zone->random.Int(0, closest.size() - 1));
cur_wp = (*iter).index;
}
break;
@ -412,13 +412,13 @@ void NPC::SetWaypointPause()
switch (pausetype)
{
case 0: //Random Half
AIwalking_timer->Start((cur_wp_pause - MakeRandomInt(0, cur_wp_pause-1)/2)*1000);
AIwalking_timer->Start((cur_wp_pause - zone->random.Int(0, cur_wp_pause-1)/2)*1000);
break;
case 1: //Full
AIwalking_timer->Start(cur_wp_pause*1000);
break;
case 2: //Random Full
AIwalking_timer->Start(MakeRandomInt(0, cur_wp_pause-1)*1000);
AIwalking_timer->Start(zone->random.Int(0, cur_wp_pause-1)*1000);
break;
}
}

View File

@ -1300,13 +1300,13 @@ void Zone::ChangeWeather()
return;
}
int chance = MakeRandomInt(0, 3);
int chance = zone->random.Int(0, 3);
uint8 rainchance = zone->newzone_data.rain_chance[chance];
uint8 rainduration = zone->newzone_data.rain_duration[chance];
uint8 snowchance = zone->newzone_data.snow_chance[chance];
uint8 snowduration = zone->newzone_data.snow_duration[chance];
uint32 weathertimer = 0;
uint16 tmpweather = MakeRandomInt(0, 100);
uint16 tmpweather = zone->random.Int(0, 100);
uint8 duration = 0;
uint8 tmpOldWeather = zone->zone_weather;
bool changed = false;
@ -1315,7 +1315,7 @@ void Zone::ChangeWeather()
{
if(rainchance > 0 || snowchance > 0)
{
uint8 intensity = MakeRandomInt(1, 10);
uint8 intensity = zone->random.Int(1, 10);
if((rainchance > snowchance) || (rainchance == snowchance))
{
//It's gunna rain!

View File

@ -22,6 +22,7 @@
#include "../common/linked_list.h"
#include "../common/rulesys.h"
#include "../common/types.h"
#include "../common/random.h"
#include "qglobals.h"
#include "spawn2.h"
#include "spawngroup.h"
@ -253,6 +254,9 @@ public:
void UpdateHotzone();
std::unordered_map<int, item_tick_struct> tick_items;
// random object that provides random values for the zone
EQEmu::Random random;
//MODDING HOOKS
void mod_init();
void mod_repop();