infiltrator_2k 29 Posted December 30, 2013 I'm trying to find out a way of triggering a spawn script when a specified number of units have been killed. I found this code and it works when I set the "==" variable to whatever number I want to activate the trigger, but the code seems to include both the condition and activation. Is this because of the "if" and "then"? If so how do I edit the code to utilise both the condition and initialisation? Also is there a way of using percentages as well as numbers for counting the amount of units alive? if ( ({(side _x) == east} count allUnits) == 0 ) then { hint "no east units is alive"; }; Share this post Link to post Share on other sites
akm74 1 Posted December 31, 2013 i'm using this script for testing. (i'm not a scripter but it work for me just fine). Start it with any trigger. --------------------------------------------- while {alive player} do { _count = {side _x == blufor} count allUnits; _count2 = {side _x == independent} count allUnits; _count3 = {alive _x} count (units aP); // hint format ["Blue is %1 \nGreen is %2 \nAp is %3", _count, _count2, _count3]; // sleep 5; }; ------------------------------------------- Share this post Link to post Share on other sites
iceman77 18 Posted December 31, 2013 Not sure what you're getting at, but if you want to use it as a condition within a trigger use: Condition: {alive _x && (side _x) == east} count allUnits == 0 OnAct: hint "no east units is alive"; Share this post Link to post Share on other sites
infiltrator_2k 29 Posted December 31, 2013 I'm trying to find out a way of triggering a spawn script when a specified number of units have been killed. I found this code and it works when I set the "==" variable to whatever number I want to activate the trigger, but the code seems to include both the condition and activation. Is this because of the "if" and "then"? If so how do I edit the code to utilise both the condition and initialisation? Also is there a way of using percentages as well as numbers for counting the amount of units alive? if ( ({(side _x) == east} count allUnits) == 0 ) then { hint "no east units is alive"; }; So frustrated, I've spent a couple of hours trying to figure this out. Is "if" equivalent to the condition that would usually be added to a script rather than the trigger condition and "then" the equivalent to the trigger's initialization? I need some help here guys. I could just add a simple trigger in a completed task that's free from a trigger's enemy, but then I wouldn't be learning anything :/ In my trigger's init field a simple nul = execVM 'myscript.sqf'; that trigger's my script, it's just the condition I need to set. Share this post Link to post Share on other sites
iceman77 18 Posted December 31, 2013 Is "if" equivalent to the condition that would usually be added to a script rather than the trigger condition and "then" the equivalent to the trigger's initialization? Yeah. What I've posted above should be a clear example of that. ---------- Post added at 08:01 ---------- Previous post was at 07:59 ---------- So ... if ({alive _x && (side _x) == east} count allUnits == 0) then { hint "no east units is alive"; }; Is essentially the same as: Trigger Condition: {alive _x && (side _x) == east} count allUnits == 0 Trigger OnAct: hint "no east units is alive"; Share this post Link to post Share on other sites
infiltrator_2k 29 Posted December 31, 2013 Not sure what you're getting at, but if you want to use it as a condition within a trigger use:Condition: {alive _x && (side _x) == east} count allUnits == 0 OnAct: hint "no east units is alive"; Thank you Iceman, it works a treat. Now I can spawn reinforcements when a desired number of enemy AI have been killed, oppose to when certain trigger areas have been cleared of AI. I know I need to focus more time in scripting, it's just with my job and family time is limited. Saying that I know I have to read Mr. Murray's guide as you've already recommended. ---------- Post added at 18:28 ---------- Previous post was at 17:26 ---------- Yeah. What I've posted above should be a clear example of that.---------- Post added at 08:01 ---------- Previous post was at 07:59 ---------- So ... if ({alive _x && (side _x) == east} count allUnits == 0) then { hint "no east units is alive"; }; Is essentially the same as: Trigger Condition: {alive _x && (side _x) == east} count allUnits == 0 Trigger OnAct: hint "no east units is alive"; I took that long to post my 2nd post I had 2 replies (one from yourself) whilst composing it LoL... Cheers chap ;) Share this post Link to post Share on other sites
iceman77 18 Posted December 31, 2013 Anytime man. We're all here to learn. Well, the majority in any case. Some know it all! Cheers. Share this post Link to post Share on other sites
hansson0728 12 Posted January 1, 2014 (edited) I had a similar problem, but i figured it out look at this: http://forums.bistudio.com/showthread.php?170855-thislist-trigger-and-foreach-loop-just-wont-work-wierd count all units in trigger aera, perfom action (on every unit or with a littile modification once every unit is dead) -- never mind i read the post wrong sorry Edited January 1, 2014 by Hansson0728 Share this post Link to post Share on other sites
mikie boy 18 Posted January 1, 2014 if you are carrying out a reinforcement script and learning the basics - good to keep an eye on groups numbers. Maximum group count i think is 250 (someone may correct me). Therefore its handy to see how many groups are in existence and how to remove said groups to ensure you have room to create more. Also its a means of learning efficient scripting. while {true} do { { if ((count (units _x)) == 0) then { if (side _x == EAST) then {deleteGroup _x; _x = grpNull; _x = nil}; }; } foreach allGroups; sleep 60; }; just something to consider Share this post Link to post Share on other sites
infiltrator_2k 29 Posted January 4, 2014 if you are carrying out a reinforcement script and learning the basics - good to keep an eye on groups numbers. Maximum group count i think is 250 (someone may correct me). Therefore its handy to see how many groups are in existence and how to remove said groups to ensure you have room to create more. Also its a means of learning efficient scripting. while {true} do { { if ((count (units _x)) == 0) then { if (side _x == EAST) then {deleteGroup _x; _x = grpNull; _x = nil}; }; } foreach allGroups; sleep 60; }; just something to consider Cheers Mikie boy. I thought I'd let the players remove the AI to trigger the reinforcements script. I understand the logic of it all, it's just the SQF language that is the steep learning curve. I'm looking at the code above and trying to get my head around it :/ Share this post Link to post Share on other sites