unit Effects;

interface
Uses
  GLVectorFileObjects, GLGeomObjects, GlObjects,
  Forms, SysUtils, Map, quod_A,
  GlFileSMD, VectorGeometry, GlScene, Model;

Procedure Blood(EX2:integer);

Procedure EffectWork;

var
BloodCube, BloodC2: TglDummyCube;
Time, KrolikTime : byte;
BloodPar, DemagePar:   TGLActor;
BloodParP: array[1..10] of TGLProxyObject;
BloodAnimation, FiteT, AnimS, DemageAnimation:byte;
AnimST : integer;
BloodL : Tglpolygon;
implementation
uses
Shoot;

Procedure Blood(EX2:integer);
var
  BI, BL : byte;
begin
   if BloodAnimation<1 then
   begin
        BloodAnimation:=50;

        for BL:=1 to random(15) do
        begin
        BloodL:=TGLPolygon(BloodC2.AddNewChild(TGLPolygon));
        BloodL.AddNode(-0.5, 0.5,0);
        BloodL.AddNode( 0.5, 0.5,0);
        BloodL.AddNode( 0.5,-0.5,0);
        BloodL.AddNode(-0.5,-0.5,0);
        BloodL.Scale.Y:=random(10)/21;
        
        BloodL.Scale.X:=BloodL.Scale.Y+random(5)/100;
        BloodL.RollAngle:=random(91)*2;

        BloodL.Position.Z:=Model.Pers[EX2].A.Position.Z-0.501+(random(100)/10000);
        BloodL.Position.X:=Model.Pers[EX2].A.Position.X+random(10)/10-0.5;
        BloodL.Position.Y:=Model.Pers[EX2].A.Position.Y+random(10)/10-0.5;
        BloodL.Material.MaterialLibrary:=ML2;
        BloodL.Material.LibMaterialName:='B'+inttostr(random(5));
        end;

        BloodCube.Visible:=true;
        BloodCube.Position.Z:=Model.Pers[EX2].Au.Height / 1.8;
        BloodCube.Position.X:=Model.Pers[EX2].A.Position.X;
        BloodCube.Position.Y:=Model.Pers[EX2].A.Position.Y;

        BloodCube.Scale.SetVector(0.07,0.07,0.07);


        for BI:=1 to 10 do
        if BloodParP[BI]=nil then begin
        BloodParP[BI]:=TGLProxyObject(BloodCube.AddNewChild(TGLProxyObject));
        With BloodParP[BI] do
           begin
            ProxyOptions:=[pooObjects];
            MasterObject:=BloodPar;
            Scale.SetVector(0.1*bi,0.1*bi,0.1*bi);
            Position.Z:=-BI*0.3+random(5);
            RollAngle:=BI*10*random(5);
          end;
        end;
    end;
end;

Procedure EffectWork;
begin
  if BloodAnimation>0 then BloodAnimation:=BloodAnimation-1
  else if BloodCube<>nil then BloodCube.Visible:=false;
  if DemageAnimation>0 then DemageAnimation:=DemageAnimation-1
  else if DemagePar<>nil then DemagePar.Visible:=false;

end;
end.
