Jump to content

Multiple Environment System


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hellow,

 

I want to share my work, I've created 2 year ago, for my old server (Resthea).

 

So, what is it exacly?

 

It's python libraries and code that allow us to have many environment (clouds, light settings, flare and so on) on one map.

 

By default, you can have only one environment for each map.

 

How does it work?

 

Well, once every 30 seconds (you can configure that time) checks our coordinates and compare it to jpg file, which size is the same as map size. Diffrent colors mean diffrent msenv file.

 

What this pack contains?

 

  • possibility to add up to 16777215 areas with diffrent environment on every map.
  • possibility to add diffrent music on these areas
  • possibility to add random snow on these areas
  • 28 ready skyboxes
  • possibility to choose skyboxes quality
  • possibility to configure the time script refreshes
  • possibility to add special xmas configuration
  • easy configuration via text file
  • code is easy to modify
  • bugfix for night and snow systems

 

Disadvantages:

 

  • not so optimal solution
  • .jpg format has indirect coloring between two colors, which sometimes could lead to problems
  • xmas song probably doesn't work (I haven't got time to fix it)
  • lots of redundant libraries, because i've uploaded whole Lib folder
  • descriptions how to add this are in polish, you can use google translate :P , if you wish i can translate it too.

 

Code sample:

    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
        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:
            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"
            if ConfigSkybox in ("_512n","_1kn","_1.5kn"):
                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
        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
        else:
            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 : ("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]
                if NightEnable == 1 and self.__IsXMasMap():
                    background.RegisterEnvironmentData(1, constInfo.ENVIRONMENT_NIGHT)
                    background.SetEnvironmentData(1)
                else:
                    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

Old video with system:

 

https://www.youtube.com/watch?v=sz1njy6sBqQ

 

Download:

 

Without skyboxes:

https://www.mediafire.com/?edtdz50gc4tzmqj

With skyboxes:

https://www.mediafire.com/?y14v0yir24tqbvv
  • Metin2 Dev 22
  • Eyes 1
  • Good 11
  • Love 1
  • Love 30
Link to comment
Share on other sites

  • 4 months later...
  • 4 years later...

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 3

      [Discussion] Rain - The First Person that leaked the M2 Files

    2. 0

      [Client] All tabs opening after quest/npc talk or even shop // PORTS

    3. 0

      Arrow does not hide at warp

    4. 0

      Problem with sidebar by vegas

    5. 58

      Discord Rich Presence

    6. 145

      Full Costume Mount System

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.