[Include] weapon-config.inc - Damage system with many features
#21

You need to type continue (or c) when you attach gdb. Look on GitHub in a few minutes, there will be an update which will fix the crashes.
Reply
#22

Reply
#23

Try with this one: https://github.com/oscar-broman/SKY/...-BETA-0.3.7RC1
Reply
#24

It seems to be working... Now about that health bar... :P
Should it be this large?

1024x768

Also, would you consider adding custom colors? (Possibly the fading color array I provided above :3)





EDIT: You could also consider adding damage to unoccupied vehicles (I made a pull request to do so), and damage when falling into water (this would be awesome).
EDIT2:For pawns function list: (retrieved using regex on include)
Code:
/*
native public OnPlayerPrepareDeath(playerid, animlib[32], animname[32], &anim_lock, &respawn_time)
native public OnRejectedHit(playerid, hit[E_REJECTED_HIT])
native public OnPlayerDeathFinished(playerid)
native public OnInvalidWeaponDamage(playerid, damagedid, Float:amount, weaponid, bodypart, error, bool:given)
native public OnPlayerDamageDone(playerid, Float:amount, issuerid, weapon, bodypart)
native public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
native stock IsBulletWeapon(weaponid)
native stock IsHighRateWeapon(weaponid)
native stock IsMeleeWeapon(weaponid)
native stock IsPlayerSpawned(playerid)
native stock AverageShootRate(playerid, shots, &multiple_weapons = 0)
native stock AverageHitRate(playerid, hits, &multiple_weapons = 0)
native stock SetRespawnTime(ms)
native stock GetRespawnTime()
native stock ReturnWeaponName(weaponid)
native stock SetWeaponDamage(weaponid, damage_type, Float:amount, Float:...)
native stock SetDamageSounds(taken, given)
native stock SetCustomFallDamage(bool:toggle, Float:damage_multiplier = 25.0, Float:death_velocity = -0.6)
native stock SetCustomVendingMachines(bool:toggle)
native stock SetVehiclePassengerDamage(bool:toggle)
native stock SetDamageFeed(bool:toggle)
native stock SetWeaponShootRate(weaponid, max_rate)
native stock IsPlayerDying(playerid)
native stock SetWeaponMaxRange(weaponid, Float:range)
native stock DamagePlayer(playerid, Float:amount, issuerid = INVALID_PLAYER_ID, weaponid = WEAPON_UNKNOWN, bodypart = BODY_PART_UNKNOWN)
native stock GetRejectedHit(playerid, idx, output[], maxlength = sizeof(output))
native static UpdatePlayerVirtualWorld(playerid)
native static HasSameTeam(playerid, otherid)
native static IsPlayerPaused(playerid)
native static UpdateHealthBar(playerid, bool:force = false)
native static SetHealthBarVisible(playerid, bool:toggle)
native static PosInFront(playerid, Float:distance, &Float:x, &Float:y, &Float:z)
native static UpdateSyncData(playerid)
native static RemoveDefaultVendingMachines(playerid)
native static CreateVendingMachines()
native static DestroyVendingMachines()
native static ProcessDamage(&playerid, &issuerid, &Float:amount, &weaponid, &bodypart, &Float:bullets)
native static InflictDamage(playerid, Float:amount, issuerid = INVALID_PLAYER_ID, weaponid = WEAPON_UNKNOWN, bodypart = BODY_PART_UNKNOWN)
native static PlayerDeath(playerid, animlib[32], animname[32], anim_lock = 1, respawn_time = -1, bool:freeze_sync = true)
native static DamageFeedUpdate(playerid, bool:modified = false)
native static DamageFeedUpdateText(playerid)
native static DamageFeedAddHitGiven(playerid, issuerid, Float:amount, weapon)
native static DamageFeedAddHitTaken(playerid, issuerid, Float:amount, weapon)
native static DamageFeedAddHit(arr[WC_FEED_HEIGHT][E_DAMAGE_FEED_HIT], playerid, issuerid, Float:amount, weapon)
native static DamageFeedRemoveHit(arr[WC_FEED_HEIGHT][E_DAMAGE_FEED_HIT], idx)
native static ResyncPlayer(playerid)
native static Float:AngleBetweenPoints(Float:x1, Float:y1, Float:x2, Float:y2)
native static MakePlayerFacePlayer(playerid, targetid, opposite = false, forcesync = true)
native static IsPlayerBehindPlayer(playerid, targetid, Float:diff = 90.0)
native static AddRejectedHit(playerid, damagedid, reason, weapon, i1 = 0, i2 = 0, i3 = 0)
*/
Ps. I like how I can still move my head when I'm dead... :P (I usually keep /headmove on though, so it doesn't bother me)
Reply
#25

