Jump to content
black_hawk_mw2_87

Complete Task When A Specific Kills Are Numbered

Recommended Posts

Hello, community!

I am testing a VR scenario with VR AI - 0_Soldier_VR_F, called tgt0. The hits on him are counted by a script which also checks his condition, depending on where the AI's being shot. But what I want to know is how to complete a task, when a specific number of kills of the same class spawning VR soldier is counted. For example, when I kill the VR AI x times, the task will be completed. What can I do about this? Thank you in advance! 🙂

Share this post


Link to post
Share on other sites

@black_hawk_mw2_87,

Are you already counting kills?
 

while {true} do {if (killcount==_x) then {"task_1" call BIS_fnc_taskCompleted;};sleep 0.5;};

Like that?

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, wogz187 said:

@black_hawk_mw2_87,

Are you already counting kills?
 


while {true} do {if (killcount==_x) then {"task_1" call BIS_fnc_taskCompleted;};sleep 0.5;};

Like that?

Yes, exactly, but do I need to create "task 1" using the BIS functions or just a normal Create Task module? And if it's the second way, with a normal task, should I name the module somehow in order to complete this task exactly - the one that is mentioned in the code above? 🙂

Share this post


Link to post
Share on other sites

@black_hawk_mw2_87
 

Quote

Yes, exactly, but do I need to create "task 1" using the BIS functions or just a normal Create Task module?

Good question. Let's see.

  • Like 1

Share this post


Link to post
Share on other sites
4 minutes ago, GEORGE FLOROS GR said:

Hello, my friend! 🙂 Could you, please, be more specific? 😄

Share this post


Link to post
Share on other sites

A Task ID is a Task ID no matter if it comes from a module or a script.

I had trouble with setTaskState and taskComplete but,

while {true} do {if(killcount==1) then {

[ "task1" ] call BIS_fnc_deleteTask;

};sleep 0.5;};

works as expected.

There we go,

while {true} do {if(killcount==1) then {

["task1","SUCCEEDED"] call BIS_fnc_taskSetState;

};sleep 0.5;};

Have fun!

  • Like 2

Share this post


Link to post
Share on other sites
32 minutes ago, wogz187 said:

A Task ID is a Task ID no matter if it comes from a module or a script.

I had trouble with setTaskState and taskComplete but,


while {true} do {if(killcount==1) then {

[ "task1" ] call BIS_fnc_deleteTask;

};sleep 0.5;};

works as expected.

OK, but it somehow didn't work for me.

1. I create a task using a module, its taskID is called "task1";

2. I activate it when the player reaches an object with "player distance sign0 <X"

3. I connect the trigger to the task, the task to the player, and the task to a "Set Task State (Succeeded), and the last one to another trigger, which, normally, should be used as a condition.

4. In this last trigger I use your code above, but I've got an error: Type nothing expected, Bool.

Where am I wrong? 😄

Share this post


Link to post
Share on other sites

@black_hawk_mw2_87,
This must be running before the killcount is reached. So like at the end of your init, or on act a trigger at some point in the mission,
 

while {true} do {if(killcount==1) then { ["task1","SUCCEEDED"] call BIS_fnc_taskSetState; };sleep 0.5;};


While that is running, when KillCount reaches the desired number, say 3 (killcount==3), it will succeed "task1".

I'll upload an example if you want.

 

 

  • Like 2

Share this post


Link to post
Share on other sites
Just now, wogz187 said:

@black_hawk_mw2_87,
This must be running before the killcount is reached. So like at the end of your init, or on act a trigger at some point in the mission,
 


while {true} do {if(killcount==1) then { ["task1","SUCCEEDED"] call BIS_fnc_taskSetState; };sleep 0.5;};


While that is running, when KillCount reaches the desired number, say 3 (killcount==3), it will succeed "task1".

I'll upload an example if you want.

 

 

I will be very thankful as it won't work for me. I tried with just 1, but no matter how many VR soldiers are killed (it's actually one and the same, respawning), this won't do the trick. Does it have anything to do with the fact this is just a VR soldier, not a real AI opponent?

Share this post


Link to post
Share on other sites
1 hour ago, black_hawk_mw2_87 said:

be more specific? 😄

 

waituntil{time>1};

[player,["task1","Mission"],["task1. Decription :","task1",""], getpos player,true,1,true,"kill",true] call BIS_fnc_taskCreate;
["task1","ASSIGNED",true] spawn BIS_fnc_taskSetState;

GF_Kills = 0;

