[committed] GameTrainingDummy fixes

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Re: GameTrainingDummy fixes

Postby Tolakram » Wed Apr 14, 2010 7:55 pm

No one will ever know how it works ... or care. :)

A better solution might be to add a simple brain for this, I suppose. One brain could allow health loss, the other would not.

But basically we only want one dummy class ... we have enough dummies as it is.

Aredhel, you have opinions on brains ... should the brain be handling body events like this or not? On the one hand the brain represents how the mob thinks and behaves. A call to on attack in the dummy could simply ask the brain what to do. IOldAgressiveBrain, and the next version if that ever happens, should really have a series of WHATDOIDO interaces. OnAttacked, etc.

I'm not sure of 'on the other hand' :) It's questionable what the body should do other than be a placeholder for a brain ... and if so then we don't need a dummy class at all, just a dummy brain.

I'm back to thinking using flags for dummies is ok. /sigh
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: GameTrainingDummy fixes

Postby bluraven » Wed Apr 14, 2010 8:52 pm

I'll pitch in my two copper on it: To me it doesn't makes sense for the brain to decide if a body takes damage when hit (it should decide how to react to it, but not whether to take damage itself), I like the way it's currently handled by the body/body class. If I have a special case mob (whether it be a boss mob, or an artifact encounter mob, or a training dummy) and I don't want it to take damage when it's hit, I'll just override the TakeDamage method or other needed methods of the GameNPC class. Wouldn't it make more sense to have GameTrainingDummyVulnerable and GameTrainingDummyInvincible? Then those classes can be re-used for every dummy that needs to be invincible (not take damage) and for the ones that do. Also I'm not a big fan of using flags if those flags aren't going to be used very often. I don't think there are really *that* many dummies in the lands to warrant it. Maybe the flag can be added to just the dummie class, and not in GameNPC. That way if the flag is in the mob table entry for that dummy mob then it will know to behave accordingly, but if the flag is set for some reason on a mob that does not use the dummy class then it can be ignored.
Image
bluraven
Support Team
 
Posts: 1484
Joined: Mon Mar 19, 2007 8:18 am
Location: Las Vegas, NV

Re: GameTrainingDummy fixes

Postby boltman » Wed Apr 14, 2010 11:15 pm

Just to throw this in, I was thinking of the Egg of Youth encounter. Sililia cannot be killed normally, once she reaches 0% she just stays alive. She can only be killed once the 9 pillars surrounding her are destroyed. Maybe I'm way off, but just thought this should be considered while you are working on this.
Image
boltman
Server Team
 
Posts: 198
Joined: Sat Sep 05, 2009 5:14 am
Location: Oregon

Re: GameTrainingDummy fixes

Postby bluraven » Thu Apr 15, 2010 12:01 am

Artifact encounters are very purpose oriented and are unique one of a kind situations (mostly), therefore I think they are best made with custom code for each encounter, which is the approach I was using when writing the few encounters I've implemented so far. I found it easier to make a custom Silia class and add custom methods or override existing ones specifically to her or to the encounter. For instance in her take damage method I could have it check the state of the pillars of the encounter she belongs to, before allowing her to take so much damage that she dies, therefore making it not possible to kill her unless all the pillars are down.
Image
bluraven
Support Team
 
Posts: 1484
Joined: Mon Mar 19, 2007 8:18 am
Location: Las Vegas, NV

Re: GameTrainingDummy fixes

Postby Aredhel » Thu Apr 15, 2010 7:48 pm

I'm with bluraven here, the proper way to go about it is to override TakeDamage() or something (don't have the code here before me).

Sililia - yes she is a special NPC, not a special type of NPC if you get my drift. Once more bluraven hit the nail on the head on this one.
User avatar
Aredhel
Inactive Staff Member
 
Posts: 1024
Joined: Sat Apr 14, 2007 1:49 pm
Location: Germany

Re: GameTrainingDummy fixes

Postby Tolakram » Thu Apr 15, 2010 7:55 pm

I would say the best solution for this problem is to use the mob.Flags field to indicate the dummy behavior and code that into the dummy class. It's not perfect but will work in this case.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: GameTrainingDummy fixes

Postby Aredhel » Thu Apr 15, 2010 7:58 pm

I disagree, they should be different classes, but if you feel more comfortable doing this in Flags, by all means, go for it.
User avatar
Aredhel
Inactive Staff Member
 
Posts: 1024
Joined: Sat Apr 14, 2007 1:49 pm
Location: Germany

Re: GameTrainingDummy fixes

Postby Tolakram » Thu Apr 15, 2010 8:08 pm

Aredhel is correct ... but I'd still use flags just because the problem seems so small. I'm no dummy :P
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: GameTrainingDummy fixes

Postby Graveen » Thu Apr 15, 2010 8:37 pm

Anyway, i committed this dummy, if Are is working on animating the tut zone, it 'll be usefull.

Accepted, soon in SVN, thank you
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: GameTrainingDummy fixes

Postby stephenxpimentel » Fri Apr 16, 2010 12:03 am

bluraven wrote:Artifact encounters are very purpose oriented and are unique one of a kind situations (mostly), therefore I think they are best made with custom code for each encounter, which is the approach I was using when writing the few encounters I've implemented so far. I found it easier to make a custom Silia class and add custom methods or override existing ones specifically to her or to the encounter. For instance in her take damage method I could have it check the state of the pillars of the encounter she belongs to, before allowing her to take so much damage that she dies, therefore making it not possible to kill her unless all the pillars are down.


if anything to be global in all artifact scripts would be a method for granting credit.. :) Which could be done in ArtifactMgr

e.g.

Code: Select all
ArtifactMgr.GrantCredit(IList<GamePlayer>, string ArtifactName)

(or int artifactID)
Lets have some fun.
stephenxpimentel
Contributor
 
Posts: 1300
Joined: Wed Sep 19, 2007 5:09 pm

Re: [committed] GameTrainingDummy fixes

Postby bluraven » Fri Apr 16, 2010 2:44 am

I'm not sure I understand what that has to do with what we're talking about but that is already something I made global to all my encounters and I thought you already knew that was the case, and yes it's in the encounter manager.
Image
bluraven
Support Team
 
Posts: 1484
Joined: Mon Mar 19, 2007 8:18 am
Location: Las Vegas, NV

Re: GameTrainingDummy fixes

Postby Are » Fri Apr 16, 2010 8:20 am

Graveen wrote:Anyway, i committed this dummy, if Are is working on animating the tut zone, it 'll be usefull.

Accepted, soon in SVN, thank you


Thx :). Yes at least the OnAttackedByEnemy thing is necessary to make the fighting NPCs work. If the dummy looses health or not, or if it is controlled by a flag or different classes can be discussed a bit more. But I like the idea of a new flag pretty much ;).
User avatar
Are
DOL Acolyte
 
Posts: 106
Joined: Mon Mar 26, 2007 7:43 pm
Location: Germany

Re: GameTrainingDummy fixes

Postby Aredhel » Fri Apr 16, 2010 11:57 am

stephenxpimentel wrote:if anything to be global in all artifact scripts would be a method for granting credit.. :) Which could be done in ArtifactMgr

e.g.

Code: Select all
ArtifactMgr.GrantCredit(IList<GamePlayer>, string ArtifactName)

(or int artifactID)


Sometimes just looking at the code helps tremendously! :) From ArtifactMgr.cs:

Code: Select all
  550       /// <summary>
  551       /// Grant credit for an artifact.
  552       /// </summary>
  553       /// <param name="player"></param>
  554       /// <param name="artifactID"></param>
  555       /// <returns></returns>
  556       public static bool GrantArtifactCredit(GamePlayer player, String artifactID)
  557       {
  558          if (player == null || artifactID == null)
  559             return false;
  560
  561          if (!player.CanReceiveArtifact(artifactID))
  562             return false;
  563
  564          Artifact artifact;
  565          lock (m_artifacts)
  566          {
  567             if (!m_artifacts.ContainsKey(artifactID))
  568                return false;
  569             artifact = m_artifacts[artifactID];
  570          }
  571
  572          if (artifact == null)
  573             return false;
  574
  575          Type encounterType = GetQuestType(artifact.EncounterID);
  576          if (encounterType == null)
  577             return false;
  578
  579             Type artifactQuestType = GetQuestType(artifact.QuestID);
  580             if (artifactQuestType == null)
  581                 return false;
  582
  583          if (player.HasFinishedQuest(encounterType) > 0 ||
  584                 player.HasFinishedQuest(artifactQuestType) > 0)
  585             return false;
  586
  587          AbstractQuest quest = (AbstractQuest)(System.Activator.CreateInstance(encounterType,
  588             new object[] { player }));
  589
  590          if (quest == null)
  591             return false;
  592
  593          quest.FinishQuest();
  594          return true;
  595       }
User avatar
Aredhel
Inactive Staff Member
 
Posts: 1024
Joined: Sat Apr 14, 2007 1:49 pm
Location: Germany

Re: [committed] GameTrainingDummy fixes

Postby bluraven » Fri Apr 16, 2010 5:44 pm

More specifically this one should get used first to easily grant credit to the players group or battlegroup and calls the one from ArtifactMgr after a list of players is built from the killer and his group or battlegroup to grant credit to them all:
dolserver > DOLSharp > trunk > GameServerScripts > quests > masterlevel example > EncounterMgr.cs
Code: Select all
namespace DOL.GS.Atlantis
{
    /// <summary>
    /// Handles ArtifactEncounter functions like granting credit.
    /// </summary>
    public static class EncounterMgr
    {
        public static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        #region Grant Credit
        /// <summary>
        /// Grants credit for the encounter to the killer/player and
        /// optionally his group or battlegroup mates.
        /// </summary>
        public static void GrantEncounterCredit(GameObject killer, bool group, bool battlegroup, string artifactid)
        {
            List<GamePlayer> creditPlayerList = new List<GamePlayer>();
            // if controlled NPC - do checks for owner instead
            if (killer is GameNPC)
            {
                IControlledBrain controlled = ((GameNPC)killer).Brain as IControlledBrain;
                if (controlled != null)
                {
                    killer = controlled.GetPlayerOwner();
                }
            }
            GamePlayer player = killer as GamePlayer;
            //add the killer player to the list.
            if (!creditPlayerList.Contains(player))
            {
                creditPlayerList.Add(player);
            }

            //if killing player has a group, let's add those players to the list to receive credit.
            if (player.Group != null && group)
            {

                //player is grouped, let's add the group to the list to recieve credit.
                foreach (GamePlayer groupplayer in (player.Group.GetPlayersInTheGroup()))
                {
                    if (!creditPlayerList.Contains(groupplayer))
                    {
                        //only add players are near enough that they would have earned XP from the kill.
                        if (groupplayer.IsWithinRadius(killer, WorldMgr.MAX_EXPFORKILL_DISTANCE))
                        {
                            creditPlayerList.Add(groupplayer);
                        }
                    }
                }
            }

            //if killing player has a battlegroup, let's add those players to the list to receive credit.
            if (player.isInBG && battlegroup)
            {

                BattleGroup bg = (BattleGroup)player.TempProperties.getProperty<object>(BattleGroup.BATTLEGROUP_PROPERTY, null);
                HybridDictionary bgplayers = bg.Members;
                foreach (GamePlayer eachplayer in bgplayers.Keys)
                {
                    if (!creditPlayerList.Contains(eachplayer))
                    {
                        //only add players who are near enough that they would have earned XP from the kill.
                        if (eachplayer.IsWithinRadius(killer, WorldMgr.MAX_EXPFORKILL_DISTANCE))
                        {
                            creditPlayerList.Add(eachplayer);
                        }
                    }
                }
            }

            //List should now contain the killer, plus optionally the players in his group, and optionally his battlegroup
            if (creditPlayerList.Count > 0)
            {
                foreach (GamePlayer creditplayer in creditPlayerList)
                {
                    creditplayer.Out.SendMessage("The " + artifactid + " encounter has been completed, you should have received credit, if you were eligible.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                    ArtifactMgr.GrantArtifactCredit(creditplayer, artifactid);
                }
            }
            return;
        }
        #endregion Grant Credit
Image
bluraven
Support Team
 
Posts: 1484
Joined: Mon Mar 19, 2007 8:18 am
Location: Las Vegas, NV

Re: [committed] GameTrainingDummy fixes

Postby Tolakram » Fri Apr 16, 2010 7:26 pm

Back to the game dummies ....

I just realized this entire time I was thinking of item flags and not mob flags, which are used all over the place and definitely NOT something to use here.

Good grief, apparently I AM a dummy :)
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest