| Script Depository for odds and ends; compilation of script bits | |
|---|---|
| Topic Started: Sep 16 2008, 05:46 PM (452 Views) | |
| ww2weasel | Sep 16 2008, 05:46 PM Post #1 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
This script is good to piggyback squads onto your unit to make ease of setup into next objective of your mission. Just create a condition to switch to new script and exit when necessary for mission. ****For Faster travel time set: SetFormation to "STAG COLUMN" and SetBehaviour "AWARE"**** The below script will get 4 squads to follow you. This is just a script to give the player extra back up in a wide open area or to collect 4 squads and have them tag along to the next mission objective. To execute in trigger: this exec "nameofscript.sqs" Admittedly the positioning could be better; but this is in early stage of development leading up to something else. Edit as you like to put into your mission. Just name 4 squads in each respective squad Leader's activation field: as = group this bs = group this cs = group this ds = group this Script: ---------------------------------------------------------------------------------------------------------------------- this exec "movetrigger.sqs" {_x setCOMBATMode "RED", _x setBehaviour "AWARE"} forEach units as {_x setCOMBATMode "RED", _x setBehaviour "AWARE"} forEach units bs {_x setCOMBATMode "RED", _x setBehaviour "AWARE"} forEach units cs {_x setCOMBATMode "RED", _x setBehaviour "AWARE"} forEach units ds as1 = units as; bs1 = units bs; cs1 = units cs; ds1 = units ds; #Start as2 = as1 - [leader as]; bs2 = bs1 - [leader bs]; cs2 = cs1 - [leader cs]; ds2 = ds1 - [leader ds]; ?!stopped player : leader as doMove [(getPos player select 0)-25,(getPos player select 1)-10,0],leader as setFormation "LINE" ?!stopped player : {_x doFollow leader as,_x setFormation "LINE"} forEach as2 ?!stopped player : leader bs doMove [(getPos player select 0) -25,(getPos player select 1)+10,0],leader bs setFormation "LINE" ?!stopped player : {_x doFollow leader bs,_x setFormation "LINE"} forEach bs2 ?!stopped player : leader cs doMove [(getPos player select 0) +25,(getPos player select 1)-10,0],leader cs setFormation "LINE" ?!stopped player : {_x doFollow leader cs,_x setFormation "LINE"} forEach cs2 ?!stopped player : leader ds doMove [(getPos player select 0) +25,(getPos player select 1)+10,0],leader ds setFormation "LINE" ?!stopped player : {_x doFollow leader ds,_x setFormation "LINE"} forEach ds2 _getpl = getDir player groupas1 setFormDir _getpl, groupbs1 setFormDir _getpl, groupcs1 setFormDir _getpl, groupds1 setFormDir _getpl, ~5 ?!alive player : exit ?supu : goto "temp_loop" goto "Start" #temp_loop ~10 ?supu : goto "temp_loop" //this pending condition from trigger --> This temp loop is a holding place till other scripts do other "child" formational changes etc... ?!supu : goto "start" //this pending condition from trigger --> "Parent" Formation script... exit ------------------------------------------------------------------------------------------------------ Set whatever condition you like to exit. ***updated this script 10-13-08 Enhanced the overall formation. This meant for 4AI squads and your own squad. Overstrength platoon formation... Edited by ww2weasel, Oct 14 2008, 01:02 AM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Sep 16 2008, 06:15 PM Post #2 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Here's a quick series of strings that will help send an Engineer to an object and plant, then later explode a bomb. Set your conditions however you like; but the below will get the AI to run and setup timebomb, then run away and detonate. If you like you could shorten this to make a suicide bomber - setDammage 4 the AI and the Object. Substiute your object ###'s with the below examples. Activation: eng1 doMove getPos object 3443 Activation: eng2 doMove getPos object 3443 Condition: eng1 distance object 3443 <= 8 Activation: eng1 playMove "PutDown" Condition: eng2 distance object 3443 <= 8 Activation: eng2 playMove "PutDown" Activation: eng1 domove getPos object 628 Activation: eng2 domove getPos object 628 Activation: holder = "shell105" createvehicle getpos object 3443 Activation: holder1 = "shell105" createvehicle getpos object 3443 Activation: holder setDammage 4 Activation: holder1 setDammage 4 Activation: object 3443 setDammage 4 Great for Hold Position missions - where the enemy AI is trying to tear open holes to send sappers through... Edited by ww2weasel, Sep 16 2008, 06:36 PM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Sep 17 2008, 05:55 AM Post #3 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
A Tip/Hint for smooth landing/deploy of: Valkyrie Airborne Assault Transport The unit has a tendency to not be faithful when it comes to landing at a specified location, by way of using waypoints. The Recommended method I suggest is to do the following thing: 1. Create a Trigger and call it xxxxx 2. Go into your mission.sqm file; look for Sensors and then look for xxxxx 3. Find the following (yours won't look like this exactly): position[]={1905.259644,44.271240,5620.872070}; 4. rearrange the position order to reflect: 1905.259644,5620.872070,44.271240 5. Create Trigger or Script. Activation field put: xwing setSpeedMode "LIMITED";xwing doMove [1905.259644,5620.87207,49.271240] 6. Setup next trigger or add line in script: Condition: unitReady xwing Activation: xwing flyInHeight 2 7. Set another Condition - to set your mission pertinent info and Activation to execute your mission pertinent actions. 8. In trigger set a Condition pertinent to your mission but in Activation field put: xwing flyInHeight 50. Then fly off to wherever you need the Valkyrie to go. The above seems to work well - not a whole lot of wrestling with this addon in the editor to make it work.... Keep in mind I'm on a mostly flat map, but with a little adjustment it should work out well. Also could set height of ground to just hover above then execute a script to have troopers jump off/deploy from it. Could have the Valkyrie move a little bit for better effects. Or even better - loop the Valkyrie so it continually brings in fresh troops to the battlefield. A good theatrical way to get reinforced. Edited by ww2weasel, Sep 17 2008, 06:04 AM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Sep 28 2008, 02:15 AM Post #4 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
To make moving sentries/patrols more aware of their surroundings setup some Markers & trigger(s) with: Create Markers: Then name them M1 and M2 In Trigger condition line whatever you want that fits mission; true or this with having selected side; repeatedly. Then set the trigger to encompass half the distance of the patrol route. If Patrol route less than 100 meters. if more add a few more triggers and markers. Unit = Blue Marker = Purple Commands = Red Array Component = Orange Array Component Variable adjustment = Yellow On Activation line put: s2 commandWatch getMarkerPos "M1";s1 commandWatch getMarkerPos "M2" On Deactivation line put: s2 commandWatch getMarkerPos "M2";s1 commandWatch getMarkerPos "M1" You could set marker to relative position of soldier this way marker will move with AI. On Activation line put: "M1" setMarkerPos [(getPos s2 select 0) +250,0,0]; "M2" setMarkerPos [(getPos s1select 0) +250,0,0]; On Deactivation line put: "M1" setMarkerPos [(getPos s1 select 0) +250,0,0]; "M2" setMarkerPos [(getPos s2 select 0) +250,0,0]; ***Direction units look in depends on their movement and what you set in the arrays. This may become a totally variable event that will require experimentation on the editors part. *** Note: Arrays in this case are made of 3 components; (* * select 0),(* * select 1),(* * select 2). I used zero's in the latter part of array as I didn't need to adjust variables. ***Distance to look at is totally up to the mission editor. Hint: I chose 250 meters this will make the unit look further out, rather than look 5 meters in front of him. Also to look up or down depending where the unit is walking in relation to sea level. Add/subtract variable modifier to select 2 This will make the AI look in different directions as they walk. Add more triggers as you like. If a sentry is standing still, then setup a loop script to have the soldier look in different directions every #n of seconds that would look natural - or for randomness then set #n accordingly to your mission needs. However if you choose to make a script; I suggest using positions rather than markers - unless a dynamic mission; where you cannot predict sentries path(s). However you could make them look out past their relative position as well. Edited by ww2weasel, Sep 28 2008, 02:45 AM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Oct 13 2008, 02:35 AM Post #5 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
About the call command... when working with variables.... There comes a time when you need to make loops in scripts. So instead of having 50 lines; that do the same thing but with 50 different variable names. The format command is used to join numbers to letters. These are commonly referred to as strings. Now strings are only useful when the script is looking for a string element. The problem that occurs when joining numbers to strings is forgetting the call command.... Example: _i = 1 _ia = "" _ib = "" _ia = call format ["ap%1g",_i] _ib = call format ["_ap%1",_i] In the above example I want to make these variables increment by one and be passed to a line of code to createunit.... Look at the result with the call command...: ap1g _ap1 Remember the point here is to get non string variables... Look at the difference if: _ia = format ["ap%1g",_i] _ib = format ["_ap%1",_i] "ap1g" "_ap1" In scripts the latter above example will not fire off error messages so you need to setup debugging measures to ensure your script fires off correctly... I can't tell you how many times I've forgotten this; thinking, "Yup, looks good." as I type up a storm in my scripts. Only to sit watching the end result with this acronym running through my head: "WTF!!!!!!!" So if I help just 1 person - even if it's myself at a later stage; as I muddle through a brain fart... It'll be worth it... |
| No Action Available | |
![]() |
|
| ww2weasel | Nov 4 2008, 12:32 PM Post #6 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
For those new to scripting. If you do not want to name the units individually as this can be very tedious and time consuming. Here are some strategies to get around this... In a leader's group init line or activation field type: group1 = group this; group1a = units group 1 Ok...... Defining the group: group1 = group this; Defining the group as array: group1a = units group 1 To define Leader of a group: Leader group1 So let's say in a script you want to move your AI troops around. Perhaps you have a mechanized squad for example and you would like to move the squad of units that are not driver and gunner of an APC (No Commander in this version. Chimera for example.) You will need to establish 3 new variables. Start with group array variable: group1a We need to isolate the Leader from Group... group1a_w_o_L = group1a - [Leader group1] The group array above has removed the Leader to enable scripting not to call on a groups leader twice. by using commands leader doMove group doFollow. So all units but leader can be called by a script. Now we need to isolate group of chimera from crew. group1a_w_o_crew = group1a - [Driver chimera1,Gunner chimera1] You need to name the Vehicle Chimera. There are scripting ways of doing this; but for the scope of this group thread I shall not list. Then to get crew isolated from group: group1acrew = [Driver chimera1,Gunner chimera1] So for example the script would work like this: driver chimera1 doMove [getPos Leader group1 select 0,(getPos Leader group1 select 1)-3,getPos Leader group1 select 2]{_x assignAsCargo chimera1,[_x] orderGetIn true} forEach group1a_w_o_crew so in the above example: The chimera drives close to it's leader and all enter into it as Cargo. Another example: group1a_squad_only = group1a - [leader group1,Driver chimera1,Gunner chimera1] leader group1 doMove getMarkerPos "movehere" {[_x] orderGetIn false} forEach group1a_w_o_crew group1a_trigger_condition doFollow leader group1 Driver chimera1 doMove getMarkerPos "movehere" ~5 ?unitready driver chimera1:chimera1 setdir getdir leader group1,chimera1 setfuel 0 The leader of mechanized group moves with all to some location. When destination reached all but crew of chimera jump out. Then variable: "group1a_squad_only" allows everyone to follow leader but leader and crew of chimera. Or if you need a trigger condition to check and see If Leader, Gunner and Driver are dead. group1a_trigger_condition = group1a - [leader group1,Driver chimera1,Gunner chimera1] Example: "!(alive _x)" count [leader group1,driver chimera1,gunner chimera1] == 3 Well there you go... To summize: You are now allowed more freedom to script without the tedium involved with naming units and limiting yourself to limited "shoebox" scripting. Addenda: To individually select units to perform tasks in scripts. Use an array selector. leadergrp = group1a select 0 --> usually is leader of group squaddie1 = group1a select 1 --> any soldier - but here is where you can decide who will do what. etc... till you get to last player in a 12 man group.... lastman = group1a select 11 --> lastman groupchat "Lastman!" Edited by ww2weasel, Nov 5 2008, 01:26 AM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Nov 15 2008, 05:50 AM Post #7 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
How to get indivual units to move around the map without giving them a name and also without giving them waypoints. 1st thing create a trigger and cover the area the indivuals are within it. In this case my example will be 16 East Side Chaos Cultists. You want to put in trigger: East Present Activate only once. Condition = true Name for trigger - in this case east1 - Triggers are referred in scripting language as list east1. Now the complicated part: cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3];cc2=[list east1 select 4,list east1 select 5,list east1 select 6,list east1 select 7];cc3=[list east1 select 8,list east1 select 9,list east1 select 10,list east1 select 11];cc4=[list east1 select 12,list east1 select 13,list east1 select 14,list east1 select 15] what the above breaks down too: cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc2=[list east1 select 4,list east1 select 5,list east1 select 6,list east1 select 7]; cc3=[list east1 select 8,list east1 select 9,list east1 select 10,list east1 select 11]; cc4=[list east1 select 12,list east1 select 13,list east1 select 14,list east1 select 15] cc1 - is a variable name I came up with to break the 16 individual chaos cultists down to an "individual" group of 4 that will closely "work" together - but yet not be yoked to a leader. Now a breakdown of variable cc1: [list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3] This is a partial array of list east1 (4 Chaos Cultists from Trigger east1) To break list east1 down to a component of 4... list east1 select 0 These four components tell the game engine what you want to select as the 1st chaos cultists for your "pseudo group" of 4 alias cc1. Psuedo group = Alias for partial array of east list1 list east1 select 1 list east1 select 2 list east1 select 3 Now the above 3 lines are selecting the next 3 chaos cultists to be included in pseudo group cc1. You will continue the above process sequentially/chronologically for the next partial arrays and their selected Chaos Cultists. So you should end up with the 4 following arrays: cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc2=[list east1 select 4,list east1 select 5,list east1 select 6,list east1 select 7]; cc3=[list east1 select 8,list east1 select 9,list east1 select 10,list east1 select 11]; cc4=[list east1 select 12,list east1 select 13,list east1 select 14,list east1 select 15] Remember inside an array items are seperated by commas. Now if you decided to do it this way look at below example. All you have done is created 4 arrays with different names covering the same 4 chaos cultists... A little counter productive don't you think? cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc2=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc3=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc4=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; or if you have typed it out this way.... cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc1=[list east1 select 4,list east1 select 5,list east1 select 6,list east1 select 7]; cc1=[list east1 select 8,list east1 select 9,list east1 select 10,list east1 select 11]; cc1=[list east1 select 12,list east1 select 13,list east1 select 14,list east1 select 15] Congratulations you have erased each previous array with last array. Alot of work just to represent only 4 Chaos Cultists... Rehashing this step.... once again a break down of the correct way for an array to look below: cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; cc2=[list east1 select 4,list east1 select 5,list east1 select 6,list east1 select 7]; cc3=[list east1 select 8,list east1 select 9,list east1 select 10,list east1 select 11]; cc4=[list east1 select 12,list east1 select 13,list east1 select 14,list east1 select 15] Break down of components: cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; The Variable cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; The ARRAY cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; The Trigger east1 cc1=[list east1 select 0,list east1 select 1,list east1 select 2,list east1 select 3]; The indiviual Chaos Cultists Ok now we covered grouping all 16 individuals into a group of 4. Now the next step - lets move the groups around.... {_x doMove getPos object 4857,_x setBehaviour "AWARE",_x setSpeedMode "FULL",_x setCombatMode "RED"}forEach cc1; {_x doMove getPos object 159547,_x setBehaviour "AWARE",_x setSpeedMode "FULL",_x setCombatMode "RED"}forEach cc2; {_x doMove getPos object 4853,_x setBehaviour "AWARE",_x setSpeedMode "FULL",_x setCombatMode "RED"}forEach cc3; {_x doMove getPos object 4847,_x setBehaviour "AWARE",_x setSpeedMode "FULL",_x setCombatMode "RED"}forEach cc4; In the above example we will set Behaviour,SpeedMode,CombatMode as well as telling the game engine where you want the partial array containing 4 chaos cultists where they should go... Now a breakdown of commands for partial array of east1 which represent 4 Chaos Cultists. {_x doMove getPos object 4857,_x setBehaviour "AWARE",_x setSpeedMode "FULL",_x setCombatMode "RED"}forEach cc1; _x is a special character to handle parced out instruction sets to arrays. _x is also considered a local variable to an array it's attached to in command execution. {} are scripting symbols which usually represent quotations. forEach is an interpreter for command sets parced to a trigger. OPflash commands: doMove getPos setBehaviour setSpeedMode setCombatMode OPflash command variable: "AWARE" "FULL" "RED" object on map - in this case a road segment: object 4857 cc1 - an array - or the partial array of trigger/list east1 So the above indicates how to move the units. But how do you get a condition to fire if the 4 chaos cultists arrive at a trigger? There are several ways: alive (list east1 select 0) || alive (list east1 select 1) (list east1 select 0) distance object 4857 <= 10 || !alive (list east1 select 0) units_left = ((count list east1) * 5) ("alive _x" count cc1) == count cc1 ("alive _x" count cc1) == 4 1st: alive (list east1 select 0) || alive (list east1 select 1) This is asking the game engine to see if the 1st 2 listed chaos cultists in trigger/list east1 are alive. An either/or operation. 2nd: (list east1 select 0) distance object 4857 <= 10 || !alive (list east1 select 0) This is asking the game Engine if a chaos cultist 1st in (trigger/list east1) is close to (road segment/object 4857) or if that same (unit/chaos cultist) is dead 3rd: units_left = ((count list east1) * 5) This is asking the game engine if there are at least 1/2 of the original members still active in array. Array components are deactivated if no longer active. Dying constitutes deactivation. 4th: ("alive _x" count cc1) == count cc1 This is asking if all of the (units/chaos cultists) are still active/alive 5th: ("alive _x" count cc1) == 4 This is the same as above.... In this case - remember we had 4 chaos cultists per array. Keep in mind all of the above examples are for a static trigger.... If the trigger that was setup for this example had been setup to fire off repeatedly... Then the trigger is considered to be a dynamic trigger. Then a whole lot needs to be changed or adjusted as the conditions and arrays will be constantly fluctuating. ***An array does not need the prefix list the way a trigger does. Look at the 2 examples below to understand.... ***units_left = ((count list east1) * 5) -----------> list east1 = trigger/array ***("alive _x" count cc1) == 4 -----------> cc1 = array This concludes this thread.... Hope it helps a mission designer out there.... Edited by ww2weasel, Nov 15 2008, 06:43 AM.
|
| No Action Available | |
![]() |
|
| ww2weasel | Nov 17 2008, 01:23 AM Post #8 |
|
Da Brainboy
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Help determining conditions... If you need a condition to determine if a unit is in vehicle. Use these - it matters not if - cargo,driver,gunner,commander.... If unit "is" in Vehicle: player in crew (vehicle jeep) If unit "is not" in Vehicle: !(player in crew (vehicle jeep)) The above examples are what's referred to as Boolean. They are either true or false. This will help to enable or disable triggers and scripts. The Two Variables in condition are: player in crew (vehicle jeep) !(player in crew (vehicle jeep)) So these commands will always remain the same: variable in crew (vehicle variable) !(variable in crew (vehicle variable)) The above is only good under these conditions.... If unit "is" in Vehicle: player in crew (vehicle jeep) -------> When player does not begin game in Vehicle. If unit "is not" in Vehicle: !(player in crew (vehicle jeep)) -------> When player does not begin game out of vehicle. Otherwise - it's alot of work just to say true or false. In other words at vert start of game; condition met and your activation event fires off immediately.... Best to use another "enabler" or "disabler" condition in conjunction with the above to handle dynamic events within game. Example: this && player in crew (vehicle jeep) -------> this = the trigger condition; like East not present..... this && !(player in crew (vehicle jeep)) -------> this = the trigger condition; like East not present..... or another trigger gets utilized in it's activation field in this manner. variable=true or variable=false The word "variable"in the above example; is any set of characters that is not reserved within the game engine.... variable && player in crew (vehicle jeep) -------> this way you can control the on/off switch in trigger activations.... variable && !(player in crew (vehicle jeep)) -------> this way you can control the on/off switch in trigger activations.... Once again I hope this helps someone. Edited by ww2weasel, Nov 17 2008, 01:56 AM.
|
| No Action Available | |
![]() |
|
| « Previous Topic · WH40K mod Mission discussion · Next Topic » |





![]](http://209.85.62.24/static/1/pip_r.png)



1:47 PM Nov 29