Announcement

Collapse
No announcement yet.

[in 3236 too] Script bug in ut2k4v3186 for health and shield points management!?!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [in 3236 too] Script bug in ut2k4v3186 for health and shield points management!?!

    Hello there,

    By curiosity, I was looking to the xPawn class and noticed the shield and health management.
    I've discovered strange figures, and I would like to know if I'm wrong or if there is something strange in the code.

    First point, I would like to say that I consider SmallShieldStrength to be set to 0 when an object of that class (xPawn) is instanciated.

    I've noticed two strange behaviors.
    1) Let's say I have health: 100 and shield: 100 ( = 1 * 100)
    I take a damage of 133.
    According to my computations, what remains me is:
    health = 67, shield = 0.25 (0 dot 25, almost 0)

    Now, same starting values (H:100,S;100) , but damage is 134
    I'll have health = 41, shield = 0

    Notice the health drop (26 points less for 1 more damage point).


    2) Now, I start with health: 100, shield 150 ( = 1 * 100 + 1 * 50)
    Damage received = 116
    ==> health = 84, shield = 50.5

    (still H:100, S:150) but damage is 117
    ==> health = 85, shield = 35

    Notice the small health "increase" and the shield drop (15), for 1 more damage point.

    Am I done some wrong computations or is this the real (and imo strange) behavior?
    Did I forget something?


    Greets.

    PS:
    1st case is:
    AddShieldStrength(100)
    ShieldAbsorb(133) or ShieldAbsorb(134)

    2nd case is:
    AddShieldStrength(100)
    AddShieldStrength(50)
    ShieldAbsorb(116) or ShieldAbsorb(117)

    I considered that what is returned by the ShieldAbsord function is directly taken on health.

    #2
    Please read "axis" where it says "axe" =)

    Better with images, here they are:
    Health 100, Shield 150 (= 100 + 50 - "super shield" + small shield)



    Health 100, Shield 100

    Comment


      #3
      Is there a way to know who read a thread?

      Comment


        #4
        Did you test this in DM or TDM?
        It might be somthing with the shield stacking, i.e. two shields (toe 100 and the 50) absorb damage separately or something.

        Comment


          #5
          I've taken the code directly from xPawn.uc, from the "int ShieldAbsorb(int damage)" function, which does not seem to be overriden.
          I think this function overrides [did not check] the [almost useless] one of Pawn.uc (no x before pawn).
          So I believe this behavior happens in all game types.

          I can post a link to my C# project if you want (need to have the .NET framework installed to compile & run).

          Thanks for your reply =]

          Comment


            #6
            Strange line in SniperFire.uc

            Found this line in SniperFire.uc [in function DoTrace(Vector Start, Rotator Dir)]

            Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;

            According to wotgreal's UScript help, Rand(int Max) returns a random number between 0 and Max-1, so the line above has two "maximums", as DamageMax and DamageMin are never changed in this class, and are both equal (to 70), making Rand(0).

            Damage = (DamageMin - 0) * DamageAtten
            or
            Damage = (DamageMin - 1) * DamageAtten

            Quite a strange line imo, what was the intention behind the written one?

            Did I miss something somewhere?

            Comment


              #7
              Originally posted by Wormbo
              It might be somthing with the shield stacking, i.e. two shields (toe 100 and the 50) absorb damage separately or something.

              The shield stacking is represented on the first screenshot, where the health follows some linear (and continuous) declinations.
              The only problem with shield stacking is that the shield graph is not continuous. :bulb:

              Comment


                #8
                Shield stacking - more info

                Hello,

                here is the graph obtained when stacking 2 "super shields" (100 armor points).

                Health 100, shield 100+100 (= 150)

                AddShieldStrength(100)
                AddShieldStrength(100)
                And then, compare ShieldAbsorb(183) to ShieldAbsorb(184)
                Here shown is 183.


                For 183 damage points, you get 67 health left and 0.25 shield, and for 84 damage points, health drops to 41 and there's 0 shield left.

                -26 health points for 1 more damage point.

                Comment


                  #9
                  And here the link to the C# project, using the latest .NET framework (1.1.4322).

                  I'll be away for a while, but I hope to get some feedback about this...

                  Comment


                    #10
                    Ah !!

                    Seems I was kinda right

                    Look to point 6 of general game play

                    Comment


                      #11
                      Re: Strange line in SniperFire.uc

                      Originally posted by Coucou
                      Found this line in SniperFire.uc [in function DoTrace(Vector Start, Rotator Dir)]

                      Damage = (DamageMin + Rand(DamageMax - DamageMin)) * DamageAtten;

                      Quite a strange line imo, what was the intention behind the written one?

                      Did I miss something somewhere?
                      Not so strange 'cause it will be usefull when one want to subclass sniperrifle and put there different DamageMax and DamageMin.

                      But obviously it should be Damage = (DamageMin + Rand(DamageMax - DamageMin +1)) * DamageAtten;

                      Comment


                        #12
                        Originally posted by Coucou
                        And here the link to the C# project, using the latest .NET framework (1.1.4322).
                        Are you certain you using exact the same function ShieldAbsorb()?

                        Anyway it's quite sophisticated for such simple fuction so some non-linearity could be :sulk:

                        Here is what I found and it seems a little different from your code:
                        Code:
                        function int ShieldAbsorb( int dam )
                        {
                            local float Interval, damage, Remaining;
                        
                            damage = dam;
                            
                            if ( ShieldStrength == 0 )
                            {
                                return damage;
                            }
                            SetOverlayMaterial( ShieldHitMat, ShieldHitMatTime, false );
                            PlaySound(sound'WeaponSounds.ArmorHit', SLOT_Pain,2*TransientSoundVolume,,400);
                            if ( ShieldStrength > 100 )
                            {
                                Interval = ShieldStrength - 100;
                                if ( Interval >= damage )
                                {
                                    ShieldStrength -= damage;
                                    return 0;
                                }
                                else
                                {
                                    ShieldStrength = 100;
                                    damage -= Interval;
                                }
                            }
                            if ( ShieldStrength > SmallShieldStrength )
                            {
                                Interval = ShieldStrength - SmallShieldStrength;
                                if ( Interval >= 0.75 * damage )
                                {
                                    ShieldStrength -= 0.75 * damage;
                                    if ( ShieldStrength < SmallShieldStrength )
                                        SmallShieldStrength = ShieldStrength;
                                    return (0.25 * Damage);
                                }
                                else
                                {
                                    ShieldStrength = SmallShieldStrength;
                                    damage -= Interval;
                                    Remaining = 0.33 * Interval;
                                    if ( Remaining <= damage )
                                        return damage;
                                    damage -= Remaining;
                                }
                            }
                            if ( ShieldStrength >= 0.5 * damage )
                            {
                                ShieldStrength -= 0.5 * damage;
                                SmallShieldStrength = ShieldStrength;
                                return Remaining + (0.5 * damage);
                            }
                            else
                            {
                                damage -= ShieldStrength;
                                ShieldStrength = 0;
                                SmallShieldStrength = 0;
                            }
                            return damage + Remaining;
                        }

                        Comment


                          #13
                          Forget that last post, it's some old code. Newest is:

                          Code:
                          function int ShieldAbsorb( int damage )
                          {
                          	local int Interval;
                          
                              if (ShieldStrength == 0)
                              {
                                  return damage;
                              }
                          	SetOverlayMaterial( ShieldHitMat, ShieldHitMatTime, false );
                          	PlaySound(sound'WeaponSounds.ArmorHit', SLOT_Pain,2*TransientSoundVolume,,400);
                              if ( ShieldStrength > 100 )
                              {
                          		Interval = ShieldStrength - 100;
                          		if ( Interval >= damage )
                          		{
                          			ShieldStrength -= damage;
                          			return 0;
                          		}
                          		else
                          		{
                          			ShieldStrength = 100;
                          			damage -= Interval;
                          		}
                          	}
                              if ( ShieldStrength > SmallShieldStrength )
                              {
                          		Interval = ShieldStrength - SmallShieldStrength;
                          
                          		if ( Interval >= 0.75 * damage )
                          		{
                          			ShieldStrength -= 0.75 * damage;
                          			if ( ShieldStrength < SmallShieldStrength )
                          				SmallShieldStrength = ShieldStrength;
                          			return (0.25 * damage);
                          		}
                          		else
                          		{
                          			ShieldStrength = SmallShieldStrength;
                          			damage -= 0.75 * Interval;
                          		}
                          	}
                          	if ( ShieldStrength >= 0.5 * damage )
                          	{
                          		ShieldStrength -= 0.5 * damage;
                          		SmallShieldStrength = ShieldStrength;
                          		return (0.5 * damage);
                          	}
                          	else
                          	{
                          		damage -= ShieldStrength;
                          		ShieldStrength = 0;
                          		SmallShieldStrength = 0;
                          	}
                          	return damage;
                          }

                          Comment


                            #14
                            Re: Re: Strange line in SniperFire.uc

                            Originally posted by Grzech
                            Not so strange 'cause it will be usefull when one want to subclass sniperrifle
                            You're right about that, I did not think about this (oops)!



                            Originally posted by Grzech
                            Forget that last post, it's some old code. Newest is:

                            Code:
                            function int ShieldAbsorb( int damage )
                            {...}
                            This is the code I worked on, from UT2004 v3186.

                            The changes I made in the C# file are just casts (at least, that was my intention).
                            I'll check this evening with the code contained in the latest beta patch, to see if there are some differences.

                            Unless it is already that code (from v3223)?
                            [in that case, the differences may occur somewhere else in the xPawn source file, in places where the shield variables appear]

                            Thanks for your posts!

                            Comment


                              #15
                              I've put the new ShieldAbsorb code from the latest beta patch (v3223), and here's the (strange) result:
                              Take 100 shield and 50 shield (in whatever order)



                              It means that when you get any damage above 117 AT ONCE, the shield does not go under 50 (you can also die with 50 shield).

                              If someone could test this, here is what to do:
                              1. have a server with the latest beta patch installed (v3223).
                              2. get big shield (100) and then small shield (50)
                              3. get a lightning gun headshot (or anything else which does more damage than 117 and that does not kill). LG HS is good because it deals 140 damage.

                              Getting two big shields (2*100) also gives 150 armor but is NOT the same than 100+50.

                              The new C# project .

                              All other combinations seem to work fine (continuous):

                              50+50+50+...+50 = 50, all small shields do not stack, damage function is continuous.
                              100 + 100 = 150 big shield stacking, limited to 150 but damage function is continuous.

                              Comment

                              Working...
                              X