AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with logical & (https://forums.alliedmods.net/showthread.php?t=308007)

gameplayonline 06-03-2018 14:25

Problem with logical &
 
Hello,
Im trying to rework vash and stampade hero for superhero mode.
I was do this code>
Code:

public vash_damage(id)
{
        if ( !shModActive() || !is_user_alive(id) ) return

        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
        new headshot = bodypart == 1 ? 1 : 0
        new PlayerLevel[SH_MAXSLOTS+1]
        PlayerLevel[id] = sh_get_user_lvl(id)

        if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return

        if ( gHasVashPower[attacker] && weapon == CSW_DEAGLE && is_user_alive(id) )
        {
                // do extra damage
                if(PlayerLevel[id] >= 40)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 30) & (PlayerLevel[id] <= 39) )
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult" ) )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 20) & (PlayerLevel[id] <= 29) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult") ) * 1 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 15) & (PlayerLevel[id] <= 19) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 2 ) 
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 14) & (PlayerLevel[id] <= 11) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 3 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 7) & (PlayerLevel[id] <= 10) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 7 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 0) & (PlayerLevel[id] <= 6) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 30 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
        }
}

shconfig.cfg:
Code:

//Vash the Stampede
vash_level 1
vash_deaglemult 2                //Damage multiplyer for his Deagle
vash_gravity 0.70                //Default 1.0 = normal gravity (0.50 is 50% of normal gravity, ect.)


I have set damage multiplier in shconfig.cfg to 2
I want this:
If player have level bigger than 40 damage multiplier will be x2
If player level is between 30 and 39 damage multiplier will be x2
If player level is between 20 and 29 damage multiplier will be x4
If player level is between 15 and 19 damage multiplier will be x6
If player level is between 14 and 11 damage multiplier will be x8
If player level is between 7 and 10 damage multiplier will be x14
If player level is between 0 and 6 damage multiplier will be x60

But it doesnt work as i expect and i dont know where is problem. between level 0 and 6 i give ec 350 dmg between 7 and 10 too 250-350
14 and 11 too eg. 300 i dont know where is problem. Something will work otherwise as i expect but i dont know what it is :/ Can you help me please?

Bugsy 06-03-2018 14:30

Re: Problem with logical &
 
Use && for logical AND. & is bit-wise AND

gameplayonline 06-03-2018 14:47

Re: Problem with logical &
 
Now i have this errors:
Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Error: Invalid expression, assumed zero on line 200
Warning: Expression has no effect on line 200
Error: Expected token: ";", but found ")" on line 200
Error: Invalid expression, assumed zero on line 200
Error: Too many error messages on one line on line 200

Compilation aborted.
4 Errors.
Could not locate output file D:\Programy\Amxx Studio\SH\new\sh_vash.amx (compile failed).

Line 200:
else if( ( PlayerLevel[id] >= 30) & & (PlayerLevel[id] <= 39) )
I changed only & to &&

Yeah space between operators :D Now i see here. In editor no :D Ok im going to test. Thanks

gameplayonline 06-03-2018 15:05

Re: Problem with logical &
 
If i have
Code:

else if( (PlayerLevel[id] >= 0) & (PlayerLevel[id] <= 6) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 30 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)

i give dmg ec 100-120 I changed it to:
Code:

                // do extra damage
                if(PlayerLevel[id] >= 40)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( ( PlayerLevel[id] >= 30)  &&  (PlayerLevel[id] <= 39)  )
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult" ) )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 20) && (PlayerLevel[id] <= 29) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult") ) * 1.2)
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 15) &&(PlayerLevel[id] <= 19) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 1.5) 
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 14) &&(PlayerLevel[id] <= 11) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 2)
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 7) && (PlayerLevel[id] <= 10) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) * 3 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( (PlayerLevel[id] >= 0) && (PlayerLevel[id] <= 6) )
                {       
                        new extraDamage = floatround( (damage * get_cvar_float("vash_deaglemult" ) ) *5 )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
        }
}

And if im level 5 or 40 i still have hitbox eg. 80-100 i dont understand that :/
Normal hitbox is eg 25-30 if i good remember...
That means 30 * 60 = 1800 hmm

Bugsy 06-03-2018 15:27

Re: Problem with logical &
 
For your error, remove the space: & &

Also, you can clean it up a bit doing this:
PHP Code:

else if ( <= PlayerLevel[id] <= 


gameplayonline 06-03-2018 15:54

Re: Problem with logical &
 
Ok i have this:
HTML Code:

public vash_damage(id)
{
        if ( !shModActive() || !is_user_alive(id) ) return

        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
        new headshot = bodypart == 1 ? 1 : 0
        new PlayerLevel[SH_MAXSLOTS+1]
        PlayerLevel[id] = sh_get_user_lvl(id)

        if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return

        if ( gHasVashPower[attacker] && weapon == CSW_DEAGLE && is_user_alive(id) )
        {
                // do extra damage
                if(PlayerLevel[id] >= 40)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 30 <= PlayerLevel[id] <= 39)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult" ) )
                        if (extraDamage >
0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 20 <= PlayerLevel[id] <= 29)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage >
0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 15 <= PlayerLevel[id] <= 19)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 2
                        if (extraDamage >
0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if(11 <=  PlayerLevel[id] <= 14 )
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 3
                        if (extraDamage >
0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 7<=  PlayerLevel[id]  <= 10)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 6
                        if (extraDamage >
0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if(  0 <= PlayerLevel[id] <= 6)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ))  *12
                        if (extraDamage >
0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
        }
}

Level 5 vs bots. I dont know hwo many i give them damage but i will kill bots(HP from 100 to 550) on 1-3 fires...
Level 5 vs lvl 40 human with only 1 hero with cola lover which menas 950HP 1 fire take him 120 HP hwo is this possible? I dont understand... Im trying do math... 12*2 = 24 * 20(low normal damage...) = 480. Why i take only 120? I dont understand this...

Bugsy 06-03-2018 16:29

Re: Problem with logical &
 
I'm not sure how the damage is being applied being I cannot see all of your code. My assumption is some of the damage is being offsetted by the victims armor.

gameplayonline 06-03-2018 16:38

Re: Problem with logical &
 
Full code:
Code:

// VASH THE STAMPEDE! - From the anime Trigun. Vash is a peace loving, donut eating, girl crazy pacifist with a 60 billion double dollar bounty on his head.

/* CVARS - copy and paste to shconfig.cfg

//Vash the Stampede
vash_level 4
vash_deaglemult 2.5                //Damage multiplyer for his Deagle
vash_gravity 1.0                //Default 1.0 = normal gravity (0.50 is 50% of normal gravity, ect.)

*/

/*
* v1.4 - vittu - 6/22/05
*      - Code clean up.
*
* v1.3 - vittu - 5/05/05
*      - Fixed code run on clearpowers, now only gets run if user actually had the hero.
*      - Other minor change to code for efficiency.
*
* v1.2 - vittu - 2/02/05
*      - Changed weapon model, old one was for the wrong hand anyway.
*      - Added Evasion to code, a missing hitzone randomly chosen every second.
*      - Set gravity default to none because vash doesn't have low gravity, but
*        left cvar since it was in orginal.
*      - Removed no-reload because he uses a revolver, and gave ammo instead but
*        just enough not affect no-reload heroes.
*
*  Ripped from the hero - Morpheus by RadidEskimo & Freecode.
*  Weapon model by Thin Red Paste & X-convinct, converted by SplinterCell.
*/

#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>

