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.
ArtifactMgr.GrantCredit(IList<GamePlayer>, string ArtifactName)
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
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)
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 }
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
Return to “%s” DOL Code Contributions
Users browsing this forum: No registered users and 1 guest