User:Illviljan: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
>Illviljan
No edit summary
>Illviljan
mNo edit summary
Line 214: Line 214:


{| class="wikitable mw-collapsible mw-collapsed"
{| class="wikitable mw-collapsible mw-collapsed"
! Leech Mechanics. Last updated: 2015-12-10
! Leech Mechanics. Last updated: 2016-02-03
|-
|-
|  
|  
Line 227: Line 227:
%% Input
%% Input
p              = 5000;                % Maximum Life.
p              = 5000;                % Maximum Life.
l              = 0.02;                % Increased Leech.
l              = 0.01;                % Increased Leech.
m              = 0;                   % Increased Base Leeech Rate.
m              = 0.00;                 % Increased Base Leeech Rate.
m_max          = 0;                   % Increased Maximum Leech Rate.
m_max          = 0.00;                 % Increased Maximum Leech Rate.
 
% Damage values from the hit:
d              = 1000;
attacksPerSec  = 4;                    % Attacks per Second.
mobsPerAttack  = 5;                    % Enemies hit by one attack.
numberOfAttacks = 5;                    % Number of attacks done to enemies.
% The time when the attack started:
attackTime      = 0:1/attacksPerSec:(numberOfAttacks - 1)/attacksPerSec; 
% The time when the attack hit the target(s):
hitTime        = kron(attackTime, ones(1,mobsPerAttack));
 
q              = 0.02;                % Base Leech Rate.           
q              = 0.02;                % Base Leech Rate.           
q_max          = 0.2;                  % Base Maximum Leech Rate.
q_max          = 0.2;                  % Base Maximum Leech Rate.
steps          = 1000;                % Number of steps.
steps          = 1000;                % Number of steps.
% Damage values from the hit:
d              = 4000; %[1000 1000 1000 1000 1000];
attacksPerSec  = 5;                    % Attacks per Second:
mobsPerAttack  = 3;                    % Enemies hit by one attack:
attackTime      = 0:1/attacksPerSec:1;  % The time when the attack started.
% The time when the attack hit the target(s):
hitTime        = kron(attackTime, ones(1,mobsPerAttack)); % [0 0.01 0.02 0.03 0.04];


%% Calculations
%% Calculations
% Maximum recovery rate:
% Maximum recovery rate:
r_max = (q_max  + m_max ) * p;
r_max = (q_max  + m_max) * p;


% Leech duration
% Leech duration
t_dur = d * l / (p *q)  .* ones(1, length(hitTime));
t_dur = floor(d * l) / (p *q)  .* ones(1, length(hitTime));


% Total allowed leech instance to not exceed the maximum recovery rate
% Total allowed leech instance to not exceed the maximum recovery rate
n_tot = (q_max + m_max) / (q * (1 + m));
n_tot = (q_max + m_max) / (q * (1 + m));
% Amount of HP leeched:
LeechAmount = l .* d;


% Maximum analysis time:
% Maximum analysis time:
Line 267: Line 267:
% Boolean conditions to check if there have been an enemy hit and if
% Boolean conditions to check if there have been an enemy hit and if
% the leeched ife is lower than the total amount of life leeched.
% the leeched ife is lower than the total amount of life leeched.
boolHitStart = tRep >= AttackTimeRep;
boolHitStart   = tRep >= AttackTimeRep;
boolLeechEnd = tRep < AttackTimeRep + t_durRep;
boolLeechEnd   = tRep < AttackTimeRep + t_durRep;
BoolLeechEndVP = tRep <= AttackTimeRep + (maxTime-0)/steps;  


% Both of the above conditions must be true for leech to occur:
% Both of the above conditions must be true for leech to occur:
boolLeech = (boolHitStart .* boolLeechEnd);
boolLeech   = (boolHitStart .* boolLeechEnd);
boolLeechVP = (boolHitStart .* BoolLeechEndVP);


% Base Recovery Rate for each leech instance:
% Base Recovery Rate for each leech instance:
r = (q + m) * p .* boolLeech;
r = p * q * (1 + m) .* boolLeech;


% Each active leech instance:
% Each active leech instance:
Line 280: Line 282:


% Base Recovery Rate summarized for all the leech instances:
% Base Recovery Rate summarized for all the leech instances:
r_sum = sum(r);
r_sum = sum(r,1);


% Check that r_sum is not greater than r_max:
% Check that r_sum is not greater than r_max:
Line 290: Line 292:
HP_i = zeros(length(hitTime),length(t));
HP_i = zeros(length(hitTime),length(t));
HP_tot = zeros(1,length(t));
HP_tot = zeros(1,length(t));
HP_totVP = zeros(1,length(t));


for i = 1:length(t)-1;
for i = 1:length(t)-1;
Line 298: Line 301:
     % Total HP restored from all the leech instances:
     % Total HP restored from all the leech instances:
     HP_tot(:,i+1) =  r_sum(:,i) * dt + HP_tot(:,i);
     HP_tot(:,i+1) =  r_sum(:,i) * dt + HP_tot(:,i);
   
    % Vaal Pact restores life instanteously:
    HP_totVP(:,i+1) =  d * l .* sum(boolLeechVP(:,i),1) + HP_totVP(:,i);
end
end


Line 304: Line 310:
leechInstance(leechInstance == 0) = NaN; % Remove zeros from plot.
leechInstance(leechInstance == 0) = NaN; % Remove zeros from plot.
fig(1) = subplot(3,1,1);
fig(1) = subplot(3,1,1);
plot(t, leechInstance(:,:));
colororder = get(gca,'colororder');
plot(t, leechInstance, 'Color', colororder(1,:));
% set(gca, 'YTick', 0:length(hitTime)); % Show integers only.
ylim([0 length(hitTime)+0.5]);
ylim([0 length(hitTime)+0.5]);
xlim([0 maxTime]);
xlim([0 maxTime]);
Line 315: Line 323:
     [rowStart, colStart]  = find(~isnan(leechInstance(i,:)), 1, 'first');
     [rowStart, colStart]  = find(~isnan(leechInstance(i,:)), 1, 'first');
     [rowEnd,  colEnd]    = find(~isnan(leechInstance(i,:)), 1, 'last');
     [rowEnd,  colEnd]    = find(~isnan(leechInstance(i,:)), 1, 'last');
     plot(t(colStart), leechInstance(i, colStart), '.', ...
     plot(t(colStart), leechInstance(i, colStart), 'b.', ...
         t(colEnd),  leechInstance(i, colEnd), 'x');
         t(colEnd),  leechInstance(i, colEnd),'bx', ...
        t(colStart),  leechInstance(i, colStart),'ro');
    % Vaal Pact Start and End:
    plot(t(colStart),  leechInstance(i, colStart),'ro');    
end
end


fig(2) = subplot(3,1,2);
fig(2) = subplot(3,1,2);
[a, h1, h2] = plotyy(t, r_sum, t, r_sum/p);
[ax, h1, h2] = plotyy(t, r_sum, t, r_sum/p);
delete(h2);
delete(h2);
NumberOfTicks = 4;
NumberOfTicks = 4;
set(a(1),  'ycolor', 'black', ...          % Change right axis color to black
set(ax(1),  'ycolor', 'black', ...          % Change right axis color to black
             'YTick', 0:r_max/NumberOfTicks:r_max);
             'YTick', 0:r_max/NumberOfTicks:r_max);
set(a(2),  'ycolor', 'black', ...          % Change left axis color to black
set(ax(2),  'ycolor', 'black', ...          % Change left axis color to black
             'YTick', 0:q_max/NumberOfTicks:q_max);  %
             'YTick', 0:(q_max+m_max)/NumberOfTicks:(q_max+m_max));  %
ylim(a(1), [0 r_max]);
ylim(ax(1), [0 r_max]);
ylim(a(2), [0 q_max]);
ylim(ax(2), [0 q_max+m_max]);
xlim([0 maxTime]);
xlim([0 maxTime]);
xlabel('Time, t, [s]');
xlabel('Time, t, [s]');
ylabel(a(1), 'Recovery Rate [HP/s]');  
ylabel(ax(1), 'Recovery rate [HP/s]');  
ylabel(a(2), 'Base Rate [HP/(max hp * s)]');  
ylabel(ax(2), 'Base Rate [HP/(max hp * s)]');  
title('Recovery Rate');
title('Leech Rate');


fig(3) = subplot(3,1,3);
fig(3) = subplot(3,1,3);
plot(t, HP_tot);
plot(t, HP_tot, 'b', t, HP_totVP, 'r-.');
ylim([0 inf]);
ylim([0 inf]);
xlim([0 maxTime]);
xlim([0 maxTime]);
Line 342: Line 353:
ylabel('HP restored, [HP]');
ylabel('HP restored, [HP]');
title('HP restored from leech');
title('HP restored from leech');
legend('Recovery rate','Instantenous leech', 'Location','SouthEast')
linkaxes(fig,'x')
linkaxes(fig,'x')



Revision as of 12:59, 3 February 2016

Collapsible Template

Text here


Matlab scripts
Experience Penalty. Last updated: 2015-12-10

%% Experience Penalty
% The player also suffers a penalty to XP if the player is too far above 
% or below the monster's level. 
home, clear all, close all
%% Input
PlayerLevel     = 1:100;
MonsterLevel    = 1:85;

%% Calculations
% Create a repeated matrix:
mPlayerLevel = repmat(PlayerLevel, length(MonsterLevel), 1);
mMonsterLevel = repmat(MonsterLevel, length(PlayerLevel), 1)';

% Minimum amount of experience penalty:
minEXPMulti = 0.01;

% There's a safe zone between player level and monster level where no 
% experience penalty is applied:
SafeZone = floor(3 + mPlayerLevel/16);

% Any additional level difference in excess of this safe range is the
% effective level difference:
EffectiveDifference = max(abs(mPlayerLevel - mMonsterLevel) - SafeZone, 0);
% If the effective difference is negative that implies the player is inside
% the safe zone. Therefore only values =>0 are relevant. 

% If the player level is outside the safe zone a multiplier on monsters 
% experience takes effect, reducing the amount by: 
XPMultiplier = max(((mPlayerLevel + 5) ./ ...
    (mPlayerLevel + 5 + EffectiveDifference.^2.5)).^1.5, minEXPMulti);

%% Contour plot
figure
[C,h] = contourf(mPlayerLevel,mMonsterLevel,XPMultiplier);
ticks = 5;
set(gca,'XTick',0:ticks:PlayerLevel(end));
set(gca,'YTick',0:ticks:MonsterLevel(end));
h = colorbar;
h.Limits = [0.01 1];
grid minor
shading interp
title('Experience Penalty')
xlabel('Player Level')
ylabel('Monster Level')
% zlabel('Experience efficiency')
ylabel(h,'Experience Efficiency');
%% Party play
% Parties with different character levels will gain different amount of
% experience according to:
PercentualShare = (PlayerLevel + 10).^2.71 ./ sum((PlayerLevel + 10).^2.71,2);

Chance to hit and avoid attacks. Last updated: 2015-12-10

%% Chance to hit and avoid attacks.
close all, clear all, home 
set(0,'DefaultFigureWindowStyle', 'docked');

% Sources:
% http://pathofexile.gamepedia.com/Evasion
% http://pathofexile.gamepedia.com/Accuracy

%% Input
step = 100;
evasionRating = linspace(0, 50000, step);
attackerAccuracy = linspace(0, 4000, step);
chanceToDodge = 0;

%% Calculations
% Create a Mesh grid to be able to do contour plots:
[evasionRatingMesh, attackerAccuracyMesh] = meshgrid(evasionRating, attackerAccuracy);

% Chance to hit is a function if accuracy and evasion rating:
chanceToHit = min(max( attackerAccuracyMesh ./ (attackerAccuracyMesh + (evasionRatingMesh/4).^0.8), 0.05) , 0.95);

% Chance to avoid hits
chanceToAvoidHit = 1 - chanceToHit*(1-chanceToDodge);

%% Contour plot
% Chance to avoid hit contour plot
figure
[C,h] = contourf(evasionRatingMesh,attackerAccuracyMesh,chanceToAvoidHit*100);
clabel(C,h,'labelspacing',200)
% clabel(C,h,'manual')
colormap(cool)
h = colorbar;
h.Limits = [5 95];
grid minor
shading interp
title('Chance to avoid enemy attacks')
xlabel('Defender''s Evasion Rating')
ylabel('Attacker''s Accuracy Rating')
ylabel(h,'Chance to avoid hit [%]');

% Chance to hit contour plot
figure
[C,h] = contourf(attackerAccuracyMesh,evasionRatingMesh, chanceToHit*100);
clabel(C,h,'labelspacing',700)
colormap(cool)
h = colorbar;
h.Limits = [5 95];
grid minor
shading interp
title('Chance to hit enemy')
xlabel('Attacker''s Accuracy Rating')
ylabel('Defender''s Evasion Rating')
% zlabel('Experience efficiency')
ylabel(h,'Chance to hit [%]');

Armour Reduction. Last updated: 2015-12-10

%% Armour Reduction 
close all, clear all, home

% Sources:
% http://pathofexile.gamepedia.com/Armour

%% Input
step = 100;
Armour = linspace(0, 50000, step);
Damage = linspace(0, 10000, step);
%% Calculations
% Create a Mesh grid to be able to do contour plots:
[ArmourMesh, DamageMesh] = meshgrid(Armour, Damage);

Damage_Reduction_FactorMesh = ArmourMesh ./ (ArmourMesh + 10 * DamageMesh);

%% Contour plot
figure
% [C,h] = contourf(ArmourMesh,DamageMesh,Damage_Reduction_FactorMesh*100);
[C,h] = contour(ArmourMesh,Damage_Reduction_FactorMesh*100,DamageMesh, ...
    [100:200:600, 1000:500:2000, 3000:1000:6000, 8000:2000:10000]);
clabel(C,h, 'labelspacing',700);
clabel(C,h,'manual')
colormap(copper)
h = colorbar;
% h.Limits = [0.01 1];
grid minor
shading interp
ylim([0 90])
title('Physical Damage Reduction when Hit')
xlabel('Armour Rating')
ylabel('#% additional Physical Damage Reduction when Hit')
ylabel(h,'Raw Physical Damage');

Plot Energy shield recharge. Last updated: 2015-12-10

%% Plot Energy shield recharge
close all, clear all, home

% Sources:
% http://pathofexile.gamepedia.com/Energy_shield

%% Inputs
r = 0:300;
BaseStart = 2;

%% Calculations
ESStartTime = BaseStart * 100./(100 + r);

%% Plot 
figure
plot(r, ESStartTime)
title('Start of Energy Shield Recharge')
xlabel('#% faster start of Energy Shield Recharge')
ylabel('Start time of Energy Shield Recharge [s]')
grid on

Leech Mechanics. Last updated: 2016-02-03

%% Leech mechanics for Path of Exile
% This script analyses how the leech rate changes with increasing number of
% enemies and number of hits on the enemy. 
close all, clear all, home
set(0,'DefaultFigureWindowStyle', 'docked');

%% Input
p               = 5000;                 % Maximum Life.
l               = 0.01;                 % Increased Leech.
m               = 0.00;                 % Increased Base Leeech Rate.
m_max           = 0.00;                 % Increased Maximum Leech Rate.

% Damage values from the hit:
d               = 1000;
attacksPerSec   = 4;                    % Attacks per Second.
mobsPerAttack   = 5;                    % Enemies hit by one attack.
numberOfAttacks = 5;                    % Number of attacks done to enemies.
% The time when the attack started:
attackTime      = 0:1/attacksPerSec:(numberOfAttacks - 1)/attacksPerSec;  
% The time when the attack hit the target(s):
hitTime         = kron(attackTime, ones(1,mobsPerAttack));

q               = 0.02;                 % Base Leech Rate.          
q_max           = 0.2;                  % Base Maximum Leech Rate.
steps           = 1000;                 % Number of steps.

%% Calculations
% Maximum recovery rate:
r_max = (q_max  + m_max) * p;

% Leech duration
t_dur = floor(d * l) / (p *q)   .* ones(1, length(hitTime));

% Total allowed leech instance to not exceed the maximum recovery rate
n_tot = (q_max + m_max) / (q * (1 + m));

% Maximum analysis time:
maxTime = hitTime(end) + t_dur(end);       

% Repeat vectors:
t = linspace(0, maxTime, steps);
instanceRep = repmat((1:length(hitTime))',1,length(t));
tRep = repmat(t,length(hitTime),1);
AttackTimeRep = repmat(hitTime',1,length(t));
t_durRep = repmat(t_dur',1,length(t));

% Boolean conditions to check if there have been an enemy hit and if
% the leeched ife is lower than the total amount of life leeched.
boolHitStart   = tRep >= AttackTimeRep;
boolLeechEnd   = tRep < AttackTimeRep + t_durRep;
BoolLeechEndVP = tRep <= AttackTimeRep + (maxTime-0)/steps; 

% Both of the above conditions must be true for leech to occur:
boolLeech   = (boolHitStart .* boolLeechEnd);
boolLeechVP = (boolHitStart .* BoolLeechEndVP);

% Base Recovery Rate for each leech instance:
r = p * q * (1 + m)  .* boolLeech;

% Each active leech instance:
leechInstance =  instanceRep .* boolLeech;

% Base Recovery Rate summarized for all the leech instances:
r_sum = sum(r,1);

% Check that r_sum is not greater than r_max:
boolLimit = r_sum >= r_max;
r_sum = r_max .* boolLimit + r_sum .*(~boolLimit);

% Pre-load for for-loop:
dt = (maxTime-0)/steps;
HP_i = zeros(length(hitTime),length(t));
HP_tot = zeros(1,length(t));
HP_totVP = zeros(1,length(t));

for i = 1:length(t)-1;
    % HP restored from each leech instance, this is used to check
    % when each leech instance is finished:
    HP_i(:,i+1) =  q * p .* boolLeech(:,i) * dt + HP_i(:,i);
    
    % Total HP restored from all the leech instances:
    HP_tot(:,i+1) =  r_sum(:,i) * dt + HP_tot(:,i);
    
    % Vaal Pact restores life instanteously:
    HP_totVP(:,i+1) =  d * l .* sum(boolLeechVP(:,i),1) + HP_totVP(:,i);
end

%% Plot 
figure
leechInstance(leechInstance == 0) = NaN; % Remove zeros from plot.
fig(1) = subplot(3,1,1);
colororder = get(gca,'colororder');
plot(t, leechInstance, 'Color', colororder(1,:));
% set(gca, 'YTick', 0:length(hitTime)); % Show integers only.
ylim([0 length(hitTime)+0.5]);
xlim([0 maxTime]);
xlabel('Time, t, [s]');
ylabel('Leech instance');
title('Leech instance');
for i = 1:length(hitTime);
    hold on
    % Find the start and end point of each instance and mark it:
    [rowStart, colStart]   = find(~isnan(leechInstance(i,:)), 1, 'first');
    [rowEnd,   colEnd]     = find(~isnan(leechInstance(i,:)), 1, 'last');
    plot(t(colStart), leechInstance(i, colStart), 'b.', ...
         t(colEnd),   leechInstance(i, colEnd),'bx', ...
         t(colStart),   leechInstance(i, colStart),'ro');
     % Vaal Pact Start and End:
    plot(t(colStart),   leechInstance(i, colStart),'ro');     
end

fig(2) = subplot(3,1,2);
[ax, h1, h2] = plotyy(t, r_sum, t, r_sum/p);
delete(h2);
NumberOfTicks = 4;
set(ax(1),   'ycolor', 'black', ...          % Change right axis color to black
            'YTick', 0:r_max/NumberOfTicks:r_max);
set(ax(2),   'ycolor', 'black', ...          % Change left axis color to black
            'YTick', 0:(q_max+m_max)/NumberOfTicks:(q_max+m_max));  %
ylim(ax(1), [0 r_max]);
ylim(ax(2), [0 q_max+m_max]);
xlim([0 maxTime]);
xlabel('Time, t, [s]');
ylabel(ax(1), 'Recovery rate [HP/s]'); 
ylabel(ax(2), 'Base Rate [HP/(max hp * s)]'); 
title('Leech Rate');

fig(3) = subplot(3,1,3);
plot(t, HP_tot, 'b', t, HP_totVP, 'r-.');
ylim([0 inf]);
xlim([0 maxTime]);
xlabel('Time, t, [s]');
ylabel('HP restored, [HP]');
title('HP restored from leech');
legend('Recovery rate','Instantenous leech', 'Location','SouthEast')
linkaxes(fig,'x')

Tab wide buyout creator. Last updated: 2015-12-13

%% Tab wide buyout creator
home; close all; clear all; 
% This script will create spoiler tab buyouts for use in shop
% templates, for example in Procurement or Acquisition Plus. 

%% Input
% File name to save the template to:
fileName = 'Shop.txt';

% Price range:
priceIncrease = 0.5;
minPrice = 0;
maxPrice = 100;

% Define the name of spoiler and its stash name:
%   First column: Name of spoiler tag, can be Currency format, ilvl... 
%   Second column: Shorthand stash name.
currency = {
    'mirror',   'mirror';
    'exa',      'ex';
    'divine',   'divine';
    'gcp',      'gcp';
    'regal',    'regal';
    'regret',   'regret';
    'chaos',    'c';
    'blessed',  'blessed';
    'scour',    'scour';
    'alchemy',  'alch';
    'fuse',     'fuse';
    'chisel',   'chis';
    'chance',   'chance';
    'jewel',    'jew';
    'alt',      'alt';
    'chrom',    'chrom';
    'vaal',     'vaal';
            };
%% Print Shop
% Price vector:
prices = minPrice:priceIncrease:maxPrice;

% Open/create file to write:
fileID = fopen(fileName,'w');

% Create buyouts for all the defined currencies in Currency:
for currencyType = 1:length(currency(:,1))
    % Create spoiler buyouts for that particular currency type, 
    % value according to Prices at the following form:
    for i = 1:length(prices);
        % For Procurement or pre-0.4 Acquisition Plus:
        % [spoiler="~b/o 2.5 mirror"]
        % {Stash:2.5mirror|include.ignored}
        % [/spoiler]
%         fprintf(fileID,'[spoiler="~b/o %g ', prices(i)); fprintf(fileID,currency{type,1}); fprintf(fileID,'"]');
%         fprintf(fileID,'\n{Stash:%g', prices(i)); fprintf(fileID,currency{type,2}); fprintf(fileID,'|include.ignored}');
%         fprintf(fileID,'\n[/spoiler]');
%         fprintf(fileID,'\n');
        
        % For 0.4+ Acquisition plus:
        % {Stash:1c|include.ignored|wrap|header:~b/o 1 chaos}
        fprintf(fileID,'{Stash:%g', prices(i)); fprintf(fileID,currency{currencyType,2}); 
        fprintf(fileID,'|include.ignored|wrap'); fprintf(fileID,'|header:~b/o %g ', prices(i)); 
        fprintf(fileID,currency{currencyType,1}); fprintf(fileID,'}');
%         fprintf(fileID,'\n');
    end
end

% Close the written file:
fclose(fileID);


---