From 62c68028d34aa9723a0380d3a4ac8c7f3462c1e8 Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Wed, 13 Apr 2016 01:23:37 +0200 Subject: [PATCH] +frag for rotation locking, +speed_throw for switching between rotation modes. You can switch between modes using the +speed_throw keybind (usually right mouse key). Initial mode will be 0 which is "full rotation" without any limitation. 1 will then be "limited rotation" which allows for more "default" rotation like "just left"/"just right"/"just forward"/"just backwards" or "just down"/"just up". 2 is only accessible through the +frag keybind (usually G) and completely locks the current angles. --- maps/mp/gametypes/hns.gsc | 113 ++++++++++++++++++++++++++++++++------ maps/mp/mods/_math.gsc | 19 +++++++ 2 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 maps/mp/mods/_math.gsc diff --git a/maps/mp/gametypes/hns.gsc b/maps/mp/gametypes/hns.gsc index ac1c969..049cc50 100644 --- a/maps/mp/gametypes/hns.gsc +++ b/maps/mp/gametypes/hns.gsc @@ -2,6 +2,7 @@ #include maps\mp\_utility; #include maps\mp\perks\_perks; #include maps\mp\gametypes\_hud_util; +#include maps\mp\mods\_math; #include maps\mp\mods\_modversion; #include maps\mp\mods\disableClassMenu; #include maps\mp\mods\helpingHints; @@ -62,6 +63,7 @@ main() if (getdvar("mapname") == "mp_background") return; + /# // Show version watermark at bottom right versionHudElem = createServerFontString("default", 1.0); versionHudElem setPoint("BOTTOMRIGHT", "BOTTOMRIGHT", -4, -14); @@ -70,6 +72,7 @@ main() versionHudElem.sort = 1001; versionHudElem.foreground = false; versionHudElem.alpha = 0.5; + #/ // Define allowed seeker weapons level.seekerWeapons = []; @@ -677,6 +680,10 @@ handleHider() { player thread enableQuickRandomModelChange("+reload"); player thread giveHelpfulHintsForHider(); player thread revealWhenGameEnds(); + /# + player thread enableUnlimitedReload(); + player thread enableWeaponDicing("+actionslot 2"); + #/ if (!gameFlag("seekers_released")) { @@ -721,7 +728,7 @@ setDisguiseModel(model) player.disguiseEntity.owner = player.owner; player.disguiseEntity Solid(); player.disguiseEntity SetCanDamage(true); - player thread watchDisguise("+melee"); + player thread watchDisguise("+frag", "+speed_throw"); player thread watchDisguiseDamage(); } player.disguiseEntity SetModel(model); @@ -959,8 +966,12 @@ handleModelMenuSelection() * * Also runs enableDisguiseModelAngleLocking() with the given player * command that allows to rotate the entity as intended. + * + * Also runs enableDisguiseModelAngleModeSwitching() with the given + * player command that allows to switch between methods of rotating + * the entity. */ -watchDisguise(angleLockingPlayerCommand) +watchDisguise(angleLockingPlayerCommand, angleModeSwitchPlayerCommand) { logPrint("watchDisguise called"); @@ -970,18 +981,31 @@ watchDisguise(angleLockingPlayerCommand) player endon("death"); player endon("disconnect"); - player.disguiseAnglesLocked = false; + player.disguiseAngleMode = 0; player thread enableDisguiseModelAngleLocking(angleLockingPlayerCommand); + player thread enableDisguiseModelAngleModeSwitching(angleModeSwitchPlayerCommand); for (;;) { wait 0.05; if (!IsDefined(player.disguiseEntity)) - break; - player.disguiseEntity MoveTo(player GetOrigin(), 0.1); - if (player.disguiseAnglesLocked) continue; - player.disguiseEntity RotateTo(player GetPlayerAngles(), 0.1); + + player.disguiseEntity MoveTo(player GetOrigin(), 0.1); + switch (player.disguiseAngleMode) + { + case 0: // full rotate + player.disguiseEntity RotateTo(player GetPlayerAngles(), 0.1); + break; + case 1: // lock rotate + playerAngles = player GetPlayerAngles(); + playerAngles = ( + roundFloat(playerAngles[0] / 90, 0) * 90, + roundFloat(playerAngles[1] / 90, 0) * 90, + playerAngles[2]); + player.disguiseEntity RotateTo(playerAngles, 0.1); + //case 2: // no rotate + } } } @@ -998,20 +1022,63 @@ watchDisguiseDamage() for (;;) { player.disguiseEntity waittill("damage", amount, attacker, direction_vec, point, type, modelName, tagName, partName, iDFlags); - attacker maps\mp\gametypes\_damagefeedback::updateDamageFeedback("standard"); - // eInflictor = the entity that causes the damage (e.g. a claymore) - // eAttacker = the player that is attacking - // iDamage = the amount of damage to do - // sMeansOfDeath = string specifying the method of death (e.g. "MOD_PROJECTILE_SPLASH") - // sWeapon = string specifying the weapon used (e.g. "claymore_mp") - // damagepos = the position damage is coming from - // damagedir = the direction damage is moving in - player maps\mp\gametypes\_weapons::damageEnt(type, attacker, amount, "", modelName, point, direction_vec); - //player.health = player.disguiseEntity.health; + if (attacker.team != player.team) + { + attacker maps\mp\gametypes\_damagefeedback::updateDamageFeedback("standard"); + // eInflictor = the entity that causes the damage (e.g. a claymore) + // eAttacker = the player that is attacking + // iDamage = the amount of damage to do + // sMeansOfDeath = string specifying the method of death (e.g. "MOD_PROJECTILE_SPLASH") + // sWeapon = string specifying the weapon used (e.g. "claymore_mp") + // damagepos = the position damage is coming from + // damagedir = the direction damage is moving in + player maps\mp\gametypes\_weapons::damageEnt(type, attacker, amount, "", modelName, point, direction_vec); + } + player.disguiseEntity.health = player.health; } } +/* + * Enables switching between methods of angle application on the disguise model + * using a player command. + */ +enableDisguiseModelAngleModeSwitching(playerCommand) +{ + logPrint("enableDisguiseModelAngleModeSwitching called"); + + player = self; + + level endon("game_ended"); + player endon("death"); + player endon("disconnect"); + + player notifyOnPlayerCommand("disguisemodelanglemodeswitch_requested", playerCommand); + + for (;;) + { + player waittill("disguisemodelanglemodeswitch_requested"); + if (player.disguiseAngleMode > 1) + { + // Some other button was used to lock the position completely + player.disguiseAngleMode = 0; // start from "Full" + } + else + { + player.disguiseAngleMode = (player.disguiseAngleMode + 1) % 2; + } + switch (player.disguiseAngleMode) + { + case 0: // full rotate + player IPrintLnBold("Rotation mode: ^2Full"); + break; + case 1: // lock rotate + player IPrintLnBold("Rotation mode: ^2Limited"); + break; + } + } +} + /* * Enables locking the angles of the disguise model using a player * command. @@ -1031,7 +1098,17 @@ enableDisguiseModelAngleLocking(playerCommand) for (;;) { player waittill("disguisemodelanglelocking_requested"); - player.disguiseAnglesLocked = !player.disguiseAnglesLocked; + switch (player.disguiseAngleMode) + { + case 2: // currently locked, should unlock (to full as this is the easiest way out) + player.disguiseAngleMode = 0; + player IPrintLnBold("Rotation mode: ^2Full"); + break; + default: // currently unlocked, should lock + player.disguiseAngleMode = 2; + player IPrintLnBold("Rotation mode: ^2Locked"); + break; + } } } diff --git a/maps/mp/mods/_math.gsc b/maps/mp/mods/_math.gsc new file mode 100644 index 0000000..a05afda --- /dev/null +++ b/maps/mp/mods/_math.gsc @@ -0,0 +1,19 @@ +// The below code is modified from the original at http://www.mpgh.net/forum/showthread.php?t=309318&p=4346157&viewfull=1#post4346157 + +roundFloat(floatValue, places) +{ + expValue = exponent(10, places); + floatValue *= expValue; + floatValue += 0.5; + floatValue = int(floatValue); + floatValue /= expValue; + return floatValue; +} + +exponent(basev, exp) +{ + result = 1; + for(i = 0; i < exp; i++) + result *= basev; + return result; +} \ No newline at end of file