Союз | Union

Объявление

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Союз | Union » News and comments » Some Shit in Script


Some Shit in Script

Сообщений 1 страница 22 из 22

1

Hi Guys,

i am trying to make a script, where type of reinforcement depends on type units which are just around the commander. But the scripts alway fail to memory error and crash :(

Please, anyone, look at it where have i mistake.................... or tell ..................... it is shit :)

--- Unit (10) is a commander and reinf: 3005 - panzers, 3100 - gun, mortar, heavy mg, 3200 - support car and medicine, 3300 - infantry

function HijackF1()
local a = GetNUnitsOfType("arm_light",0) + GetNUnitsOfType("arm_medium",0) + GetNUnitsOfType("spg_antitank",0);
local b = GetNUnitsOfType("art_mortar",0) + GetNUnitsOfType("art_heavy_mg",0) + GetNUnitsOfType("art_gun",0);
local c = GetNUnitsOfType("trn_carrier",0) + GetNUnitsOfType("trn_medicine",0) + GetNUnitsOfType("trn_support",0);
local d = GetNUnitsOfType("soldier",0) + GetNUnitsOfType("art_aagun",0);

   if GetNUnitsInScriptGroup(10) == 0 then
      Suicide();
   else
   local x,y = GetObjCoord(10);
      if GetNUnitsInCircle(a, x, y, 355) > 0 then
         LandReinforcement(3005); end;
      if GetNUnitsInCircle(b, x, y, 355) > 0 then
         LandReinforcement(3100); end;
      if GetNUnitsInCircle(c, x, y, 355) > 0 then
         LandReinforcement(3200); end; 
      if GetNUnitsInCircle(d, x, y, 355) > 0 then
         LandReinforcement(3300); end;
      RunScript("HijackF1", 1000000);
         Suicide();
      end;
   end;

Many thanks Martin

0

2

Most likely the error happens because of function misuse:

GetNUnitsInCircle (iPlayer, X, Y, Radius)

Variable substitution "a", "b", "c", "d" in parameter iPlayer causes an error as iPlayer - scripting number of the player, and variables "a", "b", "c", "d" is an amount of units of appropriate type. As soon as "a", "b", "c", "d" value more than the maximum number iPlayer, adjusted in the editor is appropriated, there is a game crash.

P.S.: the message is translated from Russian into English by means of "Promt".

0

3

Hi Reks, many thanks for answer. So this is not a way i should go on............ I have hoped, that this one could be good :( :(. I shal try another possibilities.

One more, great thanks :) :)

0

4

Guys, i would like to ask one more little thing........... How will i correctly write command where would like to result number between two values

my nonworking exapmle

local G = GetNUnitsInCircle(0, x, y, 355);

if  (G > 0 and <= 3) then
         LandReinforcement(3300);
         Suicide();

thanks martin

0

5

Does this work?

Код:
if (G>0 and G<=3) then
...
end

0

6

Hi,

not, this one is not working........ i have gave it as a example of bad one :)

0

7

Hi, would you like to look at this script. I am begining with scripting tables and not very succede in that up to now. There are 10 areas 100 - 109 and ten script id groups 100 - 109. Chtěl bych změnit přehrávač scriptId jednotku, pokud velitel vstup do skriptu oblastí.

function batch()
  RunScript("HTanksG1",5000);
end;

function HTanksG1()
local commander = 1000;
local i = 0;
local X = {100,101,102,103,104,105,106,107,108,109};
    repeat
        if (GetNScriptUnitsInArea (commander, "X[i]") == 1) then
ChangePlayer (X[i], 0);
i = i + 1;
    until(i > 10);
    Suicide ();
end;

Отредактировано SoundeluxCZ (2012-03-15 19:00:14)

0

8

SoundeluxCZ написал(а):

Chtěl bych změnit přehrávač scriptId jednotku, pokud velitel vstup do skriptu oblastí.

:dontknow:  %-)  :|
Any way, Martin your script do not increase index i, because every time script started i=0   .... it must be out of function body.

For, example
function default()
i=0; -- must be global variable
Suicide();
end;

