Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Stratagem Calculation #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 58 additions & 63 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8492,80 +8492,75 @@ private void resetSongTimer_Tick(object sender, EventArgs e)

private void checkSCHCharges_Tick(object sender, EventArgs e)
{
if (_ELITEAPIPL != null && _ELITEAPIMonitored != null)
if (_ELITEAPIPL == null || _ELITEAPIMonitored == null)
{
int MainJob = _ELITEAPIPL.Player.MainJob;
int SubJob = _ELITEAPIPL.Player.SubJob;
return;
}

if (MainJob == 20 || SubJob == 20)
{
if (plStatusCheck(StatusEffect.Light_Arts) || plStatusCheck(StatusEffect.Addendum_White))
{
int currentRecastTimer = GetAbilityRecastBySpellId(231);
int MainJob = _ELITEAPIPL.Player.MainJob;
int SubJob = _ELITEAPIPL.Player.SubJob;

int SpentPoints = _ELITEAPIPL.Player.GetJobPoints(20).SpentJobPoints;
if (MainJob != 20 && SubJob != 20)
{
return;
}

int MainLevel = _ELITEAPIPL.Player.MainJobLevel;
int SubLevel = _ELITEAPIPL.Player.SubJobLevel;
if (!plStatusCheck(StatusEffect.Light_Arts) && !plStatusCheck(StatusEffect.Addendum_White))
{
return;
}

int baseTimer = 240;
int baseCharges = 1;
int schLevel = MainJob == 20 ? _ELITEAPIPL.Player.MainJobLevel : _ELITEAPIPL.Player.SubJobLevel;
int jobPoints = _ELITEAPIPL.Player.GetJobPoints(20).SpentJobPoints;

// Generate the correct timer between charges depending on level / Job Points
if (MainLevel == 99 && SpentPoints > 550 && MainJob == 20)
{
baseTimer = 33;
baseCharges = 5;
}
else if (MainLevel >= 90 && SpentPoints < 550 && MainJob == 20)
{
baseTimer = 48;
baseCharges = 5;
}
else if (MainLevel >= 70 && MainLevel < 90 && MainJob == 20)
{
baseTimer = 60;
baseCharges = 4;
}
else if (MainLevel >= 50 && MainLevel < 70 && MainJob == 20)
{
baseTimer = 80;
baseCharges = 3;
}
else if ((MainLevel >= 30 && MainLevel < 50 && MainJob == 20) || (SubLevel >= 30 && SubLevel < 50 && SubJob == 20))
{
baseTimer = 120;
baseCharges = 2;
}
else if ((MainLevel >= 10 && MainLevel < 30 && MainJob == 20) || (SubLevel >= 10 && SubLevel < 30 && SubJob == 20))
{
baseTimer = 240;
baseCharges = 1;
}
int regainChargeTime = 0;
int maxCharges = 0;

// Now knowing what the time between charges is lets calculate how many
// charges are available
if (schLevel == 99 && jobPoints >= 550)
{
regainChargeTime = 33;
maxCharges = 5;
}
else if (schLevel >= 90)
{
regainChargeTime = 48;
maxCharges = 5;
}
else if (schLevel >= 70)
{
regainChargeTime = 60;
maxCharges = 4;
}
else if (schLevel >= 50)
{
regainChargeTime = 80;
maxCharges = 3;
}
else if (schLevel >= 30)
{
regainChargeTime = 120;
maxCharges = 2;
}
else if (schLevel >= 10)
{
regainChargeTime = 240;
maxCharges = 1;
}

if (currentRecastTimer == 0)
{
currentSCHCharges = baseCharges;
}
else
{
int t = currentRecastTimer / 60;
int chargeTimeRemaining = GetAbilityRecastBySpellId(231);

int stratsUsed = t / baseTimer;
if (chargeTimeRemaining == 0)
{
currentSCHCharges = maxCharges;
return;
}

currentSCHCharges = (int)Math.Ceiling((decimal)baseCharges - stratsUsed);
// Now knowing what the time between charges is lets calculate how many
// charges are available

if (baseTimer == 120)
{
currentSCHCharges -= 1;
}
}
}
}
}
int maxChargeTime = (maxCharges - 1) * regainChargeTime;
int fullChargeTimeRemaining = maxChargeTime - chargeTimeRemaining / 60;
currentSCHCharges = (int) Math.Ceiling((double) fullChargeTimeRemaining / regainChargeTime);
}

private bool CheckEngagedStatus()
Expand Down