Jump to content
Sign in to follow this  
hogmason

calling a game logic when a task has started

Recommended Posts

Hi all i am designing a mission that has random side missions using the shk_taskmaster script.

i have got the side missions randomly starting but now am stuck spawning the enemy.

i am using cB_TaskDefend wich is started by using a game logic. i need to know how i can call the game logic when the random task starts.

so if task5 is started how do start the game logic containing the units for task5.

how i have set up the side missions " all side missions are set the same just different names.

1 marker with a name for mission location.

1 trigger

text

Task/objective 1

condition

!alive dude1

on act

["Task1","succeeded"] call SHK_Taskmaster_upd; call SHK_addTask

in my init i have

call compile preprocessfile "shk_taskmaster.sqf";

//taskCount = paramsarray select 0;
taskCount = 6;

SHK_addTask = {
 if isserver then {
   if (count SHK_Tasks == 0) then {
     // whatever you want server to do when mission should end
     TheEnd = true;
     publicvariable "TheEnd";
   } else {
     [] spawn {
       if (count SHK_Tasks != taskCount) then {sleep 1};
       private "_t";
       _t = SHK_Tasks select (floor random count SHK_Tasks);
       SHK_Tasks = SHK_Tasks - [_t];
       switch _t do {
         case 0: { ["Task1","Task1Title","Task1Desc"] call SHK_Taskmaster_add };
         case 1: { ["Task2","Task2Title","Task2Desc"] call SHK_Taskmaster_add };
         case 2: { ["Task3","Task3Title","Task3Desc"] call SHK_Taskmaster_add };
         case 3: { ["Task4","Task4Title","Task4Desc"] call SHK_Taskmaster_add };
         case 4: { ["Task5","Task5Title","Task5Desc"] call SHK_Taskmaster_add };
         case 5: { ["Task6","Task6Title","Task6Desc"] call SHK_Taskmaster_add };
       };
     };
   };
 };
};
if isserver then {
 SHK_Tasks = [];
 for "_i" from 0 to (taskCount - 1) do {
   SHK_Tasks set [_i,_i];
 };

 call SHK_addTask; // first task
};

waituntil {BIS_fnc_init};

the game logic i need to attach contains in the init

0 = [position this, "Infantry", "INS"] execVM "crb_scripts\crB_taskDefend.sqf";

Share this post


Link to post
Share on other sites

Do you have to use a gamelogic for that?

If so, and no logic is on the map yet, start from here:

_lgccenter = createCenter sideLogic;
_lgcgroup = createGroup _lgccenter;
crb_gamelogic1 = _lgcgroup createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"];
crb_gamelogic1 setVehicleInit "0 = [position this, "Infantry", "INS"] execVM 'crb_scripts\crB_taskDefend.sqf'";
processInitCommands;

createUnit_array

crb_gamelogic1 - I left that global because you might want to do something with it from another script, if not, put a _ infront of it.

edit: if you need that on a certain position you need to change the [0,0,0] position array to the position you want or add, for example:

_pos = getMarkerPos "MarkerName";
crb_gamelogic1 = _lgcgroup createUnit ["LOGIC", _pos, [], 0, "NONE"];

Edited by PELHAM

Share this post


Link to post
Share on other sites

Thanks pelham but as i am a noob at the scripting side of things can i be a pest and just ask where do i place this so it will only create itself once the corrosponding task starts.

i.e if i need it to create the gamelogic when task6 starts and only when task6 is running and on task6 location

Share this post


Link to post
Share on other sites

Make life easy for yourself - you don't need a gameLogic, it's just an example of how to start it. You just need to put something in that first parameter that returns a position, examples:

_handle = [getMarkerPos "markerName", "Infantry", "INS"] execVM "crb_scripts\crB_taskDefend.sqf";

_handle = [getPos unitName, "Infantry", "INS"] execVM "crb_scripts\crB_taskDefend.sqf";

_handle = [position objectOrVehicleName, "Infantry", "INS"] execVM "crb_scripts\crB_taskDefend.sqf";

_handle = [getWPPos [groupName,1], "Infantry", "INS"] execVM "crb_scripts\crB_taskDefend.sqf";

Put a marker where you want this to happen and name it - use the getMarkerPos option.

Where to put it? It depends how Task 6 is assigned? If it's a script put it in the script - if it's a trigger (you example above) put it in the trigger On Act.

Edited by PELHAM

Share this post


Link to post
Share on other sites

cheers mate trying this now ill post how i go :)

---------- Post added at 13:26 ---------- Previous post was at 13:17 ----------

hhhmmmm i dont know its still not working.

i have attached the mission file its pretty small would you mind just taking a quick look when you get a chance only if you wish to mate i dont want to be a pest

http://ds5758.hostname.net.au/downloads/=HARDCORE=%20Downloads/ARMADownloads/Operation%20HOG%20Downloads/my%20demo.rar

you can email it back to me on nathanandsusan@live.com.au

---------- Post added at 13:36 ---------- Previous post was at 13:26 ----------

better explain what is on the map

you will see 6 men with a trigger and a marker around them the men are the objective when they die the task ends its just a demo

the marker is where the side mission is at and the trigger calls taskmaster to update the task to finished then task master will randomly pick out of the remaining tasks to get another one from the mission init file.

im trying to achieve the crb_scripts\crB_taskDefend.sqf"; to spawn men around the task marker to defend the area.

Share this post


Link to post
Share on other sites

Not really got time to pick through missions but tried to put Taskdefend folders into the Taskmaster example mission. Problems:

1) There is no funtions module on the map?

2) There are no side centres created so the AI will not spawn?

If you put a functions module on the map Taskdefend only spawns the vehicles, no AI.

To solve 2 and get AI, you need to put 4 AI on the map in a corner, 1 from each side, probability of presence 0% (set in editor on AI options), that creates centres and the AI will spawn.

Sides: Blufor, Opfor, Independent,Civilian.

If you look at other maps you will often see a cluster of 4 AI somewhere, blue, red, green and yellow markers, thats what they are for.

Works for me. ;)

edit: some useful info for the 3rd perameter so you can spawn every type of faction:

http://community.bistudio.com/wiki/faction

http://community.bistudio.com/wiki/Side

nother edit, example I just thought of for multiple markers:

{[getMarkerPos _x, "motorized", WEST] execVM "crb_scripts\crB_taskDefend.sqf";} forEach ["mkr1","mkr2","mkr3","mkr4","mkr5"];

You must make sure that the faction you call has the entry under CfgGroups - http://community.bistudio.com/wiki/CfgGroups

eg this will not work:

_handle = [getMarkerPos "mkr1", "motorized", "BIS_GER"] execVM "crb_scripts\crB_taskDefend.sqf";

"BIS_GER" has no entry under "motorized" it will only work with "infantry".

***It does not like the BIS_BAF faction (should be BIS_BAF_MTP) - Not sure why, in theory adding _MTP should work. BIS_PMC seems to be fine as it has the usual group types. http://forums.bistudio.com/showthread.php?119184-BAF-cfgGroups-not-working-with-BIS_fnc_spawnGroup-SOLVED&p=1932338#post1932338

Edited by PELHAM

Share this post


Link to post
Share on other sites

[/color]I GOT IT thank you so much for your help mate and for putting up with my noobness ;)

i place this in a trigger around the side mission site

{[getMarkerPos _x, "Armored", INS] execVM "crb_scripts\crB_taskDefend.sqf";} forEach ["mrkTaskMM1"];;

now i have this trigger placed at all the task sites so when the mrkTaskMM1 marker is created at the task site it spawns the enemy BUT

it works for the first task but when another taks starts the trigger doesnt seem to activate becous i get no enemy at the task site.

would you know why.

---------- Post added at 02:22 ---------- Previous post was at 01:14 ----------

i should mention the trigger has an area to cover the spot the mrkTaskMM1 marker is spawned. and is set to activate by anybody

Edited by hogmason

Share this post


Link to post
Share on other sites

{[getMarkerPos _x, "Armored", INS] execVM "crb_scriptscrB_taskDefend.sqf";} forEach ["mrkTaskMM1"];;

Doing that is pointless for 1 marker, you are better off using the 1st example I gave you, foreach is for multiple elements in an array (it will still work though lol). You have an extra ; at the end there? If you want a trigger to work more than once set it to repeatedly. Why set it to anyone? It will react to all and I can't see how a task is set or achieved that way. Have you read any editing or scripting guides? Might be a wise thing to do before you prceed further? You might need a condition to set of the trigger under a set of specific circumstances. Search "trigger condition" and you will get some examples. Have a look at other maps, find eliteness and DePbo them to learn how it's done.

Keep going though - you have the right idea! Have a look at this site for lots of good examples: http://www.kylania.com/ex/

Edited by PELHAM

Share this post


Link to post
Share on other sites

cheers mate ill take your advice and do some research thanks heaps for your time mate i really appreciate it. :)

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  

×