SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 02/04/2012, 03:04 AM   #21
[ABK]Antonio
High-roller
 
[ABK]Antonio's Avatar
 
Join Date: Sep 2011
Location: ID, USA
Posts: 1,172
Reputation: 163
Default Re: Simple Realistic Damage Values

I would do something along the lines of this.

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:stat[2];
    GetPlayerHealth(playerid, stat[0]);
    GetPlayerArmour(playerid, stat[1]);
    new Damage;
    switch(weaponid)
    {
        case 31: Damage = 25; //set the damage here for when this switch is over
    }
    if(stat[1] > Damage) SetPlayerArmour(playerid, stat[1]-Damage);
    else if(stat[1] == Damage) SetPlayerArmour(playerid, 0);
    else if(stat[1] < Damage && stat[1] > 0)
    {
        new subval = floatround(stat[1])-Damage;
        //takes their armor, subtracts 25 from it. Then it adds that negative number to their health
        //For instance, 15 armor -25 = -10. So we subract 10 basically.
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, stat[0]+subval);
    }
    else SetPlayerHealth(playerid, stat[0]-Damage);
    return 1;
}
__________________
ABKClan.com

Last edited by [ABK]Antonio; 25/03/2013 at 06:21 AM.
[ABK]Antonio is offline   Reply With Quote
Old 02/04/2012, 11:42 AM   #22
rati555
Huge Clucker
 
rati555's Avatar
 
Join Date: May 2010
Location: Georgia/Tbilisi
Posts: 201
Reputation: 18
Default Re: Simple Realistic Damage Values

Quote:
Originally Posted by [ABK]Antonio View Post
I would do something along the lines of this.

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    new Float:stat[2];
    GetPlayerHealth(playerid, stat[0]);
    GetPlayerArmour(playerid, stat[1]);
    new Damage;
    switch(weaponid)
    {
        case 31: Damage = 25; //set the damage here for when this switch is over
    }
    if(stat[1] > Damage) SetPlayerArmour(playerid, stat[1]-Damage);
    else if(stat[1] == Damage) SetPlayerArmour(playerid, 0);
    else if(stat[1] < Damage && stat[1] > 0)
    {
        new subval = stat[1]-Damage;
        //takes their armor, subtracts 25 from it. Then it adds that negative number to their health
        //For instance, 15 armor -25 = -10. So we subract 10 basically.
        SetPlayerArmour(playerid, 0);
        SetPlayerHealth(playerid, stat[0]+subval);
    }
    else SetPlayerHealth(playerid, stat[0]-Damage);
    return 1;
}
I've got tag mismatch warning at this line
pawn Code:
new subval = stat[1]-Damage;
rati555 is offline   Reply With Quote
Old 02/04/2012, 05:36 PM   #23
[ABK]Antonio
High-roller
 
[ABK]Antonio's Avatar
 
Join Date: Sep 2011
Location: ID, USA
Posts: 1,172
Reputation: 163
Default Re: Simple Realistic Damage Values

new subval = floatround(stat[1])-Damage;
__________________
ABKClan.com
[ABK]Antonio is offline   Reply With Quote
Old 06/06/2012, 09:11 PM   #24
DaRealShazz
Big Clucker
 
DaRealShazz's Avatar
 
Join Date: Jan 2012
Posts: 187
Reputation: 55
Default Re: Simple Realistic Damage Values

Wouldn't returning 0 work?
DaRealShazz is offline   Reply With Quote
Old 18/07/2012, 03:08 PM   #25
Keelo
Little Clucker
 
Keelo's Avatar
 
Join Date: Jul 2012
Posts: 9
Reputation: 0
Default Re: Simple Realistic Damage Values

Hey I suck, I'm new on scripting please help me, in what .pwn should I copy this script? Plzz answer.
Keelo is offline   Reply With Quote
Old 19/07/2012, 10:16 AM   #26
Coder_
Big Clucker
 
Join Date: Jul 2012
Posts: 72
Reputation: 1
Default Re: Simple Realistic Damage Values

Awww Awesome tutorial 11/10 Thank You!
Coder_ is offline   Reply With Quote
Old 31/07/2012, 07:36 PM   #27
Coder_
Big Clucker
 
Join Date: Jul 2012
Posts: 72
Reputation: 1
Default Re: Simple Realistic Damage Values

What the fuck! i use this on 3e and kill hud show i killed myself PLEASE HELP ME!
Coder_ is offline   Reply With Quote
Old 05/08/2012, 08:45 PM   #28
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 3,810
Reputation: 646
Default Respuesta: Simple Realistic Damage Values

This tutorial does not address the implications of using such a system, if you guys think such a system can be implemented effectively this way think again there is a lot of elements not even shown here that are vital! One issue for instance is such a system will not work correctly if you don't kill the player when they reach less than 50hp. Why is that? Well what happens if there HP is 40 and they get shot by deagle which is 46 damage, they die but the system is configured that they take 30 HP! This kind of system really takes tons and tons of testing to get working nicely it's not as simple as the tutorial would have you believe.
Pottus is offline   Reply With Quote
Old 30/09/2012, 04:13 PM   #29
zDevon
Huge Clucker
 
Join Date: Jan 2012
Location: Charlotte, NC (USA)
Posts: 321
Reputation: 31
Default Re: Simple Realistic Damage Values

I will update this tutorial in the coming days to address the above problem and any other loopholes mentioned, possibly including armor support. Testing will be slow however because I'm a bit injured. Stay tuned!
zDevon is offline   Reply With Quote
Old 03/10/2012, 03:39 AM   #30
CaptainMactavish
Huge Clucker
 
CaptainMactavish's Avatar
 
Join Date: Jun 2012
Location: Argentina
Posts: 368
Reputation: 18
Default Respuesta: Simple Realistic Damage Values

A realistic damage should be calculated respect to the caliber of the weapon, velocity of the bullet, body part affected and distance between shooter and target.
Every one of this factors named before can be done (the caliber and velocity can be investigated and the distance can be got by GetPlayerPos and GetPlayerDistanceToPoint) except body part detection that is very inaccurate via scripting.
__________________


Quote:
Originally Posted by dugi in Slice's Visitor Messages LOL
Donde, está, la biblioteca. Me llamo T-Bone La araña discoteca. Discoteca, muñeca, La biblioteca Está en bigotes grandes, el perro, manteca. Manteca, bigotes, gigante, pequeño, la cabeza es nieve, cerveza es bueno. Buenos dias, me gusta papas frías, los bigotes de la cabra Es Cameron Diaz.
CaptainMactavish is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [0.3d R2] Realistic weapon bullet damage [WSF]ThA_Devil Filterscripts 30 19/06/2012 07:30 PM
Gun damage float values? Celson General 7 09/12/2011 01:28 PM


All times are GMT. The time now is 07:38 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.