HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Major trigger help

02-27-2004, 12:40 AM#1
Transcendence
I'm making a custom ability called merge. I used Healing Wave as a base spell cause I wanted that Art. I modified the healing to 0, and the number of targets to 1. This is what I want my ability to do.

Merge - Level 1 - Removes targetted unit from game, and adds its attack damage, HP, Armor, etc. to another unit owned by the same player that is closest to targetted unit.

Merge - Level 2 - Removes targetted unit from game as well as another unit owned by player nearest to targetted unit and adds them to the closest unit to the unit closest to the targetted unit.

Etc. Etc.

I have no idea how to do this. I also want the size to increase with each level so that the merged creature grows a bit larger. It doesnt have to add the armor and damage though I really want it to, but mostly the HP of the unit.

Any help?

~TRUMP
02-27-2004, 12:46 AM#2
ThyFlame
#1 for the most part can be done with triggers fairly easy...

#2 definitely is hard to do (the unit closest to a unit)... a few systems in repository.
02-27-2004, 12:59 AM#3
Transcendence
Anyone care to help me?
02-27-2004, 02:21 AM#4
Narwanza
Here is a JASS function that gets closest unit. It is pretty intensive on the CPU, so it can only be used about every 2 seconds.
Code:
function findactualunit takes location unitorigin, location origin, real prevdistance returns boolean
    local real distance = DistanceBetweenPoints(unitorigin,origin)
    if (not(distance < prevdistance)) then
       return false
    endif
    return true
endfunction

function GetClosestUnit takes unit who, group pool returns unit
    local location temploc = GetUnitLoc(who)
    local integer x = 1
    local integer y
    local real distance = 99999.0
    local location array templocs
    local unit array tempunits
    local unit actualunit
//  [color=silver]This next line is optional depending on whether you want it to filter units owned by casting player[/color]
    call GroupRemoveGroup(pool, GetUnitsOfPlayerAll(GetOwningPlayer(who)))
    call GroupRemoveUnitSimple(who, pool)
    set y = CountUnitsInGroup(pool)
    loop
        exitwhen x > y
        set tempunits[x] = FirstOfGroup(pool)
        set templocs[x] = GetUnitLoc(tempunits[x])
        call GroupRemoveUnitSimple(tempunits[x], pool)
        if (findactualunit(templocs[x],temploc,distance)) then
            set distance = DistanceBetweenPoints(templocs[x],temploc)
            set actualunit = tempunits[x]
        endif
        call RemoveLocation(templocs[x])
        set templocs[x] = null
        set x = x + 1
    endloop
    call DestroyGroup(pool)
    return actualunit
endfunction
02-27-2004, 03:13 AM#5
Transcendence
Thanks :foot: