ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Sun Jun 24, 2018 5:25 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue May 01, 2018 1:05 pm 
Offline
Uruivellas

Joined: Mon Sep 21, 2015 8:45 pm
Posts: 624
Location: Middle of Nowhere
I'm working on an addon that uses the damage type of a wielded staff for most of a class's spells, and it occurred to me that the method I used could be useful for modding, or development in general, and that it wouldn't hurt to share it.

Code:
getStaffType = function(self)
   --from channel staff. we'll use this to check damage type for all of our staff and shield attacks.
   --we changed damtype to kind so it wouldn't be confusing in our callbackOnMeleeAttack. we also added the name field to save ourselves some steps when we want to get the name as a string -- with colors!
   local weapon, combat = self:hasStaffWeapon()

   local combat = weapon and weapon.combat or false
   local trail = "arcanetrail"
   local particle = "bolt_arcane"
   local explosion = "manathrust"
   local name = "#PURPLE#Arcane#LAST#"
   local kind = (combat and combat.element) or (combat and combat.damtype) or DamageType.ARCANE

   if     kind == DamageType.FIRE then      explosion = "flame"                  particle = "bolt_fire"      trail = "firetrail"         name = "#LIGHT_RED#Fire#LAST#"      
   elseif kind == DamageType.COLD then      explosion = "freeze"                 particle = "ice_shards"     trail = "icetrail"         name = "#1133F3#Cold#LAST#"      
   elseif kind == DamageType.ACID then      explosion = "acid"                   particle = "bolt_acid"      trail = "acidtrail"         name = "#GREEN#Acid#LAST#"      
   elseif kind == DamageType.LIGHTNING then explosion = "lightning_explosion"   particle = "bolt_lightning" trail = "lightningtrail"   name = "#ROYAL_BLUE#Lightning#LAST#"   
   elseif kind == DamageType.LIGHT then     explosion = "light"                  particle = "bolt_light"     trail = "lighttrail"      name = "#YELLOW#Light#LAST#"      
   elseif kind == DamageType.DARKNESS then  explosion = "dark"                   particle = "bolt_dark"      trail = "darktrail"         name = "#GREY#Darkness#LAST#"   
   elseif kind == DamageType.NATURE then    explosion = "slime"                  particle = "bolt_slime"     trail = "slimetrail"      name = "#LIGHT_GREEN#Nature#LAST#"      
   elseif kind == DamageType.BLIGHT then    explosion = "slime"                  particle = "bolt_slime"     trail = "slimetrail"       name = "#DARK_GREEN#Blight#LAST#"      
   elseif kind == DamageType.PHYSICAL then  explosion = "dark"                   particle = "stone_shards"   trail = "earthtrail"      name = "Physical#LAST#"   
   elseif kind == DamageType.TEMPORAL then  explosion = "light"         particle = "temporal_bolt"  trail = "lighttrail"      name = "#STEEL_BLUE#Temporal#LAST#"   
   else      kind = DamageType.ARCANE           explosion = "manathrust"             particle = "bolt_arcane"    trail = "arcanetrail"  name = "#PURPLE#Arcane#LAST#"
   end
   
   return {kind = kind, explosion = explosion, particle = particle, trail = trail, name = name} -- half of these we might not use, but since we just coppied the function anyway, we might as well store the info in case we do decide to use it
end


All we've done here is copy the relevant portion of Channel Staff and dropped it into a function defined in spells.lua which returns all of the determined values. Also, for cosmetics, we added a 'name' field which returns a string with the name of the damage type in the appropriate color.

Image

Edit: Image link looks broken. Might just be on my end, but I'll just drop it inline anyhow.

Attachment:
channelStaff.jpg
channelStaff.jpg [ 55.86 KiB | Viewed 104 times ]



It occurred to me afterward that this could also be wrapped up into hasStaffWeapon(). I'm not really sure which would be more ideal.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group