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

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

Закрытая тема
 
PiCkUpEr_AsT

offline
Опыт: 1,060
Активность:
Ошибка при сохранении Structs: (1) Is not a member of EquipmentSystem__Inventory
Это работало... я код не трогал, стоило поредактировать(дописать некоторые триггеры), которые не имеют вообще отношения к этому, как что то сломалось
library EquipmentSystem initializer Init

globals
     private constant integer inventoryid = 'h01N'        
     private constant integer itemclasses = 4    
     private constant integer mainhandclass = 1           
     private constant integer offhandclass = 2            
     private constant integer exitabi = 'A04P'            
     private constant integer openabi = 'A00G'              
     private constant string  no  =  " не может носить "     
     private constant integer TwohandedAbi = 0  
     private constant boolean DoubleIcon = true
     private integer array normalpic
endglobals

private function InitNormals takes nothing returns nothing // here you have to give an icon ability for every empty slot
    set normalpic[1] = 'A049'  
    set normalpic[2] = 'A048'
    set normalpic[3] = 'A04A'
    set normalpic[4] = 'A04B'    
    set normalpic[5] = 'A04D'
    set normalpic[6] = 'A04C'    
    set normalpic[7] = 'A04E'
    set normalpic[8] = 'A00L'
    set normalpic[9] = 'A00M'
endfunction

//--------------------------------------------------------
//---------------system code------------------------------
//--------------------------------------------------------

private struct Inventory
unit owner
unit u
string animtag = ""
integer array icon[12]
integer array effekt1[12]
integer array effekt2[12]
integer array effekt3[12]
integer array Item[12]
boolean array enabled[200]
endstruct

globals
     private integer items = 0
     private integer array itemm
     private integer array itemclass
     private integer array itemeffekt1
     private integer array itemeffekt2
     private integer array itemeffekt3
     private integer array itempic
     private boolean array twohand
     private string array tag
     private hashtable h = InitHashtable()
endglobals

function InitEquipment takes unit whichunit returns nothing
    local Inventory dat = Inventory.create()
    local integer i = 1
    local unit u = whichunit
    set dat.owner = u
    set dat.u = CreateUnit(GetOwningPlayer(dat.owner),inventoryid,GetUnitX(dat.owner),GetUnitY(dat.owner),0)
    call UnitAddAbility(dat.u,exitabi)
    call UnitAddAbility(dat.owner,openabi)
    loop
        exitwhen i > itemclasses
        call UnitAddAbility(dat.u,normalpic[i])
        set dat.icon[i] = normalpic[i]
        set dat.effekt1[i] = 0
        set dat.effekt2[i] = 0
        set dat.effekt3[i] = 0
        set dat.Item[i] = 0
        set i = i + 1
    endloop
    set i = 0
    loop
        exitwhen i > items
        set dat.enabled[i] = true
        set i = i + 1
    endloop
    call SaveInteger(h,GetHandleId(u),1,dat)
    call SaveInteger(h,GetHandleId(dat.u),1,dat)
    set u = null
endfunction

public function RegisterItem takes integer itemid, integer ability1,integer ability2,integer ability3, integer icon, integer class, boolean twohanded, string animation returns nothing
    set items = items + 1
    set itemm[items] = itemid
    set itemclass[items] = class
    set itemeffekt1[items] = ability1
    set itemeffekt2[items] = ability2
    set itemeffekt3[items] = ability3
    set itempic[items] = icon
    set tag[items] = animation
    if class == mainhandclass then
        set twohand[items] = twohanded
    else
        set twohand[items] = false
    endif
    call SaveInteger(h,itemid,1,items)
    call SaveInteger(h,icon,1,items)
endfunction

private function Equip takes unit u, item ite returns nothing
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    local integer id = GetItemTypeId(ite)
    local integer i = LoadInteger(h,id,1)
    local integer ii = LoadInteger(h,dat.Item[mainhandclass],1)
    local integer shield=0
    if GetItemLevel(ite)==6 then
    set shield=1
    else
    endif
    call RemoveItem(ite)
    if itemclass[i] == mainhandclass or itemclass[i] == offhandclass then     
        if twohand[i] or twohand[ii] then
            call UnitRemoveAbility(dat.u, dat.icon[offhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt1[offhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt2[offhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt3[offhandclass])
            call UnitAddAbility(dat.u, normalpic[offhandclass])
            call UnitAddItemById(dat.owner, dat.Item[offhandclass])
            set dat.icon[offhandclass] = normalpic[offhandclass]
            set dat.effekt1[offhandclass] = 0
            set dat.effekt2[offhandclass] = 0
            set dat.effekt3[offhandclass] = 0
            set dat.Item[offhandclass] = 0
            call UnitRemoveAbility(dat.u, dat.icon[mainhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt1[mainhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt2[mainhandclass])
            call UnitRemoveAbility(dat.owner, dat.effekt3[mainhandclass])
            call UnitAddItemById(dat.owner, dat.Item[mainhandclass])
            call UnitAddAbility(dat.u, normalpic[mainhandclass])
            set dat.icon[mainhandclass] = normalpic[mainhandclass]
            set dat.effekt1[mainhandclass] = 0
            set dat.effekt2[mainhandclass] = 0
            set dat.effekt3[mainhandclass] = 0
            set dat.Item[mainhandclass] = 0
        endif
        if DoubleIcon and twohand[i]then
            call UnitRemoveAbility(dat.u, dat.icon[offhandclass])
            call UnitAddAbility(dat.u, TwohandedAbi)
            set dat.icon[offhandclass] = TwohandedAbi
        endif
        if dat.Item[offhandclass] == 0 then
            call AddUnitAnimationProperties(dat.owner, dat.animtag, false)
            call AddUnitAnimationProperties(dat.owner, tag[i], true)
            set dat.animtag = tag[i]
        endif
        if shield==1 then
        call SetPlayerAbilityAvailable(GetOwningPlayer(dat.owner),itemeffekt3[i],false)
        endif
    endif    
    call UnitRemoveAbility(dat.u, dat.icon[itemclass[i]])
    call UnitRemoveAbility(dat.owner, dat.effekt1[itemclass[i]])
    call UnitRemoveAbility(dat.owner, dat.effekt2[itemclass[i]])
    call UnitRemoveAbility(dat.owner, dat.effekt3[itemclass[i]])
    call UnitAddItemById(dat.owner, dat.Item[itemclass[i]])
    call UnitAddAbility(dat.owner, itemeffekt1[i])
    call UnitAddAbility(dat.owner, itemeffekt2[i])
    call UnitAddAbility(dat.owner, itemeffekt3[i])
    //
    
    //
    call UnitAddAbility(dat.u, itempic[i])
    set dat.icon[itemclass[i]] = itempic[i]
    set dat.effekt1[itemclass[i]] = itemeffekt1[i]
    set dat.effekt2[itemclass[i]] = itemeffekt2[i]
    set dat.effekt3[itemclass[i]] = itemeffekt3[i]
    set dat.Item[itemclass[i]] = itemm[i]
endfunction

private function check takes nothing returns boolean
    return LoadInteger(h,GetItemTypeId(GetManipulatedItem()),1) != 0
endfunction

private function access takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    local integer i = LoadInteger(h,GetSpellAbilityId(),1)
    if (GetSpellAbilityId() == exitabi) then
        call SelectUnitForPlayerSingle(dat.owner, GetOwningPlayer(dat.owner))
    elseif (GetSpellAbilityId() == openabi) then
        set dat = LoadInteger(h,GetHandleId(u),1)
        call SelectUnitForPlayerSingle(dat.u, GetOwningPlayer(dat.u))
    elseif GetUnitTypeId(u) == inventoryid then
        call UnitRemoveAbility(dat.u, dat.icon[itemclass[i]])
        call UnitRemoveAbility(dat.owner, dat.effekt1[itemclass[i]])
        call UnitRemoveAbility(dat.owner, dat.effekt2[itemclass[i]])
        call UnitRemoveAbility(dat.owner, dat.effekt3[itemclass[i]])
        call UnitAddItemById(dat.owner, dat.Item[itemclass[i]])
        call UnitAddAbility(dat.u,normalpic[itemclass[i]])
        set dat.icon[itemclass[i]] = normalpic[itemclass[i]]
        set dat.effekt1[itemclass[i]] = 0
        set dat.effekt2[itemclass[i]] = 0
        set dat.effekt3[itemclass[i]] = 0
        set dat.Item[itemclass[i]] = 0
        if twohand[i] == true then
            call UnitAddAbility(dat.u,normalpic[offhandclass])
            set dat.icon[offhandclass] = normalpic[offhandclass]
            call UnitRemoveAbility(dat.u,TwohandedAbi)
        endif
        if itemclass[i] == mainhandclass and dat.Item[offhandclass] == 0 then
            call AddUnitAnimationProperties(dat.owner, dat.animtag, false)
            set dat.animtag = ""
        elseif itemclass[i] == offhandclass then
            call AddUnitAnimationProperties(dat.owner, dat.animtag, false)
            call AddUnitAnimationProperties(dat.owner, tag[LoadInteger(h,dat.Item[mainhandclass],1)], true)
            set dat.animtag = tag[LoadInteger(h,dat.Item[mainhandclass],1)]
        endif
    endif
    set u = null
endfunction

function TransferEquipment takes unit a, unit b returns nothing
    local integer i = 1
    local Inventory dat = LoadInteger(h,GetHandleId(a),1)
    loop
        exitwhen i > itemclasses 
        call UnitRemoveAbility(a,itemeffekt1[LoadInteger(h,dat.Item[i],1)])
        call UnitAddAbility(b,itemeffekt1[LoadInteger(h,dat.Item[i],1)])
        call UnitRemoveAbility(a,itemeffekt2[LoadInteger(h,dat.Item[i],1)])
        call UnitAddAbility(b,itemeffekt2[LoadInteger(h,dat.Item[i],1)])
        call UnitRemoveAbility(a,itemeffekt3[LoadInteger(h,dat.Item[i],1)])
        call UnitAddAbility(b,itemeffekt3[LoadInteger(h,dat.Item[i],1)])
        set i = i + 1
    endloop
    call SaveInteger(h,GetHandleId(b),1,dat)
    set dat.owner = b
    call UnitAddAbility(b,openabi)
    call UnitRemoveAbility(a,openabi)
    call AddUnitAnimationProperties(a, dat.animtag, false)
    call AddUnitAnimationProperties(b, dat.animtag, true)
endfunction

function IsEquipmentClassEmpty takes unit u, integer class returns boolean
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    return dat.icon[class] == normalpic[class]
endfunction

function GetEquipItemID takes unit u, integer class returns integer
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    return dat.Item[class]
endfunction

function GetItemIndex takes item ite returns integer
    return LoadInteger(h,GetItemTypeId(ite),1)
endfunction

function EnableItemEquipByID takes unit u, integer id, boolean flag returns nothing
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    set dat.enabled[LoadInteger(h,id,1)] = flag
endfunction

function EnableItemEquipByIndex takes unit u, integer index, boolean flag returns nothing
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    set dat.enabled[index] = flag
endfunction

function GetEquipItemIndex takes unit u, integer class returns integer
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    return LoadInteger(h,dat.Item[class],1)
endfunction

function EquipItemByID takes unit u, integer id returns nothing
    call Equip(u,CreateItem(id,0,0))
endfunction

function EquipItemByIndex takes unit u, integer index returns nothing
    call Equip(u,CreateItem(itemm[index],0,0))
endfunction

private function Itemequip takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local item ite = GetManipulatedItem()
    local integer i = LoadInteger(h,GetItemTypeId(ite),1)
    local Inventory dat = LoadInteger(h,GetHandleId(u),1)
    if GetItemLevel(ite) == 1 then
        if GetUnitTypeId(u) == 'Edem' or GetUnitTypeId(u) == 'Ogrh' or GetUnitTypeId(u) == 'Udre' then
        call Equip(u,ite)
        else
        call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
        endif
    elseif GetItemLevel(ite) == 2 then
        if GetUnitTypeId(u) == 'Edem' or GetUnitTypeId(u) == 'Ogrh' then
        call Equip(u,ite)
        else
        call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
        endif
    elseif GetItemLevel(ite) == 3 then
        if GetUnitTypeId(u) == 'Emoo' then
        call Equip(u,ite)
        else
        call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
        endif
        //    else dat.enabled[LoadInteger(h,GetItemTypeId(ite),1)]
    elseif GetItemLevel(ite) == 4 then
        if GetUnitTypeId(u) == 'Ekee' or GetUnitTypeId(u) == 'Uwar' then
        call Equip(u,ite)
        else
        call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
        endif
    elseif GetItemLevel(ite) == 5 then
       if GetUnitTypeId(u) == 'Ogrh' or GetUnitTypeId(u) == 'Udre' then
       call Equip(u,ite)
       else
       call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
       endif
    elseif GetItemLevel(ite) == 6 then
       if GetUnitTypeId(u) == 'Ogrh' or GetUnitTypeId(u) == 'Udre' then
       call Equip(u,ite)
       else
       call DisplayTextToPlayer(GetOwningPlayer(u), 0, 0, GetUnitName(u) + no + GetItemName(ite))
       endif
    else
       call Equip(u,ite)
    endif
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Itemequip)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition(t, Condition(function check))
          
    set t = CreateTrigger()
    call TriggerAddAction(t, function access)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_CAST )
    
    call InitNormals()
endfunction

endlibrary
Этот текст был показан в в JassHelper'e:
struct EquipmentSystem___Inventory
unit owner
unit u
string animtag = ""
integer array icon[12]
integer array effekt1[12]
integer array effekt2[12]
integer array effekt3[12]
integer array Item[12]
boolean array enabled[200]
endstruct

function InitEquipment takes unit whichunit returns nothing
    local EquipmentSystem___Inventory dat = EquipmentSystem___Inventory.create()
    local integer i = 1
    local unit u = whichunit
    set dat.owner = u
    set dat.u = CreateUnit(GetOwningPlayer(dat.owner),EquipmentSystem___inventoryid,GetUnitX(dat.owner),GetUnitY(dat​.owner),0)

Отредактировано ScorpioT1000, 07.11.2010 в 11:19.
Старый 07.11.2010, 11:05
Doc

offline
Опыт: 63,163
Активность:
PiCkUpEr_AsT, во первых xgm.ru/forum/showthread.php?t=27186
во вторых укажи на какой строчке ошибка.
Старый 07.11.2010, 11:11
PiCkUpEr_AsT

offline
Опыт: 1,060
Активность:
на этой строчке:local EquipmentSystem___Inventory dat = EquipmentSystem___Inventory.create(), пишет: (1) Is not a member of EquipmentSystem__Inventory
Старый 07.11.2010, 12:50
Doc

offline
Опыт: 63,163
Активность:
PiCkUpEr_AsT, попробуй убрать private чтоли, не знаю даже.
Старый 07.11.2010, 12:58
PiCkUpEr_AsT

offline
Опыт: 1,060
Активность:
Убрал... то же самое пишет...
PiCkUpEr_AsT добавил:
ну кто-нибудь помогите, вроде всё правильно... работало же раньше... я вообще не прикасался к этому коду... т.е. может ошибка извне, но стоило стереть эту систему, как карта сохранилась без ошибок... вообще шок
Старый 07.11.2010, 17:54
PiCkUpEr_AsT

offline
Опыт: 1,060
Активность:
Все. Проблема решена
оказывается я создал функцию которая называется "create", из за этого он запутался
Урок: Используя структуры не создавать функцию которая называлась бы "create"
Старый 07.11.2010, 20:56
Hellfim
Новичок
offline
Опыт: 79,707
Активность:
PiCkUpEr_AsT, не не создавать, а правильно с ней работать =) Это просто системное название для функции, создающей структуру, она может принимать какие-нибудь параметры и должна возвращать структуру.
Закрыто.
Старый 07.11.2010, 20:58
ScorpioT1000
Работаем
offline
Опыт: отключен
без креэйта нет наследования =( они вобще крабы так называть функции
Старый 07.11.2010, 21:30
Закрытая тема

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

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

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

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



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