Announcement

Collapse
No announcement yet.

Dealing Damage over time

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

    Dealing Damage over time

    How would I go about making an attack deal maybe -2 damage every second for x amount of seconds

    #2
    One unconventional approach is to spawn an emitter on the target and have the emitter deal the damage in its Tick(). You probably need an emitter anyway, right?

    I'm not sure if that would work perfectly online...

    Comment


      #3
      I'd be surprised if it wouldn't. All the replication is in the emitter's code. So if it can deal damage offline, it will certainly do damage online

      Comment


        #4
        still doesnt explain how i deal the damage tho?????

        Comment


          #5
          Sry m8. Xyx is wrong. Emitters can't deal damage. What you can do, is spawn a damagetype and attach an emitter to it. About dealing damage every second, I don't know. Try looking for a weapon that already does that, and dig through that code.

          Comment


            #6
            like so:
            Code:
            class mydamageovertimeacor extends info;
            
            var float TimeElapsed;
            var pawn PainTarget;
            
            funciton PostBeginPlay()
            {
                SetTimer(0.5, True);
            }
            
            function Timer()
            {
                local vector vNull;
            
                if (PainTarget != None)
                    PainTarget.TakeDamage(1, Instigator, vNull, vNull, MyDamageType);
            
                if(TimeElapsed == 2.0)
                    Self.Destroy();
            
                TimeElapsed += 0.5;
            }

            Just have your weapon spawn the above and set PainTarget to = the pawn you want to take damage and it will deal 1 damage every half second for 2 seconds (obvioulsy you can adjut how long)


            All Damage is dealt server side BTW so replication is not an issue...

            Comment


              #7
              Originally posted by Nov4
              Sry m8. Xyx is wrong. Emitters can't deal damage. What you can do, is spawn a damagetype and attach an emitter to it. About dealing damage every second, I don't know. Try looking for a weapon that already does that, and dig through that code.
              You don't spawn damage types, they are just information holding classes...


              And any class can deal damage, and any actor based class can take damage...

              Comment


                #8
                ok so this is the attack i`m currently using it`s a melee attack from a monster

                code:
                ------------------------------------------------------------------------------
                else if ( Velocity == vect(0,0,0) ) // if standing still

                SetAnimAction('AssSmack'); //set this animation
                MeleeDamageTarget(8, vect(0,0,0)); //assume does 8 damage @ this vect
                Controller.bPreparingMove = true; //next move
                Acceleration = vect(0,0,0); // stay still
                FlameFX(); // spawn flame fx
                return;
                -----------------------------------------------------------------------------

                so if was to create a function that spawned the DamageOverTimeActor how do i set the pain target??

                maybe something like this

                code:
                ----------------------------------------------------------------------------
                else if ( Velocity == vect(0,0,0) ) // if standing still

                SetAnimAction('AssSmack'); //set this animation
                DoDamage(); //Call new function
                Controller.bPreparingMove = true; //next move
                Acceleration = vect(0,0,0); // stay still
                FlameFX(); // spawn flame fx
                return;


                simulated function DoDamage() //new function
                {

                if (Other != Instigator) //anybody but instigator

                Spawn(class'MyDamageOverTimeActor');// call DoDamage Actor
                painTarget = other // pain Target
                }
                ---------------------------------------------------------------------------
                pretty new to scripting so it hard work getting my head round it

                Comment


                  #9
                  In the do damage part:
                  Code:
                  local myDamageOverTimeActor Pain;
                  
                  Pain = Spawn(class'myDamageOverTimeActor')
                  Pain.PainTarget = Pawn(Other) //you have to make sure Other is set to the enmy first

                  Comment


                    #10
                    Add a variable to your DamageOverTimeActor of type Actor to hold the pain target. For example, like so:
                    Code:
                    var Actor PainTarget;
                    Then, after you spawn the DamageOverTimeActor, you set its pain target to whatever it needs to be. Like so:
                    Code:
                    local DamageOverTimeActor DOTA;
                    
                    // Do stuff to get the target, which I will call HitActor.
                    
                    DOTA = Spawn(class'DamageOverTimeActor', self,, HitActor.Location);
                    
                    if(DOTA != none)
                    {
                        DOTA.PainTarget = HitActor;
                    }

                    Comment


                      #11
                      Originally posted by Hsoolien
                      You don't spawn damage types, they are just information holding classes...


                      And any class can deal damage, and any actor based class can take damage...


                      I'll shut up already. Trying to help, obviously not very good at it. :noob: What I tried to do was finding a reference on dealing damage in the emitter's class, but didnt find any. Thx for correcting me, guess you learn something every day

                      Comment


                        #12
                        ok been messing with this all nite and still get this error

                        Error, Call to 'DoDamage': bad or missing parameter 1

                        any ideas??

                        Comment


                          #13
                          The DoDamage function needs specific variuables passed to it (where/how is it delcared originaly?)

                          Comment


                            #14
                            Ok My monster is just an extension from the skaarj Class and i`m using his ranged attack to call the DoDamage() function .I can inflick melee damage by calling either the SpinDamageTarget or ClawDamageTarget functions but I don`t understand where or how the targetting works

                            code
                            -------------------------------------------------------------------------------
                            function RangedAttack(Actor A)
                            {
                            local float Dist;

                            if ( bShotAnim )
                            return;

                            Dist = VSize(A.Location - Location);
                            if ( Dist > 400 )
                            return;
                            bShotAnim = true;
                            PlaySound(ChallengeSound[Rand(4)], SLOT_Interact);
                            if ( Dist < MeleeRange + CollisionRadius + A.CollisionRadius )
                            {
                            if ( FRand() < 0.5 )
                            {
                            SetAnimAction('gesture_cheer');
                            LeftTrailFX();
                            RightTrailFX();
                            return;
                            }

                            else if ( Velocity == vect(0,0,0) ) // if standing still
                            SetAnimAction('AssSmack'); //set this animation
                            // new function
                            Controller.bPreparingMove = true; //next move
                            Acceleration = vect(0,0,0); // stay still
                            FlameFX(); // spawn flame fx
                            DoDamage();
                            return;
                            }

                            // lunge at enemy
                            bLunging = true;
                            Enable('Bump');
                            SetAnimAction('WallDodgeF');
                            Velocity = 500 * Normal(A.Location + A.CollisionHeight * vect(0,0,0.75) - Location);
                            if ( dist > CollisionRadius + A.CollisionRadius + 50 )
                            Velocity.Z += 0.7 * dist;
                            SetPhysics(PHYS_Falling);
                            LeftTrailFX();
                            RightTrailFX();
                            }
                            ----------------------------------------------------------------------------------

                            my flameFX function uses the code taken from the SpawnTwo Shots() function to point the flameFX() in the right direction and works pretty well dont know if this will help but here`s the code

                            code
                            ----------------------------------------------------------------------------------

                            function vector GetFlameStart(vector X, vector Y, vector Z)
                            {
                            return Location + 0.9 * CollisionRadius * X + 0.9 * CollisionRadius * Y + 0.4 * CollisionHeight * Z;
                            }

                            simulated function FlameFX() //Spawn Flame effects & attach to bone
                            {
                            local vector X,Y,Z, FlameStart;
                            local rotator FlameRotation;


                            GetAxes(Rotation,X,Y,Z);
                            FlameStart = GetFlameStart(X,Y,Z);
                            FlameRotation = Controller.AdjustAim(SavedFireProperties,FlameStar t,0);
                            Flames = Spawn(class'MyFlames',,,FlameStart,FlameRotation);
                            AttachToBone(Flames, 'Bone20');

                            return;
                            }

                            -------------------------------------------------------------------------------

                            maybe I could use the flame rotation as the damage radius for the attack

                            ultimatly what i`m aiming for is a flame attack that burns for a second or 2 after the initial hit and maybe also some flame effects on the victim but I will work on that after I get The Damage part working

                            Comment

                            Working...
                            X