Jump to content
Sign in to follow this  
meatball

Zombie Script

Recommended Posts

I almost hate to ask this, because I feel like zombie related stuff is getting old hat, but I've been monkeying around with a mission idea that requires some sort of unarmed menace that will chase the players around and Zombies are just the easiest to deal with from the perspective of creating all new models/animations and such.

I've looked at the few scripts that are out there and would like something a bit cleaner/more robust. I also don't want to use any types of addons or mods, and want the whole thing to be completely script based. Could someone let me know if doing any of the following is feasible through script?

1) Be completely script based, no addons/mods required.

2) Be multiplayer compatible, so anyone in the playableUnits array that is in range of one of these units will set it off to go after them.

3) Change the skin tone of the infected units to grey or something that looks off.

4) Have the units wander aimlessly until a player gets within range, then the unit may move to investigate, and if the player gets closer, it will start to chase them.

5) When the unit gets up close and personal, hit the player and do damage.

I've got a real basic script I've started working up, but it's just not looking right, and I'm not even sure some of these things can be done completely through script. Plus I'm thinking a behavior type script running for every 'zombie' unit out there will just kill server/host FPS/resources.

Before I put a ton of time into this, I was just wondering if anyone had any thoughts or ideas...

Share this post


Link to post
Share on other sites

Here is my idea.

1. Spawn regular AI, handle damage via event handeler, setdamage 0.9

You now have an AI limping around covered in blood and using the eventhandel you can adjust how much damage it can take.

2. Set the AI to move at the fastest speed to the closest player. This should cause him to limp around to the player.

3. if ((_target distance _zombie) < 1) then {Animation; _target damage; etc}

Thats my rough idea. You could probably craft some particle effects and attach to the zombie to make it more death like.

Share this post


Link to post
Share on other sites

Here's what I threw together so far, but it still needs a ton of work. The animations don't seem to be working right and I can't seem to get the zombie to actually start sprinting when within the chase distance. I still need to figure out adding sounds and changing the zombie skin tone. If anyone has any suggestions/thoughts or any of those or any way to make the script better, let me know.

// Zombie Init v 0.1 - By Meatball
// Save file in root mission folder as 'zombieInit.sqf'
// Call Script in AI Unit's Init field with the following:
//    nul = [this] execVM "zombieInit.sqf";

_zombieName = _this select 0;

_viewDistance = 100; // Distance at which the zombie will do various animations, but not notice the player.
_investigateDistance = 50; // Distance at which a zombie will start investigating/closing on player
_chaseDistance = 25;  // Distance at which a zombie will start chasing the player.
_attackDistance = 2;  // Distance at which a zombie will 'attack' player
_attackDamage = 0.15;  // Damage done every time a zombie hits player.

_zombieName setdamage 0.9;

while {(alive _zombieName)} do
{
 // Find closest player out of all playableUnits
	_closestPlayer = playableUnits call BIS_fnc_selectRandom;
	_closestDistance = _zombieName distance _closestPlayer;
	{_distCheck = _zombieName distance _x;
	 if (_distCheck < _closestDistance)
		then {_closestPlayer = _x;
			  _closestDistance = _distCheck;
			  };
			  } foreach playableUnits;

hint "1";

// Zombie is in 'view' distance.  Will do random animations and walk around randomly. but does not see player

while {((_zombieName distance _closestPlayer) <= _viewDistance) && ((_zombieName distance _closestPlayer) > _investigateDistance)} do {
		_randomMove = floor (random 3);
		switch (_randomMove) do {
			case 0: {_zombieName playaction "C7A_longWalk";_randPlayer = playableUnits call BIS_fnc_selectRandom;_zombieName domove (position _randPlayer);};
			case 1: {_zombieName playaction "AmovPercMstpSnonWnonDnon_Scared";};
			case 2: {_zombieName playaction "AidlPercMstpSnonWnonDnon_G03";};
			};
		hint "2";
		sleep 5;
	}; 

 // 'Randomly' towards the closest Player if within _investigateDistance

 while {((_zombieName distance _closestPlayer) <= _investigateDistance) && ((_zombieName distance _closestPlayer) > _chaseDistance)} do {
		_randomMove = floor (random 3);
		switch (_randomMove) do {
			case 0: {_zombieName playaction "C7A_longWalk";_zombieName domove (position _closestPlayer);};
			case 1: {_zombieName playaction "AmovPercMstpSnonWnonDnon_Scared2";};
			case 2: {_zombieName playaction "AmovPercMstpSnonWnonDnon_AinPercMstpSnonWnonDnon";};
			};
		hint "3";
		// Add random zombie sound
		sleep 2;
	};

// Run towards the closest Player if within _chaseDistance
while {((_zombieName distance _closestPlayer) <= _chaseDistance) && ((_zombieName distance _closestPlayer) > _attackDistance)} do {
		_randomMove = floor (random 3);
		switch (_randomMove) do {
			case 0: {_zombieName playaction "SprintCivilBaseDF";_zombieName domove (position _closestPlayer);};
			case 1: {_zombieName playaction "SprintCivilBaseDFl";_zombieName domove (position _closestPlayer);};
			case 2: {_zombieName playaction "SprintCivilBaseDFr";_zombieName domove (position _closestPlayer);};
			};
		hint "4";
		// Add random zombie sound
		sleep 1;
	};
// Attack player if within _attackDistance
while {((_zombieName distance _closestPlayer) <= _attackDistance)} do {
		_turnDir = [_zombieName,_closestPlayer] call BIS_fnc_dirTo;
		_zombieName setdir _turnDir;
		_zombieName playmove "AmovPercMstpSnonWnonDnon_AinvPercMstpSnonWnonDnon_Putdown";
		// Add attack sound(s)
		hint "5";
		sleep 0.5;
		_closestPlayer setdamage ((damage _closestPlayer) + _attackDamage);
		sleep 0.5;
	};
sleep 1;
}:

Share this post


Link to post
Share on other sites

Slow zombies are much cooler anyway.

Regarding 5.

You could probably use the ThrowGrenade gesture for that.

_this playActionNow "ThrowGrenade";

I think that is the most suitable default animation for an attack.

You could also experiment with some of the movement-gestures.

_this playActionNow "FastF";

This could be used to randomly let the zombie do a short sprint (even without a weapon).

https://community.bistudio.com/wiki/playAction/actions

Share this post


Link to post
Share on other sites

After a lot of experimentation, I ended up going with BlueBar's shaun zombie script. I've had to modify a lot of it to fit what I want, but the core of it is pretty good.

Share this post


Link to post
Share on other sites

Hi there, I'm new on this forum, and maybe the thread is a bit old but I just finished a "zombie" script, and based on the shaun Bluebär one (started it in march).

A zombie don't run so I call them "infecteds" ;) Anyway it work on solo/server/dedicated, no limit in players or infected count, mission makers just have to create markers to determine infected zone and put markers name in the init file, then the script create triggers, creating activating infected when players enter the zone, depopping everything when they leave. Infected can only target blufor inside the triggers.

I've made 2 missions with my old script (look for "dawn of the dead coop" in the workshop), but it was limited to 3 players due to my shitty targeting system, but it was the first script of my life ^^, so I'll post the new one as soon as find a way to create a thread in the correct one.

Share this post


Link to post
Share on other sites

Sounds good gulozwood. I think you need a certain amount of posts before you can start your own thread.

Share this post


Link to post
Share on other sites

I was messing around and managed to get a zombie script to work with EOS, so that it spawns and despawns the zombies when players are near or too far from them. The lack of zombie animations and their casual walking pace doesn't make it very compelling, plus they don't look scary or infected, but it's a start. Can be interesting at night without NVGs or foggy weather.

Might end up working on it more and release it as a template or something. Haven't messed with Gulozwood's zombie scripts yet.

Share this post


Link to post
Share on other sites

Hello there, I am not sure if you are intentionally recreating this, but here is a package that has exactly what you are looking for:

http://dynamiczombiesandbox.com/

It has loot, zombies, custom damage handling. It is based on the old Arma 2 zombie scripts, and the guy Craig who made DZS added a few very useful functions.

The only issue with DZS is the zombies don't patrol, they simply stand around until they spot a player (aggro distance can be configured). Once spotted, a message is broadcast to other zombies and before you know it you have quite the horde on your hands.

I use a very heavily modified version of DZS for my current project.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×