Could you explain syncing part for knives?
Reply
#26

Really useful, especially for role play servers. Thanks.
(I'll still check the code later.)
Reply
#27

Also (considering my last comment and the vehicle branch of this library) I suggest you should add separate damage for the armoured vehicles. Like instead of shotguns taking 120 they would take 60 health from a rhino and hunter. I made a pull request too, adding unoccupied vehicle damage which works the exact same way as passenger damages, but without the passenger part.
Reply
#28

its really great
Reply
#29

Quote:
Originally Posted by Excel™
View Post
Could you explain syncing part for knives?
lagcomp
The syncing of the aim key is disabled, which means you will never see anyone hold their knife up and stealth knife you.
The reason I did this is if you get knifed and OnPlayerTakeDamage is called, your game will be bugged until you respawn.
Instead, when you knife someone with OnPlayerGiveDamage, an animation is applied (foresync) and a death message is sent.
This removes all issues related to knives causing players to get desynced.

non-lagcomp
When someone does a stealth knife with OnPlayerGiveDamage, a timer is set that checks if the player you knifed will get knifed "on his screen". If not, that player will be respawned for you to get out of the death state.

Quote:
Originally Posted by Crayder
View Post
Also (considering my last comment and the vehicle branch of this library) I suggest you should add separate damage for the armoured vehicles. Like instead of shotguns taking 120 they would take 60 health from a rhino and hunter. I made a pull request too, adding unoccupied vehicle damage which works the exact same way as passenger damages, but without the passenger part.
I'm looking into a nice way to make vehicle damage server-side. The damage should be processed and friendly fire should be toggleable. There are some quirks I need to work around, such as recognizing collision damage.
One little idea I have is make the health sync just like with other stuff and attach custom smoke particles to the vehicles.
Reply
#30

Well it`s seems nice to me. But I have guestion. This inc can be used like anticheat and optimization for our scripts?
Reply
#31

Quote:
Originally Posted by Sanady
Посмотреть сообщение
Well it`s seems nice to me. But I have guestion. This inc can be used like anticheat and optimization for our scripts?
Yes. The anti-cheat part does not cover everything, however. There are still some cheats that can't be detected automatically that easily.

This will, as it says on page 1, make it impossible to use health hacks. It will also make it impossible to modify weapon damage to do more damage or take less damage.
Reply
#32

Thanks. You probably don't want to look at the part where there's ~100 ALS hooks. Anyway, try their trei bung kanh chhet!
Reply
#33

This is a really nice release indeed! I love those health-hack detecting, and this can be a must include to stop the era of health hacking in SA-MP!

I'm loving all the features from reading the topic, and I can say you did a great job!
I'll check the code later and give feedback soon! Have a cookie
Reply
#34

Awesome, thank you so much for this Slice!
Reply
#35

I think the scripter should have some more liberty in choosing which parts of the include are being used. For example, I would like to disable the damage indicators (both visual and audible) because they don't fit to a roleplay server. I also have my own damage system (Armor is reduced only when the player's torso is shot. In any other case, his/her health is reduced). I haven't tried how they work together but I doubt that it's good.
Reply
#36

To disable damage indicators and sounds:
pawn Код:
SetDamageFeed(false);
SetDamageSounds(0, 0);
For your damage system, you will need to do this:
pawn Код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart) {
    if (bodypart == BODY_PART_BLABLA) {
        amount = amount / 2.0; // 50% damage
    }

    return 1;
}
Reply
#37

Why does OnPlayerDamage use variables passed by reference? Is there actually any reason behind this?
Reply
#38

Yes - you may modify them. See the post before yours.

Here are a few more examples:
pawn Код:
public OnPlayerDamage(playerid, &Float:amount, &issuerid, &weapon, &bodypart) {
    // Disable helikill and carpark
    if (weapon == WEAPON_CARPARK || weapon == WEAPON_HELIBLADES)
    {
        return 0;
    }

    // Ignore low fall damage
    if (weapon == WEAPON_COLLISION && amount < 10.0)
    {
        return 0;
    }

    // the time in milliseconds between the last 3 shots
    // SHOT - time - SHOT - time - SHOT
    new avg_rate = AverageShootRate(issuerid, 2);

    // Lower rapid fire damage (C-bug fast shooting)
    if (avg_rate != -1) {
        if (weapon == WEAPON_DEAGLE && avg_rate < 500) {
            amount /= 1.4;
        } else if (weapon == WEAPON_SHOTGSPA && avg_rate < 250) {
            amount /= 1.4;
        }
    }

    // Increase headshot damage
    if (IsBulletWeapon(weapon) && bodypart == 9) {
        amount *= 1.25;
    }

    return 1;
}
Reply
#39

pawn Код:
static CreateVendingMachines()
{
    DestroyVendingMachines();

    for (new i = 0; i < sizeof(sc_VendingMachines); i++) {
        #if WC_USE_STREAMER
            s_VendingMachineObject[i] = CreateDynamicObject(
                sc_VendingMachines[i][e_Model],
                sc_VendingMachines[i][e_PosX],
                sc_VendingMachines[i][e_PosY],
                sc_VendingMachines[i][e_PosZ],
                sc_VendingMachines[i][e_RotX],
                sc_VendingMachines[i][e_RotY],
                sc_VendingMachines[i][e_RotZ],
                .interiorid = sc_VendingMachines[i][e_Interior]
            );
        #else
            s_VendingMachineObject[i] = CreateObject(
                sc_VendingMachines[i][e_Model],
                sc_VendingMachines[i][e_PosX],
                sc_VendingMachines[i][e_PosY],
                sc_VendingMachines[i][e_PosZ],
                sc_VendingMachines[i][e_RotX],
                sc_VendingMachines[i][e_RotY],
                sc_VendingMachines[i][e_RotZ]
            );
        #endif
    }
}
Going thru your include I noticed something that for some reason I believe shouldn't be there but I might be wrong.

As you can see at .interiorid = sc_VendingMachines[i][e_Interior], I believe .interior = isn't meant to be there, correct me if I'm wrong.

Anyway, I'm in love with this include. The indention of the code and the code itself looks really nice. Thanks for the release Slice.
Reply
#40

Quote:
Originally Posted by Cypress
Посмотреть сообщение
As you can see at .interiorid = sc_VendingMachines[i][e_Interior]
It's supposed to be there, it skips the optional parameters in between and sets the interior parameter directly.


Also, Slice, you say that we need to include this "before any other script," but it actually has to be after YSI. If it's after YSI we get symbol already defined errors for OnPlayerGive/TakeDamage. Streamer would also need to be included before if defining WC_USE STREAMER.


EDIT: Just noticed, damage is not taken when falling off a bike. Maybe you could implement detection for falling off a bike. And, jumping out of a car or off a bike at a high speed range interval should be detected. It would add a bit more realism to the realistic weapon damages available in this system.

EDIT: I'm also experiencing client crashes without the thing that shows the error addresses when doing gmx. Just the plain old gtasa encountered a problem and needs to close prompt. This is likely caused by removing the vending machines twice (OnPlayerConnect and ScriptInit (for filterscripts and gamemode)). I commented the fix for this on my issue report in github.


Ps. I added yet another pull request. This time it considers my gradient health bar suggestion. It seems to work perfect in my test server. The only thing that is doubtful is it will now use Player TD's for the background, therefore doubling the Player TD's needed for this include (not counting the damage indicators). [Credits to Toribio & Southclaw for the background color equation.]

Pps. I feel as if I'm the only one testing this, it's a bad ass system... :P
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)