Code Monkey home page Code Monkey logo

Comments (2)

szapp avatar szapp commented on September 25, 2024

Fix #43 #47 #42 outsource accuracy and draw force

from gothicfreeaim.

szapp avatar szapp commented on September 25, 2024
/* Retrieve draw force scaled between 0 and 100 (percent) */
func int freeAimGetDrawForce() {
    // Scale draw time between 0 and 100, see #43
    return 100;
};

/* Retrieve aiming accuracy scaled between 0 and 100 (percent). Modify this function to alter accuracy calculation */
func int freeAimGetAccuracy() {
    var int accuracy[3]; // Number of factors playing into the accuracy(+1), here: talent [1] and draw force [2]
    // Factor 1: Talent (keep in mind that it might be greater than 100)
    var oCItem weapon; weapon = Npc_GetEquippedRangedWeapon(hero);
    if (weapon.flags &~ ITEM_BOW) { accuracy[1] = hero.HitChance[NPC_TALENT_BOW]; }
    else if (weapon.flags &~ ITEM_CROSSBOW) { accuracy[1] = hero.HitChance[NPC_TALENT_CROSSBOW]; }
    else { MEM_Error("freeAimGetAccuracy: No valid weapon equipped!"); return -1; }; // Invalid, should never happen
    // Factor 2: Draw force
    accuracy[2] = freeAimGetDrawForce(); // Already scaled between [0, 100], see above
    // Factor X: Add any other factors here e.g. weapon-specific accuracy stats, accuracy talent, ...
    // Calculate overall accuracy from all factors (modify the following line for different weighting)
    accuracy[0] = (accuracy[1] + accuracy[2])/2; // Here: simple average
    // Final accuracy needs to be in [0, 100]
    if (accuracy[0] > 100) { accuracy[0] = 100; } else if (accuracy[0] < 0) { accuracy[0] = 0; };
    return accuracy[0];
};

/* ... */

var int accuracy; accuracy = freeAimGetAccuracy();

from gothicfreeaim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.