// GLOBAL VARIABLES
new gHeroName[]="Vash the Stampede"
new bool:gHasVashPower[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
        // Plugin Info
        register_plugin("SUPERHERO Vash the Stampede", "1.4", "sharky / vittu")

        // DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
        register_cvar("vash_level", "4")
        register_cvar("vash_deaglemult", "2.5")
        register_cvar("vash_gravity", "1.0")

        // FIRE THE EVENT TO CREATE THIS SUPERHERO!
        shCreateHero(gHeroName, "Revolver & Evasion", "Get Vash's .45 Long Colt Revolver (DEAGLE), that does More Damage. Also, evade by removing random hitzones.", false, "vash_level")

        // REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
        // INIT
        register_srvcmd("vash_init", "vash_init")
        shRegHeroInit(gHeroName, "vash_init")

        // EVENTS
        register_event("ResetHUD", "newSpawn", "b")
        register_event("CurWeapon", "weaponChange", "be", "1=1")
        register_event("Damage", "vash_damage", "b", "2!0")

        // HITZONE CHANGING LOOP
        set_task(1.0, "vash_hitzones", 0, "", 0, "b")

        // Let Server know about Vash's Variables
        shSetMinGravity(gHeroName, "vash_gravity")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
        precache_model("models/shmod/vash_deagle.mdl")
}
//----------------------------------------------------------------------------------------------
public vash_init()
{
        // First Argument is an id
        new temp[6]
        read_argv(1,temp,5)
        new id = str_to_num(temp)

        // 2nd Argument is 0 or 1 depending on whether the id has the hero
        read_argv(2,temp,5)
        new hasPowers = str_to_num(temp)

        if ( is_user_alive(id) ) {
                if ( hasPowers ) {
                        vash_weapons(id)
                        switchmodel(id)
                }
                // This gets run if they had the power but don't anymore
                else if ( !hasPowers && gHasVashPower[id] ){
                        engclient_cmd(id, "drop", "weapon_deagle")
                        shRemGravityPower(id)
                        set_user_hitzones(0, id, 255)
                        set_hudmessage(200, 0, 0, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 54)
                        show_hudmessage(id, "Vash - EVASION OFF - Hitzones returned to normal")
                }
        }

        // Sets this variable to the current status
        gHasVashPower[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
        if ( shModActive() && gHasVashPower[id] && is_user_alive(id) ) {
                set_task(0.1, "vash_weapons", id)

                new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)
                if ( wpnid != CSW_DEAGLE && wpnid > 0 ) {
                        new wpn[32]
                        get_weaponname(wpnid, wpn, 31)
                        engclient_cmd(id, wpn)
                }
        }
}
//----------------------------------------------------------------------------------------------
public vash_weapons(id)
{
        if ( shModActive() && is_user_alive(id) ) {

                // Just tell them here since this gets run at the right times anyway
                set_hudmessage(200, 0, 0, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 54)
                show_hudmessage(id, "Vash - EVASION ON - Removing a random hitzone every second")

                shGiveWeapon(id, "weapon_deagle")

                //Give him just enough ammo so as to not effect a no-reload hero
                new clip, ammo
                get_user_ammo(id, 26, clip, ammo)
                if( ammo <= 6 ) {
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                }
                else if( ammo > 6 && ammo <= 13 ) {
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                }
                else if( ammo > 13 && ammo <= 20 ) {
                        shGiveWeapon(id, "ammo_50ae")
                        shGiveWeapon(id, "ammo_50ae")
                }
                else if( ammo > 20 && ammo <= 27 ) {
                        shGiveWeapon(id, "ammo_50ae")
                }
        }
}
//----------------------------------------------------------------------------------------------
public switchmodel(id)
{
        if ( !is_user_alive(id) ) return

        //If holding shield don't change model, since there is no custom model with shield
        new v_mdl[32]
        Entvars_Get_String(id, EV_SZ_viewmodel, v_mdl, 31)
        if ( containi(v_mdl, "v_shield_") != -1 ) return

        new clip, ammo, wpnid = get_user_weapon(id, clip, ammo)
        if ( wpnid == CSW_DEAGLE ) {
                // Weapon Model change thanks to [CCC]Taz-Devil
                Entvars_Set_String(id, EV_SZ_viewmodel, "models/shmod/vash_deagle.mdl")
        }
}
//----------------------------------------------------------------------------------------------
public weaponChange(id)
{
        if ( !gHasVashPower[id] || !shModActive() ) return

        new wpnid = read_data(2)

        if ( wpnid != CSW_DEAGLE ) return

        switchmodel(id)
}
//----------------------------------------------------------------------------------------------
public vash_damage(id)
{
        if ( !shModActive() || !is_user_alive(id) ) return

        new damage = read_data(2)
        new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
        new headshot = bodypart == 1 ? 1 : 0
        new PlayerLevel[SH_MAXSLOTS+1]
        PlayerLevel[id] = sh_get_user_lvl(id)

        if ( attacker <= 0 || attacker > SH_MAXSLOTS ) return

        if ( gHasVashPower[attacker] && weapon == CSW_DEAGLE && is_user_alive(id) )
        {
                // do extra damage
                if(PlayerLevel[id] >= 40)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 30 <= PlayerLevel[id] <= 39)
                {       
                        new extraDamage = floatround(damage * get_cvar_float("vash_deaglemult" ) )
                        if (extraDamage > 0) shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 20 <= PlayerLevel[id] <= 29)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult") )
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 15 <= PlayerLevel[id] <= 19)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 2
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if(11 <=  PlayerLevel[id] <= 14 )
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 3
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if( 7<=  PlayerLevel[id]  <= 10)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ) ) * 6
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
                else if(  0 <= PlayerLevel[id] <= 6)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ))  *12
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }
        }
}
//----------------------------------------------------------------------------------------------
public vash_hitzones()
{
        if ( !shModActive() || !hasRoundStarted() ) return

        for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
                if ( gHasVashPower[id] && is_user_alive(id) ) {
                        new hitZone
                        hitZone = random_num(1, 7)
                        switch(hitZone) {
                                case 1: set_user_hitzones(0, id, 127)        //remove right leg hitzone
                                case 2: set_user_hitzones(0, id, 191)        //remove left leg hitzone
                                case 3: set_user_hitzones(0, id, 223)        //remove right arm hitzone
                                case 4: set_user_hitzones(0, id, 239)        //remove left arm hitzone
                                case 5: set_user_hitzones(0, id, 247)        //remove stomach hitzone
                                case 6: set_user_hitzones(0, id, 251)        //remove chest hitzone
                                case 7: set_user_hitzones(0, id, 253)        //remove head hitzone
                        }
                }
        }
}
//----------------------------------------------------------------------------------------------

Code:

I tried this:
                else if(  0 <= PlayerLevel[id] <= 6)
                {       
                        new extraDamage = floatround( damage * get_cvar_float("vash_deaglemult" ))  *120
                        if (extraDamage > 0)
                                shExtraDamage(id, attacker, extraDamage, "deagle", headshot)
                }

And still cant kill bot with 950 HP with 1 shot... i killed him with 5 shots. I think it doesnt work and i dont know why. Damage still looks same.
I tried *320 and same result(it looks it is possible to take him 400HP but i dont know it 100% because i cant test it with live person now...).

Garey 06-07-2018 21:47

Re: Problem with logical &
 
Did you check vash_deaglemult cvar value? Also you can debug extraDamage to chat to see if there problem with damage value or with shExtraDamage


All times are GMT -4. The time now is 04:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.