Jump to content
ArmaMan360

HVT spawning issues

Recommended Posts

Sounds simple but I am unable to get these 3 things together via scripting. I am not using spawning in editor as I am making random mission scenario.

 

1. I need an HVT

2. I need him to start patrolling in the marker "_marker 2" area

3. I need him to have a moving marker over him updating at 'x' seconds

 

So far I can successfully spawn him via createvehicle command but the createvehicleinit command doesnt do anything. He keeps standing there.

 

The best I have attained is to have him spawn and start patrol but I am unable to put the moving marker over him as I didnt spawn him with any underscore command like so "_spawn". Then I tried createunit, but it specifically says on the wiki that the createunit command should not have any 'string' or '=' before it:

"B_Officer_F createUnit [ _setpos, [], "[this, getPos this, 100] call bis_fnc_taskPatrol", 1, "COLONEL"] // The _setpos is the area marker of my mission

_marker2 = createMarker ["target", _spawn];
_marker2 setMarkerColor "ColorRed";
_marker2 setMarkerPos getMarkerPos _spawn;

But since I cannot define "_spawn" anywhere this is the issue.

 

 

I need to:

spawn hvt

he patrols

he has moving marker

 

Thats it :'(

Share this post


Link to post
Share on other sites

Have you tried the tip that was in the createUnit wiki? 

To give a newly created unit a name, put "newUnit = this" in the init field.

 

Then you should be able to use 

_marker2 = createMarker ["target", newUnit];
_marker2 setMarkerColor "ColorRed";
_marker2 setMarkerPos getMarkerPos newUnit;

Share this post


Link to post
Share on other sites

 

Have you tried the tip that was in the createUnit wiki? 

 

Then you should be able to use 

_marker2 = createMarker ["target", newUnit];
_marker2 setMarkerColor "ColorRed";
_marker2 setMarkerPos getMarkerPos newUnit;

 

I will check but from what I can understand due to my limited scripting knowledge, I do not know how to put 2 inits in the createunit call line. I mean one for naming him as per your suggestion, and the other for have him patrol the area as per taskpatrol function. I am in the office so cant try and check. :(

Share this post


Link to post
Share on other sites

I will check but from what I can understand due to my limited scripting knowledge, I do not know how to put 2 inits in the createunit call line. I mean one for naming him as per your suggestion, and the other for have him patrol the area as per taskpatrol function. I am in the office so cant try and check. :(

 

Yeah, you can probably also do what the guy above me suggested. If you wanna do it your way you should be able to put two peices of codes just like this:  

"B_Officer_F createUnit [ _setpos, [], "[this, getPos this, 100] call bis_fnc_taskPatrol; newUnit = this;", 1, "COLONEL"]

Share this post


Link to post
Share on other sites

Not yet. Ive given up hope and instead given the spawned unit "sit_low" animation..

This is really really annoying..

Share this post


Link to post
Share on other sites

 sigh...

 

Here you are. Creates a (walking) BLUFOR officer and a marker on top of him, that gets refreshed and also deleted when the HVT dies.

Adjust or remove the sleep in the waitUntil to change the refresh rate.

_setPos = ???;

_groupHVT = createGroup west;

_unitHVT = _groupHVT createUnit ["B_Officer_F", _setPos, [], 0, "NONE"];
_unitHVT setRank "COLONEL";
_unitHVT setSkill 1;

_groupHVT setBehaviour "SAFE";

[_groupHVT, getPos _unitHVT, 100] call BIS_fnc_taskPatrol;


[_unitHVT] spawn {
	_markerHVT = createMarker [str (_this select 0), getPos (_this select 0)];
	_markerHVT setMarkerShape "ICON";
	_markerHVT setMarkerType "hd_destroy";
	_markerHVT setMarkerColor "ColorBlufor";

	waitUntil {sleep 0.5; _markerHVT setMarkerPos getPos (_this select 0); !alive (_this select 0)};
	deleteMarker _markerHVT;
};

Share this post


Link to post
Share on other sites

Finallyyyyyy.. this is what I did if it can be of any help to anyone:

// Spawn enemy officer
_groupHVT = createGroup west;
_veh = _groupHVT createUnit ["B_officer_F", _sidepos, [], 0, "NONE"];
_veh setRank "COLONEL";
_veh setSkill 1;

_groupHVT setBehaviour "SAFE";

[_groupHVT, getPos _veh, 100] call BIS_fnc_taskPatrol;

[_veh] spawn {
	_markerHVT = createMarker [str (_this select 0), getPos (_this select 0)];
	_markerHVT setMarkerShape "ICON";
	_markerHVT setMarkerType "hd_destroy";
	_markerHVT setMarkerColor "ColorBlufor";

	["Task5",true,["A new NATO general has been appointed on the island. Find him
	and finish him forgood","Take out their new general", getMarkerPos "side_area"],
	getMarkerPos "side_area", "AUTOASSIGNED",6,true,true] call BIS_fnc_setTask;

	waitUntil {sleep 0.5; _markerHVT setMarkerPos getPos (_this select 0);
		!alive (_this select 0)};

["Task5","Succeeded"] call BIS_fnc_taskSetState;

	deleteMarker _markerHVT;
};

:D

 

Thank you guys..

Share this post


Link to post
Share on other sites

Cool that it works! Pretty nifty script

 

Did you change anything in KauppaPekka's code or what was the problem? 

Share this post


Link to post
Share on other sites

Cool that it works! Pretty nifty script

 

Did you change anything in KauppaPekka's code or what was the problem? 

 

No man still giving issues. It spawns everything well, but completes the task after 6-7 seconds. O.O what gives?

However the officer and the marker over him remains, just the tasks keeps assigning itself and completing itself automatically at the random locations i put in array. :(

 

Maybe that "this select 0" coming twice is the issue?

Share this post


Link to post
Share on other sites

Not sure why it doesn't work.

 

Try putting sleep 3; before the waitUntill. Maybe he didn't become alive before the check started since he is created in the same script without delay. Just a theory.

Share this post


Link to post
Share on other sites

Ok.

 

Firstly at least for me the script you put up works just fine when I put it in the init.sqf. It spawns the officer and the task, and also waits the officer to be killed before making it complete.

So you must have something else in your script or it's otherwise something I can't explain.

 

 

Now for an information overload.

 

• You have a faulty expression in your BIS_fnc_setTask. The first getMarkerPos "side_area" should  be replaced with a string for the marker name the task marker gets.

(Currently makes a difference only with the default task look, and not the new one being made. https://community.bistudio.com/wiki/Arma_3_Task_Enhancements )

 

• Instead of using BIS_fnc_setTask it's recomended to use BIS_fnc_taskCreate: https://community.bistudio.com/wiki/Arma_3_Task_Framework

 

• The task position can be attached to a object, so you instead of using the custom marker you could use the task marker. Of course the marker look is limited to the circle with arrow inside it with the default task look and you can't adjust the refresh rate.

Seems not to refresh the task position until my dude sees him / knows about the officer. Quite interesting.

 

• Instead of having the [_veh] spawn {} you can just replace all the (_this select 0) with the _veh and remove the [_veh] spawn {}.

I just made it like that so that the code I made won't interfere with anything you've possibly already made.

 

As the spawn creates a new "branch" from the script that does its thing independently so the waitUntil in it won't affect the rest of the script. So if you have code regarding the task in both the "branch" and the script where the "branch" was made you'll probably have some complications.

Share this post


Link to post
Share on other sites

Thanks Kauppapekka and Altsor. I have turned "Show script errors" on and whenever I change the first getmarkerpos command with "_marker" (as I use _marker before the above script to spawn a marker) or even with "_setpos" (which chooses from among an array of gamelogics for random placement) ,but it says something like  "no expression defined under _marker".

 

 

Anyway, I will try your suggestion today again and let you guys know. Thank you for being patient. ^^

Share this post


Link to post
Share on other sites

Well if you have the spawn still in place, you would need to feed the _marker into it first.

 

But I'd say it's just easier to do something like this:

["Task5",true,["A new NATO general...", "Take out...", "HVT Task"],getMarkerPos "side_area", "AUTOASSIGNED",6,true,true] call BIS_fnc_setTask;

And a picture how it looks.

7CE82CBE8A181A57E434728662713A421B562298

Share this post


Link to post
Share on other sites

Well if you have the spawn in still place, you would need to feed the _marker first into it.

 

But I'd say it's just easier to do something like this:

["Task5",true,["A new NATO general...", "Take out...", "HVT Task"],getMarkerPos "side_area", "AUTOASSIGNED",6,true,true] call BIS_fnc_setTask;

And a picture how it looks.

7CE82CBE8A181A57E434728662713A421B562298

Wow thank you for taking the trouble to test it. Will share results asap. :)

 

EDITED:

You Sir are a legend. It works now. Thanks @kauppapekka and others who helped :)

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

×