| 07-25-2007, 05:43 AM | #1 |
ive been studying attached variables in CS_Cache, but still didnt get my problem solved, so ill ask it directly to the master JASS:local unit u = GetTriggerUnit() call AttachObject( GetTriggerUnit(), "caster", gg_trg_AWD ) or trigger AWD is attached to GetTriggerUnit()? JASS:local unit e = GetAttachedUnit(GetTriggerUnit(), "caster") why cant i use this? JASS:local unit u = GetTriggerUnit() call AttachObject(u, "caster", gg_trg_AWD) can anyone post a trigger that uses attached variables correctly? i need an answer for this to make a spell that blocks damage dealt to the buffed unit for Tables can anyone post a trigger that a table is used, i need a short trigger that clarifies the uses of tables? they said tables are better than attached variable, so i think i will need it... |
| 07-25-2007, 07:24 AM | #2 | ||||||
Quote:
Quote:
Quote:
Quote:
JASS:function AddLightningFromUnitToUnitTimed_Child takes nothing returns nothing local timer t = GetExpiredTimer() local unit from = GetAttachedUnit(t, "from") local unit to = GetAttachedUnit(t, "to") local lightning bolt = GetAttachedLightning(t, "bolt") local real z1 = GetUnitFlyHeight(from) local real z2 = GetUnitFlyHeight(to) if z1 == 0 then set z1 = 60 endif if z2 == 0 then set z2 = 60 endif call MoveLightningEx(bolt, GetAttachedBoolean(t, "checkVisibility"), GetUnitX(from), GetUnitY(from), z1, GetUnitX(to), GetUnitY(to), z2) call AttachReal(t, "timeelapsed", GetAttachedReal(t, "timeelapsed")+0.01) if ((GetAttachedReal(t, "timeelapsed") > GetAttachedReal(t, "duration")) or (GetUnitState(from, UNIT_STATE_LIFE) <= 0) or (GetUnitState(to, UNIT_STATE_LIFE) <= 0)) then call CleanAttachedVars(t) call DestroyTimer(t) call DestroyLightning(bolt) endif set t = null set from = null set to = null set bolt = null endfunction function AddLightningFromUnitToUnitTimed takes string codeName, boolean checkVisibility, unit from, unit to, real duration returns lightning local timer t = CreateTimer() local lightning bolt local real z1 = GetUnitFlyHeight(from) local real z2 = GetUnitFlyHeight(to) if z1 == 0 then set z1 = 60 endif if z2 == 0 then set z2 = 60 endif set bolt = AddLightningEx(codeName, checkVisibility, GetUnitX(from), GetUnitY(from), z1, GetUnitX(to), GetUnitY(to), z2) call AttachReal(t, "duration", duration) call AttachObject(t, "from", from) call AttachObject(t, "to", to) call AttachBoolean(t, "checkVisibility", checkVisibility) call AttachObject(t, "bolt", bolt) call TimerStart(t, 0.01, true, function AddLightningFromUnitToUnitTimed_Child) return bolt endfunction Quote:
Then, simply add the ability to a unit when needed and then run a periodic check for all units that have that ability but not the buff. If a unit matches this condition, remove the ability from it. Quote:
JASS://==========================================================\\ // Pyrogasm's Custom Sleep Functions \\ // \\ // Version 1.00 \\ //==========================================================\\ //##########################################################\\ // Start Configuration \\ //##########################################################\\ constant function CSF_SleepAbilityId takes nothing returns integer return 'A000' //Rawcode of the "__CSF Dummy Sleep" spell endfunction constant function CSF_DummyUnitId takes nothing returns integer return 'e000' //Rawcode of your dummy unit endfunction constant function CSF_SleepStunTime takes nothing returns real return 2.00 //This is the "Stun Duration" field of the sleep ability //It determines how long a slept unit is invulnerable for endfunction constant function CSF_SleepBuffId takes nothing returns integer return 'BUsl' //Rawcode of the "Sleep" buff that your map uses //This should be the same on all spells based on Sleep endfunction constant function CSF_SleepPauseBuffId takes nothing returns integer return 'BUsp' //Rawcode of the "Sleep (Pause)" buff that your map uses //This should be the same on all spells based on Sleep endfunction constant function CSF_SleepStunBuffId takes nothing returns integer return 'BUst' //Rawcode of the "Sleep (Stun)" buff that your map uses //This should be the same on all spells based on Sleep endfunction //function CSF_InvulnerableBuff takes unit whichUnit returns boolean // if GetUnitAbilityLevel(whichUnit, 'BHds') > 0 then //Divine Shield // return true // elseif GetUnitAbilityLevel(whichUnit, 'Bvul') > 0 then // return true //Repeat this and the above line for each different // endif //Invulnerability buff in your map; change 'Bvul' // return false //To the rawcode of the buff //endfunction //##########################################################\\ // End Configuration \\ //##########################################################\\ function CSF_EndSleep takes nothing returns nothing local timer T = GetExpiredTimer() local string TTable = GetAttachmentTable(T) local unit whichUnit = GetTableUnit(TTable, "CSF whichUnit") local string UTable = GetAttachmentTable(whichUnit) local integer ActiveSleeps = GetTableInt(UTable, "CSF Active Sleeps") set ActiveSleeps = ActiveSleeps-1 if ActiveSleeps == 0 then call UnitRemoveAbility(whichUnit, CSF_SleepBuffId()) if GetTableBoolean(TTable, "CSF Short Duration") then // call SetUnitInvulnerable(whichUnit, false) call UnitRemoveAbility(whichUnit, CSF_SleepPauseBuffId()) call UnitRemoveAbility(whichUnit, CSF_SleepStunBuffId()) call SetTableBoolean(TTable, "CSF Short Duration", false) endif endif call SetTableInt(UTable, "CSF Active Sleeps", ActiveSleeps) call PauseTimer(T) call CleanAttachedVars(T) call DestroyTimer(T) set T = null set whichUnit = null endfunction function SleepUnit takes unit whichUnit, real Duration, boolean OverRide returns nothing local unit Dummy local timer T local string Table if (not(OverRide) and GetUnitAbilityLevel(whichUnit, CSF_SleepBuffId()) == 0) or OverRide then set Dummy = CreateUnit(GetOwningPlayer(whichUnit), CSF_DummyUnitId(), GetUnitX(whichUnit), GetUnitY(whichUnit), 0.00) call UnitAddAbility(Dummy, CSF_SleepAbilityId()) call IssueTargetOrder(Dummy, "sleep", whichUnit) call UnitApplyTimedLife(Dummy, 'BTLF', 2.00) set T = CreateTimer() set Table = GetAttachmentTable(T) call SetTableObject(Table, "CSF whichUnit", whichUnit) if Duration < CSF_SleepStunTime() then call SetTableBoolean(Table, "CSF Short Duration", true) endif call TimerStart(T, Duration, false, function CSF_EndSleep) set Table = GetAttachmentTable(whichUnit) call SetTableInt(Table, "CSF Active Sleeps", GetTableInt(Table, "CSF Active Sleeps")+1) set Dummy = null set T = null endif endfunction |
| 07-25-2007, 01:33 PM | #3 |
hmmm am I a victim of dejavu? |
| 07-25-2007, 08:30 PM | #4 |
Yup; I've seen this before somewhere too... |
| 07-26-2007, 04:38 AM | #5 |
yeah i posted this thread in vexorians spells and systems, but after 3 days, theres no one who replies, so i posted it here anyways, thanks pyro +rep |
