|
Post by Stanenberg on Jan 22, 2018 20:00:40 GMT 1
In a script, as how many units does infantry count? Does each soldier count as one unit or does a squad count as one unit?
|
|
|
Post by Quintaxel on Jan 22, 2018 20:05:50 GMT 1
For the function GetNUnitsInParty(iPlayer) An infantry squad counts as 1 unit. So does an artillery unit. When all gunners are killed then the artillery unit will count as 0.
When you use the function GetNUnitsInCircle(iPlayer, X, Y, Radius) or GetNUnitsInArea(iPlayer, strScriptAreaName) then an infantry squad returns the number of men which it a composes and an artillery unit counts for 3 men + the artillery unit (=4)
|
|
|
Post by Quintaxel on Apr 6, 2018 20:38:20 GMT 1
vonosten question inspired me to do some scripting. Suppose that you want to put units on the map as reinforcements but that you want to make these units invisible to the AI then this could be done with a little scripting. Nothing exotic, just using plain BK functions. This is the idea. Put reinforcements on the map as neutral units. The AI will not attack neutral units when they are in range nor will neutral units trigger artillery when they are spotted by recon planes. However when a player unit is in plane sight of an AI unit then it's not realistic if the unit is simply ignored. So to add a bit of realism we can camouflage the unit. This is done by putting 'flora reinforcements' on top of the units that were sent in as reinforcements. Another possibility is to put units under a camouflage tent. These objects are use in Panzerkrieg. The script speak for itself. function Cammo ()
LandReinforcement (200);
DisplayTrace ("Units get a camouflage");
RunScript ("MoveAIUnit", 2000);
Suicide ();
end;
function Reinforce ()
LandReinforcement (100);
DisplayTrace ("Units have arrived");
Suicide ();
end;
function CheckTrigger ()
if GetNScriptUnitsInArea (50,"Trigger") == 1 then
DisplayTrace ("Units will now change party");
RunScript ("ChangeParty",3000);
Suicide();
end;
end;
function ChangeParty()
DisplayTrace ("The units will now come out of hiding");
ChangePlayer (100,0); --The units change from neutral to player party. Cmd (0,100, GetScriptAreaParams ("Trigger"));
DamageObject (200,0);
KillScript ("CheckTrigger");
Suicide ();
end;
function MoveAIUnit() -- makes the enemy units move. Cmd (3,600, GetScriptAreaParams ("a"));
QCmd (3,600, GetScriptAreaParams ("b"));
QCmd (3,600, GetScriptAreaParams ("c"));
QCmd (3,600, GetScriptAreaParams ("d"));
Suicide ();
end;
function Init()
ViewZone ("View",1);
DisplayTrace ("Init is Running");
RunScript ("Reinforce", 3000);
RunScript ("Cammo", 6000);
RunScript ("CheckTrigger",3100);
end;
|
|
|
Post by Quintaxel on May 12, 2018 23:06:56 GMT 1
I would like to script a weather forecast function. The idea is that the script gives the odds of the weather getting bad (rain, desert storm or snow = no air support) and the chance it get's better (clear = air support). The forecast could be displayed with intervals of let's say 5 minutes and could be a function of the place and time of year.
So with fixed intervals you would get a message like;
"The weather is steady, chance of rain in the next 5 minutes is 15 %.
The scripting itself should not be that difficult but is there someone who knows more about models to calculate probability for weather ?
|
|
|
Post by Quintaxel on May 13, 2018 14:49:59 GMT 1
I'm wondering if it would be interesting to have a weather forecast in BK or if there's no real added value in it ? I have seen this in turn based strategy games like Panzer Korps where the weather forecast plays a major role in the game. Launch an attack when there is a bad weather forecast and changes are high that you will not be able to count on air support just when you needed it the most. The weather will also have an effect on the passability of the terrain. A function for BK forecast the weather could influence the availability of air support (all types disabled or some, depending on actual weather). Changing the passability of the terrain could be challenging but not impossible. The 'weather forecast function' would have to give the chance of what the weather will be in the next time frame. The odds that the weather is as forecasted would be like 80%. So suppose the function predicts 'slightly overcast' for the next period then there's a chance of 80% that this will be the case. However, like in reality the weather might improve to 'sunny' or go to 'heavily overcast' or 'rain'. The challenge is that weather still follows a pattern in most cases. The odds of going from sunny to heavy rain and visa versa are are smaller then let's say going from 'sunny' to 'slightly overcast'. I would be interested in how other forum members see this, so feel free to share your thoughts.
|
|
|
Post by Quintaxel on May 15, 2018 22:10:32 GMT 1
I have been thinking about a weather model for BK as a function. So far I'm thinking along the way of having about 10 types of weather that could change at fixed or random intervals in a game. Let's say the current weather is 'clear4'. Then the weather could change along the following pattern. It gets 'worse' going or it gets 'better'. I call this the 'trend'. In reality weather would not switch from one extreme to the other but it also follows a trend. Now again let's say that the trend is 'worse'. Then the possibilities of a change in weather could change depend on the result of a randomly generated number. The number would be used to decide that a) the weather stays the same b) the weather gets worse by 1 step c) the weather gets worse by 2 steps d) the trend changes to 'better' I'm have not figured out how exactly the weather should change but the idea is that the odds of the weather switching from 'Clear4' to 'Clear5' should be higher then the odds of changing form clear4 to 'Mostly Clear'. The odds that the weather remains unchanged should be the highest. When the weather changes to rain then aviation will become unavailable and the terrain could get muddy in some places. After the rain the weather could go back to 'clear'. I hope this makes sense.
|
|
|
Post by Quintaxel on May 16, 2018 21:29:19 GMT 1
I did some first quick trials with the weather function now. I've decided to have two functions The first function GetWeatherForecast () will return...... right a weather forecast. This is what the function does; It forecasts the weather trend, so if the weather gets better, worse or remains unchanged. For now the odds are; 80% chance that the weather trend does not change. 20% chance that the weather trend switches direction. The function also forecasts the number of steps the weather moves in the trend. for now the odds are; 0 steps : 70 % change 1 step : 30 % chance 2 steps : 20 % chance 3 steps : 10 % chance The second function SwitchWeatherForecast () will take the result returned by the function GetWeatherForecast () and change the actual weather. That is there is an 80 % chance that the weather actually changes to the weather forecast. So the player should get feedback at fixed intervals about the actual weather and the weather forecast. More later.
|
|
Grot
General
J-23 znowu nadaje
Posts: 4,049
|
Post by Grot on May 16, 2018 22:18:59 GMT 1
caught in bad weather
|
|
|
Post by Quintaxel on May 26, 2018 18:00:56 GMT 1
I found some time to put he idea of a function to forecast the weather. In fact I ended up with two functions. function ShowWeatherForecast () to Display the current weather and a weather forecast and a second function GetWeatherForeCast (currentWeather) to generate a weather forecast. As I explained earlier the idea is that a set intervals the player will get information about the current weather and a weather forecast for the next interval. So suppose the function runs every 5 minutes then the player will see something like this; This means that the weather will remain 'cloudy, but lucid' for the next 5 minutes and could then chance to overcast. The weather forecast is 80 % accurate. This means that in 8 out of 10 times the weather will switch as forecasted. In 2 out of 10 times the weather will remain unchanged. I'm aware that this is not realistic as in reality the weather could also change to another type of weather then the weather that was forceasted. This would need fine tuning in a future version. At the next interval a new weather forecast is displayed. As forecasted the weather has changed from 'cloudy, but lucid' to 'overcast'. The weather forecast for the next turn is 'overcast now'.
The weather changes do not have an effect until it rains and aviation becomes unavailable but there are other possibilities. Depending on the weather you could script that only certain aviation types become available. I did a test with changing the terrain when it rains, making certain areas of the map impassable. The terrain becomes impassable for all types of units but I would now need a terrain object that is only passable by armour and squads but not units of the type 'auto'.
|
|
|
Post by Quintaxel on Jul 25, 2018 13:49:16 GMT 1
This is a little script that was requested by ranjid . The question is to put a reinforcement group on the map at given intervals for a limited number of times. I'm also needed something similar for a SH script Im working on so I tried to kill two birds with one stone. For the timing I use an exiting function that keeps track of the number of minutes and seconds that passed since it was called. function MissionTimer()
local minutes, seconds;
minutes = GetIGlobalVar("TimerMinutes", 0);
seconds = (10 + GetIGlobalVar("TimerSeconds", 0));
if(seconds == 60) then
seconds = 0;
minutes = 1 + minutes;
SetIGlobalVar("TimerMinutes", minutes);
end;
SetIGlobalVar("TimerSeconds", seconds);
end; The function MissionTimer() runs every 6000 miliseconds (10 seconds) A second function <SpawnReinfGroup_100 ()> runs ever 8000 miliseconds (8 seconds) and checks the minutes and seconds that have past. function Init() RunScript ("MissionTimer",10000); RunScript ("SpawnReinfGroup_100",8000); end; The function SpawnReinfGroup_100() is quite basic. When the condition in the if ...then statement are met then the reinforcement group is placed on the map. SpawnReinfGroup_100()
local m = GetIGlobalVar("TimerMinutes",0); local s = GetIGlobalVar("TimerSeconds",0);
if m == 0 and s == 50 then -- reinforce after 50 seconds LandReinforcement (100); end;
if m == 1 and s == 30 then --reinforce after 1 minute, 30 seconds LandReinforcement (100); end; if m == 2 and s == 20 then -- Reinforce after 2 minutes, 20 seconds LandReinforcement (100); Suicide (); -- function is no longer needed. end; end;
The timing for running SpawnReinfGroup_100() is important. The interval should higher than 5000 lower than 10000. If the timing would be set at, let's say 2000 milliseconds then the conditions for putting reinforcements will be checked every 2 seconds. As the timer runs only every 10 seconds this would mean that the conditions for putting reinforcement on the map are met 5 times before the timer changes, except for the reinforcement put on the map after 2 minutes and 20 seconds because of the Suicide () function. The scripting is very basic and could be tuned to make it more flexible but this will do for now I guess. Note: The timer function uses the functions GetIGlobalVar and SetIGlobalVar.
Alternatively the function could also work with global variables, so variables that have not been declared as local.
|
|
|
Post by ranjid on Jul 25, 2018 14:00:04 GMT 1
Thanks Quintaxel ! I will test that later. Interesting would be too to have for both sides seperate "commands". For example that player0 get his "firstwave" after 2 minutes, then "secondwave" after 4 minutes and player1 get his one and only wave for example after 3 minutes.
I send you 3 maps Quintaxel for what I would have no skills to do that alone. Check please that out and let me know that is possible or not. If there would be any issuse then I would change there something befor the missions would get a script.
|
|
|
Post by Quintaxel on Jul 25, 2018 14:16:25 GMT 1
Should be no problem, just change the time condition and the reinforcement group you want to put on the map. for example
Reinforcement group 100 belongs to player 1 Reinforcement group 200 belongs to player 2
function SpawnReinfGroups()
local m = GetIGlobalVar("TimerMinutes",0); local s = GetIGlobalVar("TimerSeconds",0); if m == 2 and s == 0 then LandReinforcement (100); end;
if m == 3 and s == 0 then LandReinforcement (200); end; if m == 4 and s == 0 then LandReinforcement (100); Suicide (); end; end;
|
|
|
Post by ranjid on Jul 25, 2018 16:31:08 GMT 1
My script looks now like that:
That for 1 mission.
If I want 1 more or 1 lower reinforcement then I need to add/delete only one of that here:
Correctly?
If looks all fine I would add it for my maps.
|
|
|
Post by Quintaxel on Jul 25, 2018 18:36:38 GMT 1
Looks fine to me. I don't exactly understand what you mean with one more ore 1 lower reinforcement but all you have to do is add an if condition to the SpawnReinfGroup_100 function. You can add any reinforcement groups at any time in the game. It's that easy Just put the if statements in chronological order. I mean put the if...then statements in the order that the reinforcements will be placed on the map and remember to finish the last if statement with Suicide ();
If you don't do this then it's the function will work but its good practice to stop a function from running when it is no longer needed. Hence the Suicide () function. SpawnReinfGroup_100()
local m = GetIGlobalVar("TimerMinutes",0); local s = GetIGlobalVar("TimerSeconds",0);
if m == 3 and s == 0 then LandReinforcement (200); LandReinforcement (200); LandReinforcement (200); end;
if m == 2 and s == 0 then LandReinforcement (100); end;
if m == 6 and s == 0 then LandReinforcement (300); end;
if m == 10 and s = 30 then LandReinforcement (100); LandReinforcement (300); LandReinforcement (200); Suicide (); end; end;
|
|
|
Post by ranjid on Jul 25, 2018 18:52:50 GMT 1
what I mean with that is if you want more waves as only 1 or 2 then add only the small part
yeah? But you answered my question with your reply right now. I tested the lua script and it do not work. The units are hidden but I get no reinforcements after few minutes. I made time speed up to 10x and waited 1-2 minutes and nothing happened.
I will test it later chronogical order. If there will be any issuse I will let you know what happened. Same if that work.
|
|