Jump to content
  • 0

Attack Frame


Aiden9

Question

I have made a frame attack, who first work perfectly

 

5091aa3f1c3270d64c2f61118fc43506.gif

 

Now we want to make the animation of attack with 4 frame,

 

if anyone have an idea i will take.

 

The objective is the attack use frame 4 > 5 > 6 > 7 

 

this is the code in Intersect.Client -> Entities -> Entity.cs

 

292f6be6f3036ffbecbbcde539ceec58.png

 

line 879.

 

Maybe with While/For loop but it doesnt work.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Please don't bump topics in this board unless they are a week old...

 

CalculateAttackTime() returns a value.. say.. 200ms

 

Which means you have 200ms to show all 4 frames.

 

You gotta add your own logic to figure out how long you've been attacking and then show the correct frame for it.

Link to comment
Share on other sites

  • 0

i managed to animate the attack frames, assuming youre also using an 8x4 spritesheet. mine just looks twitchy bc the base attack speed is super high. it looks better with a slower weapon, and can be changed easily to fit your desired speed

 

i think you can just copy paste the code into the DrawEquipment() section just below to animate equipment paperdolls to match your char sprite

 

i also made the walk anim work with 8x4

 

but i wasnt able to make it use the latter half of it where the attack animations are, the anim just comes up blank

 

im not sure where you can edit that but i will look into it tomorrow if nobody else can tell us. here is what I got for now! hope it helps

 

GIF

 

code:

Spoiler

                    var attackTime = CalculateAttackTime();
                    if (AttackTimer - CalculateAttackTime() / 2 > Globals.System.GetTimeMs() || Blocking)
                    {
                        if (Globals.System.GetTimeMs() > FrameTimer)
                        {
                            if (AttackFrame > 2)
                            {
                                AttackFrame = 0;
                            }
                            else
                            {
                                AttackFrame += 1;
                            }

                            FrameTimer = Globals.System.GetTimeMs() + (attackTime / 8);
                        }

                        srcRectangle = new FloatRect(
                            AttackFrame * (int)Texture.GetWidth() / 8  + (int)Texture.GetWidth() / 2, d * (int)Texture.GetHeight() / 4,
                            (int)Texture.GetWidth() / 8, (int)Texture.GetHeight() / 4
                        );
                    }
                    else
                    {
                        srcRectangle = new FloatRect(
                            WalkFrame * (int)Texture.GetWidth() / 8, d * (int)Texture.GetHeight() / 4,
                            (int)Texture.GetWidth() / 8, (int)Texture.GetHeight() / 4
                        );
                    }
                }

 

edit: apparently when you change the sprite of a class, it does not change an existing character sprite of that class lol.

 

edit2: fixed it up a bit, but now my NPCs are a bit offset... still working on it.  also sorry for my ugly code, i am brand new to C#. there is probably a better way to do this as well with much more effort, like being able to set the spritesheet cell size in editor or something

Link to comment
Share on other sites

  • 0
2 hours ago, Blestro said:

Well, the mod works, but

 

when you equip a weapon with a speedattack modifier this happen:

 

53f28aa3a6287ae3a0ddaa0ec90a982f.gif
 
The frame loop plays the ms of speedattack modifier duration.

Correct. How else would this be handled? I think it's on the game dev to make sure attacks are at a reasonable rate.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...