-
07-18-2009, 05:37 AM #31
-
07-18-2009, 06:24 AM #32
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 ofin 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.Code:setViewDistance _x;
PS: What would accepted distances be? Does anyone actually play ArmA under 2km? And would most pilots be able to handle 5?
-
07-18-2009, 06:42 AM #33
-
07-18-2009, 05:27 PM #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---

-
07-19-2009, 07:15 AM #35
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?
-
07-19-2009, 11:34 AM #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:
and in the activation field put:Code:this and (!(isEngineOn vehicle Plane1))
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.Code:vehicle Plane1 setFuel 1; vehicle Plane1 setVehicleAmmo 1; vehicle Plane1 setDamage 0;
---Bellicosity---

-
07-19-2009, 07:19 PM #37
Re: The Scripting How-To Thread
So I've got this
in my trigger line, thisCode:this and (!(isEngineOn vehicle Huey_2))
in my activation line, and thisCode:0null = this execVM "rearm_huey_2.sqf";
in script. I know it's not formatted properly... am I on the right track?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;
-
07-20-2009, 02:24 AM #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---

-
07-20-2009, 02:46 AM #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):
Or did I just completely miss something and that's basically psuedocode? lol.Code:while (fuel Huey_2 < 1) { vehicle Huey_2 setFuel ((fuel Huey_2) + 0.1); sleep 1; }
-
07-20-2009, 12:53 PM #40
- 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.
-
07-20-2009, 03:58 PM #41
- Join Date
- Jun 2007
- Posts
- 351
-
07-20-2009, 08:25 PM #42
-
07-20-2009, 09:13 PM #43
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?
-
07-21-2009, 04:44 AM #44
- 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:
4: Success trigger using condition:Code:(dammage veh1 >= 1) && (dammage veh2 >= 1)
Fail trigger set up as in task 1/2, with activation:Code:(dammage veh3 >= 1) && (dammage veh4 >= 1) && !reachedDestination
All code above is untested. You might want to initialize reachedDestination = false (via init.sqs or init field of a unit).Code:reachedDestination = true; "4" objStatus "FAILED";
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.
-
07-21-2009, 07:28 AM #45
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"?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)






Reply With Quote











Bookmarks