Skip to content

Instantly share code, notes, and snippets.

@CanadianJeff
Last active January 5, 2022 13:24
Show Gist options
  • Save CanadianJeff/86f4d39e823153245d3fbe83d0ab6f10 to your computer and use it in GitHub Desktop.
Save CanadianJeff/86f4d39e823153245d3fbe83d0ab6f10 to your computer and use it in GitHub Desktop.
//-----------------------------------------------------
Msg("Activating Mutation 16 Extra Hunters\n");
::mapName <- Director.GetMapName().tolower()
::survivorSet <- Director.GetSurvivorSet()
::ghostModeEnabled <- false
::Debug <- true
::devs <- {}
devs["STEAM_1:0:26359107"] <- { name = "ReneTM", role = "creator" }
devs["STEAM_1:0:16327272"] <- { name = "Derdoron", role = "Beta Tester" }
IncludeScript("rocketdude/rd_debug")
IncludeScript("rocketdude/rd_utils")
IncludeScript("rocketdude/rd_melee_getter")
IncludeScript("rocketdude/rd_meds")
IncludeScript("rocketdude/rd_last_chance")
IncludeScript("rocketdude/rd_decals")
IncludeScript("rocketdude/rd_saferoom_timer")
ClientPrint(null, 5, WHITE + "Welcome To Hunter Dude!")
// Precache models and sounds
// ----------------------------------------------------------------------------------------------------------------------------
precacheSurvivorModels()
precacheRocketDudeModels()
precacheSounds()
// Get's fired 'OnGameplayStart' (usually after every single loadingscreen)
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameplayStart(){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameplayStart()")
}
/* CREATE MUSHROOMS */
if(IsValveMap()){
spawnMushrooms()
}
/* SPAWN MAP SIDED MUSHROOMS */
// spawnMapSidedMushrooms()
/* SET PLAYERS MAX HEALTH AND CURRENT HEALTH TO 200 */
setAllPlayersHealth()
/* Ghost Mode YaY */
// EnableGhostMode()
/* GENERAL SETTINGS */
// checkCvars()
/* CREATE BULLET TIME */
// createBulletTimerEntity()
/* KILL ALL DEATH CAMS */
// removeDeathFallCameras()
/* CREATE THINK TIMER */
createThinkTimer()
/* RESTORE SETTINGS LIKE BULLET TIME 1/0 */
// restoreGlobals()
}
function setAllPlayersHealth(){
if(Debug){
ClientPrint(null, 5, WHITE + "setAllPlayersHealth()")
}
foreach(player in GetSurvivors()){
NetProps.SetPropInt(player, "m_iMaxHealth", 100)
NetProps.SetPropInt(player, "m_iHealth", 100)
}
}
function setPlayersHealth(ent){
if(Debug){
ClientPrint(null, 5, WHITE + "setPlayersHealth(ent)")
}
NetProps.SetPropInt(ent, "m_iMaxHealth", 100)
NetProps.SetPropInt(ent, "m_iHealth", 100)
}
function ChangeGhostState(ent){
if(Debug){
ClientPrint(null, 5, WHITE + "ChangeGhostState(ent)")
}
local scope = GetValidatedScriptScope(ent)
scope["ghost_mode"] <- true
foreach(player in GetHumanSurvivors()){
local playerscope = GetValidatedScriptScope(player)
if(!("ghost_mode" in playerscope)){
ClientPrint(null, 5, GREEN + ent.GetPlayerName() + WHITE + " voted to " + ( IsGhostModeActive() ? "disable" : "enable" ) + " Ghost Mode")
return
}
}
if(IsGhostModeActive()){
DisableGhostMode()
}else{
EnableGhostMode()
}
foreach(player in GetHumanSurvivors()){
local scope = GetValidatedScriptScope(player)
if("ghost_mode" in scope){
player.GetScriptScope().rawdelete("ghost_mode")
}
}
ClientPrint(null, 5, WHITE + "Ghost Mode has been " + GREEN + ( IsGhostActive() ? "enabled" : "disabled") )
}
function DisableGhostModeAll(){
if(Debug){
ClientPrint(null, 5, WHITE + "DisableGhostModeAll()")
}
foreach(player in GetSurvivors()){
NetProps.SetPropInt(player, "m_isGhost", 0)
NetProps.SetPropInt(player, "m_iHealth", 100)
}
}
function EnableGhostModeAll(){
if(Debug){
ClientPrint(null, 5, WHITE + "EnableGhostModeAll()")
}
foreach(player in GetSurvivors()){
NetProps.SetPropInt(player, "m_ghostSpawnState", 385)
NetProps.SetPropInt(player, "m_ghostSpawnClockCurrentDelay", 0)
NetProps.SetPropInt(player, "m_bHasNightVision", 1)
NetProps.SetPropInt(player, "m_fEffects", 4)
NetProps.SetPropInt(player, "m_iClass", 0)
NetProps.SetPropInt(player, "m_iAddonBits", 0)
NetProps.SetPropInt(player, "m_iPlayerState", 0)
NetProps.SetPropInt(player, "m_iVersusTeam", 3)
NetProps.SetPropInt(player, "m_isGhost", 1)
NetProps.SetPropInt(player, "m_nForceBone", 0)
NetProps.SetPropInt(player, "m_nRenderMode", 1)
NetProps.SetPropInt(player, "m_ubEFNoInterpParity", 3)
NetProps.SetPropInt(player, "m_zombieClass", 8)
NetProps.SetPropInt(player, "m_iHealth", 100)
}
}
function DisableGhostMode(player){
if(Debug){
ClientPrint(null, 5, WHITE + "DisableGhostMode(player)")
}
NetProps.SetPropInt(player, "m_isGhost", 0)
NetProps.SetPropInt(player, "m_iHealth", 100)
}
function EnableGhostMode(player){
if(Debug){
ClientPrint(null, 5, WHITE + "EnableGhostMode(player)")
}
NetProps.SetPropInt(player, "m_ghostSpawnState", 385)
NetProps.SetPropInt(player, "m_ghostSpawnClockCurrentDelay", 0)
NetProps.SetPropInt(player, "m_bHasNightVision", 1)
NetProps.SetPropInt(player, "m_fEffects", 4)
NetProps.SetPropInt(player, "m_iClass", 0)
NetProps.SetPropInt(player, "m_iAddonBits", 0)
NetProps.SetPropInt(player, "m_iPlayerState", 0)
NetProps.SetPropInt(player, "m_iVersusTeam", 3)
NetProps.SetPropInt(player, "m_isGhost", 1)
NetProps.SetPropInt(player, "m_nForceBone", 0)
NetProps.SetPropInt(player, "m_nRenderMode", 1)
NetProps.SetPropInt(player, "m_ubEFNoInterpParity", 3)
NetProps.SetPropInt(player, "m_zombieClass", 8)
NetProps.SetPropInt(player, "m_iHealth", 100)
}
function IsGhostModeActive(player){
if(Debug){
ClientPrint(null, 5, WHITE + "IsGhostModeActive(player)")
}
if(NetProps.GetPropInt(player, "m_isGhost") & 1){
return true
}
return false
}
// Chat commands
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_player_say(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_say()")
}
local text,ent = null
if("userid" in params && params.userid == 0){
return
}
text = strip(params["text"].tolower())
ent = GetPlayerFromUserID(params["userid"])
if(text.len() < 1){
return
}
local steamID = ent.GetNetworkIDString()
local scope = GetValidatedScriptScope(ent)
switch(text){
case ".g2mushroom" :
GoToNextMushroom(ent)
break
case "+ghost" :
EnableGhostMode(ent)
break
case "-ghost" :
DisableGhostMode(ent)
break
case "+health" :
setPlayersHealth(ent)
break
}
}
function OnGameEvent_player_first_spawn(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_first_spawn()")
}
local orangestar = ORANGE + "?"
if(params["isbot"] == 0){
local player = GetPlayerFromUserID(params.userid)
local steamID = player.GetNetworkIDString()
if(steamID in devs){
local invTable = {}
GetInvTable(player, invTable)
if(GetAvailableSharpMelees().find("crowbar") != null){
if("slot1" in invTable && invTable.slot1.GetClassname() == "weapon_melee"){
if(NetProps.GetPropString(invTable.slot1, "m_strMapSetScriptName") != "crowbar"){
invTable.slot1.Kill()
player.GiveItemWithSkin("crowbar", 1)
}else{
NetProps.SetPropInt(invTable.slot1, "m_nSkin", 1)
}
}
}
ClientPrint(null, 5, orangestar + GREEN + " RocketDude " + devs[steamID].role + BLUE + " " + player.GetPlayerName() + WHITE + " joined the game.")
}
}
}
// "The right man in the wrong place can make all the difference in the world"
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_player_changename(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_changename()")
}
local player = GetPlayerFromUserID(params["userid"])
local invTable = {}
GetInvTable(player, invTable)
if("newname" in params && params["newname"] == "Dr. Gordon Freeman"){
if("slot1" in invTable && invTable.slot1.GetClassname() == "weapon_melee"){
if(NetProps.GetPropString(invTable.slot1, "m_strMapSetScriptName") == "crowbar"){
NetProps.SetPropInt(invTable.slot1, "m_nSkin", 1)
}
}
}
}
function OnGameEvent_player_spawn(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_spawn()")
}
local player = GetPlayerFromUserID(params["userid"])
if(player.GetZombieType() == 9 && !IsPlayerABot(player)){
placeRocketDudeDecals()
teleportToSurvivor(player)
DoEntFire("!self", "DisableLedgeHang", "", 0.0, player, player)
DoEntFire("!self", "ignorefalldamagewithoutreset", "99999", 0.0, player, player)
if(NetProps.GetPropInt(player, "m_iMaxHealth") != 100){
NetProps.SetPropInt(player, "m_iMaxHealth", 100)
}
}
}
function teleportToSurvivor(player){
if(Debug){
ClientPrint(null, 5, WHITE + "teleportToSurvivor(" + player + ")")
}
setPlayersHealth(player)
local target = getClosestSurvivorTo(player)
if(target == null){
return
}
if((player.GetOrigin() - target.GetOrigin()).Length() < 256){
return
}
if(target.IsValid()){
if(!target.IsDead() && !target.IsDying()){
if(Director.HasAnySurvivorLeftSafeArea()){
player.SetOrigin(target.GetOrigin())
}
}
}
}
function OnGameEvent_player_incapacitated(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_incapacitated()")
}
if("attackerentid" in params){
if(EntIndexToHScript(params.attackerentid).GetClassname() == "trigger_hurt"){
return
}
}
// if(!lastChanceUsed){
// lastChanceSwitch(params)
// }
}
// When a survivor stands full hp in a mushroom trigger volume the function is unlocked
// again and the survivor gets hurt a touchtest should be done
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_player_hurt(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_hurt()")
}
if(GetPlayerFromUserID(params.userid).GetZombieType() == 9){
foreach(trigger in medkit_triggers){
DoEntFire("!self", "TouchTest", "", 0, trigger, trigger)
}
}
}
// Disable glows when survivors enter "last chance mode" but fail
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_mission_lost(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_mission_lost()")
}
disableInfectedGlows()
}
// Called when any player dies. Purpose mostly for bullet time, reviving survivors from being incap and "last chance"
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_player_death(params){
if(Debug){
ClientPrint(null, 5, WHITE + "OnGameEvent_player_death()")
}
local victim = null
local attacker = null
local victimClass = null
if("userid" in params){
victim = GetPlayerFromUserID(params["userid"])
} else if("entityid" in params){
victim = EntIndexToHScript(params["entityid"])
}
if("attacker" in params){
attacker = GetPlayerFromUserID(params["attacker"])
} else if("attackerentid" in params){
attacker = EntIndexToHScript(params["attackerentid"])
}
// if(!lastChanceUsed){
// lastChanceSwitch(params)
// }
if(victim.IsPlayer() && victim.GetZombieType() == 9){
ClientPrint(null, 5, BLUE + victim.GetPlayerName() + WHITE + " did not finish this map. The map finished them.")
}
if(victim.GetClassname() != "infected"){
if(victim.GetClassname() == "witch" || victim.GetZombieType() != 9){ // Killed witch or any Special infected or tank
if(attacker != null && attacker.IsPlayer()){ // Dont do anything when the map is the killer
if(attacker.GetZombieType() == 9){
if(attacker.IsIncapacitated()){
if(!missionFailed){
if(last_chance_active){
stopLastChanceMode()
attacker.ReviveFromIncap()
}else{
if(!allSurvivorsIncap()){
attacker.ReviveFromIncap()
}else{
ClientPrint(null, 5, BLUE + "Time to say goodbye")
}
}
EmitAmbientSoundOn("player/orch_hit_csharp_short", 1, 100, 100, attacker)
}
}
}
}
}
}else{
if(attacker != null && attacker.GetClassname() == "player" && attacker.GetZombieType() == 9){
bulletTime()
}
}
}
// Set tank's health in relation to the current difficulty
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_tank_spawn(params){
local tank = EntIndexToHScript(params.tankid)
local health = 0
switch(Convars.GetStr("z_difficulty").tolower()){
case "easy" :
health = 8000; break
case "normal" :
health = 16000; break
case "hard" :
health = 32000; break
case "impossible" :
health = 64000; break
}
tank.SetMaxHealth(health)
tank.SetHealth(health)
}
// Set witch health in relation to the current difficulty
// ----------------------------------------------------------------------------------------------------------------------------
function OnGameEvent_witch_spawn(params){
local witch = EntIndexToHScript(params.witchid)
local health = 0
switch(Convars.GetStr("z_difficulty").tolower()){
case "easy" :
health = 2048; break
case "normal" :
health = 4096; break
case "hard" :
health = 8192; break
case "impossible" :
health = 16384; break
}
witch.SetMaxHealth(health)
witch.SetHealth(health)
}
// Typing sv_cheats 1 on local server would result in every cheat flagged variable reset
// ----------------------------------------------------------------------------------------------------------------------------
//function OnGameEvent_server_cvar(param){
// if("cvarname" in param){
// local cvar = param.cvarname
// if(cvar == "sv_cheats"){
// checkCvars()
// }
// }
//}
__CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)
::fixEntitiesRemoved <- false
::killFixEntities <- function(){
if(!fixEntitiesRemoved){
EntFire( "anv_mapfixes*", "Kill" )
EntFire( "env_player_blocker", "Kill" )
EntFire( "rene_relay", "Trigger" )
fixEntitiesRemoved = true
}
}
// Check if mushrooms can be reactivated
// ----------------------------------------------------------------------------------------------------------------------------
function updateMushroomTrigger(){
foreach(trigger in medkit_triggers){
local scope = GetValidatedScriptScope(trigger)
if(Time() >= scope.usetime + scope.restoreTime){
if(scope.usable == false){
scope.usetime = Time() - scope.restoreTime
setMedVisibility(1, scope.model)
scope.usable = true
DoEntFire("!self", "TouchTest", "", 0, trigger, trigger)
}
}
}
}
// Hold space for auto-bhop ( if player used bhop mushroom )
// ----------------------------------------------------------------------------------------------------------------------------
::bunnyPlayers <- {}
function autobhop(){
foreach(player,ent in bunnyPlayers){
if(ent.IsValid()){
if(!(NetProps.GetPropInt(ent, "m_fFlags") & 1) && NetProps.GetPropInt(ent, "movetype") == 2){
if(ent.GetButtonMask() & 2){
ent.OverrideFriction(0.033, 0)
}
NetProps.SetPropInt(ent, "m_afButtonDisabled", NetProps.GetPropInt(ent, "m_afButtonDisabled") | 2)
}else{
NetProps.SetPropInt(ent, "m_afButtonDisabled", NetProps.GetPropInt(ent, "m_afButtonDisabled") & ~2)
}
}else{
bunnyPlayers.rawdelete(player)
}
}
}
function safeRoomCheck(){
foreach(ent in GetHumanSurvivors()){
if(ent.IsValid()){
if( ResponseCriteria.GetValue(ent, "incheckpoint" ) == "1" ){
DisableGhostMode()
}else{
//Do Something Every Tick You Are Not In Saferoom?
// EnableGhostMode()
}
}
}
}
// Get's fired every tick from a timer
// ----------------------------------------------------------------------------------------------------------------------------
function Think(){
// checkCvars()
// GrenadeListener()
// PlayerSettings()
// projectileListener()
updateMushroomTrigger()
autobhop()
// PlayerFunctions()
// lastChanceCountDown()
// tankrockListener()
// safeRoomTimer()
// safeRoomCheck()
}
DirectorOptions <-
{
ActiveChallenge = 1
weaponsToRemove =
{
weapon_defibrillator = 0
}
function AllowWeaponSpawn( classname )
{
if ( classname in weaponsToRemove )
{
return false;
}
return true;
}
weaponsToConvert =
{
weapon_first_aid_kit = "weapon_pain_pills_spawn"
weapon_pipe_bomb = "weapon_molotov_spawn"
weapon_vomitjar = "weapon_molotov_spawn"
}
function ConvertWeaponSpawn( classname )
{
if ( classname in weaponsToConvert )
{
return weaponsToConvert[classname];
}
return 0;
}
DefaultItems =
[
"weapon_pistol_magnum",
]
function GetDefaultItem( idx )
{
if ( idx < DefaultItems.len() )
{
return DefaultItems[idx];
}
return 0;
}
cm_ProhibitBosses = 1
cm_NoSurvivorBots = 1
cm_SpecialSlotCountdownTime = 5
cm_SpecialRespawnInterval = 0
cm_AutoReviveFromSpecialIncap = 1
SurvivorMaxIncapacitatedCount = 3
cm_DominatorLimit = 1
cm_MaxSpecials = 3
cm_BaseSpecialLimit = 3
cm_AllowSurvivorRescue = 1
cm_AllowPillConversion = 0
ProhibitBosses = true
HunterLimit = 3
BoomerLimit = 0
SmokerLimit = 0
SpitterLimit = 0
ChargerLimit = 0
JockeyLimit = 0
CommonLimit = 0
DominatorLimit = 4
SpecialInitialSpawnDelayMin = 0
SpecialInitialSpawnDelayMax = 6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment