• 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 Issue

Status
Not open for further replies.
Level 24
Joined
May 9, 2007
Messages
3,563
JASS:
real damage = (GetHeroInt(GetTriggerUnit(), true ) + GetUnitAbilityLevel(GetTriggerUnit(), 'A003'))


For some reason this is returning 0, even if intelligence is one (default for the current map that I'm making. Any ideas why?

JASS:
scope StormBolt initializer Init

globals
    private constant integer Rawcode = 'A003'
    private constant string Model = "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl"
    private real damage = (GetHeroInt(GetTriggerUnit(), true ) + GetUnitAbilityLevel(GetTriggerUnit(), 'A003'))
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Rawcode
endfunction

function StormBoltHit takes nothing returns nothing
    local Projectile p = ProjectileInt
    if IsUnitEnemy( p.hit, GetOwningPlayer( p.origin ) ) then
        call KnockbackTarget( p.hit, Atan2( GetUnitY( p.hit ) - GetUnitY( p.missile ), GetUnitX( p.hit ) - GetUnitX( p.missile ) ), 500, 60, false, true )
        call BJDebugMsg(R2S(damage))
        call UnitDamageTarget( p.origin, p.hit, damage, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null )
        set p.end = true
    endif    
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real damage = (GetHeroInt( caster, true ) + GetUnitAbilityLevel( caster, Rawcode) * 10 )
    local location loc = GetSpellTargetLoc()
    local real x = GetUnitX( caster )
    local real y = GetUnitY( caster )
    local real tx = GetLocationX( loc )
    local real ty = GetLocationY( loc )
    local real a = Atan2( ty - y, tx -x )
    local unit projectile = AddProjectile( caster, x + 50 * Cos( a ), y + 50 * Sin( a ), x + 2000 * Cos( a ), y + 2000 * Sin( a ), 1000, 115, 0, Model, "StormBoltHit", false, 0 )
    call SetUnitFlyHeight( projectile, 55, 0 )
    call SetUnitScale( projectile, 1.3, 1.3, 1.3 )
    set caster = null
    call RemoveLocation( loc )
    set loc = null
    set projectile = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Actions )
    call TriggerAddCondition( t, Condition( function Conditions ) )
endfunction

endscope

I've just started JASS, so please excuse me if its a stupid mistake,

I'm using systems by Bobo_The_Kodo (a friend of mine)
 
Level 24
Joined
May 9, 2007
Messages
3,563
Update:

Still, when I return that folmurla when the hero has 2 Magic (Int) and 1 level of the skill it = 0. (Debug Msg)

Here is my new code.

JASS:
scope StormBolt initializer Init

globals
    private constant integer Rawcode = 'A003'
    private constant string Model = "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl"
endglobals

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Rawcode
endfunction

function StormBoltHit takes nothing returns nothing
    local Projectile p = ProjectileInt
    if IsUnitEnemy( p.hit, GetOwningPlayer( p.origin ) ) then
        call KnockbackTarget( p.hit, Atan2( GetUnitY( p.hit ) - GetUnitY( p.missile ), GetUnitX( p.hit ) - GetUnitX( p.missile ) ), 500, 60, false, true )
        call UnitDamageTarget( p.origin, p.hit, I2R((GetHeroInt(GetTriggerUnit(), true ) + GetUnitAbilityLevel(GetTriggerUnit(), 'A003')) * 10), false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null )
        call BJDebugMsg(R2S(I2R((GetHeroInt(GetTriggerUnit(), true ) + GetUnitAbilityLevel(GetTriggerUnit(), 'A003')) * 10)))
        set p.end = true
    endif    
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real damage = (GetHeroInt( caster, true ) + GetUnitAbilityLevel( caster, Rawcode) * 10 )
    local location loc = GetSpellTargetLoc()
    local real x = GetUnitX( caster )
    local real y = GetUnitY( caster )
    local real tx = GetLocationX( loc )
    local real ty = GetLocationY( loc )
    local real a = Atan2( ty - y, tx -x )
    local unit projectile = AddProjectile( caster, x + 50 * Cos( a ), y + 50 * Sin( a ), x + 2000 * Cos( a ), y + 2000 * Sin( a ), 1000, 115, 0, Model, "StormBoltHit", false, 0 )
    call SetUnitFlyHeight( projectile, 55, 0 )
    call SetUnitScale( projectile, 1.3, 1.3, 1.3 )
    set caster = null
    call RemoveLocation( loc )
    set loc = null
    set projectile = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function Actions )
    call TriggerAddCondition( t, Condition( function Conditions ) )
endfunction

endscope
 
Level 5
Joined
Jan 15, 2007
Messages
199
or it might be called p.origin

Your Code said:
JASS:
AddProjectile( caster, x + 50 * Cos( a ), y + 50 * Sin( a ), x + 2000 * Cos( a ), y + 2000 * Sin( a ), 1000, 115, 0, Model, "StormBoltHit", false, 0 )

Look at the first value passed?

System Code said:
JASS:
function AddProjectile takes unit origin, real x, real y, real tx, real ty, real speed, real radius, real damage, string model, string onhit, boolean checkDead, integer Struct returns unit
...
        set p.origin = origin
 
Status
Not open for further replies.
Top