Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2012-06-17 15:32:51

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

about new decorators

this is a spin-off from http://opensnc.sourceforge.net/forum/vi … p?id=1290. In that thread, you guys asked for a new decorator called on_player_invincible.

that's a fairly simple decorator to make. Many other useful decorators are also surprisingly easy to make (once you know the recipe): for example, give players a shield, check if they've got the speedshoes, etc. Unfortunately, my free time is limited and, while not in vacations, I end up programming stuff for opensurge for much less time than I'd like to. Simple decorators such as on_player_invincible, that in reality take only a few minutes to be made, end up taking days, if not more.

I know that some of you guys have knowledge that go beyond scripting, and I know that you're really interested in making the engine better. So, since there are decorators that are easy to make, instead of waiting a lot of time for me to write them, I thought: would it be possible that you guys wrote some of these simple decorators and submitted patches, so that everyone can benefit from them? You're clearly interested on those, but I guess everybody else is interested too.

Here, I wrote some simple decorator called on_player_ultrafast: it checks whether the player has the speed shoes or not. Here's the recipe for adding an on_something decorator (click here to see more):

  • opensurge/trunk/src/entities/player.h: I added a new function, player_is_ultrafast(), that returns true or false.

  • opensurge/trunk/src/entities/player.c: I wrote the code for player_is_ultrafast. It's just
    "return player->got_speedshoes;"

  • opensurge/trunk/src/entities/object_decorators/on_event.h: I added a new function called objectdecorator_onplayerultrafast_new

  • opensurge/trunk/src/entities/object_decorators/on_event.c: I wrote the code of objectdecorator_onplayerultrafast_new (it just calls player_is_ultrafast)

  • opensurge/trunk/src/entities/object_compiler.c: I registered a new event called "on_player_ultrafast". It just calls objectdecorator_onplayerultrafast_new.

Finally, after implementing it, I documented the decorator in the API Reference. This is very important!!!

Writing on_player_invincible is 99% the same thing. Can you do it? If you do it, maybe I can tackle (and explain) unroll_player too. smile

Offline

#2 2012-06-17 16:08:28

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: about new decorators

alright big_smile hands on the job now...


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#3 2012-06-17 18:53:24

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Why is the decorator called "on_player_ultrafast"? I think "speedshoes" is better since the powerup is called Speed Shoes...

EDIT: Do we need a new revision in order to make the decorator valid?
EDIT2: Got an idea for a new decorator. We got a decorator called "add_collectibles", well how about this?

  object "Custom Shield Box"
  {
         state "main"
     {
             let $stability=3
             set_obstacle TRUE
             change_state "loop"
     }
        state "loop"
     {
            set_animation SD_CRATE 0
            on_player_attack "take_damage"
     }
        state "take_damage"
     {
            let $stability-=1
            if $stability==0 "break"
            change_state "cooldown"
     }
        state "cooldown"
     {
            on_timeout 0.5 "loop"
     }
        state "break"
     {
           set_animation SD_CRATE 1
           give_shield "shield"
           on_animation_finished "destroy"
     }
        state "destroy"
     {
           destroy
     }
}

The "give_shield" "<shield>" varies from this:

"shield"
"fireshield"
"thundershield"
"watershield"
"acidshield"
"windshield"
"invincible"

I don't think "create_item" just doesn't work in some conditions.

Last edited by S32X (2012-06-17 19:08:45)

Offline

#4 2012-06-17 19:50:55

SupertheHedgie
Member
Registered: 2011-12-11
Posts: 120

Re: about new decorators

S32X wrote:

"give_shield"

its already planned

Offline

#5 2012-06-17 20:23:38

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Awesome! Can't wait 'till it comes out!

Offline

#6 2012-06-17 22:07:32

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: about new decorators

KZR wrote:

alright big_smile hands on the job now...

Great! Glad you accepted. Please remember to put your name in the code you write. Also, since you're hacking the source code, you need to release your modifications under the same license.

S32X wrote:

Why is the decorator called "on_player_ultrafast"? I think "speedshoes" is better since the powerup is called Speed Shoes...

to whoever speaks lots of english: isn't saying "on_player_speedshoes" weird? why/why not?

Offline

#7 2012-06-17 22:17:09

SupertheHedgie
Member
Registered: 2011-12-11
Posts: 120

Re: about new decorators

Alexandre wrote:

to whoever speaks lots of english: isn't saying "on_player_speedshoes" weird? why/why not?

it makes more sense to do 'speedshoes' because speed shoes is the name of the item. its no weirder than saying 'invincible' in 'on_player_invincible'.

however, i do think that 'ultrafast' is weird because its not really referenced at any other place in the game. it'd be harder to memorize. ("was it ultra fast, or was it super fast? i forgot")

Last edited by SupertheHedgie (2012-06-17 22:17:47)

Offline

#8 2012-06-17 22:28:25

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: about new decorators

yeah, indeed, "ultrafast" breaks the internal consistency... You're absolutely right. It must be "speedshoes". Thanks.

I'll change it to on_player_speedshoes. Please let me see if kzr submits the decorator first.

Offline

#9 2012-06-17 23:00:43

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Excellent. Now could I ask a favour? Could someone compile Revision 704 to a binary for download? I want to experiment this new decorator but I don't know how to compile the source.

Offline

#10 2012-06-18 01:12:13

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

S32X wrote:

Excellent. Now could I ask a favour? Could someone compile Revision 704 to a binary for download? I want to experiment this new decorator but I don't know how to compile the source.

I could compile that for you, however I will wait until KZR is done messing around with decorators.  I might start messing around with them later tonight (depending entirely on the server status of League of Legends) and if either me or him makes a working patch for it then we will submit it so that it can make it into the build.  If I don't end up toying with it and KZR doesn't end up building that patch I will grab the latest and compile it so you can try it.


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#11 2012-06-18 01:15:20

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Great! Remember I run a Windows.

Offline

#12 2012-06-18 02:30:22

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: about new decorators

I haven't had time yet, but i will work on that real soon


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#13 2012-06-18 04:41:08

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

I don't want to rush anyone. But I really want to use that decorator for an object in Sonic Greek Overture... But no rush. smile

Offline

#14 2012-06-18 06:25:41

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

S32X wrote:

I don't want to rush anyone. But I really want to use that decorator for an object in Sonic Greek Overture... But no rush. smile

The multiplayer revision should have the 'ultrafast' decorator, you can use it there, though I'm not sure if it is currently the old wording or the new wording.  Which decorator in particular were you thinking about for SGO?


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#15 2012-06-18 06:28:53

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

on_player_ultrafast. I have a object that when that happens the player leaves a trail of smoke/fire behind.

Offline

#16 2012-06-18 11:26:49

Sugarmaster
Member
From: Barcelona, Spain
Registered: 2011-04-26
Posts: 132
Website

Re: about new decorators

Alex, i think this post should be sticky because it's very important the explanation you gave about creating new decorators. It's a neat piece of information useful for all.


"The true master is always learning"
Avatar by Raul Sama.

Offline

#17 2012-06-19 23:10:42

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

Hi there,
Just made a patch that changes the ultrafast reference in the decorator to speedshoes and adds the new on_player_invincible modifier.  It took a few tries, but I finally got it to work.  Give it a shot if you want to, please keep in mind that this folder only contains the source code files I modified, I will release my compile of it if Alex agrees that I did it right.  I left ultrafast in player.h and player.c because it made more sense there than speedshoes, if this is wrong please feel free to tell me.
thanks,
-lunar
Edit: Link removed, please see my new thread for an updated version of the link.

Edit: Haven't documented it yet either, want it to be accepted first.

Last edited by lunarrush (2012-06-20 23:38:46)


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#18 2012-06-20 01:24:56

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Thanks.

EDIT: Oh... it's just the patch... could you put this in a binary? KZR has a multiplayer on_player_ultrafast one, but no on_player_invincible.

Last edited by S32X (2012-06-20 01:29:49)

Offline

#19 2012-06-20 04:02:29

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

In this patch I changed the following:
on_player_ultrafast became on_player_speedshoes
added on_player_invincible.

I can distribute the binary, but I need to hear from Alex first because this might become part of the build and I need to know the steps from here.


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#20 2012-06-20 04:14:40

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

There should be some sort of "ring tone" on Alex's computer that let's him know we need him. tongue

Offline

#21 2012-06-20 04:16:52

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: about new decorators

lunar, although i haven't tested it, it looks like everything is right smile

Nice job! Was it easy?

Two things:
- please follow the coding conventions: use 4 spaces, not tabs]
- please put your name in your modifications

S32X wrote:

There should be some sort of "ring tone" on Alex's computer that let's him know we need him

you're kidding, right.

Offline

#22 2012-06-20 04:18:46

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Of course I am! lol It would get pretty annoying if there every one needed me all the time.

Offline

#23 2012-06-20 04:19:56

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

It was fairly easy, now I have an ambition to do more.  I will set up notepad++ to four space when I press tab.  Where should I put my name, in the header?

Edit2: Found it

Last edited by lunarrush (2012-06-20 04:28:18)


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#24 2012-06-20 04:23:36

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: about new decorators

Hey lunarrush. If doing this is so easy, do you think that you could implement the "multiplayer" thing Alex was talking about in another thread?

Offline

#25 2012-06-20 04:36:16

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: about new decorators

@Everyone: I have included a binary in the latest version in the root of the zip, if you want that binary go ahead.

@S32X: I will probably try, but I have a few more priorities ahead of me, namely unroll_player, on_category_collision, and change_background


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org