Beispiel #1
0
        private void UpdateMyBuffsListInternal()
        {
            System.Collections.ArrayList dirty_items = new System.Collections.ArrayList();

            for (int i = 0; i < listView_mybuffs_data.Items.Count; i++)
            {
                uint id = Util.GetUInt32(((ListViewItem)listView_mybuffs_data_items[i]).SubItems[3].Text);

                if (Globals.gamedata.mybuffs.ContainsKey(id))
                {
                    CharBuff cb = Util.GetBuff(id);

                    cb.InList = true;

                    if (cb.ExpiresTime == -1)
                    {
                        ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = "ON";
                    }
                    else
                    {
                        System.TimeSpan remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks);

                        //update it
                        //((ListViewItem)listView_npc_data_items[i]).SubItems[0].Text = Util.GetNPCName(npc.NPCID);
                        //((ListViewItem)listView_npc_data_items[i]).SubItems[1].Text = npc.Title;
                        ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = ((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString();
                        //((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = cb.ID.ToString();
                    }
                }
                else
                {
                    dirty_items.Add(i);
                }
            }

            //need to remove all dirty items now
            for (int i = dirty_items.Count - 1; i >= 0; i--)
            {
                listView_mybuffs_data_items.RemoveAt((int)dirty_items[i]);
            }
            dirty_items.Clear();

            foreach (CharBuff cb in Globals.gamedata.mybuffs.Values)
            {
                if (!cb.InList)
                {
                    cb.InList = true;

                    System.TimeSpan remain = new System.TimeSpan(0);
                    if (cb.ExpiresTime == -1)
                    {
                    }
                    else
                    {
                        remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks);
                    }

                    //add it
                    System.Windows.Forms.ListViewItem ObjListItem;
                    ObjListItem = new ListViewItem(Util.GetSkillName(cb.ID, cb.SkillLevel)); //Name
                    ObjListItem.SubItems.Add(cb.SkillLevel.ToString());                      //Title
                    if (cb.ExpiresTime == -1)
                    {
                        ObjListItem.SubItems.Add("ON");
                    }
                    else
                    {
                        ObjListItem.SubItems.Add(((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString()); //Remaining Time
                    }
                    ObjListItem.SubItems.Add(cb.ID.ToString());                                                            //ObjID
                    ObjListItem.ImageIndex = AddInfo.Get_Skill_Image_Index(cb.ID);

                    listView_mybuffs_data_items.Add(ObjListItem);
                }
            }
        }
Beispiel #2
0
        public static void UpdateBuff(ByteBuffer buff)
        {
            uint skill_id = buff.ReadUInt32();
            uint skill_level = buff.ReadUInt32(); // maybe it iwll fix it
            int skill_duration = buff.ReadInt32();

            Globals.MyBuffsListLock.EnterWriteLock();
            try
            {
                //need to see if the buff exists in our list...
                //if so, update the remaining time
                //otherwise, add the buff
                if (Globals.gamedata.mybuffs.ContainsKey(skill_id))
                {
                    CharBuff cb = (CharBuff)Globals.gamedata.mybuffs[skill_id];
                    cb.SkillLevel = skill_level;
                    if (skill_duration == -1)
                    {
                        //remove the buff
                        //Globals.gamedata.mybuffs.Remove(skill_id);


                        //toggle buff
                        cb.ExpiresTime = -1;
                        cb.EFFECT_TIME = -1;
                    }
                    else
                    {
                        cb.EFFECT_TIME = skill_duration;
                        cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                    }
                }
                else
                {
                    CharBuff cb = new CharBuff();
                    cb.ID = skill_id;
                    cb.SkillLevel = skill_level;
                    if (skill_duration == -1)
                    {
                        //toggle buff

                        cb.ExpiresTime = -1;
                        cb.EFFECT_TIME = -1;
                        Globals.gamedata.mybuffs.Add(cb.ID, cb);
                    }
                    else
                    {
                        cb.EFFECT_TIME = skill_duration;
                        cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                        Globals.gamedata.mybuffs.Add(cb.ID, cb);
                    }
                }
                if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
                {
                    SortedList _mybuff = new SortedList();
                    if (Globals.gamedata.mybuffs.Count > 0)
                    {
                        foreach (CharBuff _buff in Globals.gamedata.mybuffs.Values)
                        {
                            Script_ClassData cd = new Script_ClassData();
                            cd.Name = "EFFECT";
                            cd._Variables.Add("ID", new ScriptVariable((long)_buff.ID, "ID", Var_Types.INT, Var_State.PUBLIC));
                            cd._Variables.Add("LEVEL", new ScriptVariable((long)_buff.SkillLevel, "LEVEL", Var_Types.INT, Var_State.PUBLIC));
                            cd._Variables.Add("DURATION", new ScriptVariable((long)_buff.ExpiresTime, "DURATION", Var_Types.INT, Var_State.PUBLIC));
                            cd._Variables.Add("EFFECT_TIME", new ScriptVariable((long)_buff.EFFECT_TIME, "EFFECT_TIME", Var_Types.INT, Var_State.PUBLIC));
                            cd._Variables.Add("NAME", new ScriptVariable(Util.GetSkillName(_buff.ID, _buff.SkillLevel), "NAME", Var_Types.STRING, Var_State.PUBLIC));
                            ScriptVariable sv = new ScriptVariable(cd, "EFFECT", Var_Types.CLASS, Var_State.PUBLIC);
                            _mybuff.Add(_buff.ID.ToString(), sv);
                        }
                    }
                    ScriptEvent sc_ev = new ScriptEvent();
                    sc_ev.Type = EventType.CharEffect;
                    sc_ev.Variables.Add(new ScriptVariable(_mybuff, "EFFECTLIST", Var_Types.SORTEDLIST, Var_State.PUBLIC));
                    ScriptEngine.SendToEventQueue(sc_ev);
                }
            }
            finally
            {
                Globals.MyBuffsListLock.ExitWriteLock();
            }
        }
Beispiel #3
0
        public static void Add_PartyBuff(uint object_id, uint skill_id, int skill_duration, PartyMember ph)
        {
            // XXX: Not Thread Safe by itself
            try
            {
                if (Globals.gamedata.PartyMembers.ContainsKey(object_id))
                {
                    try
                    {
                        CharBuff cb = new CharBuff();
                        cb.ID = skill_id;
                        cb.SkillLevel = 1; // partyspelld doesnt give level, so set to 1 so we can lookup the name if needed
                        /*if (skill_duration == -1)
                        {
                            // slothmo: this is a delete for a buff we don't have...
                            // d00d: actually -1 == toggle buff, fix later
                        }
                        else
                        {*/
                            cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                            cb.EFFECT_TIME = skill_duration;
                            //v392B11: This hopefully fixes F4 packeterror
                            if (ph.my_buffs.ContainsKey(cb.ID))
                            {
                                ph.my_buffs[cb.ID] = cb;
                            }
                            else
                            {
                                ph.my_buffs.Add(cb.ID, cb);
                            }
                        //}
                    }
                    finally
                    {

                    }
                }
            }
            finally
            {
            }
        }
Beispiel #4
0
        public static void Add_Buff(ByteBuffer buff)
        {
            uint skill_id = buff.ReadUInt32();
            uint skill_level = buff.ReadUInt16();
            int skill_duration = buff.ReadInt32();

            //need to see if the buff exists in our list...
            //if so, update the remaining time
            //otherwise, add the buff
            if (Globals.gamedata.mybuffs.ContainsKey(skill_id))
            {
                CharBuff cb = (CharBuff)Globals.gamedata.mybuffs[skill_id];
                cb.SkillLevel = skill_level;
                if (skill_duration == -1)
                {
                    //remove the buff
                    //Globals.gamedata.mybuffs.Remove(skill_id);


                    // Toggle buff!
                    cb.ExpiresTime = -1;
                    cb.EFFECT_TIME = -1;
                }
                else
                {
                    cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                }
            }
            else
            {
                CharBuff cb = new CharBuff();
                cb.ID = skill_id;
                cb.SkillLevel = skill_level;
                if (skill_duration == -1)
                {
                    //toggle buff

                    cb.ExpiresTime = -1;
                    cb.EFFECT_TIME = -1;
                    Globals.gamedata.mybuffs.Add(cb.ID, cb);

                }
                else
                {
                    cb.EFFECT_TIME = skill_duration;
                    cb.ExpiresTime = System.DateTime.Now.AddSeconds(skill_duration).Ticks;
                    Globals.gamedata.mybuffs.Add(cb.ID, cb);
                }
            }
        }
Beispiel #5
0
        public static void Extargetbuffs(ByteBuffer buffe)
        {
            /*
             * FE E6 00 
                59 B0 21 48 // char id
                02 00 // buff count
	                01 2D 00 00 // buff id
	                01 00  //lvl
	                A3 01 00 00 //  ???
	                5D 03 00 00 //  real dur in sec 
	                59 B0 21 48 // id from char what put that buff

	                05 2D 00 00 // buff id
	                01 00 
	                A5 01 00 00 
	                62 03 00 00 
	                59 B0 21 48 
             * 
             */

                uint id = buffe.ReadUInt32(); // char id
                int buff_count = buffe.ReadInt16(); // buff count
                if (id > 0)
                {
                    TargetType type = Util.GetType(id);

                    switch (type)
                    {
                        case TargetType.PLAYER:
                            Globals.PlayerLock.EnterWriteLock();
                            try
                            {
                                Globals.PartyLock.EnterReadLock();
                                if (!Globals.gamedata.PartyMembers.ContainsKey(id))
                                {
                                    CharInfo player = Util.GetChar(id);
                                    if (player != null)
                                    {
                                        player.my_buffs.Clear();
                                        if (buff_count > 0)
                                        {

                                            for (int i = 0; i < buff_count; i++)
                                            {
                                                CharBuff _mybuff = new CharBuff();
                                                _mybuff.ID = buffe.ReadUInt32(); // skill id
                                                _mybuff.SkillLevel = (uint)buffe.ReadInt16(); // skill lvl
                                                buffe.ReadUInt32(); // xxx
                                                _mybuff.EFFECT_TIME = buffe.ReadInt32();
                                                _mybuff.ExpiresTime = System.DateTime.Now.AddSeconds(_mybuff.EFFECT_TIME).Ticks;
                                                buffe.ReadUInt32();
                                                if (player.my_buffs.ContainsKey(_mybuff.ID))
                                                {
                                                    player.my_buffs[_mybuff.ID] = _mybuff;
                                                }
                                                else
                                                {
                                                    player.my_buffs.Add(_mybuff.ID, _mybuff);
                                                }
                                                //clearing player buffs
                                            }
                                        }


                                    }
                                }
                            }
                            finally
                            {
                                Globals.PlayerLock.ExitWriteLock();
                                Globals.PartyLock.ExitReadLock();
                            }
                            break;
                        case TargetType.NPC:
                            Globals.NPCLock.EnterWriteLock();
                            try
                            {
                                NPCInfo npc = Util.GetNPC(id);
                                if (npc != null)
                                {

                                    if (npc.ID != Globals.gamedata.my_pet.ID &&
                                        npc.ID != Globals.gamedata.my_pet1.ID &&
                                        npc.ID != Globals.gamedata.my_pet2.ID &&
                                        npc.ID != Globals.gamedata.my_pet3.ID)
                                    {
                                        npc.my_buffs.Clear();
                                        if (buff_count > 0)
                                        {
                                            for (int i = 0; i < buff_count; i++)
                                            {
                                                CharBuff _mybuff = new CharBuff();
                                                _mybuff.ID = buffe.ReadUInt32(); // skill id
                                                _mybuff.SkillLevel = (uint)buffe.ReadInt16(); // skill lvl
                                                buffe.ReadUInt32(); // xxx
                                                _mybuff.EFFECT_TIME = buffe.ReadInt32();
                                                _mybuff.ExpiresTime = System.DateTime.Now.AddSeconds(_mybuff.EFFECT_TIME).Ticks;
                                                buffe.ReadUInt32();
                                                if (npc.my_buffs.ContainsKey(_mybuff.ID))
                                                {
                                                    npc.my_buffs[_mybuff.ID] = _mybuff;
                                                }
                                                else
                                                {
                                                    npc.my_buffs.Add(_mybuff.ID, _mybuff);
                                                }
                                                //clearing player buffs
                                            }
                                        }
                                    }


                                    //
                                }
                            }//unlock
                            finally
                            {
                                Globals.NPCLock.ExitWriteLock();
                            }
                            break;

                    } // switch end
                } // if id > 0
                
        }