clear all close all clc %% Formulas base (weight calculus) OA = -500:10:700'; % Offensive ability DA = zeros(1,length(OA)); % Deffensive ability PTH = ((((OA*5)+7500)-(DA*5))/75)-15 ; % probability to hit % PTH = 3.15 * (OA / (3.5*OA + DA)) + 0.0002275 * (OA - DA) + 0.2 CC = (1-(90)./max(100,PTH))*100 ; % chance to crit for i = 1:length(OA) if(OA(i)<90) CC(i)= 0; end end THR0= min(PTH/75*100,100); THR1= min(max(PTH-90,0),20); %x1.1 90 THR THR2= min(max(PTH-105,0),20); %x1.2 105 THR3= min(max(PTH-120,0),20); %x1.3 120 THR4= min(max(PTH-130,0),20); %x1.4 120 THRtot = THR1+THR2+THR3+THR4; % sin contar THR0 Miss = max(100-PTH,0); %% Graphs formulas base figure() hold on plot(OA,PTH) plot(OA,CC,'r') plot(OA,THR0,'y') plot(OA,THR1,'g') plot(OA,THR2,'m') plot(OA,THR3,'k') plot(OA,THR4,'c') legend('PTH','CC','THR0','THR1','THR2','THR3','THR4') title('Weight of PTH, THR') grid on xlabel('OA-DA') %% Weighted chances Hit = (PTH-THRtot)./PTH*100; % for i = 1:length(OA) % if(PTH(i)<=90) % Hit(i) = PTH(i); % end % end Hit = Hit - Miss; Crit1 = THR1./PTH*100; Crit2 = THR2./PTH*100; Crit3 = THR3./PTH*100; Crit4 = THR4./PTH*100; Crittot = Crit1+Crit2+Crit3+Crit4; revisionCC = Hit+CC; revisionCrit = Hit+Crittot; %% Weighted chance plots figure() hold on plot(OA,Hit) plot(OA,CC,'r') plot(OA,Crittot,'g') plot(OA,revisionCrit,'o') legend('Hit%','CC% (formula)','Crittot% (from thresholds)') title('Chance to hit and crit') xlabel('OA-DA') grid on figure() hold on plot(OA,Crit1,'g') plot(OA,Crit2,'m') plot(OA,Crit3,'k') plot(OA,Crit4,'c') legend('Crit1','Crit2','Crit3','Crit4') title('Chances of each crit') xlabel('OA-DA') grid on