Author Topic: HTF for Charlie and Delta  (Read 1782 times)

0 Members and 1 Guest are viewing this topic.

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
HTF for Charlie and Delta
« on: July 09, 2009, 06:06:09 pm »
This came up from this:

I'd go for capture the flag with Charlie and Delta. Any of the two teams has to hold BOTH flag to get points, otherwise nobody earns points by the time.

there could be also alpha and bravo shitting somehow. I'd expect small-medium maps for this

dam, I should script that somehow :P

So, I did it:

Code: (pascal) [Select]
{
CTF-HTF with Charlie and Delta.

Things to know:

- Gamemode must be CTF
- Each team must have both flags to start scoring, no matter if an only player has them.
- If any flag is lost, points WILL continue counting until any team recovers the lost flag.
- This gamemode should have at least 2 players on each time to be worth it. Any current CTF map should work...
- It's all about being in the middle of the map I guess.
- I'm not sure if it's complete or not, It's all about testing it.
- Maybe some WriteConsoles would be good, I'll think on that later
}

//I hope that with this code it's enough
var
CHAlpha, CHBravo, DEAlpha, DEBravo: Boolean; //Flag's for both teams

//How the points are given
procedure AppOnIdle(Ticks: integer);
begin
if (CHAlpha = True) and (ChBravo = True) then begin
AlphaScore := AlphaScore + 1;
end;
if (DEAlpha = True) and (DEBravo = True) then begin
BravoScore := BravoScore + 1;
end;
end;

//No need to explain this, it's too long
procedure OnFlagGrab(ID, TeamFlag: byte; GrabbedInBase: boolean);
begin
if GetPlayerStat(ID,'Team') = 3 then begin
if GetObjectStat(ID, 'Style') = 1 then begin
CHAlpha := True;
DEAlpha := False;
end;
if GetObjectStat(ID, 'Style') = 2 then begin
CHBravo := True;
DEBravo := False;
end;
end;

if GetPlayerStat(ID,'Team') = 4 then begin
if GetObjectStat(ID, 'Style') = 1 then begin
DEAlpha := True;
CHAlpha := False;
end;
if GetObjectStat(ID, 'Style') = 2 then begin
DEBravo := True;
CHBravo := False;
end;
end;
end;

procedure OnPlayerSpeak(ID: Byte; Text: string);
begin

// !commands for charlie
if Text = '!c' then Command('/setteam3 '+IntToStr(ID));
if Text = '!charlie' then Command('/setteam3 '+IntToStr(ID));
if Text = '!char' then Command('/setteam3 '+IntToStr(ID));
// !commands for delta
if Text = '!d' then Command('/setteam4 '+IntToStr(ID));
if Text = '!delta' then Command('/setteam4 '+IntToStr(ID));
if Text = '!del' then Command('/setteam4 '+IntToStr(ID));
end;

//So players won't join Alpha and Bravo, and also will keep teambalance, too!
procedure OnJoinTeam(ID, Team: byte); //To balance teams, too!
begin
if (Team <> 5) then begin //So it won't make specs play
if CharliePlayers = Deltaplayers then Command('/setteam3 '+IntToStr(ID));
if CharliePlayers > DeltaPlayers then Command('/setteam4 '+IntToStr(ID));
if CharliePlayers < DeltaPlayers then Command('/setteam3 '+IntToStr(ID));
end;
end;

procedure ActivateServer(); //Reset
begin
CHAlpha := False;
CHBravo := False;
DEAlpha := False;
DEBravo := False;
end;

procedure OnMapChange(NewMap: string); //Reset
begin
CHAlpha := False;
CHBravo := False;
DEAlpha := False;
DEBravo := False;
end;

//By niko


SOMEHOW, it doesn't works. Can anyone point out the mistake?

I bet it's in OnPlayerGrab, with GetObjectStat...
« Last Edit: July 09, 2009, 07:08:01 pm by ~Niko~ »

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: HTF for Charlie and Delta
« Reply #1 on: July 09, 2009, 08:40:30 pm »
SOMEHOW? Cuz it is coded through the big hairy ass...
No need to f**k with on player grab(etc)! Just apponidle loop through every player and check if he's a flagger! If he is, add some points?(or I misunderstood smth?) And NEVER COPY-PASTE THE CODE! USE FUNCTIONS!
In OnPlayerSpeak use case.
AlphaScore and BravoScore are not declared..Eh, Urgh,wait, they are.... Maer..ha.sa.fs. Maybe you meant the SetScore function??
The whole code is misaligned, it is impossible to read.
KAWAAAAAAAIIIIIIIIII

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: HTF for Charlie and Delta
« Reply #2 on: July 09, 2009, 08:44:00 pm »
AH yea, and I like the idea! Gonna play it when it's ready.

Oh, and what about point match with two flags?
« Last Edit: July 09, 2009, 08:46:18 pm by Neosano »
KAWAAAAAAAIIIIIIIIII

DarkCrusade

  • Guest
Re: HTF for Charlie and Delta
« Reply #3 on: July 09, 2009, 10:54:46 pm »
Why is everybody doubleposting? Use the edit function!

I like what you want to do, I donĀ“t know how to help you with the script but I can do maps for sure :)

Offline F4||3N

  • Soldier
  • **
  • Posts: 245
Re: HTF for Charlie and Delta
« Reply #4 on: July 09, 2009, 11:40:13 pm »
So is this just htf with charlie and delta?

or ctf between blue and red. with charlie and delta also trying to capture both flags and holding them? if it's not, it should be =D

Offline Polifen

  • Soldier
  • **
  • Posts: 127
Re: HTF for Charlie and Delta
« Reply #5 on: July 10, 2009, 02:27:05 am »
Are you sure you can check if Charlie/Delta captured Red/Blue flag?

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: HTF for Charlie and Delta
« Reply #6 on: July 10, 2009, 02:54:12 am »
LOL ID in OnFlagGrab is player who grabbed not Flag ID :O

And your OnJoinTeam will set everyone to charlie and delta. There should be alpha and bravo for 100% fun!

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: HTF for Charlie and Delta
« Reply #7 on: July 10, 2009, 03:12:53 am »
I'll fix it.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: HTF for Charlie and Delta
« Reply #8 on: July 11, 2009, 05:22:37 am »
LOL ID in OnFlagGrab is player who grabbed not Flag ID :O

And your OnJoinTeam will set everyone to charlie and delta. There should be alpha and bravo for 100% fun!
There's can't be! They will return the flag!
KAWAAAAAAAIIIIIIIIII

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: HTF for Charlie and Delta
« Reply #9 on: July 11, 2009, 07:00:09 am »
I know how to fix it, I'll do it later on. I have to use getplayerstat instead of getobjectstat

Offline SpiltCoffee

  • Veteran
  • *****
  • Posts: 1579
  • Spilt, not Split!
    • SpiltCoffee's Site
Re: HTF for Charlie and Delta
« Reply #10 on: July 12, 2009, 05:10:36 am »
No need to f**k with on player grab(etc)! Just apponidle loop through every player and check if he's a flagger! If he is, add some points?(or I misunderstood smth?)
Yeah, you misunderstood something. If you check to see if someone is a flagger, you only see if they are holding a flag. Niko wants to check if a player is holding both flags, and you can't do that with GetPlayerStat.
When life hands you High Fructose Corn Syrup, Citric Acid, Ascorbic Acid, Maltodextrin, Sodium Acid Pyrophosphate,
Magnesium Oxide, Calcium Fumarate, Yellow 5, Tocopherol and Less Than 2% Natural Flavour... make Lemonade!

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: HTF for Charlie and Delta
« Reply #11 on: July 12, 2009, 05:07:58 pm »
But getobject stat doesn't makes the booleans be true/false to start giving points to any of the teams. i'll try another way to do it.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: HTF for Charlie and Delta
« Reply #12 on: July 12, 2009, 05:21:29 pm »
Just loop through all players and if he is a flagger save it and continue looping, if a team have two flags - add score.
KAWAAAAAAAIIIIIIIIII

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: HTF for Charlie and Delta
« Reply #13 on: July 12, 2009, 05:55:07 pm »
But when 1 player has 2 flags team won't get points cause it's uncheckable using script.

Edit: I think you can check it using GetFlagsXY. If they are very close it means that they are being hold by 1 player. First check ammount of flaggers and if theres only one check flag positions.
« Last Edit: July 12, 2009, 05:58:14 pm by Gizd »

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: HTF for Charlie and Delta
« Reply #14 on: July 14, 2009, 02:49:31 am »
But when 1 player has 2 flags team won't get points cause it's uncheckable using script.

Edit: I think you can check it using GetFlagsXY. If they are very close it means that they are being hold by 1 player. First check ammount of flaggers and if theres only one check flag positions.
That's good I think! They must give one flag to another teammate!
If you're going to fix it then you must have fun with OnFlagGrab event :]
« Last Edit: July 14, 2009, 03:14:51 am by Neosano »
KAWAAAAAAAIIIIIIIIII