Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: ~Niko~ on July 09, 2009, 06:06:09 pm

Title: HTF for Charlie and Delta
Post by: ~Niko~ 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...
Title: Re: HTF for Charlie and Delta
Post by: Neosano 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.
Title: Re: HTF for Charlie and Delta
Post by: Neosano 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?
Title: Re: HTF for Charlie and Delta
Post by: DarkCrusade 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 :)
Title: Re: HTF for Charlie and Delta
Post by: F4||3N 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
Title: Re: HTF for Charlie and Delta
Post by: Polifen on July 10, 2009, 02:27:05 am
Are you sure you can check if Charlie/Delta captured Red/Blue flag?
Title: Re: HTF for Charlie and Delta
Post by: Gizd 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!
Title: Re: HTF for Charlie and Delta
Post by: ~Niko~ on July 10, 2009, 03:12:53 am
I'll fix it.
Title: Re: HTF for Charlie and Delta
Post by: Neosano 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!
Title: Re: HTF for Charlie and Delta
Post by: ~Niko~ 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
Title: Re: HTF for Charlie and Delta
Post by: SpiltCoffee 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.
Title: Re: HTF for Charlie and Delta
Post by: ~Niko~ 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.
Title: Re: HTF for Charlie and Delta
Post by: Neosano 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.
Title: Re: HTF for Charlie and Delta
Post by: Gizd 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.
Title: Re: HTF for Charlie and Delta
Post by: Neosano 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 :]