CODE |
private static TimeSpan m_DeathDelay = TimeSpan.FromSeconds(60); // 60 seconds default min time between deaths for point loss |
QUOTE |
// check to see whether points can be taken if(!(AttachedTo is Mobile) || !CanAffectPoints((Mobile)AttachedTo, killer, killed, false)) { awardpoints = false; } Console.WriteLine("killer={0} killed={1} awardpoints={2}", killer, killed, awardpoints); |
QUOTE (The Jedi @ August 03, 2006 04:04 am) |
Compiling now.... killer=0x1234 "Bob" killed=0x5678 "Joe" awardpoints=False There she is. Seems clear, but whats with the false, is that right? |
CODE |
public bool CanAffectPoints(Mobile from, Mobile killer, Mobile killed, bool assumechallenge) { // uncomment this for newbie protection //if( ((killed.SkillsTotal < 6000 && (killer.SkillsTotal - killed.SkillsTotal ) > 1000) || //(killed.RawStatTotal <= 200 && (killer.RawStatTotal - killed.RawStatTotal) > 20 ) ) && m_Challenger != killer && m_Challenger != killed) return false; // check for within guild kills and ignore them if this has been disabled if(!AllowWithinGuildPoints && SameGuild(killed,killer)) return false; // check for within team kills and ignore them if(AreTeamMembers(killer, killed)) return false; // are the players challengers? bool inchallenge = false; if((from == killer && m_Challenger == killed) || (from == killed && m_Challenger == killer)) { inchallenge = true; } bool norestriction = UnrestrictedChallenges; // check for team challenges if(ChallengeGame != null && !ChallengeGame.Deleted) { // check to see if points have been disabled in this game if(!ChallengeGame.AllowPoints) return false; inchallenge = true; // check for kill delay limitations on points awards norestriction = !ChallengeGame.UseKillDelay; } // if UnlimitedChallenges has been set then allow points // otherwise, challenges have to obey the same restrictions on minimum time between kills as normal pvp if(norestriction && (inchallenge || assumechallenge)) return true; // only allow guild kills to yield points if in a challenge if(!(assumechallenge || inchallenge) && SameGuild(killed,killer)) return false; // uncomment the line below to limit points to challenges. regular pvp will not give points //if(!inchallenge && !assumechallenge) return false; // check to see whether killing the target would yield points // get a point for killing if they havent been killed recent // get the points attachment on the killer if this isnt the killer XmlPoints a = this; if (from != killer) { a = (XmlPoints)XmlAttach.FindAttachment(killer, typeof(XmlPoints)); } if(a != null) { a.RefreshKillList(); // check the kill list if there is one if(a.KillList != null) { foreach(KillEntry k in a.KillList) { if(k.WhenKilled + m_KillDelay > DateTime.Now) { // found a match on the list so dont give any points if(k.Killed == killed) { return false; } } } } } // check to see whether the killed target could yield points if(from == killed) { // is it still within the minimum delay for being killed? if(DateTime.Now < m_LastDeath + m_DeathDelay) return false; } return true; } |
QUOTE (The Jedi @ August 03, 2006 05:57 am) |
Hah! I was just about to ask if it might be time related. And no, hasn't been manually set in at least 3 years. And I have glanced at the Last Killed DateTime() and they are all zerod out. Should mean that any value you add (from death delay) should still be less than the current date/time, right? Edit: even after kills the Last Killed remains at 1/1/1 12:00, but the kill has the proper timing. So even the DateTime from the death isn't being registered. |
CODE |
// check the kill list if there is one if(a.KillList != null) { foreach(KillEntry k in a.KillList) { if(k.WhenKilled + m_KillDelay > DateTime.Now) { Console.WriteLine("Are they on the kill list?"); // found a match on the list so dont give any points if(k.Killed == killed) { return false; } } } } } Console.WriteLine("Is the time right?"); // check to see whether the killed target could yield points if(from == killed) { // is it still within the minimum delay for being killed? ....... etc |
CODE |
if(k.WhenKilled + m_KillDelay > DateTime.Now) |
QUOTE |
// take points from the killed, either a fixed amount or scaled by the difference with the points of the killer // if the killer has fewer points than the killed then lose more XmlPoints xp = XmlAttach.FindAttachment(killer, typeof(XmlPoints)) as XmlPoints; if(xp != null) { killerpoints = xp.Points; // add to the recently killed list xp.KillList.Add(new KillEntry(killed, DateTime.Now)); } |
CODE |
// add to the recently killed list //KillList.Add(new KillEntry(killed, DateTime.Now)); |