Jump to content
Rosso777

Randomized Damage / onHit

Recommended Posts

17 minutes ago, wogz187 said:

@Rosso777,


[this, 3] spawn { sleep (_this select 1); systemChat format ["%1 waited %2 seconds", _this select 0, _this select 1];};

In the above example we are selecting from the array at the beginning of "spawn". So select 0 is "this"-- the unit and select 1 is the number (arrays start at 0).

Have fun!

 

I am going to translate to ensure I understand: By that code example, THIS (an AI, for example) is stopped for 3 seconds. A message then appears in systemChat that reads: "THIS waited 3 seconds"   So the {sleep is placing a hold on the unit (identified by the _this).

_this select 0 is referring back to the THIS in the initial bracket set.

_this select 1 is referring back to the 3, which is a variable that WE chose to set. 

 

If we were to establish another parameter (wait... is that initial bracket [this, 3] the params? Am I actually understanding?) and add Joe to it, it might go something like this:

 

[Mark, 13, Joe] spawn { sleep (_this select 1); sideChat format ["%3 is watching %1 do nothing for %2 seconds!", _this select 2, _this select 0, _this select 1];};

Goal:               Sidechat: "Joe is watching Mark do nothing for 13 seconds!"

  • Like 1

Share this post


Link to post
Share on other sites

@Rosso777,

Yes!

Except the sleep doesn't "hold" anything the system will just delay the message by that amount of time.

Make your "Joe watch Mark" script into a usable script and we'll test it.

Have fun!

  • Like 2

Share this post


Link to post
Share on other sites

Well, kind of... Your understanding of passing the arguments is correct. The only thing to note here is that sleep does NOT stop a unit, it just delays the "running" script by (roughly) that amount of time (in seconds).

 

EDIT: Hehe, wogz187 was a bit faster than me :D. Sorry for posting two times the same thing.

Edited by ZaellixA
  • Haha 1

Share this post


Link to post
Share on other sites

If misunderstanding the sleep command is the only real error there (so far), than I am one happy camper! Thanks guys! I am going to test this tonight when I get home.

 

Additional learning: So when building something like these spawns, you can essentially configure them how you want as long as you refer back to the _select correctly? Aside from simplicities like units or values, what other types of parameters can go in there?

 

EDIT: Okay, I am now realizing that this has turned into a private lesson thread. And, as much as I am absolutely loving this process, I am sure you guys are exhausted with such tasks. I appreciate all the help, fellas. I will do my best to keep researching things on my own instead of sending constant feedback loops.

Share this post


Link to post
Share on other sites

@Rosso777,

Quote

Aside from simplicities like units or values, what other types of parameters can go in there?

You can send any variable as a param. Common param variables are,
Boolean: Define the var as true or false
Array: Define an array for the functions to use
String: either common language (user defined) or system strings like behavior state ex. "AWARE", "SAFE"

you_fnc_sayThis=
{	params [["_caller", player], ["_doChat", false], ["_chatString", "HELLO!"]];
private _grp = group _caller;
if (_doChat) exitWith {
						{
							systemChat format ["%1", _chatString];
						} forEach units _grp;
			};
};

[player, true, "Say this instead of HELLO"] call you_fnc_sayThis;
Quote

EDIT: Okay, I am now realizing that this has turned into a private lesson thread. And, as much as I am absolutely loving this process, I am sure you guys are exhausted with such tasks. I appreciate all the help, fellas. I will do my best to keep researching things on my own instead of sending constant feedback loops.

It's all good, man. We're just loading you up with some tools to make the long process ahead a little more bearable.

 

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

Although wogz187 is right when saying that it's all right, it would probably be a good idea to move this "private lesson" to pm, or some other platform where we could possibly be able to provide more info and/or collaborate on some examples.

 

Not saying that I don't like what is going on here, but it has indeed gone "out of scope" of the question and since this is a forum maybe it is a good idea to move the "conversation" somewhere else.

 

Feel free to pm anyone of us, or post another topic here. Glad to be of help :)

  • Like 1

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

×