• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] JASS semi-unknown problem again (2)

Status
Not open for further replies.
Hi, it is me again with some JASS problems (OOHH GOD, really ?? lol =P). Anyway, the problem is that JassCraft says it can't convert real to integer, making my spell fail ...
But question is, if it can be done in GUI why can't it be done in JASS !? Can some1 help me plz ?
Here is the spell:

JASS:
function SpeedLust_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'A001' 
endfunction
//===============================================================
function SpeedLust_Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl", caster, "origin")
    local integer level = GetUnitAbilityLevel(caster, 'A001')
    local texttag bonus = CreateTextTag() 
        call SetHeroAgi(caster,GetHeroAgi(caster, false) + GetHeroAgi(caster, false) * (0.10*level), true) 
        call SetTextTagText(bonus, "+" + I2S(GetHeroAgi(caster, false) * (0.10*level)), .023 )   
        call SetTextTagPosUnit( bonus, caster, 0 )
        call SetTextTagColor( bonus, 0, 255, 0, 255 )   
        call SetTextTagPermanent(bonus, false)
        call SetTextTagVelocity( bonus, 0, .0277 )
        call TriggerSleepAction(2.00)
        call DestroyTextTag(bonus)
        call TriggerSleepAction( 4*level )
        call SetHeroAgi(caster,GetHeroAgi(caster, false) - GetHeroAgi(caster, false) * (0.10*level), true)
        call DestroyEffect(e)
    set caster = null
    set e = null
    set bonus = null 
endfunction
//===========================================================================
function InitTrig_Speed_Lust takes nothing returns nothing
    local trigger SpeedLust = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpeedLust, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SpeedLust, Condition( function SpeedLust_Conds ) )
    call TriggerAddAction( SpeedLust, function SpeedLust_Acts )
endfunction

I tried to apply as much knowledge as i could and i think i did everythong ok, except the real to integer conversion .. and i don't know how to solve this problem ..

The objective of the spell id to give 10%, 20% and 30% bonus to the agility of the hero, together with items if possible, during 4, 8, 12 seconds....

Help again plz .. =S
 
Last edited:
i did what you suggested purplepoot but now i have more than one problem. To start, the texttag shows wrong values, example, if my hero gains 5 agi bonus, the text will display 6 agi bonus.
The other problem is that every time i use this ability, the hero looses 1 or 2 agility permanently after the wait ...

So if my hero has 24 agility, and i use my spell in level 3, he will gain 8 agility, the text will say he gained 9 agility, and when the effect of the spell disappears, my hero will have 22 agility.

Help ?! Perhaps i should use BJ's ?? don't know ... i just know that it works in GUI, but i don't understand why it doesn't here....

Spell (improvement !?):
JASS:
function SpeedLust_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtc' 
endfunction
//===============================================================
function SpeedLust_Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl", caster, "origin")
    local integer level = GetUnitAbilityLevel(caster, 'AHtc')
    local texttag bonus = CreateTextTag() 
        call SetHeroAgi(caster,GetHeroAgi(caster, false) + (R2I(GetHeroAgi(caster, false) * (0.10*level))), true) 
        call SetTextTagText(bonus, "+" + I2S(R2I(GetHeroAgi(caster, false) * (0.10*level))), .023 )   
        call SetTextTagPosUnit( bonus, caster, 0 )
        call SetTextTagColor( bonus, 0, 255, 0, 255 )   
        call SetTextTagPermanent(bonus, false)
        call SetTextTagVelocity( bonus, 0, .0277 )
        call TriggerSleepAction(2.00)
        call DestroyTextTag(bonus)
        call TriggerSleepAction( 4*level )
        call SetHeroAgi(caster,GetHeroAgi(caster, false) - (R2I(GetHeroAgi(caster, false) * (0.10*level))), true)
        call DestroyEffect(e)
    set caster = null
    set e = null
    set bonus = null 
endfunction
//===========================================================================
function InitTrig_Speed_Lust takes nothing returns nothing
    local trigger SpeedLust = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpeedLust, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SpeedLust, Condition( function SpeedLust_Conds ) )
    call TriggerAddAction( SpeedLust, function SpeedLust_Acts )
endfunction


Help please!
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Off-topic:

JASS:
function Destructable takes nothing returns boolean
    return GetDestructableTypeId(GetDyingDestructable()) == 'ATtr'
endfunction


Everything ok, but:

JASS:
function Destructable takes nothing returns boolean
    return GetDestructableTypeId(GetTriggerWidget()) == 'ATtr'
endfunction


"cannot convert widget to destructable"! WTF??? I just got out the content of the GetDyingDestructable function, I practically did the same thing!

JASS:
function GetDyingDestructable takes nothing returns destructable
    return GetTriggerWidget()
endfunction
 
Silvenon i suggest next time you create your own thread instead of posting a completely different unrelated problem in my thread ...

PurplePoot thx by the tip, but it seems that the computer is more stupid than we thought (lol) ... now if i cast the ability, the text shows the current agility of hero with no bonuses and nothing happens ...
yap, that's rit nothing happens ... somehow there is no way to make this work ... i will post the code i made here ... perhaps more people can find a solution:

JASS:
function SpeedLust_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtc' 
endfunction
//===============================================================
function SpeedLust_Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl", caster, "origin")
    local integer Bagi = (GetHeroAgi(caster, false))*(GetUnitAbilityLevel(caster, 'AHtc')/10)
    local texttag bonus = CreateTextTag() 
        call SetHeroAgi(caster,(GetHeroAgi(caster, false) + Bagi), true) 
        call SetTextTagText(bonus, "+" + I2S(GetHeroAgi(caster, false) + Bagi), .023 )   
        call SetTextTagPosUnit( bonus, caster, 0 )
        call SetTextTagColor( bonus, 0, 255, 0, 255 )   
        call SetTextTagPermanent(bonus, false)
        call SetTextTagVelocity( bonus, 0, .0277 )
        call TriggerSleepAction(2.00)
        call DestroyTextTag(bonus)
        call TriggerSleepAction( 4* (GetUnitAbilityLevel(caster, 'AHtc')))
        call SetHeroAgi(caster,(GetHeroAgi(caster, false) - Bagi), true)
        call DestroyEffect(e)
    set caster = null
    set e = null
    set bonus = null 
endfunction
//===========================================================================
function InitTrig_Speed_Lust takes nothing returns nothing
    local trigger SpeedLust = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpeedLust, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SpeedLust, Condition( function SpeedLust_Conds ) )
    call TriggerAddAction( SpeedLust, function SpeedLust_Acts )
endfunction

Help some1 !
PS: why is JASS so good and so stupid at the same time !!!
 
Level 9
Joined
Mar 25, 2005
Messages
252
local integer Bagi = (GetHeroAgi(caster, false))*(GetUnitAbilityLevel(caster, 'AHtc')/10)

Try replacing that line with:

local integer Bagi = R2I(GetHeroAgi(caster, false)*GetUnitAbilityLevel(caster, 'AHtc')*0.1)

I think that this way the comp might round the bagi -integer differently
 
Thx Disciple of life, your code saved my ability from BJ's and most important from failure. the code you gave me works just fine, works perfectly in my map.

Also thx to purplepoot, he didn't find the solution, but he is always trying, no1 is perfect.

Final Code:

JASS:
function SpeedLust_Conds takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtc' 
endfunction
//===============================================================
function SpeedLust_Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl", caster, "origin")
    local integer Bagi = R2I(GetHeroAgi(caster, true)*(GetUnitAbilityLevel(caster, 'AHtc')*0.1))
    local texttag bonus = CreateTextTag() 
        call SetHeroAgi(caster,(GetHeroAgi(caster, false) + Bagi), true) 
        call SetTextTagText(bonus, "+" + I2S(Bagi), .023 )   
        call SetTextTagPosUnit( bonus, caster, 0 )
        call SetTextTagColor( bonus, 0, 255, 0, 255 )   
        call SetTextTagPermanent(bonus, false)
        call SetTextTagVelocity( bonus, 0, .0277 )
        call TriggerSleepAction(2.00)
        call DestroyTextTag(bonus)
        call TriggerSleepAction( 4* (GetUnitAbilityLevel(caster, 'AHtc')))
        call SetHeroAgi(caster,(GetHeroAgi(caster, false) - Bagi), true)
        call DestroyEffect(e)
    set caster = null
    set e = null
    set bonus = null 
endfunction
//===========================================================================
function InitTrig_Speed_Lust takes nothing returns nothing
    local trigger SpeedLust = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( SpeedLust, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SpeedLust, Condition( function SpeedLust_Conds ) )
    call TriggerAddAction( SpeedLust, function SpeedLust_Acts )
endfunction


Done guys here is the final code. I think everything is ok, and if you use this code in the spell you will get 30% agi bonus (with items) for 12 seconds (in level3).
The effect is not permanent =)

Thx i really appreciate your help.
 
Status
Not open for further replies.
Top