Creating Group With Trigger + Add Urban Patrol Script |
Creating Group With Trigger + Add Urban Patrol Script |
Mar 15 2010, 07:57
Post
#1
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Can anyone help me with making a script that makes an enemy group and have them init the Urban Patrol Script that you can call in with a trigger
I'm doing it this way because my mission is big and I dont want a bunch of units already spawned in all over the map when the mission spawns. I want the groups to spawn and follow the UPS script when triggered by BLUFOR. I tried making egroup1.sqf ups1 is the marker, _egroup1 is the group name CODE _grp = Creategroup EAST; _grp createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; _grp createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; Then after that I tried to call it in but kept giving me errors. Any help would be greatly appreciated. |
|
|
Mar 15 2010, 09:20
Post
#2
|
|
Gee, I wish we had one of them doomsday machines. Group: Moderators Posts: 2,037 Joined: 13-November 06 From: Wales Member No.: 155 |
It'd helpful if you could let us know what errors you're getting exactly.
I'd advise against using a marker to get positions, game logic objects work a lot better IMO. Also, I think your trying to use the incorrect format for creating units. It should look something like this: CODE unit = _grp createUnit ["SoldierWB", position player, [], 100, "FORM"]; (Shamelessly stolen from BIKI) Or this: CODE "soldierWB" createUnit [getMarkerPos "marker_1", _groupAlpha,("loon1 = this; this addweapon {binocular}"), 0.6, "corporal"] (Also nabbed from BIKI) -------------------- The Rules - Nothing too complicated, follow these and we'll have no problems.
Moderation Feedback Thread - Tell everyone how much you Site Issues Thread - Complain about site issues here. We might even fix them! Community Chatter Thread - Furthest Mud-sling gets a free subscription to "JdB Monthly". QUOTE(Major Mike Shearer) We can categorically state that we have not released man-eating badgers into the area. QUOTE(Brace Belden) A machine gun is like a woman, I don’t understand it, I’m afraid of it, and one day I’ll accidentally be killed by one. |
|
|
Mar 15 2010, 14:01
Post
#3
|
|
ArmA.info Sarcasm Society's Slightly Mad Scotsman Group: Former .info Serviceman Posts: 718 Joined: 28-September 07 From: Glasgow, UK Member No.: 1,331 |
In addition to what Dave has already said: if your doing this in a multiplayer mission be sure to have the script execute server side only or there's a chance that'll you'll have the lovely issue of spawning N=X*Y (where X is the number of players on the server and Y is the number of units created by one script) units and causing ridiculous amounts of desync/lag as a result.
Don't know if they fixed that bug in ArmA I or ArmA II but it was a pita in OFP. -------------------- Never before in the history of man, was so much buggered up by so few.
|
|
|
Mar 15 2010, 21:46
Post
#4
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Ok it's getting very frustrating for me to figure this out
1. The script I'm using to spawn a group does in fact work 2. This is the error I get: I found out it's from the UPS script. What I'm doing to try to get this script working: I'm trying to spawn an enemy group from my Init.sqf for now to just test and find how to add a group and make them init the ups.sqf: [this,"marker"] execVM "ups.sqf" From my init.sqf: CODE //Spawns Group With UPS [] execvm "ups1spwn.sqf"; Sleep 1; [_grp,"ups1spwn"] execVM "ups.sqf"; From ups1spwn.sqf: CODE ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: Semedar //exec: [] execvm "ups1spwn.sqf" ////////////////////////////////////////////////////////////////// _grp = Creategroup EAST; _grp createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; _grp createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; _grp createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; I have a rectangle marker named GrpM to spawn the units there. I'm trying to make them follow the ups script from the init.sqf So, to summarize: Does anyone know how to spawn an enemy group and make them init: [this,"marker"] execVM "ups.sqf" And make them spawn with a trigger? If so, can you post detailed instructions? This post has been edited by semedar: Mar 15 2010, 21:53 |
|
|
Mar 16 2010, 13:37
Post
#5
|
|
ArmA.info Sarcasm Society's Slightly Mad Scotsman Group: Former .info Serviceman Posts: 718 Joined: 28-September 07 From: Glasgow, UK Member No.: 1,331 |
Well a couple of things first:
Your trying to move a local* variable between two scripts: AFAIK this is not possible: you have to define the variables at the start of your script unless your working with global variables. If your playing around with groups your best using global variables so I'd first change: CODE ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: Semedar //exec: [] execvm "ups1spwn.sqf" ////////////////////////////////////////////////////////////////// eastGP = Creategroup EAST; eastGP createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; eastGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; Leading into the next change: CODE //Spawns Group With UPS [] execvm "ups1spwn.sqf"; Sleep 1; [eastGP,"ups1spwn"] execVM "ups.sqf"; an alternate line of code for the ups.sqf activation could be: CODE [leader eastGP,"ups1spwn"] execVM "ups.sqf"; The second thing I have to point out is: I'm not entirely sure but are you entirely sure your using the right names throughout.... It's been a while since I've done any scripting and I can't say I truely tampered with ups so take my advice with a pinch of salt! If you have no luck I'll dig out my old scripts folder and see if I can put together a template for you. *Reffering to local and global in the script sense not in the multiplayer sense: Global in this case means a variable that is not restricted to one script and has a value of one sort or another that remains the same through each script unless changed by a trigger or script mechanic. Local variables are temporary and as such must be defined for each script and do not carry over between scripts unless using a global variable as a carrier. -------------------- Never before in the history of man, was so much buggered up by so few.
|
|
|
Mar 18 2010, 01:07
Post
#6
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Haha thanks, JynX!
It worked! I used CODE [leader eastGP,"GrpM"] execVM "ups.sqf"; instead of CODE [eastGP,"ups1spwn"] execVM "ups.sqf"; Because it gave me an error: Thanks a lot! EDIT: I'm trying to execute ups1spwn.sqf CODE ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: JynX //exec: [] execvm "ups1spwn.sqf" //Spawns Enemy Group (eastGP) with UPS ////////////////////////////////////////////////////////////////// eastGP = Creategroup EAST; eastGP createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; eastGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; eastGP createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 2, "FORM"]; Sleep 1; [leader eastGP,"GrpM"] execVM "ups.sqf"; exit Within a trigger: [] execvm "ups1spwn.sqf" But gives me this error: It works perfectly if executed within my init.sqf file: CODE //Spawns Enemy Group With UPS
[] execvm "ups1spwn.sqf"; This post has been edited by semedar: Mar 18 2010, 01:33 |
|
|
Mar 18 2010, 08:48
Post
#7
|
|
Gee, I wish we had one of them doomsday machines. Group: Moderators Posts: 2,037 Joined: 13-November 06 From: Wales Member No.: 155 |
If you're using a trigger, execVM needs to be called in this format:
CODE _Handle = [arguements] execVM "filename" The handle is so you can mess around with the script later, I don't imagine you're going to use it, because your script doesn't look to be looping repeatedly, but if you've got the sleep function and whatnot, the engine will throw a hissy fit if you don't have one... can be anything (ie, "_scipt002741", "_myawesomescript" or "_whydoIneeditbasedontimedelayandnotsomethingthatmakesmoresenselikesaythepre scenceofadoloop". though I think that last one might be a bit too long) This makes sense if you've got a complex script with loops and time delays that runs throughout the mission (ie, a script that randomizes the weather conditions, waits an hour, then randomizes them again), but for (relatively) simple stuff, it might seem a bit convoluted. -------------------- The Rules - Nothing too complicated, follow these and we'll have no problems.
Moderation Feedback Thread - Tell everyone how much you Site Issues Thread - Complain about site issues here. We might even fix them! Community Chatter Thread - Furthest Mud-sling gets a free subscription to "JdB Monthly". QUOTE(Major Mike Shearer) We can categorically state that we have not released man-eating badgers into the area. QUOTE(Brace Belden) A machine gun is like a woman, I don’t understand it, I’m afraid of it, and one day I’ll accidentally be killed by one. |
|
|
Mar 18 2010, 09:42
Post
#8
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Aye thanks. That helped out alot!
EDIT: Here's the end-result if anyone wants to know/do the same thing. EDIT 2: Just edited it to create a marker on the script for UPS when triggered. Instead of placing a marker on mission editor and showing up when you don't need it. If anyone could look it over and see if I did it right, it would be helpful. I'm pretty sure I did since it works I think. Can't be too sure.. SpawnMarker is a unit I placed in the town. And he gets deleted once the script has been called. ortegospwn.sqf CODE ////////////////////////////////////////////////////////////////// // Spawn 5 Enemy Groups With UPS // Created by: JynX/D@V£/Semedar // To Exec In Init: [] execvm "ortegospwn.sqf" // To Exec In Trigger: nul = [] execVM "ortegospwn.sqf" ////////////////////////////////////////////////////////////////// // Creates Marker Over Town For UPS createMarker ["GrpM", position SpawnMarker]; "GrpM" setMarkerShape "RECTANGLE"; "GrpM" setMarkerSize [200, 200]; "GrpM" setMarkerPos getPos SpawnMarker; Sleep 2; // First Squad ortegoGP = Creategroup EAST; ortegoGP createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; ortegoGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; Sleep 1; [leader ortegoGP,"GrpM","nofollow","random"] execVM "ups.sqf"; // Second Squad ortegoGP1 = Creategroup EAST; ortegoGP1 createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; ortegoGP1 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP1 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP1 createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP1 createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP1 createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP1 createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; Sleep 1; [leader ortegoGP1,"GrpM","nofollow","random"] execVM "ups.sqf"; // Third Squad ortegoGP2 = Creategroup EAST; ortegoGP2 createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; ortegoGP2 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP2 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP2 createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP2 createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP2 createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP2 createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; Sleep 1; [leader ortegoGP2,"GrpM","nofollow","random"] execVM "ups.sqf"; // Fourth Squad ortegoGP3 = Creategroup EAST; ortegoGP3 createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; ortegoGP3 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP3 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP3 createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP3 createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP3 createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP3 createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; Sleep 1; [leader ortegoGP3,"GrpM","nofollow","random"] execVM "ups.sqf"; // Fifth Squad ortegoGP4 = Creategroup EAST; ortegoGP4 createUnit ["SquadLeaderE", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"]; ortegoGP4 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP4 createUnit ["SoldierEB", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP4 createUnit ["SoldierEG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP4 createUnit ["SoldierEMG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP4 createUnit ["SoldierEAT", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; ortegoGP4 createUnit ["SoldierESniper", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"]; Sleep 1; [leader ortegoGP4,"GrpM","nofollow","random"] execVM "ups.sqf"; Sleep 1; //Deletes Unit Used To Spawn Marker Deletevehicle SpawnMarker; exit Another thing: You can't createUnit an enemy vehicle? The following script spawns the both soldiers, but not the Shilka (ZSU) SpawnShilka.sqf CODE createMarker ["Shilka1", position Shilka1M];
"Shilka1" setMarkerType "DOT"; "Shilka1" setMarkerColor "ColorRed"; "Shilka1" setMarkerPos getPos Shilka1M; Shilka1 = Creategroup EAST; Shilka1 createUnit ["ZSU", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; Shilka1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; Shilka1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; Sleep 1; leader Shilka1 disableAI "MOVE"; exit This post has been edited by semedar: Mar 19 2010, 01:26 |
|
|
Mar 20 2010, 12:14
Post
#9
|
|
ArmA.info Sarcasm Society's Slightly Mad Scotsman Group: Former .info Serviceman Posts: 718 Joined: 28-September 07 From: Glasgow, UK Member No.: 1,331 |
When dealing with vehicles it's best to view it as if making things appear in reality: Your gonna be making a machine appear not a sentient being, you need to use createVehicle for vehicles and then create the crew and then moveindriver/gunner/cargo them into the named vehicle.
so essentially if you look up the createvehicle command on the biki or comref that'll tell you what to do with the ZSU, if you create the crew as two seperate units and then group them after sticking them in the zsu: CODE crew1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"];
crew2 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; crew1 moveinGunner shilka1;where shilka1 is the previously created shilka crew2 moveinDriver shilka1;where shilka1 is the previously created shillka zsucrew = [crew1,crew2] Sleep 1; leader zsucrew disableAI "MOVE"; exit This post has been edited by JynX: Mar 20 2010, 12:14 -------------------- Never before in the history of man, was so much buggered up by so few.
|
|
|
Mar 20 2010, 19:38
Post
#10
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Aye thanks alot! I figured it wasn't createVehicle since it only spawned an empty vehicle.
EDIT: I get an error on line 28 (leader zsucrew disableAI "MOVE";) on the following script: Shilkas.sqf CODE createMarker ["Shilka1", position SpawnMarker2]; "Shilka1" setMarkerType "Dot"; "Shilka1" setMarkerColor "ColorRed"; "Shilka1" setMarkerPos getPos SpawnMarker2; Sleep 1; _Shilka1 = "ZSU" createVehicle (getMarkerPos "Shilka1"); sleep 1; crew1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; crew2 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; crew1 moveinGunner shilka1; crew2 moveinDriver shilka1; zsucrew = [crew1,crew2]; Sleep 1; leader zsucrew disableAI "MOVE"; exit It also doesn't spawn the soldiers, just the ZSU. This post has been edited by semedar: Mar 21 2010, 04:10 |
|
|
Mar 21 2010, 14:40
Post
#11
|
|
ArmA.info Sarcasm Society's Slightly Mad Scotsman Group: Former .info Serviceman Posts: 718 Joined: 28-September 07 From: Glasgow, UK Member No.: 1,331 |
CODE createMarker ["Shilka1", position SpawnMarker2]; "Shilka1" setMarkerType "Dot"; "Shilka1" setMarkerColor "ColorRed"; "Shilka1" setMarkerPos getPos SpawnMarker2; Sleep 1; _Shilka1 = "ZSU" createVehicle (getMarkerPos "Shilka1"); sleep 1; ;define crew groups crew1 = Creategroup EAST crew2 = Creategroup EAST zsucrew = Creategroup EAST zsucrew = [] _crew1 = crew1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; _crew2 = crew2 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; _crew1 moveinGunner _Shilka1; _crew2 moveinDriver _Shilka1; zsucrew = [] + [_crew1,_crew2] Sleep 1; leader zsucrew disableAI "MOVE"; exit that might fix it, not got my templates on the pc so don't know for sure. -------------------- Never before in the history of man, was so much buggered up by so few.
|
|
|
Mar 21 2010, 19:49
Post
#12
|
|
Junior Member Group: Members Posts: 20 Joined: 18-March 09 From: San Antonio, TX Member No.: 5,356 |
Aye thanks a lot and sorry for being a nuisance by asking a bunch of questions.
I'll try it later and will confirm it, but I can't right now. =\ EDIT: Just tried it and it works perfectly! Thanks! There was about 2-3 minor error with missing ";" but an easy fix Here's the final one if anyone wants to know/do the same thing in the future. CODE createMarker ["Shilka1", position SpawnMarker2]; "Shilka1" setMarkerType "Dot"; "Shilka1" setMarkerColor "ColorRed"; "Shilka1" setMarkerPos getPos SpawnMarker2; Sleep 1; _Shilka1 = "ZSU" createVehicle (getMarkerPos "Shilka1"); _Shilka1 setDir 90; sleep 1; crew1 = Creategroup EAST; crew2 = Creategroup EAST; zsucrew = Creategroup EAST; zsucrew = []; _crew1 = crew1 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; _crew2 = crew2 createUnit ["SoldierEB", getMarkerPos "Shilka1", ["Shilka1"], 1, "FORM"]; _crew1 moveinGunner _Shilka1; _crew2 moveinDriver _Shilka1; zsucrew = [] + [_crew1,_crew2]; Sleep 1; exit EDIT2: I took off the leader disableAI move thing because it kept giving me an error. But I figured that its not needed as the Shilka wont move anyways without a waypoint/order. This post has been edited by semedar: Mar 22 2010, 04:53 |
|
|
Lo-Fi Version | Time is now: 26th April 2024 - 16:57 |