The Daily Click ::. Forums ::. Klik Coding Help ::. Help me fix a small bug!
 

Post Reply  Post Oekaki 
 

Posted By Message

Lönnemyr



Registered
  30/06/2008
Points
  69
30th September, 2008 at 22:00:36 -

Hello, and thank you for your time.


The last time I asked for help I got such good respons so I though I`d ask here again.

The game is an RPG with real time battles, and the problem probably lies within the "combat events". The idea is giving each enemy 2 invisible objects which decide its reach, So far there is only one foe and it`s reach is supposed to be 1.

When the player step into that reach the enemy will hit the player every third second, the first hit should be 3 sec after that the player entered the "attack zone". That way the player might be able to go in close, hit, go back(as if dodge:ing the foes attack), and so on.
This foe is only supposed to hit for one dmg(1 heart!) but for some reason, sometimes it hits for 2dmg!


I think it might has to do with my scratch animation which is an object that spawns on the player when the foe is ready to strike, that object is what actually deals the dmg, but I also feel that it is important with some kind of animation to make the battles a little more "fun". The Player also plays another animation when hit (he "blinks" once), can that be a problem?


Anyway, anyone who would like to take a look could download the gam here (Yes, I use TGF =/ ). Don`t let the grapic scare you, it`s supposed to look like that.

http://lonnemyr.googlepages.com/home <---- Download "Apurpurtale".


Of course you can tell me if you wonder over something else/happens to find another bug etc.. I promise not to bite your head off

 
-

Logiq



Registered
  09/04/2007
Points
  120
30th September, 2008 at 22:42:55 -

Well from what I found out deals with your last event and your "taking damage" animation. The way you have it setup now is that your player is overlapping when the "slash" spawns, it takes the damage and then flashes. While flashing it stops the "'Slash' overlapping 'Player'" event but when the player finished the flash the "Slash" animation is not finished so the "'Slash' overlapping 'Player'" starts up again thus taking another heart away. By taking out the "blank" frame in that animation it fixed the double damage effect.

I replaced the "blank" frame with a copy of your character but replaced it's color with red, so it shows that he was hurt but keeps the error from occurring.

 
Hello guys! I'm New! -- I've been new for a year now...haha

Lönnemyr



Registered
  30/06/2008
Points
  69
30th September, 2008 at 23:01:32 -

Thanks, that fixes the doubble hit bug!

There is still one weird thing thou. Might just be me but sometimes when entering the foe`s battle reach he does not wait 3sec to strike as he is supposed to, instead he strikes almost instantly, which could be a problem.

I think it might have to do with how I set the "wait Xsec" event, I admit I was not really sure what I was doing since I never done anything like that before. Suggestions?

 
-

Logiq



Registered
  09/04/2007
Points
  120
30th September, 2008 at 23:21:20 -

I've never used TGF so i don't know whether it uses Alterable Values and Flags, but if they do then I would utilize those. Dedicate "flag 0" for in range and "Alterable Value A" for Attack Timer. Before going into your event editor, set your Alterable Value A how ever long you want it to take to attack.


If player is overlapping "close strike area"
-or-
If player is overlapping "close strike area 2"
-- Set flag 0 ON


This first event it pretty self explanatory.


If flag 0 is ON
-- Substract 1 from Alterable Value A


This next event will start the timer if the Flag is ON


X If player is overlapping "close strike area" X
X If player is overlapping "close strike area 2" X
-- Set flag 0 OFF
-- Set Alterable Value to (whatever you had it set to in the beginning)


This event will make everything reset itself if the player leaves the ranged area.


If Alterable Value A =< 0
-- (do your attack stuff)
-- Set flag 0 OFF
-- Set Alterable Value A to (whatever you had it set to in the beginning)


This event will set off the attack when the timer hits 0. After the attack it will reset itself.

I hope that was easy to understand. If not then let me know.

 
Hello guys! I'm New! -- I've been new for a year now...haha

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
30th September, 2008 at 23:49:48 -

Personally, I'd ditch the detectors altogether and compare the distance using a formula.
I took the liberty of making some modifications to your game to demonstrate what I mean.

http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/Apurpurtale.gam



 
n/a

Lönnemyr



Registered
  30/06/2008
Points
  69
1st October, 2008 at 00:11:20 -

Logiq

TGF has Flags and Alterable Values, don`t know how many for each object though..

I understood everything except the timer? Were is the timer? If the attack goes off when the alterable value get <0 then the foe will attack when the player enter the zone?

[EDIT; oh! I missed the part were I was supposed to set the alterable value. Were if not in the event editor can I do this? Thanks.]

Sketchy


I`m not good at using code or TGF, thats why I used detectors (the only way I know). I tried to download your example but all I get is an empty gam file.. D:

Image Edited by the Author.

Image Edited by the Author.

 
-

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
1st October, 2008 at 00:15:34 -

16 flags, 3 Alterable values.

Kind of limited, but you can find ways to work around that.

 
Craps, I'm an old man!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st October, 2008 at 00:24:27 -

I don't have TGF - I saved it using MMF1.5, but I guess it didn't work
Here's the changes anyway;

Image

It's occurred to me that you may need to save your alterable values. If I remember right, TGF doesn't have very many, although it's possible to pack several numbers into one.

Edit: Knudde beat me to it LoL

Image Edited by the Author.

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
1st October, 2008 at 00:31:01 -


Originally Posted by Sketchy
I don't have TGF - I saved it using MMF1.5, but I guess it didn't work
Here's the changes anyway;

Image

It's occurred to me that you may need to save your alterable values. If I remember right, TGF doesn't have very many, although it's possible to pack several numbers into one.



Yeah, I've used that method several times. In one of my tactics games Value A held the values of HP, MoveP, and a few other things. Simply put, I did it like this
987

9 = HP
8 = MP
7 = Something Else

1. Divide 100 into 987 = 9
2. Subtract the above result (9) times 100 to = 87
3. Repeat 1 and 2 with 10's

You'll run into problems with 0's though.

 
Craps, I'm an old man!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st October, 2008 at 00:38:21 -

or the left$, right$, and mid$ functions are pretty useful if they exist in TGF. Gets a bit trickier when you are adding zeroes in front of values to force them to a certain length.


 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
1st October, 2008 at 02:23:12 -

Hello, Lonnemyr. I've shortened my name since you were last here, but I also got my old hard drive back, so I now have TGF1 again! However, I can't help you right now, not until Friday, because I have to work.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Lönnemyr



Registered
  30/06/2008
Points
  69
1st October, 2008 at 16:44:21 -

By the way, I`m trying to set all normal events (like open tresure chests, pushing blocks, etc) in the first frame, and then copy the entire frame with events and everything, delete the "play area" and remodel it. I`m thinking I wont have to redo everything in the event editor everytime if I do this.. but maybe it would be better to select tose "normal events" as global? Are there any drawbacks with global events? I never used them..

Jon Lambert

Good to see you again! It`s ok, The "engine" probably won`t be done untill friday anyway=

Sketchy & Knudde

You`ve gotten me all confused now, I`m open for suggestions for how to make the combat more stable etc but I don`t know how to do what sketchy has done (I`m not even sure what he has done). Please explain it like you would explain something to an idiot

About saving flags and values, The game won`t be that complex.. or big, really. Of course I dont know everything that will be needed yet, but I`m thinking something like 5 (small) dungeons with bosses and "special items". Nothing to fancy though, mostly puzzle solving and a few monsters here and there. And ofc, some puzzles outside the dungeons were you can get some tresures and "stuff".

So far I have done;

*Player movement.

*Pushy blocks which you can push around - every zelda clone has them

*Arrow "blocks" on which player can stand and "PurPur" will be moved to the place were the arrow is pointing. - Thinking about doing other arrow blocks on which you could push those "pushy blocks" and also give purpur an animation when moved by the arrow blocks.

*tresure chest which you can open and get a few gems from.

-----------

If anyone has any suggestions to anything else I should put in this game I will lend you an ear, nothing monster complex though, becuse if I try something like that I will never finish



[EDIT; I updated the file, only new in this one is the "pushy block mongos" which you can push around and the red arrow blocks on which you can pushy the "pushy block mongos" and then they will move in that direction. I also deleted most of the battle events since it was buggy and it seems like someone here could give me a better idea for how to solve it.]

Image Edited by the Author.

[EDIT2; oh, it seems like I didn`t delete most of the battle events. Still some left... ]

Image Edited by the Author.

 
-

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st October, 2008 at 18:49:28 -

Ok, I'll try


This might be a bit patronising to begin with...

To start with, all your graphics are basically 50x50 pixel squares (or "Tiles"), and they all line up to form a "grid".

