HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Buff Spell: Soul Link. Need help.

02-12-2007, 11:24 AM#1
SzymonK
I've decided to make a spell that links two units as long as they are near. For example I want to make spell that will link hero with his summoned unit and if one of them take damage then both take half of full damage of attack. I've created dummy aura (to prevent some abuses) and so on I've no idea how to make that. I tried to make it by variables but nothing good came from it.
02-12-2007, 05:51 PM#2
CommanderZ
You may use GC to keep whose summon the unit is and then check every 1 sec if it is too far of its master or not.
02-13-2007, 10:51 AM#3
SzymonK
Hm I can't do it by myself :/. Here is what i started to do:
Trigger:
Events:
Unit - A unit Starts an effect of abillity
Conditions:
(Ability being cast) is equal to Soul Link
Actions:
Collapse Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit))) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(((Picked unit) is Summoned) is equal to YES)
Collapse Then - Actions
Unit - Create 1 Soul Link D for (Owner of (Casting unit)) at (Position of (Picked unit)) facing (Position of (Picked unit))
Unit - Order (Last created unit) to Orc - Spirit Walker - Spirit Link (Picked unit)
Unit - Add a 1.00 second General expiration timer to (Last created unit)
Else - Actions
Someone have any ideas how to rework that crap :/ ?
02-13-2007, 01:24 PM#4
WNxCryptic
The issue is that the way your unit-group selection works is taht its picking every unit, including enemy units, creeps, heroes, neutrals, whatever might be within a 500 range.

However, even if your hero is all by itself with the summon, the only picked units are the hero and the summon, but the conditions ((Picked unit is summoned) equal to YES) will ALWAYS evaluate to false because the hero is not of type summoned.

Before you go any further, though...have you tried simply copying spirit link and changing its stats to your usage? You shouldn't need to trigger ANYTHING except maybe some code to prevent this spell's abuse.
02-13-2007, 02:03 PM#5
SzymonK
I though about it but look from this points: Spirit Link will affect other units ( even if I only choose self and summoned - so when I will add other summons too my map that comes from hero skills it I'll be bad cus it might link those unit instead of unit I want.) I want to make simple abillity but it's not so simple in WE :/. I want only to link Hero and his minion.
02-13-2007, 06:42 PM#6
NmdSnprEnigma
There's a JASS solution that would involve On Damage triggers and CSCache. That said, it'd be something like, when the summon gets summoned...

Trigger:
Soul Link
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Mana of (Triggering unit)) Greater than or equal to 100.00
((Target unit of ability being cast) is Summoned) Equal to True // if you only want to link to summons
(Ability being cast) Equal to Soul Link (frostnova)
Collapse Actions
Custom script: call SetUnitState(GetTriggerUnit(),UNIT_STATE_MANA, RMinBJ(0,GetUnitState(GetTriggerUnit(),UNIT_STATE_MANA) - 100))
Custom script: call AttachObject(GetAttachedUnit(GetTriggerUnit(),"linkedunit"),"linkedunit",null) // if you want a Hero to link to only one at a time
Custom script: call AttachObject(GetTriggerUnit(),"linkedunit",GetSpellTargetUnit())
Custom script: call AttachObject(GetSpellTargetUnit(),"linkedunit",GetTriggerUnit())


so that they are mutually linked. Then when any unit gets damaged ( and the way to do this is all over this forum a hundred times )...

Collapse JASS:
function Trig_Damage_Split_Actions takes nothing returns nothing
    local unit linked = GetAttachedUnit(GetTriggerUnit(),"linkedunit")
    local real hp = GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE)
    local real dist = DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(linked))
   
    if ( linked != null and dist <= 500 ) and IsTriggerEnabled(GetTriggeringTrigger()) then
        call DisableTrigger(GetTriggeringTrigger())
        call UnitDamageTarget(GetEventDamageSource(), linked, GetEventDamage() / 2, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
        call SetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE,hp + GetEventDamage() / 2)
        call EnableTrigger(GetTriggeringTrigger())
    endif
    
    set linked = null
endfunction

//===========================================================================
function InitTrig_Damage_Split takes nothing returns nothing
    set gg_trg_Damage_Split = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Damage_Split, function Trig_Damage_Split_Actions )
endfunction

This should get most of the job done, though I admit it's not fool proof, but it gets a bit closer than trying to use Spirit Link. If one of the units dies you might also need something like...

Collapse JASS:
call AttachUnit(GetAttachedUnit(GetDyingUnit(),"linkedunit"),"linkedunit",null)
call AttachUnit(GetDyingUnit(),"linkedunit",null)

so that the one won't continue only taking half damage, unless when one dies, you kill the other or something. Anyway, food for thought at the very least.

PS - probably rather hard to do in GUI