X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fdodging%2Fsv_dodging.qc;h=8af5092226109f9664f78165d376355f5034934b;hb=689d7266afa20762289c3f3ef13f50c1ab9ea017;hp=19f8b1046ca9f4acce853f5644012cdec16c2468;hpb=873f1b3ef177d3b290982be4adb3707482b8c6fc;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 19f8b1046..8af509222 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -42,22 +42,21 @@ #endif #ifdef CSQC - float cvar_cl_dodging_timeout; - bool cvar_cl_dodging; bool autocvar_cl_dodging; #define PHYS_DODGING_FRAMETIME (1 / (frametime <= 0 ? 60 : frametime)) #define PHYS_DODGING_TIMEOUT(s) STAT(DODGING_TIMEOUT) #define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys #define PHYS_DODGING_ENABLED(s) autocvar_cl_dodging #elif defined(SVQC) - .float cvar_cl_dodging_timeout; - .bool cvar_cl_dodging; #define PHYS_DODGING_FRAMETIME sys_frametime - #define PHYS_DODGING_TIMEOUT(s) CS(s).cvar_cl_dodging_timeout + #define PHYS_DODGING_TIMEOUT(s) CS_CVAR(s).cvar_cl_dodging_timeout #define PHYS_DODGING_PRESSED_KEYS(s) CS(s).pressedkeys - #define PHYS_DODGING_ENABLED(s) CS(s).cvar_cl_dodging + #define PHYS_DODGING_ENABLED(s) CS_CVAR(s).cvar_cl_dodging #endif +REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); +REPLICATE(cvar_cl_dodging, bool, "cl_dodging"); + #ifdef SVQC bool autocvar_sv_dodging_sound; @@ -280,6 +279,7 @@ void PM_dodging_GetPressedKeys(entity this) { PM_dodging_checkpressedkeys(this); + // NOTE: GetPressedKeys and PM_dodging_GetPressedKeys use similar code int keys = this.pressedkeys; keys = BITSET(keys, KEY_FORWARD, PHYS_CS(this).movement.x > 0); keys = BITSET(keys, KEY_BACKWARD, PHYS_CS(this).movement.x < 0); @@ -287,7 +287,7 @@ void PM_dodging_GetPressedKeys(entity this) keys = BITSET(keys, KEY_LEFT, PHYS_CS(this).movement.y < 0); keys = BITSET(keys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(this)); - keys = BITSET(keys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(this)); + keys = BITSET(keys, KEY_CROUCH, IS_DUCKED(this)); // workaround: player can't un-crouch until their path is clear, so we keep the button held here keys = BITSET(keys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(this)); keys = BITSET(keys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(this)); this.pressedkeys = keys; @@ -306,8 +306,30 @@ MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics) #ifdef SVQC -REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); -REPLICATE(cvar_cl_dodging, bool, "cl_dodging"); +void dodging_ResetPlayer(entity this) +{ + this.last_dodging_time = 0; + + this.dodging_action = 0; + this.dodging_single_action = 0; + + this.dodging_force_total = 0; + this.dodging_force_remaining = 0; + + this.dodging_direction = '0 0 0'; +} + +MUTATOR_HOOKFUNCTION(dodging, PlayerSpawn) +{ + entity player = M_ARGV(0, entity); + dodging_ResetPlayer(player); +} + +MUTATOR_HOOKFUNCTION(dodging, MakePlayerObserver) +{ + entity player = M_ARGV(0, entity); + dodging_ResetPlayer(player); +} MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys) {