Jump to content
×
×
  • Create New...

Restart Dialog Timer System


Recommended Posts

  • Honorable Member

M2 Download Center

Hidden Content

    Give reaction to this post to see the hidden content.
( Internal )

Hidden Content

    Give reaction to this post to see the hidden content.
( GitHub )

Spoiler

19242268747470733a2f2f6d656469612e67697019242268747470733a2f2f7075752e73682f4458

 

  • Metin2 Dev 13
  • Love 33
  • Good 6
  • Lmao 1
  • LoL 1
Link to comment
  • Honorable Member
2 minutes ago, PeaceMaker said:

There is no need to extend the packet. 
You can simply do it in python ....

wtf?

Where do you get times?? It's not same everytime. If you open exchange or anything it will change

Link to comment
16 minutes ago, Mali61 said:

wtf?

Where do you get times?? It's not same everytime. If you open exchange or anything it will change

I've looked again over your code and yes every calculation you did on CalculateDeadTime can be done client side. 
I know it would take more time to do that as you need to set the last time you traded or opened a shop then do the calculation ... 

 
But i just don't like using extra unnecessary packets that can be prevented. 

Link to comment
  • Honorable Member
27 minutes ago, PeaceMaker said:

I've looked again over your code and yes every calculation you did on CalculateDeadTime can be done client side. 
I know it would take more time to do that as you need to set the last time you traded or opened a shop then do the calculation ... 

 
But i just don't like using extra unnecessary packets that can be prevented. 

Yes client side can make but this is the easiest way. Why do we do the hardest?

You don't like packets but you like longest and weirds codes?

  • Love 3
Link to comment

@Mali61 I just implemented your code and I got some problems.

1. If you die for the first time -  you can see timers

2. If you die for the second time and you used restart here in the first death - you cannot see timers

