HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

What to do with this function.... add to Spell Classes System?

04-20-2004, 04:39 AM#1
Narwanza
Don't ask me why I created this function, because I don't quite know the answer for myself. I just created it.... I think it might be useful for AIAndy to implement a derivative of it into his spell classes code for someone who wants to create a spell effect for locations in a sine cuve. It could be really cool if added with a timer and then have 2 go off at once. One with a positive magnitude, and the second with a negative magnitude. If you know what the graphs of y = sin x and y = -sin x you know what I mean. Anyway, here is the function. It basically creates locations on a sine curve between two points. Note that the points can be anywhere, which could make some cool effects. I will make some spells using it myself for my hero arena in my TD, but I thought I would release it to public here. Does anyone think this is worth submitting to the vault?

Code:
function LocationToLocationByAngleFromLocation takes location origin, location l, real angle returns location
    return PolarProjectionBJ(origin,DistanceBetweenPoints(origin,l),AngleBetweenPoints(origin,l)+angle)
endfunction

function SineCurveTemp takes location origin, real magnitude,location end, integer skippedDegs returns nothing
    local location temp = null
    local location temp1 = null
    local real x = GetLocationX(origin)
    local real y = GetLocationY(origin)
    local real origY = y
    local real distance = DistanceBetweenPoints(origin,end)
    local real distInc = x
    local integer i = 1
    local real angle = AngleBetweenPoints(origin,end)
    loop
        exitwhen i > 360
        if (i == 1) then
            set temp = Location(x,y)
        elseif (ModuloInteger(i,skippedDegs) == 0) then
            if (origY<0) then
                set temp1 = Location(x,y-RAbsBJ(GetLocationY(origin)))
                set temp = LocationToLocationByAngleFromLocation(origin,temp1,angle)
            else
                set temp1 = Location(x,y+RAbsBJ(GetLocationY(origin)))
                set temp = LocationToLocationByAngleFromLocation(origin,temp1,angle)
            endif
        endif
        set x = distInc
        set y = (250*magnitude)*SinBJ(i)
        set distInc = distInc + (distance/360)
        call RemoveLocation(temp)
        call RemoveLocation(temp1)
        set i = i + 1
    endloop
    set temp = null
    set temp1 = null
endfunction
04-21-2004, 06:15 AM#2
AIAndy
A sinus curve is actually a quite good idea. I think I will add a point modification to the spell classes system that modifies the set of points a point template has. One of them could then be a sinus modification.