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

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

Ответ
 
DeT

offline
Опыт: 5,715
Активность:
Проблема
Собственно небольшая респаун системка....код не рбаотает как я задумывал...пасматрите плиз.

карт в аттаче код внизу

» Код системы

Код:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function H2S takes handle h returns string
    return I2S(H2I(h))
endfunction

function SetHandleInt takes handle obj,string key, integer value returns nothing
    call StoreInteger(udg_cache,H2S(obj),key,value)
endfunction

function SetHandleReal takes handle obj,string key, real value returns nothing
    call StoreReal(udg_cache,H2S(obj),key,value)
endfunction

function SetHandleString takes handle obj,string key, string value returns nothing
    call StoreString(udg_cache,H2S(obj),key,value)
endfunction

function GetHandleInt takes handle obj,string key returns integer
    return GetStoredInteger(udg_cache,H2S(obj),key)
endfunction

function GetHandleReal takes handle obj,string key returns real
    return GetStoredReal(udg_cache,H2S(obj),key)
endfunction

function GetHandleString takes handle obj,string key returns string
    return GetStoredString(udg_cache,H2S(obj),key)
endfunction

function FlushHandle takes handle obj returns nothing
    call FlushStoredMission(udg_cache,H2S(obj))
endfunction
/***************************************
function RS_CreateUnit takes integer UT_ID, integer time, location loc, integer pnumber returns unit
    local unit a = CreateUnitAtLoc(Player(pnumber), UT_ID,loc, GetRandomReal(0.00,360.00) )
    call SetHandleInt(a,"Dtime", time)
    call SetHandleReal(a,"LocX", GetLocationX(loc))
    call SetHandleReal(a,"LocY", GetLocationY(loc))
    return a
endfunction

function RS_D_Condition takes nothing returns boolean
    local unit a = GetDyingUnit()
    local boolean b = false
    set b = (GetUnitTypeId(a) == GetHandleInt(a,I2S(GetUnitTypeId(a ))) )
    set a =null
    return b
endfunction

function RS_D_Action takes nothing returns nothing
    call DisplayTextToPlayer(Player(0),0.00,0.00,"Our unit is dead")
    call SetHandleInt(GetDyingUnit(),"Time",GetHandleInt(GetDyingUnit(),"Dtime") )
    set udg_RS_Count=udg_RS_Count+1
    set udg_RS_UTypes[udg_RS_Count] = GetDyingUnit()
    call SetHandleInt(GetLastCreatedUnit(),"Time", GetHandleInt(GetLastCreatedUnit(),"Dtime"))
endfunction

function RS_T_Condition takes nothing returns boolean
    return udg_RS_Count>=1
endfunction

function RS_T_Action takes nothing returns nothing
    local integer a = 0
    loop
    exitwhen a>udg_RS_Count
        if GetHandleInt(udg_RS_UTypes[a],"Time")>0 then
            call SetHandleInt(udg_RS_UTypes[a],"Time",GetHandleInt(udg_RS_UTypes[a],"Time")-1)
        else
            call RS_CreateUnit(GetUnitTypeId(udg_RS_UTypes[a]),GetHandleInt(udg_RS_UTypes[a],"Dtime"),Location(GetHandleReal(udg_RS_UTypes[a],"LocX"),GetHandleReal(udg_RS_UTypes[a],"LocY")),GetPlayerId(GetOwningPlayer(udg_RS_UTypes[a]) ) )
            call FlushHandle(udg_RS_UTypes[a]) 
            call RemoveUnit(udg_RS_UTypes[a])
            set udg_RS_UTypes[a]=udg_RS_UTypes[udg_RS_Count]
            set udg_RS_UTypes[udg_RS_Count]=null
            set udg_RS_Count=udg_RS_Count-1
        endif
    endloop
endfunction

function RS_AddUClasses takes unit ut returns nothing
    call SetHandleInt(udg_RS_UTypes[2000],I2S(GetUnitTypeId(ut)),GetUnitTypeId(ut) )
endfunction

function RS_AddUClassesAdv takes unit ut, integer time returns nothing
    call SetHandleInt(udg_RS_UTypes[2000],I2S(GetUnitTypeId(ut)),GetUnitTypeId(ut) )
    call SetHandleInt(ut,"Dtime",time)
endfunction

function RS_Init takes nothing returns nothing
    call CreateUnitAtLocSaveLast(Player(14),'hpea',Location(0.00,0.00),0.00)
    set udg_RS_UTypes[2000]=GetLastCreatedUnit()
    call ShowUnit(udg_RS_UTypes[2000], false )
    set udg_RS_Triggers[0] = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(udg_RS_Triggers[0],EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(udg_RS_Triggers[0],Condition(function RS_D_Condition) )
    call TriggerAddAction(udg_RS_Triggers[0],function RS_D_Action)
    set udg_RS_Triggers[1] = CreateTrigger()
    call TriggerRegisterTimerEvent(udg_RS_Triggers[1],1,true)
    call TriggerAddCondition(udg_RS_Triggers[1],Condition(function RS_T_Condition) )
    call TriggerAddAction(udg_RS_Triggers[1],function RS_T_Action)
endfunction

function RS_InitUnit takes unit u, integer time returns nothing
    call SetHandleInt(u,"Dtime", time)
    call SetHandleReal(u,"LocX", GetUnitX(u))
    call SetHandleReal(u,"LocY", GetUnitY(u)) 
    call RS_AddUClasses(u)
endfunction

Прикрепленные файлы
Тип файла: w3x respaunsys.w3x (21.0 Кбайт, 15 просмотров )
Старый 17.02.2007, 23:57
DioD

offline
Опыт: 45,134
Активность:
  1. Как должен работать
  2. Как работает
ибо алгоритмика на чужом коде сильно хромает.
Старый 18.02.2007, 08:00
DeT

offline
Опыт: 5,715
Активность:
ща..я еще побьюсь головой...мб получится..код еще нада подправить

Развалины деревни морлоков. Некогда это поселение подавало большие надежды, все думали, что оно разрастется в большой торговый центр, однако по неизвестным причинам здесь наступил упадок.
Вы обходите руины, но никого не находите, уже собравшись уходить видите следующее: в промежутке между двумя развалившимися хижинами проходит человек с ленточками вместо головы, а за ним — еще один, точно такой же. У вас шок, до этого вы с дежавю никогда не сталкивались...
В сознание приводит хриплый голос за спиной: «Мда, сегодня мы видели Адольфов больше, чем за последние полгода...»
Вы оборачиваетесь и видите старого морлока в костюме послушника.
В результате не очень длительного разговора вы узнаете,что он видел пропавшего здесь и даже знает куда тот пошел. По его словам, Дедушка направился по кирпичной дороге к заводу, названному в честь одного из первых киборгов, но точного названия он, к сожалению не помнит.


Отредактировано Hellfim, 31.12.2010 в 17:40.
Старый 18.02.2007, 14:13
exAres
I love magic :)
offline
Опыт: 7,788
Активность:
1)юзай таймер с нужным количством времени а не периодический триггер который минусует время. Если ты думаешь что несколько таймеров хуже чем посекундный loop то ты сильно ошибаешся.
2)лучше юзай не локации а Х и Y или хотябы удаляй локацию.
3)
Код:
function RS_D_Condition takes nothing returns boolean
    local unit a = GetDyingUnit()
    local boolean b = false
    set b= GetUnitTypeId(a) == GetHandleInt(a,I2S(GetUnitTypeId(a )  ) )
    set a =null
    return b
endfunction
- жжесть, а не лучше:
Код:
function RS_D_Condition takes nothing returns boolean
    local unit a=GetDyingUnit()
    return GetUnitTypeId(a)==GetHandleInt(a,I2S(GetUnitTypeId(a)))
endfunction
конечно если боишся потери обнуления одной переменной то можешь просто вызывать "GetDyingUnit()" вместо "а".

ЗЫ здесь можно вообще не использовать массивы и при этом производительность только возрастёт, а ошибку щас найду...
Старый 18.02.2007, 14:32
DeT

offline
Опыт: 5,715
Активность:
о_О
давай. Там не работает триггер проверки юнитов на смерть...странно..
по идее записаь типов для респауна идет но вот не колбасится проверка при мсерти. Про локации - у мну пока дебаг, оптимизацией особо не занимался.
про кондишн - просто думал стоит "a" обнулять
изначально был твой вариант
Старый 18.02.2007, 14:42
exAres
I love magic :)
offline
Опыт: 7,788
Активность:
DeT нашёл главную ошибку : ты или записываешь не туда или читаешь не оттуда :) т.е. ты записываешь тип юнита на юнита которого создаешь при старте карты а читаешь из того который умирает, по этому Cоndition триггера который реагирует на смерть - не исполняется ! Но там и кроме этого полно багов !!!
Старый 18.02.2007, 15:13
DeT

offline
Опыт: 5,715
Активность:
понятно..баги исправим и выложим истемку дополненную :)

DeT добавил:
Код:
function RS_D_Condition takes nothing returns boolean
    local unit a = GetDyingUnit()
    return (GetUnitTypeId(a) == GetHandleInt(udg_RS_UTypes[2000],"c" + I2S(GetUnitTypeId(a) ) ) ) or (GetPlayerId(GetOwningPlayer(a)) == GetHandleInt(udg_RS_UTypes[2000]),"p" + I2S(GetPlayerId(GetOwningPlayer(a)) ) or (H2I(a) == GetHandleInt(udg_RS_UTypes[2000],"u" + H2S(a)) )
endfunction

не работает :(
Старый 18.02.2007, 16:50
exAres
I love magic :)
offline
Опыт: 7,788
Активность:
может где-нить букву путаешь хз, я без полного кода ничего точно сказать не могу.
Старый 18.02.2007, 17:12
DeT

offline
Опыт: 5,715
Активность:
там скобка была лишняя

вот код, посматри, там че-то с ззносом в кеш...<_<
Код:
function RS_CreateUnit takes integer UT_ID, integer time, location loc, integer pnumber returns unit
    local unit a = CreateUnitAtLoc(Player(pnumber), UT_ID,loc, GetRandomReal(0.00,360.00) )
    call SetHandleInt(a,"Dtime", time)
    call SetHandleReal(a,"LocX", GetLocationX(loc))
    call SetHandleReal(a,"LocY", GetLocationY(loc))
    return a
endfunction

function RS_D_Condition takes nothing returns boolean
    local unit a = GetDyingUnit()
    local boolean b
    set b = GetUnitTypeId(a) == GetHandleInt(udg_RS_UTypes[2000],"c" + I2S(GetUnitTypeId(a) ) ) 
    if b==false then 
    else
        set b = GetPlayerId(GetOwningPlayer(a)) == GetHandleInt(udg_RS_UTypes[2000],"p" + I2S(GetPlayerId(GetOwningPlayer(a))))
        if b==false then
        else
            set b = H2I(a) == GetHandleInt(udg_RS_UTypes[2000],"u" + H2S(a))
            if b== false then 
                return b
            endif
        endif
    endif
    return b
   // return (GetUnitTypeId(a) == GetHandleInt(udg_RS_UTypes[2000],"c" + I2S(GetUnitTypeId(a) ) ) ) or (GetPlayerId(GetOwningPlayer(a)) == GetHandleInt(udg_RS_UTypes[2000]),"p" + I2S(GetPlayerId(GetOwningPlayer(a)) ) or (H2I(a) == GetHandleInt(udg_RS_UTypes[2000],"u" + H2S(a)) )
endfunction

function RS_D_Action takes nothing returns nothing
    local unit a = GetDyingUnit()
    call DisplayTimedTextToPlayer(Player(0),0,0,10,"Dead!!")
    if GetHandleInt(a,"Dtime")!=0 then
        call SetHandleInt(a,"Time",GetHandleInt(a,"Dtime"))
    else
        if GetHandleInt(udg_RS_UTypes[2000],"c" + I2S(GetUnitTypeId(a )))!=0 then
            call SetHandleInt(a,"Time",GetHandleInt(udg_RS_UTypes[2000],"c" + I2S(GetUnitTypeId(a )) +"Dtime" ))
        else
            if GetHandleInt(udg_RS_UTypes[2000],"p" + I2S(GetPlayerId(GetOwningPlayer(a)))) != 0 then
                call SetHandleInt(a,"Time",GetHandleInt(udg_RS_UTypes[2000],"p" + I2S(GetPlayerId(GetOwningPlayer(a)))+"Dtime" ) )
            endif
        endif    
    endif 
    set udg_RS_Count=udg_RS_Count+1
    set udg_RS_UTypes[udg_RS_Count] = a
    set a = null
endfunction

function RS_T_Condition takes nothing returns boolean
    return udg_RS_Count>=1
endfunction

function RS_T_Action takes nothing returns nothing
    local integer a = 0
    loop
    exitwhen a>udg_RS_Count
        if GetHandleInt(udg_RS_UTypes[a],"Time")>0 then
            call SetHandleInt(udg_RS_UTypes[a],"Time",GetHandleInt(udg_RS_UTypes[a],"Time")-1)
        else
            call RS_CreateUnit(GetUnitTypeId(udg_RS_UTypes[a]),GetHandleInt(udg_RS_UTypes[a],"Dtime"),Location(GetHandleReal(udg_RS_UTypes[a],"LocX"),GetHandleReal(udg_RS_UTypes[a],"LocY")),GetPlayerId(GetOwningPlayer(udg_RS_UTypes[a]) ) )
            call FlushHandle(udg_RS_UTypes[a]) 
            call RemoveUnit(udg_RS_UTypes[a])
            set udg_RS_UTypes[a]=udg_RS_UTypes[udg_RS_Count]
            set udg_RS_UTypes[udg_RS_Count]=null
            set udg_RS_Count=udg_RS_Count-1
        endif
    endloop
endfunction

function RS_AddClassByUnit takes unit ut, integer time returns nothing
    call SetHandleInt(udg_RS_UTypes[2000],"u" + H2S(ut),GetUnitTypeId(ut) )
    call SetHandleInt(ut,"Dtime",time)
endfunction

function RS_AddClassByType takes integer ut, integer time returns nothing
    call SetHandleInt(udg_RS_UTypes[2000],"c" + I2S(ut),ut )
    call SetHandleInt(udg_RS_UTypes[2000],"c" + I2S(ut) + "Dtime",time )
endfunction

function RS_AddClassByPlayer takes integer ut, integer time returns nothing
    call SetHandleInt(udg_RS_UTypes[2000],"p" + I2S(ut),ut )
    call SetHandleInt(udg_RS_UTypes[2000],"p" + I2S(ut) + "Dtime",time )
endfunction

function RS_Init takes nothing returns nothing
    call CreateUnitAtLocSaveLast(Player(14),'hpea',Location(0.00,0.00),0.00)
    set udg_RS_UTypes[2000]=GetLastCreatedUnit()
    call ShowUnit(udg_RS_UTypes[2000], false )
    set udg_RS_Triggers[0] = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(udg_RS_Triggers[0],EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(udg_RS_Triggers[0],Condition(function RS_D_Condition) )
    call TriggerAddAction(udg_RS_Triggers[0],function RS_D_Action)
    set udg_RS_Triggers[1] = CreateTrigger()
    call TriggerRegisterTimerEvent(udg_RS_Triggers[1],1,true)
    call TriggerAddCondition(udg_RS_Triggers[1],Condition(function RS_T_Condition) )
    call TriggerAddAction(udg_RS_Triggers[1],function RS_T_Action)
endfunction

function RS_LocationSet takes unit u returns nothing
    call SetHandleReal(u,"LocX", GetUnitX(u))
    call SetHandleReal(u,"LocY", GetUnitY(u)) 
endfunction


DeT добавил:
решил проблему почти!
Старый 18.02.2007, 17:24
Ответ

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

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

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

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



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