A_Suvorov

PHOT SIM

May 12th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.55 KB | None | 0 0
  1. clear
  2. base_crit_pct = 9.2; %base critical chance
  3. base_severity_pct = 75.2; %base critical severity
  4.  
  5. biom_crit_pct = 2; %additional crit chance on enhanced biometric  torp
  6. biom_severity_pct = 20; % additional crit severity on enhanced biometric torp
  7.  
  8. phot_crit_pct = 4; % additional crit chance on photon torp
  9. phot_severity_pct = 10; %additional severity on photon torp
  10.  
  11. torp_damage = 5922.16; % the per shot kinetic torpedo damage
  12.  
  13. for i = 1:1:10000 %number of tests
  14.  
  15.     seconds=120; %the number of seconds you want to run the test for
  16.     %setup
  17.     biom = 0; %the enhanced biomolecular photon torpedo is ready to fire
  18.     phot = 0; %the regular photon torpedo is ready to fire
  19.     CD = 0; %global torpedo cooldown is not active
  20.     biomcount = 0; %no biomolecular torpedoes have been fired
  21.     photcount = 0; %no photon torpedoes have been fired
  22.     damage_dealt = 0; % no damage dealt yet
  23.     for j=1:.5:seconds
  24.         if biom == 0 && CD == 0
  25.             biom = 6.5; %biom fires, with .5 sec act time and 6 sec CD time;
  26.             doff1 = randi(5); %roll doffs
  27.             if doff1 == 1
  28.                 biom = biom -5;
  29.             end
  30.             doff2 = randi(5);
  31.             if doff2 == 1
  32.                 biom = biom-5;
  33.             end
  34.             doff3 = randi(5);
  35.             if doff3 == 1
  36.                 biom = biom -5;
  37.             end
  38.             if biom < 1.5
  39.                 biom = 1.5;
  40.             end
  41.             CD = 1; %global torpedo cooldown is active
  42.             biomcount = biomcount +1; %count the shot
  43.             crit = randi(1000); %roll crit
  44.             crith = (base_crit_pct + biom_crit_pct)*10; %crith threshold calculation
  45.             critd = (base_severity_pct + biom_severity_pct)/100; %critical bonus
  46.             mult = 1; %multiplier, to be modified if a crit is scored
  47.             if crit <= crith
  48.                 mult = 1 + critd;
  49.             end
  50.             damage_dealt=damage_dealt + (mult)*torp_damage; %deal the damage
  51.         end
  52.         if phot == 0 && CD == 0
  53.             phot = 6.5; %phot fires, with .5 sec act time and 6 sec CD time;
  54.             doff1 = randi(5); %roll doffs
  55.             if doff1 == 1
  56.                 phot = phot -5;
  57.             end
  58.             doff2 = randi(5);
  59.             if doff2 == 1
  60.                 phot = phot-5;
  61.             end
  62.             doff3 = randi(5);
  63.             if doff3 == 1
  64.                 phot = phot -5;
  65.             end
  66.             if phot < 1.5
  67.                 phot = 1.5;
  68.             end
  69.             CD = 1; %global torpedo cooldown is active
  70.             photcount = photcount + 1; %count the shot
  71.             crit = randi(1000); %roll crit
  72.             crith = (base_crit_pct + phot_crit_pct)*10; %crith threshold calculation
  73.             critd = (base_severity_pct + phot_severity_pct)/100; %critical bonus
  74.             mult = 1; %multiplier, to be modified if a crit is scored
  75.             if crit <= crith
  76.                 mult = 1 + critd;
  77.             end
  78.             damage_dealt=damage_dealt + (mult)*torp_damage; %deal the damage
  79.         end
  80.         if biom > 0
  81.             biom = biom -.5;
  82.         end
  83.         if phot > 0
  84.             phot = phot -.5;
  85.         end
  86.         if CD > 0
  87.             CD = CD -.5;
  88.         end
  89.     end
  90.     biomolecular_fired(i) = biomcount;
  91.     photon_fired(i) = photcount;
  92.     total_fired(i) = photcount + biomcount;
  93.     damage(i) = damage_dealt;
  94.  
  95. end
  96.  
  97. average_biomolecular_fired = mean(biomolecular_fired)
  98. average_photon_fired = mean(photon_fired)
  99. average_fired = mean(total_fired)
  100. average_damage = mean(damage)
Advertisement
Add Comment
Please, Sign In to add comment