Advertisement
7n6

Glow Effects

7n6
Aug 12th, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.86 KB | None | 0 0
  1. --[[
  2.                             *###########################################################################*
  3.                             #                        -Glow Effects NPC by 7n6.-                         #
  4.                             #       If used please give credit or I will break your server Kappa.       #
  5.                             #                  (But seriously don't remove credits...)                  #
  6.                             *###########################################################################*
  7.  
  8.  
  9. *******************************************************************************************************************************
  10. ###############################################################################################################################
  11. *******************************************************************************************************************************
  12.  
  13.     Installation:
  14.         1) Ensure you have hook.lua loaded
  15.         2) Load this file with DoFile
  16.        
  17.         Please note: ALL STATES that are to be added must NOT have the ALLExAttrSet(role) or AttrRecheck(role) lines, as this would cause an overflow error.
  18.        
  19.     Configuration:
  20.         All sets of equips that add states are stored in the GlowEffects.Effects table.
  21.         To add a new set, add a new entry in the table, for example:
  22.  
  23.             {
  24.                 State = STATE_BBRING1,
  25.                 Fusable = false,
  26.                 AllowApparelGlow = false,
  27.                 SpecialCheck = nil,
  28.                 Effects = {
  29.                     Kylin = false,
  30.                     BlackDragon = false,
  31.                     Death = true,
  32.                     Chaos = false,
  33.                 },
  34.                 ItemID = nil,
  35.                 Slot = nil,
  36.                 Equips = {
  37.                     Head = nil ,
  38.                     Armour = {2817},
  39.                     Boots = nil,
  40.                     Gloves = nil,
  41.                     LeftHand = nil,
  42.                     RightHand = nil,
  43.                     LeftRing = nil,
  44.                     RightRing = {2577},
  45.                     Necklace = nil,
  46.                 },
  47.                 Apparels = {
  48.                     Head = nil,
  49.                     Armour = nil,
  50.                     Gloves = nil,
  51.                     Boots  = nil,  
  52.                     LeftHand = nil,
  53.                     RightHand = nil,
  54.                 },
  55.             },
  56.        
  57.         This means that when you have 2817 (SS death torso) or 825 (Kylin armour) equipped as your armour, and 2577 (Hell feather) as your right ring,
  58.         you are given the STATE_BBRING1 state (green glow + stats).
  59.        
  60.         Fusable = false, means that you do NOT get the effect is the equipment is fused.
  61.         AllowApparelGlow = false, means that you do NOT get the effect if the equipment is being used as an apparel.
  62.         SpecialCheck = nil, means no special checks are being done. If you specify a function here, that function must return true to allow the state to be added, eg:
  63.             if we set SpecialCheck = AllowGlow then made this function:
  64.            
  65.                 function AllowGlow(role)
  66.                     if GetChaDefaultName(role) == "admin" then
  67.                         return true
  68.                     else
  69.                         return false
  70.                     end
  71.                 end
  72.                
  73.             Only admin would get that glow.
  74.         Kylin = false, BlackDragon = false,Death = true, Chaos = false, These means that this set doesnt grant BD/Kylin/chaos effects, but does grant death (exp loss reduction)
  75.         The Equips table is used to declare which equips are needed in which slots. If multiple equips are specified in one slot, the player must have one of them equipped.
  76.        
  77.         You can also specify an effect with no state by using "State = nil", this can be useful to add kylin effect, but no state, to a set.
  78.        
  79.         ItemID = nil,
  80.         Slot = nil,
  81.        
  82.         Specifys an item that has to be in a slot for effect to work.
  83.        
  84.         The Apparels table specifys that the effect is only given if certain apparels are used.
  85.             eg:
  86.            
  87.             Apparels = {
  88.             Head = nil,
  89.             Armour = {6373,6374,6375,6376,6377,6378,6381,6384,6393,6396,6397,6398,6401,6414,6418,6422,6425,6426,6428,6430,6434,6437,6441,6445,6449,6453,6457,6461,6465,6479,6483,6487,6490,6493,6497,6501,6511,6514,6518,6522,6526,6530,6534,6537,6541,6545,6548,6551,6555,6559,6563,6567,6576,6582,6586,6589,6592,6593,6595,6598,6601,6605,6609,6613,7247,7251,7255,7258,7262,7266,7269,7272,7276,7280,7283,7287,7294,7298,7300,7304,7308,7312,7316,7320,7324,7327,7330,7334,7338,7341},
  90.             Gloves = nil,
  91.             Boots  = nil,  
  92.             LeftHand = nil,
  93.             RightHand = nil,
  94.         },
  95.        
  96.         The effect will only be added if one of the apparels in the armour table is used.
  97.        
  98. *******************************************************************************************************************************
  99. ###############################################################################################################################
  100. *******************************************************************************************************************************
  101. ]]
  102. --Glow Effects Object
  103. GlowEffects = {}
  104.  
  105. --table containing players current effects
  106. GlowEffects.PlayerEffects = {}
  107. --Table containing set glows
  108. GlowEffects.Effects = {
  109.     {
  110.         State = nil,
  111.         Fusable = true,
  112.         AllowApparelGlow = false,
  113.         SpecialCheck = nil,
  114.         Effects = {
  115.             Kylin = false,
  116.             BlackDragon = false,
  117.             Death = true,
  118.             Chaos = true,
  119.         },
  120.         ItemID = nil,
  121.         Slot = nil,
  122.         Equips = {
  123.             Head = nil ,
  124.             Armour = {1124},
  125.             Gloves = {1125},
  126.             Boots = {1126},
  127.             LeftHand = nil,
  128.             RightHand = nil,
  129.             LeftRing = nil,
  130.             RightRing = nil,
  131.             Necklace = nil,
  132.         },
  133.         Apparels = {
  134.             Head = nil,
  135.             Armour = nil,
  136.             Gloves = nil,
  137.             Boots  = nil,  
  138.             LeftHand = nil,
  139.             RightHand = nil,
  140.         },
  141.     },
  142.    
  143.     {
  144.         State = STATE_BBRING1,
  145.         Fusable = true,
  146.         AllowApparelGlow = false,
  147.         SpecialCheck = nil,
  148.         Effects = {
  149.             Kylin = false,
  150.             BlackDragon = false,
  151.             Death = true,
  152.             Chaos = false,
  153.         },
  154.         ItemID = nil,
  155.         Slot = nil,
  156.         Equips = {
  157.             Head = nil ,
  158.             Armour = {2817},
  159.             Gloves = nil,
  160.             Boots = nil,
  161.             LeftHand = nil,
  162.             RightHand = nil,
  163.             LeftRing = nil,
  164.             RightRing = {2577},
  165.             Necklace = nil,
  166.         },
  167.         Apparels = {
  168.             Head = nil,
  169.             Armour = nil,
  170.             Gloves = nil,
  171.             Boots  = nil,  
  172.             LeftHand = nil,
  173.             RightHand = nil,
  174.         },
  175.     },
  176.    
  177.     {
  178.         State = STATE_BBRING2,
  179.         Fusable = true,
  180.         AllowApparelGlow = false,
  181.         SpecialCheck = nil,
  182.         Effects = {
  183.             Kylin = false,
  184.             BlackDragon = false,
  185.             Death = true,
  186.             Chaos = false,
  187.         },
  188.         ItemID = nil,
  189.         Slot = nil,
  190.         Equips = {
  191.             Head = nil ,
  192.             Armour = {2820},
  193.             Gloves = nil,
  194.             Boots = nil,
  195.             LeftHand = nil,
  196.             RightHand = nil,
  197.             LeftRing = nil,
  198.             RightRing = {2578},
  199.             Necklace = nil,
  200.         },
  201.         Apparels = {
  202.             Head = nil,
  203.             Armour = nil,
  204.             Gloves = nil,
  205.             Boots  = nil,  
  206.             LeftHand = nil,
  207.             RightHand = nil,
  208.         },
  209.     },
  210.  
  211.     {
  212.         State = STATE_BBRING3,
  213.         Fusable = true,
  214.         AllowApparelGlow = false,
  215.         SpecialCheck = nil,
  216.         Effects = {
  217.             Kylin = false,
  218.             BlackDragon = false,
  219.             Death = true,
  220.             Chaos = false,
  221.         },
  222.         ItemID = nil,
  223.         Slot = nil,
  224.         Equips = {
  225.             Head = nil ,
  226.             Armour = {2823},
  227.             Gloves = nil,
  228.             Boots = nil,
  229.             Necklace = nil,
  230.             LeftHand = nil,
  231.             LeftRing = nil,
  232.             RightRing = {2579},
  233.             RightHand = nil,
  234.         },
  235.         Apparels = {
  236.             Head = nil,
  237.             Armour = nil,
  238.             Gloves = nil,
  239.             Boots  = nil,  
  240.             LeftHand = nil,
  241.             RightHand = nil,
  242.         },
  243.     },
  244.    
  245.     {
  246.         State = STATE_BBRING4,
  247.         Fusable = true,
  248.         AllowApparelGlow = false,
  249.         SpecialCheck = nil,
  250.         Effects = {
  251.             Kylin = false,
  252.             BlackDragon = false,
  253.             Death = true,
  254.             Chaos = false,
  255.         },
  256.         ItemID = nil,
  257.         Slot = nil,
  258.         Equips = {
  259.             Head = nil ,
  260.             Armour = {2826},
  261.             Gloves = nil,
  262.             Boots = nil,
  263.             LeftHand = nil,
  264.             RightHand = nil,
  265.             LeftRing = nil,
  266.             RightRing = {2580},
  267.             Necklace = nil,
  268.         },
  269.         Apparels = {
  270.             Head = nil,
  271.             Armour = nil,
  272.             Gloves = nil,
  273.             Boots  = nil,  
  274.             LeftHand = nil,
  275.             RightHand = nil,
  276.         },
  277.     },
  278.    
  279.     {
  280.         State = STATE_BBRING5,
  281.         Fusable = true,
  282.         AllowApparelGlow = false,
  283.         SpecialCheck = nil,
  284.         Effects = {
  285.             Kylin = false,
  286.             BlackDragon = false,
  287.             Death = true,
  288.             Chaos = false,
  289.         },
  290.         ItemID = nil,
  291.         Slot = nil,
  292.         Equips = {
  293.             Head = nil ,
  294.             Armour = {2829},
  295.             Gloves = nil,
  296.             Boots = nil,
  297.             LeftHand = nil,
  298.             RightHand = nil,
  299.             LeftRing = nil,
  300.             RightRing = {2581},
  301.             Necklace = nil,
  302.         },
  303.         Apparels = {
  304.             Head = nil,
  305.             Armour = nil,
  306.             Gloves = nil,
  307.             Boots  = nil,  
  308.             LeftHand = nil,
  309.             RightHand = nil,
  310.         },
  311.     },
  312.    
  313.     {
  314.         State = STATE_BBRING6,
  315.         Fusable = true,
  316.         AllowApparelGlow = false,
  317.         SpecialCheck = nil,
  318.         Effects = {
  319.             Kylin = false,
  320.             BlackDragon = false,
  321.             Death = true,
  322.             Chaos = false,
  323.         },
  324.         ItemID = nil,
  325.         Slot = nil,
  326.         Equips = {
  327.             Head = nil ,
  328.             Armour = {2832},
  329.             Gloves = nil,
  330.             Boots = nil,
  331.             LeftHand = nil,
  332.             RightHand = nil,
  333.             LeftRing = nil,
  334.             RightRing = {2582},
  335.             Necklace = nil,
  336.         },
  337.         Apparels = {
  338.             Head = nil,
  339.             Armour = nil,
  340.             Gloves = nil,
  341.             Boots  = nil,  
  342.             LeftHand = nil,
  343.             RightHand = nil,
  344.         },
  345.     },
  346.    
  347.     {
  348.         State = STATE_zhongshen,
  349.         Fusable = true,
  350.         AllowApparelGlow = false,
  351.         SpecialCheck = nil,
  352.         Effects = {
  353.             Kylin = true,
  354.             BlackDragon = false,
  355.             Death = false,
  356.             Chaos = false,
  357.         },
  358.         ItemID = nil,
  359.         Slot = nil,
  360.         Equips = {
  361.             Head = {1514,1518,1522,1526,1530,1534},
  362.             Armour = {1515,1519,1523,1527,1531,1535},
  363.             Gloves = {1516,1510,1524,1528,1532,1536},
  364.             Boots = {1517,1511,1525,1529,1533,1537},
  365.             LeftHand = nil,
  366.             RightHand = nil,
  367.             LeftRing = nil,
  368.             RightRing = {2577,2578,2579,2580,2581,2582,7573,7574,7575,7576,7577,7578},
  369.             Necklace =nil,
  370.         },
  371.         Apparels = {
  372.             Head = nil,
  373.             Armour = nil,
  374.             Gloves = nil,
  375.             Boots  = nil,    
  376.             LeftHand = nil,
  377.             RightHand = nil,
  378.         },
  379.     },
  380.    
  381.     {
  382.         State = nil,
  383.         Fusable = true,
  384.         AllowApparelGlow = false,
  385.         SpecialCheck = nil,
  386.         Effects = {
  387.             Kylin = true,
  388.             BlackDragon = false,
  389.             Death = false,
  390.             Chaos = false,
  391.         },
  392.         ItemID = nil,
  393.         Slot = nil,
  394.         Equips = {
  395.             Head = nil,
  396.             Armour = {825,2549},
  397.             Gloves = {826,2550},
  398.             Boots = {827,2551},
  399.             LeftHand = nil,
  400.             RightHand = nil,
  401.             LeftRing = nil,
  402.             RightRing = nil,
  403.             Necklace =nil,
  404.         },
  405.         Apparels = {
  406.             Head = nil,
  407.             Armour = nil,
  408.             Gloves = nil,
  409.             Boots  = nil,  
  410.             LeftHand = nil,
  411.             RightHand = nil,
  412.         },
  413.     },
  414.    
  415.    
  416.    
  417.     {
  418.         State = nil,
  419.         Fusable = true,
  420.         AllowApparelGlow = false,
  421.         SpecialCheck = nil,
  422.         Effects = {
  423.             Kylin = false,
  424.             BlackDragon = true,
  425.             Death = false,
  426.             Chaos = false,
  427.         },
  428.         ItemID = nil,
  429.         Slot = nil,
  430.         Equips = {
  431.             Head = nil,
  432.             Armour = {845,2367},
  433.             Gloves = {846,2368},
  434.             Boots = {847,2369},
  435.             LeftHand = nil,
  436.             RightHand = nil,
  437.             LeftRing = nil,
  438.             RightRing = nil,
  439.             Necklace =nil,
  440.         },
  441.         Apparels = {
  442.             Head = nil,
  443.             Armour = nil,
  444.             Gloves = nil,
  445.             Boots  = nil,  
  446.             LeftHand = nil,
  447.             RightHand = nil,
  448.         },
  449.     },
  450. }
  451.  
  452. --*******************************************************************************************************************************--
  453. --###############################################################################################################################--
  454. --*******************************************************************************************************************************--
  455. --function to iterate through the table and check each glow
  456. function GlowEffects.CheckGlows(role)
  457.     local States = {}
  458.     local PID = GetRoleID(role)
  459.     GlowEffects.PlayerEffects[PID] = {}
  460.     for i,v in pairs(GlowEffects.Effects) do
  461.         if GlowEffects.CheckGlow(role,i) == true then
  462.             if v.State ~= nil then
  463.                 AddState(role,role,v.State,1,0)
  464.                 States[v.State] = true
  465.             end
  466.             for j,k in pairs(v.Effects) do
  467.                 GlowEffects.SetPlayerEffects(role,v,j)
  468.             end
  469.         end
  470.     end
  471.     GlowEffects.RemoveGlows(role,States)
  472. end
  473.  
  474. function GlowEffects.SetPlayerEffects(role,v,State)
  475.     local PID = GetRoleID(role)
  476.     if v.Effects[State] == true then
  477.         GlowEffects.PlayerEffects[PID][State] = true
  478.     end
  479. end
  480.  
  481. --function to check if the player meets the requirements for a glow.
  482. function GlowEffects.CheckGlow(role,ID)
  483.     local Equips = GlowEffects.GetEquips(role)
  484.     local FusedEquips = GlowEffects.GetFusedEquips(role)
  485.     if GlowEffects.Effects[ID].SpecialCheck ~= nil then
  486.         if GlowEffects.Effects[ID].SpecialCheck(role) == false then
  487.             return false
  488.         end
  489.     end
  490.     if (GlowEffects.Effects[ID].Slot ~= nil and GetItemID(GetChaItem ( role , 2 , GlowEffects.Effects[ID].Slot)) ~= GlowEffects.Effects[ID].ItemID ) then
  491.         return false
  492.     end
  493.     for i,v in pairs(GlowEffects.Effects[ID].Equips) do
  494.         if (GlowEffects.InArray (v , Equips[i]) == false or (FusedEquips[i] ~= 0 and GlowEffects.Effects[ID].AllowApparelGlow == false))
  495.         and (GlowEffects.Effects[ID].Fusable == false or GlowEffects.InArray (v , FusedEquips[i]) == false or (GlowEffects.Effects[ID].Apparels[i] ~=nil and GlowEffects.InArray (GlowEffects.Effects[ID].Apparels[i] , Equips[i]) == false )) then
  496.             return false
  497.         end
  498.     end
  499.     return true
  500. end
  501.  
  502. --function to remove all glows that the user does not meet the requirements for.
  503. function GlowEffects.RemoveGlows(role,States)
  504.     for i,v in pairs(GlowEffects.Effects) do
  505.         if GetChaStateLv ( role , v.State) > 0 and States[v.State] ~= true then
  506.             RemoveState ( role ,  v.State )
  507.         end
  508.     end
  509. end
  510.  
  511. --function to check if a data item is within an array
  512. function GlowEffects.InArray(array,str)
  513.     for i,v in pairs(array) do
  514.         if v == str then
  515.             return true
  516.         end
  517.     end
  518.     return false
  519. end
  520.  
  521. --returns a table of user equips
  522. function  GlowEffects.GetEquips(role)
  523.     return {
  524.         Head = GetItemID(GetEquipItemP(role,0)),
  525.         Armour = GetItemID(GetEquipItemP(role, 2)),
  526.         Gloves = GetItemID(GetEquipItemP(role,3)),
  527.         Boots = GetItemID(GetEquipItemP(role,4)),
  528.         Necklace = GetItemID(GetEquipItemP(role,5)),
  529.         LeftHand = GetItemID(GetEquipItemP(role,6)),
  530.         LeftRing = GetItemID(GetEquipItemP(role,7)),
  531.         RightRing = GetItemID(GetEquipItemP(role,8)),
  532.         RightHand = GetItemID(GetEquipItemP(role,9)),
  533.     }
  534. end
  535.  
  536. --returns a table of user equips fusion IDs
  537. function GlowEffects.GetFusedEquips(role)
  538.     return {
  539.         Head = GlowEffects.VerifyApparel(role, 0),
  540.         Armour = GlowEffects.VerifyApparel(role, 2),
  541.         Gloves = GlowEffects.VerifyApparel(role, 3),
  542.         Boots = GlowEffects.VerifyApparel(role, 4),
  543.         Necklace = GlowEffects.VerifyApparel(role, 5),
  544.         LeftHand = GlowEffects.VerifyApparel(role, 6),
  545.         LeftRing = GlowEffects.VerifyApparel(role, 7),
  546.         RightRing = GlowEffects.VerifyApparel(role, 8),
  547.         RightHand = GlowEffects.VerifyApparel(role, 9),
  548.     }
  549. end
  550.  
  551. --verifys if a slot is empty
  552. function GlowEffects.VerifyApparel(role, slot)
  553.     if GetItemID(GetEquipItemP(role,slot)) == 0 then
  554.         return 0
  555.     else
  556.         return GetItemAttr(GetEquipItemP(role,slot), ITEMATTR_VAL_FUSIONID)
  557.     end
  558. end
  559. --function called to check for kylin effect
  560. function GlowEffects.CheckKylin ( role )
  561.     return GlowEffects.CheckEffect(role,"Kylin")
  562. end
  563. --function called to check for BD effect
  564. function GlowEffects.CheckBlackDragon ( role )
  565.     return GlowEffects.CheckEffect(role,"BlackDragon")
  566. end
  567. --function called to check for Death effect
  568. function GlowEffects.CheckDeath ( role )
  569.     return GlowEffects.CheckEffect(role,"Death")
  570. end
  571. --function called to check for Chaos effect
  572. function GlowEffects.CheckChaos ( role )
  573.     return GlowEffects.CheckEffect(role,"Chaos")
  574. end
  575.  
  576. --iterates through table to check effects
  577. function GlowEffects.CheckEffect(role,effect)
  578.     if Is_NormalMonster ( role ) == 1 then
  579.         return 0
  580.     end
  581.     local PID = GetRoleID(role)
  582.     if GlowEffects.PlayerEffects[PID] == nil then
  583.         GlowEffects.CheckGlows(role)
  584.     end
  585.     if GlowEffects.PlayerEffects[PID][effect] ~= true then
  586.         return 0
  587.     else
  588.         return 1
  589.     end
  590. end
  591.  
  592. --Hooked on taking damage
  593. function GlowEffects.CheckGlows2(role,num)
  594.     if Is_NormalMonster ( role ) ~= 1 then
  595.         GlowEffects.CheckGlows(role)
  596.     end
  597. end
  598.  
  599.  
  600. --Hooks
  601. --Hook:AddPreHook("Hp_Endure_Dmg",GlowEffects.CheckGlows2) --Hook on taking damage to check states, not needed if you do not have effects that need a stone.
  602. Hook:AddPreHook("AttrRecheck",GlowEffects.CheckGlows) --Hook on updating stats to check states
  603. Hook:AddReplacementHook("CheckItem_Nianshou",GlowEffects.CheckKylin) --Hook to check kylin set
  604. Hook:AddReplacementHook("CheckItem_Heilong",GlowEffects.CheckBlackDragon) --Hook to check BD set
  605. Hook:AddReplacementHook("CheckItem_Death",GlowEffects.CheckDeath) --Hook to check Death set
  606. Hook:AddReplacementHook("CheckItem_fighting",GlowEffects.CheckChaos) --Hook to check Chaos set
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement