Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. At the top add:
- import time
- import sys
- import Image
- import linecache
- 2. After "self.pressNumber = None" add:
- self.Env = 0
- self.Resthea = "0"
- self.SnowEnable = 0
- self.NightEnable = 0
- self.ConfigTime = 0
- self.XmasEvent = -1
- self.ConfigSkybox = "0"
- 3. After "net.SendEnterGamePacket()" add (modify it up to your maps):
- ### START OF LOGIN ENVIRONMENT MODULE Resthea.eu, qentinios
- czass = str(time.ctime())
- sekundy = czass[17:19]
- bg = background.GetCurrentMapName()
- """Here you set on which maps changing environment will work."""
- map = ( "metin2_map_4_wiatry",
- "metin2_map_krance_swiata",
- "metin2_map_srodziemie",
- "metin2_map_resthea", )
- if bg in map:
- godziny = czass[11:13]
- minuty = czass[14:16]
- czas = int(godziny + minuty)
- try:
- """Images must be in msenv folder and have the same name as name (*.jpg) and the same size as maximum x,y coordinates on map (256*map_size)"""
- im = Image.open("msenv/" + bg + ".jpg")
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: " + "msenv/" + bg + ".jpg")
- return
- (x, y, z) = player.GetMainCharacterPosition()
- x = int(x/100)
- y = int(y/100)
- try:
- color = str(im.getpixel((int(x),int(y))))
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Not exist pixel: " + str(x) + ", " + str(y) + "; " + "msenv/" + bg + ".jpg")
- return
- #Skybox config
- try:
- ConfigSkybox = linecache.getline("config.cfg", 5)
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: config.cfg")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Using medium quality skybox")
- ConfigSkybox = "_1k"
- """Skybox quality is set in config.cfg ( 512, 1024, 1536px )"""
- if ConfigSkybox in ("_512\n","_1k\n","_1.5k\n"):
- ConfigSkybox = ConfigSkybox[:-1]
- if ConfigSkybox not in ("_512","_1k","_1.5k"):
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Wrong data: " + ConfigSkybox + ", config.cfg, line 5")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Using medium quality skybox")
- ConfigSkybox = "_1k"
- #End of skybox config
- #Xmas event
- try:
- XmasEvent = int(linecache.getline("config.cfg", 8))
- except:
- XmasEvent = 0
- """Special config for xmas"""
- if XmasEvent == 1:
- ColorList={
- #Color (RGB)
- 1 : ("(255, 255, 255)", "(241, 255, 158)", "(254, 0, 0)", "(0, 255, 127)", "(158, 255, 248)", "(253, 254, 62)", "(255, 176, 63)", "(222, 255, 0)", "(95, 255, 0)", "(50, 121, 19)", "(95, 192, 35)", "(214, 214, 214)", "(148, 0, 0)", "(142, 142, 142)", "(251, 165, 0)"),
- #Msenv
- 2 : ("snowm02", "map_n_desert_01", "fire_low", "white_sky", "default", "rainy", "sand_mountain", "vanilia_white", "trent", "trent02", "vanilia", "snowm02", "fire_low", "default", "desert_cloud"),
- #Mp3
- 3 : ("christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/srodziemie/xmas", "christmas/srodziemie/xmas", "christmas/srodziemie/xmas", "christmas/resthea/xmas", "christmas/resthea/xmas_wyspa")
- }
- #End of Xmas event
- """Normal configuration"""
- else:
- ColorList={
- """1 - color in RGB for which we set environment,
- 2 - msenv filename in d:/ymir work/environment/ directory,
- 3 - mp3 filename in BGM directory, which will be played on this area"""
- #Color (RGB)
- 1 : ("(255, 255, 255)", "(241, 255, 158)", "(254, 0, 0)", "(0, 255, 127)", "(158, 255, 248)", "(253, 254, 62)", "(255, 176, 63)", "(222, 255, 0)", "(95, 255, 0)", "(50, 121, 19)", "(95, 192, 35)", "(214, 214, 214)", "(148, 0, 0)", "(142, 142, 142)", "(251, 165, 0)"),
- #Msenv
- 2 : ("snowm02", "map_n_desert_01", "fire_low", "white_sky", "default", "rainy", "sand_mountain", "vanilia_white", "trent", "trent02", "vanilia", "snowm02", "fire_low", "default", "desert_cloud"),
- #Mp3
- 3 : ("4w/lodowa", "4w/pustynia", "4w/ognista", "4w/orki", "4w/srodek", "krance/przeklete", "krance/pustynia", "krance/swiatynia", "krance/las", "krance/las2", "srodziemie/trawa", "srodziemie/lodowa", "srodziemie/ognista", "resthea/trawa", "resthea/wyspa")
- }
- i = 0
- Colors = ColorList[1]
- length = len(Colors)
- for ColorItem in xrange(length):
- if color == Colors[ColorItem]:
- Msenv = ColorList[2]
- Music = ColorList[3]
- """Msenv files must be named according to this template (map_name + { _512 lub _1k lub 15k } + .msenv) """
- background.RegisterEnvironmentData(1, "d:/ymir work/environment/" + Msenv[ColorItem] + ConfigSkybox + ".msenv")
- background.SetEnvironmentData(1)
- if app.IsExistFile("BGM/" + Music[ColorItem] + ".mp3")==1:
- if musicInfo.fieldMusic != "":
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic = (Music[ColorItem] + ".mp3")
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- else:
- if musicInfo.fieldMusic != "":
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic=musicInfo.METIN2THEMA
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- snd.SetMusicVolume(systemSetting.GetMusicVolume()*0.5)
- break
- else:
- i = i+1
- if i == length:
- background.SetEnvironmentData(0)
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic=musicInfo.METIN2THEMA
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- ### END OF LOGIN ENVIRONMENT MODULE Resthea.eu, qentinios
- 4. After "self.interface.BUILD_OnUpdate()" add:
- self.__SpecialEnvironmentEnable(self.Env, self.Resthea, self.SnowEnable, self.NightEnable, self.ConfigTime, self.ConfigSkybox, self.XmasEvent)
- 5. After "__SpecialEnvironmentEnable" add whole function (modify it up to your maps):
- def __SpecialEnvironmentEnable(self, Env, Resthea, SnowEnable, NightEnable, ConfigTime, ConfigSkybox, XmasEvent):
- ### START OF ENVIRONMENT MODULE Resthea.eu, qentinios
- self.Env = Env
- self.Resthea = Resthea
- self.SnowEnable = SnowEnable
- self.NightEnable = NightEnable
- self.ConfigTime = ConfigTime
- self.ConfigSkybox = ConfigSkybox
- self.XmasEvent = XmasEvent
- czass = str(time.ctime())
- sekundy = czass[17:19]
- bg = background.GetCurrentMapName()
- if ConfigTime == 0:
- try:
- ConfigTime = int(linecache.getline("config.cfg", 2))
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: config.cfg")
- if ConfigTime == -1:
- return
- """Here you set on which maps changing environment will work."""
- map = ( "metin2_map_4_wiatry",
- "metin2_map_krance_swiata",
- "metin2_map_srodziemie",
- "metin2_map_resthea", )
- if bg in map and sekundy != Env:
- if ConfigTime == 5 and int(sekundy) in (5,10,15,20,25,30,35,40,45,50,55,00):
- self.Env = sekundy
- pass
- elif ConfigTime == 15 and int(sekundy) in (15,30,45,00):
- self.Env = sekundy
- pass
- elif ConfigTime == 30 and int(sekundy) in (30,00):
- self.Env = sekundy
- pass
- elif ConfigTime == 60 and int(sekundy) == 30:
- pass
- else:
- if ConfigTime not in (-1,5,15,30,60) and int(sekundy) == 30:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Wrong data: " + ConfigTime + ", config.cfg, line 2")
- self.Env = sekundy
- return
- else:
- return
- minuty = czass[14:16]
- godziny = czass[11:13]
- czas = int(godziny + minuty)
- try:
- """Images must be in msenv folder and have the same name as name (*.jpg) and the same size as maximum x,y coordinates on map (256*map_size)"""
- im = Image.open("msenv/" + bg + ".jpg")
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: " + "msenv/" + bg + ".jpg")
- return
- (x, y, z) = player.GetMainCharacterPosition()
- x = int(x/100)
- y = int(y/100)
- try:
- color = str(im.getpixel((int(x),int(y))))
- except:
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
- chat.AppendChat(chat.CHAT_TYPE_INFO, "Not exist pixel: " + str(x) + ", " + str(y) + "; " + "msenv/" + bg + ".jpg")
- return
- #Skybox config
- if ConfigSkybox == "0":
- try:
- ConfigSkybox = linecache.getline("config.cfg", 5)
- except:
- ConfigSkybox = "_1k"
- """Skybox quality is set in config.cfg ( 512, 1024, 1536px )"""
- if ConfigSkybox in ("_512\n","_1k\n","_1.5k\n"):
- ConfigSkybox = ConfigSkybox[:-1]
- if ConfigSkybox not in ("_512","_1k","_1.5k"):
- ConfigSkybox = "_1k"
- #End of skybox config
- #Xmas event
- if XmasEvent == -1:
- try:
- XmasEvent = int(linecache.getline("config.cfg", 8))
- except:
- XmasEvent = 0
- """Special config for xmas"""
- if XmasEvent == 1:
- ColorList={
- #Color (RGB)
- 1 : ("(255, 255, 255)", "(241, 255, 158)", "(254, 0, 0)", "(0, 255, 127)", "(158, 255, 248)", "(253, 254, 62)", "(255, 176, 63)", "(222, 255, 0)", "(95, 255, 0)", "(50, 121, 19)", "(95, 192, 35)", "(214, 214, 214)", "(148, 0, 0)", "(142, 142, 142)", "(251, 165, 0)"),
- #Msenv
- 2 : ("snowm02", "map_n_desert_01", "fire_low", "white_sky", "default", "rainy", "sand_mountain", "vanilia_white", "trent", "trent02", "vanilia", "snowm02", "fire_low", "default", "desert_cloud"),
- #Mp3
- 3 : ("christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/4w/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/krance/xmas", "christmas/srodziemie/xmas", "christmas/srodziemie/xmas", "christmas/srodziemie/xmas", "christmas/resthea/xmas", "christmas/resthea/xmas_wyspa"),
- #Snow
- 4 : (1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1)
- }
- #End of Xmas event
- """Normal configuration"""
- else:
- ColorList={
- """1 - color in RGB for which we set environment,
- 2 - msenv filename in d:/ymir work/environment/ directory,
- 3 - mp3 filename in BGM directory, which will be played on this area
- 4 - 1 - enable random snow, 0 - disable"""
- #Color (RGB)
- 1 : ("(255, 255, 255)", "(241, 255, 158)", "(254, 0, 0)", "(0, 255, 127)", "(158, 255, 248)", "(253, 254, 62)", "(255, 176, 63)", "(222, 255, 0)", "(95, 255, 0)", "(50, 121, 19)", "(95, 192, 35)", "(214, 214, 214)", "(148, 0, 0)", "(142, 142, 142)", "(251, 165, 0)"),
- #Msenv
- 2 : ("snowm02", "map_n_desert_01", "fire_low", "white_sky", "default", "rainy", "sand_mountain", "vanilia_white", "trent", "trent02", "vanilia", "snowm02", "fire_low", "default", "desert_cloud"),
- #Mp3
- 3 : ("4w/lodowa", "4w/pustynia", "4w/ognista", "4w/orki", "4w/srodek", "krance/przeklete", "krance/pustynia", "krance/swiatynia", "krance/las", "krance/las2", "srodziemie/trawa", "srodziemie/lodowa", "srodziemie/ognista", "resthea/trawa", "resthea/wyspa"),
- #Snow
- 4 : (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
- }
- i = 0
- Colors = ColorList[1]
- length = len(Colors)
- for ColorItem in xrange(length):
- if color == Colors[ColorItem]:
- #START OF SNOW EFFECT
- Snow = ColorList[4]
- if SnowEnable != 1:
- if Snow[ColorItem] == 1 and int(minuty) in (2,7,12,17,22,27,32,37,42,47,52,57) and int(sekundy) in (00,01,30,31):
- random = app.GetRandom(1,3)
- if random == 1:
- background.EnableSnow(1)
- else:
- background.EnableSnow(0)
- if Snow[ColorItem] == 0:
- background.EnableSnow(0)
- #END OF SNOW EFFECT
- if Resthea == color:
- break
- #START OF MUSIC MODULE
- Music = ColorList[3]
- if app.IsExistFile("BGM/" + Music[ColorItem] + ".mp3")==1:
- if musicInfo.fieldMusic != "":
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic = (Music[ColorItem] + ".mp3")
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- else:
- if musicInfo.fieldMusic != "":
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic=musicInfo.METIN2THEMA
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- #END OF MUSIC MODULE
- Msenv = ColorList[2]
- """Bugfix for night (/x 1)"""
- if NightEnable == 1 and self.__IsXMasMap():
- background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
- background.SetEnvironmentData(1)
- else:
- """Msenv files must be named according to this template (map_name + { _512 lub _1k lub 15k } + .msenv) """
- background.RegisterEnvironmentData(1, "d:/ymir work/environment/" + Msenv[ColorItem] + ConfigSkybox + ".msenv")
- background.SetEnvironmentData(1)
- self.Resthea = color
- break
- else:
- i = i+1
- if i == length:
- background.SetEnvironmentData(0)
- snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
- musicInfo.fieldMusic=musicInfo.METIN2THEMA
- snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
- self.Resthea = color
- ### END OF ENVIRONMENT MODULE Resthea.eu, qentinios
- 6. Replace (whole!) function "__XMasSnow_Enable":
- def __XMasSnow_Enable(self, mode):
- self.__XMasSong_Enable(mode)
- if "1"==mode:
- if not self.__IsXMasMap():
- return
- print "XMAS_SNOW ON"
- background.EnableSnow(1)
- self.SnowEnable = 1
- else:
- print "XMAS_SNOW OFF"
- background.EnableSnow(0)
- self.SnowEnable = 0
- 7. Replace (whole!) function "__DayMode_OnCompleteChangeToLight":
- def __DayMode_OnCompleteChangeToLight(self):
- background.SetEnvironmentData(0)
- self.curtain.FadeIn()
- self.NightEnable = 0
- 8. Replace (whole!) function "__DayMode_OnCompleteChangeToDark":
- def __DayMode_OnCompleteChangeToDark(self):
- background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
- background.SetEnvironmentData(1)
- self.curtain.FadeIn()
- self.NightEnable = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement