Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.38 KB | None | 0 0
  1. require "/scripts/vec2.lua"
  2. require "/scripts/util.lua"
  3.  
  4. function init()
  5. local bounds = mcontroller.boundBox()
  6. script.setUpdateDelta(10)
  7. self.damageUpdate = 1
  8. self.damageGivenUpdate = 1
  9. self.challengeDamageGivenUpdate = 1
  10. self.lastMonster = {nil, nil, nil, nil, nil}
  11. self.level = -1
  12. message.setHandler("addToChallengeCount", function(_, _, level)
  13. addToChallengeCount(level)
  14. end)
  15. end
  16.  
  17. function update(dt)
  18.  
  19. self.id = entity.id()
  20. self.xp = world.entityCurrency(self.id, "experienceorb")
  21. self.level = self.level == -1 and math.floor(math.sqrt(self.xp/100)) or self.level
  22. self.classType = world.entityCurrency(self.id, "classtype")
  23.  
  24. self.strengthBonus = self.classType == 1 and 1.15 or 1
  25. self.agilityBonus = self.classType == 3 and 1.1 or (self.classType == 5 and 1.1 or (self.classType == 6 and 1.1 or 1))
  26. self.vitalityBonus = self.classType == 4 and 1.05 or (self.classType == 1 and 1.1 or (self.classType == 6 and 1.15 or 1))
  27. self.vigorBonus = self.classType == 4 and 1.15 or (self.classType == 2 and 1.1 or (self.classType == 5 and 1.1 or (self.classType == 6 and 1.05 or 1)))
  28. self.intelligenceBonus = self.classType == 2 and 1.2 or 1
  29. self.enduranceBonus = self.classType == 1 and 1.1 or (self.classType == 4 and 1.05 or (self.classType == 6 and 1.05 or 1))
  30. self.dexterityBonus = self.classType == 3 and 1.2 or (self.classType == 5 and 1.15 or (self.classType == 4 and 1.1 or 1))
  31.  
  32. self.strength = world.entityCurrency(self.id, "strengthpoint")^self.strengthBonus
  33. self.agility = world.entityCurrency(self.id,"agilitypoint")^self.agilityBonus
  34. self.vitality = world.entityCurrency(self.id,"vitalitypoint")^self.vitalityBonus
  35. self.vigor = world.entityCurrency(self.id,"vigorpoint")^self.vigorBonus
  36. self.intelligence = world.entityCurrency(self.id,"intelligencepoint")^self.intelligenceBonus
  37. self.endurance = world.entityCurrency(self.id,"endurancepoint")^self.enduranceBonus
  38. self.dexterity = world.entityCurrency(self.id,"dexteritypoint")^self.dexterityBonus
  39.  
  40. status.setPersistentEffects( "ivrpgstatboosts",
  41. {
  42.  
  43. -- Strength
  44. {stat = "shieldHealth", effectiveMultiplier = 1 + self.strength*.05},
  45. {stat = "physicalResistance", amount = self.strength*.0025},
  46.  
  47. -- Intelligence
  48. {stat = "energyRegenPercentageRate", amount = .05*self.intelligence},
  49. {stat = "energyRegenBlockTime", amount = -.01*self.intelligence},
  50.  
  51. -- Dexterity
  52. {stat = "fallDamageMultiplier", amount = -self.dexterity*.005},
  53.  
  54. -- Endurance
  55. {stat = "physicalResistance", amount = self.endurance*.0075},
  56. {stat = "poisonResistance", amount = self.endurance*.005},
  57. {stat = "fireResistance", amount = self.endurance*.005},
  58. {stat = "electricResistance", amount = self.endurance*.005},
  59. {stat = "iceResistance", amount = self.endurance*.005},
  60. {stat = "shadowResistance", amount = self.endurance*.005},
  61. {stat = "cosmicResistance", amount = self.endurance*.005},
  62. {stat = "radioactiveResistance", amount = self.endurance*.005},
  63. {stat = "grit", amount = self.endurance*.01},
  64.  
  65. --Agility
  66. {stat = "fallDamageMultiplier", amount = -self.agility*.01},
  67.  
  68. -- Vitality
  69. {stat = "maxHealth", baseMultiplier = math.floor(100*(1 + self.vitality*.05))/100},
  70. {stat = "foodDelta", amount = self.vitality*.0002},
  71.  
  72. -- Vigor
  73. {stat = "maxEnergy", baseMultiplier = math.floor(100*(1 + self.vigor*.05))/100},
  74. {stat = "energyRegenPercentageRate", amount = math.floor(.02*self.vigor)}
  75.  
  76. })
  77.  
  78. -- Agility
  79. if not status.statPositive("activeMovementAbilities") or mcontroller.canJump() or status.statPositive("ninjaVanishSphere") then
  80. mcontroller.controlModifiers({
  81. speedModifier = 1 + self.agility*.02,
  82. airJumpModifier = 1 + self.agility*.01
  83. })
  84. end
  85.  
  86. self.heldItem = world.entityHandItem(self.id, "primary")
  87. self.heldItem2 = world.entityHandItem(self.id, "alt")
  88. self.itemConf = self.heldItem and root.itemConfig(self.heldItem).config
  89. self.twoHanded = self.itemConf and self.itemConf.twoHanded or false
  90. self.category = self.itemConf and self.itemConf.category or false
  91. self.isBrokenBroadsword = self.heldItem == "brokenprotectoratebroadsword" and true or false
  92. self.weapon1 = self.heldItem and root.itemHasTag(self.heldItem, "weapon") or false
  93. self.weapon2 = self.heldItem2 and root.itemHasTag(self.heldItem2, "weapon") or false
  94. self.isBow = self.weapon1 and root.itemHasTag(self.heldItem, "bow") or false
  95.  
  96. --Weapon Stat Bonuses
  97. if self.heldItem == "magnorbs" or self.heldItem == "evileye" then
  98. status.addPersistentEffects("ivrpgstatboosts",
  99. {
  100. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.01 + self.intelligence*0.01}
  101. })
  102. elseif self.heldItem == "remotegrenadelauncher" then
  103. status.addPersistentEffects("ivrpgstatboosts",
  104. {
  105. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.015}
  106. })
  107. elseif self.heldItem == "erchiuseye" then
  108. status.addPersistentEffects("ivrpgstatboosts",
  109. {
  110. {stat = "powerMultiplier", baseMultiplier = 1 + self.intelligence*0.015}
  111. })
  112. elseif self.heldItem == "energywhip" then
  113. status.addPersistentEffects("ivrpgstatboosts",
  114. {
  115. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.02}
  116. })
  117. elseif self.heldItem then
  118. if root.itemHasTag(self.heldItem, "broadsword") or root.itemHasTag(self.heldItem, "spear") or root.itemHasTag(self.heldItem, "hammer") then
  119. status.addPersistentEffects("ivrpgstatboosts",
  120. {
  121. {stat = "powerMultiplier", baseMultiplier = 1 + self.strength*0.02}
  122. })
  123. elseif root.itemHasTag(self.heldItem, "staff") then
  124. status.addPersistentEffects("ivrpgstatboosts",
  125. {
  126. {stat = "powerMultiplier", baseMultiplier = 1 + self.intelligence*0.02}
  127. })
  128. elseif self.isBow or root.itemHasTag(self.heldItem, "rifle") or root.itemHasTag(self.heldItem, "sniperrifle") or root.itemHasTag(self.heldItem, "assaultrifle") or root.itemHasTag(self.heldItem, "shotgun") or root.itemHasTag(self.heldItem, "rocketlauncher") then
  129. status.addPersistentEffects("ivrpgstatboosts",
  130. {
  131. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.015}
  132. })
  133. else
  134. --Bonus for One-Handed Primary
  135. if root.itemHasTag(self.heldItem,"wand") then
  136. status.addPersistentEffects("ivrpgstatboosts",
  137. {
  138. {stat = "powerMultiplier", baseMultiplier = 1 + self.intelligence*0.0075}
  139. })
  140. elseif self.weapon1 or root.itemHasTag(self.heldItem,"ninja") then
  141. status.addPersistentEffects("ivrpgstatboosts",
  142. {
  143. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.0075}
  144. })
  145. end
  146. end
  147. end
  148. --Extra Bonus with One-Handed Secondary
  149. if self.heldItem2 then
  150. if root.itemHasTag(self.heldItem2,"wand") then
  151. status.addPersistentEffects("ivrpgstatboosts",
  152. {
  153. {stat = "powerMultiplier", baseMultiplier = 1 + self.intelligence*0.0075}
  154. })
  155. elseif self.weapon2 or root.itemHasTag(self.heldItem2,"ninja") then
  156. status.addPersistentEffects("ivrpgstatboosts",
  157. {
  158. {stat = "powerMultiplier", baseMultiplier = 1 + self.dexterity*0.0075}
  159. })
  160. end
  161. end
  162.  
  163. updateClassEffects(self.classType)
  164.  
  165. -- Affinity Effects
  166.  
  167. self.affinity = world.entityCurrency(self.id, "affinitytype")
  168.  
  169. if self.affinity == 0 then
  170. status.clearPersistentEffects("ivrpgaffinityeffects")
  171. else
  172. local frost = hasEphemeralStat("frostslow")
  173. local wet = hasEphemeralStat("wet")
  174. local isSuborWet = isInLiquid() | wet
  175. --sb.logInfo("FROST: "..frost)
  176. --sb.logInfo("WET: "..wet)
  177. --sb.logInfo("ISSUBORWET: "..isSuborWet)
  178. effs = {
  179. { -- Flame --
  180. {stat = "fireStatusImmunity", amount = 1},
  181. {stat = "biomeheatImmunity", amount = 1},
  182. {stat = "maxEnergy", effectiveMultiplier = 1 - 0.3*isInLiquid()}
  183. },
  184. { -- Venom --
  185. {stat = "poisonStatusImmunity", amount = 1},
  186. {stat = "tarStatusImmunity", amount = 1},
  187. {stat = "poisonStatusImmunity", amount = 1},
  188. {stat = "electricResistance", amount = -0.25},
  189. {stat = "maxHealth", effectiveMultiplier = 0.85}
  190. },
  191. { -- Frost --
  192. {stat = "iceStatusImmunity", amount = 1},
  193. --{stat = "iceResistance", amount = 3},
  194. {stat = "wetImmunity", amount = 1},
  195. {stat = "snowslowImmunity", amount = 1},
  196. {stat = "iceslipImmunity", amount = 1},
  197. {stat = "biomecoldImmunity", amount = 1},
  198. {stat = "fireResistance", amount = -0.25}
  199. },
  200. { -- Shock --
  201. {stat = "electricStatusImmunity", amount = 1},
  202. --{stat = "electricResistance", amount = 3},
  203. {stat = "tarStatusImmunity", amount = 1},
  204. {stat = "slimeImmunity", amount = 1},
  205. {stat = "fumudslowImmunity", amount = 1 },
  206. {stat = "jungleslowImmunity", amount = 1 },
  207. {stat = "spiderwebImmunity", amount = 1 },
  208. {stat = "sandstormImmunity", amount = 1 },
  209. {stat = "snowslowImmunity", amount = 1},
  210. {stat = "iceResistance", amount = -0.25},
  211. {stat = "maxHealth", effectiveMultiplier = 1 - 0.3*isInLiquid()}
  212. },
  213. --{ -- Aer --
  214. -- {stat = "breathprotectionvehicle", amount = 1},
  215. -- {stat = "jumpModifier", effectiveMultiplier = 1.5},
  216. -- {stat = "fallDamageMultiplier", effectiveMultiplier = 0.5},
  217. --},
  218. { -- Infernal --
  219. {stat = "fireStatusImmunity", amount = 1},
  220. {stat = "fireResistance", amount = 3},
  221. {stat = "biomeheatImmunity", amount = 1},
  222. {stat = "maxEnergy", effectiveMultiplier = 1 - 0.3*isInLiquid()},
  223.  
  224. {stat = "ffextremeheatImmunity", amount = 1},
  225. {stat = "lavaImmunity", amount = 1}
  226. },
  227. { -- Toxic --
  228. {stat = "poisonStatusImmunity", amount = 1},
  229. {stat = "tarStatusImmunity", amount = 1},
  230. {stat = "poisonResistance", amount = 3},
  231. {stat = "electricResistance", amount = -0.25},
  232. {stat = "maxHealth", effectiveMultiplier = 0.85},
  233.  
  234. {stat = "biomeradiationImmunity", amount = 1},
  235. {stat = "protoImmunity", amount = 1}
  236. },
  237. { -- Cryo --
  238. {stat = "iceStatusImmunity", amount = 1},
  239. {stat = "iceResistance", amount = 3},
  240. {stat = "breathProtection", amount = 1},
  241. {stat = "wetImmunity", amount = 1},
  242. {stat = "snowslowImmunity", amount = 1},
  243. {stat = "iceslipImmunity", amount = 1},
  244. {stat = "biomecoldImmunity", amount = 1},
  245. {stat = "fireResistance", amount = -0.25},
  246.  
  247. {stat = "ffextremecoldImmunity", amount = 1},
  248. },
  249. { -- Arc --
  250. {stat = "electricStatusImmunity", amount = 1},
  251. {stat = "electricResistance", amount = 3},
  252. {stat = "tarStatusImmunity", amount = 1},
  253. {stat = "slimeImmunity", amount = 1},
  254. {stat = "fumudslowImmunity", amount = 1 },
  255. {stat = "jungleslowImmunity", amount = 1 },
  256. {stat = "spiderwebImmunity", amount = 1 },
  257. {stat = "sandstormImmunity", amount = 1 },
  258. {stat = "snowslowImmunity", amount = 1},
  259. {stat = "iceResistance", amount = -0.25},
  260. {stat = "maxHealth", effectiveMultiplier = 1 - 0.3*isInLiquid()},
  261.  
  262. {stat = "shadowResistance", amount = 3},
  263. {stat = "biomeradiationImmunity", amount = 1}
  264. }
  265. --{ -- Void --
  266. -- {stat = "breathprotectionvehicle", amount = 1},
  267. -- {stat = "jumpModifier", effectiveMultiplier = 1.5},
  268. -- {stat = "fallDamageMultiplier", effectiveMultiplier = 0.5},
  269. -- {stat = "biomeradiationImmunity", amount = 1},
  270. --}
  271. }
  272. status.setPersistentEffects("ivrpgaffinityeffects",effs[self.affinity])
  273.  
  274. local aestheticType = {"fire", "poison", "ice", "electric"}
  275. if self.affinity > 0 then
  276. local affinityMod = (self.affinity-1)%4
  277. if status.statPositive("ivrpgaesthetics") and (mcontroller.xVelocity() > 1 or mcontroller.xVelocity() < -1) and not status.statPositive("activeMovementAbilities") then
  278. world.spawnProjectile(aestheticType[affinityMod+1].."trailIVRPG", {mcontroller.xPosition(), mcontroller.yPosition()-2}, self.id, {0,0}, false, {power = 0, knockback = 0, timeToLive = 0.3, damageKind = "applystatus"})
  279. end
  280.  
  281. if isInLiquid() == 1 then
  282. if affinityMod == 0 then
  283. status.overConsumeResource("health", dt)
  284. elseif affinityMod == 3 then
  285. status.overConsumeResource("energy", dt)
  286. end
  287. end
  288.  
  289. if affinityMod == 2 then
  290. mcontroller.controlModifiers({
  291. speedModifier = 0.85,
  292. airJumpModifier = 0.85
  293. })
  294. end
  295. end
  296. end
  297.  
  298. self.dnotifications, self.damageGivenUpdate = status.inflictedHitsSince(self.damageGivenUpdate)
  299. if self.dnotifications then
  300. --sb.logInfo("Damage Taken!!!")
  301. for _,notification in pairs(self.dnotifications) do
  302. --sb.logInfo("In damage given update")
  303. --Rogue Siphon
  304. if notification.damageSourceKind == "rogueelectricslash" then status.modifyResource("energy", 20)
  305. elseif notification.damageSourceKind == "roguepoisonslash" then status.modifyResource("health", 10)
  306. elseif notification.damageSourceKind == "rogueslash" then status.modifyResource("food", 3)
  307. end
  308.  
  309. end
  310. end
  311.  
  312. checkLevelUp()
  313. updateChallenges()
  314. end
  315.  
  316. function checkLevelUp()
  317. local currXP = world.entityCurrency(self.id,"experienceorb")
  318. if currXP >= (self.level+1)^2*100 and self.level < 50 then
  319. self.level = self.level + 1
  320. if self.level == 1 then
  321. return
  322. end
  323. status.addEphemeralEffect("ivrpglevelup")
  324. elseif currXP < (self.level+1)^2*100 then
  325. self.level = math.floor(math.sqrt(currXP/100))
  326. end
  327. end
  328.  
  329. function hasEphemeralStat(stat)
  330. ephStats = util.map(status.activeUniqueStatusEffectSummary(),
  331. function (elem)
  332. return elem[1]
  333. end)
  334. for _,v in pairs(ephStats) do
  335. if v == stat then return 1 end
  336. end
  337. return 0
  338. end
  339.  
  340. function isInLiquid()
  341. local mouthPosition = vec2.add(mcontroller.position(), status.statusProperty("mouthPosition"))
  342. local mouthful = world.liquidAt(mouthposition)
  343. if (world.liquidAt(mouthPosition)) and
  344. ((mcontroller.liquidId()== 1) or
  345. (mcontroller.liquidId()== 5) or
  346. (mcontroller.liquidId()== 6) or
  347. (mcontroller.liquidId()== 12) or
  348. (mcontroller.liquidId()== 43) or
  349. (mcontroller.liquidId()== 55) or
  350. (mcontroller.liquidId()== 58) or
  351. (mcontroller.liquidId()== 60) or
  352. (mcontroller.liquidId()== 69))
  353. then
  354. return 1
  355. end
  356. return 0
  357. end
  358.  
  359. function updateClassEffects(classType)
  360. local hardcore = status.statPositive("ivrpghardcore")
  361. local weaponsDisabled = false
  362.  
  363. if classType == 0 then
  364. --No Class
  365. status.clearPersistentEffects("ivrpgclassboosts")
  366. status.removeEphemeralEffect("explorerglow")
  367. status.removeEphemeralEffect("knightblock")
  368. status.removeEphemeralEffect("ninjacrit")
  369. status.removeEphemeralEffect("wizardaffinity")
  370. status.removeEphemeralEffect("roguepoison")
  371. status.removeEphemeralEffect("soldierdiscipline")
  372. elseif classType == 1 then
  373. --Knight
  374. status.setPersistentEffects("ivrpgclassboosts",
  375. {
  376. {stat = "grit", amount = .2},
  377. })
  378.  
  379. self.notifications, self.damageUpdate = status.damageTakenSince(self.damageUpdate)
  380. if self.notifications then
  381. --sb.logInfo("Damage Taken!!!")
  382. for _,notification in pairs(self.notifications) do
  383. if notification.hitType == "ShieldHit" then
  384. if status.resourcePositive("perfectBlock") then
  385. --increased damage after perfect blocks
  386. if self.heldItem and root.itemHasTag(self.heldItem, "vitalaegis") then
  387. status.addEphemeralEffect("regeneration4", 2)
  388. end
  389. status.addEphemeralEffect("knightblock")
  390. --sb.logInfo("Perfect Block: " .. tostring(status.resource("perfectBlock")) .. ", " .. tostring(status.resource("prefectBlockLimit")))
  391. end
  392. end
  393. end
  394. end
  395.  
  396. if self.heldItem and root.itemHasTag(self.heldItem, "broadsword") then
  397. status.addPersistentEffects("ivrpgclassboosts",
  398. {
  399. {stat = "powerMultiplier", baseMultiplier = 1.2}
  400. })
  401. elseif self.heldItem and self.heldItem2 and not self.twoHanded then
  402. if (root.itemHasTag(self.heldItem, "shortsword") and root.itemHasTag(self.heldItem2, "shield")) or (root.itemHasTag(self.heldItem, "shield") and root.itemHasTag(self.heldItem2, "shortsword")) then
  403. status.addPersistentEffects("ivrpgclassboosts",
  404. {
  405. {stat = "powerMultiplier", baseMultiplier = 1.2 + self.strength*.015}
  406. })
  407. end
  408. end
  409.  
  410. --Hardcore
  411. if hardcore then
  412. status.addPersistentEffects("ivrpgclassboosts",
  413. {
  414. {stat = "maxEnergy", effectiveMultiplier = 0.75}
  415. })
  416. mcontroller.controlModifiers({
  417. speedModifier = 0.9,
  418. airJumpModifier = 0.7
  419. })
  420.  
  421. --Weapon Checks
  422. if not self.isBrokenBroadsword and not self.isBow then
  423. if self.twoHanded then
  424. if self.weapon1 and not root.itemHasTag(self.heldItem, "melee") then weaponsDisabled = true end
  425. else
  426. if self.weapon1 then
  427. if not root.itemHasTag(self.heldItem, "melee") or self.weapon2 then
  428. weaponsDisabled = true
  429. end
  430. elseif self.weapon2 then
  431. if not root.itemHasTag(self.heldItem2, "melee") then
  432. weaponsDisabled = true
  433. end
  434. end
  435. end
  436. end
  437.  
  438. end
  439.  
  440. elseif classType == 2 then
  441. --Wizard
  442. status.setPersistentEffects("ivrpgclassboosts",
  443. {
  444. --purposefully left empty
  445. })
  446. --Arcane Chance Specified in monster.lua and npc.lua
  447.  
  448. self.checkDualWield = true
  449. self.wizardaffinityAdded = false
  450.  
  451. if self.heldItem and root.itemHasTag(self.heldItem, "staff") then
  452. status.addPersistentEffects("ivrpgclassboosts",
  453. {
  454. {stat = "powerMultiplier", baseMultiplier = 1.1},
  455. })
  456. status.addEphemeralEffect("wizardaffinity", math.huge)
  457. self.wizardaffinityAdded = true
  458. elseif (self.heldItem and root.itemHasTag(self.heldItem, "wand") and self.heldItem2 and root.itemHasTag(self.heldItem2,"wand")) then
  459. status.addPersistentEffects("ivrpgclassboosts",
  460. {
  461. {stat = "powerMultiplier", baseMultiplier = 1.1},
  462. })
  463. status.addEphemeralEffect("wizardaffinity", math.huge)
  464. self.wizardaffinityAdded = true
  465. elseif holdingWeaponsCheck(self.heldItem, self.heldItem2, true) then
  466. if (self.heldItem2 and root.itemHasTag(self.heldItem2, "wand")) or (self.heldItem and root.itemHasTag(self.heldItem, "wand")) then
  467. status.addEphemeralEffect("wizardaffinity", math.huge)
  468. self.wizardaffinityAdded = true
  469. end
  470. end
  471.  
  472. if holdingWeaponsCheck(self.heldItem, self.heldItem2, false) then
  473. if (self.heldItem and root.itemHasTag(self.heldItem, "wand")) then
  474. self.checkDualWield = false
  475. status.addPersistentEffects("ivrpgclassboosts",
  476. {
  477. {stat = "powerMultiplier", baseMultiplier = 1.1}
  478. })
  479. status.addEphemeralEffect("wizardaffinity", math.huge)
  480. self.wizardaffinityAdded = true
  481. end
  482. end
  483.  
  484. if holdingWeaponsCheck(self.heldItem2, self.heldItem, false) then
  485. if (self.heldItem2 and root.itemHasTag(self.heldItem2, "wand")) and self.checkDualWield then
  486. status.addPersistentEffects("ivrpgclassboosts",
  487. {
  488. {stat = "powerMultiplier", baseMultiplier = 1.1}
  489. })
  490. status.addEphemeralEffect("wizardaffinity", math.huge)
  491. self.wizardaffinityAdded = true
  492. end
  493. end
  494.  
  495. if not self.wizardaffinityAdded then
  496. status.removeEphemeralEffect("wizardaffinity")
  497. end
  498.  
  499. --Hardcore
  500. if hardcore then
  501. status.addPersistentEffects("ivrpgclassboosts",
  502. {
  503. {stat = "physicalResistance", amount = -.2}
  504. })
  505. mcontroller.controlModifiers({
  506. speedModifier = 0.8,
  507. airJumpModifier = 0.8
  508. })
  509.  
  510. --Weapon Checks
  511. if not self.isBrokenBroadsword and not self.isBow and not (self.heldItem == "erchiuseye") and not (self.heldItem == "magnorbs") and not (self.heldItem == "evileye") then
  512. if self.twoHanded then
  513. if self.weapon1 and not root.itemHasTag(self.heldItem, "staff") then weaponsDisabled = true end
  514. else
  515. if self.weapon1 then
  516. if not root.itemHasTag(self.heldItem, "wand") then
  517. weaponsDisabled = true
  518. end
  519. end
  520. if self.weapon2 then
  521. if not root.itemHasTag(self.heldItem2, "wand") and not root.itemHasTag(self.heldItem2, "dagger") then
  522. weaponsDisabled = true
  523. end
  524. end
  525. end
  526. end
  527.  
  528. end
  529. elseif classType == 3 then
  530. --Ninja
  531. --ThrowingStar, ThrowingKunai, SnowflakeShuriken, ThrowingKnife, ThrowingDagger
  532. status.setPersistentEffects("ivrpgclassboosts",
  533. {
  534. {stat = "fallDamageMultiplier", amount = -.1}
  535. })
  536. nighttime = nighttimeCheck()
  537. underground = undergroundCheck()
  538. if nighttime or underground then
  539. status.addEphemeralEffect("ninjacrit", math.huge)
  540. else
  541. status.removeEphemeralEffect("ninjacrit")
  542. end
  543. self.checkDualWield = true
  544. --if self.heldItem and root.itemHasTag(self.heldItem, "bow") then
  545. --status.addPersistentEffects("ivrpgclassboosts",
  546. --{
  547. --{stat = "powerMultiplier", effectiveMultiplier = 1.1}
  548. --})
  549. --end
  550. if holdingWeaponsCheck(self.heldItem, self.heldItem2, false) then
  551. if (self.heldItem and root.itemHasTag(self.heldItem, "ninja")) then
  552. self.checkDualWield = false
  553. status.addPersistentEffects("ivrpgclassboosts",
  554. {
  555. {stat = "powerMultiplier", baseMultiplier = 1.2}
  556. })
  557. end
  558. end
  559. if holdingWeaponsCheck(self.heldItem2, self.heldItem, false) then
  560. if (self.heldItem2 and root.itemHasTag(self.heldItem2, "ninja")) and self.checkDualWield then
  561. status.addPersistentEffects("ivrpgclassboosts",
  562. {
  563. {stat = "powerMultiplier", baseMultiplier = 1.2}
  564. })
  565. end
  566. end
  567. mcontroller.controlModifiers({
  568. speedModifier = 1.1,
  569. airJumpModifier = 1.1
  570. })
  571.  
  572. --Hardcore
  573. if hardcore then
  574. status.addPersistentEffects("ivrpgclassboosts",
  575. {
  576. {stat = "maxHealth", effectiveMultiplier = 0.5}
  577. })
  578.  
  579. --Weapon Checks
  580. if not self.isBrokenBroadsword and not self.isBow and not (self.heldItem == "adaptablecrossbow") and not (self.heldItem == "soluskatana") and not (self.heldItem == "energywhip") and not root.itemHasTag(self.heldItem, "katana") then
  581. if self.twoHanded then
  582. if self.weapon1 then weaponsDisabled = true end
  583. else
  584. if self.weapon1 then
  585. if root.itemHasTag(self.heldItem, "ranged") or root.itemHasTag(self.heldItem, "wand") then
  586. weaponsDisabled = true
  587. end
  588. end
  589. if self.weapon2 then
  590. if root.itemHasTag(self.heldItem2, "ranged") or root.itemHasTag(self.heldItem2, "wand") then
  591. weaponsDisabled = true
  592. end
  593. end
  594. end
  595. end
  596.  
  597. end
  598. elseif classType == 4 then
  599. --Soldier
  600. --Molotov, Thorn Grenade, Bomb
  601. status.setPersistentEffects("ivrpgclassboosts",
  602. {
  603. --Purposefully Empty
  604. })
  605. self.energy = status.resource("energy")
  606. self.maxEnergy = status.stat("maxEnergy")
  607. if self.energy == self.maxEnergy then
  608. status.addEphemeralEffect("soldierdiscipline", math.huge)
  609. elseif self.energy < self.maxEnergy*3/4 then
  610. status.removeEphemeralEffect("soldierdiscipline")
  611. end
  612. if self.heldItem and (root.itemHasTag(self.heldItem, "shotgun") or root.itemHasTag(self.heldItem, "sniperrifle") or root.itemHasTag(self.heldItem, "assaultrifle")) then
  613. status.addPersistentEffects("ivrpgclassboosts",
  614. {
  615. {stat = "powerMultiplier", baseMultiplier = 1.1}
  616. })
  617. elseif holdingWeaponsCheck(self.heldItem, self.heldItem2, true) then
  618. if (root.itemHasTag(self.heldItem,"soldier") and root.itemHasTag(self.heldItem2,"ranged")) or (root.itemHasTag(self.heldItem,"ranged") and root.itemHasTag(self.heldItem2,"soldier")) then
  619. status.addPersistentEffects("ivrpgclassboosts",
  620. {
  621. {stat = "powerMultiplier", baseMultiplier = 1.2}
  622. })
  623. end
  624. end
  625.  
  626. --Hardcore
  627. if hardcore then
  628. status.addPersistentEffects("ivrpgclassboosts",
  629. {
  630. {stat = "poisonResistance", amount = -.2},
  631. {stat = "fireResistance", amount = -.2},
  632. {stat = "electricResistance", amount = -.2},
  633. {stat = "iceResistance", amount = -.2}
  634. })
  635. mcontroller.controlModifiers({
  636. airJumpModifier = 0.9
  637. })
  638.  
  639. --Weapon Checks
  640. if not self.isBrokenBroadsword and not self.isBow then
  641. if self.twoHanded then
  642. if self.weapon1 and (not root.itemHasTag(self.heldItem, "ranged") or self.heldItem == "erchiuseye") then weaponsDisabled = true end
  643. else
  644. if self.weapon1 then
  645. if not root.itemHasTag(self.heldItem, "ranged") or self.weapon2 then
  646. weaponsDisabled = true
  647. end
  648. elseif self.weapon2 then
  649. if not root.itemHasTag(self.heldItem2, "ranged") then
  650. weaponsDisabled = true
  651. end
  652. end
  653. end
  654. end
  655.  
  656. end
  657. elseif classType == 5 then
  658. --Rogue
  659. status.setPersistentEffects("ivrpgclassboosts",
  660. {
  661. --Purposefully empty
  662. })
  663. self.foodValue = status.resource("food")
  664. if self.foodValue >= 34 then
  665. status.addEphemeralEffect("roguepoison",math.huge)
  666. else
  667. status.removeEphemeralEffect("roguepoison")
  668. end
  669. --poison is finished in monster.lua
  670. if holdingWeaponsCheck(self.heldItem, self.heldItem2, true) then
  671. if self.weapon1 and self.weapon2 then
  672. status.addPersistentEffects("ivrpgclassboosts",
  673. {
  674. {stat = "powerMultiplier", baseMultiplier = 1.2}
  675. })
  676. end
  677. end
  678.  
  679. --Hardcore
  680. if hardcore then
  681. status.addPersistentEffects("ivrpgclassboosts",
  682. {
  683. {stat = "maxHealth", effectiveMultiplier = 0.8},
  684. {stat = "foodDelta", amount = -0.002}
  685. })
  686.  
  687. --Weapon Checks
  688. if not self.isBrokenBroadsword and not self.isBow and not (self.heldItem == "energywhip") then
  689. if self.twoHanded and self.weapon1 then
  690. weaponsDisabled = true
  691. elseif (self.heldItem and root.itemHasTag(self.heldItem, "wand")) or (self.heldItem2 and root.itemHasTag(self.heldItem2, "wand")) then
  692. weaponsDisabled = true
  693. end
  694. end
  695. end
  696. elseif classType == 6 then
  697. --Explorer
  698. status.setPersistentEffects("ivrpgclassboosts",
  699. {
  700. {stat = "physicalResistance", amount = .1}
  701. })
  702. if (self.heldItem and root.itemHasTag(self.heldItem, "explorer")) or (self.heldItem2 and root.itemHasTag(self.heldItem2, "explorer")) then
  703. status.addPersistentEffects("ivrpgclassboosts",
  704. {
  705. {stat = "powerMultiplier", baseMultiplier = 1.1},
  706. {stat = "physicalResistance", amount = .1},
  707. {stat = "poisonResistance", amount = .1},
  708. {stat = "fireResistance", amount = .1},
  709. {stat = "electricResistance", amount = .1},
  710. {stat = "iceResistance", amount = .1},
  711. {stat = "shadowResistance", amount = .1},
  712. {stat = "cosmicResistance", amount = .1},
  713. {stat = "radioactiveResistance", amount = .1}
  714. })
  715. end
  716. self.health = world.entityHealth(self.id)
  717. if self.health[1] ~= 0 and self.health[2] ~= 0 and self.health[1]/self.health[2]*100 >= 50 and not status.statPositive("ivrpgclassability") then
  718. status.addEphemeralEffect("explorerglow", math.huge)
  719. else
  720. status.removeEphemeralEffect("explorerglow")
  721. end
  722.  
  723. --Hardcore
  724. if hardcore then
  725. status.addPersistentEffects("ivrpgclassboosts",
  726. {
  727. {stat = "powerMultiplier", effectiveMultiplier = 0.85}
  728. })
  729. end
  730. end
  731.  
  732. if weaponsDisabled then
  733. status.setPersistentEffects("ivrpghardcoreweaponsdisabled", {
  734. {stat = "powerMultiplier", effectiveMultiplier = 0}
  735. })
  736. else
  737. status.clearPersistentEffects("ivrpghardcoreweaponsdisabled")
  738. end
  739.  
  740. end
  741.  
  742. function holdingWeaponsCheck(heldItem, heldItem2, dualWield)
  743. if heldItem then
  744. if heldItem2 then
  745. if dualWield then
  746. --Returning True only when two items are equipped and Dual-Wield is specified.
  747. return true
  748. else
  749. if root.itemHasTag(heldItem2, "weapon") then
  750. --Second Item is a weapon, and Dual-Wield is not specified, so we return False.
  751. return false
  752. else
  753. --Second item is not a weapon, so we return True.
  754. return true
  755. end
  756. end
  757. else
  758. if dualWield then
  759. --Returning False because Dual-Wield is specified, but there is only one item equipped.
  760. return false
  761. else
  762. --Returning True because Dual-Wield is not specified, and only one item is equipped.
  763. return true
  764. end
  765. end
  766. else
  767. --Returning False because no items are equipped.
  768. return false
  769. end
  770. end
  771.  
  772.  
  773. function getLight()
  774. local position = mcontroller.position()
  775. position[1] = math.floor(position[1])
  776. position[2] = math.floor(position[2])
  777. local lightLevel = world.lightLevel(position)
  778. lightLevel = math.floor(lightLevel * 100)
  779. return lightLevel
  780. end
  781.  
  782. function nighttimeCheck()
  783. return world.timeOfDay() > 0.5 -- true if night
  784. end
  785.  
  786. function daytimeCheck()
  787. return world.timeOfDay() < 0.5 -- true if daytime
  788. end
  789.  
  790. function undergroundCheck()
  791. return world.underground(mcontroller.position())
  792. end
  793.  
  794. function updateChallenges()
  795. self.dnotifications, self.challengeDamageGivenUpdate = status.inflictedDamageSince(self.challengeDamageGivenUpdate)
  796. if self.dnotifications then
  797. --sb.logInfo("Damage Taken!!!")
  798. for _,notification in pairs(self.dnotifications) do
  799. --Challenges
  800. local challenge1 = status.stat("ivrpgchallenge1")
  801. local challenge2 = status.stat("ivrpgchallenge2")
  802. local challenge3 = status.stat("ivrpgchallenge3")
  803.  
  804. if challenge1 then
  805. if challenge1 == 3 then
  806. if updateProgress(notification, "boss", 7, "kluexboss") then
  807. status.addPersistentEffect("ivrpgchallenge1progress", {stat = "ivrpgchallenge1progress", amount = 1})
  808. end
  809. end
  810. end
  811.  
  812. if challenge2 then
  813. if challenge2 == 2 then
  814. if updateProgress(notification, "boss", 7, "dragonboss") then
  815. status.addPersistentEffect("ivrpgchallenge2progress", {stat = "ivrpgchallenge2progress", amount = 1})
  816. end
  817. end
  818. end
  819.  
  820. if challenge3 then
  821. if challenge3 == 2 then
  822. if updateProgress(notification, "boss", 7, "vault") then
  823. status.addPersistentEffect("ivrpgchallenge3progress", {stat = "ivrpgchallenge3progress", amount = 1})
  824. end
  825. elseif challenge3 == 3 then
  826. if updateProgress(notification, "boss", 7, "eyeboss") then
  827. status.addPersistentEffect("ivrpgchallenge3progress", {stat = "ivrpgchallenge3progress", amount = 1})
  828. end
  829. end
  830. end
  831.  
  832. if updateProgress(notification, "boss", 8, "eyeboss") then
  833. world.spawnItem("experienceorb", mcontroller.position(), 1000)
  834. end
  835.  
  836. end
  837. end
  838. end
  839.  
  840. function updateProgress(notification, challengeKind, threatTarget, bossKind)
  841. local targetEntityId = notification.targetEntityId
  842. local isMonster = world.isMonster(targetEntityId)
  843. if not isMonster then
  844. return false
  845. end
  846.  
  847. local isNpc = world.isNpc(targetEntityId)
  848. local monsterName = world.monsterType(targetEntityId)
  849. local health = world.entityHealth(targetEntityId)
  850. local healthLost = notification.healthLost
  851. local hitType = notification.hitType
  852. local damageTeam = world.entityDamageTeam(targetEntityId)
  853. local isEnemy = damageTeam and damageTeam.type == "enemy" or false
  854. local threat = world.threatLevel()
  855. local bosses = {"crystalboss", "apeboss", "cultistboss", "dragonboss", "eyeboss", "kluexboss", "penguinUfo", "spiderboss", "robotboss", "electricguardianboss", "fireguardianboss", "iceguardianboss", "poisonguardianboss"}
  856. local vaultGuardians = {"electricguardianboss", "fireguardianboss", "iceguardianboss", "poisonguardianboss"}
  857. local notKilled = (targetEntityId ~= self.lastMonster[threatTarget-3])
  858.  
  859. if challengeKind == "boss" then
  860. if notKilled and ((not health) or (healthLost >= health[1])) then
  861. if bossKind == "vault" then
  862. for _,boss in pairs(vaultGuardians) do
  863. if boss == monsterName then
  864. self.lastMonster[threatTarget-3] = targetEntityId
  865. return true
  866. end
  867. end
  868. else
  869. if bossKind == monsterName then
  870. self.lastMonster[threatTarget-3] = targetEntityId
  871. return true
  872. end
  873. end
  874. end
  875. elseif challengeKind == "bosses" then
  876. if notKilled and ((not health) or (healthLost >= health[1])) then
  877. for _,boss in pairs(bosses) do
  878. if boss == monsterName then
  879. self.lastMonster[threatTarget-3] = targetEntityId
  880. return true
  881. end
  882. end
  883. end
  884. end
  885. return false
  886. end
  887.  
  888. function addToChallengeCount(level)
  889. --sb.logInfo("Added to Challenge Count with Level: " .. level)
  890. local challenge1 = status.stat("ivrpgchallenge1")
  891. local challenge2 = status.stat("ivrpgchallenge2")
  892. local challenge3 = status.stat("ivrpgchallenge3")
  893.  
  894. if challenge1 == 1 and level >= 4 then
  895. status.addPersistentEffect("ivrpgchallenge1progress", {stat = "ivrpgchallenge1progress", amount = 1})
  896. elseif challenge1 == 2 and level >= 5 then
  897. status.addPersistentEffect("ivrpgchallenge1progress", {stat = "ivrpgchallenge1progress", amount = 1})
  898. end
  899.  
  900. if challenge2 == 1 and level >= 6 then
  901. status.addPersistentEffect("ivrpgchallenge2progress", {stat = "ivrpgchallenge2progress", amount = 1})
  902. end
  903.  
  904. if challenge3 == 1 and level >= 7 then
  905. status.addPersistentEffect("ivrpgchallenge3progress", {stat = "ivrpgchallenge3progress", amount = 1})
  906. end
  907.  
  908. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement