My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
function [statblock]=pally_mc(config,statSetup)
dhit=0;dexp=0;dhaste=0;dmastery=0;ddodge=0;dparry=0;

%% Input handling - config - stat,val,simMins,plotFlag,tocFlag
if ~exist('config','var')
config=[];
end
if ~isfield(config,'tocFlag')
config.tocFlag='toc';
end
tocFlag=config.tocFlag;

if ~isfield(config,'plotFlag')
config.plotFlag='plot';
end
plotFlag=config.plotFlag;

if ~isfield(config,'simMins')
config.simMins=500;
warning('simMins defaulting to %d', config.simMins) %#ok<*WNTAG>
end
simMins=config.simMins;

if ~isfield(config,'val')
config.val=600;
warning('stat value defaulting to %d',config.val)
end
val=config.val;

if ~isfield(config,'sF')
config.sF=5;
warning(['smoothing factor defaulting to ' int2str(config.sF)])
end
sF=config.sF;

if ~isfield(config,'finisher')
config.finisher='S';
end

if ~isfield(config,'bossSwingTimer')
config.bossSwingTimer=1.5;
warning(['boss swing timer factor defaulting to ' num2str(config.bossSwingTimer,'%2.2f')])
end
bossSwingTimer=config.bossSwingTimer;

if ~isfield(config,'WoGoverheal')
config.WoGoverheal=0.5;
warning(['WoG overheal defaulting to ' int2str(config.WoGoverheal.*100) '%'])
end
WoGoverheal=config.WoGoverheal;

if ~isfield(config,'WoGfakeBubbleDuration')
config.WoGfakeBubbleDuration=3;
warning(['WoG fake bubble duration defaulting to ' num2str(config.WoGfakeBubbleDuration,'%2.2f') 's'])
end
WoGfakeBubbleDuration=config.WoGfakeBubbleDuration;

if ~isfield(config,'t152pcEquipped')
config.t152pcEquipped=0;
warning('T15 2-piece bonus defaulting to off')
end
t152pcEquipped=config.t152pcEquipped;

%% Finisher priority Queue handling
finisher=config.finisher;
n=regexp(finisher,'(?<ftype>[a-zA-Z]+)(?<lockstr>\d*\.?\d*)-?(?<bleedstr>\d*)(?<ovrw>\**)','names');
ftype=n.ftype;
bleed=str2double(n.bleedstr);
lock=str2double(n.lockstr);
ovrw=~strcmpi(n.ovrw,'*');
%%
if nargin>=1
switch config.stat
case 'hit'
dhit=val;
case 'exp'
dexp=val;
case 'haste'
dhaste=val;
case 'mastery'
dmastery=val;
case 'dodge'
ddodge=val;
case 'parry'
dparry=val;
end
end

%% Initialize different random streams
RandStream.setDefaultStream ...
(RandStream('mt19937ar','seed',sum(100*clock)));

%% Player stats
if nargin<2
buffedStr=9208;
parryRating=4834;
dodgeRating=4892;
masteryRating=6758;
hitRating=900;
expRating=1777;
hasteRating=0;
armor=60000;
else
buffedStr=statSetup.buffedStr;
parryRating=statSetup.parryRating;
dodgeRating=statSetup.dodgeRating;
masteryRating=statSetup.masteryRating;
hitRating=statSetup.hitRating;
expRating=statSetup.expRating;
hasteRating=statSetup.hasteRating;
armor=statSetup.armor;
end

%artificially set hit/exp to zero
% hitRating=0;
% expRating=0;
armorMit=1-armor./(armor+58370);
specMit=1-0.15;
wbMit=0.9;


%% Define constants/variables
Cd=66.56745;
Cp=237.186;
Cb=150.3759;
k=0.886;
gcAvoidProcRate=0.12;
gcCSProcRate=0.12;
gcBuffDuration=6.3;
% dpProcRate=0.25;
dpProcRate=0;
dpBuffDuration=8;

%Vengeance info
bossRawDPS=310000;
bossRawSwingDamage=bossRawDPS.*bossSwingTimer;
bossSwingDamage=bossRawSwingDamage.*armorMit.*specMit.*wbMit;
avgVengAP=0.36*bossRawDPS;
AP=floor(1.1.*(avgVengAP+270+2.*(buffedStr-10)));
WoGHealBase=(5538+0.49.*AP./2).*1.05./bossSwingDamage.*(1-WoGoverheal);


%% calculate stats
%defensive stats
mastery=8+(masteryRating+dmastery)./600;
blockCS=3+10+1./(1./Cb+k./mastery);
% miss=0;
dodgeCS=5.01+1./(1./Cd+k./((dodgeRating+ddodge)./885));
parryCS=3.19+1./(1./Cp+k./((buffedStr-178)./951.158596+(parryRating+dparry)./885));

avoidance=(dodgeCS+parryCS-9)./100;
block=(blockCS-4.5)./100;

DRmod=max([1-0.3-mastery./100 0.2]);

%offensive stats
haste=(hasteRating+dhaste)./425./100;

hit=(hitRating+dhit)./340./100;
exp=(expRating+dexp)./340./100;

miss=max(0,0.075-hit);
dodge=max(0,(0.075-exp));
parry=max(0,(0.075-max((exp-0.075),0)));


%initialize Holy Power
hp=int8(0);

%% Define events, cooldowns and buffs to track
events={'Boss Swing Timer','GCD'};
tbe = zeros(size(events));
idBossSwing=1;
idGCD=2;
%start boss swing timer at 0.5 seconds, just to de-synch from GCD
%not strictly necessary, I think, as HP generation should shuffle SotR
%around significantly, but just to be safe...
tbe(1)=0.5;

buffs={'SotR duration','BoG Duration','CS cooldown','J cooldown','AS cooldown','SotR cooldown','Grand Crusader duration','Div Pupr duration','T152pc','WoG cd','WoG absorb'};
tob = zeros(size(buffs));
idSotR=1;
idBoG=2;
idCScd=3;
idJcd=4;
idAScd=5;
idSotRcd=6;
idGCbuff=7;
idDPBuff=8;
idT152pc=9;
idWoGcd=10;
idWoGfakebubble=11;

BoGstacks=0;

simTime=simMins*60;
steps_per_sec=100;

%preallocate arrays
N=floor(simTime.*steps_per_sec);
dt=1./steps_per_sec;
t=zeros(N,1);
damage=-1.*ones(N,1);
SotRUptime=t;
debugHP=t;
debugHPG=t;
debugBoG=t;

%tracking
avoids=0;
blocks=0;
hits=0;
mits=0;
bMits=0;
hMits=0;
partialAbsorbs=0;
fullAbsorbs=0;
gcCSProcs=0;
gcAProcs=0;

% %make t array
% t=((1:N)-1).*dt;

%%for loop to do event handling
tic
for k=1:N

%record time
t(k)=(k-1).*dt;

%figure out if any of the event timers is 0 or less
ids=find(tbe<=0);

%event handling
for j=1:length(ids)

%% upkeep stuff we'll want to do before every event

%clear BoG stacks if the buff has expired
if tob(idBoG)<=0
BoGstacks=0;
end

%fix SotR at 0
tob(idSotR)=max(tob(idSotR),0);

%% now see which ID we have and handle the event
switch ids(j)

%if the GCD timer is up, see if there's something to cast
case idGCD

%check for finisher cast
finisherCast(ftype,lock,bleed,ovrw);

%CS is first priority
if tob(idCScd)<=0
%put CS on cooldown, start GCD
tob(idCScd)=4.5./(1+haste);
tbe(idGCD)=1.5./(1+haste);
%Check for hit
if rand<(1-miss-dodge-parry)
%success! grant HP, enforce bounds
grantHP;
debugHPG(k)=1; %debug flag

%Check for Grand Crusader proc
if rand<gcCSProcRate
%set GC buff duration
tob(idGCbuff)=gcBuffDuration;
%reset AS cooldown
tob(idAScd)=0;
gcCSProcs=gcCSProcs+1;
end
end
%J is second priority, check for cooldown and don't use
%if CS cd is almost up
elseif tob(idJcd)<=0 && tob(idCScd)>=0.2
%set J cooldown, start GCD
tob(idJcd)=6./(1+haste);
tbe(idGCD)=1.5./(1+haste);
%check for hit
if rand<(1-miss)
%success! grant HP, enforce bounds
grantHP;
debugHPG(k)=2; %debug flag
end
%Avenger's Shield
elseif tob(idAScd)<=0 && tob(idCScd)>=0.2
%set AS cooldown, Start GCD
tob(idAScd)=15./(1+haste);
tbe(idGCD)=1.5./(1+haste);
%if Grand Crusader was active,
if tob(idGCbuff)>0
%Consume GC buff, set GCD
tob(idGCbuff)=0;
%grant HP, enforce bounds
grantHP;
debugHPG(k)=3; %debug flag
end
%for completeness, fill the GCD with a blank filler
else
tbe(idGCD)=1.5./(1+haste);
end

%boss swing
case idBossSwing

%update WoG fake absorb
if tob(idWoGfakebubble)<=0
WoGAmount=0;
end
if WoGAmount<=0
tob(idWoGfakebubble)=0;
end


%check for finisher cast
finisherCast(ftype,lock,bleed,ovrw);

%reset boss swing timer
tbe(idBossSwing)=bossSwingTimer;

%check for avoid
if rand < avoidance %#ok<*BDSCI>
damage(k)=0;
avoids=avoids+1;

%Check for Grand Crusader proc
if rand<gcAvoidProcRate
%set GC buff duration
tob(idGCbuff)=gcBuffDuration;
%reset AS cooldown
tob(idAScd)=0;
gcAProcs=gcAProcs+1;
end

%now check for block
elseif rand < block+0.4*(tob(idT152pc)>0)
blocks=blocks+1;
if tob(idSotR)>0
mits=mits+1;
bMits=bMits+1;
if WoGAmount>=0.7*DRmod
damage(k)=0;
WoGAmount=WoGAmount-0.7*DRmod;
fullAbsorbs=fullAbsorbs+1;
elseif WoGAmount>0
damage(k)=0.7*DRmod-WoGAmount;
WoGAmount=0;
partialAbsorbs=partialAbsorbs+1;
else
damage(k)=0.7*DRmod;
end
else
if WoGAmount>=0.7
damage(k)=0;
WoGAmount=WoGAmount-0.7;
fullAbsorbs=fullAbsorbs+1;
elseif WoGAmount>0
damage(k)=0.7-WoGAmount;
WoGAmount=0;
partialAbsorbs=partialAbsorbs+1;
else
damage(k)=0.7;
end
end
%and finally, normal hits
else
hits=hits+1;
if tob(idSotR)>0
mits=mits+1;
hMits=hMits+1;
if WoGAmount>=DRmod
damage(k)=0;
WoGAmount=WoGAmount-DRmod;
fullAbsorbs=fullAbsorbs+1;
elseif WoGAmount>0
damage(k)=DRmod-WoGAmount;
WoGAmount=0;
partialAbsorbs=partialAbsorbs+1;
else
damage(k)=DRmod;
end
else
if WoGAmount>=1
damage(k)=0;
WoGAmount=WoGAmount-1;
fullAbsorbs=fullAbsorbs+1;
elseif WoGAmount>0
damage(k)=1-WoGAmount;
WoGAmount=0;
partialAbsorbs=partialAbsorbs+1;
else
damage(k)=1;
end
end
end

end %close switch


end %close event for


%% Debugging
SotRUptime(k)=tob(idSotR);
% SotRUptimeotR(k,1)=tob(idSotRcd);
% debugHP(k)=hp;
% debugBoG(k)=BoGstacks;


%increment time by decreasing tob and tbe
%rounding to prevent floating point inaccuracies
tbe=round((tbe-dt).*1000)./1000;
tob=round((tob-dt).*1000)./1000;

end %close timestep for loop

%flash toc for timing/debugging if desired
if ~strcmp(tocFlag,'notoc')
toc
end

%% compile for plots
dmg=damage(damage>=0);

%sanity check
if hits+blocks+avoids~=length(dmg)
error('reporting error, length(dmg) doesn''t match number of events')
else
numEvents=length(dmg);
end

statblock.S=sum(SotRUptime>0)./length(SotRUptime);
% avoids=sum(dmg==0);

statblock.avoidsPct=avoids./numEvents;
statblock.blocksPct=blocks./numEvents;
statblock.hitsPct=hits./numEvents;
statblock.mitsPct=mits./numEvents;
statblock.unmitsPct=(hits-hMits)./numEvents;
statblock.bMitsPct=bMits./numEvents;
statblock.hMitsPct=hMits./numEvents;
statblock.gcAProcs=gcAProcs;
statb.ock.gcCSProcs=gcCSProcs;

statblock.Tsotr = max(t)./sum(SotRUptime==3);
statblock.Rsotr = 1/statblock.Tsotr;
statblock.Rhpg=sum(debugHPG>0)/max(t);
statblock.DRmod=DRmod;

statblock.DTPS=sum(dmg)./max(t);
statblock.maDTPS=filter(ones(1,5)./5,1,dmg);
statblock.mean_ma=mean(statblock.maDTPS);
statblock.std_ma=std(statblock.maDTPS);

statblock.block=block;
statblock.avoidance=avoidance;
statblock.avoids=avoids;
statblock.blocks=blocks;
statblock.hits=hits;
statblock.mits=mits;
statblock.hMits=hMits;
statblock.bMits=bMits;
statblock.partialAbsorbs=partialAbsorbs;
statblock.fullAbsorbs=fullAbsorbs;

statblock.dmg=dmg;

statblock.simMins=simMins;
statblock.simTime=simTime;
statblock.stepsPerSec=steps_per_sec;


%% plot
if ~strcmp(plotFlag,'noplot')
pally_mc_plot(config,statblock,sF)
end

%% helper functions
function finisherCast(ftype,lock,bleed,~)
if strcmpi(ftype,'S') %SotR spam
castSotRIfAble()
elseif strcmpi(ftype,'T') %maintain T152pc, bleed w/WoG
if tob(idT152pc)<=0 || hp==5
castWoGT15(0);
end
elseif strcmpi(ftype,'TS') %maintain T152pc, bleed w/SotR
if tob(idT152pc)<=0 && (isnan(lock) || hp>=lock)
castWoGT15(0);
elseif hp==5
castSotRIfAble()
end
elseif strcmpi(ftype,'ST') %SotR with T15 to bridge gaps
if isnan(bleed) %no bleeding
castSotRIfAble()
if tob(idSotR)<=0 && tob(idT152pc)<=0 && (isnan(lock) || hp>=lock)
castWoGT15(0)
end
else %add a bleeding condition on BoG
castSotRIfAble()
if tob(idSotR)<=0 && tob(idT152pc)<=0 && (isnan(lock) || hp>=lock) && BoGstacks>=bleed;
castWoGT15(0)
end
end

else
error('invalid finisher specification')
end

end
function castSotRIfAble()

%check for 3+ HP, if so cast SotR
if ( hp>=3 || tob(idDPBuff)>0 ) && tob(idSotRcd)<=0
%set SotR CD, give 3 seconds of DR, 20s of BoG
tob(idSotRcd)=1.5./(1+haste); %5.2
tob(idSotR)=tob(idSotR)+3;
tob(idBoG)=20;
BoGstacks=min(BoGstacks+1,5);
%Consume Divine Purpose proc if it exists
if tob(idDPBuff)>0
tob(idDPBuff)=0;
%otherwise, consume 3 HP
elseif hp>=3
hp=hp-3;
%Just in case - debugging
else
error('WTF')
end
%Divine Purpose procs
if rand<dpProcRate
tob(idDPBuff)=dpBuffDuration;
end
end
end

function castWoGT15(hpmin,strict)
%input handling
if nargin<1
hpmin=0;
end
if nargin<2
strict=0;
end
%first, try and cast WoG
hpused=castWoG(hpmin,strict);
%if we successfully cast, then hpused>0
if hpused>0
tob(idT152pc)=hpused.*5.*t152pcEquipped;
end
end

function hpused=castWoG(hpmin,strict)
%input handling
if nargin<1
hpmin=0;
end
if nargin<2
strict=0;
end
%if WoG off cooldown
if tob(idWoGcd)<=0
%first, check for strict casts
if nargin>1 && strict
%if we've asked for strict and HP matches the target value
if hp==hpmin
%set hp used to the target value
hpused=hpmin;
end
%else, we've not asked for strict casts
elseif hp>=max(hpmin,1)
%if we have hp>1 or hp>hpmin
hpused=min(hp,3);
elseif hp==0
hpused=0;
%oops, no holy power
else
%just in case, debugging
error('WTF')
end

%if hpused is nonzero, cast WoG
if hpused>0
%subtrat HP
hp=hp-hpused;
%set cooldown of WoG
tob(idWoGcd)=1.5;
%add a 3-second absorb shield
tob(idWoGfakebubble)=WoGfakeBubbleDuration;
%set the amount of the absorb shield based on HP spent, BoG
WoGAmount=WoGHealBase.*hpused.*(1+BoGstacks.*(0.1+mastery/100));
%consume BoG buff
BoGstacks=0;
tob(idBoG)=0;
end


end
end

function grantHP(amt)
if nargin<1
amt=1;
end
hp=hp+amt;
hp=min([hp 5]);
hp=max([hp 0]);
end


end

Change log

r557 by theckhd on Feb 19, 2013   Diff
[AM][CRS][CS][CSS][QM][SM] updates for
5.2; [FSMG][FSMK][MFSM][RM] modified to
handle new FSM parameters; [RC*] modified
Usage() and defined GC ability proc rate
variable
Go to: 
Project members, sign in to write a code review

Older revisions

r552 by theckhd on Jan 26, 2013   Diff
[AM] HPr corrections & selfcast; [BC]
updated default gear set to T14H; [C*]
updated configurations and comments;
[CW] added prismatic socket versions
of Kilrak; [DDB] new gem template for
...
r545 by theckhd on Dec 16, 2012   Diff
DR coefficient corrections
r544 by theckhd on Dec 14, 2012   Diff
blog updates
All revisions of this file

File info

Size: 18346 bytes, 613 lines
Powered by Google Project Hosting