Dusty Posted December 9, 2014 Posted December 9, 2014 I can't figure out why this code isn't working, and I can't find anything else in the code that would seem to override it. What should happen is if the player is holding the Use button saber throw should be disabled so they can kick (this is in Single Player btw). From bg_pmove.cpp: qboolean PM_SaberThrowable( void ) { //player gets to kick if holding use if (pm->cmd.buttons & BUTTON_USE) { return qfalse; } //ugh, hard-coding this is bad... if ( pm->ps->saberAnimLevel == SS_STAFF ) { return qfalse; } if ( !(pm->ps->saber[0].saberFlags&SFL_NOT_THROWABLE) ) {//yes, this saber is always throwable return qtrue; } //saber is not normally throwable if ( (pm->ps->saber[0].saberFlags&SFL_SINGLE_BLADE_THROWABLE) ) {//it is throwable if only one blade is on if ( pm->ps->saber[0].numBlades > 1 ) {//it has more than one blade int numBladesActive = 0; for ( int i = 0; i < pm->ps->saber[0].numBlades; i++ ) { if ( pm->ps->saber[0].blade[i].active ) { numBladesActive++; } } if ( numBladesActive == 1 ) {//only 1 blade is on return qtrue; } } } //nope, can't throw it return qfalse; } qboolean PM_CheckAltKickAttack( void ) { if ( (pm->cmd.buttons&BUTTON_ALT_ATTACK) && (!(pm->ps->pm_flags&PMF_ALT_ATTACK_HELD) ||PM_SaberInReturn(pm->ps->saberMove)) && (!PM_FlippingAnim(pm->ps->legsAnim)||pm->ps->legsAnimTimer<=250) && (!PM_SaberThrowable()) && pm->ps->SaberActive() && !(pm->ps->saber[0].saberFlags&SFL_NO_KICKS)//okay to do kicks with this saber && (!pm->ps->dualSabers || !(pm->ps->saber[1].saberFlags&SFL_NO_KICKS) )//okay to do kicks with this saber ) { return qtrue; } return qfalse; } I would know it was partially working if I couldn't kick but I couldn't throw the saber either while use is held, but I know it's not working at all because I can always throw my saber... I would try debugging but the VS debugger hasn't been ehm, agreeing with me. Bek likes this
Asgarath83 Posted December 9, 2014 Posted December 9, 2014 in SAB file, if you set the "throwable" command to 0, the player with alt attack and lightsaber can kick. O.oif you want to disable saber throw on engine, maybe you need to search the "throwable" command of sab file and how work is boolean.
Dusty Posted December 10, 2014 Author Posted December 10, 2014 I tried that, but I didn't get any leads as to what was making my specific code not do anything. Maybe if I could have the use key change the "throwable" value. Only problem with that is I don't know if "throwable" is checked every frame. Maybe pressing use would change the value of the "saber" to 0, and then letting go would set it back. Worth a shot I guess.
Asgarath83 Posted December 11, 2014 Posted December 11, 2014 So you want to switch to 1 \ 0 on \ off the throwable command? for disable \ enable the kick \ throwing?
Solution Dusty Posted December 11, 2014 Author Solution Posted December 11, 2014 ^So, I looked into that. But I'm not sure how to "set" the SFL_NOT_THROWABLE flag back to not being on the saber after it is applied (setting it is easy as I can just copy Raven's code). I'm sure it can be done, but I'm not good with bitwise operators (the |=, &=, ~, and & are all used as bitwise operators by Raven) as they require me to wrap my mind around modifying binary code. What I did find was a piece of code I previously overlooked, a function in wp_saber.cpp called WP_Forcepowerusable. That actually controls the ability to saber throw. So now holding use disables saber throw by modding that. It seems the purpose of PM_SaberThrowable is just purely for kick checking. I'm still a bit confused however as to why staff saber allows kicks and single does not (maybe it has to do with the saberAnimLevel == SS_STAFF in there?), as with staff saber even when I make the saber throwable, you can still kick as the saber is returning to your hand, while it's mid-flight, or when you don't have enough FP for a saber throw. Still trying to solve the mystery I guess... EDIT: I'm thinking that based on my observations, the "if player is holding use" chunk of code in PM_SaberThrowable is having zilch effect (maybe the expression I used has no value in the context of that function), as the next two pieces of code regarding saberAnimLevel == SS_STAFF and the one pertaining to the SFL_NOT_THROWABLE flag (which is set by throwable 1/0 in the .sab) are consistent with all my/our other observations. Solution:Posting this way later. It turns out it was a redundant piece of code (somewhere in bg_pmove I think) that would bar the player code-side from even being able to press the Alt-Attack button if they had a non-staff saber that wasn't throwable.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now