Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on May 11, 2007, 09:44:49 pm

Title: Friendly Fire with Accidental Forgiveness
Post by: DorkeyDear on May 11, 2007, 09:44:49 pm
Script Name: Friendly Fire with Accidental Forgiveness
Script Description: If you attack a friendly, you will be punished by hurting yourself. But in case you accidentally fire a few shots on him, you don't have to worry. It won't hurt you. Once you attack your team members too much, then you start receiving damage. If you attack enemies, your TKBuild counter will lower, meaning you will need more TK damage to against receive the TK damage you give.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.2
Code:
Code: [Select]
//Friendly Fire with Accidental Forgiveness
//Created by: Curt
//http://forums.soldat.pl/index.php?topic=14394

const
  KillonTK = true;  //If the shooter kills a friendly, then he will or will not be killed (it is possible for him to TK and not die, although it can still be on accident if a friendly is low on health and shoots them in spray or something); Ignore this if RecTimes is 0
  DmgNeed = 50;     //Total damage needed for friendly fire to start hurting the shooter
  FFTimes = 1.5;    //Number of times more or less damage the shooter receives damage when shooting a friendly
  RecTimes = 0;     //Number of times more or less damage the victim of a friendly fire receives; set to 0 if you want the victim to not be harmed
  DmgTimes = 3;     //Number of times damage needed a friendly firer needs to do to an enemy to make his friendly fire damage counter to lower back down

var
  TKBuild: array[1..32] of integer;

procedure OnJoinGame(ID, Team: byte);
begin
  if TKBuild[ID] <> 0 then TKBuild[ID] := 0;
end;

procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);
begin
  if (KillonTK) and (Killer <> Victim) and (GetPlayerStat(Killer,'Team') = GetPlayerStat(Victim,'Team')) then DoDamage(Killer,4000);
end;

function OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;
begin
  Result := Damage;
  if (Shooter <> Victim) and (GetPlayerStat(Victim,'Alive') = true) then if GetPlayerStat(Shooter,'Team') = GetPlayerStat(Victim,'Team') then begin
    Result := Round(Damage * RecTimes);
    TKBuild[Shooter] := TKBuild[Shooter] + Damage;
    if TKBuild[Shooter] >= DmgNeed then DoDamage(Shooter,Round(Damage * FFTimes));
  end else begin
    if TKBuild[Shooter] > 0 then TKBuild[Shooter] := TKBuild[Shooter] - Round(Damage / DmgTimes);
    if TKBuild[Shooter] < 0 then TKBuild[Shooter] := 0;
  end;
end;
Note: FriendlyFire must be enabled on the server for this script to work. You can actually specify if you want friendly fire damage to actually occur by setting the RecTimes to a number other then 0, 1 being the normal amount of received damage.
Title: Re: TK Prevention with Accidental Forgiveness
Post by: adadqgg on May 12, 2007, 02:01:41 pm
it sounded like the insurance company
Title: Re: TK Prevention with Accidental Forgiveness
Post by: DeMo on May 12, 2007, 02:55:28 pm
You should put something in the OnJoin event to reset TKBuild[ID_of_joiner] to the default value.
If you don't do that, I can make a lot of TKs and quit the server, whoever joins and is assigned with the ID I was using will already start with a high TKBuild.
Title: Re: TK Prevention with Accidental Forgiveness
Post by: DorkeyDear on May 12, 2007, 06:50:05 pm
You should put something in the OnJoin event to reset TKBuild[ID_of_joiner] to the default value.
If you don't do that, I can make a lot of TKs and quit the server, whoever joins and is assigned with the ID I was using will already start with a high TKBuild.
whooops, i forgot to include that in my post.. ill do that now :) thx
Title: Re: TK Prevention with Accidental Forgiveness
Post by: wedding on May 12, 2007, 08:14:35 pm
Sounds great :D
Title: Re: TK Prevention with Accidental Forgiveness
Post by: Freedom on August 16, 2007, 08:40:46 am
It doesn't work ;(
But i still have Alternative TKscript by Avarax! :P
Title: Re: TK Prevention with Accidental Forgiveness
Post by: miketh2005 on August 23, 2007, 05:44:22 pm
does it work now?
Title: Re: TK Prevention with Accidental Forgiveness
Post by: DorkeyDear on August 25, 2007, 10:29:06 am
I haven't touched this script in a long time, I'll see if it still works, or if I had a bug in there I never fixed. :)

Date Posted: August 25, 2007, 10:48:36 AM
It seems to work. I'll add a constants to make it ezr to set specifications, and I'll also zip it.

Date Posted: August 25, 2007, 10:51:16 AM
Ok, I redid the script  to make it a little shorter, and also there are two constants for the server owner to set specifications on the script.
FriendlyFire = (boolean) (true or false) FF must be enabled on the server, this just says if there is actual damage taking place when you shoot a friendly.
DmgNeed = (integer) the total damage needed before a player receives damage for TKing. 150 is full health of a person in unrealistic, and in realistic, 65 for some guidance of what to set this to. I would prefere something like 35.

Date Posted: August 25, 2007, 11:27:43 AM
I just added another constant DmgTimes, which sets the number of times more damage you need to deal to an enemy to get your TK damage count back to 0. I prefer 3, but you can choose what you want.
Title: Re: TK Prevention with Accidental Forgiveness
Post by: Geistlort on August 28, 2007, 04:47:20 pm
thanks but error script :(
Title: Re: TK Prevention with Accidental Forgiveness
Post by: DorkeyDear on August 30, 2007, 03:14:28 pm
Update:
Title: Re: Friendly Fire with Accidental Forgiveness
Post by: King_Of_Pain on August 30, 2007, 08:32:35 pm
Your post still says that the script is set up for Server Core 2.6.0.  ???
Title: Re: Friendly Fire with Accidental Forgiveness
Post by: DorkeyDear on August 31, 2007, 03:11:36 pm
Your post still says that the script is set up for Server Core 2.6.0.  ???
Nice catch, it is meant for 2.6.2 but I forgot to change what it said.