ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 28, 2014 12:08:35 GMT 1
I made this thread to discuss what is possible to do with script and what isn't. I hope for replies from experienced scripters. I studied deep almost every Blitzkrieg build in functions from Calvin's reference manual, mad a lot of scripts and did a lot of thinking how to make something work. For start I have few questions:
Is it possible to check how much ammo is left in a unit?
Is it possible to somehow reset which aviation was called last time in order to reserve certain aviation type for some time?
Is it possible to order infantry unit to take unmanned artillery?
|
|
|
Post by ariete on Sept 28, 2014 13:10:33 GMT 1
i've a basic knowledge about script, so take what i tell you as basic .. Is it possible to check how much ammo is left in a unit?what you need check how much ammo has left a unit? to reload it? a near cargo can do that without script command. Is it possible to somehow reset which aviation was called last time in order to reserve certain aviation type for some time?i think no. game uses the aviation you load in the relative section in the map editor. i don't know if an heavy script can call different aitcraft models, me i don't know. you can set 2 different attack ground plane models putting one in attack ground plane slot and one another in bomber slot, in the realative aviation section in map editor. Is it possible to order infantry unit to take unmanned artillery?have you already ask this? i remember someone had replied you about, but maybe i'm confusing ... anyway it seemed yes, but i don't know with script, i know you can do it with -start command- in map editor if it's the first command of the unit, then the unit can be called with a script command so the first action of the unit isn't the first action in game. you look for heavy-deep situation. if i could suggest you one, don't complicate the life (which is already so complicated), make the thing much simple, or in easy ways, they're those which give few troubles then ..
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 28, 2014 13:39:12 GMT 1
I am asking for script help only. I know how all start commands works.
Reason for first question: I would like to have enemy armored SPG when is out of ammo to move to safety and get resupplied, cause if I place supply trucks near him they will get easily destroyed in artillery attack.
I can make delay trough the script but it only works if u didn't call same aviation type twice in a row because of the way how GetAviationState() works it always return last called aviation type.
|
|
|
Post by Quintaxel on Sept 28, 2014 14:09:11 GMT 1
What about using the function GetNammo(iScriptID)to check the ammo of the SPG. When the value = 0 or gets under a certain level you move the SPG to a depot ? You could define a scriptarea around the depot and write some script to keet the supply trucks within the bounderies of that scriptarea. When the SPG comes into the script area it would resupply the SPG. It's just an idea but that is how would try to solve the problem.
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 30, 2014 15:37:06 GMT 1
I allways thought GetNAmmo() returns how much ammo unit can have. I tested it long ago on probably some faulty unit, i kept firing with it and it allways returned the same number !? Thx Quint for making me check it again. I can easily make script I wanted now.
I have another question:
How to write correctly for and if statement combined in Blitz SCITE editor:
I want for multiple units to check a condition. For example artillery with script id from 201 to 225 to check if the enemy gunners are still allive, if they are than to change side to neutral:
function Check() for i=201,225 do if GetNUnitsInScriptGroup(i,1)~=0 then ChangePlayer(i,2);
but i am not sure where to put end; and Suicide();
|
|
|
Post by Quintaxel on Sept 30, 2014 16:09:22 GMT 1
ecan,
Its quite some time since I looked at Lua but this should be the syntax.
function Check() for i=201,225 do if GetNUnitsInScriptGroup(i,1)~=0 then ChangePlayer(i,2); end; -- ending the if statement end; -- ending the for loop Suicide(); end; -- function end
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 30, 2014 16:40:39 GMT 1
Already tried that way but function does not work.
I tested even simpler function with same concept:
function Provjera() for i=100,101 do if GetNUnitsInScriptGroup(i,1)==0 then DisplayTrace("The gunners are dead."); end; end; Suicide(); end;
but it does not display anything when enemy gunners of artillery with script ID 100 or 101 are killed.
|
|
|
Post by Quintaxel on Sept 30, 2014 17:57:40 GMT 1
Ok, I'll have a look at it tonight. Have a little patience please.
|
|
|
Post by Jagged Steel on Sept 30, 2014 20:56:57 GMT 1
I don't think a check of the artillery units' crews state is necessary for what you are proposing, ecan. If they are alive at the time you want them to be turned over to Player 2 you simply do it. There is no reason for a check. If they are dead and the artillery is still intact it will by default belong to Player 2 (neutral).
|
|
|
Post by Quintaxel on Sept 30, 2014 21:04:15 GMT 1
That's correct jagged.
ecan: let me know what you want to do. I have written the script Provjera so it should work. I'll post it later.
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Sept 30, 2014 22:57:26 GMT 1
Reason I want to perform check is because when artillery change player to neutral, if u capture that artillery before change then your crew becomes neutral as well so you have to kill your own gunners in order to make artillery usable.
|
|
|
Post by Jagged Steel on Oct 1, 2014 0:51:15 GMT 1
Sounds to me like you are trying to make something simple overly complicated for no benefit. The obvious solution is to not script anything at all for this situation. Problem solved.
|
|
|
Post by Major Pain on Oct 1, 2014 6:22:07 GMT 1
The gun only goes neutral if there is no crew. No crew... neutral.
Once a new crew is assigned... by either side... the gun is no longer neutral.... it belongs to whoever mans it...
If you change the gun to neutral, and it still has a crew... the crew will become neutral with the gun...
If you then assign the gun to a player... the crew belongs to that player...
I'm not sure what you're trying to accomplish...
|
|
ecan
Zastavnik
Posts: 79
|
Post by ecan on Oct 1, 2014 9:48:09 GMT 1
I have map area that will surrender if u eliminate 70% percent of enemy units. But when artillery units surrender (AT,AA guns, MG...) if some of them are taken by player before surrender then your crew on them becomes neutral too and the artillery is not usable unless you kill your own gunners. So I want to change player only for ID units whose gunners were not killed.
No matter what I try to do , the question is till same:
How to test a single condition for multiple units (for and if statement together)?
|
|
|
Post by Quintaxel on Oct 1, 2014 11:42:27 GMT 1
The problem with what you are trying to do is that an arty unit counts for 1. So it does not matter how many members of the crew have been killed. Checking with GetNUnitsInScriptGroup will result in 1 or 0
To answer your question see the script below. The first for...do loop will put renforcements on the map. The second for...do checks the status of the arty. If you kill the crew then the arty becomes party 0 so not neutral (2). There are probably more elegant ways to deal with this but then I would need to know exactly what you want to achieve. Ï hope this helps
function Reinforce() local i DisplayTrace("running"); for i = 100,102 do DisplayTrace (i); LandReinforcement (i); end; Suicide(); end;
function Check() local j for j = 100,102 do if GetNUnitsInScriptGroup (j,1) == 0 then ChangePlayer(j,0); DisplayTrace ("Unit %g is now yours",j); end; end; end;
function Init() RunScript ("Reinforce",2000); RunScript ("Check",3000); end;
|
|