Welcome to Tactical Gamer

+ Reply to Thread
Page 4 of 16 FirstFirst 1234567891011121314 ... LastLast
Results 46 to 60 of 237
Discussion: ArmA - Development / ArmA - Mission Development - The Scripting How-To Thread - Originally Posted by Sc[ + ]pe Syntax is off slightly, but the logic works fine.
  1. #46

    Inkompetent's Avatar

    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    848

    Re: The Scripting How-To Thread

    Quote Originally Posted by Sc[ + ]pe View Post
    Syntax is off slightly, but the logic works fine. Thanks Vic!

    Almost last questions, I promise. I want to be able to end my game on a timer, or if both tasks 1 and 2 are completed, or if both tasks are failed. Am I right in thinking that setting a trigger to Countdown min:120, mid:120, max:120 would cause the trigger to activate in two hours under condition "this"? And would setting the "Type" to End #1, End #2, etc. end the mission? What about "Lose"?
    The countdown is in seconds, so you'd need to set it to 7200 for two hours. You could set that trigger to true in the condition field, and it'd start counting at once.

    Set it either as an END trigger, or put for example outOfTime = TRUE in the On Activation field and have that variable as a condition for some other trigger. You can only have one END#-trigger per end, but you can have an infinite amount of LOSE-triggers. So you could have the time-out trigger cause one mission failure, failing with the tasks causing another, and having the successful victory as your END#1 trigger.




  2.  
  3. #47


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    I was trying to figure out how to get units to spawn parachuting on launch of the game and my code doesn't seem to work. I finally got it to stop with the syntax errors, but now just nothing happens. It's supposed to iterate through the units in a leader's group, create a parachute for all of them and place them in the parachute as driver.

    Code:
    _osprey = this select 0;
    _leader = this select 1;
    _pos = objNull;
    {
        switch (_osprey)
        {
             case 0:
             {
                  _pos = Osprey0;
             };
        };
        if (_pos) then
        {
            para = createVehicle ["Parachute", _pos, [], 0, "FLY"];
            _x moveInDriver para;
        }else
        {
            exitWith {};
        };
    }foreach units _leader;
    The syntax may not be perfect since I'm not copying and pasting, I'm at work. And I shortened the case statements, there's more.

  4.  
  5. #48


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    Here's the code I have to spawn a para squad

    spawnParaSquad.sqf
    Code:
    if (isServer) then
    {
    	_soldierClasses = ["RU_Soldier_SL", "RU_Soldier_AA", "RU_Soldier_GL", "RU_Soldier_GL", "RU_Soldier_AR", "RU_Soldier_AR", "RU_Soldier_Medic", "RU_Soldier_Marksman", "RU_Soldier_AT", "RU_Soldier_AT", "RU_Soldier", "RU_Soldier"];
    	_ranks = ["PRIVATE", "CORPORAL", "SERGEANT"];
    	_spawnPoints = ["VehSpawn1"];
    	_attack = "Attack";
    	_spread = 400;
    	_maxSkill = .6;
    
    
    	_grp = createGroup east;
    	_wp = _grp addWaypoint [getMarkerPos "Attack", 0];
    	[_grp, 0] setWaypointType "SAD";
    	[_grp, 0] setWaypointCompletionRadius 400;
    	[_grp, 0] setWaypointTimeout [500, 500, 500];
    
    	_currentSpawn = _spawnPoints select 0;
    
    	for [{_x = 0},{_x < count _soldierClasses},{_x = _x + 1}] do 
    	{
    		_currentSpawnPos = [(getMarkerPos _currentSpawn select 0) + (random _spread) - (_spread / 2), (getMarkerPos _currentSpawn select 1) + (random _spread) - (_spread / 2), 100];
    		_type = _soldierClasses select _x;
    		_skill = random _maxSkill;
    		_rank = _ranks select (round (random 2));
    		if (_x == 0) then
    		{
    			_rank = "LIEUTENANT";
    		};
    		_type createUnit [_currentSpawnPos, _grp, "", _skill, _rank];
    	};
    
    	for [{_x = 0},{_x < count _soldierClasses},{_x = _x + 1}] do 
    	{
    		_currentSpawnPos = [(getMarkerPos "Attack" select 0) + (random _spread) - (_spread / 2), (getMarkerPos "Attack" select 1) + (random _spread) - (_spread / 2), 100];
    
    		_para = "ParachuteEast" createVehicle _currentSpawnPos;
    		_para setPos _currentSpawnPos;
    		(units _grp select _x) moveInDriver _para;
    	};
    	_grp allowFleeing 0;
    
    	_allUnits = units _grp;
    	waitUntil { {alive _x} count _allUnits == 0 };
    	sleep 60;
    	
    	{ deleteVehicle _x; } foreach _allUnits;
    
    	waitUntil { count units _grp == 0 };
    	deleteGroup _grp;		
    };
    ---Bellicosity---


  6.  

     
  7. #49


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    Quote Originally Posted by DLBlue View Post
    Here's the code I have to spawn a para squad

    spawnParaSquad.sqf
    [not quoted]
    With mine I was hoping I would be able to create the groups in the editor so all group generation and variation could be done there and then just have a script that ran across a group putting them in the air. But when I get back home I'll go through your script try it in my mission then see if I can change it to work how I originally wanted it. If it just can't work the way I want it, I guess I'll have to go with it that way.

  8.  
  9. #50

    Fincuan's Avatar

    Join Date
    Jan 2009
    Location
    Helsinki, Finland
    Posts
    772

    Re: The Scripting How-To Thread

    One thing that caught my eye, among other things, was this:
    Code:
    foreach units _leader
    That won't work unless _leader is a group, which it isn't judging by your post. forEach only works on an array of units, so we have to give it one:
    Code:
    forEach units group _leader

  10.  
  11. #51


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    Quote Originally Posted by Fincuan View Post
    One thing that caught my eye, among other things, was this:
    Code:
    foreach units _leader
    That won't work unless _leader is a group, which it isn't judging by your post. forEach only works on an array of units, so we have to give it one:
    Code:
    forEach units group _leader
    According to the comref "units" is overloaded to accept either a group or a unit. If it's a unit it gets all of the units in the same group as the one passed in. So it should be the same as units group _leader...

  12.  

     
  13. #52

    Fincuan's Avatar

    Join Date
    Jan 2009
    Location
    Helsinki, Finland
    Posts
    772

    Re: The Scripting How-To Thread

    Yeah you're right and I stand corrected. It really should accept a unit too as input according to the comref.

  14.  
  15. #53

    Blackdog1's Avatar

    Join Date
    Apr 2008
    Location
    London
    Posts
    2,370

    Re: The Scripting How-To Thread

    Stupic question time... What is a Civ respawn called?

    I thought it was Respawn_Civ but clearly it is not as my civ respawns at Respawn_East when he is a neutral...

    Is it Respawn_Civilian?
    BlackDog1




    "What we do in life... echoes in eternity!"

  16.  
  17. #54


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    Not exactly a scripting issue, but how do you make the AI drive better? More waypoints, less waypoints? I'm trying to put together a mission where it starts with the players being driven somewhere(want it to be out of their control) but the damn AI keeps running off the road and into trees and weaving and just making a whole mess of this vehicle column I'm trying to have...

  18.  

     
  19. #55


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    I've heard if you put only one vehicle in the convoy it drives better

    Not tested
    ---Bellicosity---


  20.  
  21. #56


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    They do seem to drive better when not grouped with other vehicles... They still suck, but that's probably just the bad pathfinding.

  22.  
  23. #57
    Vic
    Vic is offline


    Join Date
    Jun 2005
    Posts
    126

    Re: The Scripting How-To Thread

    The most dangerous thing on a battlefield is an officer with a map.

  24.  

     
  25. #58

    Blackdog1's Avatar

    Join Date
    Apr 2008
    Location
    London
    Posts
    2,370

    Re: The Scripting How-To Thread

    Yep ta Vic, found that yesterday.

    Cheers
    BD1
    BlackDog1




    "What we do in life... echoes in eternity!"

  26.  
  27. #59


    Join Date
    Jan 2006
    Location
    I jump between Maine and Trier, Germany
    Age
    26
    Posts
    2,134

    Re: The Scripting How-To Thread

    How do you make it so a vehicle burns for a set period of time instead of just setting the damage to 1 and letting it burn out?



  28.  
  29. #60

    Inkompetent's Avatar

    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    848

    Re: The Scripting How-To Thread

    Quote Originally Posted by viper1986 View Post
    How do you make it so a vehicle burns for a set period of time instead of just setting the damage to 1 and letting it burn out?
    Not sure if you can change that when a vehicle is already burning, but you could try to do a VehicleName setFuel 0 when you want it to stop. How long a vehicle burns is supposedly depending on how much fuel it had when it was destroyed. If some variant of this doesn't work I don't have a clue.




  30.  

     

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


  
 

Back to top