xydius
Just an otland wanderer
- Joined
- Feb 25, 2016
- Messages
- 41
- Reaction score
- 37
Hello fellow otlanders,
Im releasing this simple "script" i just made for my custom ot where players have a passive spell which are cast from time to time while the player is in combat and has a target.
P.D.
It uses the exact same formulas for "exori mort" for mages, "exori con" for paladins and "exori hur" for knights in tfs 1.2 version 10.98-10.99
If i add some of this later I will edit this post.
If you encounter any issue let me know and ill try to fix it.
If you have any suggestion feel free to let me know so i can improve this code.
Im releasing this simple "script" i just made for my custom ot where players have a passive spell which are cast from time to time while the player is in combat and has a target.
- First go to creaturescripts and create a new file and name it however you want and paste this
Lua:local config = { enabled = true, doChance = 10000, --chance to do spell 1000 = 1 % TALKTYPE_ORANGE_1 = TALKTYPE_MONSTER_SAY, TALKTYPE_ORANGE_2 = TALKTYPE_MONSTER_YELL } local voc = { { id = 1, --sorc spellname = "passive spell", --TODO think for proper names combatDamage = COMBAT_DEATHDAMAGE, CombatEffect = CONST_ME_MORTAREA, distEffect = CONST_ANI_DEATH }, { id = 2, --druid spellname = "passive spell", combatDamage = COMBAT_ICEDAMAGE, CombatEffect = CONST_ME_ICEAREA, distEffect = CONST_ANI_ICE }, { id = 3, --pally spellname = "passive spell", combatDamage = COMBAT_PHYSICALDAMAGE, CombatEffect = CONST_ME_HITAREA, distEffect = CONST_ANI_THROWINGSTAR }, { id = 4, --knight spellname = "passive spell", combatDamage = COMBAT_PHYSICALDAMAGE, CombatEffect = CONST_ME_DRAWBLOOD, distEffect = CONST_ANI_LARGEROCK }, } function onThink(creature, interval) if config.enabled then if creature:isPlayer() then local target = creature:getTarget() if target then local chance = math.random(1, 100000) if chance <= config.doChance then local vocation = creature:getVocation():getBase():getId() for i=1, #voc do if vocation == voc[i].id then local level = creature:getLevel() local min = 0 local max = 0 if vocation == 1 or vocation == 2 then local maglevel = creature:getMagicLevel() min = (level / 5) + (maglevel * 1.4) + 8 max = (level / 5) + (maglevel * 2.2) + 14 end if vocation == 3 then local weapontype = nil local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) if slotItem then weaponType = slotItem:getType():getWeaponType() end local skill = SKILL_FIST if weaponType == 5 then skill = SKILL_DISTANCE end local skilllvl = creature:getEffectiveSkillLevel(skill) min = (level / 5) + skilllvl * 2 max = (level / 5) + skilllvl * 5 end if vocation == 4 then local weapontype = nil local attack = 10 local uid = nil local slotItem = creature:getSlotItem(CONST_SLOT_LEFT) if slotItem then uid = slotItem:getUniqueId() attack = getItemAttribute(uid, ITEM_ATTRIBUTE_ATTACK, true) weaponType = slotItem:getType():getWeaponType() end local skill = SKILL_FIST if weaponType == 1 then skill = SKILL_SWORD end if weaponType == 2 then skill = SKILL_CLUB end if weaponType == 3 then skill = SKILL_AXE end local skilllvl = creature:getEffectiveSkillLevel(skill) min = (level / 5) + (skilllvl * attack * 0.01) + 1 max = (level / 5) + (skilllvl * attack * 0.03) + 6 end doCreatureSay(creature, voc[i].spellname, config.TALKTYPE_ORANGE_1) doSendDistanceShoot(creature:getPosition(), target:getPosition(), voc[i].distEffect) doTargetCombatHealth(creature, target, voc[i].combatDamage, -min, -max, voc[i].CombatEffect) end end end end if not target then creature:unregisterEvent("PassiveSpells") end end end end
- Add this script on your creaturescripts.xml file like this just remmber to change "passive.lua" to your filename
Code:<!-- Passive Spells --> <event type="think" name="PassiveSpells" script="passive.lua" />
- Register the event, I suggest you register the event in creature.lua in events folder in "Creature: onTargetCombat(target)" function right after "if not self then return true end" add this
Lua:if self:isPlayer() and target:isMonster() then self:registerEvent("PassiveSpells") end
P.D.
It uses the exact same formulas for "exori mort" for mages, "exori con" for paladins and "exori hur" for knights in tfs 1.2 version 10.98-10.99
If i add some of this later I will edit this post.
If you encounter any issue let me know and ill try to fix it.
If you have any suggestion feel free to let me know so i can improve this code.