Image

All of the active objects in your game have what are known as "Alterable Values" (3 of them in fact - A,B, and C). These work just like counters, except that they are unique to each instance of an object. Even if you have lots of duplicates of "Baddie1", each one has it's own individual set of alterable values.

Flags work in much the same way, but can only be "on" or "off". Think of them as counters whose value can only ever be "0" or "1". You'll generally use them as switches, to "activate" or "deactivate" events.

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

Now, onto the events themselves...

11| Always
-> set Alterable Value A to
Abs( ( X( "Baddy 1" ) / 50 ) - ( X( "PurPur" ) / 50 ) ) + Abs( ( Y( "Baddy 1" ) / 50 ) - ( Y( "PurPur" ) / 50 ) )

Let's start with this bit "X( Baddy 1" ) / 50".
Remember that "grid" I was talking about? What this bit does, is find the horizontal grid coordinate of "Baddy 1" like in the diagram above. We do this by dividing its screen coordinate by the width of each individual tile - in this case 50 pixels.

"Y( "Baddy 1" ) / 50" does exactly the same thing with the Y coordinate.

Ignoring the Abs() for now, what we're essentially saying is this;

(Grid X of "Baddie 1" - Grid X of "PurPur") + (Grid Y of "Baddie 1" - Grid Y of "PurPur")

Looking at the example image above, this would be;

( 3 - 1 ) + ( 1 - 0 ) which = 3

Hopefully, you can now see that what we are doing, is finding the distance in grid tiles, between the "Baddy1" and
"PurPur", and setting "Baddy1"'s alterable value to this distance.

Image

Now, back to that "Abs()" business...
"Abs" is a special function that removes the sign from a number. "-10" becomes just plain "10" for example.

So why do we use it here? Well, suppose we change the positions of "Baddy1" and "PurPur".

Image

Our formula would now look like this;

( 1 - 3 ) + ( 2 - 1 ) which = -1

However, the actual distance is still 3. By using Abs() to force all our values to be positive, we get the correct result.

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

Right, that just about covers Line 11 - onto line 13!

What we're doing here, is comparing the grid distance that we just calculated to "1". Here, "1" represents the maximum attack range of "Baddy1" (measured in grid squares of course). If we used "2" instead of "1", then "Baddy1" could attack "PurPur" from 2 squares away.

We're using another alterable value here - "Alterable Value B". Once we've determined that "PurPur" is within attack range (1 square away) we start to add 1 to Alterable Value B every second.

In line 16, we check to see if alterable value B = 3, as this would mean that "PurPur" has been within attack range for 3 seconds. In this case, we perform all the actions relating to an attack, and reset alterable value B to 0, ready to start timing the next 3 seconds.

Now, let's go back to line 14 for a second. This is to check whether "PurPur" leaves attack range within the 3 seconds.

This way, we know to set alterable value back to 0. Otherwise, "PurPur" could be in attack range for 2 seconds before moving out of range. This would result in alterable value B reaching 2, thus next time "PurPur" moved back into range, it would take just 1 second before damage was dealt, instead of the normal 3 seconds.


damn that was long... I should write a book

Image Edited by the Author.

 
n/a

Lönnemyr



Registered
  30/06/2008
Points
  69
1st October, 2008 at 19:38:17 -

A bit confusing, yes (becuse never used alt values, only global).

You explain the math pretty good, but I have a problem with creating those events in the event editor..

What I do is;

Enter the event editor..

Create a new "always" event, then klicks on baddy1`s values..

Image

Press the "Edit" button..

Image

Klick on "set value" for the alterable value "A"..

Image

Copy paste the formula.. (I guess this is were I went wrong, eyy?

Image



...Screenshot 2-3 got a bit messed up, you can see screenshot 1 behind them but whatever ;P


 
-

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st October, 2008 at 20:06:03 -

Hmmm. You appear to be doing everything right. There's a possibility that TGF may not support the Abs function - you don't seem to have a lot of the buttons in the expression editor that there are in MMF.

Try this;
( X( "Baddy 1" ) / 50 ) - ( X( "PurPur" ) / 50 ) + ( Y( "Baddy 1" ) / 50 ) - ( Y( "PurPur" ) / 50 )

If TGF doesn't complain, then it means TGF has a problem with Abs, in which case I'll have to come up with an alternative.

I'm going to download the TGF demo to see exactly what is possible.

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click