Untermensch 0 Posted December 20, 2007 I need desperately a way of making addactions to be triggered only by a specific unit. I'm using MrMurray's artillery script but I would like to change the way the artillery is call. Currently it can be order by anybody that is in the trigger area. I would like if possible to change that to be available only to the spotter . That way I will be able to make the trigger to cover the entire island and the menu will show "call artillery" all the time only to the Spotter. (no need to go to the radio which is soooo 20th Century ). This is probably a question has been answer ad nauseam but I couldnt find the information. Another thing is: This setPos [ getPos this select 0, getPos this select 1, (getPos this select 2) -1] Honestly, I've done my homework and I'm improving my scripting abilities but, I can't make sense of that. The last number (-1) is the height that's clear but....why if I tried to change the other values the unit ends up thousands of meters away? Is it a x,y,z coordinates or something else? Thank you all Share this post Link to post Share on other sites
loyalguard 15 Posted December 20, 2007 ***Edited to answer first question*** Regarding your first question...I don't recall the specifics of Mr. Murray's script, but since it is given to all players via a trigger, one of the ways to limit would be to insert an exitWith command at/near the beginning of the script if a certain condition is not met. An easy way to determine condition is to use isKindOf to find the player's class. Here's an example: 1. Make one of the playbale units in your mission a unique class (only one position for that class). Example: SoldierWSaboteur 2. At/near the beginning of the script add a line like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if !(player isKindOf "SoldierWSaboteur") exitWith {}; What this does is as soon as the script is executed and to comes to this line, if the player is not a "SoldierWSaboteur" then script exits immediately. You can expand on the exitWith command like this to explain the reason if desired: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if !(player isKindOf "SoldierWSaboteur") exitWith {hint "You must be the spotter to call artillery"}; There are most likely other ways (altering the condition or On Act. code of the trigger) but this is an easy one I have used for other types of limiting that I recommend. Regarding your second question...here is the breakdown of the setPos Line. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setPos [getPos this select 0, getPos this select 1, (getPos this select 2) -1] The three entries in between the [ ] are the three spatial coordinates of the object: x,y,z. The reason why "x" is represented by "getPos this select 0" is because the command getPos returns the position of the object in a three-element array. element 0 = x, element 1 = X, and element 2 = z. So, in order to specify just the x coordinate you have to use the "select 0" to specify only element 0. You then repeat this for y, and z. When used with "this setPos..." you can specify "exactly" where you want the object to be placed (if you don't the position could be shifted slightly). In reference to the "-1", you are partially correct. What this does is allow us to raise or lower the object by the value of the number in meters. We enclose (getPos this select 2) in parentheses to mke it clear we want to subtract 1 from the entire element. When I gave you the example in the other thread I really should have put it like this for conformity sake: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this setPos [(getPos this select 0), (getPos this select 1), ((getPos this select 2) -1)] So, what the line above tells the game to do is "take this item and put it it exactly where it is alrady on the x and y axis BUT lower 1 meter from its current position on the z axis". Regarding the "thousands of meters away" problem you are encountering, are you using coordinates for objects as listed in the mission.sqm? if so in the mission.sqm file coordinates of objects are listed [x,z,y] format but in the editor or in scripts we use [x,y,z]. So, if you do not change them your objects will end up thousands of meters away. If that is not what you are doing can you post an example. Share this post Link to post Share on other sites
Untermensch 0 Posted December 21, 2007 Thank you LoyalGuard, that's more clear now. What I was doing was to change "this select 2" by "this select 200" that's when I got huge distances from the unit Share this post Link to post Share on other sites