3. After using restart in town - timers will start working but again only after first death (second, third etc. deaths won't show the timers)

Only after restarting in town you can see timers everytime.

Hope you will look into it and try to provide us some solution. 

Thanks!

Link to comment
  • Honorable Member
7 hours ago, ReFresh said:

@Mali61 I just implemented your code and I got some problems.

1. If you die for the first time -  you can see timers

2. If you die for the second time and you used restart here in the first death - you cannot see timers

3. After using restart in town - timers will start working but again only after first death (second, third etc. deaths won't show the timers)

Only after restarting in town you can see timers everytime.

Hope you will look into it and try to provide us some solution. 

Thanks!

fixed

  • Love 1
Link to comment
  • Honorable Member

Hidden Content

    Give reaction to this post to see the hidden content.

Spoiler
//<srv&client:packet.h
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
enum EReviveTypes
{
	REVIVE_TYPE_HERE,
	REVIVE_TYPE_TOWN,
	REVIVE_TYPE_AUTO_TOWN,
	REVIVE_TYPE_MAX
};
#endif

typedef struct packet_dead
{
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
	packet_dead()
	{
		memset(&reviveTime, 0, sizeof(reviveTime));
	}
#endif
	BYTE	header;
	DWORD	vid;
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
	BYTE	reviveTime[REVIVE_TYPE_MAX];
#endif
} TPacketGCDead;
//>

//<srv:char.h
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
	public:
		BYTE		CalcReviveTimeDelay(uint8_t bType);
#endif
//>

//<srv:char.cpp
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
BYTE CHARACTER::CalcReviveTimeDelay(uint8_t bType)
{
	if (!m_pkDeadEvent)
		return 0;

	BYTE bTimeToDead = BYTE(event_time(m_pkDeadEvent) / passes_per_sec);
	if (bType == REVIVE_TYPE_AUTO_TOWN)
		return bTimeToDead-7;

	if (!test_server && bType == REVIVE_TYPE_HERE && (!GetWarMap() || GetWarMap()->GetType() == GUILD_WAR_TYPE_FLAG))
	{
		if (IsHack(false) && !CThreeWayWar::instance().IsSungZiMapIndex(GetMapIndex()))
			return bTimeToDead - (180 - g_nPortalLimitTime);
		if (bTimeToDead > 170)
			return bTimeToDead - 170;
	}

	if (IsHack(false) && ((!GetWarMap() || GetWarMap()->GetType() == GUILD_WAR_TYPE_FLAG) || !CThreeWayWar::instance().IsSungZiMapIndex(GetMapIndex())))
		return bTimeToDead - (180 - g_nPortalLimitTime);

	if (bTimeToDead > 173)
		return bTimeToDead - 173;

	return 0;
}
#endif
//>

//<srv:char_battle.cpp
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
	TPacketGCDead pack;
	pack.header = HEADER_GC_DEAD;
	pack.vid = m_vid;
	pack.reviveTime[REVIVE_TYPE_HERE] = CalcReviveTimeDelay(REVIVE_TYPE_HERE);
	pack.reviveTime[REVIVE_TYPE_TOWN] = CalcReviveTimeDelay(REVIVE_TYPE_TOWN);
	pack.reviveTime[REVIVE_TYPE_AUTO_TOWN] = CalcReviveTimeDelay(REVIVE_TYPE_AUTO_TOWN);
	PacketAround(&pack, sizeof(pack));
#endif
//>

//<srv:char_horse.cpp
// You can skip it.
//>

//<client:PythonNetworkStreamPhaseGame.cpp
			if (false == pkInstMain->GetDuelMode())
			{
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
				PyObject *times = PyTuple_New(REVIVE_TYPE_MAX);
				PyTuple_SetItem(times, 0, PyInt_FromLong(DeadPacket.reviveTime[REVIVE_TYPE_HERE]));
				PyTuple_SetItem(times, 1, PyInt_FromLong(DeadPacket.reviveTime[REVIVE_TYPE_TOWN]));
				PyTuple_SetItem(times, 2, PyInt_FromLong(DeadPacket.reviveTime[REVIVE_TYPE_AUTO_TOWN]));
				PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnGameOver", Py_BuildValue("(O)", times));
#else
				PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "OnGameOver", Py_BuildValue("()"));
#endif

//>

//<srv:PythonPlayerModule.cpp
#ifdef ENABLE_REVIVE_BOARD_RENEWAL
	PyModule_AddIntConstant(poModule, "REVIVE_TYPE_HERE",		REVIVE_TYPE_HERE);
	PyModule_AddIntConstant(poModule, "REVIVE_TYPE_TOWN",		REVIVE_TYPE_TOWN);
	PyModule_AddIntConstant(poModule, "REVIVE_TYPE_AUTO_TOWN",	REVIVE_TYPE_AUTO_TOWN);
	PyModule_AddIntConstant(poModule, "REVIVE_TYPE_MAX",		REVIVE_TYPE_MAX);
#endif
//>

//<root:game.py
	if app.ENABLE_REVIVE_BOARD_RENEWAL:
		def OnGameOver(self, times):
			self.CloseTargetBoard()
			self.OpenRestartDialog(times)

		def OpenRestartDialog(self, times):
			self.interface.OpenRestartDialog(times)
	else:
		def OnGameOver(self):
			self.CloseTargetBoard()
			self.OpenRestartDialog()

		def OpenRestartDialog(self):
			self.interface.OpenRestartDialog()
//>

//<root:interfaceModule.py
	if app.ENABLE_REVIVE_BOARD_RENEWAL:
		def OpenRestartDialog(self, times):
			self.dlgRestart.OpenDialog(times)
			self.dlgRestart.SetTop()
	else:
		def OpenRestartDialog(self):
			self.dlgRestart.OpenDialog()
			self.dlgRestart.SetTop()
//>

//<root:localeInfo.py
def SecondToMS(time):
	if time < 60:
		return "%d%s" % (time, SECOND)

	second = int(time % 60)
	minute = int((time / 60) % 60)

	text = ""

	if minute > 0:
		text += str(minute) + MINUTE
		if minute > 0:
			text += " "

	if second > 0:
		text += str(second) + SECOND

	return text
//>

//<locale/locale_game.txt
REVIVE_AUTO_TOWN_MESSAGE	Autorestart at town in: {}
//>

 

You can follow the tutorial from the original post, I have changed some names, you can compare them.

  • Metin2 Dev 1
  • Love 13
Link to comment

Is there any possibility @p3ng3r bis Version to ignore at gamemaster?

Because i changed some Line at cmd_general.cpp that gamemaster are possible to start here/start in City without waiting

But now i have to wait...

I tested with return 0 but i will get the negative time

 

I hope, someone know a solution.

Best regards

Link to comment
vor 3 Stunden schrieb Koray:
if 0. < endtime <= .1:

change with

if endtime < 0:

 

dont work -> cant click on buttons. (No syserr)

Hidden Content

    Give reaction to this post to see the hidden content.


 

  • Love 2
Link to comment
Am 2.8.2019 um 16:40 schrieb JeeX:

dont work -> cant click on buttons. (No syserr)

Hidden Content

    Give reaction to this post to see the hidden content.


 

 

Am 28.7.2019 um 19:28 schrieb Helia01:

THX :3

Nice system ?


 

GIF.gif

No Solution?

hope anyone knows

best regards.

Link to comment
  • Honorable Member
On 8/6/2019 at 6:22 PM, JeeX said:

 

No Solution?

hope anyone knows

best regards.

I checked all codes but I did not find any error in py codes. Then I checked ui enable/disable command at client src(PythonWindow.cpp) and I found little mistake. Now I fixed that code and bug solved.

->Update EterPythonLib/PythonWindow.cpp

Link to comment
  • 9 months later...
On 7/15/2019 at 6:27 PM, Mali61 said:

Hidden Content

    Give reaction to this post to see the hidden content.

giphy.gif

 

hi i found a little "bug" on the system:

 

in guildwar you have a timer from 7 seconds but normally it's 0 seconds

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


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.