| 05-04-2006, 12:48 AM | #1 |
Why won't this work right? JASS://====================================================================== constant function MaxStateModifierId takes unitstate u returns integer if u == UNIT_STATE_MAX_LIFE then return 'A005' // Rawcode of the Max Life Modifier ability. elseif u == UNIT_STATE_MAX_MANA then return 'A006' // Rawcode of the Max Mana Modifier ability. endif return 0 endfunction function SetUnitMaxState takes unit whichUnit, unitstate whichUnitState, integer newVal returns boolean local integer c = newVal-R2I(GetUnitState(whichUnit, whichUnitState)) local integer i = MaxStateModifierId(whichUnitState) if i == 0 then return false endif if c > 0 then loop exitwhen c == 0 call UnitAddAbility(whichUnit, i) if c >= 100 then set c = c - 100 call SetUnitAbilityLevel(whichUnit, i, 4) elseif c >= 10 then set c = c - 10 call SetUnitAbilityLevel(whichUnit, i, 3) else set c = c - 1 call SetUnitAbilityLevel(whichUnit, i, 2) endif call UnitRemoveAbility(whichUnit, i) endloop elseif c < 0 then set c = -c loop exitwhen c == 0 call UnitAddAbility(whichUnit, i) if c >= 100 then set c = c - 100 call SetUnitAbilityLevel(whichUnit, i, 7) elseif c >= 10 then set c = c - 10 call SetUnitAbilityLevel(whichUnit, i, 6) else set c = c - 1 call SetUnitAbilityLevel(whichUnit, i, 5) endif call UnitRemoveAbility(whichUnit, i) endloop endif return true endfunction //====================================================================== //====================================================================== //====================DO NOT EDIT BELOW THIS LINE======================= //====================================================================== //====================================================================== // =========================== function H2I takes handle h returns integer return h return 0 endfunction // =========================== function LocalVars takes nothing returns gamecache // Replace InitGameCache("jasslocalvars.w3v") with a global variable!! return InitGameCache("jasslocalvars.w3v") endfunction function SetHandleHandle takes handle subject, string name, handle value returns nothing if value==null then call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name) else call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value)) endif endfunction function SetHandleInt takes handle subject, string name, integer value returns nothing if value==0 then call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name) else call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleBoolean takes handle subject, string name, boolean value returns nothing if value==false then call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name) else call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleReal takes handle subject, string name, real value returns nothing if value==0 then call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name) else call StoreReal(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function SetHandleString takes handle subject, string name, string value returns nothing if value==null then call FlushStoredString(LocalVars(), I2S(H2I(subject)), name) else call StoreString(LocalVars(), I2S(H2I(subject)), name, value) endif endfunction function GetHandleHandle takes handle subject, string name returns handle return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleInt takes handle subject, string name returns integer return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleBoolean takes handle subject, string name returns boolean return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleReal takes handle subject, string name returns real return GetStoredReal(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleString takes handle subject, string name returns string return GetStoredString(LocalVars(), I2S(H2I(subject)), name) endfunction function GetHandleUnit takes handle subject, string name returns unit return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTimer takes handle subject, string name returns timer return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleTrigger takes handle subject, string name returns trigger return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleEffect takes handle subject, string name returns effect return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleGroup takes handle subject, string name returns group return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleLightning takes handle subject, string name returns lightning return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function GetHandleWidget takes handle subject, string name returns widget return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction function FlushHandleLocals takes handle subject returns nothing call FlushStoredMission(LocalVars(), I2S(H2I(subject)) ) endfunction //====================================================================== function AuraBuff_Remove takes unit whichUnit, integer spellbookabil returns nothing local timer t = GetHandleTimer(whichUnit,"aurabtimer"+I2S(spellbookabil)) local trigger t2 = GetHandleTrigger(whichUnit,"aurabtrig"+I2S(spellbookabil)) if t != null then call SetHandleHandle(whichUnit,"aurabtimer"+I2S(spellbookabil),null) call SetHandleHandle(whichUnit,"aurabtrig"+I2S(spellbookabil),null) call TriggerRemoveAction(t2,GetHandleTriggerAction(t2,"action")) call FlushHandleLocals(t2) call DestroyTrigger(t2) call FlushHandleLocals(t) call PauseTimer(t) call DestroyTimer(t) call UnitRemoveAbility( whichUnit, spellbookabil) endif set t = null set t2 = null endfunction function AuraBuff_Child takes nothing returns nothing call AuraBuff_Remove( GetHandleUnit(GetExpiredTimer(),"u"), GetHandleInt(GetExpiredTimer(),"aura") ) endfunction function AuraBuff_OnDeath takes nothing returns nothing call AuraBuff_Remove(GetTriggerUnit(),GetHandleInt(GetTriggeringTrigger(),"aura")) endfunction function AuraBuff_Add takes unit whichUnit,real dur, integer spellbookabil returns nothing local timer t = CreateTimer() local trigger t2 = CreateTrigger() call AuraBuff_Remove( whichUnit, spellbookabil ) call SetPlayerAbilityAvailable( GetOwningPlayer(whichUnit), spellbookabil, false ) call UnitAddAbility(whichUnit,spellbookabil) call SetHandleHandle(t,"u",whichUnit) call SetHandleInt(t,"aura",spellbookabil) call SetHandleHandle(t2,"u",whichUnit) call SetHandleInt(t2,"aura",spellbookabil) call SetHandleHandle(whichUnit,"aurabtimer"+I2S(spellbookabil),t) call SetHandleHandle(whichUnit,"aurabtrig"+I2S(spellbookabil),t2) call TimerStart(t, dur, false, function AuraBuff_Child) call TriggerRegisterUnitEvent(t2 , whichUnit, EVENT_UNIT_DEATH) call SetHandleHandle(t2,"action",TriggerAddAction(t2,function AuraBuff_OnDeath)) set t = null set t2 = null endfunction JASS:call TriggerRemoveAction(t2,GetHandleTriggerAction(t2,"action")) |
| 05-04-2006, 01:42 AM | #2 |
The only syntactic problem is an omission of GetHandleTriggerAction: JASS:function GetHandleTriggerAction takes handle subject, string name returns triggeraction return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name) return null endfunction |
| 05-04-2006, 01:52 AM | #3 |
syntactic? omission? |
| 05-04-2006, 05:28 AM | #4 |
I cannot see anywhere in your script that you have the GetHandleTriggerAction function. |
| 05-04-2006, 04:43 PM | #5 | |
Quote:
Where did you get this JASS code? |
