donovanvaught Posted October 21, 2011 Author Share Posted October 21, 2011 First off, hello everyone, I am glad to be a part of the forums and am very excited to be working on my first game. Unfortunately, I have hit a snag.A thousand and one apologies if I annoy anyone for asking a question that seems to have been asked before, but I ran into a problem. Attack Animations, not 1 frame, several, a smooth animation showing a regular attack. I found someone else asking this a while back, a tutorial was linked but it has since been removed or I can't access it for some other reason. I've searched the forums over and over wording it differently and only found attacks with ONE frame. So this is my first question, can someone help me with this?Second, I also wish to have combos in my game, where a person can press attack within a short enough time to produce a string of different attacks. I also wan't a "smash" attack, a stronger, slower attack set to a separate button, that can also be placed in combos.Again, I have searched extensively, (It's been 2 weeks of looking at least an hour a day) and cannot find (exactly) what I'm looking for. I have some knowledge of code and am getting very familiar with Origins, but I lack any starting point, I am out in the middle of nowhere with this particular idea, and have no information to help me. I deeply and sincerely thank anyone willing to help, and apologize again for anyone I annoy.Remember, we were all noobs once….. :embarrassed: Link to comment Share on other sites More sharing options...
DJMaxus Posted October 22, 2011 Share Posted October 22, 2011 I've never attempted it before, but here's a way you can probably do the first feature, you will need bigger sprite sheets, the top containing the original 16, the bottom containing 16 sprites for the animation for each direction, following the same format (Down, Left, Right, Up). You can have a function that is set to true upon attacking, and when the function is true, it cycles through the player's attack animation once by showing the first sprite for the animation, and adding +1 to cycle through different sprites on a timer. Once its reset, you can have it show the original sprite again.Again I've never actually attempted it, and this is just a thought off the top of my head, sounds interesting to attempt these though.Don't be so apologetic, you're at least using proper grammar, it's always ok to ask questions. ;) Link to comment Share on other sites More sharing options...
donovanvaught Posted October 22, 2011 Author Share Posted October 22, 2011 Thanks a million, :cheesy: I have had that Idea myself as well! great minds think alike, eh? ;) My only pitfall was that I couldn't quite figure out how to implement a timer in just the code, without having to create a physical one on one of the forms… I tried to do a loop, adding plus one for each cycle, which activated when attacking=1, but then got lost on doing a timer without making the object on the form. any specific help on that would be great! And again, thanks a million for the help DJMaxus!Also, as far as the apologizing goes, I have witnessed my share of flame wars getting in the way of actually solving problems, on more than a few threads, always like to avoid those as much as possible.Both questions still up for grabs if anyone has any other methods or ideas! :cheesy: Link to comment Share on other sites More sharing options...
DJMaxus Posted October 22, 2011 Share Posted October 22, 2011 You can add a timer by using GetTickCount. There are examples throughout the code in multiple cases. For instance, the trade timer, where it tells you "You took too long to decide." whenever you don't select a player in time. You can search the project for GetTickCount, and get an idea of how timers work without using them on forms.Hmm, your second request for combos can also be done with timers. You may want to first remove the 1 second restriction on attacking for all players, but have the speed entirely dependent on the weapon. Let's say an attack is done, we can have a timer start (GetTickCount) and if an attack is done within the timer's "combo time" a variable will add +1 and the timer will reset, this will continue until the timer runs out. Once the timer runs out, it will show the variable to the player, "12 Hits Combo!" or something like that. We have to also remember to reset the variable to 0, and have the timer stop and reset.That'd take some troubleshooting of course, probably a variable or two missing from that explanation, but it's a thought. Link to comment Share on other sites More sharing options...
donovanvaught Posted October 23, 2011 Author Share Posted October 23, 2011 well, for now I'm trying to get the animation to work. So far I have this code:``` If Player(Index).AttackTimer + (attackspeed / 2) > GetTickCount Then If Player(Index).Attacking = 1 Then For i = 1 To 4 If AtkTimer + (500) < GetTickCount Then Anim = i AtkTimer = GetTickCount End If Next i End If```Loops just crash so I tried For To, it seems to work but the animation looks like it goes blinding speed, all I see is a twitch, I'm pretty sure the 500 up there means .5 sec, if I'm wrong please correct. Anywho, I'm stuck trying to figure out how to perfect this, the frames right now are just some walking frames and an attack frame, as I don't want to commit all the art until the code is right. The equipment I have on gives an attack speed of 1000 (1 sec?) so I tried changing the timer to 250 (1000/ 4 frames) but still yielded same result. Link to comment Share on other sites More sharing options...
donovanvaught Posted October 26, 2011 Author Share Posted October 26, 2011 bump Link to comment Share on other sites More sharing options...
donovanvaught Posted October 30, 2011 Author Share Posted October 30, 2011 OK, so I've been racking my brain and staying up late nights to try and figure this out, but I can't. In theory the code above should work, right? The program waits for a few milliseconds, anims the frame, then waits and does the next frame, boom, animation.But upon tweaking the time, I noticed that it is not waiting the allotted time before showing the first frame, and then does not show any more, just holds the first one for the duration of the attack. I've searched and read and read and searched, but there's just no jumping off point, if ANYONE can give me help, I'll be eternally grateful. All my production is at a stand still because of this :sad:, the combat system is the most important part of my game and I can't move forward without getting this to work first. Again, any help is greatly appreciated. Link to comment Share on other sites More sharing options...
donovanvaught Posted November 4, 2011 Author Share Posted November 4, 2011 bump Link to comment Share on other sites More sharing options...
Gohan Posted November 4, 2011 Share Posted November 4, 2011 Hmm, I need this exact same feature. You mind telling me where you placed the code in the source? Perhaps having another mind on this would get us both some results. Link to comment Share on other sites More sharing options...
donovanvaught Posted November 4, 2011 Author Share Posted November 4, 2011 gladly, the code was simply a replacement of the regular 'Anim = 3' code in BltPlayer on the directdraw7 Module in the client code, I haven't altered the server code yet because I want to take one problem on at a time. Though I remember seeing elsewhere that it is important to do this so other players see your own animations. Link to comment Share on other sites More sharing options...
Gohan Posted November 6, 2011 Share Posted November 6, 2011 I'm getting the same results as you, can't seem to find the problem.Perhaps someone else will have an answer. Link to comment Share on other sites More sharing options...
Baron Posted November 8, 2011 Share Posted November 8, 2011 Unless im very much mistaken this code posted above doesn't work because it jsut runs through the entire logic loop every single pass. So you likely only see the 4th frame for one tick each time you attack.GetTickCount effectively returns a "current time" of the server in MS.to make things happen at x time you need to be able to compare what time it is currently to when the action occured.EXAMPLE (NOT ACTUAL CODE, THATS UP TO YOU)player attacks, when attack packet is recieved triggers saves the current tick count to their datain the blt player display loop it gets the current tick count, then subtracts the time we saved earlier. This gives you the difference in time between when the player attacked and when bltplayer runs to draw the player.we then decide how quickly to go through the frames, ie:if difference < 125msanim = 1;if difference <250ms && difference >= 125msanim = 2;if difference <375ms && difference >= 250msanim = 3;if difference <500ms && difference >= 375msanim = 4;if difference >= 500msgo and do usual display routines. Link to comment Share on other sites More sharing options...
donovanvaught Posted November 9, 2011 Author Share Posted November 9, 2011 WOOOT!!!! Ok, first off Baron, A million thank yous for giving me a leg to stand on. I hugely appreciate that you didn't spoon feed me the code, after a hour or so of tinkering, I got the code working swimingly. I used Dim AtkTimer As Long to create ANOTHER variable that played off the ORIGINAL Player(Index).AttackTimer . Below is a slow version proof-of-concept.``` ' Check for attacking animation If Player(Index).AttackTimer + (attackspeed / 2) > GetTickCount Then If Player(Index).Attacking = 1 Then AtkTimer = (GetTickCount - Player(Index).AttackTimer) If AtkTimer < 250 Then Anim = 4 End If If AtkTimer < 500 And AtkTimer >= 250 Then Anim = 5 End If If AtkTimer < 750 And AtkTimer >= 500 Then Anim = 6 End If If AtkTimer < 1000 And AtkTimer >= 750 Then Anim = 7 End If If AtkTimer >= 1000 Then Anim = 0 End If End If```Second, I'm sendin you some damn cookies, Baron :cheesy:, you have singlehandedly brought my production out of a black whole.Third, I hope Liger sees this and finds it useful as well.Last, anyone else hoping to use this code that is a noob should know 2 things, 1) the numbers above should be altered to adjust the speed of the animation. 2) Learning and understanding the code to the best of your ability is a reward in and of itself. Now, I just need to see how to have other players see your character animate… Link to comment Share on other sites More sharing options...
Gohan Posted November 13, 2011 Share Posted November 13, 2011 Very nice *proceeds to work this into my tut* Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now