Jump to content

Functions on timeline


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Hey guys,

 

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:


Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):


            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

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

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:


template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

(just add it to like singleton.h)

  • Metin2 Dev 4
  • Angry 1
  • Good 2
  • Love 6

WRnRW3H.gif

Link to comment
Share on other sites

On 7/12/2020 at 8:31 PM, Distraught said:

Hey guys,

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:


Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):


            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

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

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:

 


template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

 

(just add it to like singleton.h)

where did you put the POINT_GOLD function ?

Edited by Mafuyu
Link to comment
Share on other sites

On 7/14/2020 at 4:56 PM, Distraught said:

That was just an example, it's not a tutorial for that specific stuff.

But put it in CPythonNetworkStream::RecvPointChange in the if (PointChange.Type == POINT_GOLD) condition.

yeah thats what i was trying but it didnt worked for me, it didnt change anything ingame.

can you show the full edit function how it would work? i tried some changes but no effect on it, so i dont know if i made mistaks or if the system doesnt work

Edited by Mafuyu
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.