Advertisement
Guest User

Untitled

a guest
Mar 25th, 2015
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 14.09 KB | None | 0 0
  1. 1. At the top add:
  2.  
  3. import time
  4. import sys
  5. import Image
  6. import linecache
  7.  
  8.  
  9.  
  10.  
  11. 2. After "self.pressNumber = None" add:
  12.  
  13.         self.Env = 0
  14.         self.Resthea = "0"
  15.         self.SnowEnable = 0
  16.         self.NightEnable = 0
  17.         self.ConfigTime = 0
  18.         self.XmasEvent = -1
  19.         self.ConfigSkybox = "0"
  20.  
  21.  
  22.  
  23.  
  24. 3. After "net.SendEnterGamePacket()" add (modify it up to your maps):
  25.  
  26.         ### START OF LOGIN ENVIRONMENT MODULE Resthea.eu, qentinios
  27.         czass = str(time.ctime())
  28.         sekundy = czass[17:19]
  29.         bg = background.GetCurrentMapName()
  30.         """Here you set on which maps changing environment will work."""
  31.         map = ( "metin2_map_4_wiatry",
  32.                 "metin2_map_krance_swiata",
  33.                 "metin2_map_srodziemie",
  34.                 "metin2_map_resthea", )
  35.  
  36.         if bg in map:
  37.             godziny = czass[11:13]
  38.             minuty = czass[14:16]
  39.             czas = int(godziny + minuty)
  40.  
  41.             try:
  42.                 """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)"""
  43.                 im = Image.open("msenv/" + bg + ".jpg")
  44.             except:
  45.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  46.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: " + "msenv/" + bg + ".jpg")
  47.                 return
  48.  
  49.             (x, y, z) = player.GetMainCharacterPosition()
  50.             x = int(x/100)
  51.             y = int(y/100)
  52.  
  53.             try:
  54.                 color = str(im.getpixel((int(x),int(y))))
  55.             except:
  56.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  57.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Not exist pixel: " + str(x) + ", " + str(y) + "; " + "msenv/" + bg + ".jpg")
  58.                 return
  59.                
  60.             #Skybox config
  61.             try:
  62.                 ConfigSkybox = linecache.getline("config.cfg", 5)
  63.  
  64.             except:
  65.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  66.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: config.cfg")
  67.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Using medium quality skybox")
  68.                 ConfigSkybox = "_1k"
  69.                
  70.             """Skybox quality is set in config.cfg ( 512, 1024, 1536px )"""
  71.             if ConfigSkybox in ("_512\n","_1k\n","_1.5k\n"):
  72.                 ConfigSkybox = ConfigSkybox[:-1]
  73.  
  74.             if ConfigSkybox not in ("_512","_1k","_1.5k"):
  75.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  76.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Wrong data: " + ConfigSkybox + ", config.cfg, line 5")
  77.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Using medium quality skybox")
  78.                 ConfigSkybox = "_1k"
  79.             #End of skybox config
  80.            
  81.             #Xmas event
  82.             try:
  83.                 XmasEvent = int(linecache.getline("config.cfg", 8))
  84.  
  85.             except:
  86.                 XmasEvent = 0
  87.            
  88.             """Special config for xmas"""
  89.             if XmasEvent == 1:
  90.                 ColorList={
  91.                     #Color (RGB)
  92.                     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)"),
  93.                     #Msenv
  94.                     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"),
  95.                     #Mp3
  96.                     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")
  97.                 }
  98.             #End of Xmas event
  99.             """Normal configuration"""
  100.             else:
  101.                 ColorList={
  102.                     """1 - color in RGB for which we set environment,
  103.                        2 - msenv filename  in d:/ymir work/environment/ directory,
  104.                        3 - mp3 filename in BGM directory, which will be played on this area"""
  105.                     #Color (RGB)
  106.                     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)"),
  107.                     #Msenv
  108.                     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"),
  109.                     #Mp3
  110.                     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")
  111.                 }
  112.             i = 0
  113.             Colors = ColorList[1]
  114.             length = len(Colors)
  115.             for ColorItem in xrange(length):
  116.                 if color == Colors[ColorItem]:
  117.  
  118.                     Msenv = ColorList[2]
  119.                     Music = ColorList[3]
  120.  
  121.  
  122.                     """Msenv files must be named according to this template (map_name + { _512 lub _1k lub 15k } + .msenv) """
  123.                     background.RegisterEnvironmentData(1, "d:/ymir work/environment/" + Msenv[ColorItem] + ConfigSkybox + ".msenv")
  124.                     background.SetEnvironmentData(1)
  125.  
  126.                     if app.IsExistFile("BGM/" + Music[ColorItem] + ".mp3")==1:
  127.                         if musicInfo.fieldMusic != "":
  128.                             snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  129.                         musicInfo.fieldMusic = (Music[ColorItem] + ".mp3")
  130.                         snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  131.                     else:
  132.                         if musicInfo.fieldMusic != "":
  133.                             snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  134.                         musicInfo.fieldMusic=musicInfo.METIN2THEMA
  135.                         snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  136.                     snd.SetMusicVolume(systemSetting.GetMusicVolume()*0.5)
  137.                     break
  138.  
  139.                 else:
  140.                     i = i+1
  141.  
  142.             if i == length:
  143.                 background.SetEnvironmentData(0)
  144.                 snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  145.                 musicInfo.fieldMusic=musicInfo.METIN2THEMA
  146.                 snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  147.         ### END OF LOGIN ENVIRONMENT MODULE Resthea.eu, qentinios
  148.  
  149.  
  150.  
  151.  
  152. 4. After "self.interface.BUILD_OnUpdate()" add:
  153.  
  154.         self.__SpecialEnvironmentEnable(self.Env, self.Resthea, self.SnowEnable, self.NightEnable, self.ConfigTime, self.ConfigSkybox, self.XmasEvent)
  155.  
  156.  
  157.  
  158.  
  159. 5. After "__SpecialEnvironmentEnable" add whole function (modify it up to your maps):
  160.  
  161.     def __SpecialEnvironmentEnable(self, Env, Resthea, SnowEnable, NightEnable, ConfigTime, ConfigSkybox, XmasEvent):
  162.         ### START OF ENVIRONMENT MODULE Resthea.eu, qentinios
  163.         self.Env = Env
  164.         self.Resthea = Resthea
  165.         self.SnowEnable = SnowEnable
  166.         self.NightEnable = NightEnable
  167.         self.ConfigTime = ConfigTime
  168.         self.ConfigSkybox = ConfigSkybox
  169.         self.XmasEvent = XmasEvent
  170.         czass = str(time.ctime())
  171.         sekundy = czass[17:19]
  172.         bg = background.GetCurrentMapName()
  173.  
  174.         if ConfigTime == 0:
  175.             try:
  176.                 ConfigTime = int(linecache.getline("config.cfg", 2))
  177.             except:
  178.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  179.                 chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: config.cfg")
  180.  
  181.         if ConfigTime == -1:
  182.             return
  183.  
  184.         """Here you set on which maps changing environment will work."""
  185.         map = ( "metin2_map_4_wiatry",
  186.                 "metin2_map_krance_swiata",
  187.                 "metin2_map_srodziemie",
  188.                 "metin2_map_resthea", )
  189.  
  190.         if bg in map and sekundy != Env:
  191.             if ConfigTime == 5 and int(sekundy) in (5,10,15,20,25,30,35,40,45,50,55,00):
  192.                 self.Env = sekundy
  193.                 pass
  194.             elif ConfigTime == 15 and int(sekundy) in (15,30,45,00):
  195.                 self.Env = sekundy
  196.                 pass
  197.             elif ConfigTime == 30 and int(sekundy) in (30,00):
  198.                 self.Env = sekundy
  199.                 pass
  200.             elif ConfigTime == 60 and int(sekundy) == 30:
  201.                 pass
  202.             else:
  203.                 if ConfigTime not in (-1,5,15,30,60) and int(sekundy) == 30:
  204.                     chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  205.                     chat.AppendChat(chat.CHAT_TYPE_INFO, "Wrong data: " + ConfigTime + ", config.cfg, line 2")
  206.                     self.Env = sekundy
  207.                 return
  208.         else:
  209.             return
  210.  
  211.         minuty = czass[14:16]
  212.         godziny = czass[11:13]
  213.         czas = int(godziny + minuty)
  214.  
  215.         try:
  216.             """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)"""
  217.             im = Image.open("msenv/" + bg + ".jpg")
  218.         except:
  219.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  220.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Cannot open file: " + "msenv/" + bg + ".jpg")
  221.             return
  222.  
  223.         (x, y, z) = player.GetMainCharacterPosition()
  224.         x = int(x/100)
  225.         y = int(y/100)
  226.  
  227.         try:
  228.             color = str(im.getpixel((int(x),int(y))))
  229.         except:
  230.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Error while changing environment")
  231.             chat.AppendChat(chat.CHAT_TYPE_INFO, "Not exist pixel: " + str(x) + ", " + str(y) + "; " + "msenv/" + bg + ".jpg")
  232.             return
  233.  
  234.         #Skybox config
  235.         if ConfigSkybox == "0":
  236.             try:
  237.                 ConfigSkybox = linecache.getline("config.cfg", 5)
  238.  
  239.             except:
  240.                 ConfigSkybox = "_1k"
  241.                
  242.             """Skybox quality is set in config.cfg ( 512, 1024, 1536px )"""
  243.             if ConfigSkybox in ("_512\n","_1k\n","_1.5k\n"):
  244.                 ConfigSkybox = ConfigSkybox[:-1]
  245.  
  246.             if ConfigSkybox not in ("_512","_1k","_1.5k"):
  247.                 ConfigSkybox = "_1k"
  248.         #End of skybox config
  249.        
  250.         #Xmas event
  251.         if XmasEvent == -1:
  252.             try:
  253.                 XmasEvent = int(linecache.getline("config.cfg", 8))
  254.  
  255.             except:
  256.                 XmasEvent = 0
  257.  
  258.         """Special config for xmas"""
  259.         if XmasEvent == 1:
  260.             ColorList={
  261.                 #Color (RGB)
  262.                 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)"),
  263.                 #Msenv
  264.                 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"),
  265.                 #Mp3
  266.                 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"),
  267.                 #Snow
  268.                 4 : (1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1)
  269.                 }
  270.         #End of Xmas event
  271.             """Normal configuration"""
  272.         else:
  273.             ColorList={
  274.                 """1 - color in RGB for which we set environment,
  275.                    2 - msenv filename  in d:/ymir work/environment/ directory,
  276.                    3 - mp3 filename in BGM directory, which will be played on this area
  277.                    4 - 1 - enable random snow, 0 - disable"""
  278.                 #Color (RGB)
  279.                 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)"),
  280.                 #Msenv
  281.                 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"),
  282.                 #Mp3
  283.                 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"),
  284.                 #Snow
  285.                 4 : (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0)
  286.                 }
  287.         i = 0
  288.         Colors = ColorList[1]
  289.         length = len(Colors)
  290.         for ColorItem in xrange(length):
  291.             if color == Colors[ColorItem]:
  292.                 #START OF SNOW EFFECT
  293.                 Snow = ColorList[4]
  294.                 if SnowEnable != 1:
  295.                     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):
  296.                         random = app.GetRandom(1,3)
  297.                         if random == 1:
  298.                             background.EnableSnow(1)
  299.                         else:
  300.                             background.EnableSnow(0)
  301.  
  302.                     if Snow[ColorItem] == 0:
  303.                             background.EnableSnow(0)
  304.                 #END OF SNOW EFFECT
  305.  
  306.                 if Resthea == color:
  307.                     break
  308.  
  309.                 #START OF MUSIC MODULE
  310.                 Music = ColorList[3]
  311.                 if app.IsExistFile("BGM/" + Music[ColorItem] + ".mp3")==1:
  312.                     if musicInfo.fieldMusic != "":
  313.                         snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  314.                     musicInfo.fieldMusic = (Music[ColorItem] + ".mp3")
  315.                     snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  316.                 else:
  317.                     if musicInfo.fieldMusic != "":
  318.                         snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  319.                     musicInfo.fieldMusic=musicInfo.METIN2THEMA
  320.                     snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  321.                 #END OF MUSIC MODULE
  322.  
  323.                 Msenv = ColorList[2]
  324.  
  325.                 """Bugfix for night (/x 1)"""
  326.                 if NightEnable == 1 and self.__IsXMasMap():
  327.                     background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  328.                     background.SetEnvironmentData(1)
  329.                 else:
  330.                     """Msenv files must be named according to this template (map_name + { _512 lub _1k lub 15k } + .msenv) """
  331.                     background.RegisterEnvironmentData(1, "d:/ymir work/environment/" + Msenv[ColorItem] + ConfigSkybox + ".msenv")
  332.                     background.SetEnvironmentData(1)
  333.                
  334.                 self.Resthea = color
  335.  
  336.                 break
  337.  
  338.             else:
  339.                 i = i+1
  340.  
  341.         if i == length:
  342.             background.SetEnvironmentData(0)
  343.             snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
  344.             musicInfo.fieldMusic=musicInfo.METIN2THEMA
  345.             snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
  346.             self.Resthea = color
  347.     ### END OF ENVIRONMENT MODULE Resthea.eu, qentinios
  348.  
  349.  
  350.  
  351.  
  352. 6. Replace (whole!) function "__XMasSnow_Enable":
  353.  
  354.     def __XMasSnow_Enable(self, mode):
  355.  
  356.         self.__XMasSong_Enable(mode)
  357.  
  358.         if "1"==mode:
  359.  
  360.             if not self.__IsXMasMap():
  361.                 return
  362.  
  363.             print "XMAS_SNOW ON"
  364.             background.EnableSnow(1)
  365.             self.SnowEnable = 1
  366.  
  367.         else:
  368.             print "XMAS_SNOW OFF"
  369.             background.EnableSnow(0)
  370.             self.SnowEnable = 0
  371.  
  372.  
  373.  
  374.  
  375. 7. Replace (whole!) function "__DayMode_OnCompleteChangeToLight":
  376.  
  377.     def __DayMode_OnCompleteChangeToLight(self):
  378.         background.SetEnvironmentData(0)
  379.         self.curtain.FadeIn()
  380.         self.NightEnable = 0
  381.  
  382.  
  383.  
  384.  
  385. 8. Replace (whole!) function "__DayMode_OnCompleteChangeToDark":
  386.  
  387.     def __DayMode_OnCompleteChangeToDark(self):
  388.         background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
  389.         background.SetEnvironmentData(1)
  390.         self.curtain.FadeIn()
  391.         self.NightEnable = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement