SAIL - Przejęcie, Zapis budowli bez ID

Gotowe kody SAIL'a, informacje na temat moddingu, itd.

Модератор: zoNE

User avatar
zoNE
The Great Uniter & Site Administrator
The Great Uniter & Site Administrator
Сообщения: 2061
Зарегистрирован: Fri Feb 17, 2006 3:44 pm
Location: Poland
Контактная информация:

SAIL - Przejęcie, Zapis budowli bez ID

Post zoNE »

Gogeta103 wrote:Co do laboratorium:

Code: Select all

export budovy, depot, deport,buii;
on BuildingComplete(build) do
begin
   budovy:=budovy union build;

   if GetBType(build)=b_lab then begin
//kod;
  end;
end;
Co to małp:

Code: Select all

every 0$1 trigger FilterAllUnits([f_class,class_apeman])>=5 do
begin
//kod;
end;

class_apeman - Czyli zwykłe małpy a jeżeli chciał byś żeby po zrobieniu 5 małp inżynierów wystarczy zmienić na  class_apeman_engineer 
Co do budynków:
Zapis

Code: Select all

export function Save;
var baza, tmp, t;
begin
    kair:=[];
    for t in tmp do begin
      case getbtype(t) of
        b_lab_basic,b_lab_weapon,b_lab_biological,b_lab_computer,b_lab_opto,b_lab_siberium,b_lab_spacetime:begin end;
        b_lab,b_lab_half,b_lab_full:baza:=baza^[[GetX(t),GetY(t),GetDir(t),GetBType(t),GetBLevel(t),GetLabKind(t,1),GetLabKind(t,2)]];
        b_bunker,b_turret:baza:=baza^[[GetX(t),GetY(t),GetDir(t),GetBType(t),GetBLevel(t),GetBWeapon(t)]];
        else baza:=baza^[[GetX(t),GetY(t),GetDir(t),GetBType(t),GetBLevel(t)]];
      end;
    end;
    SaveVariable(baza, 'baza);
End;
Odczyt

Code: Select all

function base;
var i, tmp, btype, baza;
begin
    InitUc;
    InitHc;
    InitBc;
    uc_side:=1;
    uc_nation:=nation_american;

  //seznam budov
  //[x,y,direction,building_type,level]
    baza:=LoadVariable('baza',[]);
    if not baza then msg('bad save');
    for i in baza do
        btype:=btype^ i[4];
    SortListByListAsc(baza, btype);
    for i in baza do begin
        bc_type:=i[4];
        bc_level:=i[5];
        case bc_type of
             b_lab,b_lab_half,b_lab_full: begin
                                             bc_kind1:=i[6];
                                             bc_kind2:=i[7];
                                          end;
                                end;
                      end;
            end;
Co do odczytu i zapisu bazy to nie jestem pewien


Dropsik jak nie wiesz i nie udzielasz dokładnej odpowiedzi to nie pisz
Gothuk wrote:1. budovy:=budovy union build;
Jak kopiujesz to tylko potrzebne elementy :P.
do tej operacji wystarczy tylko:

Code: Select all

on BuildingComplete(build) do 
begin 
   if GetBType(build)=b_lab then 
   begin 
     //kod; 
   end; 
end;
2. Co do małp Gogeta103 powinieneś dodać jeszcze stronę małp, bo tak filtrowanie zwróci wszystkie małpy na mapie.

Code: Select all

every 0$1 trigger FilterAllUnits([[f_side,1], [f_class,class_apeman]])>=5 do
3. Do zapisywania bazy to zapomniałeś dać co to tmp:

Code: Select all

tmp:=FilterAllUnits([[f_side,1],[f_type,unit_building]]);
to pownno być nad pętlą

Code: Select all

for t in tmp do begin
Ahh i bym zapomniał tablicę

Code: Select all

kair:=[];
należy zamienić na

Code: Select all

baza:=[];
:D.

4. Odczytywanie.
W "case bc_type of" należy jeszcze coś dodać (i usunąć zbyt wielką ilość end; na końcu) ^^.

Code: Select all

function base; 
var i, tmp, btype, baza; 
begin 
    InitUc; InitHc; InitBc; 
    uc_side:=1; 
    uc_nation:=nation_american; 

    baza:=LoadVariable('baza',[]); 
    if not baza then msg('bad save'); 
    
    for i in baza do 
        btype:=btype^ i[4]; 
    SortListByListAsc(baza, btype); 
    
   for i in baza do begin 
        bc_type:=i[4]; 
        bc_level:=i[5]; 
        case bc_type of 
             b_lab, b_lab_half, b_lab_full: 
                begin 
                   bc_kind1:=i[6]; 
                   bc_kind2:=i[7]; 
                end; 
            b_bunker, b_turret: 
                begin
                    weapon= i[7];
                end;
        end;
        tmp:=CreateAndPlaceBuildingXYD(i[1], i[2], i[3]);
        if weapon then
           PlaceWeaponTurret(tmp, weapon);
    end;
Gogeta103 wrote:Spróbuj tego:
Zapis

Code: Select all

every 0$10 do
var kair, tmp, t, filter;
begin

    kair:=[];
    filter:=FilterAllUnits([[f_side,2],[f_btype,b_factory,b_warehouse]])^
            FilterAllUnits([[f_side,2],[f_type,unit_building],[f_not,[f_btype,b_factory,b_warehouse]]]);
    for un in filter do
    begin
      if GetBType(un) in [b_lab, b_lab_half, b_lab_full] then
        kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un),GetLabKind(un,1),GetLabKind(un,2)]]
      else
        if GetBType(un) in [b_bunker,b_turret] then
          kair:=kair^[[getbtype(un),getx(un),gety(un),getdir(un),getblevel(un),getnation(un),getbweapon(un)]];
      else
        if GetBType(un) in [b_oil_mine,b_oil_power,b_solar_power,b_siberite_mine,b_siberite_power] then
          kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un)]]
      else
          kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un)]];
    end;
    SaveVariable(kair,'kair');
end;
Zapisuje jak widać:
elektrownie,laboratoria,fabryki,warsztaty,bunkry,szyby i kopalnie.

Odczyt

Code: Select all


var zakladna,tmp,tmp1,x,y,r;

starting
begin
  if testvariable('kair') then zakladna=loadvariable('kair',[])
  else msg('neny kair');

  uc_nation=nation_arabian;
  uc_side=2;
  x=0;y=0;
  for tmp in zakladna do
    case tmp[1] of
      b_lab,b_lab_half,b_lab_full:begin
        bc_type=tmp[1];
        bc_level=tmp[5];
        bc_kind1=tmp[6];
        bc_kind2=tmp[7];
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]);
        x=x+tmp[2];y=y+tmp[3];
        setLives(tmp1,1000);
      end;
      b_bunker,b_turret:begin
        bc_type=tmp[1];
        bc_level=tmp[5];
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]);
        if tmp1 then placeweaponturret(tmp1,tmp[6]);
        x=x+tmp[2];y=y+tmp[3];
      end;
      b_oil_mine,b_oil_power,b_solar_power,b_siberite_power,b_siberite_mine:begin
        bc_type=tmp[1];
        bc_level=tmp[5];
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]);
        x=x+tmp[2];y=y+tmp[3];
      end;
   end;
end;
To jest przykład z mojej kampanii więc wyrazy typu "kair" nie wchodzą w grę.
Gothuk wrote:gogeta nie musiałeś się meczyć ^^, pisałem potem do jeanksa i zrobił (tzn nie zrobił xD) to co myślałem, czyli wywołanie funkcji w kodzie, czyli odpowiednio:

Code: Select all

save;
i

Code: Select all

base;


[ Dodano: Nie Gru 28, 2008 22:09 ]
poza tym dziwnie to robisz ^^
1.

Code: Select all

 filter:=FilterAllUnits([[f_side,2],[f_btype,b_factory,b_warehouse]])^ 
            FilterAllUnits([[f_side,2],[f_type,unit_building],[f_not,[f_btype,b_factory,b_warehouse]]]);
wpierw szukasz warsztatu lub fabryki, dodajesz do filter, a potem jeszcze dodajesz reszte budynkow, oprocz warsztatu i fabryki. Przecież da się to zapisać:

Code: Select all

 filter:=FilterAllUnits([[f_side,2],[f_type,unit_building]]);
2.

Code: Select all

else 
        if GetBType(un) in [b_oil_mine,b_oil_power,b_solar_power,b_siberite_mine,b_siberite_power] then 
          kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un)]] 
      else 
          kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un)]];
ten kod można zastąpić krócej:

Code: Select all

else 
        kair:=kair^[[GetBType(un),GetX(un),GetY(un),GetDir(un),GetBLevel(un),GetNation(un)]] 
      
no chyba, że chcesz zapisać tylko te budynki.

3.

Code: Select all

x=0;y=0;
i dalsze zabawy w dodawanie do x i do y.
Do czego to ma służyć xD?

4.

Code: Select all

for tmp in zakladna do 
    case tmp[1] of 
      b_lab,b_lab_half,b_lab_full:begin 
        bc_type=tmp[1]; 
        bc_level=tmp[5]; 
        bc_kind1=tmp[6]; 
        bc_kind2=tmp[7]; 
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]); 
        x=x+tmp[2];y=y+tmp[3]; 
        setLives(tmp1,1000); 
      end; 
      b_bunker,b_turret:begin 
        bc_type=tmp[1]; 
        bc_level=tmp[5]; 
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]); 
        if tmp1 then placeweaponturret(tmp1,tmp[6]); 
        x=x+tmp[2];y=y+tmp[3]; 
      end; 
      b_oil_mine,b_oil_power,b_solar_power,b_siberite_power,b_siberite_mine:begin 
        bc_type=tmp[1]; 
        bc_level=tmp[5]; 
        tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]); 
        x=x+tmp[2];y=y+tmp[3]; 
      end; 
   end;
zastąpił bym na coś krótszego ^^

Code: Select all

for tmp in zakladna do 
begin
   lab=0; weapon=0;
   bc_type=tmp[1]; 
   bc_level=tmp[5];
   case tmp[1] of 
      b_lab,b_lab_half,b_lab_full:begin 
        bc_kind1=tmp[6]; 
        bc_kind2=tmp[7];
        lab=1; 
      end; 
      b_bunker,b_turret:begin 
        weapon=1;
      end; 
   end;
   tmp1=createandplacebuildingxyd(tmp[2],tmp[3],tmp[4]); 
   if lab=1 then setLives(tmp1,1000); 
   if weapon=1 then placeweaponturret(tmp1,tmp[6]);
end;
Author: Gogeta103 & Gothuk
Topic: http://forum.original-war.net/viewtopic.php?t=1288