/** * Get the difference in company value between the value of the provided company * and the next ahead or behind in the rank list. * @param company_id The Company ID in which the difference is based of. * @param next_ahead_in_rank boolean value (use 'true' to compare with the next * ahead in rank or 'false' to compare with the next behind in rank). * @note The difference is always equal or higher than zero. * @note Returns -1 when Company Value GS SCP isn't active, or when the provided * Company ID is invalid. * @note Returns 0 when there is no company ahead or behind in rank. */ function GetCompanyIDDiffToNext(company_id, next_ahead_in_rank); function SCPClient_CompanyValueGS::GetCompanyIDDiffToNext(company_id, next_ahead_in_rank) { if (this._scp == null) return -1; if (this._company_value_gs_game != true) return -1; if (AICompany.ResolveCompanyID(company_id) == AICompany.COMPANY_INVALID) return -1; if (typeof(next_ahead_in_rank) != "bool") return -1; local global_list = this.GetRankingList(); if (global_list.Count() == 0) return -1; local difference = 0; if (global_list.Count() == 1) return difference; local company_id_rank = this.GetCompanyIDRank(company_id); if (company_id_rank == 1 && next_ahead_in_rank || company_id_rank == global_list.Count() && !next_ahead_in_rank) return difference; local rank = 0; local next_company_id = AICompany.COMPANY_INVALID; for (local c_id = global_list.Begin(); !global_list.IsEnd(); c_id = global_list.Next()) { rank++; if (rank == (company_id_rank + (next_ahead_in_rank ? -1 : 1))) { next_company_id = c_id; break; } } if (next_ahead_in_rank) { difference = this.GetCompanyIDValue(next_company_id) - this.GetCompanyIDValue(company_id); } else { difference = this.GetCompanyIDValue(company_id) - this.GetCompanyIDValue(next_company_id); } return difference; }