Sgqvur
FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
- Reaction score
- 62
Requires:
Unit Indexer by Nestharus
GrimexManual (file:///somewhere_on_you_hd/newgen/jassnewgenpack5d/grimext/GrimexManual.html) by PitzerMike
A spreadsheet program like OpenOffice.org Calc
After clearing the requirements I will try to explain what tilems does and how to use it (hopefully).
Well tilems is just a script that happens to control how much bonus movement speed will a given unit (actaully it's type) will
have while moving over a given terrain type. To configure this the user has to edit a .slk file. The demo map's .slk file is in the zip (could not directly upload slk).
I will try to explain the demo map. First a unit type that must be picked (say 'hfoo'), then some terrain tile(s) are picked. The tiles are picked by opening the GrimexManual and going to the Tile Id List section. Then say we want to make the footmen run slower on "Lordaeron Summer Dark Grass" tile, we open the slk find the "Lordaeron Summer Dark Grass"'s id which is 'Lgrd' (it's written on the left in the GrimexManual) and under it we specify a real value (negative if we want to reduce the movement speed and positive to increase it), if the value is say 0.5 it means that the 'hfoo' movement speed over "Lordaeron Summer Dark Grass" will be increased by 50%. That's it.
=)
Edit: Now works for preplaced units as well, all tiles are included this time and the .slk generates much less script. =)
Unit Indexer by Nestharus
* WorldBounds
* Event
SpeedMod by DiracGrimexManual (file:///somewhere_on_you_hd/newgen/jassnewgenpack5d/grimext/GrimexManual.html) by PitzerMike
A spreadsheet program like OpenOffice.org Calc
After clearing the requirements I will try to explain what tilems does and how to use it (hopefully).
Well tilems is just a script that happens to control how much bonus movement speed will a given unit (actaully it's type) will
have while moving over a given terrain type. To configure this the user has to edit a .slk file. The demo map's .slk file is in the zip (could not directly upload slk).
I will try to explain the demo map. First a unit type that must be picked (say 'hfoo'), then some terrain tile(s) are picked. The tiles are picked by opening the GrimexManual and going to the Tile Id List section. Then say we want to make the footmen run slower on "Lordaeron Summer Dark Grass" tile, we open the slk find the "Lordaeron Summer Dark Grass"'s id which is 'Lgrd' (it's written on the left in the GrimexManual) and under it we specify a real value (negative if we want to reduce the movement speed and positive to increase it), if the value is say 0.5 it means that the 'hfoo' movement speed over "Lordaeron Summer Dark Grass" will be increased by 50%. That's it.
=)
JASS:
library tilems uses UnitIndexer SpeedMod
globals
// When a unit goes from one tile to a different one
// it's movement speed bonus will be recalculated
// within a maximum delay of:
private real TILE_TRANSITION_DELAY = 1.0 // in seconds
private hashtable HT = InitHashtable()
private group G = CreateGroup()
private group swap = CreateGroup()
//int i
endglobals
// jasshelper loads the data from the .slk and
// puts it in to the struct then
// the data is taken from the struct and is loaded
// in to the hashtable for "easier" access
//
//! loaddata "tilems.slk"
struct tilemsld extends array
real Ldrt
real Ldro
real Ldrg
real Lrok
real Lgrs
real Lgrd
real Fdrt
real Fdro
real Fdrg
real Frok
real Fgrs
real Fgrd
real Wdrt
real Wdro
real Wsng
real Wrok
real Wgrs
real Wsnw
real Bdrt
real Bdrh
real Bdrr
real Bdrg
real Bdsr
real Bdsd
real Bflr
real Bgrr
real Adrt
real Adrd
real Agrs
real Arck
real Agrd
real Avin
real Adrg
real Alvd
real Cdrt
real Cdrd
real Cpos
real Crck
real Cvin
real Cgrs
real Clvg
real Ndrt
real Ndrd
real Nrck
real Ngrs
real Nice
real Nsnw
real Nsnr
real Ydrt
real Ydtr
real Yblm
real Ybtl
real Ysqd
real Yrtl
real Ygsb
real Yhdg
real Ywmb
real Vdrt
real Vdrr
real Vcrp
real Vcbp
real Vstp
real Vgrs
real Vrck
real Vgrt
real Qdrt
real Qdrr
real Qcrp
real Qcbp
real Qstp
real Qgrs
real Qrck
real Qgrt
real Xdrt
real Xdtr
real Xblm
real Xbtl
real Xsqd
real Xrtl
real Xgsb
real Xhdg
real Xwmb
real Ddrt
real Dbrk
real Drds
real Dlvc
real Dlav
real Ddkr
real Dgrs
real Dsqd
real Gdrt
real Gbrk
real Grds
real Glvc
real Glav
real Gdkr
real Ggrs
real Gsqd
real Zdrt
real Zdtr
real Zdrg
real Zbks
real Zsan
real Zbkl
real Ztil
real Zgrs
real Zvin
real Idrt
real Idtr
real Idki
real Ibkb
real Irbk
real Itbk
real Iice
real Ibsq
real Isnw
real Odrt
real Odtr
real Osmb
real Ofst
real Olgb
real Orok
real Ofsl
real Oaby
real Kdrt
real Kfsl
real Kdtr
real Kfst
real Ksmb
real Klgb
real Ksqt
real Kdkt
real Jdrt
real Jdtr
real Jblm
real Jbtl
real Jsqd
real Jrtl
real Jgsb
real Jhdg
real Jwmb
real cAc2
real cAc1
real cBc2
real cBc1
real cKc1
real cKc2
real cYc2
real cYc1
real cXc2
real cXc1
real cJc2
real cJc1
real cDc2
real cDc1
real cCc2
real cCc1
real cIc2
real cIc1
real cFc2
real cFc1
real cLc2
real cLc1
real cWc2
real cWc1
real cNc2
real cNc1
real cOc1
real cOc2
real cZc2
real cZc1
real cGc2
real cGc1
real cVc2
real cVc1
real cQc2
real cQc1
static key TCX
static integer sid = 1
static integer array uids
static method getFromKey takes integer uid returns tilemsld
local tilemsld s = LoadInteger(HT, uid, TCX)
if s == 0 then
set s = sid
// map 1, 2, ..., sid to uid('hfoo', 'etc.')
set uids[sid] = uid
// map uid('hfoo', 'etc.') to, 1, 2, ..., sid
call SaveInteger(HT, uid, TCX, sid)
set sid = sid + 1
endif
return s
endmethod
static method init takes nothing returns nothing
local tilemsld t
local integer uid
local integer i = 1
loop
exitwhen i >= tilemsld.sid
set uid = tilemsld.uids<i>
set t = LoadInteger(HT, uid, TCX)
call SaveReal(HT, uid, 039;Ldrt039;, t.Ldrt)
call SaveReal(HT, uid, 039;Ldro039;, t.Ldro)
call SaveReal(HT, uid, 039;Ldrg039;, t.Ldrg)
call SaveReal(HT, uid, 039;Lrok039;, t.Lrok)
call SaveReal(HT, uid, 039;Lgrs039;, t.Lgrs)
call SaveReal(HT, uid, 039;Lgrd039;, t.Lgrd)
call SaveReal(HT, uid, 039;Fdrt039;, t.Fdrt)
call SaveReal(HT, uid, 039;Fdro039;, t.Fdro)
call SaveReal(HT, uid, 039;Fdrg039;, t.Fdrg)
call SaveReal(HT, uid, 039;Frok039;, t.Frok)
call SaveReal(HT, uid, 039;Fgrs039;, t.Fgrs)
call SaveReal(HT, uid, 039;Fgrd039;, t.Fgrd)
call SaveReal(HT, uid, 039;Wdrt039;, t.Wdrt)
call SaveReal(HT, uid, 039;Wdro039;, t.Wdro)
call SaveReal(HT, uid, 039;Wsng039;, t.Wsng)
call SaveReal(HT, uid, 039;Wrok039;, t.Wrok)
call SaveReal(HT, uid, 039;Wgrs039;, t.Wgrs)
call SaveReal(HT, uid, 039;Wsnw039;, t.Wsnw)
call SaveReal(HT, uid, 039;Bdrt039;, t.Bdrt)
call SaveReal(HT, uid, 039;Bdrh039;, t.Bdrh)
call SaveReal(HT, uid, 039;Bdrr039;, t.Bdrr)
call SaveReal(HT, uid, 039;Bdrg039;, t.Bdrg)
call SaveReal(HT, uid, 039;Bdsr039;, t.Bdsr)
call SaveReal(HT, uid, 039;Bdsd039;, t.Bdsd)
call SaveReal(HT, uid, 039;Bflr039;, t.Bflr)
call SaveReal(HT, uid, 039;Bgrr039;, t.Bgrr)
call SaveReal(HT, uid, 039;Adrt039;, t.Adrt)
call SaveReal(HT, uid, 039;Adrd039;, t.Adrd)
call SaveReal(HT, uid, 039;Agrs039;, t.Agrs)
call SaveReal(HT, uid, 039;Arck039;, t.Arck)
call SaveReal(HT, uid, 039;Agrd039;, t.Agrd)
call SaveReal(HT, uid, 039;Avin039;, t.Avin)
call SaveReal(HT, uid, 039;Adrg039;, t.Adrg)
call SaveReal(HT, uid, 039;Alvd039;, t.Alvd)
call SaveReal(HT, uid, 039;Cdrt039;, t.Cdrt)
call SaveReal(HT, uid, 039;Cdrd039;, t.Cdrd)
call SaveReal(HT, uid, 039;Cpos039;, t.Cpos)
call SaveReal(HT, uid, 039;Crck039;, t.Crck)
call SaveReal(HT, uid, 039;Cvin039;, t.Cvin)
call SaveReal(HT, uid, 039;Cgrs039;, t.Cgrs)
call SaveReal(HT, uid, 039;Clvg039;, t.Clvg)
call SaveReal(HT, uid, 039;Ndrt039;, t.Ndrt)
call SaveReal(HT, uid, 039;Ndrd039;, t.Ndrd)
call SaveReal(HT, uid, 039;Nrck039;, t.Nrck)
call SaveReal(HT, uid, 039;Ngrs039;, t.Ngrs)
call SaveReal(HT, uid, 039;Nice039;, t.Nice)
call SaveReal(HT, uid, 039;Nsnw039;, t.Nsnw)
call SaveReal(HT, uid, 039;Nsnr039;, t.Nsnr)
call SaveReal(HT, uid, 039;Ydrt039;, t.Ydrt)
call SaveReal(HT, uid, 039;Ydtr039;, t.Ydtr)
call SaveReal(HT, uid, 039;Yblm039;, t.Yblm)
call SaveReal(HT, uid, 039;Ybtl039;, t.Ybtl)
call SaveReal(HT, uid, 039;Ysqd039;, t.Ysqd)
call SaveReal(HT, uid, 039;Yrtl039;, t.Yrtl)
call SaveReal(HT, uid, 039;Ygsb039;, t.Ygsb)
call SaveReal(HT, uid, 039;Yhdg039;, t.Yhdg)
call SaveReal(HT, uid, 039;Ywmb039;, t.Ywmb)
call SaveReal(HT, uid, 039;Vdrt039;, t.Vdrt)
call SaveReal(HT, uid, 039;Vdrr039;, t.Vdrr)
call SaveReal(HT, uid, 039;Vcrp039;, t.Vcrp)
call SaveReal(HT, uid, 039;Vcbp039;, t.Vcbp)
call SaveReal(HT, uid, 039;Vstp039;, t.Vstp)
call SaveReal(HT, uid, 039;Vgrs039;, t.Vgrs)
call SaveReal(HT, uid, 039;Vrck039;, t.Vrck)
call SaveReal(HT, uid, 039;Vgrt039;, t.Vgrt)
call SaveReal(HT, uid, 039;Qdrt039;, t.Qdrt)
call SaveReal(HT, uid, 039;Qdrr039;, t.Qdrr)
call SaveReal(HT, uid, 039;Qcrp039;, t.Qcrp)
call SaveReal(HT, uid, 039;Qcbp039;, t.Qcbp)
call SaveReal(HT, uid, 039;Qstp039;, t.Qstp)
call SaveReal(HT, uid, 039;Qgrs039;, t.Qgrs)
call SaveReal(HT, uid, 039;Qrck039;, t.Qrck)
call SaveReal(HT, uid, 039;Qgrt039;, t.Qgrt)
call SaveReal(HT, uid, 039;Xdrt039;, t.Xdrt)
call SaveReal(HT, uid, 039;Xdtr039;, t.Xdtr)
call SaveReal(HT, uid, 039;Xblm039;, t.Xblm)
call SaveReal(HT, uid, 039;Xbtl039;, t.Xbtl)
call SaveReal(HT, uid, 039;Xsqd039;, t.Xsqd)
call SaveReal(HT, uid, 039;Xrtl039;, t.Xrtl)
call SaveReal(HT, uid, 039;Xgsb039;, t.Xgsb)
call SaveReal(HT, uid, 039;Xhdg039;, t.Xhdg)
call SaveReal(HT, uid, 039;Xwmb039;, t.Xwmb)
call SaveReal(HT, uid, 039;Ddrt039;, t.Ddrt)
call SaveReal(HT, uid, 039;Dbrk039;, t.Dbrk)
call SaveReal(HT, uid, 039;Drds039;, t.Drds)
call SaveReal(HT, uid, 039;Dlvc039;, t.Dlvc)
call SaveReal(HT, uid, 039;Dlav039;, t.Dlav)
call SaveReal(HT, uid, 039;Ddkr039;, t.Ddkr)
call SaveReal(HT, uid, 039;Dgrs039;, t.Dgrs)
call SaveReal(HT, uid, 039;Dsqd039;, t.Dsqd)
call SaveReal(HT, uid, 039;Gdrt039;, t.Gdrt)
call SaveReal(HT, uid, 039;Gbrk039;, t.Gbrk)
call SaveReal(HT, uid, 039;Grds039;, t.Grds)
call SaveReal(HT, uid, 039;Glvc039;, t.Glvc)
call SaveReal(HT, uid, 039;Glav039;, t.Glav)
call SaveReal(HT, uid, 039;Gdkr039;, t.Gdkr)
call SaveReal(HT, uid, 039;Ggrs039;, t.Ggrs)
call SaveReal(HT, uid, 039;Gsqd039;, t.Gsqd)
call SaveReal(HT, uid, 039;Zdrt039;, t.Zdrt)
call SaveReal(HT, uid, 039;Zdtr039;, t.Zdtr)
call SaveReal(HT, uid, 039;Zdrg039;, t.Zdrg)
call SaveReal(HT, uid, 039;Zbks039;, t.Zbks)
call SaveReal(HT, uid, 039;Zsan039;, t.Zsan)
call SaveReal(HT, uid, 039;Zbkl039;, t.Zbkl)
call SaveReal(HT, uid, 039;Ztil039;, t.Ztil)
call SaveReal(HT, uid, 039;Zgrs039;, t.Zgrs)
call SaveReal(HT, uid, 039;Zvin039;, t.Zvin)
call SaveReal(HT, uid, 039;Idrt039;, t.Idrt)
call SaveReal(HT, uid, 039;Idtr039;, t.Idtr)
call SaveReal(HT, uid, 039;Idki039;, t.Idki)
call SaveReal(HT, uid, 039;Ibkb039;, t.Ibkb)
call SaveReal(HT, uid, 039;Irbk039;, t.Irbk)
call SaveReal(HT, uid, 039;Itbk039;, t.Itbk)
call SaveReal(HT, uid, 039;Iice039;, t.Iice)
call SaveReal(HT, uid, 039;Ibsq039;, t.Ibsq)
call SaveReal(HT, uid, 039;Isnw039;, t.Isnw)
call SaveReal(HT, uid, 039;Odrt039;, t.Odrt)
call SaveReal(HT, uid, 039;Odtr039;, t.Odtr)
call SaveReal(HT, uid, 039;Osmb039;, t.Osmb)
call SaveReal(HT, uid, 039;Ofst039;, t.Ofst)
call SaveReal(HT, uid, 039;Olgb039;, t.Olgb)
call SaveReal(HT, uid, 039;Orok039;, t.Orok)
call SaveReal(HT, uid, 039;Ofsl039;, t.Ofsl)
call SaveReal(HT, uid, 039;Oaby039;, t.Oaby)
call SaveReal(HT, uid, 039;Kdrt039;, t.Kdrt)
call SaveReal(HT, uid, 039;Kfsl039;, t.Kfsl)
call SaveReal(HT, uid, 039;Kdtr039;, t.Kdtr)
call SaveReal(HT, uid, 039;Kfst039;, t.Kfst)
call SaveReal(HT, uid, 039;Ksmb039;, t.Ksmb)
call SaveReal(HT, uid, 039;Klgb039;, t.Klgb)
call SaveReal(HT, uid, 039;Ksqt039;, t.Ksqt)
call SaveReal(HT, uid, 039;Kdkt039;, t.Kdkt)
call SaveReal(HT, uid, 039;Jdrt039;, t.Jdrt)
call SaveReal(HT, uid, 039;Jdtr039;, t.Jdtr)
call SaveReal(HT, uid, 039;Jblm039;, t.Jblm)
call SaveReal(HT, uid, 039;Jbtl039;, t.Jbtl)
call SaveReal(HT, uid, 039;Jsqd039;, t.Jsqd)
call SaveReal(HT, uid, 039;Jrtl039;, t.Jrtl)
call SaveReal(HT, uid, 039;Jgsb039;, t.Jgsb)
call SaveReal(HT, uid, 039;Jhdg039;, t.Jhdg)
call SaveReal(HT, uid, 039;Jwmb039;, t.Jwmb)
call SaveReal(HT, uid, 039;cAc2039;, t.cAc2)
call SaveReal(HT, uid, 039;cAc1039;, t.cAc1)
call SaveReal(HT, uid, 039;cBc2039;, t.cBc2)
call SaveReal(HT, uid, 039;cBc1039;, t.cBc1)
call SaveReal(HT, uid, 039;cKc1039;, t.cKc1)
call SaveReal(HT, uid, 039;cKc2039;, t.cKc2)
call SaveReal(HT, uid, 039;cYc2039;, t.cYc2)
call SaveReal(HT, uid, 039;cYc1039;, t.cYc1)
call SaveReal(HT, uid, 039;cXc2039;, t.cXc2)
call SaveReal(HT, uid, 039;cXc1039;, t.cXc1)
call SaveReal(HT, uid, 039;cJc2039;, t.cJc2)
call SaveReal(HT, uid, 039;cJc1039;, t.cJc1)
call SaveReal(HT, uid, 039;cDc2039;, t.cDc2)
call SaveReal(HT, uid, 039;cDc1039;, t.cDc1)
call SaveReal(HT, uid, 039;cCc2039;, t.cCc2)
call SaveReal(HT, uid, 039;cCc1039;, t.cCc1)
call SaveReal(HT, uid, 039;cIc2039;, t.cIc2)
call SaveReal(HT, uid, 039;cIc1039;, t.cIc1)
call SaveReal(HT, uid, 039;cFc2039;, t.cFc2)
call SaveReal(HT, uid, 039;cFc1039;, t.cFc1)
call SaveReal(HT, uid, 039;cLc2039;, t.cLc2)
call SaveReal(HT, uid, 039;cLc1039;, t.cLc1)
call SaveReal(HT, uid, 039;cWc2039;, t.cWc2)
call SaveReal(HT, uid, 039;cWc1039;, t.cWc1)
call SaveReal(HT, uid, 039;cNc2039;, t.cNc2)
call SaveReal(HT, uid, 039;cNc1039;, t.cNc1)
call SaveReal(HT, uid, 039;cOc1039;, t.cOc1)
call SaveReal(HT, uid, 039;cOc2039;, t.cOc2)
call SaveReal(HT, uid, 039;cZc2039;, t.cZc2)
call SaveReal(HT, uid, 039;cZc1039;, t.cZc1)
call SaveReal(HT, uid, 039;cGc2039;, t.cGc2)
call SaveReal(HT, uid, 039;cGc1039;, t.cGc1)
call SaveReal(HT, uid, 039;cVc2039;, t.cVc2)
call SaveReal(HT, uid, 039;cVc1039;, t.cVc1)
call SaveReal(HT, uid, 039;cQc2039;, t.cQc2)
call SaveReal(HT, uid, 039;cQc1039;, t.cQc1)
set i = i + 1
endloop
// add the preplaced units to G if
// their id was in the .slk
//call ExecuteFunc("s__tilemsld_add_preplaced_units_to_G")
call ExecuteFunc(tilemsld.add_preplaced_units_to_G.name)
endmethod
static method add_preplaced_units_to_G takes nothing returns nothing
local unit u
local integer i
local integer uid
call GroupEnumUnitsInRect(swap, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(swap)
exitwhen u == null
set i = 1
set uid = GetUnitTypeId(u)
loop
exitwhen i >= sid
if uid == uids<i> then
call GroupAddUnit(G, u)
exitwhen true
endif
set i = i + 1
endloop
call GroupRemoveUnit(swap, u)
endloop
endmethod
static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function tilemsld.init)
endmethod
endstruct
private struct grouper extends array
integer cur_tile
integer prev_tile
SpeedMod sm
static method filter takes unit u returns boolean
local integer uid = GetUnitTypeId(u)
local integer i = 1
loop
exitwhen i >= tilemsld.sid
if uid == tilemsld.uids<i> then
return true
endif
set i = i + 1
endloop
return false
endmethod
method index takes nothing returns nothing
//set cur_tile = 0 //GetTerrainType(GetUnitX(unit), GetUnitY(unit))
set prev_tile = 0
set sm = 0
call GroupAddUnit(G, unit)
endmethod
method deindex takes nothing returns nothing
call GroupRemoveUnit(G, unit)
if sm != 0 then
call sm.destroy()
endif
endmethod
implement UnitIndexStruct
endstruct
private struct looper extends array
static method act takes nothing returns nothing
local unit u
local group g
local grouper d
local integer uid
loop
set u = FirstOfGroup(G)
exitwhen u == null
call GroupRemoveUnit(G, u)
call GroupAddUnit(swap, u)
set d = GetUnitUserData(u)
set d.cur_tile = GetTerrainType(GetUnitX(u), GetUnitY(u))
// the unit moved to a different tile
if d.cur_tile != d.prev_tile then
if d.sm != 0 then
call d.sm.destroy()
endif
set uid = GetUnitTypeId(u)
// recalculate the speed mod
// only if the unit actually has one for the
// current tile, i.e it is != 0
//
if LoadReal(HT, uid, d.cur_tile) != 0 then
set d.sm = SpeedMod.create(u, LoadReal(HT, uid, d.cur_tile))
else
set d.sm = 0
endif
endif
set d.prev_tile = d.cur_tile
endloop
set g = G
set G = swap
set swap = g
// set g = null
set u = null
endmethod
static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), TILE_TRANSITION_DELAY, true, function looper.act)
endmethod
endstruct
endlibrary
</i></i></i>
Edit: Now works for preplaced units as well, all tiles are included this time and the .slk generates much less script. =)