int prob

GPC2 script programming for Titan Two. Code examples, questions, requests.

Re: int prob

Postby J2Kbr » Mon Sep 26, 2016 5:55 pm

here is your code coveted to Titan Two script language:

Code: Select all
#include <xb1.gph>

#define ADS_SENS    100.0
#define OVE_SENS    100.0
#define MIDPOINT    50.0

fix32 add_time;
fix32 add_times;
fix32 add_timem;

main {
    if(get_val(XB1_LT)) {
        sensitivity(XB1_LX, MIDPOINT+add_timem, ADS_SENS+add_time);       
        sensitivity(XB1_LY, MIDPOINT+add_timem, ADS_SENS+add_time);
    } else { // OVERALL SENS
        sensitivity(XB1_LX, MIDPOINT+add_timem, OVE_SENS+add_times);
        sensitivity(XB1_LY, MIDPOINT+add_timem, OVE_SENS+add_times);
    }
   
    if(get_val(XB1_LT)) {
        if(event_active(XB1_Y)) add_times += 5.0;
        if(event_active(XB1_B)) add_times -= 5.0;
    }
    if(get_val(XB1_LS)) {
        if(event_active(XB1_Y)) add_timem += 5.0;
        if(event_active(XB1_B)) add_timem -= 5.0;
    }
    if(get_val(XB1_P4)) {
        if(event_active(XB1_Y)) add_time += 5.0;
        if(event_active(XB1_B)) add_time -= 5.0;
    }
}

void sensitivity(uint8 i, fix32 m, fix32 s) {
    fix32 v = get_val(i);
    if(v) {
        if(m) {
            v = (v > 0.0) ? midpoint(v, m) : midpoint(v * -1.0, m) * -1.0;
        }
        if(s) {
            v = (v * s) / 100.0;
        }
        if(v > 100.0) v = 100.0;
        else if(v < -100.0) v = -100.0;
        set_val(i, v);
    }
    return;
}

fix32 midpoint(fix32 v, fix32 m) {
    if(v <= m) return((v * 50.0) / m);
    return(((50.0 * (v - m)) / (100.0 - m)) + 50.0);
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: int prob

Postby yohimbe » Mon Sep 26, 2016 6:07 pm

nope doesnt change any sens in the game
User avatar
yohimbe
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Sun Mar 01, 2015 7:27 pm

Re: int prob

Postby J2Kbr » Mon Sep 26, 2016 6:26 pm

Sorry, I mistakenly used LX/LY instead of RX/RY, fixed:

Code: Select all
#include <xb1.gph>

#define ADS_SENS    100.0
#define OVE_SENS    100.0
#define MIDPOINT    50.0

fix32 add_time;
fix32 add_times;
fix32 add_timem;

main {
    if(get_val(XB1_LT)) {
        sensitivity(XB1_RX, MIDPOINT+add_timem, ADS_SENS+add_time);       
        sensitivity(XB1_RY, MIDPOINT+add_timem, ADS_SENS+add_time);
    } else { // OVERALL SENS
        sensitivity(XB1_RX, MIDPOINT+add_timem, OVE_SENS+add_times);
        sensitivity(XB1_RY, MIDPOINT+add_timem, OVE_SENS+add_times);
    }
   
    if(get_val(XB1_LT)) {
        if(event_active(XB1_Y)) add_times += 5.0;
        if(event_active(XB1_B)) add_times -= 5.0;
    }
    if(get_val(XB1_LS)) {
        if(event_active(XB1_Y)) add_timem += 5.0;
        if(event_active(XB1_B)) add_timem -= 5.0;
    }
    if(get_val(XB1_P4)) {
        if(event_active(XB1_Y)) add_time += 5.0;
        if(event_active(XB1_B)) add_time -= 5.0;
    }
}

void sensitivity(uint8 i, fix32 m, fix32 s) {
    fix32 v = get_val(i);
    if(v) {
        if(m) {
            v = (v > 0.0) ? midpoint(v, m) : midpoint(v * -1.0, m) * -1.0;
        }
        if(s) {
            v = (v * s) / 100.0;
        }
        if(v > 100.0) v = 100.0;
        else if(v < -100.0) v = -100.0;
        set_val(i, v);
    }
    return;
}

fix32 midpoint(fix32 v, fix32 m) {
    if(v <= m) return((v * 50.0) / m);
    return(((50.0 * (v - m)) / (100.0 - m)) + 50.0);
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: int prob

Postby yohimbe » Mon Sep 26, 2016 6:55 pm

no, i already corrected it.
there just no sens change in the game.
User avatar
yohimbe
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Sun Mar 01, 2015 7:27 pm

Re: int prob

Postby Prototype » Mon Sep 26, 2016 7:23 pm

yohimbe wrote:there just no sens change in the game.

It change the sensitivity for me when i set the midpoint to 60 for example.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: int prob

Postby paname » Wed Sep 28, 2016 1:00 pm

Jefferson,

maybe to avoid issue for the general "non developper" public, maybe we should have a "wrapper" type that would
cast behind the scene the variable to avoid confusion.. basically making everything defined a fix32 for example but behind the scene.. not sure if that makes sense but this will avoid a lot of problem in the futur for people not familiar with the various variable type.. it would consume a bit more memory but should be a problem.
User avatar
paname
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 204
Joined: Wed Jan 07, 2015 3:02 pm

Re: int prob

Postby J2Kbr » Wed Sep 28, 2016 6:54 pm

paname wrote:Jefferson,

maybe to avoid issue for the general "non developper" public, maybe we should have a "wrapper" type that would
cast behind the scene the variable to avoid confusion.. basically making everything defined a fix32 for example but behind the scene.. not sure if that makes sense but this will avoid a lot of problem in the futur for people not familiar with the various variable type.. it would consume a bit more memory but should be a problem.

yes, I liked your idea ... like 'var', which is just a synonymous of fix32. Is 'var' an good keyword for that purpose? or any other suggestion?

GitHub: https://github.com/J2Kbr/GtunerIV/issues/21
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: int prob

Postby pablosscripts » Thu Sep 29, 2016 7:36 am

J2Kbr wrote:
paname wrote:Jefferson,

maybe to avoid issue for the general "non developper" public, maybe we should have a "wrapper" type that would
cast behind the scene the variable to avoid confusion.. basically making everything defined a fix32 for example but behind the scene.. not sure if that makes sense but this will avoid a lot of problem in the futur for people not familiar with the various variable type.. it would consume a bit more memory but should be a problem.

yes, I liked your idea ... like 'var', which is just a synonymous of fix32. Is 'var' an good keyword for that purpose? or any other suggestion?

GitHub: https://github.com/J2Kbr/GtunerIV/issues/21



I really like "var", perfectly describes what it is.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR

My R6 script: https://youtu.be/x-9NtxyySVM
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: int prob

Postby J2Kbr » Thu Sep 29, 2016 8:26 am

:smile1001: So be it
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: int prob

Postby Prototype » Thu Sep 29, 2016 9:55 am

+1 for var!
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 108 guests