• 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] UGGG Script not working......

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
Alright this script here is coming up with an error:

Code:
function Rocket_Engines_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04D'
endfunction

function Rocket_Engines_Knockback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetAttachedUnit(t, "cast")
    local integer steps = GetAttachedInt(t, "steps")
    local location curr = GetUnitLoc(cast)
    local location dest = PolarProjectionBJ(curr, 25, GetUnitFacing(cast))
    call SetUnitPositionLoc(cast, dest)
    call RemoveLocation(curr)
    call RemoveLocation(dest)        
    set curr = null
    set dest = null
    if (steps <= 1) then
        call FlushHandle(t)
        call DestroyTimer(t)
        call FlushHandle(cast)
        set cast = null
        set t = null
        return    
    endif
    set cast = null
    call AttachInt( t, "steps", steps - 1 )
    set t = null
endfunction

function Rocket_Engines_Actions takes nothing returns nothing
    local boolean stopped = true
    local timer t = CreateTimer()
    local unit cast = GetTriggerUnit()
    local integer channeltime = GetAttachedInt(cast, "channeltime")
    local integer steps = channeltime/.025
    call AttachBoolean(cast, "stopped", stopped)
    call AttachInt(t, "steps", steps)
    call AttachObject(t, "cast", cast)
    call TimerStart(t, .025, true, function Rocket_Engines_Knockback)
    set cast = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Captian_Germross_Rocket_Engines takes nothing returns nothing
    set gg_trg_Captian_Germross_Rocket_Engines = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Germross_Rocket_Engines, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition( gg_trg_Captian_Germross_Rocket_Engines, Condition( function Rocket_Engines_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Germross_Rocket_Engines, function Rocket_Engines_Actions )
endfunction


The error is:

Cannot convert real to integer
Code:
call AttachBoolean(cast, "stopped", stopped)

Once again im using the cache system blah blah
http://forums.dota-allstars.com/index.php?showtopic=92616
 
Level 11
Joined
Jul 12, 2005
Messages
764
WE often illuminates the line below the error... In this case, the problem is that you want to store a real into an integer variable (dividing with .025 makes an integer a real):

local integer steps = channeltime/.025

change it to a real variable, and use AttachReal instead of AttachInt

local integer steps = channeltime/.025
call AttachBoolean(cast, "stopped", stopped)
call AttachReal(t, "steps", steps)

You shouldn't have started a new thread for this. The existing would be fine... Really!
 
Level 5
Joined
Jul 17, 2006
Messages
145
O_O using a fraction requires to statement to be a real? : /

Anyways, thanks for the help and sorry about the new thread :p
 
Level 5
Joined
Jul 17, 2006
Messages
145
New Message:

Math checking time ^^

Alright, heres what i have in total, and it WORKS (oh thank god!)

Code:
function Trig_Captian_Gemross_Rocket_Channel_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04D'
endfunction

function Rocket_Channel_Add takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetAttachedUnit(t, "cast")
    local integer channeltime = GetAttachedInt(cast, "channeltime")
    local boolean stopped = GetAttachedBoolean(cast, "stopped")
    call AttachInt( cast, "channeltime", channeltime + 1 )
    if stopped == true then
        call FlushHandle(t)
        call DestroyTimer(t)
    endif
    set cast = null
    set t = null
endfunction

function Trig_Captian_Gemross_Rocket_Channel_Actions takes nothing returns nothing
    local boolean stopped = false
    local integer channeltime = 0
    local unit cast = GetTriggerUnit()    
    local timer t = CreateTimer()
    call AttachBoolean(cast, "stopped", stopped)
    call AttachInt(cast, "channeltime", channeltime)
    call AttachObject(t, "cast", cast)
    call TimerStart(t, 1, true, function Rocket_Channel_Add)
    set cast = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Captian_Gemross_Rocket_Channel takes nothing returns nothing
    set gg_trg_Captian_Gemross_Rocket_Channel = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Gemross_Rocket_Channel, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Captian_Gemross_Rocket_Channel, Condition( function Trig_Captian_Gemross_Rocket_Channel_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Gemross_Rocket_Channel, function Trig_Captian_Gemross_Rocket_Channel_Actions )
endfunction

Alright, this script here takes every second sence casting the ability.

Code:
function Rocket_Engines_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A04D'
endfunction

function Rocket_Engines_Knockback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetAttachedUnit(t, "cast")
    local integer steps = GetAttachedInt(t, "steps")
    local location curr = GetUnitLoc(cast)
    local location dest = PolarProjectionBJ(curr, 17.5 + (5 * GetUnitAbilityLevel(cast, 'A04D')), GetUnitFacing(cast))
    call SetUnitPositionLoc(cast, dest)
    call RemoveLocation(curr)
    call RemoveLocation(dest)        
    set curr = null
    set dest = null
    if (steps <= 1) then
        call FlushHandle(t)
        call DestroyTimer(t)
        call FlushHandle(cast)
        set t = null
        set cast = null
        return    
    endif
    set cast = null
    call AttachInt( t, "steps", steps - 1 )
    set t = null
endfunction

function Rocket_Engines_Actions takes nothing returns nothing
    local boolean stopped = true
    local timer t = CreateTimer()
    local unit cast = GetTriggerUnit()
    local integer channeltime = GetAttachedInt(cast, "channeltime")
    local real steps = I2R(channeltime)/.025
    call AttachBoolean(cast, "stopped", stopped)
    call AttachInt(t, "steps", R2I(steps))
    call AttachObject(t, "cast", cast)
    call TimerStart(t, .025, true, function Rocket_Engines_Knockback)
    set cast = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Captian_Germross_Rocket_Engines takes nothing returns nothing
    set gg_trg_Captian_Germross_Rocket_Engines = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Captian_Germross_Rocket_Engines, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition( gg_trg_Captian_Germross_Rocket_Engines, Condition( function Rocket_Engines_Conditions ) )
    call TriggerAddAction( gg_trg_Captian_Germross_Rocket_Engines, function Rocket_Engines_Actions )
endfunction

alright, and this tells it what to do when it stopps or is stopped channeling.

Now, my problem is:
When its done casting, the loop will go off and set channeltime to + 1. but will this happen before the channeltime is set in stone (in other words, will the chaneltime accually last for 5 seconds, or only four because thats what it was when the second trigger started.) I know it dose (i tested it with triggers such as "Display Channeltime"), but i want to know why, because to me it seems like its up for grabs and i just got lucky (though maybe it is XD)
 
Status
Not open for further replies.
Top