Coder Social home page Coder Social logo

Comments (10)

szapp avatar szapp commented on June 2, 2024

Fix #10 implement free shooting

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

Constrain this issue to rotation and free shooting.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

Free rotation is implemented.

Separately for runes and scrolls, oCMag_Book::Spell_Cast calls oCSpell::Setup. This function performs a check on oCSpell.targetCollectAlgo and then presumably (?) calls oCVisualFX::Init (0x491F20). This, in turn, sets up the trajectory of the spell fx according to the passed target vob.

Finding out where best to manipulate this target vob is the next step.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

The address to inject the aim vob at should be in this engine function.

0x4861D0          int __thiscall oCSpell::IsValidTarget(zCVob*)

In that function, the target vob is validated. This entails checking if its type matches oCSpell.targetCollectType and if it is in line of sight.
An appropriate address to hook within this function is after both checks are performed to overwrite the return value as well as the vob itself (to the aim vob). This will set the aim vob as focus vob for the spell and have it always valid, even when out of line of sight.

Allow free aiming only for spells whose property targetCollectAlgo is one of the following.

  • TARGET_COLLECT_NONE
  • TARGET_COLLECT_FOCUS_FALLBACK_NONE

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

Pick up the work on free aim for spells.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

Update issue details to generalize to free aim for spells.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

At the moment, work is focused on finalizing and stabilizing free aiming. After it has been solved for ranged combat (bow and crossbow), the work on blink and spells in general will be picked up again.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

It might even be a nice idea to create a distributor like Spell_ProcessMana. Spell_ProcessMana calls the respective Spell_Logic_* function of each spell. The function to hook oCSpell::Setup could be just like that calling each (the spells that are actually entered there) spell's Spell_Invest_* function. This would offer additional control over spells with this general structure:

instance  Spell_Name () // Settings
func  int Spell_Logic_Name(var int manaInvested) // Previous invest loop (as before: trigger FX-levels and timed events)
func void Spell_Invest_Name() // NEW (for frame-based operations like aiming; only necessary for certain invest spells of course)
func void Spell_Cast_Name(var int spellLevel) // Cast function (as before: decrease mana, cast the spell if it is not an invest spell)

Analogous to Spell_ProcessMana:

const int oCSpell__Setup = 4737328; //0x484930
HookEngineF(oCSpell__Setup, 7, Spell_ProcessInvest);

func void Spell_ProcessInvest(/* Is it possible to ask for arguments here? */) {
    // Get self and other (or item)
    self = _@(MEM_ReadInt(ESP+4)); // Self is a global instance (Classes.d) and will stay set in the functions below
    var int targetPtr; targetPtr = MEM_ReadInt(ESP+8);
    if (Hlp_Is_oCNpc(targetPtr)) { other = _@(targetPtr); } // Other is a global instance (Classes.d) and will stay set in the functions below
    else if (Hlp_Is_oCItem(targetPtr)) { item = _@(targetPtr); }; // Item is a global instance (Classes.d) and will stay set in the functions below

    // From here on it's the usual (like in Spell_ProcessMana and Spell_ProcessManaRelease)
    var int activeSpell; activeSpell = Npc_GetActiveSpell(self); // Could also be retrieved with ESP+12 but this looks more familiar

    // ...
    if (activeSpell == SPL_Blink) { Spell_Invest_Blink(); return; };
    // ...

    // Spells that don't need to hook the function should just not be listed here. Same as in Spell_ProcessManaRelease.
};
func void Spell_Invest_Blink() {
    if (!Npc_IsPlayer(self)) { return; }; // Only player is allowed to use this spell anyway
    // ...
    var int ptr; ptr = ESP+8; // Not sure about the offset here
    MEM_WriteInt(ptr, vobPtr); // The variable vobPtr points to the aim vob
};

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

If this works, it is probably not even necessary to create the aim vob as oCItem.

from gothicfreeaim.

szapp avatar szapp commented on June 2, 2024

One likely solution might be to change the hook. Hook this function instead (or additionally) to unconditionally change the target vob:

const int oCSpell__Setup = 4737328; //0x484930
HookEngineF(oCSpell__Setup, 7, Spell_Invest_Blink);
func void Spell_Invest_Blink() {
    // ...
    var int ptr; ptr = ESP+8; // Not sure about the offset here
    MEM_WriteInt(ptr, vobPtr); // The variable vobPtr points to the aim vob
};

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.