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

Implement mouse movement lock #1

Closed
szapp opened this issue Aug 9, 2016 · 8 comments
Closed

Implement mouse movement lock #1

szapp opened this issue Aug 9, 2016 · 8 comments

Comments

@szapp
Copy link
Owner

szapp commented Aug 9, 2016

Mouse movement speed is different in different environments. It needs to be locked with framerame.

@szapp
Copy link
Owner Author

szapp commented Aug 10, 2016

Either update the mouse at fixed intervals in the frame function/hook (not every iteration).

var int lastMouseUpdate;
const int mouseUpdateInterval = 50; // Time interval (ms) to update mouse
func void Spell_Invest_Blink(var int casterId) {
    if (MEM_Timer.totaltime > lastMouseUpdate + mouseUpdateInterval) {
        lastMouseUpdate = MEM_Timer.totaltime;
        if (!aimModifier) { aimModifier = FLOATEINS; };
        updateHeroYrot(aimModifier); // Outsourced since it might be useful for other spells/weapons as well (free aim)
    };
    // ...
};

Or create a separarte frame function for that.

// A little redunant but, aimModifier changes and needs to be updated before every call
func void updateMouse() {
    if (!aimModifier) { aimModifier = FLOATEINS; };
    updateHeroYrot(aimModifier); // Outsourced since it might be useful for other spells/weapons as well (free aim)
};

const int mouseUpdateInterval = 50; // Time interval (ms) to update mouse
func void Spell_Invest_Blink(var int casterId) {
    if (!FF_Active(updateHeroYrot) { FF_ApplyExt(updateMouse, mouseUpdateInterval, -1);
    // ...
};

@szapp
Copy link
Owner Author

szapp commented Aug 16, 2016

The modifier for different interframe intervals needs to be adjusted. (Lower frame-rate causes to fast movement at the moment).

@szapp
Copy link
Owner Author

szapp commented Aug 16, 2016

This modifier must be adjusted and tested:

var int frameAdj; frameAdj = divf(MEM_Timer.frameTimeFloat, mkf(100)); // Adjust speed to fps (~= frame lock)
turnDeg = mulf(turnDeg, frameAdj);

@szapp
Copy link
Owner Author

szapp commented Aug 17, 2016

The above works for high frame rates (IFI 6), but is to fast for low frame rates (IFI 30).
sigmoid(x*0.1)*0.1 might help, but first of all it's not ideal (does not start at zero) and secondly it is too complicated (I don't know if there exists a sigmoid function in gothic).

@szapp
Copy link
Owner Author

szapp commented Aug 17, 2016

It does not help to hook the mouse movement directly.

These are the data collected in-game:

IFI (inter-frame interval) modifier
3 0.048
14 0.19
24 0.44

@szapp
Copy link
Owner Author

szapp commented Oct 13, 2016

Fix #20 and #1 by linear regression

@szapp
Copy link
Owner Author

szapp commented Oct 13, 2016

Fix #1, #2, #5, #9 implements stable version

The FX scripts are added and changed: Now the aiming FX is managed by
the spell and Wld_PlayEffect was removed. (See #5)

The focus vob is no set to the aim vod which is an oCItem. This works
very consistently now. (See #2)

The mouse is not really frame locked but rather scaled to the fps.
(See #1)

The mouse sensitivity issue seems to be resolved by #1. (See #9)

1 similar comment
@szapp
Copy link
Owner Author

szapp commented Oct 13, 2016

Fix #1, #2, #5, #9 implements stable version

The FX scripts are added and changed: Now the aiming FX is managed by
the spell and Wld_PlayEffect was removed. (See #5)

The focus vob is no set to the aim vod which is an oCItem. This works
very consistently now. (See #2)

The mouse is not really frame locked but rather scaled to the fps.
(See #1)

The mouse sensitivity issue seems to be resolved by #1. (See #9)

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

No branches or pull requests

1 participant