This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNPCDifficulty.py
91 lines (80 loc) · 3.14 KB
/
NPCDifficulty.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
__author__ = 'Corrosion X'
__version__ = '0.7'
__name__ = 'NPCDifficulty'
import clr
import sys
clr.AddReferenceByPartialName("UnityEngine")
clr.AddReferenceByPartialName("Pluton")
import UnityEngine
import Pluton
import re
from UnityEngine import Random
path = Util.GetPublicFolder()
sys.path.append(path + "\\Plugins\\EasyAttachEntities")
import EasyAttachEntities
class NPCDifficulty:
methodname = "AttachToAnimal"
ClassName = EasyAttachEntities.EasyAttachEntities()
AttachToAnimals = getattr(ClassName, methodname)
methodname = "TimedExplosive"
ClassName = EasyAttachEntities.EasyAttachEntities()
TimedExplosive = getattr(ClassName, methodname)
def On_PluginInit(self):
DataStore.Flush("marked4death")
def On_PlayerConnected(self, player):
player.Message("Animals take 200% less dmg, try not to kill too many...")
def On_PlayerDisconnected(self, player):
DataStore.Remove("marked4death", player.GameID)
def On_PlayerDied(self, pde):
DataStore.Remove("marked4death", pde.Victim.GameID)
def On_PlayerGathering(self, ge):
num = int(Random.Range(0, 10))
res = ge.Resource
player = ge.Gatherer
if res is None and num == 5:
player.Message("Oh noes! You found a hibernating bear!")
World.SpawnAnimal("bear", player.Location)
def On_NPCAttacked(self, npa):
npa.DamageAmount /= 200
def On_NPCKilled(self, nde):
baseplayer = nde.Attacker
if baseplayer is None or "NPC":
return
player = Server.Players[baseplayer.userID]
npc = nde.Victim
npcname = npc.Name
npcname = re.sub("\(Clone\)", "", npcname)
kills = DataStore.Get("kills", player.GameID)
marked = bool(DataStore.Get("marked4death", player.GameID))
timer = int(Random.Range(30, 180))
#player.Message("timer set")
if not marked:
#player.Message("You have angered the " + npcname + " Gods!")
if kills is None:
kills = 1
elif kills < 10:
kills += 1
elif kills >= 10:
kills = 1
DataStore.Add("marked4death", player.GameID, True)
pldict = Plugin.CreateDict()
pldict["uid"] = player.GameID
time = int(timer)*1000
Plugin.CreateParallelTimer("marked", time, pldict).Start()
player.Message("You have been marked for death!")
DataStore.Add("kills", player.GameID, kills)
for c in xrange(0, kills):
newexplosive = self.TimedExplosive()
self.AttachToAnimals(npcname, newexplosive, "head", True)
#World.SpawnAnimal(npcname, npc.Location)
def markedCallback(self, timer):
pldict = timer.Args
userid = pldict["uid"]
n = 3
DataStore.Remove("marked4death", userid)
player = Server.Players[userid]
player.MessageFrom("Animal Gods", "I hope you learn your lesson!")
for c in xrange(0, n):
World.SpawnAnimal("wolf", player.Location)
World.SpawnAnimal("bear", player.Location)
timer.Kill()