User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: RPG-like damage counters

  1. #1
    No Products Registered

    Join Date
    Jun 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RPG-like damage counters

    When my player attacks an enemy I want the amount of damage dealt to show up in a number above the enemies head. The number will then float upwards and fade away. I've tried using a counter object for this but its semi-transparency is a fixed value, and there are no values to control multiple instances of it. I'd use an active object but the number can be anything from 0-9999 so..I've also tried using a string but that didn't work out. Any ideas on how this could be done? Thanks.

  2. #2
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    use a hidden counter for a enemy. Then use a string and always change the alterable string to String(counter).

    I don't know the exact code for value-->sting, but it's in the expression editor.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    Its actually an often requested feature and I'm sure you could find a tutorial on this somewhere, but I'll tell you my own approach. If you're familiar with the CallBack controls of the text blitter object (I mean *very* familiar) it can do this exact effect, with a lot greater options than anything else.


    You should have a large text blitter that overlaps the entire window and does not follow the frame. Somehow, you should instantiate multiple lines of text inside the blitter that would correspond to each object. This could prove very tricky to pull off. One possible way of doing this, if you don't care about the # of active objects, is to just create a new active object as a dummy unit offscreen to record the values of the line of text to be displayed.

    So for example:

    Code:
    +On enemy being hit by sword"
    =Create "dummytext" @ (-100,-100)
    =Set value text_posx of "dummytext" to X("enemy")
    =Set value text_posy of "dummytext" to Y("enemy")
    =Set string damage of "dummytext" to str$(damage done by player)
    =Set value duration of "dummytext" to 50
    =Set value string_length of "dummytext" to len$(damage("dummytext")

    Then, you should run very specific controls of the callback on the text blitter. The easiest way to do this is to load up the text of the text blitter with something like 100x repeating "A" characters ("AAAAAAAAAA....."). Doesn't actually matter which character. Remember to enable "On Character Callback".


    Create a callback event, which should display the text for the damage. This is where it gets tricky. You need the game to display as many characters in a row for each damage as the length of the string, but the callback goes on a 'per character' basis. Since the order you draw the characters wouldn't matter, an interesting way to do this would be to keep a variable inside each "dummytext" object that keeps track of how many characters are left. On the character callback, you can position the X & Y of the string, as well as the transparency.

    An implementation would look like this:



    Code:
    +Callback: On Begin
    =Set flag 1 of "dummytext" to OFF
    =Set flag 2 of "dummytext" to OFF
    =Set value counter("dummytext") to 0 (zero)
    
    
    +Callback: On character
    =Callback-> Set destination X to -100
    (this causes extra numbers to not be displayed)

    Code:
    +Callback: On character
    +Flag 1 of "SomeOtherObjectInTheGame" is OFF
    +Flag 2 of "dummytext" is OFF
    +Pick a "dummytext" at random
    =Set Flag 1 of "dummytext" to ON
    =Set Flag 1 of "SomeOtherObjectInTheGame" to ON
    (this picks a random dummy text that hasn't yet been drawn to the screen to be the one rendered- this way the game will only being drawing a single dummy at a time. The flags look like this:
    Flag 1 of dummytext: "is this object drawing currently?"
    Flag 2 of dummytext: "has this object already drawn?"
    Flag 1 of someotherobject: "is a dummytext already drawing?")


    Code:
    +Callback: On Character
    +Flag 1 of DummyText is ON
    =Callback: Set Destination X to (text_posx(dummytext) + 8 * counter(dummytext))
    =Callback: Set Destination Y to (text_posy(dummytext))
    =Callback: Set Source X/Y to (stuff, see below)
    =Callback: Set Transparency to (whatever, maybe duration * 2)
    =Add 1 to value Counter("dummytext")

    you need to somehow format the image on your text blitter so that you can easily retrieve the positions of the number images. An easy way to do this would be to put 0/1/2/3/4/5/6/7/8/9 all in one big horizontal strip. Then, you could retrieve the source positions like this:

    Source X = val(damage(dummytext)) * 16
    Source Y = 0


    Code:
    +Callback: On Character
    +Flag 1 of "Dummytext" is ON
    +Counter("dummytext") == string_length("dummytext")
    =Set Flag 1 of Dummytext to OFF
    =Set Flag 1 of SomeOtherObjectInTheGame to OFF

    (this inactivates the dummy text once the full string has been read).



    I really ought to have just made an example for you, which I probably could have done even faster than writing this out. But that would have been much to vulgar a display of power, my dear father karras.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    Speaking of vulgar displays of power, look what I cooked up in 5 minutes:
    http://sites.google.com/site/claniraq/stuff/Counters.mfa?attredirects=0&d=1

    Feel free to use that- it would require lots of editting to look better and work in scrolling applications and so on. There might be a few "off by one" errors, too.

    EDIT: Oops I totally attached the wrong file
    that other one was an engine for using text blitters for graphics

  5. #5
    No Products Registered

    Join Date
    Jun 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    O_O wow. Thanks for all the info and the example. This really shows off the text blitter object. This seems like an extremely overworked method for doing what you'd think is really simple though :\ not to mention having a giant TBO over my frame could possibly bog things down..but I'll see how it goes..would you have any simpler methods by chance? preferably using only one or two small objects?

    On another note, so I don't make 2 posts..How do you get a dragging camera to not shake the player object when scrolling? I've tried multiple dragging methods but the player continues to shake..perhaps the camera's movement isn't the case?

  6. #6
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    Well, I don't think there is a simple method, or someone would have found it by now. Its really been a tutorial/request I've seen a lot of, but I don't think i've seen too many people pulling it off. The TBO won't bog down your game- its an extremely optimized object, and at the most its probably going to be parsing 10 characters at a time.

    In order to get it to work on a scrolling app, go into the "Destination X/Y" events of the callback, and subtract "X Left Frame" and "Y Top Frame" from each, respectively, and then go into the level editor and set the TBO to not follow the frame. Then it should work great! If you want to make it slightly more efficient, set the alterable text of the blitter to be just "AAAAAAAAAAAAAAA", that is, 15 characters long. Because I doubt you'll ever have more than 15 characters blitted to the screen at once, and even if you do, it will just cause them to flicker.

  7. #7
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    That's some fantastic Text Blitter mad science there - thanks for putting all of that up! I would have suggested using the same object, but created/destroyed on an individual basis (as you have the advantage with Text Blitter of having alterable values...)

  8. #8
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    I suppose yeah you could do that.
    Create individual text blitters, treat them like active objects.

    ofc that would be less efficient, and not give you as much control >.>

  9. #9
    No Products Registered

    Join Date
    Jun 2007
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    So I spent some time messing with the above example, and got some pretty awesome results. This turned out to be exactly what I needed . No slowdown or anything either with the giant text blitter..even if there was I can add the scrolling stuff you mentioned and shrink it down to window size..Thanks for all the help!

    Does anyone have any ideas about the dragging camera shaking my player when scrolling though? I can upload an example if needed..I'm sure someone's had this problem before o.o It may just be because my player object is kinda slow but I can't speed him up anymore :\

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleMac Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Tisnart's Avatar
    Join Date
    Feb 2008
    Location
    On, Canada
    Posts
    1,073
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: RPG-like damage counters

    Very nice example Pixelthief
    I have never used the text blitter object as of yet, but now I'm going to!! :grin: Thanx

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Need Help with Player Damage
    By 122334shadow in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 1st December 2010, 08:06 AM
  2. Battle damage
    By Twario in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 5th July 2010, 06:36 AM
  3. Enemys take damage.
    By Dakk in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 22nd March 2010, 11:09 AM
  4. Floating Damage Counters like in RPG's
    By Pixelthief in forum File Archive
    Replies: 0
    Last Post: 17th November 2009, 02:14 PM
  5. RPG Damage Formula
    By ZayLong in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 5th September 2008, 08:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •