HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Convert attack tpye to integer

07-30-2006, 08:28 PM#1
emjlr3
why does this not save using tables, but it used to save when I used local handle vars

Collapse JASS:
call SetTableInt(s, "attacktype", H2I(attacktype))
call SetTableInt(s, "damagetype", H2I(damagetype))
07-30-2006, 09:54 PM#2
PipeDream
attacktype and damagetype are types as in handle extensions. You can't use them for variable names, at least not with standard common.j/Blizzard.j
07-30-2006, 10:00 PM#3
Guesst
In case you're naming your local variables 'attacktype' and 'damagetype', choose a different name.
07-30-2006, 10:00 PM#4
The)TideHunter(
I think he means when he replaces the types with actual values.

EDIT: I see, i dident know he was using them as names.
07-30-2006, 10:05 PM#5
emjlr3
those arent the variable names, it was just an example to show u the variable type i was using

my names r not that
07-30-2006, 10:12 PM#6
PipeDream
Then you fucked something else up and that isn't enough context to tell. Use PJASS to find out what.
07-30-2006, 10:49 PM#7
emjlr3
i use JASS Craft, and it dont know whats wrong, says there is nothing wrong

Collapse JASS:
function DamageOverTime_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttTable(t)
    local unit u = GetTableUnit(s, "whichUnit")
    local widget target = GetTableWidget(s, "target")
    
    call SetTableReal(s, "total", (GetTableReal(s, "total" ) + GetTableReal(s, "timeout")))
    if (GetTableReal(s, "total") > GetTableReal(s, "duration")) then
        call Clearst(s,t)
        set t = null
    else
        call UnitDamageTarget(u, target, GetTableReal(s, "amount"), GetTableBoolean(s, "attack"), GetTableBoolean(s, "ranged"), ConvertAttackType(GetTableInt(s, "attacktype")), ConvertDamageType(GetTableInt(s, "damagetype")), null)
    endif

    set u = null
    set target = null    
endfunction

function DamageOverTime takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, real duration, real timeout returns nothing
    local timer t = CreateTimer( )
    local string s = GetAttTable(t)
    
    call SetTableObject(s, "whichUnit", whichUnit)
    call SetTableObject(s, "target", target)
    call SetTableReal(s, "amount", amount)
    call SetTableReal(s, "duration", duration)
    call SetTableReal(s, "timeout", timeout)
    call SetTableReal(s, "total", 0)
    //call SetTableInt(s, "attacktype", H2I(attackType))
    //call SetTableInt(s, "damagetype", H2I(damageType))    
    call SetTableBoolean(s, "attack", attack)
    call SetTableBoolean(s, "ranged", ranged)
    call TimerStart(t, timeout, true, function DamageOverTime_Child)    
endfunction
07-30-2006, 10:58 PM#8
Vexorian
Maybew you used H2I()and you don't really have that function? To avoid conflicts I add CS_ before any return bug exploiter so it is CS_H2I() you could just use SetTableObject(s,"attacktype",attacktypev) btw To load you use ConvertAttackType(GetTableInt(s,"attacktype"))
07-30-2006, 11:00 PM#9
emjlr3
rofl that just might be it lol

yup, lol im a tard as usuall
07-30-2006, 11:35 PM#10
The)TideHunter(
Also, you could just use a smaller integer, which all damage types and attack types have, they have their own index. Thats what i use, saves the H2I.

Collapse JASS:
    constant attacktype         ATTACK_TYPE_NORMAL              = ConvertAttackType(0)
    constant attacktype         ATTACK_TYPE_MELEE               = ConvertAttackType(1)
    constant attacktype         ATTACK_TYPE_PIERCE              = ConvertAttackType(2)
    constant attacktype         ATTACK_TYPE_SIEGE               = ConvertAttackType(3)
    constant attacktype         ATTACK_TYPE_MAGIC               = ConvertAttackType(4)
    constant attacktype         ATTACK_TYPE_CHAOS               = ConvertAttackType(5)
    constant attacktype         ATTACK_TYPE_HERO                = ConvertAttackType(6)

    constant damagetype         DAMAGE_TYPE_UNKNOWN             = ConvertDamageType(0)
    constant damagetype         DAMAGE_TYPE_NORMAL              = ConvertDamageType(4)
    constant damagetype         DAMAGE_TYPE_ENHANCED            = ConvertDamageType(5)
    constant damagetype         DAMAGE_TYPE_FIRE                = ConvertDamageType(8)
    constant damagetype         DAMAGE_TYPE_COLD                = ConvertDamageType(9)
    constant damagetype         DAMAGE_TYPE_LIGHTNING           = ConvertDamageType(10)
    constant damagetype         DAMAGE_TYPE_POISON              = ConvertDamageType(11)
    constant damagetype         DAMAGE_TYPE_DISEASE             = ConvertDamageType(12)
    constant damagetype         DAMAGE_TYPE_DIVINE              = ConvertDamageType(13)
    constant damagetype         DAMAGE_TYPE_MAGIC               = ConvertDamageType(14)
    constant damagetype         DAMAGE_TYPE_SONIC               = ConvertDamageType(15)
    constant damagetype         DAMAGE_TYPE_ACID                = ConvertDamageType(16)
    constant damagetype         DAMAGE_TYPE_FORCE               = ConvertDamageType(17)
    constant damagetype         DAMAGE_TYPE_DEATH               = ConvertDamageType(18)
    constant damagetype         DAMAGE_TYPE_MIND                = ConvertDamageType(19)
    constant damagetype         DAMAGE_TYPE_PLANT               = ConvertDamageType(20)
    constant damagetype         DAMAGE_TYPE_DEFENSIVE           = ConvertDamageType(21)
    constant damagetype         DAMAGE_TYPE_DEMOLITION          = ConvertDamageType(22)
    constant damagetype         DAMAGE_TYPE_SLOW_POISON         = ConvertDamageType(23)
    constant damagetype         DAMAGE_TYPE_SPIRIT_LINK         = ConvertDamageType(24)
    constant damagetype         DAMAGE_TYPE_SHADOW_STRIKE       = ConvertDamageType(25)
    constant damagetype         DAMAGE_TYPE_UNIVERSAL           = ConvertDamageType(26)
Instead of the actual variable, replace and store the correct index, then use the Convert when you want to use it.