0 Members and 1 Guest are viewing this topic.
const KillsPerMine = 1; //Number of kills needed to create mines, set to 0 to disable mines DistanceMinesToFlag = 175; //Distance from flags to create mine MineMaxDuration = 160; //Seconds to automatic detonate mines cMine = $00AF78;
unit Mines;interfaceimplementationconst KillsPerMine = 1; //Number of kills needed to create mines, set to 0 to disable mines DistanceMinesToFlag = 175; //Distance from flags to create mine MineMaxDuration = 160; //Seconds to automatic detonate mines cMine = $00AF78;//Mines script v0.0.0.1 SC3 by Dominiktype tMine = record owner: byte; duration: integer; X,Y: single;end;var FlagX, FlagY: array[1..2] of single; soldier: array[1..32] of integer; mine: array[1..32] of tMine; Decl: byte; isCompile: boolean; procedure PlantMine(ID: byte);var placed: boolean; i: byte; X,Y: single;begin if (soldier[ID] >= KillsPerMine) then begin if (Players[ID].Alive) then if (Players[ID].OnGround) then begin case (Players[ID].Team) of 1: begin X:=FlagX[1]; Y:=FlagY[1]; end; 2: begin X:=FlagX[2]; Y:=FlagY[2]; end; end; if (Distance(Players[ID].X,Players[ID].Y,X,Y) > DistanceMinesToFlag) then begin placed:=false; i:=1; while (placed = false) and (i < 33) do begin if (mine[i].duration = 0) then begin placed := true; mine[i].duration := MineMaxDuration; mine[i].owner := ID; mine[i].X := Players[ID].X; mine[i].Y := Players[ID].Y; soldier[ID] := (soldier[ID]-KillsPerMine); Map.CreateBullet(Players[ID].X,Players[ID].Y-25,0,-3.5,0,7,Players[ID]); Players[ID].BigText(18,'Mine placed.'+chr(13)+chr(10)+'Keep distance to activate it.',220,cMine,0.112,20,360); end; i:=(i+1); end; if (placed = false) then Players[ID].WriteConsole('Mine count limit exceeded.',cMine); end else Players[ID].WriteConsole('Mines can not be placed that close to your flag.',cMine); end else Players[ID].WriteConsole('Mines can only be placed on the ground.',cMine) else Players[ID].WriteConsole('Mines can not be placed while dead.',cMine); end else Players[ID].WriteConsole('You need '+inttostr(KillsPerMine-soldier[ID])+' more kills to plant a mine',cMine);end;procedure AppOnIdle(Ticks: integer);var i, j: integer;begin if (isCompile=false) then begin isCompile := True; FlagX[1] := round(Map.RedFlag.X); FlagY[1] := round(Map.RedFlag.Y); flagX[2] := round(Map.BlueFlag.X); FlagY[2] := round(Map.BlueFlag.Y); end; for i:=1 to 32 do if (mine[i].duration > 0) then begin mine[i].duration := (mine[i].duration-1); if (mine[i].duration=0) then begin Map.CreateBullet(mine[i].X+20,mine[i].Y-5,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X-20,mine[i].Y-5,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X,mine[i].Y-22,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X,mine[i].Y,0,10,25,4,Players[mine[i].owner]); Players[mine[i].owner].WriteConsole('One of your mines has exceeded duration and blew up.',cMine); end else for j := 1 to 32 do if ((Players[j].Active) and (Players[j].Team<5) and (Players[j].Team<>Players[mine[i].owner].Team)) then if ((Distance(Players[j].X,Players[j].Y,mine[i].X,mine[i].Y)<55) and (Distance(Players[mine[i].owner].X,Players[mine[i].owner].Y,mine[i].X,mine[i].Y)>80)) then begin Map.CreateBullet(mine[i].X+20,mine[i].Y-5,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X-20,mine[i].Y-5,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X,mine[i].Y-22,0,0,25,4,Players[mine[i].owner]); Map.CreateBullet(mine[i].X,mine[i].Y,0,10,25,4,Players[mine[i].owner]); mine[i].duration := 0; Players[mine[i].owner].WriteConsole(Players[j].Name+' stepped into one of your mines.',cMine); Players[j].BigText(18,'Baaammm!!',300,cMine,0.15,60,360); end; end;end;function CommandEvent(Player: TActivePlayer; Command: string): boolean;begin if (Command = '/mine') then if (KillsPerMine > 0) then PlantMine(Player.ID) else Player.WriteConsole('Mines are disabled',cMine); Result := false;end;procedure OnFlagScore(Player: TActivePlayer; Flag: TActiveFlag; Team: Byte);begin if (KillsPerMine > 0) then begin soldier[Player.ID] := (soldier[Player.ID] + KillsPerMine); Player.WriteConsole('You were rewarded with one nade for scoring. Plant it with /mine',cMine); end;end;procedure BeforeMapChange(NewMap: string);var i: byte;begin for i := 1 to 32 do begin mine[i].duration := 0; soldier[i] := 0; end;end;procedure AfterMapChange(Next: string);begin if (isCompile = true) then begin FlagX[1] := round(Map.RedFlag.X); FlagY[1] := round(Map.RedFlag.Y); flagX[2] := round(Map.BlueFlag.X); FlagY[2] := round(Map.BlueFlag.Y); end; end;procedure OnPlayerKill(Killer, Victim: TActivePlayer; BulletId: Byte);begin if (Killer.Team <> Victim.Team) then begin if (KillsPerMine > 0) then begin soldier[Killer.ID] := (soldier[Killer.ID]+1); if ((soldier[Killer.ID] mod KillsPerMine) = 0) then Killer.WriteConsole('You may now place up to ' + inttostr(soldier[Killer.ID] div KillsPerMine) + ' mines (/mine)',cMine); end; end;end;initializationbegin for Decl := 1 to 32 do begin Players[Decl].OnKill := @OnPlayerKill; Players[Decl].OnFlagScore := @OnFlagScore; Players[Decl].OnCommand := @CommandEvent; end; Map.OnBeforeMapChange := @BeforeMapChange; Game.OnClockTick := @AppOnIdle; isCompile:=false; if (isCompile = true) then begin FlagX[1] := round(Map.RedFlag.X); FlagY[1] := round(Map.RedFlag.Y); flagX[2] := round(Map.BlueFlag.X); FlagY[2] := round(Map.BlueFlag.Y); end;end;finalization;end.
https://forums.soldat.pl/index.php?topic=38010 ?