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

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

Ответ
 
PiCkUpEr_AsT

offline
Опыт: 1,060
Активность:
Дуэль система не работает помогите
вот весь код
ошибка в функции startduel (расписано место)

Код:
library duel

function dueltimer takes nothing returns nothing
local timer time=GetExpiredTimer()
local integer table=GetHandleId(time)
local integer i=LoadInteger(udg_h,table,1)
local unit u1=LoadUnitHandle(udg_h,table,2)
local unit u2=LoadUnitHandle(udg_h,table,3)
set udg_timertores[989]=table
if i==0 then
call DisplayTimedTextToForce(GetPlayersAll(),4.00,"|cFFFF0000F I G H T!!!")
call UnitResetCooldown(u1)
call UnitResetCooldown(u2)
call PauseUnit(u1,false)
call PauseUnit(u2,false)
call DestroyTimer(time)
call EnableTrigger( gg_trg_Duel_End )
else
set i=i-1
call DisplayTimedTextToForce(GetPlayersAll(),5.00,"|cFFA000FFПоединок начнется через "+"|cffffcc00"+I2S(i)+" |cFFA000FF...")
call SaveInteger(udg_h,table,1,i)
endif
endfunction

function startduel takes nothing returns nothing
local timer time=GetExpiredTimer()
local integer table=GetHandleId(time)
local timerdialog td=LoadTimerDialogHandle(udg_h,table,0)
call DestroyTimerDialog(td)
call FlushChildHashtable(udg_h,table)
call DestroyTimer(time)
set udg_timertores[987]=udg_timertores[987]+1
if udg_timertores[987]<=udg_timertores[988] then
set time=CreateTimer()
set table=GetHandleId(time)
call SaveInteger(udg_h,table,1,6)
call SaveUnitHandle(udg_h,table,2,udg_player_hero[udg_timertores[997+udg_timertores[987]]])
call SaveUnitHandle(udg_h,table,3,udg_player_hero[udg_timertores[998+udg_timertores[987]]])
call PauseUnit(udg_player_hero[udg_timertores[9980+udg_timertores[987]]],true)
call PauseUnit(udg_player_hero[udg_timertores[9970+udg_timertores[987]]],true)
call SetUnitPositionLoc(udg_player_hero[udg_timertores[9970+udg_timertores[987]]],GetRectCenter(gg_rct_3_Down) )
call SetUnitPositionLoc(udg_player_hero[udg_timertores[9980+udg_timertores[987]]],GetRectCenter(gg_rct_3_Up) )
call PanCameraToTimedLocForPlayer(GetOwningPlayer(udg_player_hero[udg_timertores[9970+udg_timertores[987]]]),GetRectCenter(gg_rct_3_Down), .0 )
call PanCameraToTimedLocForPlayer(GetOwningPlayer(udg_player_hero[udg_timertores[9980+udg_timertores[987]]]),GetRectCenter(gg_rct_3_Up), .0 )
call SetPlayerAllianceStateBJ(GetOwningPlayer(udg_player_hero[udg_timertores[9970+udg_timertores[987]]]),GetOwningPlayer(udg_player_hero[udg_timertores[9980+udg_timertores[987]]]), bj_ALLIANCE_UNALLIED )
call SetPlayerAllianceStateBJ(GetOwningPlayer(udg_player_hero[udg_timertores[9980+udg_timertores[987]]]),GetOwningPlayer(udg_player_hero[udg_timertores[9970+udg_timertores[987]]]), bj_ALLIANCE_UNALLIED )
call DisplayTimedTextToPlayer(Player(0),.0,.0,5.0,"udg_timertores[987]="+I2S(udg_timertores[987])+" / "+"udg_timertores[9970+987]="+I2S(udg_timertores[9970+udg_timertores[987]])+" / "+"udg_timertores[9981]="+I2S(udg_timertores[9981]))
//Вот тут выводит мне мессадж: udg_timertores[987]=1 / udg_timertores[9970+987]=0 / udg_timertores[9981]=0
//Эти переменные остаются нулями
call TimerStart(time,1.0,true,function dueltimer)
endif
endfunction

function startduelspreparetimer takes nothing returns nothing
local timer time=CreateTimer()
local integer table=GetHandleId(time)
local timerdialog td=CreateTimerDialog(time)
call SaveTimerDialogHandle(udg_h,table,0,td)
call TimerDialogSetTitle(td,"|cff00dd00Дуэль: ")
call TimerDialogDisplay(td,true)
call TimerStart(time,30.0,false,function startduel)
endfunction

//тут механика принятия или отказа, путем выделения 2ого или третьего героя соответственно. Проблема либо тут либо в следующем шаге ( после таймера)

function accept_decline takes nothing returns nothing
local integer i=GetHandleId(GetTriggerPlayer())
local integer i2=1
local player p=LoadPlayerHandle(udg_h,i,0)
if GetUnitTypeId(GetTriggerUnit()) == 'H01L' then
call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+" Принимает вызов, брошенный игроком "+ GetPlayerName(p))
call CreateUnitAtLoc(p,'hpea',GetRectCenter(gg_rct_start),.0)
call RemoveUnit(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'H01  K')))
call RemoveUnit(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'H01  L')))
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 3
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
 if udg_timertores[9970+i2]==0 then
set udg_timertores[9970+i2]=GetPlayerId(GetTriggerPlayer())+1
set udg_timertores[9980+i2]=GetPlayerId(p)+1
call DisplayTextToForce(GetPlayersAll(),"Бой между "+GetPlayerName(GetTriggerPlayer())+" и "+ GetPlayerName(p)+" записан в очередь под номером: "+I2S(bj_forLoopAIndex))
call SetPlayerState(Player(12),PLAYER_STATE_RESOURCE_HERO_TOKENS,GetPlayerState(Playe  r(12),PLAYER_STATE_RESOURCE_HERO_TOKENS)-2)
set udg_timertores[988]=udg_timertores[988]+1
if GetPlayerState(Player(12),PLAYER_STATE_RESOURCE_HERO_TOKENS)<=1 then
call DisplayTextToForce( GetPlayersAll(), "Набор заявок для дуэлей завершён." )
call startduelspreparetimer()
set bj_forLoopAIndex = 5
else
endif

//
set bj_forLoopBIndex = 0
set bj_forLoopBIndexEnd = 7
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd 
call RemoveItemFromStock(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(Player(bj_forL  oopBIndex), 'hpea')),udg_item_spell[100+udg_timertores[9980+bj_forLoopAIndex]])
call RemoveItemFromStock(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(Player(bj_forL  oopBIndex), 'hpea')),udg_item_spell[100+udg_timertores[9980+2*bj_forLoopAIndex]])
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
else
//
set i2=i2+1
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endif
endloop

elseif GetUnitTypeId(GetTriggerUnit()) == 'H01K' then
call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+" He принимает вызов, брошенный игроком "+ GetPlayerName(p))
set udg_timertores[990+GetPlayerId(GetTriggerPlayer())] = 0
set udg_timertores[990+GetPlayerId(p)] = 0
call CreateUnitAtLoc(GetTriggerPlayer(),'hpea',GetRectCenter(gg_rct_start),.0)
call RemoveUnit(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'H01  K')))
call RemoveUnit(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(),'H01  L')))
endif
call FlushChildHashtable(udg_h,i)
endfunction

function duel_Conditions takes nothing returns boolean
return GetItemTypeId(GetManipulatedItem()) != udg_item_spell[100+GetPlayerId(GetTriggerPlayer())]
endfunction


function duel_Actions takes nothing returns nothing
local trigger t
local integer i
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 7
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd 
if GetItemTypeId(GetManipulatedItem()) == udg_item_spell[100+bj_forLoopAIndex] and GetPlayerSlotState(Player(bj_forLoopAIndex)) == PLAYER_SLOT_STATE_PLAYING and udg_timertores[990+bj_forLoopAIndex] == 0 then
set i=GetHandleId(Player(bj_forLoopAIndex))
call SavePlayerHandle(udg_h,i,0,GetTriggerPlayer())
call DisplayTimedTextToPlayer(Player(bj_forLoopAIndex),.0,.0,5,GetPlayerName(GetTrigg  erPlayer())+" |c006699CCПредлагает вам дуэль. Чтобы принять, нажмите: |c006699CCF2|r, чтобы отказаться: |c006699CCF3|r.")
set udg_timertores[990+GetPlayerId(GetTriggerPlayer())] = 1
set udg_timertores[990+bj_forLoopAIndex] = 1
call DisplayTextToForce(GetPlayersAll(),GetPlayerName(GetTriggerPlayer())+" бросает вызов игроку "+ GetPlayerName(Player(bj_forLoopAIndex)))
call RemoveUnit(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(Player(bj_forLoopAIndex  ),'hpea')))
call CreateUnitAtLoc(Player(bj_forLoopAIndex),'H01L',GetRectCenter(gg_rct_start),.0)
call CreateUnitAtLoc(Player(bj_forLoopAIndex),'H01K',GetRectCenter(gg_rct_start),.0)
set t=CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t, Player(bj_forLoopAIndex),EVENT_PLAYER_UNIT_SELECTED, null)
call TriggerAddAction(t, function accept_decline )
elseif GetItemTypeId(GetManipulatedItem()) == udg_item_spell[100+bj_forLoopAIndex] and GetPlayerSlotState(Player(bj_forLoopAIndex)) == PLAYER_SLOT_STATE_PLAYING and udg_timertores[990+bj_forLoopAIndex] == 1 then
call DisplayTimedTextToPlayer(GetTriggerPlayer(),.0,.0,5,"Этому игроку уже бросили вызов, либо он сам бросил вызов. Повторите попытку позднее или выберите другого игрока.")
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction

//эта функция вызывается по истечении таймера. Создается юнит hpea, у который продаёт 8 предметов, каждый предмет привязан к своему игроку. Когда игрок покупает предмет, то он предлагает дуэль тому, чей предмет купил

function duel takes nothing returns nothing
local trigger t
local unit u
local timer time=GetExpiredTimer()
local integer table=GetHandleId(time)
local timerdialog td=LoadTimerDialogHandle(udg_h,table,0)
call DestroyTimerDialog(td)
call FlushChildHashtable(udg_h,table)
call DestroyTimer(time)
set udg_level=udg_level+1
//
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 7
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if GetPlayerSlotState(Player(bj_forLoopAIndex)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(bj_forLoopAIndex)) == MAP_CONTROL_USER then
        call SetPlayerState(Player(12),PLAYER_STATE_RESOURCE_HERO_TOKENS,GetPlayerState(Playe  r(12),PLAYER_STATE_RESOURCE_HERO_TOKENS)+1)
        endif
        if GetPlayerSlotState(Player(bj_forLoopAIndex)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(bj_forLoopAIndex)) == MAP_CONTROL_USER then
        set u=CreateUnitAtLoc(Player(bj_forLoopAIndex),'hpea',GetRectCenter(gg_rct_start),.0  )
        call DisplayTimedTextToPlayer(Player(bj_forLoopAIndex),.0,.0,20,"Время для дуэли. Выберите себе желаемого противника. (Снизу слева появился значок рабочего)")
        call SelectUnitForPlayerSingle(u,Player(bj_forLoopAIndex))
set bj_forLoopBIndex = 0
set bj_forLoopBIndexEnd = 7
    loop
        exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd        
        call AddItemToStock(u,udg_item_spell[100+bj_forLoopAIndex],1,1)
        call RemoveItemFromStock(GroupPickRandomUnit(GetUnitsOfPlayerAndTypeId(Player(bj_forL  oopAIndex), 'hpea')),udg_item_spell[100+bj_forLoopAIndex])
        set bj_forLoopBIndex = bj_forLoopBIndex + 1
    endloop
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
//
set t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition(t, Condition( function duel_Conditions ) )
call TriggerAddAction(t, function duel_Actions )
set t=null
set u=null
endfunction
endlibrary

Отредактировано PiCkUpEr_AsT, 11.09.2010 в 19:42.
Старый 11.09.2010, 19:35
Elf_Stratigo

offline
Опыт: 4,699
Активность:
udg_timertores[9970+i2]==0
constant integer JASS_MAX_ARRAY_SIZE = 8192
Старый 11.09.2010, 21:04
bee
vjass.optimizer
offline
Опыт: 16,615
Активность:
...и функция duel не будет вызываться сама собой. К строке library duel подпиши initializer duel
Старый 11.09.2010, 22:59
ScorpioT1000
Работаем
offline
Опыт: отключен
constant integer JASS_MAX_ARRAY_SIZE = 1024
не хочешь?)
Старый 12.09.2010, 00:48
Sergarr

offline
Опыт: 4,677
Активность:
ScorpioT1000, втф вроде же всегда в массив в варе можно было запихнуть 8196 значений?
Старый 12.09.2010, 00:52
Doc

offline
Опыт: 63,163
Активность:
Только они вроде не сэйвятся при сохранении игры или чтото такое, но запихнуть можно, да.
Старый 12.09.2010, 01:12
Ответ

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

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

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

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



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