HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

need help with JASS

09-02-2007, 12:23 AM#1
Tiku
So basically im making a trigger, just like a real bullet instead of shockwave....

heres the trigger:
Collapse JASS:
constant function bulletid takes nothing returns integer
    return 'h001'
endfunction

function Trig_Shoot_l_Mine_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A000' )
endfunction

function IsUnitAlive takes nothing returns boolean
    return IsUnitAliveBJ(GetEnumUnit()) == true
endfunction

function bulletshot takes nothing returns nothing
    local timer i = GetExpiredTimer()
    local unit bullet = GetHandleUnit( i, "bullet" )
    local real face = GetUnitFacing(bullet)
    local real newx = GetUnitX(bullet) + 50*Cos(face*bj_DEGTORAD)
    local real newy = GetUnitY(bullet) + 50*Sin(face*bj_DEGTORAD)
    local integer dist = GetUnitUserData(bullet)
    local boolexpr b = Condition(function IsUnitAlive)
    local group bull
    local unit s
    local boolean flag
    
     call SetUnitUserData(bullet, dist+50)
     call SetUnitX(bullet, newx)
     call SetUnitY(bullet, newy)
    
     call GroupEnumUnitsInRange(bull, newx, newy, 50, b)
     loop
        set s = FirstOfGroup(bull)
        exitwhen flag == true or s == null
        if IsUnitEnemy(s, GetOwningPlayer(bullet)) then
            set flag = true
            call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", GetUnitX(s), GetUnitY(s)))
            call UnitDamageTarget(bullet, s, 500, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
        endif
        call GroupRemoveUnit(bull, s)
    endloop
    if flag or GetUnitUserData(bullet) >= 800 then
        call GroupRemoveUnit(bull, bullet)
        call RemoveUnit(bullet)
    endif
  
    set s = null 
endfunction

function Trig_Shoot_l_Mine_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real castx = GetUnitX(caster)
    local real casty = GetUnitY(caster)
    local player owner = GetOwningPlayer(caster)
    local real face = GetUnitFacing(caster)
    local timer i = CreateTimer()
    local unit bullet 
    
    set bullet = CreateUnit(owner, bulletid(), castx, casty, face)
    call SetHandleHandle(i, "bullet", bullet)
    call TimerStart(i, 0.033, true, function bulletshot)
    
    call TriggerSleepAction(4.0)
    call DestroyTimer(i)
    set caster = null
    set i = null
endfunction

//===========================================================================
function InitTrig_Shoot_l_Mine takes nothing returns nothing
    set gg_trg_Shoot_l_Mine = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot_l_Mine, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Shoot_l_Mine, Condition( function Trig_Shoot_l_Mine_Conditions ) )
    call TriggerAddAction( gg_trg_Shoot_l_Mine, function Trig_Shoot_l_Mine_Actions )
endfunction


i copyed some stuff from the hero spell pack, forgot who made it, but the hero was called grim pharoah...

the only problem im having atm is the bullet wont hit a unit, damage it or die....

and once it hits its max range it wont disapear, it'll keep going till forever... xD

so please help :D ill be greatful and give rep!
09-02-2007, 12:41 AM#2
moyack
This hero was developed by Rising Dusk, you should PM him about the problem.

I think the problem is setting taht you are not creating the group. It should be in this way:

Collapse JASS:
function bulletshot takes nothing returns nothing
    local timer i = GetExpiredTimer()
    local unit bullet = GetHandleUnit( i, "bullet" )
    local real face = GetUnitFacing(bullet)
    local real newx = GetUnitX(bullet) + 50*Cos(face*bj_DEGTORAD)
    local real newy = GetUnitY(bullet) + 50*Sin(face*bj_DEGTORAD)
    local integer dist = GetUnitUserData(bullet)
    local boolexpr b = Condition(function IsUnitAlive)
    local group bull = CreateGroup() //<= Add this setting
09-02-2007, 12:45 AM#3
Tiku
hmm, i tried it out, but it still didnt work... :/ this trigger has been bothering me for quite a while, but thanks moyack! :D ill message up rising_dusk right now :D

well still if anyone can help me out, id appreciate it