function HTanksG1()
local commander = 1000;
local i = 0;
local X = {100,101,102,103,104,105,106,107,108,109};
    repeat
        if (GetNScriptUnitsInArea (commander, "X[i]") == 1) then
ChangePlayer (X[i], 0);
i = i + 1;
    until(i > 10);
    Suicide ();
end;

be careful with local commander = 1000;
it is every new lunch of HTanksG1 script will be 1000 again

Отредактировано vlad_82 (2012-03-16 13:14:58)

0

9

Hi Vlad, i have do some research about numerals and characters ( because area name are numerals, but script could read it as characters) maybe problem could be there. I have make easier testing scirpt, but it doesnt work up to now. :)

function HTanksG1()
local commander = 1000;
GMap = {"100","101","102","103","104","105","106","107","108","109"};
repeat
if (GetNScriptUnitsInArea (commander, GMap[i]) == 1) then
RunScript("SideChange",5000);
i = i + 1;
until(i > 10);
Suicide ();
end;
end;

function SideChange()
LandReinforcement ( 1218 );
Suicide();
end;

Отредактировано SoundeluxCZ (2012-03-16 18:05:50)

0

10

SoundeluxCZ написал(а):

( because area name are numerals, but script could read it as characters) maybe problem could be there

Could be ... I don't see any errors in the your last script  :dontknow:

0

11

Looks like the luck is going around me. Now i am little stepfar  i have put the end; after runscript and now game scripts are runing, but this one remain faulty(do not anything). I have created once more easier test.

function comm_less()
local i = 0;
local X = {1000,1001,1002,1003};
    repeat
if (GetNUnitsInScriptGroup (X[i]) < 1 ) then
        LandReinforcement (X[i]);
    end;
        i = i + 1;
    until(i > 4);
end;

which should testing every 5 minutes all commanders in game and if they are dead reinforce him. :( :(

0

12

SoundeluxCZ написал(а):

Looks like the luck is going around me. Now i am little stepfar  i have put the end; after runscript and now game scripts are runing, but this one remain faulty(do not anything). I have created once more easier test.

Looks like ok.  :dontknow:

SoundeluxCZ написал(а):

if (GetNUnitsInScriptGroup (X[i]) < 1 ) then

try to change this part. I just dislike "<1". Might be better next part  "if (GetNUnitsInScriptGroup (X[i]) == 0 ) then...."

Отредактировано vlad_82 (2012-03-20 00:57:36)

0

13

Vlad....... i am stupid foolish :)

i have forgoten create reinforcement group in mapeditor........ now it is working :) :)

But anyway big thanks, and hope it will transform to some new better maps.

Martin

0

14

Hi Vlad, and others :) :)

after some time, i would like to ask for another help. My situation is:

i have a variable number ( from 5 to zero)..... which is using as a counter: after first reinforcements, it has decreased to 4...... and etc)

function MissionStart()  -- Script that execute once immediately after game start
  DisplayTrace ("Mission Start");     --example( display the script working )
  SetIGlobalVar( "panz_cnt", 5);      --set the max-count of panzer R1 reinforcement
   SwitchWeatherAutomatic (1);         --example( Weather-condition set)
  Suicide();
end;

i would like  run another script, when variable is for example 3, 2 and 1.

My first attemp:

function test()
local k = {250,251,252};
local X = GetIGlobalVar( "panz_cnt", 0);
    repeat
        if ( X == 3[i]) then
LandReinforcement ([k]);
    i = i - 1;
    k = k + 1;
    until(i < 1);
    Suicide ();
end;

Thanks for help,

Martin

Отредактировано SoundeluxCZ (2012-06-06 18:58:56)

0

15

SoundeluxCZ написал(а):

function test()
local k = {250,251,252};
local X = GetIGlobalVar( "panz_cnt", 0);
    repeat
        if ( X == 3[i]) then
LandReinforcement ([k]);
    i = i - 1;
    k = k + 1;
    until(i < 1);
    Suicide ();
end;

Просто масса ошибок. Как я понял, вот это все и не думает работать?
Прежде чем писать скрипты, рекомендую Вам зайти на сайт Луа и внимательно ознакомиться с синтаксисом используемых функций и переменных.

1) оператор if - отсутствует закрывающий оператор end
2) какой то совершенно непонятный способ вызова элементов массива, который наверняка не будет работать
3) нет понимания термина "объявление переменных" и их "область видимости". В частности переменная "i" не ясно, из-за 1й ошибки куда относится и где объявляется.
4) Так и не понял зачем был применен оператор repeat?
5) Не понятна цель, для которой служит данная функция. То ли функция test должна просто уменьшать счетчик с каждым подкреплением, то ли она еще и должна высаживать следующее подкрепление. Если так, то при каких условиях? Или через какие промежутки времени?

Все очень непонятно. Нужно написать подробнее для чего нужна функция и что она должна делать, тогда можно чем то помочь.

0

16

Hello guys, i would like to ask some part of script which i quite dont understand. RED lines :) :)

function LR(x)
LandReinforcement(x)
end

function Rad(x)
return RandomInt(x)
end

function IPP(x)
return IsPlayerPresent(x)
end

function OHP(x)
return GetObjectHPs(x)
end

function NUA(x, y)
return GetNUnitsInArea(x, y)
end

function Reinf()
LR(step + std_reinf)
std_reinf = std_reinf + 1
if std_reinf > max_reinf then
Suicide()
end
end

function Factory()
local i = 1
while area[i] do --loop through areas
if IPP(owner[i]) == 1 then --owner check
if NUA(owner[i], area[i]) > 0 then --labor check
if OHP(id_o[i]) >= hp_o[i] * (100 - dmg_perc) / 100 then --office hitpoints check
if OHP(id_w[i]) >= hp_w[i] * (100 - dmg_perc) / 100 then --factory hitpoints check
if Office[i][owner[i]] == rf[i] then --production progress check
if ind[i] == 0 and NUA(owner[i], area[i]) >= 2 then
x = 2
else
x = 1
end
for j = 1, x do
LR(id_r[i] + Rad(rd[i]))
end
Office[i][owner[i]] = 0
else
Office[i][owner[i]] = Office[i][owner[i]] + 1
end
end
end
end
end
i = i + 1
end
end

function Init()
tf_min = 1/4 --length of production check interval (minutes); production time (min) = tf_min * reinf_factor
dmg_perc = 50 --how much can production buildings be damaged
tr_min = 10
max_reinf = 6
std_reinf = 1
step = 100
-------------------------------------------------------
tf_ms = tf_min * 60 * 1000
tr_ms = tr_min * 60 * 1000
-------------------------------------------------------
player = {0, 1, 2, 3}
area = {"FA01", "FA02", "FA03", "FA11", "FA12", "FA13", "FA21", "FA22", "FA23", "FA31", "FA32", "FA33"} --office area desc
owner = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3} --office owner id
ind = {0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0} --special reinf indicator
id_o = {1501, 1511, 1521, 1601, 1611, 1621, 1701, 1711, 1721, 1801, 1811, 1821} --office id

id_w = {1500, 1510, 1520, 1600, 1610, 1620, 1700, 1710, 1720, 1800, 1810, 1820} --factory id
id_r = {1000, 1020, 1010, 1100, 1120, 1110, 1200, 1220, 1210, 1300, 1320, 1310} --base reinf id
hp_o = {500, 500, 500, 500, 750, 500, 500, 500, 500, 500, 500, 500} --office hitpoints (max)
hp_w = {750, 750, 500, 750, 1000, 500, 1000, 750, 500, 750, 1000, 500} --factory hitpoints (max)
rf = {24, 48, 24, 24, 48, 24, 24, 48, 24, 24, 48, 24} --reinf factor (when reinf initiate)
rd = {2, 2, 2, 2, 2, 2, 4, 1, 2, 4, 1, 2} --number of diff units available in factory

-------------------------------------------------------
Office = {} --production counter
i = 1
while area[i] do
Office[i] = {}
j = 1
while player[j] do
Office[i][player[j]] = 0
j = j + 1
end
i = i + 1
end
-------------------------------------------------------
RunScript("Info0", 10000)
RunScript("Info1", 20000)
RunScript("Info2", 30000)
RunScript("Reinf", tr_ms)
RunScript("Factory", tf_ms)
end

First Office ID...... does it means a buildings or officer(soldiers) ?????

rest: truly no idea whats s going on  :blush:  :disappointed:

Thanks Martin

0

17

well i hope that understand Last line RD :) :)

M

0

18

SoundeluxCZ написал(а):

ind = {0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0} --special reinf indicator
id_o = {1501, 1511, 1521, 1601, 1611, 1621, 1701, 1711, 1721, 1801, 1811, 1821} --office id
id_w = {1500, 1510, 1520, 1600, 1610, 1620, 1700, 1710, 1720, 1800, 1810, 1820} --factory id
id_r = {1000, 1020, 1010, 1100, 1120, 1110, 1200, 1220, 1210, 1300, 1320, 1310} --base reinf id
hp_o = {500, 500, 500, 500, 750, 500, 500, 500, 500, 500, 500, 500} --office hitpoints (max)
hp_w = {750, 750, 500, 750, 1000, 500, 1000, 750, 500, 750, 1000, 500} --factory hitpoints (max)
rf = {24, 48, 24, 24, 48, 24, 24, 48, 24, 24, 48, 24} --reinf factor (when reinf initiate)
rd = {2, 2, 2, 2, 2, 2, 4, 1, 2, 4, 1, 2} --number of diff units available in factory

I do not understand, what you want and where this script captured from.  :question:
This lines open arrays and set values as well.
id_o[2-index]=1511

For example,
local b={6,8,4};
local a=b[2]; –>  a=8

Arrays help avoid to create a lot of values and for some programming methods  :writing:

0

19

HI Vlad, it is old script from archive bkportal web :) i have thought if you will able to find a way what these lines managing in script above.

i have decoded last line myself and know what it should "do"

for example

rd = {2, 2, 2, 2, 2, 2, 4, 1, 2, 4, 1, 2} --number of diff units available in factory

for j = 1, x do
LR(id_r[i] + Rad(rd[i]))

in fact it is land reinforcement and amount of randominit posibilities. But these two lines i dont know what the managing in script above

ind = {0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0} --special reinf indicator
rf = {24, 48, 24, 24, 48, 24, 24, 48, 24, 24, 48, 24} --reinf factor (when reinf initiate)

Generaly script should managing reinforcents for 4 players by keeping twelve areas and protecting buildings it that areas. Every player have to protect three areas :) :)

Martin

Отредактировано SoundeluxCZ (2012-09-23 00:43:24)

0

20

SoundeluxCZ написал(а):

ind = {0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0} --special reinf indicator

Probably, it is twin separator. 1 of 3 case work only (or not work)

SoundeluxCZ написал(а):

rf = {24, 48, 24, 24, 48, 24, 24, 48, 24, 24, 48, 24} --reinf factor (when reinf initiate)

Look the same method but figures are differents

It is realy hard to understand allien thoughts  :dontknow:

0

21

Thanks Vlad :)

after some tweak i have been able to run script in game, so i can check it in game. Hope will able to research more about it. But anyway it is demonstration how might could be arrays.

Here is link to that archive ....... maybe it could be helpful for someone  like me :)

http://bkpforums.com/phpBB2/viewtopic.p … lit=nparty

0

22

Hi guys,

finally i have finished searching a factory script showed above. Those unknown lines probably mean different times of each production(reinforcements) :) Then i have prepared a new map with this factory script.
Well, now every player has a three Factories/Warehouses with Office building around. (Panzer, Infantry, Heavy artillery) For producing units plaeyers have to keep at least one unit inside those areas (near buildings) and HP of both ones has to be more than 50%. In total, thera are 12 factories in the game. For better players overview , Support vehicles of all players  will run toward the factories when they first come( few time after start game)................... so let them go there :)

Second line of reinforcemenst is by holding flags (nparty script). This reinf are weaker, but it can be called in shorter time and neverendless. Factory units can be produced only six times in the game.

http://uploaded.net/file/dsk3mgqb/[GZM7]Nordfront_alpha.pak

Because i have not time to test map there can be a potencional bugs, please report me ( best way with rpl files) and i will fix it in short time. :)

Have a nice day
Martin

Отредактировано SoundeluxCZ (2012-10-31 14:51:57)

+1

Похожие темы


Вы здесь » Союз | Union » News and comments » Some Shit in Script