a better way to do

Read log files for errors! If this fails, come here for help

Moderator: Forum Moderator

whosyourdaddy
Spell Breaker
Posts: 398
Joined: Sun Apr 27, 2008 10:11 pm

a better way to do

Postby whosyourdaddy » Wed Dec 03, 2008 4:13 pm

i know i should be pasting this in the bug report section but since i can put this in code format ill put it here. for my version im using the ham module to stop damages which is a better way. in your current version you have trace line to block helm damage and to register defense and offensive skills. one problem with this is that if some1 has a helm and the attacker is aiming at there head and changes guns but doesnt shoot, it will register it as a shot and remove a helm. you also still have

Code: Select all

if ( SHARED_ValidPlayer( iAttacker ) && fDifference < 0.1 && fDifference > 0.0 )


for night elf which is still bugging it on scoutz and other maps because pretty much u need to be shot from a machine gun and it has to be in less than 0.1 sec of a shot. using my update is all up to u but here is what i got for mine which works 100%

Code: Select all

RegisterHam(Ham_TakeDamage, "player", "EVENT_TakeDamage");

new UserAiming[33];
// Called when a user looks somewhere
public TRIGGER_TraceLine( Float:v1[3], Float:v2[3], noMonsters, pentToSkip )
{
   if ( !WC3_Check() )
   {
      return FMRES_IGNORED;
   }
   new iAttacker = pentToSkip;
   new iVictim = get_tr(TR_pHit);
   new iHitZone = (1 << get_tr(TR_iHitgroup));
   
   // Make sure we have a valid victim
   if ( SHARED_ValidPlayer( iVictim ) && p_data_b[iVictim][PB_ISCONNECTED] )
   {
      // We need to have a valid player!
      if ( SHARED_ValidPlayer( iAttacker ) )
      {

         if ( iHitZone & (1 << 1) )
            UserAiming[iVictim] = 1
         else
            UserAiming[iVictim] = 0

         // This is a check for ultimates that need to "search" for a target
         if ( p_data_b[iAttacker][PB_ISSEARCHING] )
         {

            // Now lets make sure the person he's looking at is in view and isn't on the same team
            if ( get_user_team( iAttacker ) != get_user_team( iVictim ) ) //&& UTIL_EntInView( iAttacker, iVictim ) )
            {
               
               // Check to see if the user should block this ultimate!
               if ( !g_EndRound && ULT_CanUserBlockUlt( iVictim ) )
               {
                  ULT_RemoveCharge( iVictim, 0 );
                  ULT_Blocked( iAttacker );
               }

               // Then the user's ult should work!
               else
               {
                  // Well we do have a target so lets execute the user's ultimate!!
                  if ( SM_GetSkillLevel( iAttacker, ULTIMATE_CHAINLIGHTNING ) > 0 )
                  {
                     OR_ULT_ChainLightning( iAttacker, iVictim, iHitZone );
                  }
                  else if ( SM_GetSkillLevel( iAttacker, ULTIMATE_ENTANGLE ) > 0 )
                  {
                     NE_ULT_Entangle( iAttacker, iVictim );
                  }
                  else if ( SM_GetSkillLevel( iAttacker, ULTIMATE_IMMOLATE ) > 0 )
                  {
                     BM_ULT_Immolate( iAttacker, iVictim );
                  }
               }

               // No longer searching since we found a target
               p_data_b[iAttacker][PB_ISSEARCHING]   = false;

               // Set up the user's ultimate delay
               ULT_ResetCooldown( iAttacker, get_pcvar_num( CVAR_wc3_ult_cooldown ) );
            }
         }

         // Check for Big Bad Voodoo's ultimate!
         if ( p_data_b[iVictim][PB_GODMODE] )
         {
            
            new bool:bBlockDamage = true;

            // Do we allow this person to be attacked by this player?
            if ( p_data_b[iAttacker][PB_BIGBAD_ATTACKER] )
            {
               bBlockDamage = false;
            }

            // Check to see if immunity is available for the attacker
            else if ( ULT_CanUserBlockUlt( iAttacker ) )
            {
               // Remove charge and display message to attacker
               ULT_RemoveCharge( iAttacker, 1 );

               // Display message about user's ultimate being blocked!
               ULT_Blocked( iVictim );

               // This user can attack someone with big bad voodoo!
               p_data_b[iAttacker][PB_BIGBAD_ATTACKER] = true;

               // Reset the attacker dmg
               set_task( get_pcvar_float( CVAR_wc3_ult_cooldown ), "_SH_ResetBigBadAttacker", TASK_BIGBADATTACKER + iAttacker );
            }

            // Block the damage!
            if ( bBlockDamage )
            {
               set_tr( TR_flFraction, 1.0 );

               return FMRES_SUPERCEDE;
            }
         }
      }
   }
   
   return FMRES_IGNORED;
}

public EVENT_TakeDamage( iVictim, inflictor, iAttacker, Float:iDamagee, damagetype )
{
   if ( !WC3_Check() )
   {
      return HAM_IGNORED;
   }
   
   // Make sure we have a valid victim
   if ( SHARED_ValidPlayer( iVictim ) && p_data_b[iVictim][PB_ISCONNECTED] )
   {
      // We need to have a valid player!
      if ( SHARED_ValidPlayer( iAttacker )  && p_data_b[iAttacker][PB_ISCONNECTED])
      {

         if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
            return HAM_SUPERCEDE;

         new iHitPlace
         new iWeapon
         
         get_user_attacker( iVictim , iWeapon , iHitPlace )

         if(IsGrenade ( inflictor ))
            iWeapon = CSW_HEGRENADE;

         // This is a nice check for Helm of Excellence
         if ( ITEM_Has( iVictim, ITEM_HELM ) > ITEM_NONE )
         {

            // If its a headshot then we want to block it
            if ( UserAiming[iVictim] )
            {   
                  Create_ScreenFade( iVictim, (1<<10), (1<<10), (1<<12), 0, 0, 255, 150 );

                  // Lets remove a charge from the helm!
                  ITEM_RemoveCharge( iVictim, ITEM_HELM );

                  return HAM_SUPERCEDE;
            }
         }


         // Mole protectant
         if ( p_data_b[iAttacker][PB_MOLE] && ITEM_Has( iVictim, ITEM_PROTECTANT ) > ITEM_NONE )
         {   
            client_print( iVictim, print_chat, "%s %L", g_MODclient, iVictim, "SHOT_DEFLECTED" );

            return HAM_SUPERCEDE;
         }

         static iSkillLevel;


         new iDamage = floatround(iDamagee);
         // Check to see if this user has night elf's evasion
         if ( SM_GetSkillLevel( iVictim, SKILL_EVASION ) > 0 )
         {
            iSkillLevel = SM_GetSkillLevel( iVictim, SKILL_EVASION );
            // Friendly fire is off! - This means we shouldn't evade since no damage will be done!
            if ( !get_pcvar_num( CVAR_mp_friendlyfire ) )
                  if ( g_iPlayerTeam[iAttacker] == g_iPlayerTeam[iVictim] )
                     return HAM_SUPERCEDE;
               
            // Then we should evade this shot!
            if ( !p_data_b[iVictim][PB_HEXED]  && random_float( 0.0, 1.0 ) <= p_evasion[iSkillLevel-1] )
            {   

               new iGlowIntensity = random_num( 20, 50 );
      
               // Head shot
               if ( iHitPlace & HIT_HEAD )
                  iGlowIntensity += 250;
               else
                  iGlowIntensity += 75;
      
               // Make the user glow!
               SHARED_Glow( iVictim, 0, 0, iGlowIntensity, 0 );

               Create_ScreenFade( iVictim, (1<<10), (1<<10), (1<<12), 0, 0, 255, g_GlowLevel[iVictim][2] );

               WC3_StatusText( iVictim, TXT_SKILL, "You have evaded a shot!" );

               return HAM_SUPERCEDE;
            }
         }

         g_iDamageDealt[iAttacker][iVictim] += iDamage;

         // Bot should "auto" cast his/her ultimate on random
         if ( SHARED_ValidPlayer( iAttacker ) && is_user_bot( iAttacker ) && random_num( 0, 100 ) <= ( BOT_CAST_ULT_CHANCE * 100 ) )
         {
            // Check for an actual ultimate is done in this function, why do it twice?
            cmd_Ultimate( iAttacker );
         }
   

         // We need to make sure that we have a valid attacker and the user isn't hexed
         if ( SHARED_ValidPlayer( iAttacker ) && !p_data_b[iAttacker][PB_HEXED] )
         {

            // Run the offensive spells
            UD_SkillsOffensive( iAttacker, iDamage );
            HU_SkillsOffensive( iAttacker, iVictim );
            OR_SkillsOffensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            NE_SkillsOffensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            BM_SkillsOffensive( iAttacker, iVictim, iDamage );
            SH_SkillsOffensive( iAttacker, iVictim );
            WA_SkillsOffensive( iAttacker, iVictim, iHitPlace );
            CL_SkillsOffensive( iAttacker, iVictim, iHitPlace );
            OUR_TERROR( iAttacker, iVictim);
            OUR_BLOODLUST(iAttacker, iVictim);
            OUR_BERSERK(iAttacker, iVictim);
         }

         // Make sure we can run the defensive skills
         if ( SHARED_ValidPlayer( iAttacker ) && !p_data_b[iVictim][PB_HEXED] )
         {
            //UD_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            //HU_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            //OR_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            NE_SkillsDefensive( iAttacker, iVictim, iDamage, iHitPlace );
            BM_SkillsDefensive( iAttacker, iVictim, iDamage );
            SH_SkillsDefensive( iAttacker, iVictim );
            //WA_SkillsDefensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );
            CL_SkillsDefensive( iAttacker, iVictim, iDamage, iHitPlace );
            OUR_ICESHARDS(iVictim, iDamage, iAttacker);

         }

         // Item abilities
         if ( SHARED_ValidPlayer( iAttacker ) )
            ITEM_Offensive( iAttacker, iVictim, iWeapon, iDamage, iHitPlace );

      }
   }

   return HAM_IGNORED;
}

bool:IsGrenade ( i_Inflictor ) {
   static s_Classname[ 8 ];
   pev ( i_Inflictor, pev_classname, s_Classname, charsmax ( s_Classname ) );
   return equal ( s_Classname, "grenade" ) ? true : false;
}


ull notice i have a user aiming on mine but for some reason iHitPlace on the event damage is all bugging and wont deflect so i got it taking it from trace line. i also took night elf evasion out of the script because the returns was giving me some type of compiler error so i just put it in like that
Last edited by whosyourdaddy on Fri Jan 02, 2009 3:14 am, edited 1 time in total.
Image

User avatar
Geesu
<b>King of the world!</b>
Posts: 3158
Joined: Tue Jul 05, 2005 9:24 pm
Contact:

Re: a better way to do

Postby Geesu » Fri Jan 02, 2009 1:18 am

If you haven't already - please put a link to this on the bug tracker
No Support via PM

whosyourdaddy
Spell Breaker
Posts: 398
Joined: Sun Apr 27, 2008 10:11 pm

Re: a better way to do

Postby whosyourdaddy » Tue Jan 06, 2009 12:58 am

im kinda having issues with peoples nades damaging themselves not sure why but if u would still like i can post the link
Image

whosyourdaddy
Spell Breaker
Posts: 398
Joined: Sun Apr 27, 2008 10:11 pm

Re: a better way to do

Postby whosyourdaddy » Wed Jan 21, 2009 10:45 pm

viewtopic.php?f=21&t=3411 link to events.inl and night elf that works fine
Image

whosyourdaddy
Spell Breaker
Posts: 398
Joined: Sun Apr 27, 2008 10:11 pm

Re: a better way to do

Postby whosyourdaddy » Fri May 22, 2009 9:06 pm

here is an elf evasion fix

Code: Select all

RegisterHam( Ham_TakeDamage, "player", "EVENT_TakeDamage" );

public EVENT_TakeDamage( iVictim, inflictor, iAttacker, Float:iDamage, damagetype )
{
   if ( !WC3_Check() )
   {
      return HAM_IGNORED;
   }

   // Make sure we have a valid victim
   if ( SHARED_ValidPlayer( iVictim ) && p_data_b[iVictim][PB_ISCONNECTED] )
   {
      // We need to have a valid player!
      if ( SHARED_ValidPlayer( iAttacker ) && p_data_b[iAttacker][PB_ISCONNECTED] )
      {
         if(iAttacker == iVictim)
            return HAM_IGNORED;

         if ( get_user_team( iAttacker ) == get_user_team( iVictim ) && !get_pcvar_num( CVAR_mp_friendlyfire ))
            return HAM_IGNORED;

         new iHitPlace
         new icrap

         //Check where the watched player has shot the bot
         get_user_attacker( icrap , icrap , iHitPlace )

         // Check to see if this user has night elf's evasion
         if ( SM_GetSkillLevel( iVictim, SKILL_EVASION ) > 0 )
         {

            // Then we should evade this shot!
            if ( NE_Evasion( iVictim, iHitPlace ) )
            {
                        
               WC3_StatusText( iVictim, TXT_SKILL, "You have evaded a shot!" );

               return HAM_SUPERCEDE;
            }
         }
      }
   }

   return HAM_IGNORED;
}
Image


Return to “Help/Support”

Who is online

Users browsing this forum: No registered users and 1 guest