Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit CustomGrenades;
- //Script Writed By Dominik. Version 2018.01.28.004; 265.196:535
- interface //Add in next:
- //Using PlaySound
- implementation
- const
- //Optimize
- MaxPlayer = 16; //[2-32] Max players what can be on your server.
- AllowKeyPress = True; //[true|false] Allow you to change the grenade using the keys.
- //Colors
- ColorW = $adc600; //[Longint] Color displayed text on chat using the command /help (WriteConsole).
- FlashColor = $F1F1F1; //[Longint] Color flashed. DONT EDIT. Edit only for funny :)
- HudColor = $D9D5D1; //[Longint] Color hud. Text on the screen.
- NadeInfoColor = $CC0000; //[Longint] Color nade inscription above the grenade.
- FlashInfoColor = $CDCDCD; //[Longint] Color flash inscription above the grenade.
- //Design
- LayerFlash = 36; //[Number] For other programmers, or if you dont see the texts, change it. (BigText)
- Method2FlashLayer = 40; //[Number] For other programmers, or if you dont see the texts, change it. (WorldText)
- LayerHud = 37; //[Number] For other programmers, or if you dont see the texts, change it. (BigText)
- FirstJoinLayer = 38; //[Number] For other programmers, or if you dont see the texts, change it (BigText)
- NadeInfoLayerStart = 41; //[Number] For other programmers, or if you dont see the texts, change it. (WorldText) Must be > Method2FlashLayer num.
- NadeInfoTime = 58; //[Number] <60 be transparency effect, >70 be the inscription on the map becomes longer as the grenade explodes. DONT EDIT.
- HudSize = 0.050; //[Number] Hud size on screen.
- HudPosX = 12; //[Number] Hud position X on screen.
- HudPosY = 405; //[Number] Hud position Y on screen.
- NadeInfoSize = 0.038; //[Number] Size of inscription on nade.
- NadeInfoCorrectionX = 12.75; //[Number] Position correction X of inscription on nade.
- NadeInfoCorrectionY = 6.7; //[Number] Position correction Y of inscription on nade.
- FirstJoinText = true; //[true|false] true add text to use command /flashhelp if player first join server.
- FlashAll = true; //[true|false] true - all, false - enemy
- SelfFlash = true; //[true|false] true - player can blind himself, false - player can`t blind himself. This setting works if FlashAll is false.
- FlashSee = 2; //[1-3] Inscription above your grenade see: 1 - All players, 2 - You and your team, 3 - Only you.
- //Flash config
- MaxDistance = 250; //[Number] The maximum range on which players will be blinded
- MinimalFlashTime = 80; //[Number] The minimum time of blinding caused by flash. 60 ~ 1s
- MaxFlashTime = 240; //[Number] The maximum time of blinding caused by flash. 60 ~ 1s
- MinimalDistToGainDamage = 85; //[Number] The minimum distance at which the damage can be inflicted by flash grenade. DONT EDIT.
- MaxFlashDamage = 28; //[Number] Maximum damage that a player can get from a flash grenade.
- FlashMethod = 2; //[1-2] 1 - Using BigText, old method, can be partial screen blinding effect (at very very high resolutions). 2 - Using WorldText work for all resolution. There will be no partial screen blinding effect.
- UseRayCastForNadeDisplay = true;//[true|false] Works only if realistic mode active. True - You will not see the inscription if the grenade will not be in sight. False - off this effect, all time see inscription on nade.
- AntyNadeMove = true;
- VelListMax = 3; //[Number] DONT EDIT; If AntyNadeMove true and dont work try set to 6 and set FrezTime to 5; VelListMax must be FrezTime+1 - Best option
- FrezTime = 2; //[Number] DONT EDIT; If AntyNadeMove true and dont work try set to 5 and set VelListMax to 6; FrezTime must be VelListMax-1 - Best option
- //Max grenade count
- MaxNormalCount = 2; //[Number] Specifies the maximum number of grenades, 0 to off.
- MaxFlashCount = 1; //[Number] Specifies the maximum number of flash, 0 to off.
- //Granadekit config
- DisableGranadeKit = false; //[true|false] True - Disable granadekit spawn, False - Enables granadekit spawn.
- GranadeKitNadeGive = 2; //[Positive number] Specifies the maximum amount of grenades to be granted after picking up granadekit.
- GranadeKitFlashGive = 1; //[Positive number] Specifies the maximum amount of flash to be granted after picking up granadite
- DistanceToGetNadeKit = 10.0; //[Positive single number] The distance in which the player must be to make granadekit work. DONT EDIT.
- RayCastCorection = 1; //Dont Edit
- type tNade = record
- NadeCount: byte;
- FlashCount: byte;
- LastPosX,LastPosY:single;
- FrezleTime:integer;
- Style: byte;
- FlashList, NadeList, LastVelX, LastVelY: TStringList;
- end;
- var
- Nade: array[1..MaxPlayer] of tNade;
- function Commands(Player: TActivePlayer; Text: string): Boolean;
- begin
- result:=false;
- text:=lowercase(text);
- if (Text='/set') or (text='/change') then begin
- if (Nade[Player.ID].Style<>3) then begin
- if (Nade[Player.ID].Style=0) then begin
- if (Nade[Player.ID].FlashCount>0) then Nade[Player.ID].Style := 1;
- end else if (Nade[Player.ID].NadeCount>0) then Nade[Player.ID].Style := 0;
- end;
- exit;
- end;
- if (Text='/smoke') or (Text='/nade') or (Text='/cc1') then begin
- if (Nade[Player.ID].Style<>3) then begin
- if (Nade[Player.ID].Style=1) then begin
- if (Nade[Player.ID].NadeCount>0) then Nade[Player.ID].Style := 0;
- end;
- end;
- exit;
- end;
- if (Text='/tabac') or (Text='/flash') or (Text='/cc2') then begin
- if (Nade[Player.ID].Style<>3) then begin
- if (Nade[Player.ID].Style=0) then begin
- if (Nade[Player.ID].FlashCount>0) then Nade[Player.ID].Style := 1;
- end;
- end;
- exit;
- end;
- if (Text='/help') or (Text='/flashhelp') then begin
- Player.WriteConsole('Grenade type info (Script create by Dominik):',ColorW-200);
- Player.WriteConsole('Minimal flash time: '+FormatFloat('0.00',MinimalFlashTime/60.0)+'s, Max flash time: '+FormatFloat('0.00',MaxFlashTime/60.0)+'s, Max flash range: '+FormatFloat('0.00',MaxDistance/10.0)+'m ',ColorW+700);
- Player.WriteConsole('Max flash destruction range: '+FormatFloat('0.00',MinimalDistToGainDamage/10.0)+'m, Max flash damage: '+FormatFloat('0.00',MaxFlashDamage)+'dmg ',ColorW+700);
- Player.WriteConsole('Max grenades: '+inttostr(MaxNormalCount)+', Max glash: '+inttostr(MaxFlashCount)+iif(DisableGranadeKit=false,', Grenadekit gives: '+inttostr(GranadeKitNadeGive)+' nades, '+inttostr(GranadeKitFlashGive)+' flash','')+' ',ColorW+700);
- Player.WriteConsole('Flash will blind everyone - '+iif(FlashAll=true,'true','false')+', Self blinded - '+iif(SelfFlash=true,'possible','impossible')+', Flash dont move you: '+iif(AntyNadeMove=true,'true','false')+' ',ColorW+700);
- if (Game.Realistic) and (UseRayCastForNadeDisplay=true) then begin
- case FlashSee of
- 1 : begin
- Player.WriteConsole('Everyone can see inscription above your grenade, but realistic mode is active. ',ColorW+700);
- Player.WriteConsole('If your granade isn`t visible for enemy, they will not see an inscription above your grenade ',ColorW+700);
- end;
- 2 : Player.WriteConsole('Inscription on the grenade will see you and your team friends. ',ColorW+700);
- 3 : Player.WriteConsole('Inscription on the grenade will see only you. ',ColorW+700);
- end;
- end else
- begin
- case FlashSee of
- 1 : Player.WriteConsole('Everybody will see inscription above your grenade, also enemy. ',ColorW+700);
- 2 : Player.WriteConsole('Inscription on the grenade will see you and your team friends. ',ColorW+700);
- 3 : Player.WriteConsole('Inscription on the grenade will see only you. ',ColorW+700);
- end;
- end;
- Player.WriteConsole('/set /change - Switch grenade type. ',ColorW);
- Player.WriteConsole('/nade /cc1 /smoke - Change grenade type to normal. ',ColorW);
- Player.WriteConsole('/flash /cc2 /tabac - Change the grenade to flash. ',ColorW);
- Player.WriteConsole('Default taunt: Alt+1 is commands /smoke means change to normal grenade. ',ColorW);
- Player.WriteConsole('Default taunt: Alt+2 is commands /tabac means change to flash grenade. ',ColorW);
- if AllowKeyPress then Player.WriteConsole('Press key crouch + switch weapon - Change grenade type. ',ColorW);
- end;
- end;
- procedure JoinGame(Player: TActivePlayer; Team: TTeam);
- begin
- if (Player.Human) and (FirstJoinText=true) then begin
- Player.WriteConsole('Write /flashhelp to see how use flash grenade!',ColorW+3500);
- Player.BigText(FirstJoinLayer,'Write /flashhelp to see how use flash grenade!',155,HudColor,0.09,55,295);
- end;
- end;
- procedure JoinTeam(Player: TActivePlayer; Team: TTeam);
- begin
- Nade[Player.ID].FlashList := File.CreateStringList();
- Nade[Player.ID].NadeList := File.CreateStringList();
- Nade[Player.ID].LastVelX := File.CreateStringList();
- Nade[Player.ID].LastVelY := File.CreateStringList();
- Nade[Player.ID].FrezleTime := 0;
- if (Player.Human) then begin
- if (FlashMethod=1) then Player.BigText(LayerFlash,'',0,FlashColor,0.1,0,0) else Player.WorldText(Method2FlashLayer,'+',0,FlashColor,0.1,Player.X,Player.Y);
- if (Team.ID=5) then Player.BigText(LayerHud,'',0,HudColor,0.1,0,0);
- end;
- Nade[Player.ID].Style := 0;
- Nade[Player.ID].NadeCount := MaxNormalCount;
- Nade[Player.ID].FlashCount := MaxFlashCount;
- end;
- procedure LeaveGame(Player: TActivePlayer; Kicked: Boolean);
- begin
- if (FlashMethod=1) then Player.BigText(LayerFlash,'',0,FlashColor,0.1,0,0) else Player.WorldText(Method2FlashLayer,'+',0,FlashColor,0.1,Player.X,Player.Y);
- end;
- procedure OnAfterRespawn(Player: TActivePlayer);
- begin
- if (FlashMethod=1) then Player.BigText(LayerFlash,'',0,FlashColor,0.1,0,0) else Player.WorldText(Method2FlashLayer,'+',0,FlashColor,0.1,Player.X,Player.Y);
- Nade[Player.ID].Style := 0;
- Nade[Player.ID].NadeCount := MaxNormalCount;
- Nade[Player.ID].FlashCount := MaxFlashCount;
- Nade[Player.ID].LastVelX := File.CreateStringList();
- Nade[Player.ID].LastVelY := File.CreateStringList();
- Nade[Player.ID].FrezleTime := 0;
- end;
- procedure ChangeAfter(Next: string);
- var i: byte;
- begin
- if (disablegranadekit=true) or ((GranadeKitNadeGive=0) and (GranadeKitFlashGive=0)) then begin
- for i := 1 to 254 do if (Map.Spawns[i].Style=8) then Map.Spawns[i].Active := false;
- for i := 1 to 90 do if (Map.Objects[i].Style=17) then Map.Objects[i].Kill;
- end;
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].Human) then begin
- if (FlashMethod=1) then Players[i].BigText(LayerFlash,'',0,FlashColor,0.1,0,0) else Players[i].WorldText(Method2FlashLayer,'+',0,FlashColor,0.1,Players[i].X,Players[i].Y);
- end;
- Nade[i].Style := 0;
- Nade[i].NadeCount := MaxNormalCount;
- Nade[i].FlashCount := MaxFlashCount;
- end;
- end;
- function NadeDamage(Shooter, Victim: TActivePlayer; Damage: single; Bullet: byte): single;
- var dmg:single; b:byte; i:integer; X2, Y2, Dist, TimeFlash, MaxDist: single;
- begin
- Result := Damage;
- dmg := Damage;
- if (MaxFlashDamage>0) then begin
- try
- if (Map.Bullets[Bullet].GetOwnerWeaponId=50) then begin
- for b := 1 to MaxPlayer do if (Players[b].Active) then begin
- for i := 0 to (Nade[b].FlashList.Count-1) do begin
- if (Nade[b].FlashList[i]=inttostr(Bullet)) then begin
- X2 := Victim.X-Map.Bullets[Bullet].X; Y2 := Victim.Y-Map.Bullets[Bullet].Y; Dist := X2*X2+Y2*Y2;
- MaxDist:=MinimalDistToGainDamage*MinimalDistToGainDamage; //Dominik
- if (Dist<=MaxDist) then begin
- if not Map.RayCast(Map.Bullets[Bullet].X,Map.Bullets[Bullet].Y-RayCastCorection,Victim.X,Victim.Y-RayCastCorection,false, false, true, true, 2) then begin
- TimeFlash:=((100-((Dist/MaxDist)*100))/100);
- dmg:=TimeFlash*MaxFlashDamage;
- end;
- end;
- Result := dmg;
- exit;
- end;
- end;
- end;
- end;
- except
- end;
- end;
- end;
- function CheckThisSameNades(ID:byte; check:string): boolean;
- var i: integer;
- begin
- Result := false;
- for i := 0 to (Nade[ID].NadeList.Count-1) do begin
- if (Nade[ID].NadeList[i]=check) then begin
- Result := true;
- exit;
- end;
- end;
- for i := 0 to (Nade[ID].FlashList.Count-1) do begin
- if (Nade[ID].FlashList[i]=check) then begin
- Result := true;
- exit;
- end;
- end;
- end;
- procedure NadesCreate();
- var i: byte;
- begin
- for i := 1 to 254 do if (Map.Bullets[i].Active) then begin
- if (Map.Bullets[i].GetOwnerWeaponId=50) then begin
- if (Nade[Map.Bullets[i].Owner].Style=0) then begin
- if (Nade[Map.Bullets[i].Owner].NadeCount>0) then begin
- if (CheckThisSameNades(Map.Bullets[i].Owner, inttostr(i)) = false) then begin
- Nade[Map.Bullets[i].Owner].NadeList.Append(inttostr(i));
- Nade[Map.Bullets[i].Owner].NadeCount:=(Nade[Map.Bullets[i].Owner].NadeCount-1);
- if (Nade[Map.Bullets[i].Owner].NadeCount<=0) then if (Nade[Map.Bullets[i].Owner].FlashCount>0) then Nade[Map.Bullets[i].Owner].Style := 1;
- end;
- end;
- end else if (Nade[Map.Bullets[i].Owner].Style=1) then begin
- if (Nade[Map.Bullets[i].Owner].FlashCount>0) then begin
- if (CheckThisSameNades(Map.Bullets[i].Owner, inttostr(i))=false) then begin
- Nade[Map.Bullets[i].Owner].FlashList.Append(inttostr(i));
- Nade[Map.Bullets[i].Owner].FlashCount:=(Nade[Map.Bullets[i].Owner].FlashCount-1);
- if (Nade[Map.Bullets[i].Owner].FlashCount<=0) then if (Nade[Map.Bullets[i].Owner].NadeCount>0) then Nade[Map.Bullets[i].Owner].Style := 0;
- end;
- end;
- end;
- end;
- end;
- end;
- procedure FlashPlayers(Owner:byte; FlashX, FlashY:single; Team:byte);
- var i:byte; X2, Y2, Dist, TimeFlash, MaxDist: single; RealTimeFlash:integer;
- begin
- if (FlashAll=true) then begin
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].Alive) and (Players[i].Team<5) then begin
- X2 := Players[i].X-FlashX; Y2 := Players[i].Y-FlashY; Dist := X2*X2+Y2*Y2;
- MaxDist:=MaxDistance*MaxDistance; //By
- if (Dist<=MaxDist) then begin
- Nade[i].FrezleTime := FrezTime;
- if not Map.RayCast(FlashX,FlashY-RayCastCorection,Players[i].X,Players[i].Y-RayCastCorection,false, false, true, true, 2) then begin
- TimeFlash:=((100-((Dist/MaxDist)*100))/100);
- RealTimeFlash:=Round(TimeFlash*MaxFLashTime);
- if (RealTimeFlash<MinimalFlashTime) then RealTimeFlash:=MinimalFlashTime;
- if (FlashMethod=1) then Players[i].BigText(LayerFlash,'+',RealTimeFlash,FlashColor,60,-5000,-6420) else Players[i].WorldText(Method2FlashLayer,'+',RealTimeFlash,FlashColor,1280,Players[i].X-82304,Players[i].Y-136832);//20,Players[i].X-1286,Players[i].Y-2138);
- end;
- end;
- end;
- end;
- end else
- begin
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].Alive) and (Players[i].Team<5) and (i<>owner) and (Players[i].Team<>Team) then begin
- X2 := Players[i].X-FlashX; Y2 := Players[i].Y-FlashY; Dist := X2*X2+Y2*Y2;
- MaxDist:=MaxDistance*MaxDistance;
- if (Dist<=MaxDist) then begin
- Nade[i].FrezleTime := FrezTime;
- if not Map.RayCast(FlashX,FlashY-RayCastCorection,Players[i].X,Players[i].Y-RayCastCorection,false, false, true, true, 2) then begin
- TimeFlash:=((100-((Dist/MaxDist)*100))/100);
- RealTimeFlash:=Round(TimeFlash*MaxFLashTime);
- if (RealTimeFlash<MinimalFlashTime) then RealTimeFlash:=MinimalFlashTime;
- if SelfFlash then begin
- if (FlashMethod=1) then Players[owner].BigText(LayerFlash,'+',RealTimeFlash,FlashColor,60,-5000,-6420) else Players[owner].WorldText(Method2FlashLayer,'+',RealTimeFlash,FlashColor,1280,Players[owner].X-82304,Players[owner].Y-136832);
- end;
- if (FlashMethod=1) then Players[i].BigText(LayerFlash,'+',RealTimeFlash,FlashColor,60,-5000,-6420) else Players[i].WorldText(Method2FlashLayer,'+',RealTimeFlash,FlashColor,1280,Players[i].X-82304,Players[i].Y-136832);
- end;
- end;
- end;
- end;
- end;
- end;
- procedure RemoveNades();
- var i,b: byte;
- begin
- for i := 1 to MaxPlayer do begin
- if (Nade[i].NadeList.Count>0) then begin
- for b := 0 to Nade[i].NadeList.Count-1 do begin
- try
- if (Map.Bullets[strtoint(Nade[i].NadeList[b])].Active=false) then begin
- Nade[i].NadeList.Delete(b); b:=b;
- if Nade[i].NadeList.Count=0 then exit;
- end;
- except
- end;
- end;
- end;
- if (Nade[i].FlashList.Count>0) then begin
- for b := 0 to Nade[i].FlashList.Count-1 do begin
- try
- if (Map.Bullets[strtoint(Nade[i].FlashList[b])].Active=false) then begin
- FlashPlayers(i,Map.Bullets[strtoint(Nade[i].FlashList[b])].X,Map.Bullets[strtoint(Nade[i].FlashList[b])].Y, Players[i].Team);
- Nade[i].FlashList.Delete(b); b:=b;
- if Nade[i].FlashList.Count=0 then exit;
- end;
- except
- end;
- end;
- end;
- end;
- end;
- procedure NadeControl();
- var i:byte;
- begin
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].Team < 5) then begin
- if (Players[i].Grenades < 1) then begin
- if (Nade[i].NadeCount>0) or (Nade[i].FlashCount>0) then Players[i].GiveBonus(4);
- end;
- Players[i].BigText(LayerHud,'Type: '+iif(Nade[i].Style=0,'Grenades','Flash')+chr(13)+chr(10)+'Nade: '+inttostr(Nade[i].NadeCount)+Chr(13)+Chr(10)+'Flash: '+inttostr(Nade[i].FlashCount),75,HudColor,HudSize,HudPosX,HudPosY);
- end;
- end;
- end;
- procedure DisplayNadeInfo();
- var i,b,c: byte;
- begin
- for i := 1 to 254 do if (Map.Bullets[i].Active) then begin
- if (Map.Bullets[i].GetOwnerWeaponId=50) then begin
- case FlashSee of
- 1: begin
- if (Game.Realistic) and (UseRayCastForNadeDisplay=true) then begin
- for b := 1 to MaxPlayer do if (Players[b].Active) then begin
- if (Players[Map.Bullets[i].Owner].Team=Players[b].Team) then begin
- if (Nade[b].NadeList.IndexOf(inttostr(i))>-1) then begin
- for c := 1 to MaxPlayer do if (Players[c].Active) then begin
- if (Players[b].Team = Players[c].Team) then Players[c].WorldText(NadeInfoLayerStart+i,'Nade!',NadeInfoTime,NadeInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY) else if not Map.RayCast(Map.Bullets[i].X,Map.Bullets[i].Y-RayCastCorection,Players[c].X,Players[c].Y-RayCastCorection,true, false, false, false, 2) then Players[c].WorldText(NadeInfoLayerStart+i,'Nade!',NadeInfoTime,NadeInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end;
- end else if (Nade[b].FlashList.IndexOf(inttostr(i))>-1) then begin
- for c := 1 to MaxPlayer do if (Players[c].Active) then begin
- if (Players[b].Team = Players[c].Team) then Players[c].WorldText(NadeInfoLayerStart+i,'Flash!',NadeInfoTime,FlashInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY) else if not Map.RayCast(Map.Bullets[i].X,Map.Bullets[i].Y-RayCastCorection,Players[c].X,Players[c].Y-RayCastCorection,true, false, false, false, 2) then Players[c].WorldText(NadeInfoLayerStart+i,'Flash!',NadeInfoTime,FlashInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end;
- end;
- end;
- end;
- end else
- begin
- for b := 1 to MaxPlayer do if (Players[b].Active) then begin
- if (Nade[b].NadeList.IndexOf(inttostr(i))>-1) then Players.WorldText(NadeInfoLayerStart+i,'Nade!',NadeInfoTime,NadeInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY) else if (Nade[b].FlashList.IndexOf(inttostr(i))>-1) then Players.WorldText(NadeInfoLayerStart+i,'Flash!',NadeInfoTime,FlashInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end;
- end;
- end;
- 2: begin
- for b := 1 to MaxPlayer do if (Players[b].Active) then begin
- if (Players[Map.Bullets[i].Owner].Team=Players[b].Team) then begin
- if (Nade[b].NadeList.IndexOf(inttostr(i))>-1) then begin
- for c := 1 to MaxPlayer do if (Players[c].Active) and (Players[b].Team = Players[c].Team) then Players[c].WorldText(NadeInfoLayerStart+i,'Nade!',NadeInfoTime,NadeInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end else if (Nade[b].FlashList.IndexOf(inttostr(i))>-1) then for c := 1 to MaxPlayer do if (Players[c].Active) and (Players[b].Team = Players[c].Team) then Players[c].WorldText(NadeInfoLayerStart+i,'Flash!',NadeInfoTime,FlashInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end;
- end;
- end;
- 3: if (Nade[Map.Bullets[i].Owner].NadeList.IndexOf(inttostr(i))>-1) then Players[Map.Bullets[i].Owner].WorldText(NadeInfoLayerStart+i,'Nade!',NadeInfoTime,NadeInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY) else if (Nade[Map.Bullets[i].Owner].FlashList.IndexOf(inttostr(i))>-1) then Players[Map.Bullets[i].Owner].WorldText(NadeInfoLayerStart+i,'Flash!',NadeInfoTime,FlashInfoColor,NadeInfoSize,Map.Bullets[i].X-NadeInfoCorrectionX,Map.Bullets[i].Y-NadeInfoCorrectionY);
- end;
- end;
- end;
- end;
- procedure keypresschange();
- var i:byte;
- begin
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].KeyChangeWeap) and (Players[i].KeyCrouch) then begin //KEY PRESS EDIT
- if (Nade[i].Style<>3) then begin
- if (Nade[i].Style=0) then begin
- if (Nade[i].FlashCount>0) then Nade[i].Style := 1;
- end else if (Nade[i].NadeCount>0) then Nade[i].Style := 0;
- end;
- end;
- end;
- end;
- procedure UseGranadeKit(Player: TActivePlayer; Kit: TActiveMapObject);
- var temp:integer;
- begin
- if (Kit.Style=17) then begin
- if (Nade[Player.ID].NadeCount<MaxNormalCount) or (Nade[Player.ID].FlashCount<MaxFlashCount) then begin
- if (GranadeKitNadeGive > 0) then begin
- temp := Nade[Player.ID].NadeCount+GranadeKitNadeGive;
- if (temp>MaxNormalCount) then Nade[Player.ID].NadeCount:=MaxNormalCount else Nade[Player.ID].NadeCount := temp;
- end;
- if (GranadeKitFlashGive > 0) then begin
- temp := Nade[Player.ID].FlashCount+GranadeKitFlashGive;
- if (temp>MaxFlashCount) then Nade[Player.ID].FlashCount:=MaxFlashCount else Nade[Player.ID].FlashCount := temp;
- end;
- end;
- end;
- end;
- procedure NadeKitUse();
- var KillHere: boolean; i,b:byte; temp:integer; UnDeadBox: TNewMapObject;
- begin
- if (GranadeKitNadeGive=0) and (GranadeKitFlashGive=0) then exit;
- for i := 1 to MaxPlayer do if (Players[i].Active) then begin
- if (Players[i].Team<5) then begin
- for b := 1 to 90 do if (Map.Objects[b].Active) then begin
- if (Map.Objects[b].Style=17) then begin
- if (Distance(Players[i].X,Players[i].Y,Map.Objects[b].X,Map.Objects[b].Y)<DistanceToGetNadeKit) then begin
- KillHere := false;
- if (GranadeKitNadeGive > 0) then begin
- if (Nade[i].NadeCount<MaxNormalCount) then begin
- KillHere:=true;
- UnDeadBox := TNewMapObject.Create;
- UnDeadBox.Style:=17; UnDeadBox.X:=Map.Objects[b].X; UnDeadBox.Y:=Map.Objects[b].Y+12000;
- Map.Objects[b].Kill; Map.AddObject(UnDeadBox); UnDeadBox.Free;
- temp := Nade[i].NadeCount+GranadeKitNadeGive;
- if (temp>MaxNormalCount) then Nade[i].NadeCount:=MaxNormalCount else Nade[i].NadeCount := temp;
- end;
- end;
- if (GranadeKitFlashGive > 0) then begin
- if (Nade[i].FlashCount<MaxFlashCount) then begin
- if (KillHere=false) then begin
- UnDeadBox := TNewMapObject.Create;
- UnDeadBox.Style:=17; UnDeadBox.X:=Map.Objects[b].X; UnDeadBox.Y:=Map.Objects[b].Y+12000;
- Map.Objects[b].Kill; Map.AddObject(UnDeadBox); UnDeadBox.Free;
- end;
- KillHere:=true;
- temp := Nade[i].FlashCount+GranadeKitFlashGive;
- if (temp>MaxFlashCount) then Nade[i].FlashCount:=MaxFlashCount else Nade[i].FlashCount := temp;
- end;
- end;
- if (KillHere) then break;
- end;
- end;
- end;
- end;
- end;
- end;
- procedure Frezzle();
- var i:byte;
- begin
- if (AntyNadeMove=true) then begin
- for i:= 1 to MaxPlayer do if (Players[i].Active) and (Players[i].Team<5) then begin
- if (Nade[i].FrezleTime <= 0) then begin
- Nade[i].LastPosX := Players[i].X;
- Nade[i].LastPosY := Players[i].Y;
- Nade[i].LastVelX.Append(floattostr(Players[i].VelX));
- if (Nade[i].LastVelX.Count>VelListMax) then Nade[i].LastVelX.Delete(0);
- Nade[i].LastVelY.Append(floattostr(Players[i].VelY));
- if (Nade[i].LastVelY.Count>VelListMax) then Nade[i].LastVelY.Delete(0);
- end else
- begin
- if (Nade[i].FrezleTime>0) then begin
- Nade[i].FrezleTime := Nade[i].FrezleTime-1;
- Players[i].Move(Nade[i].LastPosX,Nade[i].LastPosY);
- Players[i].SetVelocity(0,0);
- if (Nade[i].FrezleTime=0) and (Nade[i].LastVelX.Count=VelListMax) and (Nade[i].LastVelY.Count=VelListMax) then Players[i].SetVelocity(StrToFloat(Nade[i].LastVelX[0]),StrToFloat(Nade[i].LastVelY[0]));
- end;
- end;
- end;
- end;
- end;
- procedure Timers(Ticks: integer);
- begin
- RemoveNades();
- NadesCreate();
- NadeControl();
- DisplayNadeInfo();
- NadeKitUse();
- Frezzle();
- if (AllowKeyPress=true) then begin
- if ((Ticks mod 34) = 0) then keypresschange();
- end;
- end;
- procedure Recompile();
- var i:byte;
- begin
- Game.MaxGrenades := 1;
- for i := 1 to MaxPlayer do begin
- Nade[i].Style := 0;
- Nade[i].NadeCount := MaxNormalCount;
- Nade[i].FlashCount := MaxFlashCount;
- Nade[i].FrezleTime := 0;
- Nade[i].FlashList := File.CreateStringList();
- Nade[i].NadeList := File.CreateStringList();
- Nade[i].LastVelX := File.CreateStringList();
- Nade[i].LastVelY := File.CreateStringList();
- end;
- end;
- procedure ScriptDecl();
- var i:byte;
- begin
- for i := 0 to 5 do Game.Teams[i].OnJoin := @JoinTeam;
- Game.TickThreshold := 1;
- Game.OnClockTick := @Timers;
- Game.OnLeave := @LeaveGame;
- Game.OnJoin := @JoinGame;
- Map.OnAfterMapChange := @ChangeAfter;
- for i := 1 to MaxPlayer do begin
- Players[i].OnDamage := @NadeDamage;
- Players[i].OnKitPickup := @UseGranadeKit;
- Players[i].OnAfterRespawn := @OnAfterRespawn;
- Players[i].OnCommand := @Commands;
- end;
- end;
- initialization
- begin
- ScriptDecl();
- Recompile();
- end;
- finalization;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement