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

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

Закрытая тема
 
Msey
????
offline
Опыт: 67,346
Активность:
замена SCV
Нашел огромное количество классных систем, однако встретил в них рб функции. Мне приходилось работать с scv (многое заменял), но здесь уже высший пилотаж.
function I2TM takes integer i returns timer
 return i
 return null
endfunction
И таким образом можно получить любой объект.
Принцип работы функции мне ясен: берется id хендла и каким-то раком переобразовывается обратно в объект.
(h - 0x100000) где h = handle объекта, но мб я ошибаюсь
Прошу дать примеры решения, ведь они идут в пару строк.
Под катом есть еще ф-ии, которые я хз как заменить
((кат прочие ф-ии
//###########################################################################
function setcfg takes string key, string val returns nothing
 call StoreString(udg_cache,"config",key,val)
endfunction

function cfg takes string key returns string
 return GetStoredString(udg_cache,"config", key)
endfunction
function cfgr takes string key returns real
 return S2R(cfg(key))
endfunction
function cfgi takes string key returns integer
 return S2I(cfg(key))
endfunction

//###########################################################################

function get_object_iparam takes handle h, string key returns integer
 return GetStoredInteger(udg_cache,I2S(H2I(h)),key)
endfunction
function set_object_iparam takes handle h, string key, integer val returns nothing
 call StoreInteger(udg_cache,I2S(H2I(h)),key, val)
endfunction

function get_object_rparam takes handle h, string key returns real
 return GetStoredReal(udg_cache,I2S(H2I(h)),key)
endfunction
function set_object_rparam takes handle h, string key, real val returns nothing
 call StoreReal(udg_cache,I2S(H2I(h)),key,val)
endfunction

function flush_object takes handle h returns nothing
 call FlushStoredMission(udg_cache,I2S(H2I(h)))
endfunction
))
Старый 02.06.2012, 21:30
DragonSpirit
у - уходи
offline
Опыт: 22,625
Активность:
посмотри преобразование через fogstate
DioD подобное делал и называл это Shark Engine вроде как
Старый 02.06.2012, 21:47
Msey
????
offline
Опыт: 67,346
Активность:
Нашел наработку (не диода).
Она решила мой первый вопрос.
//! zinc
library Typecasting
{
    private hashtable Data = InitHashtable();

    //! textmacro Typecasting takes ParentName, parenttype, TypeName, type
    public function $ParentName$2$TypeName$ ($parenttype$ object) -> $type$
    {
        Save$ParentName$Handle(Data,0,0,object);
        return Load$TypeName$Handle(Data,0,0);
    }
    //! endtextmacro
    //! runtextmacro Typecasting ("Agent","agent","Widget","widget")
    //! runtextmacro Typecasting ("Agent","agent","Group","group")
    //! runtextmacro Typecasting ("Agent","agent","Trigger","trigger")
    //! runtextmacro Typecasting ("Agent","agent","Timer","timer")
    //! runtextmacro Typecasting ("Agent","agent","Location","location")
    //! runtextmacro Typecasting ("Agent","agent","Effect","effect")
    //! runtextmacro Typecasting ("Agent","agent","Unit","unit")
    //! runtextmacro Typecasting ("Agent","agent","Item","item")
    //! runtextmacro Typecasting ("Widget","widget","Unit","unit")
    //! runtextmacro Typecasting ("Widget","widget","Destructable","destructable")
    //! runtextmacro Typecasting ("Widget","widget","Item","item")

    //! textmacro Typecasting_I2X takes TypeName, type
    public function Int2$TypeName$ (integer id) -> $type$
    {
        SaveFogStateHandle(Data,0,0,ConvertFogState(id));
        return Load$TypeName$Handle(Data,0,0);
    }
    //! endtextmacro
    //! runtextmacro Typecasting_I2X("Unit", "unit")
    //! runtextmacro Typecasting_I2X("Effect", "effect")
    //! runtextmacro Typecasting_I2X("Trigger", "trigger")
    //! runtextmacro Typecasting_I2X("Timer", "timer")
    //! runtextmacro Typecasting_I2X("Widget", "widget")
    //! runtextmacro Typecasting_I2X("Group", "group")
    //! runtextmacro Typecasting_I2X("Location", "location")
    //! runtextmacro Typecasting_I2X("Item", "item")
    //! runtextmacro Typecasting_I2X("Destructable", "destructable")
    //! runtextmacro Typecasting_I2X("Ability", "ability")
    //! runtextmacro Typecasting_I2X("TriggerCondition", "triggercondition")
    //! runtextmacro Typecasting_I2X("TriggerAction", "triggeraction")
    //! runtextmacro Typecasting_I2X("Force", "force")
    //! runtextmacro Typecasting_I2X("Rect", "rect")
    //! runtextmacro Typecasting_I2X("Sound", "sound")
    //! runtextmacro Typecasting_I2X("UnitPool", "unitpool")
    //! runtextmacro Typecasting_I2X("ItemPool", "itempool")
    //! runtextmacro Typecasting_I2X("Quest", "quest")
    //! runtextmacro Typecasting_I2X("QuestItem", "questitem")
    //! runtextmacro Typecasting_I2X("DefeatCondition", "defeatcondition")
    //! runtextmacro Typecasting_I2X("TimerDialog", "timerdialog")
    //! runtextmacro Typecasting_I2X("Leaderboard", "leaderboard")
    //! runtextmacro Typecasting_I2X("Multiboard", "multiboard")
    //! runtextmacro Typecasting_I2X("MultiboardItem", "multiboarditem")
    //! runtextmacro Typecasting_I2X("Trackable", "trackable")
    //! runtextmacro Typecasting_I2X("Dialog", "dialog")
    //! runtextmacro Typecasting_I2X("Button", "button")
    //! runtextmacro Typecasting_I2X("TextTag", "texttag")
    //! runtextmacro Typecasting_I2X("Image", "image")
    //! runtextmacro Typecasting_I2X("Ubersplat", "ubersplat")
    //! runtextmacro Typecasting_I2X("Region", "region")
    //! runtextmacro Typecasting_I2X("FogState", "fogstate")
    //! runtextmacro Typecasting_I2X("FogModifier", "fogmodifier")
}
//! endzinc
Исходящий из этого вопрос: будет ли работать эта библиотека, если она находится в кастом коде, а код спелла отдельно, в созданном триггере?
будет ли работать макрос? (я до них пока не дошел в мануале)
Старый 02.06.2012, 22:29
DragonSpirit
у - уходи
offline
Опыт: 22,625
Активность:
да
Старый 02.06.2012, 22:45
Msey
????
offline
Опыт: 67,346
Активность:

function cfg takes string key returns string
 return GetStoredString(udg_cache,"config", key)
endfunction
function cfgr takes string key returns real
 return S2R(cfg(key))
endfunction
function cfgi takes string key returns integer
 return S2I(cfg(key))
endfunction
а с этим как быть?
Старый 02.06.2012, 23:23
DragonSpirit
у - уходи
offline
Опыт: 22,625
Активность:
сохраняй через StringHash в таблицу
Старый 04.06.2012, 16:05
Doc

offline
Опыт: 63,163
Активность:
Ну можно так и оставить лол)
Чем кеш не угодил?
Старый 04.06.2012, 16:40
quq_CCCP
Я белый и пушистый!
offline
Опыт: 93,279
Активность:
Msey, Вот типа SCV только на хеше, ну там вроде есть то что тебе нужно)
» код
((код jass
function StoreDataInteger takes handle pKey, string cKey, integer value returns nothing
call SaveInteger(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey), value )
endfunction
function StoreDataReal takes handle parentKey, string cKey, real value returns nothing
call SaveReal(bj_lastCreatedHashtable, GetHandleId(parentKey), StringHash(cKey), value )
endfunction
function StoreDataBoolean takes handle parentKey, string cKey, boolean value returns nothing
call SaveBoolean(bj_lastCreatedHashtable, GetHandleId(parentKey), S2I(cKey), value )
endfunction
function StoreDataString takes handle parentKey, string cKey, string value returns nothing
call SaveStr(bj_lastCreatedHashtable, GetHandleId(parentKey), StringHash(cKey), value )
endfunction
function GetStoredDataInteger takes handle pKey, string cKey returns integer
return LoadInteger(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataReal takes handle pKey, string cKey returns real
return LoadReal(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataBoolean takes handle pKey, string cKey returns boolean
return LoadBoolean(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataString takes handle pKey, string cKey returns string
return LoadStr(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function StoreDataHandle takes handle pKey, string cKey, handle whichHandle returns nothing
if(HaveSavedHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))) then
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"|cffff0000Ошибка!|r По адресу - "+I2S(GetHandleId(pKey))+" x "cKey" записан хендл - " + I2S(GetHandleId(LoadFogStateHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey)))))
call RemoveSavedHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endif
call SaveFogStateHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey), ConvertFogState(GetHandleId(whichHandle)))
endfunction
function GetStoredDataUnit takes handle pKey, string cKey returns unit
return LoadUnitHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataTrigger takes handle pKey, string cKey returns trigger
return LoadTriggerHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataTimer takes handle pKey, string cKey returns timer
return LoadTimerHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function GetStoredDataEffect takes handle pKey, string cKey returns effect
return LoadEffectHandle(bj_lastCreatedHashtable, GetHandleId(pKey), StringHash(cKey))
endfunction
function FlushStoredData takes handle pKey returns nothing
call FlushChildHashtable(bj_lastCreatedHashtable,GetHandleId(pKey))
endfunction
))
quq_CCCP добавил:
((код jass
function cfg takes string key returns string
return LoadStr(udg_hash,StringHash("config"), StringHash(key))
endfunction
))
тут всё просто
Старый 04.06.2012, 17:06
Msey
????
offline
Опыт: 67,346
Активность:
Всё, всем спасибо, разобрался, закрывайте)
Старый 05.06.2012, 13:39
Закрытая тема

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

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

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

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



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