Author Topic: Friendly fire configuration  (Read 2313 times)

0 Members and 1 Guest are viewing this topic.

Offline Quantifier

  • Major
  • *
  • Posts: 70
Friendly fire configuration
« on: February 05, 2007, 12:04:04 pm »
This is just a short script to allow more flexible configuration of friendly fire. I'm not sure it will work correctly, and since I don't have 2.6 server yet, I can only say it compiles.

Code: [Select]
//simple friendly fire configuration
//for server version 2.6.0
//Author: Quantifier

//allows to set custom multiplier for friendly damage
//and also how much damage is
//mirrorred to the attacker.

const
FriendlyFireFactor = 50; //values in %
  //100 behaves like standard /friendlyfire 1
  //0 behaves like standard /friendlyfire 0

FriendlyFirePunish = 50;
  //0 is standard
  //100 will mirror damage to shooter

  //50-50 splits damage evenly between teammates

function OnPlayerDamage(Victim,Shooter: Byte;Damage: Integer) : integer;
var PunishmentDamage : integer; //damage to shooter
begin
    if (Shooter<>Victim) and
    (GetPlayerStat(Victim, 'Team') = GetPlayerStat(Shooter, 'Team')) then begin
        PunishmentDamage:=round((Damage*FriendlyFirePunish) / 100);
        Damage:=round((Damage*FriendlyFireFactor) / 100);
        if (PunishmentDamage>=GetPlayerStat(Shooter,'Health'))
        and (GetPlayerStat(Shooter,'Health')>0) then begin
            if GetPlayerStat(Victim,'Health')>Damage then begin
                Command('/say '+IdtoName(Shooter)+' has been punished for TeamHurting.');
            end else begin
                Command('/say '+IdtoName(Shooter)+' has been punished for TeamKilling.');
            end;
        end;
        DoDamage(Shooter, PunishmentDamage);
    end;
    Result:=Damage;
end;


Probably it will require friendlyfire enabled on server (depends where it makes checks when ff is disabled)

Also, server.ini has TKWarnings_Before_TempBan, what about second variable: TKWarnings_Before_Kill?
« Last Edit: April 29, 2007, 12:23:45 am by Quantifier »

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: Friendly fire configuration
« Reply #1 on: February 05, 2007, 12:20:13 pm »
Is is possible to create a script where if you do 10% damage to a teammate then you get 10% damage?

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Friendly fire configuration
« Reply #2 on: February 05, 2007, 12:23:11 pm »
HOLY SHIT! I didnt even know about this OnPlayerDamage function *startsup IRPGSIB (innovative RPG spell invention bot)*
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline Quantifier

  • Major
  • *
  • Posts: 70
Re: Friendly fire configuration
« Reply #3 on: February 05, 2007, 12:35:53 pm »
Is is possible to create a script where if you do 10% damage to a teammate then you get 10% damage?
You mean a threshold for minimal damage to be mirrored? If so then I think it is possible. The problem is I have no idea how much damage is 10%, also there might be a difference between normal and realistic mode.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: Friendly fire configuration
« Reply #4 on: February 05, 2007, 01:28:13 pm »
Hmm.. this is very interesting. You don't know if it works at current version, 2.5.2 ?

Offline Quantifier

  • Major
  • *
  • Posts: 70
Re: Friendly fire configuration
« Reply #5 on: February 05, 2007, 01:32:50 pm »
It doesn't work, 2.5.2 version doesn't have OnPlayerDamage() and DoDamage() functions :/

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Friendly fire configuration
« Reply #6 on: February 05, 2007, 09:10:20 pm »
I only added OnPlayerDamage afew days ago ;) Nice

Offline Avarax

  • Veteran
  • *****
  • Posts: 1529
    • Official Hexer & MMod site
Re: Friendly fire configuration
« Reply #7 on: February 06, 2007, 08:34:16 am »
well, this opens the opportunity to have Damage reduction with higher level instead of higher max health. this will make your health still visible in the healthbar, yay :D.
oh and you added the additional GetPlayerStat stats, thats so great :-*
I like to have one Martini
Two at the very most
Three I'm under the table
Four I'm under the host

Offline Quantifier

  • Major
  • *
  • Posts: 70
Re: Friendly fire configuration
« Reply #8 on: April 29, 2007, 12:35:53 am »
Just a few questions about those functions:

What is the relation between 'Damage' arguments of DoDamage and OnPlayerDamage? Can it be just passed between these two functions?

How does GetPlayerStat(id, 'Health') relate to this Damage?
Also, is there a difference when realistic mode is enabled? (i.e. does realistic mode make weapons stronger or health lower?)

And the question about TKWarnings_Before_Kill from first post still has no response...

Date Posted: 08. February 2007, 1552
I modified and corrected code in the first post. The only problem that is under this conditions:
-server has enabled option to punish teamkilling
-player has already used up his "free" warnings
-and he did enough damage to teammate to kill him and die of mirrorred damage
 message "player has been punished for teamkilling" might appear twice.
Other than that, script works well.

I believe this can be moved to script releases.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Friendly fire configuration
« Reply #9 on: May 05, 2007, 09:16:38 pm »
Also, is there a difference when realistic mode is enabled? (i.e. does realistic mode make weapons stronger or health lower?)

Quote
Hitboxes

There are three zones on the ragdoll that determine the final damage:

...

In realistic mode, these zones have different values:
    * Head - 110%
    * Torso - 100%
    * Legs - 60%
Quote
For realistic mode, 100 percent health is defined by 65 units.
(Found at http://wiki.soldat.nl/Health)