|
Post by Quintaxel on Oct 21, 2015 10:49:50 GMT 1
I’m working on a function as shown in the image below. This is how I see the function work. Mappers would have to put a number of specific units on the map. I call these guide units for now (like the officers in the example above.) These guide units have a special function. They can form a virtual track on the map that a unit will follow. The function will be triggered when a unit is placed close to a guide. The unit will then follow the path made by the guide units. There are a couple of things I still need to solve. When unit guides are too far from other unit guides then they should be ignored. This will allow the player to only use the guide units he needs. Note: The function should also work when a unit is moved close to G3 Then the unit will follow the path G3 -> G1-> G5 -> G5On the maps you have 6 guiding units ( G1,G2,G3,G4,G5 and G6) A virtual path is made by units G5, G4, G1 and G3When the unit gets close to G5 it will follow the path G5 -> G4 -> G1 -> G3The other Guide units G2 and G6 are too far from the other units and will be ignored. The unit will not continue to move along the red path. Guide units G2 and G6 could be used to make another path. Now I have a couple of questions. 1) In reality, what kind of unit would control traffic in a military situation. Would this be done by Military police ? 2) Ideally I would like a unit for which the status can be changed (or deployed) I was thinking in the line of an officer who can use binoculars. Instead of binoculars the unit could wave a flag to make it recognizable. Could such unit be made ? Any ideas here ? 3) What would be a good name for this function ? (this is one of the most difficult aspects of scripting, namely naming variables and function. )
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 21, 2015 11:40:39 GMT 1
I do not think a soldier waving a flag needed, since this function was only to airports, aircraft carriers and when soldiers surrendered. But I think that can be a simple soldier with the rank of military police or the German case, police field. If you need it we can paint in the uniform of the American soldier, the distinctive white helmets ankle sleeves and belt. classic military police. I like the idea of lua.
|
|
|
Post by Quintaxel on Oct 21, 2015 12:39:10 GMT 1
I do not think a soldier waving a flag needed, since this function was only to airports, aircraft carriers and when soldiers surrendered. But I think that can be a simple soldier with the rank of military police or the German case, police field. If you need it we can paint in the uniform of the American soldier, the distinctive white helmets ankle sleeves and belt. classic military police. I like the idea of lua. That would be great Big Joe. It would however be nice if the status of the unit could be changed (like unit uses spyglass). If the status of the unit is changed (using the spyglass Icon in the user interface) then the unit could take another distinct position. See examples below Do you think this is possible ?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 21, 2015 16:53:16 GMT 1
Everything is possible, the question is who will make changes to the sprites? I promise to make the skins for you.
|
|
|
Post by Quintaxel on Oct 21, 2015 18:45:25 GMT 1
BigJoe I do not know anything about creating sprites. I would appreciate it if you could make the skins. Please wait with the skins until I finished the scripting. I do not want you to waste your time. I create new functions for fun but there is little demand for them so I do not want you to put time and effort in stuff that will not be used.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Oct 21, 2015 21:32:49 GMT 1
Do not worry. We expect the best.
|
|
|
Post by Quintaxel on Dec 22, 2015 13:43:13 GMT 1
I scripted a new function that makes is possible to give a unit with binoculars the order to look in a given direction. There’s already a function that does something similar, namely Cmd (29, iScriptID,x,y).
Eg. Cmd (29,100, 250,1200); will make the unit with ScripID 100 look in the direction of map coordinates x = 250 and y = 1200
For this new function you do not need to know the map coordinates x and y. You just have to give the direction (or angle) that you want the unit to look at. Syntax of the function is UseBinoculars (iScripID, angle);
So what’s the big deal? There’s no big deal but this function opens a number possibilities for the use of units with binoculars.
Unlike the function Cmd (29, iScriptID,x,y) you do not have to care about the position of the unit on the map. Also units with binoculars can be give a broader field of view, making their behaviour more realistic as the unit looks in different directions.
I made a little video to demonstrate what I mean.
function Binocu100() local a = IntUnitAngle (100); -- returns the integer part of the angle of the front of the unit. local rnd = RandomInt (3) +1; -- Random number to determine the direction in which the unit will look if rnd == 1 then UseBinocularsAngle (100,a); --Use binoculars, look forward. elseif rnd == 2 then UseBinocularsAngle (100,a-45);--Use binoculars, look right. elseif rnd == 3 then UseBinocularsAngle (100,a+45);--Use binoculars, look left. end; end; The script above make makes use of the new function. It's is all quite straightforward. The officer will look through his binoculars at front, to the left of to the right at random. The function IntUnitAngle is a custom function I made to return the front direction of the unit as an integer to allow me to get the sine and cosine of the angle.
Should anyone have use for this function, just let me know.
|
|
|
Post by Herr Kodax on Dec 30, 2015 12:03:37 GMT 1
This is so awesome!
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Dec 30, 2015 20:14:24 GMT 1
Very useful function, thanks Quint.
|
|
|
Post by Quintaxel on Dec 30, 2015 22:12:02 GMT 1
Thanks for the positive feedback guys.
Just remember that this function requires a number of other functions I made. I use a function function IntUnitAngle(Angle) to round the angle that is returned form the BK function GetFrontDir (ScriptID) Because this function uses a bit of trigonometry the sine and cosine of the angle is needed so therefore you'll also need the function SineCosine(angle) Anyway no need to worry about these other functions. All you need to do is to include them in the Lua file of your map.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,361
|
Post by bb on Feb 9, 2016 23:01:06 GMT 1
A simple question for our scripters:
Once I kill one script (using the KillScript command), can I call it again?
|
|
|
Post by Quintaxel on Feb 10, 2016 19:19:50 GMT 1
bb: Call the 'killed' function again via RunScript.
|
|
|
Post by Major Pain on Feb 11, 2016 1:40:58 GMT 1
BB: Yes, just because you kill a script function does not mean it goes away. It can be called any number of times with RunScript, just like the first time or during INIT.
All you are really doing is turning off that Function. Think of it as the opposite of RunScript.
|
|
bb
General
Blitzkrieg junkie (tried to quit several times).
Posts: 1,361
|
Post by bb on Feb 11, 2016 4:01:21 GMT 1
thanks guys, I'll try it.
|
|
|
Post by Quintaxel on Feb 28, 2016 22:05:25 GMT 1
Here's another function I wrote. I try to keep the function names a bit consistent with the BK functions so I named this function GetNUnitsAlive (..)The function returns the number of units that are alive for which the ScripIds are given as an argument. It does not matter how few or many ScriptIds you give as an argument. eg. Suppose you have placed a number of AI artillery pieces on the map with ScripIDs 100,200,300,400,500. Now if you wanted to know how many units are still alive then you could use the function as follows local t = GetNUnitsAlive (100,200,300,400,500); t will be the number of units that have a unit state that is not equal to -1 The function code is no big deal but it works fine. function GetNUnitsAlive (...) -- Script by Quintaxel 27-02-2016 (Rev.1) -- Returns the number of units alive for which the ScripID's are given as an argument -- Syntax: GetNUnitsAlive (ScriptId1, ScriptID2, ScriptId3,..., ScriptIdn) -- Input parameters: ScriptID of units as arguments;
local f = 1; local alive = 0; while arg[f] ~= nil do if GetUnitState (arg[f]) ~= -1 then alive = alive + 1; end; f = f +1; end; return alive; end; I could easily modify the function so other statuses, for example to check how many units of a group are moving or attacking. I hope someone can use it.
|
|