Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public GraalLevelNPC(CSocket Server, GraalLevel Level, int Id)
     : base(ScriptType.LEVELNPC)
 {
     this.Server = Server;
     this.Level = Level;
     this.Id = Id;
     this.Save = new SaveIndex(this, 10);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// FindLevel
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public GraalLevel FindLevel(String Name)
        {
            GraalLevel Level = null;

            if (!LevelList.TryGetValue(Name, out Level))
            {
                Level = new GraalLevel(Name, new object());

                //lock (TimerLock)
                //{
                LevelList[Name] = Level;
                //}

            }

            return Level;
        }
Ejemplo n.º 3
0
        /*
        blockPositionUpdates(false),
        levelNPC(pLevelNPC),
        x(pX), y(pY), hurtX(32.0f), hurtY(32.0f),
        x2((int)(pX*16)), y2((int)(pY*16)),
        gmaplevelx(0), gmaplevely(0),
        id(0), rupees(0),
        darts(0), bombs(0), glovePower(0), bombPower(0), swordPower(0), shieldPower(0),
        visFlags(1), blockFlags(0), sprite(2), power(0), ap(50),
        image(pImage), gani("idle"),
        level(pLevel), server(pServer)*/
        //static CString toWeaponName(CString code);
        //static CString doJoins(CString code, CFileSystem* fs);
        public TNPC(GraalLevel level, uint Id)
            : base(ScriptType.LEVELNPC)
        {
            /*
            memset((void*)colors, 0, sizeof(colors));
            memset((void*)saves, 0, sizeof(saves));
            memset((void*)modTime, 0, sizeof(modTime));
            */
            // bowImage for pre-2.x clients.
            bowImage = new CString() + (char)0;
            this.server = null;
            this.level = level;
            this.id = Id;
            //this.saves = new SaveIndex (this, 10);
            // imagePart needs to be Graal-packed.
            for (int i = 0; i < 6; i++)
                imagePart.writeGChar(0);

            // Set the gmap levels.
            /*
            GraalMap gmap = level.getMap();
            if (gmap && gmap->getType() == MAPTYPE_GMAP)
            {
            gmaplevelx = (uchar)gmap->getLevelX(level->getLevelName());
            gmaplevely = (uchar)gmap->getLevelY(level->getLevelName());
            }
            *
            // We need to alter the modTime of the following props as they should be always sent.
            // If we don't, they won't be sent until the prop gets modified.
            modTime[NPCPROP.IMAGE] = modTime[NPCPROP.SCRIPT] = modTime[NPCPROP.X] = modTime[NPCPROP.Y]
            = modTime[NPCPROP.VISFLAGS] = modTime[NPCPROP.ID] = modTime[NPCPROP.SPRITE] = modTime[NPCPROP.MESSAGE]
            = modTime[NPCPROP.GMAPLEVELX] = modTime[NPCPROP.GMAPLEVELY]
            = modTime[NPCPROP.X2] = modTime[NPCPROP.Y2] = time(0);

            bool levelModificationNPCHack = false;

            // See if the NPC sets the level as a sparring zone.
            if (pScript.subString(0, 12) == "sparringzone")
            {
            pLevel->setSparringZone(true);
            levelModificationNPCHack = true;
            }

            // See if the NPC sets the level as singleplayer.
            if (pScript.subString(0, 12) == "singleplayer")
            {
            pLevel->setSingleplayer(true);
            levelModificationNPCHack = true;
            }

            // Separate clientside and serverside scripts.
            if (server->hasNPCServer())
            {
            if (levelModificationNPCHack)
            serverScript = clientScript = pScript;
            else
            {
            CString s = pScript;
            serverScript = s.readString("//#CLIENTSIDE");
            clientScript = s.readString("");
            }
            }
            else clientScript = pScript;

            // Do joins.
            if (!serverScript.isEmpty()) serverScript = doJoins(serverScript, server->getFileSystem());
            if (!clientScript.isEmpty()) clientScript = doJoins(clientScript, server->getFileSystem());

            // See if the NPC should block position updates from the level leader.
            if (server->hasNPCServer())
            {
            if (serverScript.find("//#BLOCKPOSITIONUPDATES") != -1)
            blockPositionUpdates = true;
            }
            else
            {
            if (clientScript.find("//#BLOCKPOSITIONUPDATES") != -1)
            blockPositionUpdates = true;
            }

            // Remove comments and trim the code if specified.
            if (trimCode)
            {
            if (!serverScript.isEmpty())
            {
            serverScriptFormatted = removeComments(serverScript, "\xa7");
            std::vector<CString> code = serverScriptFormatted.tokenize("\xa7");
            serverScriptFormatted.clear();
            for (List<CString>::iterator i = code.begin(); i != code.end(); ++i)
                serverScriptFormatted + (*i).trim() + "\xa7";
            }
            if (!clientScript.isEmpty())
            {
            clientScriptFormatted = removeComments(clientScript, "\xa7");
            std::vector<CString> code = clientScriptFormatted.tokenize("\xa7");
            clientScriptFormatted.clear();
            for (std::vector<CString>::iterator i = code.begin(); i != code.end(); ++i)
                clientScriptFormatted + (*i).trim() + "\xa7";
            }
            }

            // Search for toweapons in the clientside code and extract the name of the weapon.
            weaponName = toWeaponName(clientScript);

            // Just a little warning for people who don't know.
            if (clientScriptFormatted.Length > 0x705F)
            printf("WARNING: Clientside script of NPC (%s) exceeds the limit of 28767 bytes.\n", (weaponName.Length != 0 ? weaponName.text() : image.text()));
            */
            // TODO: Create plugin hook so NPCServer can acquire/format code.
        }