Beispiel #1
0
 def On_EntityHurt(self, HurtEvent):
     if not HurtEvent.AttackerIsPlayer:
         return
     if HurtEvent.Attacker is not None and HurtEvent.Entity is not None and not HurtEvent.IsDecay:
         gun = HurtEvent.WeaponName
         if gun == "Shotgun":
             return
         OwnerID = self.GetIt(HurtEvent.Entity)
         if OwnerID is None:
             return
         id = HurtEvent.Attacker.SteamID
         ownerlong = Data.ToUlong(OwnerID)
         if Data.ToUlong(id) != ownerlong:
             if "explosive" in gun.lower() or "grenade" in gun.lower():
                 Time = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds
                 BeingRaided[Data.ToUlong(OwnerID)] = Time
                 return
         if ownerlong in BeingRaided.keys():
             Time = BeingRaided[ownerlong]
             diff = (TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds -
                     Time)
             if diff < self.RaidTimeInSeconds:
                 HurtEvent.Attacker.Message(
                     "You can't destroy while having raid cooldown! (" +
                     str(round(diff, 2)) + "/" +
                     str(self.RaidTimeInSeconds) + ")")
                 return
             BeingRaided.pop(ownerlong)
         if Data.ToUlong(id) == ownerlong or self.IsFriend(OwnerID, id):
             EntityName = HurtEvent.Entity.Name
             if DataStore.ContainsKey("DestroySystem", id):
                 if self.IsEligible(HurtEvent):
                     HurtEvent.Entity.Destroy()
                     if self.giveback == 1:
                         if EntityName in EntityList.keys():
                             HurtEvent.Attacker.Inventory.AddItem(
                                 EntityList[EntityName])
             elif DataStore.ContainsKey("DestroySystem2", id):
                 structs = HurtEvent.Entity.GetLinkedStructs()
                 if self.giveback == 1:
                     if EntityName in EntityList.keys():
                         HurtEvent.Attacker.Inventory.AddItem(
                             EntityList[EntityName])
                 for ent in structs:
                     if self.giveback == 1:
                         namef = ent.Name
                         if namef in EntityList.keys():
                             HurtEvent.Attacker.Inventory.AddItem(
                                 EntityList[namef])
                     ent.Destroy()
                 HurtEvent.Entity.Destroy()
Beispiel #2
0
import clr
from System import DateTime, DateTimeOffset, TimeSpan
clr.AddReference("WorkTasks")
from WorkTasks import WorkTask

cut_start = DateTimeOffset(1997, 3, 3, 15, 31, 34, 361,
                           TimeSpan.FromMinutes(500))
cut_details = "artio"
account = WorkTask(cut_start, cut_details)

cut_duration = TimeSpan.FromSeconds(25570)
account.Duration = cut_duration

abutting_task = WorkTask(cut_start + cut_duration, "corollarii")
not_abutting_task = WorkTask(cut_start + cut_duration + TimeSpan.FromTicks(1),
                             "poenae")


def test_abutting():
    "Do two WorkTasks abut?"
    return account.IsAbutting(abutting_task)


def test_not_abutting():
    "Do two WorkTasks NOT abut?"
    return account.IsAbutting(not_abutting_task)