• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Change death time?

Status
Not open for further replies.
Level 4
Joined
Jan 4, 2006
Messages
60
what do you do you change in this code to let the missle travel from corner to corner on a 256x256 size map?

JASS:
//Author: Leopard
//Version: 22 August 2005
//Spell's CodeName : MissileSeeker
//Raw Codes Part

function MissileSeeker_MainAbil takes nothing returns integer
    return 'A001' //Raw code of Missile Seeker ability
endfunction

function MissileSeeker_projectile takes nothing returns integer
    return 'o000' //Raw code of Missile projectile
endfunction

function MissileSeeker_dummy takes nothing returns integer
    return 'o001' //Raw code of Explosion (Dummy) unit 
endfunction

function MissileSeeker_RawExplo takes nothing returns integer
    return 'A000' //Raw code of Explosion (Missile) ability 
endfunction

function MissileSeeker_RawMSdummy takes nothing returns integer
    return 'A002' //Raw code of Missile Seeker (Dummy) ability 
endfunction

function MissileSeeker_OrderExplode takes nothing returns string
    return "thunderclap" //Order string for explosion ability
endfunction

function MissileSeeker_OrderLaunch takes nothing returns string
    return "chainlightning" //Order string for Missile Launch ability
endfunction

//========================================================================================
//Spell Setting

function MissileSeeker_NumMissile takes integer level returns integer
    local integer array num
    set num[1] = 3     //Set this integer to number of missiles that you want to launched
    set num[2] = 3
    set num[3] = 3 
    return num[level]  
endfunction

function MissileSeeker_MissileDur takes integer level returns real
    local real array dur
    set dur[1] = 2.00   //Set this real to missile's live time
    set dur[2] = 2.00   //If the missile cannot acquire the target during its life time,
    set dur[3] = 2.00   //it will explode itself.
    return dur[level] 
endfunction

function MissileSeeker_MaxTurnAngle takes integer level returns real
    local real array turnangle
    set turnangle[1] = 5.00
    set turnangle[2] = 5.00
    set turnangle[3] = 5.00
    return turnangle[level]  
    //Set this real to maximum angle that the missile can turn to
    //If you set it with 0, the missile only move straight forward
    //If you set it with 90, the missile can turn left or right precisely
    //If you set it with 180, the missile can turn 180 degrees, letter U              
endfunction

function MissileSeeker_DevAngle takes integer level returns real
    local real array dev
    set dev[1] = 30.00
    set dev[2] = 30.00
    set dev[3] = 30.00
    return dev[level]
    //if you set this real to 0, each missile will be launched with direction equal to caster's facing angle
    //if you set this real to 60, each missile will be launched with direction equal to (caster's facing angle + (Random real number between -60 and 60))
endfunction

function MissileSeeker_MissileSpeed takes integer level returns real
    local real array speed
    set speed[1] = 1250.0
    set speed[2] = 1250.0
    set speed[3] = 1250.0
    return speed[level]
endfunction
    

//========================================================================================

function MissileSeeker_expld_act takes nothing returns nothing
    local integer level = RetrieveInt(GetTriggeringTrigger(), "MissileSeeker_level")
    local unit caster = RetrieveUnit(GetTriggeringTrigger(), "MissileSeeker_caster") 
    local unit missile = RetrieveUnit(GetTriggeringTrigger(), "MissileSeeker_missile")
    local unit dummyu
    local effect bloweff
    local location missloc = GetUnitLoc(missile)

    set dummyu = CreateUnitAtLoc( GetOwningPlayer(caster), MissileSeeker_dummy(), missloc, 0.00 )
    call SetUnitAbilityLevel( dummyu, MissileSeeker_RawExplo(), level )
    call IssueImmediateOrder( dummyu, MissileSeeker_OrderExplode() )

    set bloweff =  AddSpecialEffectLoc("Abilities\\Weapons\\Mortar\\MortarMissile.mdl", missloc)
    call DestroyEffect( bloweff )
    call UnitApplyTimedLife( dummyu, 'BTLF', 1.00 )

    call RemoveLocation(missloc)
    set bloweff = null
    set missloc = null
    set caster = null
    set missile = null
    set dummyu = null
endfunction

function MissileSeeker_Homing takes nothing returns nothing
    local integer level = RetrieveInt(GetExpiredTimer(), "MissileSeeker_level") 
    local unit missile = RetrieveUnit(GetExpiredTimer(), "MissileSeeker_missile")   
    local unit target = RetrieveUnit(GetExpiredTimer(), "MissileSeeker_target")

    local location missloc = GetUnitLoc(missile)
    local location targetloc = GetUnitLoc(target)
    local location polarproj
    local real x
    local real y

  
    if ( (DistanceBetweenPoints(targetloc, missloc) > (MissileSeeker_MissileSpeed(level)*0.04)) and (IsUnitAliveBJ(missile) == true) ) then
        set x = AngleBetweenPoints(missloc, targetloc)
        if (x < 0.00) then
            set x = x + 360.00
        endif
        set y = GetUnitFacing(missile)
        if ((x > y) and ((x - y) > 180.00)) then
            set y = y + 360.00
        else
            if ((y > x) and ((y - x) > 180.00)) then
                set x = x + 360.00
            endif
        endif

        set polarproj = PolarProjectionBJ(missloc, (MissileSeeker_MissileSpeed(level)*0.04), y)
        if (x > y) then
            if ((x - y) >= MissileSeeker_MaxTurnAngle(level)) then
                call SetUnitPositionLocFacingBJ(missile, polarproj, (y + MissileSeeker_MaxTurnAngle(level)))
            else
                call SetUnitPositionLocFacingBJ(missile, polarproj, x)
            endif
        else
            if ( y > x ) then
                if ( ( y - x ) >= MissileSeeker_MaxTurnAngle(level) ) then
                    call SetUnitPositionLocFacingBJ(missile, polarproj, (y - MissileSeeker_MaxTurnAngle(level)))
                else
                    call SetUnitPositionLocFacingBJ(missile, polarproj, x)
                endif
            else
                call SetUnitPositionLocFacingBJ(missile, polarproj, y)
            endif
        endif
    else
        call KillUnit( missile )
    endif

    call RemoveLocation(missloc)
    call RemoveLocation(targetloc)
    call RemoveLocation(polarproj)
    set polarproj = null
    set missloc = null
    set targetloc = null
    set missile = null
    set target = null
endfunction

function MissileSeeker_Launch_Cond takes nothing returns boolean
    return (GetSpellAbilityId() == MissileSeeker_RawMSdummy())
endfunction

function MissileSeeker_Launch takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local integer level = GetUnitAbilityLevel(caster, MissileSeeker_RawMSdummy())
    local unit missile
    local unit target = GetSpellTargetUnit()
    local location castloc = GetUnitLoc(caster)
    local location targetloc = GetUnitLoc(target)
    local timer t = CreateTimer()
    local trigger expld = CreateTrigger()
    local triggeraction eact
 
    set missile = CreateUnitAtLoc(GetOwningPlayer(caster), MissileSeeker_projectile(), castloc, GetUnitFacing(caster))
    call UnitApplyTimedLife(missile, 'BTLF', MissileSeeker_MissileDur(level))

    if IsUnitType(target, UNIT_TYPE_FLYING) then
        call SetUnitFlyHeight(missile, GetUnitFlyHeight(target), GetUnitFlyHeight(target)*MissileSeeker_MissileSpeed(level)/(1.5*DistanceBetweenPoints(castloc, targetloc))) 
    endif
 
    call TriggerRegisterUnitEvent(expld, missile, EVENT_UNIT_DEATH)
    set eact = TriggerAddAction(expld, function MissileSeeker_expld_act)

    call StoreHandle(expld,caster,"MissileSeeker_caster")
    call StoreInt(expld,level,"MissileSeeker_level")
    call StoreInt(t,level,"MissileSeeker_level")
    call StoreHandle(t,missile,"MissileSeeker_missile")
    call StoreHandle(expld,missile,"MissileSeeker_missile")
    call StoreHandle(t,target,"MissileSeeker_target")
    call TimerStart(t, 0.04, true, function MissileSeeker_Homing)

    call PolledWait(MissileSeeker_MissileDur(level) + 1.00)
    
    call Flush(t)
    call Flush(expld)
    call DestroyTimer(t)
    call TriggerRemoveAction(expld, eact)
    call DestroyTrigger(expld)
    call RemoveLocation(castloc)
    call RemoveLocation(targetloc)
    set targetloc = null
    set castloc = null
    set caster = null
    set missile = null
    set target = null
    set t = null
    set expld = null
    set eact = null 
 
endfunction

function MissileSeeker_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == MissileSeeker_MainAbil() )
endfunction

function MissileSeeker_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location casterloc
    local unit dummyu
    local integer idx = 0
    local unit target = GetSpellTargetUnit() 
    local integer level = GetUnitAbilityLevel(caster, MissileSeeker_MainAbil()) 
    local trigger launchtrig = CreateTrigger()
    local triggeraction lact
    local triggercondition lcond

    call TriggerRegisterAnyUnitEventBJ( launchtrig, EVENT_PLAYER_UNIT_SPELL_CAST )
    set lcond = TriggerAddCondition( launchtrig, Condition( function MissileSeeker_Launch_Cond ) )
    set lact = TriggerAddAction( launchtrig, function MissileSeeker_Launch )
 
    loop
        exitwhen idx >= MissileSeeker_NumMissile(level)
        set casterloc = GetUnitLoc(caster)
        set dummyu = CreateUnitAtLoc(GetOwningPlayer(caster), MissileSeeker_dummy(), casterloc, GetUnitFacing(caster) + GetRandomReal((-1*MissileSeeker_DevAngle(level)), MissileSeeker_DevAngle(level)) )
        call SetUnitAbilityLevel( dummyu,MissileSeeker_RawMSdummy(), level )
        call IssueTargetOrder( dummyu, MissileSeeker_OrderLaunch(), target )
        call UnitApplyTimedLife( dummyu, 'BTLF', 1.00 )
        call RemoveLocation(casterloc)
        call TriggerSleepAction( 0.20 )
        set idx = idx + 1
    endloop

    call TriggerRemoveAction(launchtrig, lact)
    call TriggerRemoveCondition(launchtrig, lcond)
    call DestroyTrigger(launchtrig)
    set lcond = null
    set lact = null   
    set launchtrig = null
    set casterloc = null
    set caster = null
    set dummyu = null
    set target = null
endfunction

//===========================================================================
function InitTrig_MissileSeeker takes nothing returns nothing
    set gg_trg_MissileSeeker = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_MissileSeeker, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_MissileSeeker, Condition( function MissileSeeker_Conditions ) )
    call TriggerAddAction( gg_trg_MissileSeeker, function MissileSeeker_Actions )
endfunction
 
Status
Not open for further replies.
Top