Jump to content

NGagedFX

Member
  • Content Count

    77
  • Joined

  • Last visited

  • Medals

Everything posted by NGagedFX

  1. Hey there, After +200 hours of ArmA2-editing, I finally made my very first script. Nothing special though, but it's a start. And now I'm rolling I want to get deeper into it. I know there are tons of C130 Cargo/Transport scripts, but I get headaches by just looking at it. That's why I want to build my own script in which you can load and unload vehicles, from scratch, and learn in the proces. Right now I am able to open and close the ramp of a C130. :) Here's my setup: C130 - name = c130_transport Init: this exec "c130_cargo\initRamp.sqf" initRamp.sqf openRamp.sqf closeRamp.sqf Right now I got 3 problems: -It only works for this single C130, whereas I rather have it work for every C130. -I has to be multiplayer compatible, and I have no idea what people are talking about when saying stuff like localVariable and what not. -To get to the next part, I want a script to check if the ramp is open. Like "if c130_transport ramp_bottom = 1, then..." but that obviously doesn't work and I can't find anything on teh intarwebzorxz. So if you experts are willing to guide me through it, I would be really thankfull and it would be great for my scripting skills. But please remember that I'm a total noob at scripting. :)
  2. Just an example: BLUFOR, PRESENT, ONCE Condition: this OnAct: [this] exec "spawnAI.sqf"; spawnAI.sqf example _spawnpos = getPos this; _unit = group1 createUnit ["TK_GUE_Soldier_2_EP1", _spawnpos, [], 0, "FORM"] As you can see, this script would be independent of trigger and marker names, which would make it very easy to have this single trigger spawn a single squad, and to occupy larger areas, just Ctrl+C Ctrl+V the trigger all over the area. The only problem for me at this point, is that I have no idea of how to get the value of the position of the trigger, in the script. I've had problems with using [this] in combination with triggers, and I've been told that there is no "this", only "thislist". :( So does anyone know a solution to get the position of the center of the trigger?
  3. I'm working on a clusterbomb script and I nearly got it finished. Here is the code: airplane init: _plane addWeapon "AirBombLauncher"; _plane addMagazine "4Rnd_FAB_250"; nul = [this] execVM "CBU.sqf"; CBU.sqf _plane = _this select 0; hintSilent "starting script"; while {true} do { _weaponClass = currentWeapon _plane; if (_weaponClass == "AirBombLauncher") then { 0 = _plane addEventHandler ["Fired", {[_plane] execVM "CBU2.sqf"}]; } else { _plane removeEventHandler ["Fired", 0]; }; sleep 0.5; }; CBU2.sqf _plane = vehicle player; _weaponClass = currentWeapon _plane; _explode = false; private ["_pos", "_dir", "_vel"]; if (_weaponClass == "AirBombLauncher") then { _bomb = nearestobject [_plane, "Bo_FAB_250"]; sleep 1; waitUntil {((getPos _bomb select 2) < 30)}; _pos = getPos _bomb; _dir = getDir _bomb; _vel = velocity _bomb; deleteVehicle _bomb; _explode = true; } else { _plane removeEventHandler ["Fired", 0]; }; if (_explode) then { _submun = 300; _spread = 100; _smarray = []; for [{_i=0}, {_i<_submun}, {_i=_i+1}] do { _bomblet = "B_30mmA10_AP" createVehicle [2000,2000,2000]; _bomblet setPos [(_pos select 0) + ((_spread / 2) - Random _spread), (_pos select 1) + ((_spread / 2) - Random _spread), _pos select 2]; _bomblet setVelocity _vel; _smarray = _smarray + [_bomblet]; _cnt = count _smarray; hintSilent format ["%1 bomblets", _cnt]; }; }; It kinda works pretty good. When I load the editor, the first bomb will do exactly what I want it to do. It creates the exact amount of bomblets and it does so smoothly. However, when I drop a 2nd CBU, it creates double the amount of bomblets, even though _cnt displays there are only 300. This causes the sim speed to drop and there is a noticable slowdown. When I drop the 3rd bomb, it creates double that of the first! 1 ingame second takes 4 RL seconds which is unacceptable. Eventually the game just crashes. I made sure to reset _smarray and I've also tried setting every other variable to null/0 but that didn't work? I have no idea what to do here. :confused:
  4. NGagedFX

    Clusterbomb

    Well that fixes the problem. :) However, it spreads like a perfect square aligned to the x and y axis. Do you have any idea of how I could make it more roundly shaped? This is the CBU.sqf as I have it right now, it executes itself with a different number of variables so I don't need 2 seperate files: _cnt = count _this; if (_cnt == 1) then { _plane = _this select 0; while {true} do { _weaponClass = currentWeapon _plane; if (_weaponClass == "AirBombLauncher") then { null = _plane addEventHandler ["Fired", {[] execVM "CBU.sqf";}]; waituntil {_weaponClass != "AirBombLauncher"}; } else { _plane removeEventHandler ["Fired", 0]; }; sleep 0.1; }; }; if (_cnt == 0) then { _plane = vehicle player; _weaponClass = currentWeapon _plane; _detoheight = 30; _explode = false; private ["_pos", "_dir", "_vel"]; if (_weaponClass == "AirBombLauncher") then { _bomb = nearestobject [_plane, "Bo_FAB_250"]; sleep 1; waitUntil {((getPos _bomb select 2) < _detoheight)}; _pos = getPos _bomb; _dir = getDir _bomb; _vel = velocity _bomb; deleteVehicle _bomb; _explode = true; } else { _plane removeEventHandler ["Fired", 0]; }; if (_explode) then { _ammo = "B_30mmA10_AP"; _submun = 250; _spread = 100; _spread2 = (_spread / 2); _speed = (sqrt ((_vel select 0)^2 + (_vel select 0)^2)); for [{_i=0}, {_i<_submun}, {_i=_i+1}] do { _bomblet = _ammo createVehicle [2000,2000,2000]; _bomblet setPos [(_pos select 0) + (_spread2 - Random _spread), (_pos select 1) + (_spread2 - Random _spread), _pos select 2]; _bomblet setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),(_vel select 2)*3]; }; }; }; Right now I'll try to add a some kind of 'pop' effect/sound to the FAB_250 so it doesn't just disappaer mid-air. :)
  5. Where else can you download Mike's F16 v1.2 without six-updater?
  6. Something like this: EnTank.sqf WestGrp01 = CreateGroup West; _leader1 = WestGrp01 createUnit ["GUE_Soldier_AR", [(getMarkerPos "tank1") select 0,(getMarkerPos "tank1") select 1,0], [], 3, "FORM"]; _unit1 = WestGrp01 createUnit ["GUE_Soldier_GL", [(getMarkerPos "tank1") select 0,(getMarkerPos "tank1") select 1,0], [], 3, "FORM"]; _unit2 = WestGrp01 createUnit ["GUE_Soldier_MG", [(getMarkerPos "tank1") select 0,(getMarkerPos "tank1") select 1,0], [], 3, "FORM"]; _leader1 = leader WestGrp01; _newGrp1 = (group _leader); _tank1 = "T72_TK_Ep1" createVehicle [(getMarkerPos "tank1") select 0,(getMarkerPos "tank1") select 1,0]; _leader1 moveInCommander _tank1; _unit1 moveInDriver _tank1; _unit2 moveInGunner _tank1; _wp = _newGrp1 addWaypoint [getPos player, 0];
  7. I'm trying to create a script that allows pilots to add a waypoint for themselves with a mapclick. I'm experiencing some weird problems though. init of airplane this addAction ["Create Waypoint", "addWaypoint.sqf"]; addWaypoint.sqf - this piece of code works onMapSingleClick {(group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]}; addWaypoint.sqf - while this doesn't :confused: private ["_grpp"]; _grpp = group player; onMapSingleClick {_grpp addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]}; Since the waypoint disappears at about 1km distance when in an airplane, I want to set the completion radius to 0, but this doesn't do anything: onMapSingleClick {(group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]}; [(group player), 1] setWaypointCompletionRadius 0;
  8. For now I simply created an array of all vehicles followed by a forEach by putting this in the init.sqf: _varray = vehicles; hintSilent format ["vehicles = %1", _varray]; {_x addEventhandler ["GetIn", {_x addAction ["Create Waypoint", "pilotWaypoint2.sqf"]}];} forEach _varray; This however does nothing, not even when I change it {player addAction... :(
  9. I see! So right now I kinda got it working. I haven't tested it in MP yet, but in the editor it works solid. plane_1 init this addEventHandler ["GetIn", {plane_1 addAction ["Create Waypoint", "test2.sqf"]}]; addWaypoint.sqf onMapSingleClick { _waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -6], 0, 1]; _waypoint setWaypointStatements ["!(Alive player)", "deleteWaypoint [(group player), 1]"]; }; _id = _this select 2; (vehicle player) removeAction _id; _action = (vehicle player) addAction ["Delete Waypoint", "deleteWaypoint.sqf"]; _delete = false; _plane = vehicle player; while {!(_delete)} do { _grpp = group player; if (!(Alive player) OR !(Alive vehicle player) OR (vehicle player == player)) then { deleteWaypoint [_grpp, 1]; _delete = true; _plane removeAction _action; }; sleep 1; }; deleteWaypoint.sqf _id = _this select 2; deleteWaypoint [(group player), 1]; (vehicle player) removeAction _id; (vehicle player) addAction ["Create Waypoint", "test2.sqf"]; However, there are some thing I can't get to work. 1. In the eventHandler in the init of plane_1, I have to attach it specifically to plane_1. addEventHandler ["GetIn", {this addAction ["Create Waypoint", "test2.sqf"]}]; does not work. :confused: 2. Right now the actions are added to the vehicle and I don't want an action to pop up for people standing next to it, so I rather have the action added to the player. But no matter what I try, player addAction does nothing. 3. I don't want to add the eventHandler to each vehicle in the editor, I want it to be more general. So I was thinking of adding this to the init.sqf: {_x addEventhandler ["GetIn", {_x addAction ["Create Waypoint", "test2.sqf"]}];} forEach listObjects "Air"; //forEach *vehicle that isKindOf "Air";*
  10. Because this isn't the way they do it in an A10 :p Giallustio, I automatically define local variables and even though (vehicle player) worked, I was quite confused as to why _grpp didn't. PvPscene, simple but solid solution. :) I came up with this: onMapSingleClick { _waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]; }; _waypoint setWaypointStatements ["!(Alive player)", "deleteWaypoint [(group player), 1]"]; However, the waypoint still gets deleted when I get close. I tried global variables (without the _ ) and I tried every combination of the private command. :confused:
  11. But I declared _grpp private so it can be used in the onMapSingleClick scope right? Or what would be the solution for that? I can't find anything about the setWaypointCompletionRadius bug, is it something that should be fixed by BIS in the next patch? Cause else I can never get this to work properly. The whole idea behind this is for infantry to put a marker on the map and then the pilot can create a waypoint by clicking on the map so he has an arrow on his HUD pointing at the target. This way he won't have to constantly look at his map where he's going and it would make non-laser-guided weapons a lot more effective.
  12. I can't find any documentation on sub-menus in the action menu. Let's say you got your standard options "Gear" and "M911". It looks clean and I don't want to make a mess of it, so I only add 1 action "Customize Loadout". When I click on this action I want all of these (including gear and your secondary weapon) to disappear and 6 new actions will popup, like a sub-menu. The BIS ARMEX exposition has this, when you look at one of the info displays for example. I've looked in the mission files but I can't find any there. :(
  13. There are some great templates on that page. I also once made a FOB template which was a real pain (which is the reason it isn't finished yet). If you like it you're free to use in whatever way you can imagine. :) http://hotfile.com/dl/132411088/84d55f3/FOBTemplate.Takistan.rar.html
  14. With great help of Neokika I got a credits system working in which your team gains credits for completing objectives and with which you can buy vehicles and other stuff. In SP this works great, but in MP it gets all messy. I got some scripting knowledge but I have no clue and never had any about MP scripting. I often play with friends where I'm host, but my mission also needs to be compatible with a dedicated server. Here's the setup: Soldier A, B & C, each with the same init My_group1 = group this; init.sqf if (isServer) then { {_x setvariable ["groupCredits", 3, true]} forEach [My_group1]; }; trigger onAct My_group1 setVariable ["groupCredits", ((My_group1 getVariable "groupCredits") + 1), true]; nil = [My_group1] execVM "supplyDrop\credits.sqf"; *this code is started from either a trigger or script I also have a billboard with custom textures to reflect the current status. This is updated by running credits.sqf switch ((_this select 0) getVariable "groupCredits") do { case 0 : { hint "Your team has 0 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_0_credits.jpg"] }; case 1 : { hint "Your team has 1 Credit"; supplyDropbb setObjectTexture [0,"textures\SD_1_credits.jpg"] }; case 2 : { hint "Your team has 2 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_2_credits.jpg"] }; case 3 : { hint "Your team has 3 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_3_credits.jpg"] }; case 4 : { hint "Your team has 4 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_4_credits.jpg"] }; case 5 : { hint "Your team has 5 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_5_credits.jpg"] }; case 6 : { hint "Your team has 6 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_6_credits.jpg"] }; case 7 : { hint "Your team has 7 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_7_credits.jpg"] }; case 8 : { hint "Your team has 8 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_8_credits.jpg"] }; case 9 : { hint "Your team has 9 Credits"; supplyDropbb setObjectTexture [0,"textures\SD_9_credits.jpg"] }; case 10 : { hint "Your team has reached the maximum amount of 10 Credits. Buy something before acquiring even more Credits!"; supplyDropbb setObjectTexture [0,"textures\SD_10_credits.jpg"] }; }; We all connect and start the mission: everyone has the same amount of credits and the billboard is up-to-date. When either one us fires the trigger, most of the time everyone will get credits, but this is very inconsistent. Sometimes the player who fires the trigger will get double or triple the credits, while at other times other people don't get anything. There are moment when everything is in sync, but it takes very little effort to mess it all up. :confused: I think the problem is with running the scripts 'serverside/clientside' and I should probably use publicVariables but I have no idea where to start and how all this stuff works. So if anyone could point me in the right direction and help me out it would be greatly appreciated, as this credit system is the core of my sandbox map. :)
  15. When you are in an airplane you will only be able to see laser painted targets while having the GBUs selected. While only the GBUs are able to lock onto the painted target and guide themselve, I also find this laser to be really useful in marking an area for a GAU-8 or Hydra strike. Is there any way to make it possible for pilots to see the laser targets with every weapon? This would greatly increase the effectiveness of other weapons. :)
  16. Hello there, I'm getting more and more into scripting, and as a somewhat functional script - but more importandly as a personal tutorial - I'm writing this 'CreateMarker' script. How to call: nul = [position, "name", "type", "text", "colour", size, time, gps_object] execVM "scripts\CreateMarker.sqf" Description of Variables: CreateMarker.sqf _markerPos = _this select 0; _markerName = _this select 1; _markerType = _this select 2; _markerText = _this select 3; _markerColor = _this select 4; _markerSize = _this select 5; _markerTime = _this select 6; _markerGpsObject = _this select 7; _markerName = createmarker [_markerName, _markerPos]; _markerName setMarkerType _markerType; _markerName setMarkerText _markerText; _markerName setMarkerColor _markerColor; _markerName setMarkerSize [_markerSize,_markerSize]; //_markerTime and _markerGpsObject are working fine so I haven't included them in this post (it's a lot of text atm :P) If I fill in all the fields correctly, this script does exactly what I want it to. However, as with every script I've used up until now, you always had the choice to not assign some variables by cutting off the exec string or by using "" or not filling in anything. For example: 1 - nul = [getPos unit1, "", "", "Unit 1 is over here!", "", , , unit1] 2 - nul = [getPos unit1, "marker_unit1"] As seen in 1, "" in case of a string or [space] in case of a number, or as seen in 2 where the last part is simply cut off, it should use the default values defined by the script. However, I've had major problems defining these. if (_markerType == "") then {hint "true"}; this worked in case 1 if (isNil "_markerType") then {hint "true"}; this worked in case 2 But as you don't know how someone is gonna use your script: if ((isNil "_markerType") || (_markerType == "")) then {hint "true"}; which didn't work at all and even gave me errors :confused: So how do I define these default variables? :confused:
  17. I would love for A-10 pilots in my mission to have the ability to exchange the standard GBUs for AT and AP CBUs to add some variation and destructive power. I've found 2 scripts on the internet, but they seem way too complicated and I don't get a thing about what's going on, or they are released as a mod PBO which I can't use in my mission. So I started off making my own script, and learn about it in the process. But I simply can't get it to work, even by trying 5 different ways. This is what I came up with for an AP CBU: A-10's (no name) init (which drops the bomb immediatly so I can spectate from the ground) nul=[this] execVM "CBU\clusterCBU87.sqf"; clusterCBU87.sqf _plane = _this select 0; _subammo = "B_30mm_HE"; _value = random 20; _bomb = "Bo_Mk82" createvehicle [2000,2000,2000]; _bomb attachTo [_plane,[0,0,-1]]; sleep 0.3; detach _bomb; waitUntil {(getPos _bomb select 2) = 80)}; _blet1 = _subammo createVehicle (getPos _bomb); _blet1 setVelocity [_value,_value,((_value)-40)]; _blet2 = _subammo createVehicle (getPos _bomb); _blet2 setVelocity [_value,_value,((_value)-40)]; _blet3 = _subammo createVehicle (getPos _bomb); _blet3 setVelocity [_value,_value,((_value)-40)]; _blet4 = _subammo createVehicle (getPos _bomb); _blet4 setVelocity [_value,_value,((_value)-40)]; deleteVehicle _bomb; hint "End of script"; Ofcourse, when I get this to work there will be far more 'blets'. Other things I got on my mind are: -Not activated through the action menu, but as a normal weapon* -MK82 should be dumb, as CBUs are already defastating enough -Smoke/sound effect when detoning _bomb into submunition -An AT version with possibly "B_25mm_APDS", "B_30mm_AP" or "B_30mmA10_AP" _subammo to destroy/disable/damage light/medium/heavy armor -The ability to exchange a single GBU for a single AT or AP CBU *For this, I though it would be best to use the removeMagazine/(addWeapon)/addMagazine commands on the A-10 to simply replace the GBUs by MK82 which would work as if you were flyinh an AV-8, but I don't know if it possible, when one of the bombs drops, to detect it, give it name, and assign it to _bomb in this script ---------- Post added at 15:52 ---------- Previous post was at 15:40 ---------- Just to be a bit more specific: _subammo doesn't work, replacing it with "B_30mm_HE" does waitUntil doesn't work, until now I've been testing it with a sleep delay _value is indeed random, but is constant for every blet, whereas I want it to be random for every blet However, [(random 20),(random 20),((random 20)-40)]; doesn't do anything :confused:
  18. I've been learning a lot of stuff about scripting lately, but there are some situations in which I still use SQS as I don't have a good SQF reference. I feel mixed up using 2 different types and I would prefer to just use SQF. However, there are a few thing I'm unable to "translate": What would the following script look like if it were SQF? [b]#start[/b] _bomb = _this select 0 _target = nearestObject [_bomb, "CAR"] [b]? (side _target != west):goto "repeat" ?(_target distance _bomb < 10):goto "boom" goto "repeat"[/b] [b]#boom[/b] _charge = "M_Sidewinder_AA" createVehicle (getPos _bomb) deleteVehicle _bomb [b]exit[/b] [b]#repeat[/b] ~1 [b]goto "start"[/b] My main problems are how to ask a question and sent the script to another point if it's false, how to make a script exit after a while and how to make a script do nothing. Leaving the brackets empty gives me errors (for instance, if (Alive player) then {} )
  19. NGagedFX

    SQS to SQF

    I feel a bit ashamed right now cause it's to goddamn obvious I should have declared _class instead of _vehiclesonly. :o I had been scripting for a whole day and I was pretty tired so my brain was kinda low on logical creativity. :p Does it matter though where you declare a certain variable? I primarily use other scripts as a reference and they always seem to use the private command on top of their script or just after selecting all variables (= _this select *; etc). I haven't got a folder with Macs Tools or Squint, and I'm definitely in the need for such a program. Would be much faster then hitting preview, check the error arma shows and alt-tabbing back to notepad. I think I screwed up yesterday so I'll just do a 2nd attempt with a rested head. :D
  20. NGagedFX

    SQS to SQF

    What a coinsidence, I downloaded it about an hour ago. :p I ran the setup, rebooted and it's like nothing has happened, there's not even something called "squint" on my pc so something went wrong there. I already tried private ["_vehiclesonly"]; _vehiclesonly = true; if (_vehiclesonly) then {_class = "LandVehicle"} else {_class = "Land"}; hint format ["_variable: %1", _class]; but that didn't work either. :(
  21. Welcome Whiteraven. :) Give the unit a name, give the trigger a name. Then in the unit's init: triggername attachTo [unitname, [0,0,0]]; Besides, your post should probably be in: Bohemia Interactive Forums > BI MILITARY GAMES FORUMS > ARMA 2 EDITING > ArmA 2 & OA - MISSION EDITING & SCRIPTING It's a section dedicated to editing stuff, and there will be a lot more people reading it. ;)
  22. NGagedFX

    SQS to SQF

    Stupid mistake from me. :rolleyes: I nearly got it done, and Google servers are overloading thanks to me, but I keep coming across stuff that just doesn't make any sense for as far as my experience and knowledge reach and not everything is as well 'findable'. For example: _class = "LandVehicle"; hint format ["_variable: %1", _class]; Hint shows _variable: LandVehicle , which is good. But I need to do it through a variable: _vehiclesonly = true; if (_vehiclesonly) then {_class = "LandVehicle"} else {_class = "Land"}; hint format ["_variable: %1", _class]; Even while the variable is defined within the script, a hint shows up _variable: any :confused::confused:
  23. That explains a lot, shk. Your option works perfectly! Though it's a bit of a strange approach to be able to use defaults. Aren't any other editors here using default values, so that you can put "" where ever you don't want to change anything? I'm going back in the editor cause I've got a load of scripting to do, and it gets more interesting every time. :D
  24. NGagedFX

    SQS to SQF

    There's still something left I can't get to work. I want to be able to detect not only "Car", but also "Tank" and "Man". I tried the following, but it doesn't work. :( _targetType = ["Car", "Tank", "Man"]; _target = nearestObject [_bomb, _targetType];
×