Author Topic: [beta] Airstrike v0.8  (Read 10211 times)

0 Members and 1 Guest are viewing this topic.

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
[beta] Airstrike v0.8
« on: June 06, 2007, 10:48:27 am »
Script Name: AirStrike

Script Description:
This is script for TrenchWar servers. It provides possibilities to perform intellectual airstrikes on certain team. Unlike EnEsCe's bombardment, this script creates series of relatively short air raids on randomly picked player from target team. All this features have a lot of adjustable parameters such as accuracy, amount of missiles dropped, distance between them etc. Airstrikes can be turned on/off by admin.

According to tests i've made so far it works stable. But still this version is in Beta phase! It have a lot of debug console messages. You are using it on your own risk.. Please report any bugs and post suggestions - parameters of airstrikes needs some improvement...
AutoAirstrikes aren't implemented propely yet - they give airstrike worning only when airstrike begins. This will be improved later.

Also Createbullet function doesn't work stable...
Quote from:
This function is known to cause bugs on both Client and Server! On some Operating Systems this function will cease to function properly after awhile. So dont email me about it.

Original Author: VirtualTT

Core Version: 2.6.1

Code:
AirStrike.pas
Code: [Select]
Const
AutoAirstrikeFrequency=6;//min
RaidsPerStrike=12;
RaidInterval=3;//s
RaidAccuracy=0.3;//*MissilesPerRaid*MissileStep
MissilesPerRaid=12;
MissileStep=40;//distance between missiles

Var
AirstrikesAllowed:boolean;
AutoAirStrikesAllowed:boolean;
TargetTeam:byte;
PerformingAirstrike:boolean;
Raid:byte;
FP:shortint;//flags positions =1 if red flag on the left side of the map and blue flag is on the right side of the map
CenterX,CenterY:single;

Procedure ShowGreeting(player:byte);
Begin
writeConsole(player, 'Server is using AirStrike scipt v0.8 by VTT', rgb(20,20,20));
End;

Procedure GetMapParams;
Var
BlueFlagX,BlueFlagY,RedFlagX,RedFlagY:single;
Begin
GetFlagsXY(BlueFlagX, BlueFlagY, RedFlagX, RedFlagY);
CenterX:=(BlueFlagX+RedFlagX)/2;
CenterY:=(BlueFlagY+RedFlagY)/2;
FP:=iif(RedFlagX<BlueFlagX,1,-1);
ShowGreeting(0);
writeConsole(0, 'FP='+inttostr(FP), rgb(20,20,20));
writeConsole(0, 'Cen: ('+floattostr(round(CenterX))+' ; '+floattostr(Round(CenterY))+' )', rgb(20,20,20));
End;

Procedure PerformAirStrike(Team:byte);
Begin
case Team of
1: if AlphaPlayers=0 then exit;
2: begin if BravoPlayers=0 then Exit; end;
else exit;
end;
WriteConsole(0, 'Test point passed '+inttostr(Team), rgb(20,20,20));
Raid:=0;
TargetTeam:=Team;
DrawText(0,'Air-raid warning!',330,RGB(240,20,20),0.15,70,400);
Case team of
1: WriteConsole(0, 'AirStrike on Alpha team!', rgb(240,20,20));
2: WriteConsole(0, 'AirStrike on Bravo team!', rgb(20,20,240));
end;
PerformingAirstrike:=true;
End;

Procedure StopAirStrike;
Begin
PerformingAirstrike:=false;
DrawText(0,'Air-raid warning over!',330,RGB(20,240,20),0.15,30,400);
WriteConsole(0, 'AirStrike Complete!', rgb(20,20,20));
End;

Function PickWinningTeam():byte;
Var
i:byte;
AlphaPoints,BravoPoints:integer;
Label
q;
Begin
result:=1;
//cheching score
if AlphaScore>BravoScore then goto q;
if AlphaScore<BravoScore then begin result:=2; goto q; end;
//checking summary points
for i:=1 to NumPlayers do begin
if GetPlayerStat(i,'Team')=1 then AlphaPoints:=AlphaPoints+GetPlayerStat(i,'Kills');
if GetPlayerStat(i,'Team')=2 then BravoPoints:=BravoPoints+GetPlayerStat(i,'Kills');
end;
if AlphaPoints>BravoPoints then goto q;
if AlphaPoints<BravoPoints then begin result:=2; goto q; end;
//checking summary deths
for i:=1 to NumPlayers do begin
if GetPlayerStat(i,'Team')=1 then AlphaPoints:=AlphaPoints+GetPlayerStat(i,'Deaths');
if GetPlayerStat(i,'Team')=2 then BravoPoints:=BravoPoints+GetPlayerStat(i,'Deaths');
end;
if ((AlphaPoints<BravoPoints) and (AlphaPlayers>0)) then goto q;
if ((AlphaPoints>BravoPoints) and (BravoPlayers>0)) then begin result:=2; goto q; end;
//checking amaunt of players
if AlphaPlayers>BravoPlayers then goto q;
if AlphaPlayers<BravoPlayers then begin result:=2; goto q; end;
//randomly choosing winning team
result:=iif(Random(0,1)=0,1,2);
q:
case result of
1: WriteConsole(0, 'Winning team is Alpha', rgb(20,20,20));
2: WriteConsole(0, 'Winning team is Bravo', rgb(20,20,20));
end;
End;

Function PickRandomPlayer(Team:byte):byte;
Var
i:byte;
Begin
case Team of
1: if AlphaPlayers=0 then begin StopAirStrike; exit; end;
2: if BravoPlayers=0 then begin StopAirStrike; exit; end;
end;
case Team of
1: i:=Random(1,AlphaPlayers);
2: i:=Random(1,BravoPlayers);
end;
result:=1;
repeat if GetPlayerStat(result,'Team')=Team then i:=i-1 else result:=result+1; until i=0;
writeConsole(0, 'Target player is '+IDtoName(result), rgb(20,20,20));
End;

Procedure PerformAirRaid(Player:byte);
Var
i:integer;
c:smallint;
TargetLocationX,TargetLocationY:single;
Begin
case TargetTeam of
1:c:=1;
2:c:=-1;
end;
If ((Player=0) or (Player>NumPlayers)) then begin StopAirStrike; exit; end;
GetPlayerXY(Player,TargetLocationX,TargetLocationY);
i:=Round(MissileStep*MissilesPerRaid*RaidAccuracy);
TargetLocationX:=TargetLocationX+FP*c*(MissilesPerRaid*MissileStep*0.5+Random(-i,i));
TargetLocationY:=CenterY-500;
writeConsole(0, 'Target coordinates: ('+floattostr(round(TargetLocationX))+' ; '+floattostr(Round(TargetLocationY))+' )', rgb(20,20,20));
for i:=0 to MissilesPerRaid-1 do CreateBullet(TargetLocationX-FP*MissileStep*c*i,TargetLocationY,-0.05*FP*c,10-i,10000,8,0);
End;

Procedure EnableAirStrikes;
Begin
AirstrikesAllowed:=true;
WriteConsole(0, 'Airstrikes on', rgb(20,240,20));
End;

Procedure DisableAirStrikes;
Begin
AirstrikesAllowed:=false;
if PerformingAirstrike then StopAirStrike;
WriteConsole(0, 'Airstrikes off', rgb(240,20,20));
End;

Procedure EnableAutoAirStrikes;
Begin
EnableAirStrikes;
AutoAirStrikesAllowed:=true;
writeConsole(0, 'AutoAirstrikes will be performed every '+inttostr(AutoAirstrikeFrequency), rgb(20,240,20));
End;

Procedure DisableAutoAirStrikes;
Begin
AutoAirStrikesAllowed:=false;
WriteConsole(0, 'AutoAirstrikes off', rgb(240,20,20));
End;

Procedure AirstrikesControler(Msg:string);
Label
q;
Begin
IF Msg='/airstrikes 0' then begin DisableAirStrikes; goto q; end;
IF Msg='/airstrikes 1' then begin EnableAirStrikes; goto q; end;
IF Msg='/autoairstrikes 0' then begin DisableAutoAirStrikes; goto q; end;
IF Msg='/autoairstrikes 1' then begin EnableAutoAirStrikes; goto q; end;
IF Msg='/airstrike' then if not PerformingAirstrike then begin PerformAirStrike(PickWinningTeam); goto q; end;
IF Msg='/airstrike1' then if not PerformingAirstrike then begin PerformAirStrike(1); goto q; end;
IF Msg='/airstrike2' then if not PerformingAirstrike then begin PerformAirStrike(2); goto q; end;
q:
End;
Other:
Code: [Select]
Procedure OnAdminMessage(IP, Msg: string);
Begin
AirstrikesControler(Msg);
End;

Procedure ActivateServer();
Begin
FP:=1; //GetMapParams; //GetMapParams for some reason don't give proper results when server starts, so Fp:=1 for TW BattleField
AirstrikesAllowed:=true;
AutoAirStrikesAllowed:=true;
End;

Procedure AppOnIdle(Ticks: integer);
Begin
//AirStrikes
if ((Ticks mod(60*RaidInterval)=0) and (PerformingAirstrike)) then
if Raid<RaidsPerStrike then begin
PerformAirRaid(PickRandomPlayer(TargetTeam));
Raid:=raid+1;
end
else StopAirstrike;
//AutoAirStrikes
if ((Ticks mod(3600*AutoAirstrikeFrequency)=0) and (AirstrikesAllowed) and (AutoAirStrikesAllowed)) then
PerformAirStrike(PickWinningTeam);
End;

Function OnCommand(ID: Byte; Text: string): boolean;
//NOTE: This function will be called when an admin types a / command.
Begin
AirstrikesControler(Text);
Result := false; // Return true if you want to ignore the command typed.
End;

Procedure OnJoinGame(ID, Team: byte);
Begin
ShowGreeting(ID);
End;

Procedure OnMapChange(NewMap: string);
Begin
GetMapParams;
End;
« Last Edit: June 06, 2007, 12:20:56 pm by VirtualTT »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] Airstrike v0.8
« Reply #1 on: June 06, 2007, 11:37:16 am »
thnx for the information in this script, i won´t copy it tho because i need to make use of createbullet on a other way!
Anyways good work vtt! ;)

Offline Mikeman

  • Soldier
  • **
  • Posts: 150
    • Nuke Corruption
Re: [beta] Airstrike v0.8
« Reply #2 on: June 08, 2007, 08:14:46 am »
Nice job VTT  ;)

Offline ManSoft|Warlord

  • Major
  • *
  • Posts: 70
  • Soldat.IDE Creator
Re: [beta] Airstrike v0.8
« Reply #3 on: June 08, 2007, 08:30:22 am »
Would be cool for mods like in COD. If user a has killed 10 people he can cause an air-strike :D

Offline xReaperx

  • Major(1)
  • Posts: 45
Re: [beta] Airstrike v0.8
« Reply #4 on: June 08, 2007, 11:18:24 pm »
My server doesnt like
FP:=1;
and
AirstrikesControler(Msg);

Offline Xxypher

  • Veteran
  • *****
  • Posts: 1319
  • Soldat Veteran.
Re: [beta] Airstrike v0.8
« Reply #5 on: June 08, 2007, 11:21:07 pm »
Trenchwars have airstrikes!?
I guess I will try these out

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: [beta] Airstrike v0.8
« Reply #6 on: June 09, 2007, 12:03:47 am »
My server doesnt like
FP:=1;
and
AirstrikesControler(Msg);
it seems that putting Airstrike.pas before all other files in Includes.txt will solve your problem.

Offline Mikeman

  • Soldier
  • **
  • Posts: 150
    • Nuke Corruption
Re: [beta] Airstrike v0.8
« Reply #7 on: June 09, 2007, 04:25:46 am »
I tried this script on my TW server but I don't get it working. It says air-raid is coming but I see no missiles.

Offline xmRipper

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 742
    • Personal
Re: [beta] Airstrike v0.8
« Reply #8 on: June 09, 2007, 04:27:53 am »
Quote from: EnEsCe
This function is known to cause bugs on both Client and Server! On some Operating Systems this function will cease to function properly after awhile. So dont email me about it.
Co-Founder / CTO @ Macellan
Founder Turkish Soldat Community

Offline xReaperx

  • Major(1)
  • Posts: 45
Re: [beta] Airstrike v0.8
« Reply #9 on: June 09, 2007, 05:29:12 am »
Ok, and where do i put the other code? and where in the includes do i place it?

Offline deguix

  • Major
  • *
  • Posts: 79
Re: [beta] Airstrike v0.8
« Reply #10 on: June 09, 2007, 06:23:12 am »
I wonder how Enesce does this. Surely he doesn't use this function as it is buggy.

Offline VirtualTT

  • Veteran
  • *****
  • Posts: 1026
Re: [beta] Airstrike v0.8
« Reply #11 on: June 09, 2007, 11:28:39 am »
Ok, and where do i put the other code? and where in the includes do i place it?
Your includes.txt should be something like this:
Code: [Select]
// All files specified below here will be
// compiled for use with any SoldatServer
// Scripts. Use // to mark a comment.
// Manual:
// http://enesce.com/help/

//SocketCore.pas
AirStrike.pas
Core.pas
NetworkCore.pas
AdminCore.pas

Read this topic about scripts combining.

I wonder how Enesce does this. Surely he doesn't use this function as it is buggy.

Quote from: EnEsCe
As I said, works good on some OS's, in my case I use Debian Stable and some funky unique kernel by layeredtech....
« Last Edit: June 13, 2007, 04:06:05 pm by VirtualTT »

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] Airstrike v0.8
« Reply #12 on: June 09, 2007, 09:58:44 pm »
Does not work on : Ubuntu 7.04 "Feisty Fawn"

Offline Master Chief43

  • Soldier
  • **
  • Posts: 224
  • When life gives you lemons, eat them :D
Re: [beta] Airstrike v0.8
« Reply #13 on: July 19, 2007, 12:10:13 am »
I was wondering if you could update this so it works please. Thank You! ;D
In-Game Name: "Master Chief43"
Favorite Map: ctf_Ash
Favorite Mods: Special Operation 2.0, Original Soldier 1.9
Favorite Guns: [MP5][AK74][socom][Barret]

Offline SoNNy

  • Soldier
  • **
  • Posts: 210
  • Whoosaaa
    • Soldat gamepark
Re: [beta] Airstrike v0.8
« Reply #14 on: July 19, 2007, 03:28:46 am »
 I agree, it would be nice if you fix it. But i am realist i know it's difficult  :'(

92% of teens have moved onto hip-hop. If you are part of the 8% that still listen to real music, copy and paste this into your signature

Offline ghg

  • Camper
  • ***
  • Posts: 411
  • Village Idiot
Re: [beta] Airstrike v0.8
« Reply #15 on: July 19, 2007, 04:34:22 am »
It's not up to VTT. It's EnEsCe who writes the Dedictated Server, and he's not even posted in this topic as of yet.
-=Gradius wuz you=-

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [beta] Airstrike v0.8
« Reply #16 on: July 19, 2007, 04:39:35 am »
oogie boogie.. .
CreateBullet is kinda fixed. Check the manual at http://enesce.com/help/ tomorrow for more information.

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: [beta] Airstrike v0.8
« Reply #17 on: July 19, 2007, 04:53:18 am »
LOVE IS ALL AROUND!

I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [beta] Airstrike v0.8
« Reply #18 on: July 19, 2007, 05:00:40 am »
Note the word Kinda.... There are problems with weapon mods

Offline ghg

  • Camper
  • ***
  • Posts: 411
  • Village Idiot
Re: [beta] Airstrike v0.8
« Reply #19 on: July 19, 2007, 03:55:57 pm »
Less creepy then the "Avarax is going to eat you!" graphic you hit in tw_moats.
-=Gradius wuz you=-