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

Weapons score #43

Open
wopox1337 opened this issue Sep 19, 2023 · 0 comments
Open

Weapons score #43

wopox1337 opened this issue Sep 19, 2023 · 0 comments

Comments

@wopox1337
Copy link
Collaborator

test() {
    enum WeaponProps_s {
        _name[32],
        Float: _price,
        Float: _cycleTime,
        Float: _damage,
        Float: _armorRatio}
    new weaponsProps[][WeaponProps_s] = {
        { "Glock18",    400.00, 0.2000, 25.00, 1.05 },
        { "USP",        500.00, 0.2250, 34.00, 1.00 },
        { "P228",       600.00, 0.2000, 32.00, 1.25 },
        { "Deagle",     650.00, 0.3000, 54.00, 1.50 },
        { "FiveSeven",  750.00, 0.2000, 20.00, 1.50 },
        { "Elites",     800.00, 0.2000, 36.00, 1.05 },

        { "M3",         1700.0, 0.8750, 20.0, 1.00 },
        { "XM1014",     3000.0, 0.2500, 20.0, 1.00 },

        { "TMP",        1250.0, 0.0700, 20.00, 1.00 },
        { "MAC-10",     1400.0, 0.0700, 29.00, 0.95 },
        { "MP5Navy",    1500.0, 0.0750, 26.00, 1.00 },
        { "UMP45",      1700.0, 0.1000, 30.00, 1.00 },
        { "P90",        1500.0, 0.0660, 21.00, 1.50 },
        
        { "Famas",      2250.0, 0.0825, 30.00, 1.40 },
        { "Galil",      2000.0, 0.0875, 30.00, 1.55 },
        { "Scout",      2750.0, 1.2500, 75.00, 1.70 },
        { "M4A1",       3100.0, 0.0875, 32.00, 1.40 },
        { "AK47",       2500.0, 0.0955, 36.00, 1.55 },
        { "SG552",      2500.0, 0.0825, 33.00, 1.40 },
        { "AUG",        3500.0, 0.0825, 32.00, 1.40 },
        { "SG550",      4200.0, 0.2500, 70.00, 1.45 },
        { "G3SG1",      5000.0, 0.2500, 80.00, 1.65 },
        { "AWP",        4750.0, 1.4500, 115.0, 1.95 },

        { "M249",       5750.0, 0.1000, 32.00, 1.50 },
    }

    server_print("| %-9s | %-5s |", "Weapon", "Score")
    server_print("| --------- | ----- |")
    for (new i; i < sizeof weaponsProps; i++) {
        server_print("| %-9s | %-5i |",
            weaponsProps[i][_name],
            GetWeaponScore(
                weaponsProps[i][_price],
                weaponsProps[i][_cycleTime],
                weaponsProps[i][_damage],
                weaponsProps[i][_armorRatio]
            )
        )
    }
    // for (new i; i < sizeof weaponsProps; i++) {
    //     server_print("| %-9s | %-5i |",
    //         weaponsProps[i][_name],
    //         GetWeaponScore2(
    //             weaponsProps[i][_price],
    //             weaponsProps[i][_cycleTime],
    //             weaponsProps[i][_damage]
    //         )
    //     )
    // }
}

GetWeaponScore(const Float: price, const Float: cycleTime, const Float: damage, const Float: armorRatio) {
    new Float: score = 1.0

    new Float: score1 = floatmax(
        0.05,
        (1.0 - (price / 4500.0) * 10.0) / 5.0
    )

    new Float: score2 = score1 + floatmin(
        2.0,
        ( ( (cycleTime / damage ) * 10.0 ) + ( (2.0 - armorRatio) / 2.0 ) ) / 4.0
    )


    new Float: final = (score2 * 100.0) - 0.5
    score = floatmax(0.0, final)
    
    // server_print(" - score1:`%.4f`, score2:`%.4f`, final:`%.4f`, score:`%.4f`",
    //     score1, score2, final, score
    // )

    return floatround(score, floatround_ceil)
}
/* 
| Weapon    | Score |
| --------- | ----- |
| M3        | 28    |
| XM1014    | 21    |
| Glock18   | 19    |
| USP       | 19    |
| MAC-10    | 19    |
| Elites    | 18    |
| TMP       | 18    |
| MP5Navy   | 18    |
| UMP45     | 18    |
| P228      | 16    |
| FiveSeven | 14    |
| Deagle    | 13    |
| Famas     | 13    |
| Scout     | 13    |
| M4A1      | 13    |
| SG552     | 13    |
| AUG       | 13    |
| SG550     | 13    |
| M249      | 12    |
| P90       | 12    |
| Galil     | 11    |
| AK47      | 11    |
| G3SG1     | 10    |
| AWP       | 9     |

 */

GetWeaponScore2(const Float: price, const Float: cycleTime, const Float: damage) {
    new Float: score1 = ((cycleTime / damage) - 0.001) * 10.0
    new Float: score2 = ((300.0 / floatmax( 500.0, price )) + score1) * 100.0
    new Float: score = floatmax( 1.0, score2)

    return floatround(score, floatround_ceil)
}
/* 2

| Weapon    | Score |
| --------- | ----- |
| Glock18   | 82    |
| USP       | 66    |
| P228      | 56    |
| Deagle    | 51    |
| FiveSeven | 49    |
| Elites    | 43    |
| Scout     | 27    |
| TMP       | 27    |
| P90       | 23    |
| MAC-10    | 23    |
| MP5Navy   | 22    |
| M3        | 22    |
| UMP45     | 20    |
| AWP       | 18    |
| Galil     | 17    |
| Famas     | 16    |
| AK47      | 14    |
| SG552     | 14    |
| XM1014    | 12    |
| M4A1      | 12    |
| AUG       | 11    |
| SG550     | 10    |
| G3SG1     | 9     |
| M249      | 8     |

 */

from https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/game/shared/cstrike15/cs_gamerules.cpp#L16982-L17025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant