• 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] Spell System conflict, units face to the east

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Alright, I have a minor bug running in the four systems I have in my map that enhance spells.

The 4 systems I use are KaTTaNa's HandleVars, Vexorian's Caster System, and Knutz NewPos, and some custom functions by Blade.dk. I think it's the NewPos thats causing the problem, but I'm not familiar enough with JASS to tell. The knutz spellpack I DLed was from wc3campaigns, and came with KaTTaNa's HandleVars.

What happens is whenver the hero casts a spell, they face odd angels. My Volley spell from Blade.dk causes the hero to face a random angel.(It's blizzard based) and any stomp spell cast causes the hero to face to the east. This would be minor, but a specific JASS spell I would like to implement relies on the hero facing a specific way, and I think the facing issue is causing graphic problems with Volley.

I'm really not sure. I'm also gonna add Daminon's system, which has had weird errors too when sometimes coupled with these systems.

Anyways, if someone has an idea what's causing this please tell me. Provided are the 4 systems intertwined:

JASS:
/Return Bug

function H2I takes handle h returns integer
    return h
    return 0
endfunction
function I2H takes integer i returns handle
    return i
    return null
endfunction
function I2U takes integer i returns unit
    return i
    return null
endfunction
function I2G takes integer i returns group
    return i
    return null
endfunction
function I2E takes integer i returns effect
    return i
    return null
endfunction
function I2T takes integer i returns timer
    return i
    return null
endfunction
function I2TD takes integer i returns terraindeformation
    return i
    return null
endfunction

//External Functions:

function GetTableTriggerCondition takes string table, string field returns triggercondition
    return GetStoredInteger(CSCache(),table,field)
    return null
endfunction

function GetTableTextTag takes string table, string field returns texttag
    return GetStoredInteger(CSCache(),table,field)
    return null
endfunction
//##End of External functions##

//#########################################################
//                         Check Pathability
//                            By Vexorian
//
//#########################################################

function CheckPathabilityTrickGet takes nothing returns nothing
    set bj_rescueChangeColorUnit = bj_rescueChangeColorUnit or (GetEnumItem()!=bj_itemRandomCurrentPick)
endfunction

function CheckPathabilityTrick takes item p, real x, real y returns boolean
    local integer i=30
    local rect r
    call SetItemPosition(p,x,y)
    if ((Pow(GetItemX(p)-x,2)+Pow(GetItemY(p)-y,2))<=100) then
        return true
    endif
    set r=Rect(x-i,y-i,x+i,y+i)
    set bj_itemRandomCurrentPick=p
    set bj_rescueChangeColorUnit=false
    call EnumItemsInRect(r,null,function CheckPathabilityTrickGet)
    call RemoveRect(r)
    set r=null
    return bj_rescueChangeColorUnit
endfunction

function CheckPathability takes real x, real y returns boolean
    local item it = CreateItem('ciri',x,y)
    local boolean b = CheckPathabilityTrick(it,x,y)
    call SetItemVisible(it,false)
    call RemoveItem(it)
    set it=null
    return b
endfunction


//***********************************************
//*         knutz_Functions v 1.1
//*                By knutz
//*
//***********************************************

//***********************************************
//*
//*              knutz_NewPos
//*
//*    Description
//*    -----------
//*    Given a point of origin, a distance (c)
//*    and an angle (A) this function will return
//*    the position of the destination. You will 
//*    need Vexorian's Caster System (paste this 
//*    (paste this function under the CS code).
//*    You will also need Vexorian's CheckPathability
//*    code ABOVE this function.
//*
//*    IMPORTANT: If you set check_path to true,
//*    ensure you check the return value isn't null
//*    before assigning it to any objects.
//*
//************************************************ 

function knutz_NewPos takes location origin, real c, real A, boolean check_path returns location
    local real oX = GetLocationX(origin)
    local real oY = GetLocationY(origin)
    local real newX = CS_SafeX(oX+(Cos(A*bj_DEGTORAD)*c))
    local real newY = CS_SafeY(oY+(Sin(A*bj_DEGTORAD)*c)) 
    if ((check_path == true) and (CheckPathability(newX,newY) != true)) then
        return null
    endif 
    return Location(newX,newY) 
endfunction

//***********************************************
//*
//*              knutz_NewPosZ
//*
//*    Description
//*    -----------
//*    Given a point of origin, a distance (c)
//*    and an angle (A - from the ground) this function 
//*    will return a location. This is NOT to be used 
//*    as a location, but a convenient way of returning
//*    2 real values from a single function.
//*    The X value is the distance along the ground
//*    The Y value is the fly height/z offset
//*
//************************************************ 
function knutz_NewPosZ takes real c,real A returns location
    local real a = Sin(A*bj_DEGTORAD)*c
    local real b = Cos(A*bj_DEGTORAD)*c
    return Location(b,a)
endfunction

//KATTANAS HANDLEVAR SYSTEM

// By KaTTaNa

function LocalVars takes nothing returns gamecache
    if (udg_handlevars==null) then
        set udg_handlevars=InitGameCache("jasslocalvars.w3v")
    endif
    return udg_handlevars
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 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 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 GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(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 GetHandleLightning takes handle subject, string name returns lightning
    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 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
//***Handle Vars End***

//***TimedBoolean Start***

// By Blade.dk

function SetHandleBooleanTimed_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local handle subject = GetHandleHandle(t, "handle")
    call SetHandleBoolean(subject, GetHandleString(t, "string"), false)
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    set t = null
    set subject = null
endfunction

function SetHandleBooleanTimed takes handle subject, string name, real duration returns nothing
    local timer t  = CreateTimer()
    call SetHandleBoolean(subject, name, true)
    call SetHandleHandle(t, "handle", subject)
    call SetHandleString(t, "string", name)
    call TimerStart(t, duration, false, function SetHandleBooleanTimed_Child)
    set subject = null
    set t = null
endfunction
//***TimedBoolean End***

There will also be an index system by Clan NgO activated soon, which may cause conflict. Not shown is Vexorian's Caster System, which can be DLed easily enough and is quiet large, containing 6 seperate triggers.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
CheckPathability is old.

Anyhow, don't use Handle Vars etc with code you write yourself, and preferably don't use old code that uses them.

Also, if I were you I wouldn't touch any clan-specific stuff, since a lot of the good stuff tends to make its way to wc3campaigns in the end. Define 'index system' anyhow.
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
I haven't implemented the Index System yet, but the skills from that group are quiet nice.

I've removed CheckPathability, but the issue still arises with the units facing to the east on stomp cast and randomly on channel casts.

I got the NvGO Clan Spells off of Hiveworkshop. It's a nice assortment of skills.

Here is the Index System provided to run their spells:

JASS:
//               °                                        Mapmaking since 2006...
//            °
//          °
//         °
//       °°°ÛÜ
//      °°X°ÛÛÛ                          ÛÛÛÛÛÛÛÛ     ÿÜÛÛÛÛÛÛÛÛÜ 
//     °°XX° ÛÛÛ        ßÛÛÛÛÛ        ÛÛÛÛÛÛÛÛÛÛÛÛ   ÛÛÛÛÛÛÛÛÛÛÛÛÛ
//     °XX ° ÛÛÛÛ         ÛÛÛÛÜ     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//     °XX °  ÛÛÛÛÛ        ÛÛÛÛ    ÛÛÛÛÛß    ßÛÛÛÛÛÛ  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  
//    °°XXX°° ÛÛÛÛÛÛÜ       ÛÛÛÜ  ÛÛÛÛÛ        ßÛÛÛÛÛ ßÛÛÛÛ    ÛÛÛÛÛÛ  
//   °°°°°°°°  ÛÛÛÛÛÛÛ      ÛÛÛÛ  ÛÛÛÛ                 ÛÛÛÛ      ÛÛÛÛÜ  
//             ÛÛÛÛÛÛÛÛ     ÛÛÛÛ  ÛÛÛÛ        ÛÛÛÛÛÛÛ  ÛÛÛÛÛÜ     ÛÛÛÛ  
//   °°°°°°°°  ÛÛÛÛÛÛÛÛÛ    ÛÛÛÛÜ  ÛÛÛÛÜ     ÛÛÛÛÛÛÛÛ   ÛÛÛÛÛÜ  ÜÛÛÛÛÛÛ  
//   °°XXXXX°   ÛÛÛÛ  ÛÛÛÜ  ÛÛÛÛÛ   ÛÛÛÛÛÛÜ    ßÛÛÛÛÛ   ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  
//   °°XXXXX °° ÛÛÛÛ   ÛÛÛÛÜ ÛÛÛÛ °°°ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ°°° ÛÛÛÛÛÛÛÛÛÛÛÛÛß  
//   °  XXXXX °°ÛÛÛÛÛ°°°°ÛÛÛÛÛÛÛÛ°°XX ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ XXX°°ÛÛÛÛÛÛÛÛÛÛÛ     ÛÛÛ
//   °°  XXXXX ÜÛÛÛÛÛÛ X ÛÛÛÛÛÛÛÛÛ XXX ÛÛÛÛÛÛÛÛÛÛÛ  XXXXXX  ÛÛÛÛÛÛÛ°      ÛÛÛ
//    °°  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°°   °°°°
//     °°   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°X°°
//      °°°  XXXXXXXXXX  °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° XXXXXXXXXXXXXXXXX°°
//        °°°°°°°°°°°°°°°°                                  °°°°°°°°  XXXXXXX °°°
//                                                                  °°°°°° XX °°
//   ...2008 and still moving on.                                        °°°°°°°
//                                                                             °°
//   Screen Solution: 1280x1024                             Visit [url=http://www.ngo.clan.su]Clan NgO - Main page[/url]!

//  ++++++++++++++++++++++++++++++++++++++++++  INFO   ++++++++++++++++++++++++++++++++++++++++

//  Type........................................ : .....................................System
//  Langueage................................... : ......................................vJass
//  Coder....................................... : ......................................Hanky
//  MUI......................................... : ........................................Yes

//  +++++++++++++++++++++++++++++++++++++++++  INSTALL  +++++++++++++++++++++++++++++++++++++++

//
//   How to create your own keys?
//
//   Well this version is really easy made you just must enter runtextmacro!
//   At first you add a line "//! runtextmacro var_id("<yournumber>")". After
//   you made this add a second line there: "//! runtextmacro set_var("<yournumber>")".
//   
//   And now as example. Ok I want to have a key with the value 666. The script should look then
//   like this:
//
//   library IndexVariables initializer init
//     globals
//       private constant integer maxindex=6000
//       public trigger array setid
//       public trigger array getid
//       public integer key=0
//       public integer ret=0
//     endglobals

//     //! textmacro var_id takes key
//     globals
//        integer array id_$key$[maxindex]
//     endglobals
  
//     private function setid_$key$ takes nothing returns nothing
//        set id_$key$[key]=ret
//     endfunction
  
//     private function getid_$key$ takes nothing returns nothing
//        set ret=id_$key$[key]
//     endfunction
//     //! endtextmacro
  
//     //! runtextmacro var_id("666")
//     ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯   
//     //! textmacro set_var takes key
//       set setid[$key$]=CreateTrigger()
//       set getid[$key$]=CreateTrigger()
    
//       call TriggerAddAction(setid[$key$],function setid_$key$)
//       call TriggerAddAction(getid[$key$],function getid_$key$)
//     //! endtextmacro
  
//     private function init takes nothing returns nothing
//       //! runtextmacro set_var("666")
//       ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
//     endfunction
//   endlibrary
//
//   Note: The only stuff which you must add are the underlined strings.

//  ++++++++++++++++++++++++++++++++++++++++++  NOTES  ++++++++++++++++++++++++++++++++++++++++

//  Thanks for the JassGenNewPack: .............pipedream
//                                 .............xttocs
//                                 .............Pitzermike
//                                 .............Vexorian
//                                 .............MindWorx
//                                 .............Scio
//                                 .............Starcraftfreak
//                                 .............FyreDaug
//                                 .............KDEWolf

//  Greetz fly out to: NgO . Burax . JonNny . Darkt3mpl3r . WaRadius . Fireeye
//                     CBS . WC3C . HIVE . Toadcop

//
//                                            Enjoy!

library IndexVariables initializer init
  globals
    private constant integer maxindex=6000  //Set the maximal attach index! In the Index System v1 for example it's 32760
    public trigger array setid
    public trigger array getid
    public integer key=0
    public integer ret=0
  endglobals

  //! textmacro var_id takes key
  globals
     integer array id_$key$[maxindex]
  endglobals
  
  private function setid_$key$ takes nothing returns nothing
     set id_$key$[key]=ret
  endfunction
  
  private function getid_$key$ takes nothing returns nothing
     set ret=id_$key$[key]
  endfunction
  //! endtextmacro
  
  //! runtextmacro var_id("1")
  //! runtextmacro var_id("106")
  //! runtextmacro var_id("107")
  //! runtextmacro var_id("108")
  //! runtextmacro var_id("109")
  //! runtextmacro var_id("110")
  
  //! textmacro set_var takes key
    set setid[$key$]=CreateTrigger()
    set getid[$key$]=CreateTrigger()
    
    call TriggerAddAction(setid[$key$],function setid_$key$)
    call TriggerAddAction(getid[$key$],function getid_$key$)
  //! endtextmacro
  
  private function init takes nothing returns nothing
    //! runtextmacro set_var("1")
    //! runtextmacro set_var("106")
    //! runtextmacro set_var("107")
    //! runtextmacro set_var("108")
    //! runtextmacro set_var("109")
    //! runtextmacro set_var("110")
  endfunction
endlibrary

library ExtentedMultiCache requires MainFunctions,IndexVariables
  globals
    private constant integer minIndex=0x100000
  endglobals

  function SetHandleAttach takes handle h,integer key,integer attach returns nothing
    set IndexVariables_key=H2I(h)-minIndex
    set IndexVariables_ret=attach
    call TriggerExecute(IndexVariables_setid[key])
  endfunction
  
  function GetHandleAttach takes handle h,integer key returns integer
    set IndexVariables_key=H2I(h)-minIndex
    call TriggerExecute(IndexVariables_getid[key])
    return IndexVariables_ret
  endfunction
endlibrary

//----------------------------------------------------------------------------------------------------------------------
//*                                      Timed Dead                                                                    *
//----------------------------------------------------------------------------------------------------------------------
library TimedHandleDead requires MainFunctions,ExtentedMultiCache
  function U2Death takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call RemoveUnit(I2U(GetHandleAttach(t,GCI)))
    call AB_DestroyTimer(t)
    set t=null
  endfunction

  function U2Null takes unit u,real duration returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,duration,false,function U2Death)
    call SetHandleAttach(t,GCI,H2I(u))
    set t = null
  endfunction

  function T2Death takes nothing returns nothing
    local timer t    = GetExpiredTimer()
    local trigger tr = I2TRIG(GetHandleAttach(t,GCI))
    
    if tr!=null then
      call DestroyTrigger(tr)
    endif
    call AB_DestroyTimer(t)
    set t =null
    set tr=null
  endfunction

  function T2Null takes trigger tt,real duration returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,duration,false,function T2Death)
    call SetHandleAttach(t,GCI,H2I(tt))
    set t = null
  endfunction

  function E2Death takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call DestroyEffect(I2E(GetHandleAttach(t,GCI)))
    call AB_DestroyTimer(t)
    set t=null
  endfunction

  function E2Null takes effect e,real duration returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,duration,false,function E2Death)
    call SetHandleAttach(t,GCI,H2I(e))
    set t = null
  endfunction

  function L2Death takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call DestroyLightning(I2L(GetHandleAttach(t,GCI)))
    call AB_DestroyTimer(t)
    set t=null
  endfunction

  function L2Null takes lightning l,real duration returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,duration,false,function L2Death)
    call SetHandleAttach(t,GCI,H2I(l))
    set t = null
  endfunction

  function TT2Death takes nothing returns nothing
    local timer t = GetExpiredTimer()
    call DestroyTextTag(I2TXT(GetHandleAttach(t,GCI)))
    call AB_DestroyTimer(t)
    set t=null
  endfunction

  function TT2Null takes texttag tt,real duration returns nothing
    local timer t = CreateTimer()
    call TimerStart(t,duration,false,function L2Death)
    call SetHandleAttach(t,GCI,H2I(tt))
    set t = null
  endfunction
endlibrary

//================================================================================================
//Passiv - Damage Skill
//================================================================================================
library DamageSkill requires ExtentedMultiCache,MainFunctions
  private struct DmgData
    trigger GetDamage
    trigger GetOrder
    unit    attacker
    timer   check
    
    method onDestroy takes nothing returns nothing    
        call AB_DestroyTrigger(.GetDamage)
        call AB_DestroyTrigger(.GetOrder)
        call AB_DestroyTimer(.check)
        
        set .GetDamage=null
        set .GetOrder =null
        set .attacker =null
        set .check    =null
    endmethod
  endstruct

  function DestroyDamageTrig_Vars takes trigger tt returns nothing
    local DmgData datas       =GetHandleAttach(tt,GCI)
    call DmgData.destroy(datas)
  endfunction

  private function TimerDestroy_DamageTrigger takes nothing returns nothing
    local DmgData datas       =GetHandleAttach(GetExpiredTimer(),GCI)
    call DmgData.destroy(datas)
  endfunction

  private function TriggerDestroy_DamageTrigger takes nothing returns nothing
    local DmgData datas       =GetHandleAttach(GetTriggeringTrigger(),GCI)
    call DmgData.destroy(datas)
  endfunction
  
  function DamageEvent_Condition takes nothing returns boolean
      local DmgData datas        =GetHandleAttach(GetTriggeringTrigger(),GCI)
      return GetEventDamageSource()==datas.attacker
  endfunction
  
  function TriggerAddDamageEvent takes unit attacked,real duration,unit attacker,code func returns nothing
    local DmgData datas        =DmgData.create()

    //Init
    set datas.GetDamage=CreateTrigger()
    set datas.GetOrder =CreateTrigger()
    set datas.check    =CreateTimer()
    set datas.attacker =attacker

    //Storing
    call SetHandleAttach(datas.GetDamage,GCI,datas)
    call SetHandleAttach(datas.GetOrder,GCI,datas)
    call SetHandleAttach(datas.check,GCI,datas)

    //Trigger Settings
    call TriggerAddAction(datas.GetDamage,func)
    call TriggerAddCondition(datas.GetDamage,Condition(function DamageEvent_Condition))
    call TriggerRegisterUnitEvent(datas.GetDamage,attacked,EVENT_UNIT_DAMAGED)

    call TriggerAddAction(datas.GetOrder,function TriggerDestroy_DamageTrigger)
    call TriggerRegisterUnitEvent(datas.GetOrder,attacker, EVENT_UNIT_ISSUED_ORDER )

    //Timer Start
    call TimerStart(datas.check,duration,false,function TimerDestroy_DamageTrigger)
  endfunction
endlibrary

Unfortunately I can't avoid the HandleVars, as a large portion of the JASS and JESP spells I've downloaded use them. As for the spells I make myself, I'd probably just stick to using Vexorian's spell factories, or Trigger based spells. I haven't looked through the list of JASS functions yet, but I probably should. I've been learning dummy systems and variables amongst a myriad of things like modeling and texturing. So I learn one thing at a slow pace but all things at a fast pace.

EDIT: I found out what was REALLY causing the problem. I fixed it.
I am still having problems with graphics in the game not showing up though, despite the skill being properly implemented.
 
Last edited:
Status
Not open for further replies.
Top