XGM Forum
Сайт - Статьи - Проекты - Ресурсы - Блоги

Форуме в режиме ТОЛЬКО ЧТЕНИЕ. Вы можете задать вопросы в Q/A на сайте, либо создать свой проект или ресурс.
Вернуться   XGM Forum > Warcraft> Академия: форум для вопросов> Jass
Ник
Пароль
Войти через VK в один клик
Сайт использует только имя.

Ответ
 
tgonta
Pixelated Sora Coder
offline
Опыт: 3,160
Активность:
Развёртка BJ с предметом
Просьба подсказать, как мне развернуть здесь GetInventoryIndexOfItemTypeBJ? Она может оставить прилично мусора от необнулённых предметов.
function WhiteRing_Conditions takes nothing returns boolean
    return (GetItemTypeId(GetManipulatedItem())=='I030' or GetItemTypeId(GetManipulatedItem())=='I02F') and (UnitHasItemOfTypeBJ(GetManipulatingUnit(),'I02F') and UnitHasItemOfTypeBJ(GetManipulatingUnit(),'I030'))
endfunction

function WhiteRing_Actions takes nothing returns nothing
    call RemoveItem(GetItemOfTypeFromUnitBJ(GetManipulatingUnit(),'I02F'))
    call RemoveItem(GetItemOfTypeFromUnitBJ(GetManipulatingUnit(),'I030'))
    call UnitAddItemById(GetManipulatingUnit(),'I02V')
    if IsUnitAlly(GetTriggerUnit(),Player(10)) then
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.md​l",GetManipulatingUnit(),"origin"))
    else
        call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl"​;,GetManipulatingUnit(),"origin"))
    endif
endfunction

//===========================================================================
function InitTrig_WhiteRing takes nothing returns nothing
    local trigger WhiteRing = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(WhiteRing,EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(WhiteRing,Condition(function WhiteRing_Conditions))
    call TriggerAddAction(WhiteRing,function WhiteRing_Actions)
    set WhiteRing = null
endfunction
Старый 08.01.2010, 16:15
avatarDr
Neophyte
offline
Опыт: 6,474
Активность:
Вроде ф-ия ничего не создаёт, так что достаточно просто обнулить item indexItem.
А что вернёт функция, если будут 2 одинаковых предмета?
И где сама ф-ия? Я что-то не могу её найти.
Старый 08.01.2010, 18:30
tgonta
Pixelated Sora Coder
offline
Опыт: 3,160
Активность:
function GetItemOfTypeFromUnitBJ takes unit whichUnit, integer itemId returns item
    local integer index = GetInventoryIndexOfItemTypeBJ(whichUnit, itemId)

    if (index == 0) then
        return null
    else
        return UnitItemInSlot(whichUnit, index - 1)
    endif
endfunction

function GetInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer
    local integer index
    local item    indexItem

    set index = 0
    loop
        set indexItem = UnitItemInSlot(whichUnit, index)
        if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
            return index + 1
        endif

        set index = index + 1
        exitwhen index >= bj_MAX_INVENTORY
    endloop
    return 0
endfunction
Старый 08.01.2010, 18:45
ShadoW DaemoN

offline
Опыт: 37,078
Активность:
// вариант 1
function UnitItemInSlot takes unit u, integer id returns integer
  local integer i = 0
  loop
    if GetItemTypeId(UnitItemInSlot(u, i)) == id then
      return i
    endif
    set i = i + 1
    exitwhen i > 5
  endloop
  return 0
endfunction

// вариант 2
function UnitItemInSlot takes unit u, integer id returns integer
  if GetItemTypeId(UnitItemInSlot(u, 0)) == id then
    return 0
  elseif GetItemTypeId(UnitItemInSlot(u, 1)) == id then
    return 1
  elseif GetItemTypeId(UnitItemInSlot(u, 2)) == id then
    return 2
  elseif GetItemTypeId(UnitItemInSlot(u, 3)) == id then
    return 3
  elseif GetItemTypeId(UnitItemInSlot(u, 4)) == id then
    return 4
  elseif GetItemTypeId(UnitItemInSlot(u, 5)) == id then
    return 5
  endif
  return 0
endfunction
Старый 08.01.2010, 18:56
Ответ

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы можете скачивать файлы

BB-коды Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход



Часовой пояс GMT +3, время: 18:31.