• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Problem with a Spell :S

Status
Not open for further replies.
Level 4
Joined
Aug 3, 2008
Messages
80
hey

Power Word Shield system [not made by me....and i doesn't have learned Jass or vJass-.-so i can't find or change anything) works as it should.....but after a random time or after you cast another spell it disappear from the hero and you have to learn it again and then the spell disappear again usw-.-:confused:

Here is the CUSTOM SCRIPT:
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
 
// ===========================
function LocalVars takes nothing returns gamecache
    if (udg_hash == null) then
      set udg_hash = InitGameCache("wowmc.w3v")
      call FlushGameCache(InitGameCache("wowmc.w3v"))
    endif
    return udg_hash
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 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 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 GetHandleTextTag takes handle subject, string name returns  texttag
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
 
function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

**********
and the *TRIGGERS:*
**********
1)
JASS:
function Trig_Load_Game_Cache_Actions takes nothing returns nothing
    call InitGameCacheBJ( "localvars.w3v" )
    set udg_hash = GetLastCreatedGameCacheBJ()
endfunction

//===========================================================================
function InitTrig_Load_Game_Cache takes nothing returns nothing
    set gg_trg_Load_Game_Cache = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Load_Game_Cache, function Trig_Load_Game_Cache_Actions )
endfunction

2)
JASS:
function GetShieldBuff takes nothing returns integer
    return 'B00Y'
endfunction
function GetShieldDeadFixer takes nothing returns integer
    return 'A02X'
endfunction
//====================================================
function Trig_Shield_Damage_Actions_Child takes nothing returns nothing
    local timer x = GetExpiredTimer()
    local real special = GetHandleReal( x, "special" )
    local unit ouch = GetHandleUnit( x, "unit" )
    local real dmg = GetHandleReal( x, "dmg" )
    if special < 0.00 then
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) + dmg ) )
        set special = RAbsBJ(special)
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) - special ) )
        set special = 0.00
        call UnitRemoveBuffBJ( GetShieldBuff(), ouch )
        call SetHandleReal( GetTriggerUnit(), "shieldmax", 0.00)
        set udg_retrive = GetHandleTextTag( ouch, "float" )
        call SetHandleHandle( ouch, "float", null)
        call DestroyTextTagBJ( udg_retrive )
    else
        call SetUnitLifeBJ( ouch, ( GetUnitStateSwap(UNIT_STATE_LIFE, ouch) + dmg ) )
    endif
    call UnitRemoveAbilityBJ( GetShieldDeadFixer(), ouch )
    call SetHandleReal( ouch, "shield", special )
    set x = null
endfunction

function Trig_Shield_Damage_Actions takes nothing returns nothing
    local timer x = CreateTimer()
    local real special = GetHandleReal(  GetTriggerUnit(), "shield" )
    local effect fx
    call UnitAddAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
    if GetEventDamage() == 0 then
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
        set x = null
        return
    endif
    if special == 0 then
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit())
        set x = null
        return
    endif
    if UnitHasBuffBJ(GetTriggerUnit(), GetShieldBuff()) == false then
        call SetHandleReal( GetTriggerUnit(), "shieldmax", 0.00)
        set udg_retrive = GetHandleTextTag( GetTriggerUnit(), "float" )
        call SetHandleHandle( GetTriggerUnit(), "float", null)
        call DestroyTextTagBJ( udg_retrive )
        call UnitRemoveAbilityBJ( GetShieldDeadFixer(), GetTriggerUnit() )
        set x = null
        return
    endif
    set fx = AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl" )
    call DestroyEffectBJ( fx )
    set special = special - GetEventDamage()
    call SetHandleHandle( x, "unit", GetTriggerUnit() )
    call SetHandleReal( x, "special", special )
    call SetHandleReal( x, "dmg", GetEventDamage() )
    call TimerStart(x, 0.01, false, function Trig_Shield_Damage_Actions_Child)
    set x = null
endfunction

//===========================================================================
function InitTrig_Shield_Damage takes nothing returns nothing
    set gg_trg_Shield_Damage = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Shield_Damage, function Trig_Shield_Damage_Actions )
endfunction

3)
JASS:
function Trig_Cast_PWS_Func001C takes nothing returns boolean
    if ( ( GetSpellAbilityId() == 'A01F' ) ) then
        return true
    endif
    if ( ( GetSpellAbilityId() == 'A04L' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Cast_PWS_Conditions takes nothing returns boolean
    if ( not Trig_Cast_PWS_Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Cast_PWS_Actions takes nothing returns nothing
    local texttag retrive
    local unit udg_TempUnit = GetSpellTargetUnit()
    if GetHandleInt( GetSpellTargetUnit(), "wasshielded" ) == 0 then
    call SetHandleInt(GetSpellTargetUnit(), "wasshielded", 1)
    call TriggerRegisterUnitEvent( gg_trg_Shield_Damage, GetSpellTargetUnit(), EVENT_UNIT_DAMAGED )
    endif
    set udg_ShieldLife = ( 200.00 + ( I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit())) * 150.00 ) )
    call SetHandleReal( GetSpellTargetUnit(), "shield", udg_ShieldLife)
    call SetHandleReal( GetSpellTargetUnit(), "shieldmax", udg_ShieldLife)
    call CreateTextTagUnitBJ( "TRIGSTR_1219", GetSpellTargetUnit(), 0, 12.00, 100, 100, 100, 0 )
    set retrive = GetLastCreatedTextTag()
    call SetHandleHandle( GetSpellTargetUnit(), "float", GetLastCreatedTextTag() )
    call SetHandleInt( GetSpellTargetUnit(), "ws", 1 )
    call TriggerSleepAction( 30.00 )
    call SetHandleInt( udg_TempUnit, "ws", 0 )
    call DestroyTextTagBJ( retrive )
    call SetHandleReal( udg_TempUnit, "shield", 0.00)
    call SetHandleReal( udg_TempUnit, "shieldmax", 0.00)
    call SetHandleHandle( udg_TempUnit, "float", null)
endfunction

//===========================================================================
function InitTrig_Cast_PWS takes nothing returns nothing
    set gg_trg_Cast_PWS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cast_PWS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Cast_PWS, Condition( function Trig_Cast_PWS_Conditions ) )
    call TriggerAddAction( gg_trg_Cast_PWS, function Trig_Cast_PWS_Actions )
endfunction

4)
JASS:
function Trig_Cant_Cast_on_Weakned_units_Func001C takes nothing returns boolean
    if ( ( GetSpellAbilityId() == 'A01F' ) ) then
        return true
    endif
    if ( ( GetSpellAbilityId() == 'A04L' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Cant_Cast_on_Weakned_units_Conditions takes nothing returns boolean
    if ( not Trig_Cant_Cast_on_Weakned_units_Func001C() ) then
        return false
    endif
    return true
endfunction

function Trig_Cant_Cast_on_Weakned_units_Actions takes nothing returns nothing
    if GetHandleInt( GetSpellTargetUnit(), "ws" ) == 1 then
    call ResetUnitAnimation( GetSpellAbilityUnit() )
    call IssueImmediateOrderBJ( GetSpellAbilityUnit(), "stop" )
    endif
endfunction

//===========================================================================
function InitTrig_Cant_Cast_on_Weakned_units takes nothing returns nothing
    set gg_trg_Cant_Cast_on_Weakned_units = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cant_Cast_on_Weakned_units, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Cant_Cast_on_Weakned_units, Condition( function Trig_Cant_Cast_on_Weakned_units_Conditions ) )
    call TriggerAddAction( gg_trg_Cant_Cast_on_Weakned_units, function Trig_Cant_Cast_on_Weakned_units_Actions )
endfunction

5)
JASS:
function Trig_Dispell_Func002002002 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetFilterUnit(), 'B00Y') == false )
endfunction

function Trig_Dispell_Func003A takes nothing returns nothing
    if GetHandleTextTag( GetEnumUnit(), "float") == null then
    else
    call SetHandleReal( GetEnumUnit(), "shield", 0.00)
    call SetHandleReal( GetDyingUnit(), "shieldmax", 0.00)
    set udg_retrive = GetHandleTextTag( GetEnumUnit(), "float" )
    call SetHandleHandle( GetEnumUnit(), "float", null)
    call DestroyTextTagBJ( udg_retrive )
    endif
endfunction

function Trig_Dispell_Actions takes nothing returns nothing
    call TriggerSleepAction( 1.00 )
    set udg_TempGroup = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Dispell_Func002002002))
    call ForGroupBJ( udg_TempGroup, function Trig_Dispell_Func003A )
    call DestroyGroup( udg_TempGroup )
    set udg_TempGroup = null
endfunction

//===========================================================================
function InitTrig_Dispell takes nothing returns nothing
    set gg_trg_Dispell = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dispell, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Dispell, function Trig_Dispell_Actions )
endfunction

6)
JASS:
function Trig_Move_TT_Func001002002 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetFilterUnit(), 'B00Y') == true )
endfunction

function Trig_Move_TT_Func002001 takes nothing returns boolean
    return ( IsUnitGroupEmptyBJ(udg_TempGroup) == true )
endfunction

function Trig_Move_TT_Func003Func009Func001C takes nothing returns boolean
    if ( not ( udg_special >= ( I2R(GetForLoopIndexA()) * ( udg_max / 20.00 ) ) ) ) then
        return false
    endif
    return true
endfunction

function Trig_Move_TT_Func003Func013Func001001 takes nothing returns boolean
    return ( IsUnitVisible(GetEnumUnit(), Player(0)) == true )
endfunction

function Trig_Move_TT_Func003Func013A takes nothing returns nothing
    if ( Trig_Move_TT_Func003Func013Func001001() ) then
        call ForceAddPlayerSimple( GetEnumPlayer(), udg_seeunit )
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Move_TT_Func003A takes nothing returns nothing
    set udg_retrive = GetHandleTextTag( GetEnumUnit(), "float" )
    set udg_special = GetHandleReal( GetEnumUnit(), "shield" )
    set udg_max = GetHandleReal( GetEnumUnit(), "shieldmax" )
    set udg_spawnpoint = GetUnitLoc(GetEnumUnit())
    set udg_TempPoint = OffsetLocation(udg_spawnpoint, -60.00, 0)
    call RemoveLocation( udg_spawnpoint )
    set udg_spawnpoint = null
    set udg_createdtext = ""
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 20
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_Move_TT_Func003Func009Func001C() ) then
            set udg_createdtext = ( udg_createdtext + "|cffffcc00'|r" )
        else
            set udg_createdtext = ( udg_createdtext + "|cff000000'|r" )
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call SetTextTagPosBJ( udg_retrive, udg_TempPoint, 80.00 )
    call SetTextTagTextBJ( udg_retrive, udg_createdtext, 12.00 )
    set udg_seeunit = CreateForce()
    call ForForce( GetPlayersByMapControl(MAP_CONTROL_USER), function Trig_Move_TT_Func003Func013A )
    call ShowTextTagForceBJ( false, udg_retrive, GetPlayersAll() )
    call ShowTextTagForceBJ( true, udg_retrive, udg_seeunit )
    call RemoveLocation( udg_TempPoint )
    set udg_TempPoint = null
    call DestroyForce( udg_seeunit )
    set udg_seeunit = null
endfunction

function Trig_Move_TT_Actions takes nothing returns nothing
    set udg_TempGroup = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Move_TT_Func001002002))
    if ( Trig_Move_TT_Func002001() ) then
        return
    else
        call DoNothing(  )
    endif
    call ForGroupBJ( udg_TempGroup, function Trig_Move_TT_Func003A )
    call DestroyGroup( udg_TempGroup )
    set udg_TempGroup = null
endfunction

//===========================================================================
function InitTrig_Move_TT takes nothing returns nothing
    set gg_trg_Move_TT = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Move_TT, 0.04 )
    call TriggerAddAction( gg_trg_Move_TT, function Trig_Move_TT_Actions )
endfunction

7)
JASS:
function Trig_Flush_dead_units_Actions takes nothing returns nothing
    call SetHandleInt( GetDyingUnit(), "wasshielded", 0)
    call SetHandleReal( GetDyingUnit(), "shield", 0.00)
    call SetHandleReal( GetDyingUnit(), "shieldmax", 0.00)
    set udg_retrive = GetHandleTextTag( GetDyingUnit(), "float" )
    call SetHandleHandle( GetDyingUnit(), "float", null)
    call DestroyTextTagBJ( udg_retrive )
    call SetHandleInt( GetDyingUnit(), "ws", 0 )
endfunction

//===========================================================================
function InitTrig_Flush_dead_units takes nothing returns nothing
    set gg_trg_Flush_dead_units = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Flush_dead_units, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Flush_dead_units, function Trig_Flush_dead_units_Actions )
endfunction

i know it's much to read....but i hope somebody can help me:smile:
i need it for my map...so pls help me...thank you
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
816
wtf? do you really expect us to read through that mess of a trigger? At least make the code somehow appealing (using vJass). Then start commenting, so we dont have to spend an hour only to understand your spell (and use naming conventions actually making sense).

Seriously, dont post GUI->Jass scripts and expect anyone to read through them.
 
Level 4
Joined
Aug 3, 2008
Messages
80
wtf? do you really expect us to read through that mess of a trigger? At least make the code somehow appealing (using vJass). Then start commenting, so we dont have to spend an hour only to understand your spell (and use naming conventions actually making sense).

Seriously, dont post GUI->Jass scripts and expect anyone to read through them.

th spells works.....you can cast him and it works but why did the spell disappear from the hero after he learn it:confused:

i know it's much to read but i don't can work with Jass or vJass so i can't find a bug or something......hmmmm
 
Status
Not open for further replies.
Top