Welcome to Tactical Gamer

+ Reply to Thread
Page 3 of 16 FirstFirst 12345678910111213 ... LastLast
Results 31 to 45 of 237
Discussion: ArmA - Development / ArmA - Mission Development - The Scripting How-To Thread - Originally Posted by Gillespie This crap is a headache to learn. I have lots of
  1. #31

    AdeptAbyss's Avatar

    Join Date
    Jul 2007
    Location
    Belfast, Northern Ireland, United Kingdom
    Posts
    1,620
    Blog Entries
    2

    Re: The Scripting How-To Thread

    Quote Originally Posted by Gillespie View Post
    This crap is a headache to learn. I have lots of neat mission ideas, but to hell with learning some hieroglyphics to make it happen.

    Lol agree with ya there :P

    My name: Adept a skilled or proficient person Abyss a deep, immeasurable space, gulf, or cavity
    So I'm a very skilled deep hole :D

  2.  
  3. #32

    Sc[ + ]pe's Avatar

    Join Date
    Aug 2007
    Location
    Vancouver, Canada
    Posts
    847

    Re: The Scripting How-To Thread

    Yeah man, not like it has any real world applications.

    By the way, did I ever mention that programmers have one of the best rates of employment in the country?


    BACK ON TOPIC: I want to force view distance for players based on what vehicle they're in (and what position they're occupying). I'm aware of
    Code:
    setViewDistance _x;
    in a true trigger, but can I rig this to specific players in specific vehicles? Ideally, I'd like grunts to have viewDistance A, and pilots to have viewDistance B.

    PS: What would accepted distances be? Does anyone actually play ArmA under 2km? And would most pilots be able to handle 5?

  4.  
  5. #33

    Blackdog1's Avatar

    Join Date
    Apr 2008
    Location
    London
    Posts
    2,370

    Re: The Scripting How-To Thread

    Quote Originally Posted by Sc[ + ]pe View Post
    Yeah man, not like it has any real world applications.

    By the way, did I ever mention that programmers have one of the best rates of employment in the country?


    BACK ON TOPIC: I want to force view distance for players based on what vehicle they're in (and what position they're occupying). I'm aware of
    Code:
    setViewDistance _x;
    in a true trigger, but can I rig this to specific players in specific vehicles? Ideally, I'd like grunts to have viewDistance A, and pilots to have viewDistance B.

    PS: What would accepted distances be? Does anyone actually play ArmA under 2km? And would most pilots be able to handle 5?
    Check out the BAS-f template for ArmA1 they had this function so that you could view distance to specific asset types i.e. grunt, air, tank, etc.
    BlackDog1




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

  6.  

     
  7. #34


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    Spawn random russian squad:
    All the variables at the top can be fiddled with to your hearts desire


    Code:
    if (isServer) then
    {
    	_soldierClasses = ["RU_Soldier_AA", "RU_Soldier_HAT", "RU_Soldier_AR", "RU_Soldier_Crew", "RU_Commander", "RU_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_Marksman", "RU_Soldier_Medic", "RU_Soldier_Officer", "RU_Soldier_Pilot", "RU_Soldier", "RU_Soldier_LAT", "RU_Soldier_AT", "RU_Soldier2", "RU_Soldier_Sniper", "RU_Soldier_SniperH", "RU_Soldier_Light", "RU_Soldier_Spotter", "RU_Soldier_SL", "RU_Soldier_TL", "MVD_Soldier_MG", "MVD_Soldier_Marksman", "MVD_Soldier", "MVD_Soldier_GL", "MVD_Soldier_AT", "MVD_Soldier_Sniper", "MVD_Soldier_TL", "RUS_Soldier_Sab", "RUS_Soldier_GL", "RUS_Soldier_Marksman", "RUS_Commander", "RUS_Soldier1", "RUS_Soldier2", "RUS_Soldier3", "RUS_Soldier_TL"];
    	_ranks = ["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"];
    	_spawnPoints = ["Spawn1", "Spawn2", "Spawn3"];
    	_attack = "Attack";
    	_minimumCount = 6;
    	_maximumCount = 12;
    	_spread = 1;
    	_maxSkill = 1;
    
    
    	_grp = createGroup east;
    	_wp = _grp addWaypoint [getMarkerPos "Attack", 0];
    	[_grp, 0] setWaypointType "SAD";
    
    	_grpSize = _minimumCount + round (random (_maximumCount - _minimumCount));
    
    	_currentSpawn = _spawnPoints select round (random (count _spawnPoints));
    	_currentSpawnPos = [(getMarkerPos _currentSpawn select 0) + (random _spread) - (_spread / 2), (getMarkerPos _currentSpawn select 1) + (random _spread) - (_spread / 2), (getMarkerPos _currentSpawn select 2)];
    
    	for [{_x = 0},{_x < _grpSize},{_x = _x + 1}] do 
    	{
    		_type = _soldierClasses select round (random (count _soldierClasses));
    		_skill = random _maxSkill;
    		_rank = _ranks select (round (random (count _ranks)));
    		_type createUnit [_currentSpawnPos, _grp, "", _skill, _rank];
    	};
    };
    ---Bellicosity---


  8.  
  9. #35

    Sc[ + ]pe's Avatar

    Join Date
    Aug 2007
    Location
    Vancouver, Canada
    Posts
    847

    Re: The Scripting How-To Thread

    Question time!

    A) I've added my own vehicle resupply areas by taking a Vehicle Resupply Point (it's a Warfare object) and sinking it below the surface of the carrier. This has worked out pretty well, considering it requires no scripting and no fiddling! HOWEVER, it seems to only work for me. Hosting it, locally or dedicated, reveals that no one gets repair, resupply, or refuel from it BUT ME!! Any ideas?

    B) I want to convert a Towing Tractor (empty car) into a repair vehicle, capable of repairing any vehicle in a given radius with the exact same traits and characteristics of the MTVR (Repair). Can I do this? Easily?

  10.  
  11. #36


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    Create a trigger the size of the area you want to refuel/resupply/repair

    Group that trigger with the vehicle you want to be able to use the area, call it Plane1

    In the condition field put:
    Code:
    this and (!(isEngineOn vehicle Plane1))
    and in the activation field put:
    Code:
    vehicle Plane1 setFuel 1; vehicle Plane1 setVehicleAmmo 1; vehicle Plane1 setDamage 0;
    You can take the activation field and pull it out to a script if you want it to take some time (basically adding a sleep function between it all) just make sure you give them a hint or text explaining whats going on.
    ---Bellicosity---


  12.  

     
  13. #37

    Sc[ + ]pe's Avatar

    Join Date
    Aug 2007
    Location
    Vancouver, Canada
    Posts
    847

    Re: The Scripting How-To Thread

    So I've got this
    Code:
    this and (!(isEngineOn vehicle Huey_2))
    in my trigger line, this
    Code:
    0null = this execVM "rearm_huey_2.sqf";
    in my activation line, and this
    Code:
    hint "Repairing...";
    sleep 5;
    vehicle Huey_2 setDamage 0;
    hint "";
    sleep 2;
    
    hint "Refueling...";
    vehicle Huey_2 setFuel 0;
    sleep 1;
    vehicle Huey_2 setFuel 0.1;
    sleep 1;
    vehicle Huey_2 setFuel 0.2;
    sleep 1;
    vehicle Huey_2 setFuel 0.3;
    sleep 1;
    vehicle Huey_2 setFuel 0.4;
    sleep 1;
    vehicle Huey_2 setFuel 0.5;
    sleep 1;
    vehicle Huey_2 setFuel 0.6;
    sleep 1;
    vehicle Huey_2 setFuel 0.7;
    sleep 1;
    vehicle Huey_2 setFuel 0.8;
    sleep 1;
    vehicle Huey_2 setFuel 0.9;
    sleep 1;
    vehicle Huey_2 setFuel 1.0;
    hint "";
    sleep 2;
    
    hint "Rearming...";
    vehicle Huey_2 setVehicleAmmo 0;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.1;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.2;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.3;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.4;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.5;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.6;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.7;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.8;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 0.9;
    sleep 1;
    vehicle Huey_2 setVehicleAmmo 1.0
    hint "";
    hint "Maintenance and supply complete.";
    sleep 2;
    hint "";
    sleep 10;
    in script. I know it's not formatted properly... am I on the right track?

  14.  
  15. #38


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    Yep, gonna take awhile for it though

    And I would do fuel last
    ---Bellicosity---


  16.  
  17. #39


    Join Date
    Jun 2009
    Location
    Orlando, FL
    Posts
    68

    Re: The Scripting How-To Thread

    I looked it up and you can get the fuel of a vehicle with "fuel Huey_2". Is there an issue with the scripting language that makes this code not work?(I'm still working through this language):
    Code:
    while (fuel Huey_2 < 1)
    {
        vehicle Huey_2 setFuel ((fuel Huey_2) + 0.1);
        sleep 1;
    }
    Or did I just completely miss something and that's basically psuedocode? lol.

  18.  

     
  19. #40
    Vic
    Vic is offline


    Join Date
    Jun 2005
    Posts
    126

    Re: The Scripting How-To Thread

    This tutorial is never recommended enough:

    OFPEC MultiPlayer Scripting Tutorial

    It's the must read for multiplayer scripting, understanding what this tutorial explains - especially the Locality chapter, on which computer can/does an action run and which computer(s) see the effects of the action - will save you many hours of headaches and might spare tons of frustration when your awesome mission which worked perfectly in singleplayer goes bananas on the server for apparently no reason.

    P.S. You might discover that some very useful commands are missing from this (such as the addPublicVariableEventHandler or setVariable's usage with the public parameter). You should find more about these (and lots of other stuff) by searching the OFPEC forums or studying official or complex unofficial scripts/missions.
    The most dangerous thing on a battlefield is an officer with a map.

  20.  
  21. #41


    Join Date
    Jun 2007
    Posts
    351

    Re: The Scripting How-To Thread

    Quote Originally Posted by blibblob View Post
    I looked it up and you can get the fuel of a vehicle with "fuel Huey_2". Is there an issue with the scripting language that makes this code not work?(I'm still working through this language):
    Code:
    while (fuel Huey_2 < 1)
    {
        vehicle Huey_2 setFuel ((fuel Huey_2) + 0.1);
        sleep 1;
    }
    Or did I just completely miss something and that's basically psuedocode? lol.

    Looks right to me other than the missing semicolon after the closing bracket
    ---Bellicosity---


  22.  
  23. #42

    Inkompetent's Avatar

    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    848

    Re: The Scripting How-To Thread

    Quote Originally Posted by blibblob View Post
    I looked it up and you can get the fuel of a vehicle with "fuel Huey_2". Is there an issue with the scripting language that makes this code not work?(I'm still working through this language):
    Code:
    while (fuel Huey_2 < 1)
    {
        vehicle Huey_2 setFuel ((fuel Huey_2) + 0.1);
        sleep 1;
    }
    Or did I just completely miss something and that's basically psuedocode? lol.
    Wrong format on the while function.

    It should be written like this:
    Code:
    while {fuel Huey_2 < 1} do
    {
        vehicle Huey_2 setFuel ((fuel Huey_2) + 0.1);
        sleep 1;
    };




  24.  

     
  25. #43

    Sc[ + ]pe's Avatar

    Join Date
    Aug 2007
    Location
    Vancouver, Canada
    Posts
    847

    Re: The Scripting How-To Thread

    Alright, TRIGGER TIME.
    I'm starting to script the requirements for my tasks to be met, and am having a bit of difficulty. Task 1: The leader of a group manages to get to a certain destination. Task 2: The rest of that group manages to get to a certain destination. Task 3: A pair of enemy vehicles are destroyed. Task 4: A convoy is eliminated before it reaches a certain destination.

    How would I go about triggering these?

  26.  
  27. #44
    Vic
    Vic is offline


    Join Date
    Jun 2005
    Posts
    126

    Re: The Scripting How-To Thread

    Easy way for 1 & 2: group (F2) trigger with the group, if I remember well you'll have new options for triggering it by the Leader and Any from Group. Otherwise you can use 'gamelogic1 distance leader group player < 10' as condition (instead of 'this', with gamelogic1 placed at destination).
    3: Trigger condition, with veh1/2 being the vehicles' names:
    Code:
    (dammage veh1 >= 1) && (dammage veh2 >= 1)
    4: Success trigger using condition:
    Code:
    (dammage veh3 >= 1) && (dammage veh4 >= 1) && !reachedDestination
    Fail trigger set up as in task 1/2, with activation:
    Code:
    reachedDestination = true; "4" objStatus "FAILED";
    All code above is untested. You might want to initialize reachedDestination = false (via init.sqs or init field of a unit).

    EDIT: Example was given for ArmA1 objectives, I've just realized you might be talking about ArmA2 tasks, not sure if they work the same way.
    The most dangerous thing on a battlefield is an officer with a map.

  28.  
  29. #45

    Sc[ + ]pe's Avatar

    Join Date
    Aug 2007
    Location
    Vancouver, Canada
    Posts
    847

    Re: The Scripting How-To Thread

    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"?

  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