addMissionEventHandler ["EntityKilled",
{
	params ["_killed", "_killer", "_instigator"];
	if(isNull _instigator)then{_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if(isNull _instigator)then{_instigator = _killer}; // player driven vehicle road kill
	
	if((typeOf _killed isequalto "C_man_polo_1_F") && !(GF_Kills isequalto 3))then{
		
		systemchat "C_man_polo_1_F";
		
		GF_Kills = GF_Kills + 1;
			if(GF_Kills isequalto 3)then{

			systemchat "SUCCEEDED";
			
			["task1","SUCCEEDED",true] spawn BIS_fnc_taskSetState;
			["task1"] call BIS_fnc_deleteTask;
			};
		};
	
}];

 

  • Like 2

Share this post


Link to post
Share on other sites
7 minutes ago, GEORGE FLOROS GR said:

 


waituntil{time>1};

[player,["task1","Mission"],["task1. Decription :","task1",""], getpos player,true,1,true,"kill",true] call BIS_fnc_taskCreate;
["task1","ASSIGNED",true] spawn BIS_fnc_taskSetState;

GF_Kills = 0;

addMissionEventHandler ["EntityKilled",
{
	params ["_killed", "_killer", "_instigator"];
	if(isNull _instigator)then{_instigator = UAVControl vehicle _killer select 0}; // UAV/UGV player operated road kill
	if(isNull _instigator)then{_instigator = _killer}; // player driven vehicle road kill
	
	
	if(typeOf _killed isequalto "C_man_polo_1_F")then{
		
		systemchat "C_man_polo_1_F";
		
		GF_Kills = GF_Kills + 1;
			if(GF_Kills isequalto 3)then{
			
			systemchat "SUCCEEDED";
			
			["task1","SUCCEEDED",true] spawn BIS_fnc_taskSetState;
			["task1"] call BIS_fnc_deleteTask;

			};
		};
	
}];

 

Thank you, but where exactly should I put all this? May be inside a trigger with a "true" condition to activate it?

Which means I should simply remove my current existing task 1? 🙂

Edited by black_hawk_mw2_87

Share this post


Link to post
Share on other sites
5 minutes ago, black_hawk_mw2_87 said:

Thank you, but where exactly should I put all this?

 

you can use the init or the initserver.

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, black_hawk_mw2_87 said:

[player,["task1","Mission"],["task1. Decription :","task1",""], getpos player,true,1,true,"kill",true] call BIS_fnc_taskCreate; ["task1","ASSIGNED",true] spawn BIS_fnc_taskSetState;

 

this is just a working example.

You need to edit this to your needs.

Share this post


Link to post
Share on other sites
1 minute ago, GEORGE FLOROS GR said:

 

this is just a working example.

You need to edit this to your needs.

Thank you, but when I tried to paste the entire code of yours inside the init.sqf file a message showed up telling me I would loose my scripting of the file... LOL...

Share this post


Link to post
Share on other sites

@black_hawk_mw2_87,

Quote

"...when I kill the VR AI x times..."


Are you counting x somewhere? Because Killcount=x in my example.

In George's function he's counting kills,

GF_Kills = GF_Kills + 1;

 

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, black_hawk_mw2_87 said:

I kill the VR AI

 

Did you add the certain classname in the script ?

 

I also update this just a little.

  • Like 2

Share this post


Link to post
Share on other sites
18 minutes ago, wogz187 said:

@black_hawk_mw2_87,


Are you counting x somewhere? Because Killcount=x in my example.

In George's function he's counting kills,


GF_Kills = GF_Kills + 1;

 

I changed X to 1, just to see if it would work this way, but it didn't.

 

18 minutes ago, GEORGE FLOROS GR said:

 

Did you add the certain classname in the script ?

 

I also update this just a little.

I forgot to add it. So, instead of "C_man_polo_1_F" I should use the class name of the VR AI? And another question: you have used "GF_Kills" in the script. Do I have to rename this using my AI's variable name? This way it would count how many times the AI with that name is killed, may be, when it keeps spawning? Lol, dudes, please, explain it to me. 🙂 I am about to lose consciousness until tomorrow morning, if I don't make this work. 😄

Share this post


Link to post
Share on other sites

Okay, so just to clarify

My suggestion relied on you already having counted kills somewhere. That way, when killcount was equal to the number of kills you want to count, the task would complete.

George's solution ties it all together into one function. Go with that if you don't already have a killcount.

  • Like 2

Share this post


Link to post
Share on other sites
5 minutes ago, wogz187 said:

Okay, so just to clarify

My suggestion relied on you already having counted kills somewhere. That way, when killcount was equal to the number of kills you want to count, the task would complete.

George's solution ties it all together into one function. Go with that if you don't already have a killcount.

Thanks for your reply and support. 🙂 And for the patience, of course. I guess I am too tired by now, so may be that's why I have done something wrong. But tomorrow I will try both ways cause you both deserve it. 🙂 And if I manage to make it work, I will put my detailed feedback as a response, so this would be helpful to the community. 🙂

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
7 minutes ago, GEORGE FLOROS GR said:

 

This is just a global variable and when you are using them , it needs to be a unique word.

This is why i use GF_ in front.

https://community.bistudio.com/wiki/Variables

 

So, as far as I understand, all I need to replace, is the class name of the soldier? 🙂 I guess I am already right. 😄

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites
2 minutes ago, black_hawk_mw2_87 said:

Thanks for your reply and support. 🙂

 

Yes!

( we are in a good way ! scripting makes perfect :wave:)

Spoiler

 

 

  • Like 1
  • Haha 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

×