public GraalPlayer(Int16 Id, CSocket socket)
 {
     this.Id = Id;
     this._colorManager = new ColorManager(new ColorManager.dSendColors(SendColors));
     this._flagManager = new FlagManager(new FlagManager.dSendFlag(SendFlag));
     this.Server = socket;
 }
 /// <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);
 }
        /// <summary>
        /// Add Player to Playerlist (or return player)
        /// </summary>
        public virtual GraalPlayer AddPlayer(Int16 Id, CSocket socket)
        {
            GraalPlayer pl = FindPlayer(Id);
            if (pl == null)
            {
                GraalPlayer Player = new GraalPlayer(Id, socket);
                PlayerList[Id] = Player;
                return Player;
            }

            return pl;
        }
示例#4
0
		/// <summary>
		/// Gets a npc from the level with the specified level id.
		/// </summary>
		public GraalLevelNPC GetNPC(CSocket socket, int Id)
		{
			GraalLevelNPC npc = null;
			if (!NpcList.TryGetValue(Id, out npc))
			{
				npc = new GraalLevelNPC(socket, this, Id);
				lock (this.TimerLock)
				{
					NpcList[Id] = npc;
				}
			}
			return npc;
		}
示例#5
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ServerWeapon(CSocket Server, String WeaponName, String WeaponImage, String WeaponScript)
     : base(ScriptType.WEAPON)
 {
     this.Server = Server;
     this.UpdateWeapon(WeaponName, WeaponImage, WeaponScript);
 }
示例#6
0
 public ScriptWeapon(CSocket socket, IRefObject Ref)
     : base(socket)
 {
     this.Ref = (ServerWeapon)Ref;
 }
示例#7
0
        /// <summary>
        /// Set Weapon Data (and compile+exec)
        /// </summary>
        public int SetWeapon(CSocket Server, String WeaponName, String WeaponImage, String WeaponCode, bool SendToGS)
        {
            // Set Weapon Data
            int Status = 0;
            ServerWeapon Weapon = null;
            if (WeaponList.TryGetValue (WeaponName, out Weapon)) {
                Weapon.UpdateWeapon (WeaponName, WeaponImage, WeaponCode);
                Status = 1;
            } else {
                Weapon = new ServerWeapon (Server, WeaponName, WeaponImage, WeaponCode);
                WeaponList [WeaponName] = Weapon;
            }

            // Valid Weapon?
            if (Weapon != null) {
                // Send to GServer
                if (SendToGS) {
                    this.SendGSPacket (new CString () + (byte)GServerConnection.PacketOut.NCQUERY + (byte)GServerConnection.NCREQ.WEAPONADD + (byte)WeaponName.Length + WeaponName + (byte)WeaponImage.Length + WeaponImage + WeaponCode);
                    Compiler.CompileAdd (Weapon);
                    /*
                    CString output = new CString();
                    output += new CString() + (byte)33 + (byte)WeaponName.Length + WeaponName
                        + (byte)0 + (byte)WeaponImage.Length + WeaponImage
                        + (byte)74 + (short)0 + "\n";

                    CString header = new CString()+"weapon";

                    // Get the mod time and send packet 197.
                    CString smod = new CString() + (long)123123;
                    smod.Tokenize();
                    output += new CString() + (byte)197 + header + "," + smod + "\n";

                    //System.IO.StreamReader sr = new System.IO.StreamReader(WeaponName.Replace("-","weapon").Replace("*","weapon")+"_ClientSide.dll");
                    CString b = new CString() + "lol";
                    //sr.Close();
                    //sr.Dispose();

                    // Add to the output stream.
                    output += new CString() + (byte)100 + (int)b.Length + "\n";
                    output += new CString() + b;

                    foreach (GraalPlayer pl in this.PlayerManager)
                    {
                        if (pl.FindWeapon(WeaponName) != null)
                        {
                            this.SendGSPacket(new CString() + (byte)GServerConnection.PacketOut.NCQUERY + (byte)GServerConnection.NCREQ.FORWARDTOPLAYER + (short)pl.Id + output);
                            Console.WriteLine(output);
                        }
                    }
                    */
                }
            }

            // Added or Updated?
            return Status;
        }
示例#8
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.
        }
示例#9
0
 public ScriptObj(CSocket Server)
 {
     this.Server = Server;
 }
 public ScriptLevelNpc(CSocket socket, IRefObject Ref)
     : base(socket)
 {
     this.Ref = (GraalLevelNPC)Ref;
     this.Server = this.Ref.Server;
 }