GetEffectSlot for Chamber blahhh

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

GetEffectSlot for Chamber blahhh

Postby Yemla » Fri Aug 20, 2010 4:20 am

Method Used...
Code: Select all
      public static int GetEffectSlot(string spellName)
      {
         switch(spellName)
         {
            case "Chamber of Minor Fate":
               return 1;
            case "Chamber of Restraint":
               return 2;
            case "Chamber of Destruction":
               return 3;
            case "Chamber of Fate":
               return 4;
            case "Chamber of Greater Fate":
               return 5;
         }

         return 0;
      }

Handled in GamePlayer -> CastSpell
Code: Select all
                     ((ChamberSpellHandler)spellhandler).EffectSlot = ChamberSpellHandler.GetEffectSlot(spellhandler.Spell.Name));


New Possible Method considering you get 6chambers total but only possible 5 to have up with split/tri spec....
Code: Select all
        private int chamberCheck = 0;
      public override void FinishSpellCast(GameLiving target)
      {
         m_caster.Mana -= PowerCost(target);
         
         // endurance
         m_caster.Endurance -= 5;

         // messages
            GamePlayer caster = (GamePlayer)m_caster;
         if (Spell.InstrumentRequirement == 0)
         {
            if(SecondarySpell == null && PrimarySpell == null)
            {
               MessageToCaster("No spells were loaded into " + m_spell.Name + ".", eChatType.CT_Spell);
            }
            else
            {
                    switch (chamberCheck)
                    {
                        case 0:
                            chamberCheck++;
                            this.EffectSlot = 1;
                            return;
                        case 1:
                            chamberCheck++;
                            this.EffectSlot = 2;
                            return;
                        case 2:
                            chamberCheck++;
                            this.EffectSlot = 3;
                            return;
                        case 3:
                            chamberCheck++;
                            this.EffectSlot = 4;
                            return;
                        case 4:
                            chamberCheck++;
                            this.EffectSlot = 5;
                            return;
                    }
               MessageToCaster("Your " + m_spell.Name + " is ready for use.", eChatType.CT_Spell);
               //StartSpell(target); // and action
               GameSpellEffect neweffect = CreateSpellEffect(target, 1);
               neweffect.Start(m_caster);
               SendEffectAnimation(m_caster, 0, false, 1);
               ((GamePlayer)m_caster).Out.SendWarlockChamberEffect((GamePlayer)m_caster);
            }
            
            foreach (GamePlayer player in m_caster.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
            {
               if (player != m_caster)
                  player.Out.SendMessage(m_caster.GetName(0, true) + " casts a spell!", eChatType.CT_Spell, eChatLoc.CL_SystemWindow);
            }
         }

         //the quick cast is unallowed whenever you miss the spell
         //set the time when casting to can not quickcast during a minimum time
         if (m_caster is GamePlayer)
         {
            QuickCastEffect quickcast = (QuickCastEffect) m_caster.EffectList.GetOfType(typeof (QuickCastEffect));
            if (quickcast != null && Spell.CastTime > 0)
            {
               ((GamePlayer) m_caster).TempProperties.setProperty(GamePlayer.QUICK_CAST_CHANGE_TICK, m_caster.CurrentRegion.Time);
               ((GamePlayer) m_caster).DisableSkill(SkillBase.GetAbility(Abilities.Quickcast), QuickCastAbilityHandler.DISABLE_DURATION);
               quickcast.Cancel(false);
            }
         }
      }
      public override int OnEffectExpires(GameSpellEffect effect, bool noMessages)
      {
            chamberCheck--;
         ((GamePlayer)m_caster).Out.SendWarlockChamberEffect((GamePlayer)effect.Owner);
         return base.OnEffectExpires (effect, noMessages);
      }
Yemla
Contributor
 
Posts: 215
Joined: Sat Feb 02, 2008 3:21 am
Website: http://www.facebook.com/J.D.Snelling
Location: California

Re: GetEffectSlot for Chamber blahhh

Postby Graveen » Fri Aug 20, 2010 6:48 am

Hi Yemla,

You want to remove all GamePlayer stuff and move it in spellhandler, or i miss the point?
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: GetEffectSlot for Chamber blahhh

Postby Yemla » Fri Aug 20, 2010 11:23 am

nooo and yes lol...geteffectslot is just a hardcoded way in gameplayer -> castspell to get chamberspellhandler.effectslot basically in gameplayer it would find the effectslot by spell.name....my new method cuts through all that using aprivate int (chamberCheck)

basically on spell finishcast where the chamber is success and is created, i did a switch statement of chamberCheck basical 0 is this.EffetSLot = 1; chamberCheck++;

and oneffectexpire (when chamber is removed thru w.e matter) chamberEffect--;
Yemla
Contributor
 
Posts: 215
Joined: Sat Feb 02, 2008 3:21 am
Website: http://www.facebook.com/J.D.Snelling
Location: California

Re: GetEffectSlot for Chamber blahhh

Postby Graveen » Fri Aug 20, 2010 12:53 pm

the more GamePlayer 'll avoid this code (ie with tempproperties or w/e), the more i'd be glad you commit it :)
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: GetEffectSlot for Chamber blahhh

Postby Yemla » Sun Aug 22, 2010 10:58 am

idk exactly how to convert these checks into a temp-property...


EDITTED: what about this being as the FinishedSpellCast part this removes any ints, temp properties ect. or checks for expireeffect

Code: Select all
            GamePlayer caster = (GamePlayer)m_caster;
            foreach (ChamberSpellHandler chamberHandler in caster.EffectList.GetAllOfType(typeof(GameSpellEffect)))
            {
                if (chamberHandler == null)
                    this.EffectSlot = 1;
                if (chamberHandler != null && chamberHandler.EffectSlot != null)
                {
                    if (chamberHandler.EffectSlot != 1)
                        this.EffectSlot = 1;
                    else if (chamberHandler.EffectSlot == 1 && chamberHandler.EffectSlot != 2)
                        this.EffectSlot = 2;
                    else if (chamberHandler.EffectSlot == 1 && chamberHandler.EffectSlot == 2 &&
                        chamberHandler.EffectSlot != 3)
                        this.EffectSlot = 3;
                    else if (chamberHandler.EffectSlot == 1 && chamberHandler.EffectSlot == 2 &&
                        chamberHandler.EffectSlot == 3 && chamberHandler.EffectSlot != 4)
                        this.EffectSlot = 4;
                    else if (chamberHandler.EffectSlot == 1 && chamberHandler.EffectSlot == 2 &&
                        chamberHandler.EffectSlot == 3 && chamberHandler.EffectSlot == 4 &&
                        chamberHandler.EffectSlot != 5)
                        this.EffectSlot = 5;
                }
            }


basically it checks the chambers you have and the effectslots where to put it ect. so if say you have 5chambers and you cast Chamber 4 (a.k you lose Effectslot 4) on recreations it automatically puts it as effectslot 4 cause 1-3 are in use and doesn't even check 5 because 4 isn't in use at the time, x}?

could there be any problems with 1chamber having effectslot 1 and it checking that chamber for effectslot 2? im not 100% sure on this method but its a area were the check should be
Yemla
Contributor
 
Posts: 215
Joined: Sat Feb 02, 2008 3:21 am
Website: http://www.facebook.com/J.D.Snelling
Location: California

Re: GetEffectSlot for Chamber blahhh

Postby stephenxpimentel » Sun Aug 22, 2010 9:22 pm

the first is to set the property, the second is to get the property and use its value. :)
Code: Select all
Caster.TempProperties.setProperty("CHAMBER_EFFECT_SLOT", effect slot);//byte value
Caster.TempProperties.getProperty<byte>("CHAMBER_EFFECT_SLOT");



the only reason i changed it from int to byte is int is simply too large. :)
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: GetEffectSlot for Chamber blahhh

Postby Yemla » Mon Sep 06, 2010 6:37 pm

FinishSpellCast
Code: Select all
if (chamber == null)
                    {
                        this.EffectSlot = 1;
                        effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_1, Spell.Name);
                    }
                    else if (chamber != null)
                    {
                        if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_1) == null)
                        {
                            this.EffectSlot = 1;
                            effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_1, Spell.Name);
                        }
                        else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_2) == null)
                        {
                            this.EffectSlot = 2;
                            effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_2, Spell.Name);
                        }
                        else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_3) == null)
                        {
                            this.EffectSlot = 3;
                            effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_3, Spell.Name);
                        }
                        else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_4) == null)
                        {
                            this.EffectSlot = 4;
                            effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_4, Spell.Name);
                        }
                        else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_5) == null)
                        {
                            this.EffectSlot = 5;
                            effect.Owner.TempProperties.setProperty(EFFECT_CHAMBER_5, Spell.Name);
                        }


OnEffectExpires
Code: Select all
if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_1).Contains(effect.Spell.Name))
            {
                effect.Owner.TempProperties.removeProperty(EFFECT_CHAMBER_1);
            }
            else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_2).Contains(effect.Spell.Name))
            {
                effect.Owner.TempProperties.removeProperty(EFFECT_CHAMBER_2);
            }
            else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_3).Contains(effect.Spell.Name))
            {
                effect.Owner.TempProperties.removeProperty(EFFECT_CHAMBER_3);
            }
            else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_4).Contains(effect.Spell.Name))
            {
                effect.Owner.TempProperties.removeProperty(EFFECT_CHAMBER_4);
            }
            else if (effect.Owner.TempProperties.getProperty<string>(EFFECT_CHAMBER_5).Contains(effect.Spell.Name))
            {
                effect.Owner.TempProperties.removeProperty(EFFECT_CHAMBER_5);
            }


I believe you can use Contains or Equal <shrug>....anyway, again opinions (will test soon) blahblahblah<3...
Yemla
Contributor
 
Posts: 215
Joined: Sat Feb 02, 2008 3:21 am
Website: http://www.facebook.com/J.D.Snelling
Location: California

Re: GetEffectSlot for Chamber blahhh

Postby mgX » Mon Sep 06, 2010 8:33 pm

You might wanna consider switching to an integer based approach of detecting chambers basically since... String comparisons are a very costly affair, and should be avoided at all cost.
mgX
Inactive Staff Member
 
Posts: 235
Joined: Tue Jun 28, 2005 10:19 am
ICQ: 298828005
Yahoo Messenger: Insilopeh
Location: Denmark


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest