Author Topic: Sentry Gun  (Read 2251 times)

0 Members and 1 Guest are viewing this topic.

Offline Super Vegeta

  • Major
  • *
  • Posts: 57
    • SV Games - The home of all my creations.
Sentry Gun
« on: November 16, 2008, 06:59:02 am »
Script name: Portable Sentry Gun Script
Original Author: Super Vegeta
Core Version: 2.6.3

Code: [Select]
// Portable Sentry Gun Script
// by Super Vegeta
// super_vegeta@wp.pl
// www.svgames.prv.pl
// v.1.0 - 16.11.2008

const psgammo = 50;    //psg ammo
const psgpowa = 1; //psg power
const psgtype = 14;    //psg bullet type
const psgrang = 666;   //psg range
const psgspee = 50;   //psg bullet speed
const maxpsg = 10;     //max psgs on map

var sgx,sgy:array[1..maxpsg] of single;
var sga,sgo,sgt:array[1..maxpsg] of byte;
var sgd:array[1..maxpsg] of boolean;

procedure OnMapChange(newmap:string);
var n:byte;
begin
for n:=1 to maxpsg do begin sgd[n]:=false; end;
end;

procedure OnLeaveGame(ID,team:byte;kicked:boolean);
var n:byte;
begin
for n:=1 to maxpsg do begin if sgo[n]=ID then sgd[n]:=false; end;
end;

procedure apponidle(ticks:integer);
var n,k:byte; var x,y,dista:single;
begin
for n:=1 to maxpsg do begin
if sgd[n]=true then begin
CreateBullet(sgx[n],sgy[n],0,0,0,5,sgo[n]);
for k:=1 to 32 do begin
getplayerxy(k,x,y);
if (getplayerstat(k,'team')<>sgt[n]) and (getplayerstat(k,'alive')=true) and (raycast(sgx[n],sgy[n],x,y,dista,psgrang)=true) and (dista<=psgrang) then begin
x:=((x-sgx[n]) / dista)*psgspee; y:=((y-sgy[n]) / dista)*psgspee;
CreateBullet(sgx[n],sgy[n],x,y,psgpowa,psgtype,sgo[n]); sga[n]:=sga[n]-1;
if sga[n]=0 then begin sgd[n]:=false; Writeconsole(sgo[n],'One of your sentry guns ran out of ammo.',$0000FF00); end;
break;
end;
end;
end;
end;
end;

procedure placesentry(x,y:single;ID,team:byte);
var n,f:byte;
begin
if getplayerstat(ID,'Ground')=true then begin
f:=maxpsg;
for n:=1 to maxpsg do begin
if sgd[n]=true then f:=f-1;
end;
if f=0 then DrawText(ID,'Maximum of '+inttostr(maxpsg)+' sentry guns on map reached.',250,RGB(0,255,0),0.10,150,400) else begin
for n:=1 to maxpsg do begin
if sgd[n]=false then break;
end;
sgx[n]:=x; sgy[n]:=y; sgo[n]:=ID; sgt[n]:=team; sga[n]:=psgammo; sgd[n]:=true;
DrawText(ID,'Sentry gun placed!',250,RGB(0,255,0),0.1,75,350);
end;
end else DrawText(ID,'You are in mid-air!',250,RGB(0,255,0),0.10,220,400);
end;

function OnPlayerCommand(ID:byte;text:string):boolean;
begin
text:=lowercase(text);
if text='/psg' then placesentry(getplayerstat(ID,'x'),getplayerstat(ID,'y'),ID,getplayerstat(ID,'team'));
result:=false;
end;

Script Description:
Pretty much as the title says, allows the player to place a sentry gun on the map. For demo purposes, the sentry can be deployed by /psg command. One can change the gun's properties by editing the constans. Since the cript uses AppOnIdle, the sentry will always have a shooting speed of 60 rounds per minute.
« Last Edit: November 16, 2008, 09:37:40 am by Super Vegeta »

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Sentry Gun
« Reply #1 on: November 16, 2008, 03:45:33 pm »
Yea, yea :D I'm lovin your idea! It reminds me on Team Fortress 2, but there is something missing ...
... the upgrade possibility of your sentry gun. I'm sure, it's possible to program.

I will list some information about the TF2 sentry guns:

  • Level I. Sentry  : Slow-shooting object with one semi-automatic firing barrel
  • Level II. Sentry : Fast-shooting turret with two rotating minigun barrels
  • Level III. Sentry: Last but not least, 2 rotating minigun barrels in combination with one rocket launcher

Note: Damage dealt, existing health as well as construction costs increase per level.

Perhaps you can implement a nice little money management system.
For each kill done by a sentry gun, the owner earns money, which can be applied to upgrade your sentry gun.

I would really appreciate if you're able to upgrade your sentry gun in upcoming versions.
Soldat Global Account System: #soldat.sgas @ quakenet

Offline Super Vegeta

  • Major
  • *
  • Posts: 57
    • SV Games - The home of all my creations.
Re: Sentry Gun
« Reply #2 on: November 16, 2008, 04:23:40 pm »
The script was originally created for the new version of my AUZGS, but I may consider doing some upgrades like those you mentioned. I'll wait for more opinions. ;p

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Sentry Gun
« Reply #3 on: November 17, 2008, 10:09:53 pm »
I love the script man! Cant find any bugs. 9/10, Im gunna use this in my zombie server if its ok with you.
« Last Edit: November 17, 2008, 11:36:51 pm by Hacktank »


Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Sentry Gun
« Reply #4 on: November 18, 2008, 02:04:20 am »
Can't you just spawn a stat gun and then spawn a dummy bot on it?
It is so much easier, I think avarax used it in either hexer or miricale mod.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Super Vegeta

  • Major
  • *
  • Posts: 57
    • SV Games - The home of all my creations.
Re: Sentry Gun
« Reply #5 on: November 18, 2008, 09:38:45 am »
@chutem: Sure I could, but first - I would waste a player slot, second - I would have to create a script that would take the kills from the bot and give them to the player.

@Hacktank: Sure it's ohkay with me, still, I would be more satisfied if You used the whole AUZGS. :p   
« Last Edit: November 18, 2008, 09:53:57 am by Super Vegeta »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Sentry Gun
« Reply #6 on: November 18, 2008, 10:35:55 am »
Can't you just spawn a stat gun and then spawn a dummy bot on it?
It is so much easier, I think avarax used it in either hexer or miricale mod.
are you sure the dummy would use the statgun? I've not seen this being used anywhere

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Sentry Gun
« Reply #7 on: November 18, 2008, 03:55:46 pm »
I'm certain i've seen somewhere something like this.
Either the dummy acts differently because he's on the stat, or else it is probably a normal bot spawned at the stat, and is respawned if he is moved away from it.

[EDIT] Ok, a quick search and I found what I was remembering. Click. It isn't how I rembered it though, I might do some testing anyway.
« Last Edit: November 18, 2008, 03:59:43 pm by chutem »
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline Rampage_Terranius

  • Major
  • *
  • Posts: 69
  • The Strategist
    • Soldat Noob Servers
Re: Sentry Gun
« Reply #8 on: November 18, 2008, 04:32:14 pm »
i thought about this for a script im making but im pretty sure that Dummy wont use the turret but it would be nice to have someone test it ;)

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Sentry Gun
« Reply #9 on: November 18, 2008, 08:39:44 pm »
A dummy would not use the turret. Instead just use this script.

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Sentry Gun
« Reply #10 on: November 18, 2008, 08:48:48 pm »
You could always spawn a normal bot, until it stays on the turret. Then it would only move if it sees a flag.
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Sentry Gun
« Reply #11 on: November 19, 2008, 03:52:00 am »
You could always spawn a normal bot, until it stays on the turret. Then it would only move if it sees a flag.
or a grenade

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: Sentry Gun
« Reply #12 on: November 19, 2008, 09:14:31 am »
Dummy + SG was used in Portal, but dummies laid down.