diff --git a/maps/mp/gametypes/hns.gsc b/maps/mp/gametypes/hns.gsc index 52a39fe..37e0550 100644 --- a/maps/mp/gametypes/hns.gsc +++ b/maps/mp/gametypes/hns.gsc @@ -349,30 +349,13 @@ onPlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHit player = self; - // If victim has a custom model, destroy it - if (IsDefined(player.customModel)) + // If victim was disguised, reset him + if (IsDefined(player.disguiseEntity)) { - player.customModel Delete(); + player.disguiseEntity Delete(); if (IsDefined(game["hiders_changed_sound"])) player PlaySound(game["hiders_changed_sound"]); - } - - // If victim had a custom model set, reset it - if (IsDefined(player.originalModel)) - { - player SetModel(player.originalModel); - if (IsDefined(game["hiders_changed_sound"])) - player PlaySound(game["hiders_changed_sound"]); - player.originalModel = undefined; - } - if (IsDefined(player.originalModelAttachments)) - { - player DetachAll(); - for (index = 0; index < player.originalModelAttachments.size; index++) - { - player Attach(player.originalModelAttachments[index].model, player.originalModelAttachments[index].tag); - } - player.originalModelAttachments = undefined; + player Show(); } // Update spectator permissions @@ -606,17 +589,6 @@ handleSeeker() { // Blind player if seekers weren't released yet player playLocalSound(game["seekers_blind_sound"]); - /*for (a = 0; a < RandomIntRange(5, 20); a++) { - len = RandomFloatRange(0.0, 0.25); - player VisionSetNakedForPlayer("blacktest", len); - wait len; - len = RandomFloatRange(0.0, 0.25); - player VisionSetNakedForPlayer(getDvar("mapname"), len); - wait len; - } - len = RandomFloatRange(0.0, 0.25); - player VisionSetNakedForPlayer("blacktest", len); - */ player VisionSetNakedForPlayer("blacktest", 0.1); // Freeze, hide @@ -732,6 +704,8 @@ enableThirdPersonSwitch(playerCommand, value) { } } + + /* * Binds a player command to let the player change into the model they * are looking at. @@ -758,22 +732,6 @@ enableModelChange(playerCommand) { defaultOriginAdd = (player GetEye()) - (player GetOrigin()); } - if (!IsDefined(player.originalModel)) - { - player.originalModel = player.model; - } - - if (!IsDefined(player.originalModelAttachments)) - { - player.originalModelAttachments = []; - for (index = 0; index < player GetAttachSize(); index++) - { - player.originalModelAttachments[index] = spawnstruct(); - player.originalModelAttachments[index].tag = player GetAttachTagName(index); - player.originalModelAttachments[index].model = player GetAttachModelName(index); - } - } - // Make a trace to the focused object origin = (player GetOrigin()) + defaultOriginAdd; trace = BulletTrace(origin, origin + anglestoforward(player getplayerangles()) * 1000000, false, player); @@ -797,7 +755,13 @@ enableModelChange(playerCommand) { healthfrac = player.health / player.maxhealth; newhealth = healthfrac * (trace["entity"] GetNormalHealth()); - player SetModel(trace["entity"].model); + if (!IsDefined(player.disguiseEntity)) + { + player Hide(); + player.disguiseEntity = Spawn("script_model", player.origin); + player thread watchDisguise("+melee"); + } + player.disguiseEntity SetModel(trace["entity"].model); if (IsDefined(game["hiders_changed_sound"])) player PlaySound(game["hiders_changed_sound"]); @@ -814,6 +778,64 @@ enableModelChange(playerCommand) { } } +/* + * Makes sure that the disguiseEntity attached to the "self" object + * (a player) is always at the same position as the object itself. + * + * Also runs enableDisguiseModelAngleLocking() with the given player + * command that allows to rotate the entity as intended. + */ +watchDisguise(angleLockingPlayerCommand) +{ + logString("watchDisguise called"); + + player = self; + + level endon("game_ended"); + player endon("death"); + player endon("disconnect"); + + //player.disguiseEntity LinkTo(player, "j_head", (0,0,0), (0,0,0)); + player.disguiseEntity NotSolid(); + + player.disguiseAnglesLocked = false; + player thread enableDisguiseModelAngleLocking(angleLockingPlayerCommand); + + 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); + } +} + +/* + * Enables locking the angles of the disguise model using a player + * command. + */ +enableDisguiseModelAngleLocking(playerCommand) +{ + logString("enableDisguiseModelAngleLocking called"); + + player = self; + + level endon("game_ended"); + player endon("death"); + player endon("disconnect"); + + player notifyOnPlayerCommand("disguisemodelanglelocking_requested", playerCommand); + + for (;;) + { + player waittill("disguisemodelanglelocking_requested"); + player.disguiseAnglesLocked = !player.disguiseAnglesLocked; + } +} + /* * Binds a player command to shuffle the weapon. */ @@ -881,4 +903,6 @@ revealWhenGameEnds() PlayFX(game["fx_boom"], fxPos); wait 0.75; } +} + } \ No newline at end of file