DIMEDROLL Apr 22, 2014 @ 11:00am
Force director to spawn mob \ horde with predefined size
I want to make a mutation where director spawns small mobs every time players complete next 5% of map. For percents calculations I will use GetFurthestSurvivorFlow and GetMaxFlowDistance functions. But how do I spawn a mob \ horde of common infected of certain size?
I don't see any control over this in vscripts.
Showing 1-7 of 7 comments
< >
Casimer the Adequately Skilled Apr 22, 2014 @ 11:06am 
https://developer.valvesoftware.com/wiki/L4D2_EMS/Appendix:_Spawning_Infected

You can change MegaMobSize and CommonLimit and then force a panic event.
DIMEDROLL Apr 22, 2014 @ 11:18am 
I've found DirectorOptions for changing the size of a mob, they are:
MobMinSize
MobMaxSize

I can also control the interval between mobs using:
MobSpawnMaxTime
MobSpawnMinTime

But it seems like there is no way to force the spawning of a mob from vscript file. I want to do something like this:

if ( PlayersReachedNext5PercentFlowCheckpoint() )
{
DirectorSpawnMobWithSize(3, 7);
}
where 3 is min size, 4 is max size of commons in a mob.
Last edited by DIMEDROLL; Apr 22, 2014 @ 11:19am
Rectus Apr 22, 2014 @ 2:39pm 
The simplest way is to use Director.ResetMobTimer() to force the timer down. Make sure you turn down the Relax options, since mobs won't spawn when relaxing.

You can also use the staging system for more complex triggering. The Holdout map scripts use it a lot, so be sure to check them out.
Last edited by Rectus; Apr 22, 2014 @ 2:40pm
DIMEDROLL Apr 23, 2014 @ 11:08pm 
so here is the solution:

director_ent <- Entities.FindByClassname (null, "info_director");
DoEntFire("!self","ForcePanicEvent","0",0,null,director_ent);

By setting the MegaMobSize in MutationOptions you can control the size of mobs.

But ForcePanicEvent also produces a music which I would like to disable, didn't find an easy way to do it
Last edited by DIMEDROLL; Apr 23, 2014 @ 11:09pm
Rectus Apr 24, 2014 @ 12:28am 
The panic event outputs of the director entity are kind of old hardcoded leftovers from L4D1, you don't have that much control over it. I wouldn't rely on it for a mutation, especially with so many new ways to do it.

You probably could achieve the smae effect using stages by alterantig betwen a panic and a infinite delay with something like this:
MutationState <-
{
PanicTriggered = false
}

MutationOptions <-
{
ScriptedStageType = STAGE_SETUP
}

function DirectorSpawnMobWithSize(min, max)
{
SessionOptions.MegaMobMaxSize <- max;
SessionOptions.MegaMobMinSize <- min;

SessionState.PanicTriggered <- true;
Director.ForceNextStage();
}

function GetNextStage() // Called by the director.
{
if(SessionState.PanicTriggered)
{
DirectorOptions.ScriptedStageType <- STAGE_PANIC
DirectorOptions.ScriptedStageValue <- 1
SessionState.PanicTriggered = false
}
else
{
DirectorOptions.ScriptedStageType <- STAGE_DELAY
DirectorOptions.ScriptedStageValue <- -1
}
}

I'm not sure how it affects the music though. There are some director options beginning with MusicDynamicMob* that might let you turn it off. Most of the options are listed here.

Edit: It probably should use the DirectorOptions table for the options set in GetNextStage().
Last edited by Rectus; Apr 24, 2014 @ 12:56am
DIMEDROLL Apr 24, 2014 @ 2:52am 
well, the idea is to make something similar to Alien Swarm gameplay. I want to spawn zombies and make them run to players. A also want to prevent rushing without killing zombies. I mean that if players run and don't kill zombies they get more and more zombies chasing them, and eventually will have to kill them all or die.

This is what I've done so far

MutationOptions <-
{
CommonLimit = 80 // Maximum number of common zombies alive in the world at the same time
MegaMobSize = 20 // Total number of common zombies in a mob. (never more than CommonLimit at one time)
WanderingZombieDensityModifier = 0 // lets get rid of the wandering zombies
MaxSpecials = 1 //
TankLimit = 1 //
WitchLimit = 0 //
BoomerLimit = 0
ChargerLimit = 0
HunterLimit = 0
JockeyLimit = 0
SpitterLimit = 0
SmokerLimit = 0

cm_BaseCommonAttackDamage = 12.5
}

MutationState <-
{
CurrentStage = 0
}

flow_prev <- 0.0
//flow_current <- 0.0
flow_step <- 0.05 // 5% of flow

director_ent <- Entities.FindByClassname (null, "info_director");

function GetNextStage()
{
switch ( SessionState.CurrentStage )
{
case 0: // setup stage
SessionOptions.ScriptedStageType = STAGE_SETUP
SessionOptions.ScriptedStageValue = 10 // seconds to stay in this stage
//printl(" Director found: " + director_ent )
SessionState.CurrentStage++
break

case 1: // common zombie attack!

local furthestflow = GetAverageSurvivorFlowDistance();
local maxflow = GetMaxFlowDistance();
local flow_current = furthestflow / maxflow;
//printl( furthestflow +" : " + maxflow + " : " + flow_current + " : " + flow_prev )
if ( flow_current > (flow_prev + flow_step))
{
flow_prev = flow_prev + flow_step
DoEntFire("!self","ForcePanicEvent","0",0,null,director_ent);
//printl(" STARTING PANIC, flow is: " + flow_current )
}
SessionOptions.ScriptedStageType = STAGE_DELAY
SessionOptions.ScriptedStageValue = 1
break
// case 2: // clear out the stragglers
// SessionOptions.ScriptedStageType = STAGE_CLEAROUT
// SessionOptions.ScriptedStageValue = 10 // Wait 10 seconds once all infected are dead
// break
// case 3: // you win! the game will restart after a few moments
// SessionOptions.ScriptedStageType = STAGE_RESULTS
// printl(" *** YOU WIN! YOU WIN! YOU WIN! *** ")
// break
}
}

I use GetNextStage() because didn't found any other callback method yet.
Rectus Apr 24, 2014 @ 4:03am 
I think the stage system is completely separate from the panic event system that ForcePanicEvent fires, so they'll likely interfere. CDirector::ForceNextStage() is what triggers the next stage, as well as the prevous stage running out.
Last edited by Rectus; Apr 24, 2014 @ 4:03am
Showing 1-7 of 7 comments
< >
Per page: 15 30 50
Date Posted: Apr 22, 2014 @ 11:00am
Posts: 7