Author Topic: script needed min  (Read 5654 times)

0 Members and 1 Guest are viewing this topic.

Offline Fears

  • Major(1)
  • Posts: 5
script needed min
« on: April 17, 2020, 10:28:00 pm »
script needed min

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: script needed min
« Reply #1 on: April 19, 2020, 06:33:44 am »
 ???

Offline Fears

  • Major(1)
  • Posts: 5
Re: script needed min
« Reply #2 on: April 21, 2020, 08:50:52 pm »
that after obtaining, for example, 7-8 frags, you get 1 mine which you activate the command / mine

I found one script on mine

but he works so that there is 10 mine on the map for everyone.  :-X

Offline machina

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1117
  • The world isn't nice. Why should I be...?
Re: script needed min
« Reply #3 on: April 24, 2020, 03:31:03 pm »

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: script needed min
« Reply #4 on: April 25, 2020, 02:25:00 pm »
You can extract it from this script easy mechanism

https://forums.soldat.pl/index.php?topic=18136.msg529412#msg529412

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: script needed min
« Reply #5 on: April 25, 2020, 03:22:21 pm »
I did it for you. For edit open script and u can edit all in const  :D
Code: [Select]
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;

Code: [Select]
unit Mines;

interface

implementation

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;

//Mines script v0.0.0.1 SC3 by Dominik

type 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;

initialization
begin
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.

Offline Fears

  • Major(1)
  • Posts: 5
Re: script needed min
« Reply #6 on: April 25, 2020, 06:23:31 pm »
it works :) thank you great !  :) :)

Offline Fears

  • Major(1)
  • Posts: 5
Re: script needed min
« Reply #7 on: April 25, 2020, 06:28:20 pm »
https://forums.soldat.pl/index.php?topic=38010 ?
this script works so that you have a certain number mine on the map
so player 1 can use 10 mine at once and player 2 can use one.