HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Shooting Ability

05-28-2006, 02:43 PM#1
Kilroy40
I want to know how to make abilities that allow the unit to shoot and keep shooting until the player presses stop, and how to make then shoot really fast (press hotkey click, press hotkey click).
I tried using shockwave and carrion swarm as a root ability but they don't let you shoot very fast, and I need to find a way to make them keep shooting really fast like for a machine gun without clicking more than once. I've seen it many times before but I don't know how. PLEASE respond quickly!
05-29-2006, 03:05 AM#2
Naakaloh
Well, one thing you could do to avoid any abilities completely is give the unit a high attack speed, artillery attack, splash and tell it to attack ground. But more seriously, Cluster Rockets might fit what you're looking for or if you want to script a spell, you could use a channelling ability that fires projectiles toward a target, but I suggest you look at using Cluster Rockets first. Also, reducing the value in the cooldown field will let you cast the spell sooner...
05-29-2006, 03:31 AM#3
map-maker
makes it a channeling spell and as long as they keep casting create dummy units that cast carrion swarm and destroy them every so many seconds.
05-29-2006, 03:24 PM#4
Kilroy40
Thx guys, the battle.net forums never give me any replies but you guys helped out, ty so much!
05-29-2006, 06:09 PM#5
Karawasa
BNET forums suck.
05-29-2006, 09:28 PM#6
The)TideHunter(
Quote:
Originally Posted by Karawasa
BNET forums suck.

Totally true, if you need help you should come here.
Bnet forums has bad UI and dosent look half as good as Wc3c does, Wc3c also just sticks to Warcraft 3 External side, as bnet forums can go onto "I lost my cd key", or "How do i log into b.net".

Stick to Wc3c :)
05-29-2006, 09:35 PM#7
wereMole
dumb thread -_-

getting a good B.net reputation is hard work (and I didn't make it lol), doing it here is just a lot of buttkissing..
05-29-2006, 10:16 PM#8
The)TideHunter(
Anyway, going back on topic, you could use my projectile system i just finished making, if you want it to be officent you will have to keep updating up though.
Im going to keep updating it until its something near as good as Vexs caster system (im in no competition with Vex or his system).

Here it is up to now:

Collapse JASS:
// Globals (Mainly for Jass Editing Programs)
globals
    gamecache udg_GC = null
endglobals

// Casual Functions Engine
// Created and Updated by The)TideHunter(
// Creation Began: 28/05/06
// Last Updated: 30/05/06

// Game Cache Return Function
function CF_GC takes nothing returns gamecache
    if(udg_GC == null) then
        call FlushGameCache(InitGameCache("GC"))
        set udg_GC = InitGameCache("GC")
    endif
    return udg_GC
endfunction

// Constants
constant function CF_MaxProjectileCollisionRange takes nothing returns real
    return 7.5
endfunction

// Rawcodes
constant function CF_DummyRawcode takes nothing returns integer
    return 'A000'
endfunction

// Handle Variables
function CF_H2I takes handle H returns integer
    return H
    return 0
endfunction

function CF_I2Unit takes integer I returns unit
    return I
    return null
endfunction

function CF_I2Effect takes integer I returns effect
    return I
    return null
endfunction

function CF_I2Group takes integer I returns group
    return I
    return null
endfunction

// Attach Variables
function CF_StoreHandle takes handle whichHandle, string label, string handleType returns nothing
    call StoreInteger(CF_GC(), handleType, label, CF_H2I(whichHandle))
endfunction

function CF_AttachInt takes integer whichInt, string label, handle attachToWhichHandle returns nothing
    call StoreInteger(CF_GC(), I2S(CF_H2I(attachToWhichHandle)), label, whichInt)
endfunction

function CF_AttachString takes string whichString, string label, handle attachToWhichHandle returns nothing
    call StoreString(CF_GC(), I2S(CF_H2I(attachToWhichHandle)), label, whichString)
endfunction

function CF_AttachReal takes real whichReal, string label, handle attachToWhichHandle returns nothing
    call StoreReal(CF_GC(), I2S(CF_H2I(attachToWhichHandle)), label, whichReal)
endfunction

function CF_AttachBoolean takes boolean whichBoolean, string label, handle attachToWhichHandle returns nothing
    call StoreBoolean(CF_GC(), I2S(CF_H2I(attachToWhichHandle)), label, whichBoolean)
endfunction

function CF_AttachHandle takes handle whichHandle, string label, handle attachToWhichHandle returns nothing
    call StoreInteger(CF_GC(), I2S(CF_H2I(attachToWhichHandle)), label, CF_H2I(whichHandle))
endfunction

function CF_GetStoredEffect takes string label returns handle
    return CF_I2Effect(GetStoredInteger(CF_GC(), "Effect", label))
endfunction

function CF_GetAttachedInt takes string label, handle attachedHandle returns integer
    return GetStoredInteger(CF_GC(), I2S(CF_H2I(attachedHandle)), label)
endfunction

function CF_GetAttachedString takes string label, handle attachedHandle returns string
    return GetStoredString(CF_GC(), I2S(CF_H2I(attachedHandle)), label)
endfunction

function CF_GetAttachedReal takes string label, handle attachedHandle returns real
    return GetStoredReal(CF_GC(), I2S(CF_H2I(attachedHandle)), label)
endfunction

function CF_GetAttachedBoolean takes string label, handle attachedHandle returns boolean
    return GetStoredBoolean(CF_GC(), I2S(CF_H2I(attachedHandle)), label)
endfunction

function CF_GetAttachedUnit takes string label, handle attachedHandle returns unit
    return CF_I2Unit(GetStoredInteger(CF_GC(), I2S(CF_H2I(attachedHandle)), label))
endfunction

function CF_GetAttachedEffect takes string label, handle attachedHandle returns effect
    return CF_I2Effect(GetStoredInteger(CF_GC(), I2S(CF_H2I(attachedHandle)), label))
endfunction

function CF_GetAttachedGroup takes string label, handle attachedHandle returns group
    return CF_I2Group(GetStoredInteger(CF_GC(), I2S(CF_H2I(attachedHandle)), label))
endfunction

function CF_RemoveAttachments takes handle attachedHandle returns nothing
    call FlushStoredMission(CF_GC(), I2S(CF_H2I(attachedHandle)))
endfunction

// Common Functions
function CF_IsXSafe takes real X returns boolean
    local rect SafeRect = bj_mapInitialPlayableArea
    local real MinSafeX = GetRectMinX(SafeRect)
    local real MaxSafeX = GetRectMaxX(SafeRect)
    if(MinSafeX < X) and (MaxSafeX > X) then
        return true
    endif
    call RemoveRect(SafeRect)
    set SafeRect = null
    return false
endfunction

function CF_IsYSafe takes real Y returns boolean
    local rect SafeRect = bj_mapInitialPlayableArea
    local real MinSafeY = GetRectMinY(SafeRect)
    local real MaxSafeY = GetRectMaxY(SafeRect)
    if(MinSafeY < Y) and (MaxSafeY > Y) then
        return true
    endif
    call RemoveRect(SafeRect)
    set SafeRect = null
    return false
endfunction

function CF_IsLocSafe takes real X, real Y returns boolean
    if(CF_IsXSafe(X) == true) and (CF_IsYSafe(Y) == true) then
        return true
    endif
    return false
endfunction

function CF_IsLocSafeEx takes location whichLocation returns boolean
    return CF_IsLocSafe(GetLocationX(whichLocation), GetLocationY(whichLocation))
endfunction

function CF_DestroyTimer takes timer whichTimer returns nothing
    call CF_RemoveAttachments(whichTimer)
    call DestroyTimer(whichTimer)
endfunction

function CF_UnitDamageUnit takes unit credit, unit target, real amount, integer attackIndex, integer damageIndex returns nothing
    call UnitDamageTarget(credit, target, amount, true, false, ConvertAttackType(attackIndex), ConvertDamageType(damageIndex), ConvertWeaponType(0))
endfunction

function CF_UnitSpellDamageUnit takes unit credit, unit target, real amount returns nothing
    if(IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) then
        call CF_UnitDamageUnit(credit, target, amount, 4, 26)  
    endif
endfunction

function CF_GetADummy takes real X, real Y returns unit
    local unit u = CreateUnit(Player(15), CF_DummyRawcode(), X, Y, 0.)
    call UnitAddAbility(u, 'Avul')
    call UnitAddAbility(u, 'Aloc')
    call UnitAddAbility(u, 'Amph')
    call UnitRemoveAbility(u, 'Amph')
    return u
endfunction 

// Extended Creation Functions
// Effect
function CF_CreateEffect takes real X, real Y, string modelPath, real height returns effect
    local unit CarryingUnit
    local effect NewEffect
    if(CF_IsLocSafe(X, Y) == true) then
        set CarryingUnit = CF_GetADummy(X, Y)
        set NewEffect = AddSpecialEffectTarget(modelPath, CarryingUnit, "origin")
        call CF_AttachHandle(CarryingUnit, "Effect_CarryingUnit", NewEffect)
        call CF_AttachReal(X, "Effect_CoordX", NewEffect)
        call CF_AttachReal(Y, "Effect_CoordY", NewEffect)
        call CF_AttachReal(height, "Effect_Height", NewEffect)
        call CF_AttachString(modelPath, "Effect_ModelPath", NewEffect)
        call CF_StoreHandle(NewEffect, "LastCreatedEffect", "Effect")
        call SetUnitFlyHeight(CarryingUnit, height, 0.)
        return NewEffect
    endif
    return null
endfunction

function CF_GetEffectCarryingUnit takes effect whichEffect returns unit
    return CF_GetAttachedUnit("Effect_CarryingUnit", whichEffect)
endfunction

function CF_GetEffectX takes effect whichEffect returns real
    return CF_GetAttachedReal("Effect_CoordX", whichEffect)
endfunction

function CF_GetEffectY takes effect whichEffect returns real
    return CF_GetAttachedReal("Effect_CoordY", whichEffect)
endfunction

function CF_GetEffectLoc takes effect whichEffect returns location
    return Location(CF_GetEffectX(whichEffect), CF_GetEffectY(whichEffect))
endfunction

function CF_GetEffectModelPath takes effect whichEffect returns string
    return CF_GetAttachedString("Effect_ModelPath", whichEffect)
endfunction

function CF_GetEffectHeight takes effect whichEffect returns real
    return CF_GetAttachedReal("Effect_Height", whichEffect)
endfunction

function CF_GetLastCreatedEffect takes nothing returns effect
    return CF_GetStoredEffect("LastCreatedEffect")
endfunction

function CF_SetEffectX takes effect whichEffect, real X returns nothing
    if(CF_IsXSafe(X) == true) then
        call SetUnitX(CF_GetEffectCarryingUnit(whichEffect), X)
        call CF_AttachReal(X, "Effect_CoordX", whichEffect)
    endif
endfunction

function CF_SetEffectY takes effect whichEffect, real Y returns nothing
    if(CF_IsYSafe(Y) == true) then
        call SetUnitY(CF_GetEffectCarryingUnit(whichEffect), Y)
        call CF_AttachReal(Y, "Effect_CoordY", whichEffect)
    endif
endfunction

function CF_SetEffectLoc takes effect whichEffect, real X, real Y returns nothing
    if(CF_IsLocSafe(X, Y) == true) then
        call CF_SetEffectX(whichEffect, X)
        call CF_SetEffectY(whichEffect, Y)
    endif
endfunction

function CF_SetEffectLocEx takes effect whichEffect, location whichLoc returns nothing
    call CF_SetEffectLoc(whichEffect, GetLocationX(whichLoc), GetLocationY(whichLoc))
endfunction

function CF_SetEffectHeight takes effect whichEffect, real height returns nothing
    call SetUnitFlyHeight(CF_GetEffectCarryingUnit(whichEffect), height, 0.)
endfunction

function CF_MakeEffectFaceAngle takes effect whichEffect, real angle returns nothing
    call SetUnitFacing(CF_GetEffectCarryingUnit(whichEffect), angle)
endfunction

function CF_MakeEffectFaceAngleOverTime takes effect whichEffect, real angle, real duration returns nothing
    call SetUnitFacingTimed(CF_GetEffectCarryingUnit(whichEffect), angle, duration)
endfunction

function CF_MoveEffectFacingAngle takes effect whichEffect, real angle, real X, real Y returns nothing
    call CF_SetEffectLoc(whichEffect, X, Y)
    call CF_MakeEffectFaceAngle(whichEffect, angle)
endfunction

function CF_MoveEffectFacingAngleOverTime takes effect whichEffect, real angle, real X, real Y, real duration returns nothing
    call CF_SetEffectLoc(whichEffect, X, Y)
    call CF_MakeEffectFaceAngleOverTime(whichEffect, angle, duration)
endfunction     

function CF_CopyEffect takes effect whichEffect returns effect
    return CF_CreateEffect(CF_GetEffectX(whichEffect), CF_GetEffectY(whichEffect), CF_GetEffectModelPath(whichEffect), CF_GetEffectHeight(whichEffect))
endfunction

function CF_CopyEffectNewLoc takes effect whichEffect, real X, real Y returns effect
    local effect NewEffect = CF_CopyEffect(whichEffect)
    call CF_SetEffectLoc(NewEffect, X, Y)
    return NewEffect
endfunction

function CF_CopyEffectNewLocEx takes effect whichEffect, location whichLoc returns effect
    return CF_CopyEffectNewLoc(whichEffect, GetLocationX(whichLoc), GetLocationY(whichLoc))
endfunction

function CF_DestroyEffect takes effect whichEffect returns nothing
    local unit CarryingUnit = CF_GetEffectCarryingUnit(whichEffect)
    call CF_RemoveAttachments(whichEffect)
    call DestroyEffect(whichEffect)
    call RemoveUnit(CarryingUnit)
    set CarryingUnit = null
endfunction

function CF_DestroyTempEffect takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local effect DestroyingEffect = CF_GetAttachedEffect("Timer_TempEffect", t)
    call CF_DestroyEffect(DestroyingEffect)
    call CF_DestroyTimer(t)
    set t = null
    set DestroyingEffect = null
endfunction

function CF_CreateTempEffect takes real X, real Y, string modelPath, real duration, real height returns effect
    local timer t = CreateTimer()
    local effect NewEffect = CF_CreateEffect(X, Y, modelPath, height)
    call CF_AttachHandle(NewEffect, "Timer_TempEffect", t)
    call TimerStart(t, duration, false, function CF_DestroyTempEffect)
    return NewEffect
endfunction

function CF_CreateTempEffectLoc takes location whichLoc, string modelPath, real duration, real height returns effect
    return CF_CreateTempEffect(GetLocationX(whichLoc), GetLocationY(whichLoc), modelPath, duration, height)
endfunction
     
function CF_CopyTempEffect takes effect whichEffect, real duration returns effect
    local timer t = CreateTimer()
    local effect NewEffect = CF_CopyEffect(whichEffect)
    call CF_AttachHandle(NewEffect, "Timer_TempEffect", t)
    call TimerStart(t, duration, false, function CF_DestroyTempEffect)
    return NewEffect
endfunction

function CF_CopyTempEffectLoc takes effect whichEffect, real X, real Y, real duration returns effect
    local timer t = CreateTimer()
    local effect NewEffect = CF_CopyEffectNewLoc(whichEffect, X, Y)
    call CF_AttachHandle(NewEffect, "Timer_TempEffect", t)
    call TimerStart(t, duration, false, function CF_DestroyTempEffect)
    return NewEffect
endfunction

function CF_CopyTempEffectLocEx takes effect whichEffect, location whichLoc, real duration returns effect
    local timer t = CreateTimer()
    local effect NewEffect = CF_CopyEffectNewLocEx(whichEffect, whichLoc)
    call CF_AttachHandle(NewEffect, "Timer_TempEffect", t)
    call TimerStart(t, duration, false, function CF_DestroyTempEffect)
    return NewEffect
endfunction

// Main Functions
// Target Projectile
function CF_LaunchTargetProjectile_Update takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local effect Projectile = CF_GetAttachedEffect("Projectile_Effect", t)
    local unit credit = CF_GetAttachedUnit("Projectile_Credit", t)
    local unit target = CF_GetAttachedUnit("Projectile_Target", t)
    local real DamageAmount = CF_GetAttachedReal("Projectile_Damage", t)
    local real CurrentX = CF_GetEffectX(Projectile)
    local real CurrentY = CF_GetEffectY(Projectile)
    local real TargetX = GetUnitX(target)               
    local real TargetY = GetUnitY(target)
    local real angle = bj_RADTODEG * Atan2(TargetY - CurrentY, TargetX - CurrentX)
    local real speed = CF_GetAttachedReal("Projectile_Speed", t)
    local real distance = SquareRoot((TargetX - CurrentX) * (TargetX - CurrentX) + (TargetY - CurrentY) * (TargetY - CurrentY))
    local real time = distance / speed
    local real MovingDistance = CF_GetAttachedReal("Projectile_MovingDistance", t)
    local real NewX
    local real NewY
    local boolean FirstRun = CF_GetAttachedBoolean("Projectile_FirstRun", t)
    if(FirstRun == true) then
        set MovingDistance = distance / (time / 0.01)
        call CF_AttachReal(MovingDistance, "Projectile_MovingDistance", t)
        call CF_AttachBoolean(false, "Projectile_FirstRun", t)
    endif
    set NewX = CurrentX + MovingDistance * Cos(angle * bj_DEGTORAD)
    set NewY = CurrentY + MovingDistance * Sin(angle * bj_DEGTORAD) 
    if(distance < CF_MaxProjectileCollisionRange()) then
        call CF_UnitDamageUnit(credit, target, DamageAmount, 0, 4)
        call CF_DestroyEffect(Projectile)
        call CF_DestroyTimer(t)
        set t = null
        set Projectile = null
    else
        call CF_MoveEffectFacingAngle(Projectile, angle, NewX, NewY) 
        call TimerStart(t, 0.01, false, function CF_LaunchTargetProjectile_Update)
    endif         
endfunction

function CF_LaunchTargetProjectile_Begin takes unit credit, unit target, real startX, real startY, real damage, string modelPath, real speed, real height returns nothing
    local timer t = CreateTimer()
    local effect ProjectileEffect = CF_CreateEffect(startX, startY, modelPath, height)
    call CF_AttachHandle(credit, "Projectile_Credit", t)
    call CF_AttachHandle(target, "Projectile_Target", t)
    call CF_AttachHandle(ProjectileEffect, "Projectile_Effect", t)
    call CF_AttachReal(damage, "Projectile_Damage", t)
    call CF_AttachReal(speed, "Projectile_Speed", t)
    call CF_AttachBoolean(true, "Projectile_FirstRun", t)
    call CF_AttachReal(0., "Projectile_MovingDistance", t)
    call TimerStart(t, 0.01, false, function CF_LaunchTargetProjectile_Update)
endfunction

All you need is a global gamecache called GC (or udg_GC in Jass terms), then use the function CF_LaunchTargetProjectile_Begin

Like this:

Collapse JASS:
call CF_LaunchTargetProjectile_Begin(Your attacker, Your target, X of where the projectile begins, Y of where the projectile begins, modelPath(filepath), projectile speed, projectile height)

Or:

Collapse JASS:
call CF_LaunchTargetProjectile_Begin(unit credit, unit target, real startX, real startY, real damage, string modelPath, real speed, real height)

You can refer to this Thread for more infomation:
http://wc3campaigns.net/showthread.php?t=83709