Jump to content
Darling

Проигрывание эффектов при использовании предмета

Recommended Posts

Вопрос: Зачем это нужно?
Ответ: Красиво. Так же все будут видеть какой игрок открыл тот или иной сундук (к примеру).

Установка:
Я буду привязывать эффект к сундуку из Мира демонов, находим функцию в ItemEffect.lua

-- Сундук из Мира демонов (ID 3424)
function ItemUse_MFBX ( role , Item )
    local item_type = BaoXiang_MFBX
    local item_type_rad = BaoXiang_MFBX_Rad
    local item_type_count = BaoXiang_MFBX_Count
    local maxitem = BaoXiang_MFBX_Mxcount
    local item_quality = BaoXiang_MFBX_Qua
    local General = 0  
    local ItemId = 0
   
    local Item_CanGet = GetChaFreeBagGridNum ( role )
   
    if Item_CanGet <= 0 then
        SystemNotice(role ,"\205\229\228\238\241\242\224\242\238\247\237\238 \236\229\241\242\224 \226 \232\237\226\229\237\242\224\240\229. \205\229\226\238\231\236\238\230\237\238 \238\242\234\240\251\242\252 \241\243\237\228\243\234")
        --SystemNotice(role ,"Недостаточно места в инвентаре. Невозможно открыть сундук")
        --SystemNotice(role ,"Insufficient space in inventory. Unable to open chest"
        UseItemFailed ( role )
        return
    end
    for i = 1 , maxitem , 1 do
        General = item_type_rad [ i ] + General    
    end
    local a = math.random ( 1, General )
    local b = 0
    local d = 0
    local c = -1
    for k = 1 , maxitem , 1 do
 
        d = item_type_rad [ k ] + b
 
         if a <= d and a > b then
            c = k
            break
        end
        b = d
    end
    if c == -1 then
        ItemId = 3124
    else
        ItemId = item_type [c]  
        ItemCount = item_type_count [c]
    end
    GiveItem ( role , 0 , ItemId , ItemCount , item_quality )
    local itemname = GetItemName ( ItemId )
    local cha_name = GetChaDefaultName ( role )
    local message = cha_name.." \238\242\234\240\251\226\224\229\242 \241\243\237\228\243\234 \241 \241\238\234\240\238\226\232\249\224\236\232 \232 \239\238\235\243\247\224\229\242   "..itemname  
    --local message = cha_name.." открывает сундук с сокровищами и получает   "..itemname
    --local message = cha_name.." opens a treasure chest and obtained   "..itemname  
    Notice ( message )
end

И в конце скрипта дописываем следующие:
 

 -- Эффект при открытии сундука
    local effect = 361              -- ID эффекта из sceneffectinfo.txt
    PlayEffect (role, effect )      -- Заставляем проигрывать эффект при открытии сундука

Общая картина скрипта после привязки эффекта такова:

Цитата

-- Сундук из Мира демонов (ID 3424)
function ItemUse_MFBX ( role , Item )
    local item_type = BaoXiang_MFBX
    local item_type_rad = BaoXiang_MFBX_Rad
    local item_type_count = BaoXiang_MFBX_Count
    local maxitem = BaoXiang_MFBX_Mxcount
    local item_quality = BaoXiang_MFBX_Qua
    local General = 0  
    local ItemId = 0
   
    local Item_CanGet = GetChaFreeBagGridNum ( role )
   
    if Item_CanGet <= 0 then
        SystemNotice(role ,"\205\229\228\238\241\242\224\242\238\247\237\238 \236\229\241\242\224 \226 \232\237\226\229\237\242\224\240\229. \205\229\226\238\231\236\238\230\237\238 \238\242\234\240\251\242\252 \241\243\237\228\243\234")
        --SystemNotice(role ,"Недостаточно места в инвентаре. Невозможно открыть сундук")
        --SystemNotice(role ,"Insufficient space in inventory. Unable to open chest"
        UseItemFailed ( role )
        return
    end
    for i = 1 , maxitem , 1 do
        General = item_type_rad [ i ] + General    
    end
    local a = math.random ( 1, General )
    local b = 0
    local d = 0
    local c = -1
    for k = 1 , maxitem , 1 do
 
        d = item_type_rad [ k ] + b
 
         if a <= d and a > b then
            c = k
            break
        end
        b = d
    end
    if c == -1 then
        ItemId = 3124
    else
        ItemId = item_type [c]  
        ItemCount = item_type_count [c]
    end
    GiveItem ( role , 0 , ItemId , ItemCount , item_quality )
    local itemname = GetItemName ( ItemId )
    local cha_name = GetChaDefaultName ( role )
    local message = cha_name.." \238\242\234\240\251\226\224\229\242 \241\243\237\228\243\234 \241 \241\238\234\240\238\226\232\249\224\236\232 \232 \239\238\235\243\247\224\229\242   "..itemname  
    --local message = cha_name.." открывает сундук с сокровищами и получает   "..itemname
    --local message = cha_name.." opens a treasure chest and obtained   "..itemname  
    Notice ( message )
   
    -- Эффект при открытии сундука
    local effect = 361              -- ID эффекта из sceneffectinfo.txt
    PlayEffect (role, effect )      -- Заставляем проигрывать эффект при открытии сундука
end

P.S для раскодирования строк типа "\205\229\228\238\241\242\224\242\238\247\237\238 \236\229\241\242\224 \226 \232\237\226\229\237\242\224\240\229. \205\229\226\238\231\236\238\230\237\238 \238\242\234\240\251\242\252 \241\243\237\228\243\234"

используйте кодировщик "ТЫК"

Гайд By exc1usive - @e1mer

 

Edited by ϟAlсаtrаzϟ
  • Like 1

logo.gif.7a6bf573c184aefe07085780c554cb7b.gifimage.png.b1bdb87cf81127fc757c39aa04ca5385.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...