wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-20-2016, 02:20 PM   #1
DenisHellman
User
 
Join Date: Dec 2016
Posts: 2

DenisHellman has little to show at this moment (0)

Question Jass => vJASS Converting Issue.

Hello!

I'm trying to convert old Jass code into vJASS.

HELP HELP HELP!

There are few commands:

1. GetTableInt(a, "LearnSkillOrder")
2. SetTableInt(a, "LearnSkillOrder", i)
3. GetAttachmentTable(GetExpiredTimer())
4. GetTableUnit(a, "hero")
5. AttachObject(m, "hero", hero)

This commands don't work in vJASS.

The question is:

How this commands will look like in vJASS so I can use them?

Here is the full code:
Collapse JASS:
function AILearnSkill takes unit h, string a returns nothing
    local integer i = GetTableInt(a, "LearnSkillOrder")+1
    if i == 1 or i == 4 or i == 8 then
        call SelectHeroSkill(h, GetStoredInteger(udg_GameCache, UnitId2String(GetUnitTypeId(h)), "BaseSkill1"))
    elseif i == 2 or i == 5 or i == 9 then
        call SelectHeroSkill(h, GetStoredInteger(udg_GameCache, UnitId2String(GetUnitTypeId(h)), "BaseSkill2"))
    elseif i == 3 or i == 7 or i == 10 then
        call SelectHeroSkill(h, GetStoredInteger(udg_GameCache, UnitId2String(GetUnitTypeId(h)), "BaseSkill3"))
    elseif i == 6 then
        call SelectHeroSkill(h, GetStoredInteger(udg_GameCache, UnitId2String(GetUnitTypeId(h)), "UltimateSkill"))
    endif
    call SetTableInt(a, "LearnSkillOrder", i)
endfunction

function AISetItem takes nothing returns nothing
    set bj_lastRemovedItem=GetEnumItem()
endfunction

function AIItemFilter takes nothing returns boolean
    return IsItemVisible(GetFilterItem()) and GetWidgetLife(GetFilterItem()) > 0
endfunction

function AIHasEmptyInventorySlot takes unit u returns boolean
    return UnitItemInSlot(u, 0) == null or UnitItemInSlot(u, 1) == null or UnitItemInSlot(u, 2) == null or UnitItemInSlot(u, 3) == null or UnitItemInSlot(u, 4) == null or UnitItemInSlot(u, 5) == null
endfunction

function AIFilterEnemyConditions takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetAttachedUnit(GetExpiredTimer(), "hero")))
endfunction

function AILoop takes nothing returns nothing
    local string a = GetAttachmentTable(GetExpiredTimer())
    local unit h = GetTableUnit(a, "hero")
    local rect i
    local location r
    local real x = GetUnitX(h)
    local real y = GetUnitY(h)
    local group g
    local boolexpr b
    local boolexpr be
    local unit f
    local string o = OrderId2String(GetUnitCurrentOrder(h))
    local real l = GetUnitState(h, UNIT_STATE_LIFE)
    local real e = 5
    if l <= 0 then
        set e = 1.5
    endif
    if l < GetUnitState(h, UNIT_STATE_MAX_LIFE)/5 then
        call IssuePointOrder(h, "move", GetUnitX(gg_unit_nfoh_0001), GetUnitY(gg_unit_nfoh_0001))
        set e = 3
    else
        if ((o == "smart") or (o == "attack") or (o == "patrol") or (o == "move") or (o == "stop") or (o == "hold") or (o == null)) then
            set g = CreateGroup()
            set b = Condition(function AIFilterEnemyConditions)
            call GroupEnumUnitsInRange(g, x, y, 500, b)
            set f = FirstOfGroup(g)
            if f == null then
                set i = Rect(x-800, y-800, x+800, y+800)
                set be = Condition(function AIItemFilter)
                set bj_lastRemovedItem=null
                call EnumItemsInRect(i, be, function AISetItem)
                if bj_lastRemovedItem != null and (GetItemType(bj_lastRemovedItem) == ITEM_TYPE_POWERUP or AIHasEmptyInventorySlot(h)) then
                    call IssueTargetOrder(h, "smart", bj_lastRemovedItem)
                else
                    set r = GetRandomLocInRect(bj_mapInitialPlayableArea)
                    call IssuePointOrderLoc(h, "patrol", r)
                    call RemoveLocation(r)
                endif
                call RemoveRect(i)
                call DestroyBoolExpr(be)
            else
                call IssueTargetOrder(h, "attack", f)
            endif
            call DestroyGroup(g)
            call DestroyBoolExpr(b)
        endif
    endif
    if GetHeroSkillPoints(h) > 0 and l > 0 then
        call AILearnSkill(h, a)
    endif
    call TimerStart(GetExpiredTimer(), e, true, function AILoop)
    set h = null
    set i = null
    set r = null
    set g = null
    set b = null
    set f = null
    set be = null
endfunction

function StartAI takes unit hero returns nothing
    local timer m = CreateTimer()
    call AttachObject(m, "hero", hero)
    call TimerStart(m, 0, false, function AILoop)
    set m = null
endfunction

function PlayerLeaves takes nothing returns nothing
    local player p = GetTriggerPlayer()
    call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, GetPlayerName(p)+" has left the game.")
    if udg_Hero[GetPlayerId(p)] != null then
        call StartAI(udg_Hero[GetPlayerId(p)])
    endif
    set p = null
endfunction

function SetupSkills takes nothing returns nothing
    local string h
// Paladin
    set h = UnitId2String('Hpal')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AHhb')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AHds')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AHad')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AHre')
// Archmage
    set h = UnitId2String('Hamg')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AHbz')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AHab')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AHwe')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AHmt')
// Mountain King
    set h = UnitId2String('Hmkg')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AHtc')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AHtb')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AHbh')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AHav')
// Blood Mage
    set h = UnitId2String('Hblm')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AHfs')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AHbn')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AHdr')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AHpx')
// Blademaster
    set h = UnitId2String('Obla')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AOwk')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AOcr')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AOmi')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AOww')
// Far Seer
    set h = UnitId2String('Ofar')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AOfs')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AOsf')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AOcl')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AOeq')
// Tauren Chieftain
    set h = UnitId2String('Otch')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AOsh')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AOae')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AOws')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AOre')
// Shadow Hunter
    set h = UnitId2String('Oshd')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AOhw')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AOhx')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AOsw')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AOvd')
// Death Knight
    set h = UnitId2String('Udea')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AUdc')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AUdp')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AUau')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AUan')
// Lich
    set h = UnitId2String('Ulic')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AUfn')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AUfu')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AUdr')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AUdd')
// Dreadlord
    set h = UnitId2String('Udre')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AUav')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AUsl')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AUcs')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AUin')
// Crypt Lord
    set h = UnitId2String('Ucrl')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AUim')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AUts')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AUcb')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AUls')
// Keeper of the Grove
    set h = UnitId2String('Ekee')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AEer')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AEfn')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AEah')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AEtq')
// Priestess of the Moon
    set h = UnitId2String('Emoo')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AEfa')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AEst')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AEar')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AEsf')
// Demon Hunter
    set h = UnitId2String('Edem')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AEmb')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AEim')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AEev')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AEme')
// Warden
    set h = UnitId2String('Ewar')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'AEbl')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'AEfk')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'AEsh')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'AEsv')
// Alchemist
    set h = UnitId2String('Nalc')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANhs')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANab')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANcr')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANtm')
// Naga Sea Witch
    set h = UnitId2String('Nngs')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANfl')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANfa')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANms')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANto')
// Tinker
    set h = UnitId2String('Ntin')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANsy')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANcs')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANeg')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANrg')
// Beast Master
    set h = UnitId2String('Nbst')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANsg')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANsq')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANsw')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANst')
// Dark Ranger
    set h = UnitId2String('Nbrn')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANsi')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANba')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANdr')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANch')
// Firelord
    set h = UnitId2String('Nfir')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANic')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANso')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANlm')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANvc')
// Pandaren Brewmaster
    set h = UnitId2String('Npbm')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANbf')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANdh')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANdb')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANef')
// Pit Lord
    set h = UnitId2String('Nplh')
    call StoreInteger(udg_GameCache, h, "BaseSkill1", 'ANrf')
    call StoreInteger(udg_GameCache, h, "BaseSkill2", 'ANht')
    call StoreInteger(udg_GameCache, h, "BaseSkill3", 'ANca')
    call StoreInteger(udg_GameCache, h, "UltimateSkill", 'ANdo')
endfunction

//===========================================================================
function InitTrig_AI takes nothing returns nothing
    local integer i = 0
    set gg_trg_AI = CreateTrigger(  )
    loop
        exitwhen i > 11
        call TriggerRegisterPlayerEventLeave( gg_trg_AI, Player(i) )
        set i = i + 1
    endloop
    call TriggerAddAction( gg_trg_AI, function PlayerLeaves )
    call ExecuteFunc("SetupSkills")
endfunction
DenisHellman is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-06-2017, 07:27 PM   #2
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,189

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I'm guessing that in the original JASS map, the Set/GetTableInt functions were declared in the map's custom script section. Now that you're working on a vJass version in a new map, you don't have these functions available.

This is like really old code, you should be using hashtables now instead of GameCache.

On the other hand, as long as the JASS version of the code is working fine for you, there's no good reason to rewrite it in vJass.
__________________
Anitarf is offline   Reply With Quote
Old 01-24-2017, 05:50 AM   #3
Royalflare
User
 
Join Date: Jan 2015
Posts: 3

Royalflare has little to show at this moment (0)

Default

I Have A Question,How To Make A Ability Code Converter to Jass? I mean Combined Two Library In One Trigger.So That Can Easily to portability to other maps.
Royalflare is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:48 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services