Jump to content
  • 0

Anyone decent with the setVariable / GetVariable command?


McKeighan

Question

Interesting question, right?

 

Anyway, I've been trying to add an additional parameter to zombies, called "isRunner".  I've modified the bottom of the zombie_generate.sqf file to include this line.  (this will replace the global "DZE_slowZombies" logic).

_rnd = random(1);
if (_rnd > .985) then {
			_isrunner = 1;
		} else {
			_isrunner = 0;
		};
_agent setVariable ["isRunner", _isrunner];

The idea is to be able to pass the agent into the zombie_agent.fsm file with the potential to be a runner, where all other zombies would be walkers. 

The issue i'm having is that in the FSM file, in the INIT box, I can't get my getVariable call to actually grab the agent's "isRunner" variable.  This is how I'm attempting to do it.

 

_isrunner = _agent getVariable["isRunner",false];

if (_isrunner = true) then {diag_log "A Zombie is a Runner";};


For the most part, from what I can see, it's not pulling the variable correctly because the RPT file keeps erroring. Fortunately, it's defaulting to "false", so none of them are running. 

The RPT error is also saying something around my diag_log missing a ")", but I can't figure out exactly why it's not working either.  

 

(I'm a bit tired and been messing with this most of the day).

 

Anyway - any incites would be greatly appreciated.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
13 minutes ago, McKeighan said:

if (_isrunner = true) then {diag_log "A Zombie is a Runner";};

You also do not need to have:

if (_isrunner = true) then {

This is accomplished by simply doing:

 if (_isrunner) then {

 

It would be the same as saying:

 if (true == true) then {

 

Also, when determining whether something is equal to something, two "=" signs are used.

 

Example:

if (1 == 1) then {systemChat "Correct syntax";};

 

You are getting the missing ) because of the above mistakes.

Link to comment
Share on other sites

  • 0
14 minutes ago, McKeighan said:

_rnd = random(1); if (_rnd > .985) then { _isrunner = 1; } else { _isrunner = 0; }; _agent setVariable ["isRunner", _isrunner];

Here, you are setting _isrunner to a number. You are getting the variable in a true/false manner though, which means you want to set it as true.

 

I have corrected your code below:

_rnd = random 1;
_isrunner = if (_rnd > .985) then {true} else {false};
_agent setVariable["isRunner", _isrunner, true];

_isrunner = _agent getVariable["isRunner", false];
if (_isrunner) then {diag_log "A Zombie is a Runner";};

 

Link to comment
Share on other sites

  • 0

you should know that the DZE_SlowZombie behavior has been replaced in 1.0.6.2, yet to be release, with a min/max speed selection. this enable a mixture of both walkers and runner zombies.

https://github.com/EpochModTeam/DayZ-Epoch/blob/master/CHANGE LOG 1.0.6.2.txt#L27 

 

Edit: expanding a bit on your post.

 

You won't be able to access local variables in any script outside of those you define the variable in. however, you don't really even need an additional variable to tell if the zombie is a runner, you can just get the speed.

_speedLimit = _zombie getVariable ["speedLimit", 2]; //2 is speed of slow zombies
if (_speedLimit > 2) then {
	//your code or if you would like to add another variable, then, _isRunner = true;
};

Additional note: I wouldn't network any variables related to zombie spawning, considering the amount which can spawn over the course of a restart period you may cause a lot of overhead. especially related to speed since only the client which owns/spawned the zombie can use speed-related commands, i.e. forceSpeed on the unit.

using the method I posted above you will be able to detect/limit the amount of runners PER CLIENT IF OWNED BY SAID CLIENT, and per your other criteria

Link to comment
Share on other sites

  • 0

Icomrade - the idea was that once the zombie is "born", it should remain either a walker always or a runner, always.  When I first started messing with this years ago (Before I moved on to other games / platforms), I had everything in the FSM file... What was interesting was that each agent was a walker AND a runner, depending on random chance, every time they spotted somebody (Because I was setting their runspeed in the target found area based on a random roll. 

Seems I didn't fully re-think it, as I could have gotten around all this by not passing this variable from the zombie agent at all, and just defining the runner in the Init stage, then testing for that flag being set in the subsequent stages. (All FSM work, no adjustment needed to zombie files.)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...