+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.
master
Icedream 2016-04-13 01:23:37 +02:00
parent 8e954ac94a
commit 62c68028d3
2 changed files with 114 additions and 18 deletions

View File

@ -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 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,6 +1022,8 @@ watchDisguiseDamage()
for (;;)
{
player.disguiseEntity waittill("damage", amount, attacker, direction_vec, point, type, modelName, tagName, partName, iDFlags);
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
@ -1007,11 +1033,52 @@ watchDisguiseDamage()
// 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;
}
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;
}
}
}

19
maps/mp/mods/_math.gsc Normal file
View File

@ -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;
}