Jump to content


Spellmaking: Systems & Templates


  • Please log in to reply
21 replies to this topic

#1 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 08 September 2006 - 07:12 AM

Index:
Relevant files:

Edited by Jewified, 27 June 2007 - 04:01 AM.


#2 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 08 September 2006 - 08:42 AM

CSCache System:
How to add this to your map:

Go into the custom script area by clicking on the map icon, at the top of the trigger list @ trigger editor.
Put this chunk of code in there:

CODE
//##Begin of CS Gamecache engine##
// ================================================================================
=================
// GameCache - Return bug module : Without gamecache or return bug, JASS would be a
// retarded-limited scripting language.
//
// ================================================================================
=================
// a.k.a H2I, changed name to CS_H2I to prevent conflicts with other systems (I intended this
// system to be easy to copy
//
function CS_H2I takes handle h returns integer
    return h
    return 0
endfunction

// ================================================================================
=================
// Main Gamecache handler
//
function CSCache takes nothing returns gamecache
    if udg_cscache==null then
        call FlushGameCache(InitGameCache("CasterSystem.vx"))
        set udg_cscache=InitGameCache("CasterSystem.vx")
        call StoreInteger(udg_cscache,"misc","TableMaxReleasedIndex",100)
        //Makes table indexes start at 100, so they don't conflict with certain handle types.
    endif
return udg_cscache
endfunction

// ================================================================================
==================
// Attachable vars : Attacheable variables are what most other people call Handle Variables, they
// allow to relate data with any handle, using a label, and its value, the stuff auto flushes if
// the value is 0, false, "", or null .
//
// Differences between Attacheable variables and "Local Handle Variables" :
// - The names of the functions
// - The name of the function group does not cause confusion, it is difficult to say:
//   "you should set local handle variables to null at the end of a function" since
//   it sounds as if you were talking about the "Local Handle Variables"
// - Also Have Attacheable Sets.
// - And can work together with Tables.
//
// Notes: don't "attach" variables on texttags nor those handle types used mostly for parameters
// (for example damagetype) , Although there is no reason to do so anyways
//
// Gamecache stuff are NOT Case Sensitive, don't ever use "" for label (Crashes game!)
//

// ================================================================================
============================
// For integers
//
function AttachInt takes handle h, string label, integer x returns nothing
local string k=I2S(CS_H2I(h))
    if x==0 then
        call FlushStoredInteger(CSCache(),k,label)
    else
        call StoreInteger(CSCache(),k,label,x)
    endif
endfunction
function GetAttachedInt_FromSet takes handle h, gamecache g returns integer
    return GetStoredInteger(g,I2S(CS_H2I(h))+";"+GetStoredString(g,"argpass","set"),GetStoredString(g,"argpass","seti"))
endfunction
function GetAttachedInt takes handle h, string label returns integer
    if (label=="") then
        return GetAttachedInt_FromSet(h,CSCache())
    endif
return GetStoredInteger(CSCache(), I2S(CS_H2I(h)), label)
endfunction

// ================================================================================
=============================
function AttachReal takes handle h, string label, real x returns nothing
local string k=I2S(CS_H2I(h))
    if x==0 then
        call FlushStoredReal(CSCache(),k,label)
    else
        call StoreReal(CSCache(),k,label,x)
    endif
endfunction
function GetAttachedReal takes handle h, string label returns real
    return GetStoredReal(CSCache(),I2S(CS_H2I(h)),label)
endfunction

// ================================================================================
=============================
function AttachBoolean takes handle h, string label, boolean x returns nothing
local string k=I2S(CS_H2I(h))
    if not x then
        call FlushStoredBoolean(CSCache(),k,label)
    else
        call StoreBoolean(CSCache(),k,label,x)
    endif
endfunction
function GetAttachedBoolean takes handle h, string label returns boolean
    return GetStoredBoolean(CSCache(),I2S(CS_H2I(h)),label)
endfunction

// ================================================================================
=============================
function AttachString takes handle h, string label, string x returns nothing
local string k=I2S(CS_H2I(h))
    if x=="" then
        call FlushStoredString(CSCache(),k,label)
    else
        call StoreString(CSCache(),k,label,x)
    endif
endfunction
function GetAttachedString takes handle h, string label returns string
    return GetStoredString(CSCache(),I2S(CS_H2I(h)),label)
endfunction


// ================================================================================
=============================
function AttachObject takes handle h, string label, handle x returns nothing
local string k=I2S(CS_H2I(h))
    if (x==null) then
        call FlushStoredInteger(CSCache(),k,label)
    else
        call StoreInteger(CSCache(),k,label,CS_H2I(x))
    endif
endfunction
function GetAttachedObject takes handle h, string label returns handle
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedWidget takes handle h, string label returns widget
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedLoc takes handle h, string label returns location
    return GetAttachedInt(h, label)
    return null
endfunction
function GetAttachedRect takes handle h, string label returns rect
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedRegion takes handle h, string label returns region
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedTimerDialog takes handle h, string label returns timerdialog
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedUnit takes handle h, string label returns unit
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedItem takes handle h, string label returns item
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedEffect takes handle h, string label returns effect
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedDestructable takes handle h, string label returns destructable
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedTrigger takes handle h, string label returns trigger
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedTimer takes handle h, string label returns timer
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedGroup takes handle h, string label returns group
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedTriggerAction takes handle h, string label returns triggeraction
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedLightning takes handle h, string label returns lightning
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedImage takes handle h, string label returns image
    return GetAttachedInt(h,label)
    return null
endfunction
function GetAttachedUbersplat takes handle h, string label returns ubersplat
    return GetAttachedInt(h,label)
    return null
endfunction


// this function takes a handle and clears out all values assigned to it
function FlushHandle takes handle subject returns nothing
    call FlushStoredMission(CSCache(),I2S(CS_H2I(subject)))
endfunction


And you're done.

Edited by Jewified, 08 September 2006 - 09:12 AM.


#3 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 08 September 2006 - 09:11 AM

Autocast Spells Template:
How to add this to your map:

Make an empty trigger called AutoCastSystem, convert it to jass (Edit tab -> press x), delete whatever is in it and add this code to it:

CODE

//Autocast ability ID.
function AC_AbilityID takes nothing returns integer
    return 'A005'
endfunction

//Autocast buff ID.
function AC_AbilityBuffID takes nothing returns integer
    return 'B000'
endfunction

//Autocast ability's turn-on string
function AC_AbilityOrderIDOn takes nothing returns string
    return "poisonarrows"
endfunction

//Autocast ability's turn-off string
function AC_AbilityOrderIDOff takes nothing returns string
    return "unpoisonarrows"
endfunction

//* Floating Text misc functions

//Floating text red color level (%)
function AC_TextTagRedLevel takes nothing returns real
    return 1.00
endfunction

//Floating text green color level (%)
function AC_TextTagGreenLevel takes nothing returns real
    return 85.00
endfunction

//Floating text blue color level (%)
function AC_TextTagBlueLevel takes nothing returns real
    return 86.00
endfunction

//Floating text's transparency (%)
function AC_TextTagTransparency takes nothing returns real
    return 15.00
endfunction

//Actual floating text string. for now, returns base damage + extra damage.
function AC_TextTagString takes real damage, real extradmg returns string
    return I2S(R2I(damage+extradmg))
endfunction

//determines whether to use the floating text or not. currently enabled;
//in order to disable it, change "return true" to "return false".
function AC_UseTextTag takes nothing returns boolean
    return true
endfunction

//* End floating text misc functions

//Trigger's main condition
function AC_Condition takes nothing returns boolean
    return( GetLearnedSkill() == AC_AbilityID() )
endfunction

function AutoCast_Effect takes nothing returns nothing
    local texttag g
    local real d = 1
    local trigger t=GetTriggeringTrigger()
    local real vel = TextTagSpeed2Velocity(64.0)
    local real xvel = vel * Cos(90.0 * bj_DEGTORAD)
    local real yvel = vel * Sin(90.0 * bj_DEGTORAD)
    local real textHeight

    
    if GetUnitAbilityLevel(GetTriggerUnit(), AC_AbilityBuffID()) > 0 and GetUnitAbilityLevel( GetEventDamageSource(), AC_AbilityID() )>0  then
        call DestroyTrigger(t)

//      Add whatever actions you want
//      in these lines;
//      this function triggers when the target unit is hit
//      by the autocast ability.

//      you may change the floating text's color, transparency,
//      string, state (enabled or disabled) by changing
//      the misc floating text functions above.

        if AC_UseTextTag() then

            set g = CreateTextTag()
            set textHeight = TextTagSize2Height(10.0)
            call SetTextTagText(g, AC_TextTagString(GetEventDamage(), 0.00), textHeight)
            call SetTextTagPosUnit(g, GetTriggerUnit(), 64.0)
            call SetTextTagColor(g, PercentTo255(AC_TextTagRedLevel()), PercentTo255(AC_TextTagGreenLevel()), PercentTo255(AC_TextTagBlueLevel()), PercentTo255(100.0-AC_TextTagTransparency()))
          
            call SetTextTagVelocity(g, xvel,yvel)
            call UnitDamageTarget(GetEventDamageSource(), GetTriggerUnit(), d, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS)
            call PolledWait(1)
            call DestroyTextTag( g )

        endif

    endif
    set g=null
    set t=null
endfunction


function AutoCast_Conditions takes nothing returns boolean
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_ATTACKED then
        return GetUnitAbilityLevel( GetAttacker(), AC_AbilityID() ) == 0 or (GetAttachedInt(GetAttacker(),"CSon")==1 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == false)

    elseif GetTriggerEventId() == EVENT_UNIT_ISSUED_ORDER then

        if GetIssuedOrderId() == OrderId(AC_AbilityOrderIDOn()) then
            call AttachInt( GetTriggerUnit(), "CSon", 1)

        elseif GetIssuedOrderId() == OrderId(AC_AbilityOrderIDOff()) then
            call AttachInt( GetTriggerUnit(), "CSon", 0)

        endif

    elseif GetTriggerEventId() == EVENT_UNIT_SPELL_EFFECT then
        return GetSpellAbilityId()== AC_AbilityID()

    endif
    return false
endfunction


function AutoCast_Activate takes nothing returns nothing
    local trigger r=CreateTrigger()
    local unit t
    local event e
    local triggeraction ta

    if GetTriggerEventId() == EVENT_UNIT_SPELL_EFFECT then
        set t=GetSpellTargetUnit()
    else
        set t=GetTriggerUnit()
    endif

    set e = TriggerRegisterUnitEvent( r, t, EVENT_UNIT_DAMAGED )
    set ta = TriggerAddAction(r,function AutoCast_Effect)

    call TriggerSleepAction(2)
    call DestroyTrigger(r)

    set r=null
    set t=null
    set e = null
    set ta = null
endfunction


function Trig_AutoCastSystem_Actions takes nothing returns nothing
    local trigger r=GetTriggeringTrigger()
    local trigger t=CreateTrigger()
    local triggeraction ta
    local triggercondition tc
    local event array e1
    local event e2
    local event e3
    local integer index

    
    set index = 0
    loop
        set e1[index] = TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    set e2 = TriggerRegisterUnitEvent( t, GetLearningUnit(), EVENT_UNIT_SPELL_EFFECT )
    set e3 = TriggerRegisterUnitEvent( t, GetLearningUnit(), EVENT_UNIT_ISSUED_ORDER )
    set tc = TriggerAddCondition(t, Condition(function AutoCast_Conditions) )
    set ta = TriggerAddAction(t , function AutoCast_Activate )


    call DestroyTrigger(r)
    set r=null
    set t=null
    set gg_trg_AutoCastSystem=null
    set index = 0
    loop
        set e1[index] = null
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    set e2 = null
    set e3 = null
    set tc = null
    set ta = null
endfunction

//===========================================================================
function InitTrig_AutoCastSystem takes nothing returns nothing
    set gg_trg_AutoCastSystem = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_AutoCastSystem, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( gg_trg_AutoCastSystem, Condition( function AC_Condition ) )
    call TriggerAddAction( gg_trg_AutoCastSystem, function Trig_AutoCastSystem_Actions )
endfunction


The values in this version are fit to work for my map, but for your map you will probably have to change the values of the following functions:

AC_AbilityID
AC_AbilityBuffID
AC_AbilityOrderIDOn
AC_AbilityOrderIDOff

to fit your map.
to see the raw ID of an ability or a buff simply press control+D and they will show instead of the ability/buff name.

For this to completely work you will need an ability based on an auto-cast ability such as searing arrows/frost arrows etc -- just change the ability ID and turn on/off strings to fit your map, and make sure your ability has a buff that will last about 0.2seconds.

If any bugs are found with the Autocast Spells Template please report them to me either through BNet (Jewified.@USEast), PM on these forums or an email to oxydize@gmail.com

*Thanks to Chuckle Brother for pointing out a few memory leaks in this system.

NOTE: This template uses this CSCache system.

Edited by Jewified, 10 June 2007 - 05:18 AM.


#4 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 04 October 2006 - 10:54 AM

CSCache (Different version; required for Chuckle Brother's Generic Damage and Bonus Mod):

Same instructions as the other CSCache system.
Code:

CODE
function CS_H2I takes handle h returns integer
return h
return 0
endfunction

function CSCache takes nothing returns gamecache
if udg_cscache==null then
call FlushGameCache(InitGameCache("CasterSystem.vx"))
set udg_cscache=InitGameCache("CasterSystem.vx")
call StoreInteger(udg_cscache,"misc","TableMaxReleasedIndex",100)
endif
return udg_cscache
endfunction

function NewTableIndex takes nothing returns integer
local gamecache g=CSCache()
local integer n=GetStoredInteger(g,"misc","FreeTableTotal")
local integer i
if (n>0) then
set i=GetStoredInteger(g,"misc","FreeTable1")
if (n>1) then
call StoreInteger(g,"misc","FreeTable1", GetStoredInteger(g,"misc","FreeTable"+I2S(n)) )
call FlushStoredInteger(g,"misc","FreeTable"+I2S(n))
endif
call StoreInteger(g,"misc","FreeTableTotal", n-1)
else
set i=GetStoredInteger(g,"misc","TableMaxReleasedIndex")+1
call StoreInteger(g,"misc","TableMaxReleasedIndex",i)
endif
call StoreBoolean(g,"misc","Created"+I2S(i),true)

set g=null
return i
endfunction
function NewTable takes nothing returns string
return I2S(NewTableIndex())
endfunction
function GetAttachmentTable takes handle h returns string
return I2S(CS_H2I(h))
endfunction

// ================================================================================
============================
function DestroyTable takes string table returns nothing
local gamecache g=CSCache()
local integer i=S2I(table)
local integer n
if (i!=0) and (GetStoredBoolean(g,"misc","Created"+table)) then
call FlushStoredBoolean(g,"misc","Created"+table)
set n=GetStoredInteger(g,"misc","FreeTableTotal")+1
call StoreInteger(g,"misc","FreeTableTotal",n)
call StoreInteger(g,"misc","FreeTable"+I2S(n),i)
endif
call FlushStoredMission(g,table)
set g=null
endfunction

// ================================================================================
============================
function ClearTable takes string table returns nothing
call FlushStoredMission(CSCache(),table)
endfunction


// ================================================================================
============================
function SetTableInt takes string table, string field, integer val returns nothing
local gamecache g=CSCache()
if (val==0) then
call FlushStoredInteger(g,table,field)
else
call StoreInteger(g,table,field,val)
endif
set g=null
endfunction
function GetTableInt takes string table, string field returns integer
return GetStoredInteger(CSCache(),table,field)
endfunction

// ================================================================================
============================
function SetTableReal takes string table, string field, real val returns nothing
local gamecache g=CSCache()
if (val==0) then
call FlushStoredReal(g,table,field)
else
call StoreReal(g,table,field,val)
endif
set g=null
endfunction
function GetTableReal takes string table, string field returns real
return GetStoredReal(CSCache(),table,field)
endfunction

// ================================================================================
============================
function SetTableBoolean takes string table, string field, boolean val returns nothing
local gamecache g=CSCache()
if (not(val)) then
call FlushStoredBoolean(g,table,field)
else
call StoreBoolean(g,table,field,val)
endif
set g=null
endfunction
function GetTableBoolean takes string table, string field returns boolean
return GetStoredBoolean(CSCache(),table,field)
endfunction

// ================================================================================
============================
function SetTableString takes string table, string field, string val returns nothing
local gamecache g=CSCache()
if (val=="") or (val==null) then
call FlushStoredString(g,table,field)
else
call StoreString(g,table,field,val)
endif
set g=null
endfunction
function GetTableString takes string table, string field returns string
return GetStoredString(CSCache(),table,field)
endfunction

function SetTableObject takes string table, string field, handle val returns nothing
local gamecache g=CSCache()
if (val==null) then
call FlushStoredInteger(g,table,field)
else
call StoreInteger(g,table,field,CS_H2I(val))
endif
set g=null
endfunction

// ================================================================================
============================

function GetTableObject takes string table, string field returns handle
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableWidget takes string table, string field returns widget
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRect takes string table, string field returns rect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableRegion takes string table, string field returns region
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimerDialog takes string table, string field returns timerdialog
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUnit takes string table, string field returns unit
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableItem takes string table, string field returns item
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableEffect takes string table, string field returns effect
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableDestructable takes string table, string field returns destructable
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTrigger takes string table, string field returns trigger
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTimer takes string table, string field returns timer
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableGroup takes string table, string field returns group
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTriggerAction takes string table, string field returns triggeraction
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableLightning takes string table, string field returns lightning
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableImage takes string table, string field returns image
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableUbersplat takes string table, string field returns ubersplat
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableSound takes string table, string field returns sound
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableBoolExpr takes string table, string field returns boolexpr
return GetStoredInteger(CSCache(),table,field)
return null
endfunction
function GetTableTriggerCondition takes string table, string field returns triggercondition
return GetStoredInteger(CSCache(),table,field)
return null
endfunction


Edited by Jewified, 04 October 2006 - 10:55 AM.


#5 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 05 October 2006 - 08:38 AM

Generic Damage system by Chuckle Brother: A relatively simple system that allows you to easily detect and differentiate between different damage.

Requirements: -> 1 Orb ability, 2 buffs, CSCache & the system's code.

System code (put this in the custom script section):

CODE
//***********
// Constants:
//***********

constant function GenericDamage_DamageDetector takes nothing returns integer
    return 'A08J'  //This is the orb ability that ALL units will be given when the system is
                   //initialized and when new units arrive into the game
endfunction

constant function GenericDamage_DamageDetectorBuff takes nothing returns integer
    return 'B000'  //This is the buff the orb ability will give to attacked units, and will be
                   //detected by the system. It should last a minimum of .01 seconds and will be
                   //automatically removed by the system
endfunction

constant function GenericDamage_ArrowDetectorBuff takes nothing returns integer
    return 'B000'  //This is the buff that ALL arrow spells you use in your map should give to the
                   //affected unit. It should last a minimum of .01 seconds and will be automatically
                   //removed by the system
endfunction

//******************
// Public Functions:
//******************

function GenericDamage_DummyDamage takes unit whichUnit, string whichState returns nothing
    if whichState=="Ignore" then
        call SetTableInt("[DamageDummy]_" + GetAttachmentTable(whichUnit), "DamageDummy", 1)
    elseif whichState=="Allow" then
        call DestroyTable("[DamageDummy]_" + GetAttachmentTable(whichUnit))
    elseif whichState=="ForceAttack" then
        call SetTableInt((GetAttachmentTable(whichUnit)+"[ForcedAttack]"),"ForcedAttack",1)
    elseif whichState=="NormalAttack" then
        call DestroyTable(GetAttachmentTable(whichUnit)+"[ForcedAttack]")
    endif
endfunction

function GetDamageFactor takes unit u,attacktype a, damagetype d returns real
local real hp=GetWidgetLife(u)
local real r

    set r=hp
    if (hp<20) then
        call SetWidgetLife(u,25)
        set r=25
    endif
    call GenericDamage_DummyDamage(u,"Ignore")
    call UnitDamageTargetBJ(u,u,10,a,d)
    call GenericDamage_DummyDamage(u,"Allow")
    set r= (r-GetWidgetLife(u)) / 10
    //call BJDebugMsg("Initial Life: "+R2S(hp)+"\nFinal Life: "+R2S(GetWidgetLife(u))+"\nLife Difference: "+R2S(hp - GetWidgetLife(u)))
    call SetWidgetLife(u,hp)
return r
endfunction

function GetEventAttackDamage takes nothing returns real
    return GetTableReal("[AttackDamage]","Damage")
endfunction
function GenericDamage_SetAttackDamage takes real r returns nothing
  call SetTableReal("[AttackDamage]","Damage",r)
endfunction

//******************
// Private Function:
//******************

function GenericDamage_DamageTaken takes nothing returns nothing
  local integer i
  local integer c=1
  local string funcName
  if (not HaveStoredInteger(udg_cscache, "[DamageDummy]_" + GetAttachmentTable(GetEventDamageSource()), "DamageDummy")) then
  
    if GetUnitAbilityLevel(GetTriggerUnit(), GenericDamage_DamageDetectorBuff()) > 0 or HaveStoredInteger(udg_cscache,(GetAttachmentTable(GetEventDamageSource())+"[ForcedAttack]"),"ForcedAttack") then
        //For use SPECIFICALLY for attacks or faked attacks

        //DO NOT REMOVE - Will cause fatal errors if you remove the following line of code
        call GenericDamage_DummyDamage(GetEventDamageSource(),"NormalAttack")  //Just in case something else is forcing it, we don't want infinite loops
    
        call UnitRemoveAbility(GetTriggerUnit(), GenericDamage_DamageDetectorBuff())
        call GenericDamage_SetAttackDamage(GetEventDamage())
        //call ExecuteFunc("CriticalStrike")
        //call ExecuteFunc("DeadlyStrike")
        set c=1
        set i=GetTableInt("[GenericDamage_Table]", "FuncCountAttack")
        loop
            exitwhen c > i
            set funcName=GetTableString("[GenericDamage_Table]", "AttackFunc_" + I2S(c))
            call ExecuteFunc(funcName)
            set c=c+1
        endloop
    elseif GetUnitAbilityLevel(GetTriggerUnit(), GenericDamage_ArrowDetectorBuff()) <= 0 and GetUnitAbilityLevel(GetTriggerUnit(), GenericDamage_DamageDetectorBuff()) <= 0 then
        //For use SPECIFICALLY for spell damage
        set i=GetTableInt("[GenericDamage_Table]", "FuncCount")
        set c=1
        loop
            exitwhen c > i
            set funcName=GetTableString("[GenericDamage_Table]", "Func_" + I2S(c))
            call ExecuteFunc(funcName)
            set c=c+1
        endloop
    elseif GetUnitAbilityLevel(GetTriggerUnit(), GenericDamage_ArrowDetectorBuff()) > 0 then
        //For use SPECIFICALLY for arrow damage
        call UnitRemoveAbility(GetTriggerUnit(),GenericDamage_ArrowDetectorBuff())
        set i=GetTableInt("[GenericDamage_Table]", "FuncCountArrow")
        set c=1
        loop
            exitwhen c > i
            set funcName=GetTableString("[GenericDamage_Table]", "ArrowFunc_" + I2S(c))
            call ExecuteFunc(funcName)
            set c=c+1
        endloop
    endif

  endif
endfunction

//*****************
// Public Function:
//*****************

function GenericDamage_QueueFuncBySpell takes string funcName returns nothing
    // ********************************************************************************
************
    // Info: This function queues the system to detect triggered/spell damage. You can force it to
    //       ignore certain damage by using a dummy unit and setting an integer under the table
    //       "[DamageDummy]_" + GetAttachmentTable(DUMMY), "DamageDummy". Any units who deal damage
    //       with the ignore integer under this heading set to a value. Flushing or destroying that
    //       that table will allow damage dealt by that dummy to be registered again
    // ********************************************************************************
************
    local integer i=GetTableInt("[GenericDamage_Table]", "FuncCount") + 1
    call SetTableString("[GenericDamage_Table]", "Func_" + I2S(i), funcName)
    call SetTableInt("[GenericDamage_Table]", "FuncCount", i)
    //call DisplayTimedTextToPlayer(Player(0), 0, 0, 5, "Function Queued: " + funcName + " in slot " + I2S(i))  //DEMO ADDITION - Use to check that its working right
endfunction

//*****************
// Public Function:
//*****************

function GenericDamage_QueueFuncByArrow takes string funcName returns nothing
    // ********************************************************************************
************
    // Info: This function queues the system to detect triggered/spell damage. You can force it to
    //       ignore certain damage by using a dummy unit and setting an integer under the table
    //       "[DamageDummy]_" + GetAttachmentTable(DUMMY), "DamageDummy". Any units who deal damage
    //       with the ignore integer under this heading set to a value. Flushing or destroying that
    //       that table will allow damage dealt by that dummy to be registered again
    // ********************************************************************************
************
    local integer i=GetTableInt("[GenericDamage_Table]", "FuncCountArrow") + 1
    call SetTableString("[GenericDamage_Table]", "ArrowFunc_" + I2S(i), funcName)
    call SetTableInt("[GenericDamage_Table]", "FuncCountArrow", i)
    //call DisplayTimedTextToPlayer(Player(0), 0, 0, 5, "Function Queued: " + funcName + " in slot " + I2S(i))  //DEMO ADDITION - Use to check that its working right
endfunction

//*****************
// Public Function:
//*****************

function GenericDamage_QueueFuncByAttack takes string funcName returns nothing
    // ********************************************************************************
************
    // Info: This function queues the given function to register attack damage. This requires a weak
    //       method using a stupid Orb Effect. Lame....
    // ********************************************************************************
************
    local integer i=GetTableInt("[GenericDamage_Table]", "FuncCountAttack") + 1
    call SetTableString("[GenericDamage_Table]", "AttackFunc_" + I2S(i), funcName)
    call SetTableInt("[GenericDamage_Table]", "FuncCountAttack", i)
    //call DisplayTimedTextToPlayer(Player(0), 0, 0, 5, "Function Queued: " + funcName + " in slot " + I2S(i))  //DEMO ADDITION - Use to check that its working right
endfunction

//*******************
// Private Functions:
//*******************

function GenericDamage_AddTriggers takes nothing returns nothing
    local trigger dmgtrigger = CreateTrigger()
    local string s="damagesystem_" + GetAttachmentTable(GetTriggerUnit())
  //call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,10,GetObjectName(GetUnitTypeId(GetTriggerUnit())))
    call TriggerRegisterUnitEvent(dmgtrigger, GetTriggerUnit(),EVENT_UNIT_DAMAGED)
    call UnitAddAbility(GetTriggerUnit(), GenericDamage_DamageDetector())
    call SetTableObject(s,"action",TriggerAddAction(dmgtrigger,function GenericDamage_DamageTaken))
    call SetTableObject(s,"dmgTrigger",dmgtrigger)
  set dmgtrigger = null
endfunction

function GenericDamage_RemoveTriggers takes nothing returns nothing
  local string s = "damagesystem_" + GetAttachmentTable(GetTriggerUnit())
  local trigger me=GetTableTrigger(s,"dmgTrigger")
  local triggeraction ma=GetTableTriggerAction(s,"action")
    if IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) then
      set me = null
      set ma = null
      return
    endif
    if me == null or ma == null then
     // call BJDebugMsg("The trigger or the action is null - Look for more leaks noob")
    endif
    call TriggerRemoveAction(me,ma)
    call DestroyTriggerSafe(me)
    call DestroyTable(GetAttachmentTable(me))
    call DestroyTable(s)
  set me=null
  set ma = null
endfunction

//===========================================================================
function Init_Generic_Damage takes nothing returns nothing
    local trigger entermap=CreateTrigger()
    local group g=CreateGroup()
    local unit u
    local trigger dmgtrigger
    local trigger upondeath=CreateTrigger()
    local string s
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)
    loop
        set u=FirstOfGroup(g)
        exitwhen u==null
        set dmgtrigger=CreateTrigger()
        set s="damagesystem_" + GetAttachmentTable(u)
        call UnitAddAbility(u, GenericDamage_DamageDetector())
        call TriggerRegisterUnitEvent(dmgtrigger,u,EVENT_UNIT_DAMAGED)
        call SetTableObject(s,"action",TriggerAddAction(dmgtrigger,function GenericDamage_DamageTaken))
        call SetTableObject(s,"dmgTrigger",dmgtrigger)
        call GroupRemoveUnit(g,u)
    endloop
    call TriggerRegisterEnterRectSimple(entermap, bj_mapInitialPlayableArea)
    call TriggerAddAction(entermap,function GenericDamage_AddTriggers)

    call TriggerRegisterAnyUnitEventBJ(upondeath,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddAction(upondeath,function GenericDamage_RemoveTriggers)
    set dmgtrigger=null
    set g=null
    set upondeath=null
endfunction

Edited by Jewified, 05 October 2006 - 08:40 AM.


#6 Jewified

Jewified

    Twins incarnate

  • Forum Leaders
  • 3432 posts
  • Bnet Name:Jewified.
  • Bnet Realm:Azeroth

Posted 05 October 2006 - 12:52 PM

BonusMod system: Similar to the system made by Weaddar, its a small function that allows you to add, remove and screw with a number of bonus types.
Currently Supports -> +Agi,+Int,+Str,+Dmg,+All Stats,+Armor,+Attack Speed,+Life Regen,+Mana Regen.
Requirements: -> 1 global integer array (named BMBits) and CSCache.
By Chuckle Brother.

To set it up, copy this code into the custom script section:

CODE
constant function BonusMod_MaxBonus takes nothing returns integer
  return 1023  //This is the maximum positive value the system can add
endfunction

constant function BonusMod_MinBonus takes nothing returns integer
  return 1024 //This is the maximum negative value the system can add
endfunction

constant function BonusMod_NumBonus takes nothing returns integer
  return 10 //This is number of positive abilities each Bonus type has..NOT counting the negative
            //bonus
endfunction

function BonusMod_TimedRemoval takes nothing returns nothing
  call ExecuteFunc("BonusMod_TimedRemovalChild")
endfunction

function BonusMod_GetBonusAmount takes unit u, integer bonusType returns integer
  return GetStoredInteger(udg_cscache,"[BonusMod]"+GetAttachmentTable(u),"[BonusType]"+I2S(bonusType))
endfunction

function BonusMod_AddBonus takes unit u, integer bonusType, integer amount, real dur returns nothing

  local integer i = 1
  local integer c = 0
  local integer currentAmount = BonusMod_GetBonusAmount(u,bonusType)
  local integer toAdd
  local string s = "[BonusMod]"+GetAttachmentTable(u)
  local timer t

   set amount = currentAmount + amount
   if amount > BonusMod_MaxBonus() then
     set amount = BonusMod_MaxBonus()
     set toAdd = amount
     call UnitRemoveAbility(u,udg_BMBits[BonusMod_NumBonus() + bonusType])
   endif
   if amount < 0 then
     set toAdd = amount
     set amount = amount + BonusMod_MinBonus() //Find out how many points we will add to arrive at our proper negative value
     call UnitRemoveAbility(u,udg_BMBits[BonusMod_NumBonus() + bonusType])
   else
     set toAdd = amount
   endif

   set i = BonusMod_NumBonus()
   set c = (BonusMod_MaxBonus() + 1) / 2

   loop
    exitwhen i == 0
    if amount >= c and GetUnitAbilityLevel(u,udg_BMBits[i + bonusType - 1]) <= 0 then
      call UnitAddAbility(u,udg_BMBits[i + bonusType - 1])
      set amount = amount - c
    else
      call UnitRemoveAbility(u,udg_BMBits[i + bonusType - 1])
    endif
    set i = i - 1
    set c = c / 2
   endloop

   call SetTableInt(s,"[BonusType]"+I2S(bonusType),toAdd)

   if dur > 0 then
     set t = CreateTimer()
     set s = GetAttachmentTable(t)
     call SetTableObject(s,"targ",u)
     call SetTableInt(s,"amount",-amount)
     call SetTableInt(s,"type",bonusType)
     call TimerStart(t,dur,false,function BonusMod_TimedRemoval )
     set t = null
   endif

endfunction

function BonusMod_TimedRemovalChild takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local string s = GetAttachmentTable(t)
  local unit u = GetTableUnit(s,"targ")
    
   //call BJDebugMsg("Removing a bonus of: "+I2S(GetTableInt(s,"amount"))+" from "+s)
   call BonusMod_AddBonus(u,GetTableInt(s,"type"),GetTableInt(s,"amount"),null)

  call ClearTimer(t)
  set t = null
  set u = null
endfunction

function BonusMod_Init takes nothing returns nothing
local unit dummy = CreateUnit(Player(15),'h001',0,0,0)
local integer i = 1
//Armor
  set udg_BMBits[ 1] = 'A00C'
  set udg_BMBits[ 2] = 'A007'
  set udg_BMBits[ 3] = 'A009'
  set udg_BMBits[ 4] = 'A00A'
  set udg_BMBits[ 5] = 'A00B'
  set udg_BMBits[ 6] = 'A00K'
  set udg_BMBits[ 7] = 'A00F'
  set udg_BMBits[ 8] = 'A00G'
  set udg_BMBits[ 9] = 'A00H'
  set udg_BMBits[10] = 'A00I'
  set udg_BMBits[11] = 'A00L'
//All Stats
  set udg_BMBits[12] = 'A00M'
  set udg_BMBits[13] = 'A01J'
  set udg_BMBits[14] = 'A01K'
  set udg_BMBits[15] = 'A01L'
  set udg_BMBits[16] = 'A01M'
  set udg_BMBits[17] = 'A01N'
  set udg_BMBits[18] = 'A01O'
  set udg_BMBits[19] = 'A01P'
  set udg_BMBits[20] = 'A01Q'
  set udg_BMBits[21] = 'A01R'
  set udg_BMBits[22] = 'A01S'
//Damage
  set udg_BMBits[23] = 'A00O'
  set udg_BMBits[24] = 'A001'
  set udg_BMBits[25] = 'A01I'
  set udg_BMBits[26] = 'A01T'
  set udg_BMBits[27] = 'A01U'
  set udg_BMBits[28] = 'A01V'
  set udg_BMBits[29] = 'A01W'
  set udg_BMBits[30] = 'A01X'
  set udg_BMBits[31] = 'A01Y'
  set udg_BMBits[32] = 'A01Z'
  set udg_BMBits[33] = 'A020'
//Attack speed
  set udg_BMBits[34] = 'A004'
  set udg_BMBits[35] = 'A021'
  set udg_BMBits[36] = 'A022'
  set udg_BMBits[37] = 'A023'
  set udg_BMBits[38] = 'A024'
  set udg_BMBits[39] = 'A025'
  set udg_BMBits[40] = 'A026'
  set udg_BMBits[41] = 'A027'
  set udg_BMBits[42] = 'A028'
  set udg_BMBits[43] = 'A029'
  set udg_BMBits[44] = 'A02A'
//Agility
  set udg_BMBits[45] = 'A00P'
  set udg_BMBits[46] = 'A02B'
  set udg_BMBits[47] = 'A02C'
  set udg_BMBits[48] = 'A02D'
  set udg_BMBits[49] = 'A02E'
  set udg_BMBits[50] = 'A02F'
  set udg_BMBits[51] = 'A02G'
  set udg_BMBits[52] = 'A02H'
  set udg_BMBits[53] = 'A02I'
  set udg_BMBits[54] = 'A02J'
  set udg_BMBits[55] = 'A02K'
//Intelligence
  set udg_BMBits[56] = 'A00S'
  set udg_BMBits[57] = 'A02L'
  set udg_BMBits[58] = 'A02M'
  set udg_BMBits[59] = 'A02N'
  set udg_BMBits[60] = 'A02O'
  set udg_BMBits[61] = 'A02P'
  set udg_BMBits[62] = 'A02Q'
  set udg_BMBits[63] = 'A02R'
  set udg_BMBits[64] = 'A02S'
  set udg_BMBits[65] = 'A02T'
  set udg_BMBits[66] = 'A02U'
//Strength
  set udg_BMBits[67] = 'A00T'
  set udg_BMBits[68] = 'A02V'
  set udg_BMBits[69] = 'A02W'
  set udg_BMBits[70] = 'A02X'
  set udg_BMBits[71] = 'A02Y'
  set udg_BMBits[72] = 'A02Z'
  set udg_BMBits[73] = 'A030'
  set udg_BMBits[74] = 'A031'
  set udg_BMBits[75] = 'A032'
  set udg_BMBits[76] = 'A033'
  set udg_BMBits[77] = 'A034'
//Life Regeneration
  set udg_BMBits[78] = 'A005'
  set udg_BMBits[79] = 'A002'
  set udg_BMBits[80] = 'A035'
  set udg_BMBits[81] = 'A036'
  set udg_BMBits[82] = 'A037'
  set udg_BMBits[83] = 'A038'
  set udg_BMBits[84] = 'A039'
  set udg_BMBits[85] = 'A03A'
  set udg_BMBits[86] = 'A03B'
  set udg_BMBits[87] = 'A03C'
  set udg_BMBits[88] = 'A03D'
//Mana Regeneration
  set udg_BMBits[89] = 'A006'
  set udg_BMBits[90] = 'A03E'
  set udg_BMBits[91] = 'A03F'
  set udg_BMBits[92] = 'A03G'
  set udg_BMBits[93] = 'A03H'
  set udg_BMBits[94] = 'A03I'
  set udg_BMBits[95] = 'A03J'
  set udg_BMBits[96] = 'A03K'
  set udg_BMBits[97] = 'A03L'
  set udg_BMBits[98] = 'A03M'
  set udg_BMBits[99] = 'A03N'

  loop
    exitwhen i > 100
    call UnitAddAbility(dummy,udg_BMBits[i])
    call UnitRemoveAbility(dummy,udg_BMBits[i])
    set i = i + 1
  endloop
  call KillUnit(dummy)
endfunction


**Note**

You will need to also re-create the abilities that drive this system; refer to the attached map which has an example of how this system works. -Chuckle.

Edited by Jewified, 06 October 2006 - 01:20 AM.


#7 Necrowizard

Necrowizard

    Novice

  • Members
  • PipPip
  • 37 posts
  • Bnet Name:Necrowizard
  • Bnet Realm:Northrend

Posted 09 June 2007 - 08:06 AM

Good god! Was looking for a walk-through to auto-cast abilities and found a template. Thank you for a work well done!

#8 selfish_coyote

selfish_coyote

    Newbie

  • Members
  • Pip
  • 1 posts
  • Bnet Name:huhu_player
  • Bnet Realm:Azeroth

Posted 30 June 2007 - 06:11 AM

Woah is that a joke or a code??

now i know how hard to make DotA Code

#9 waaaks!™

waaaks!™

    Veteran

  • Members
  • PipPipPipPip
  • 181 posts
  • Interests:playing DotA allstars, world editing
  • Bnet Name:roljohn
  • Bnet Realm:none

Posted 18 October 2007 - 02:58 AM

its not very hard to make codes, especially when you have a hang of it....

im very thankful Jewified, because im JASS maker in some maps, and the only last thing i havent made is the auto cast attack ability, im searching some sites that can help me...but no one can give me a system instead spells...but this is weird, because this is my second home, and here will i find the system.....thank you very much, now ill share the system and they will credit you....thanks

also for more jass scripts and map making help, go to

www.wc3campaigns.net
www.wc3jass.com
www.thehelper.net my 1st home

Edited by waaaks!™, 18 October 2007 - 03:00 AM.


#10 waaaks!™

waaaks!™

    Veteran

  • Members
  • PipPipPipPip
  • 181 posts
  • Interests:playing DotA allstars, world editing
  • Bnet Name:roljohn
  • Bnet Realm:none

Posted 19 October 2007 - 03:59 AM

why does auto cast template doesnt work on my map....i changed the whole raw codes to my spells and buffs raw codes, but still doesnt work

#11 ertaboy356b

ertaboy356b

    Newbie

  • Members
  • Pip
  • 18 posts
  • Bnet Name:Lynxx
  • Bnet Realm:none

Posted 29 October 2007 - 04:57 AM

Maybe because you need something that was based on frost arrows.... Something with a buff.

#12 waaaks!™

waaaks!™

    Veteran

  • Members
  • PipPipPipPip
  • 181 posts
  • Interests:playing DotA allstars, world editing
  • Bnet Name:roljohn
  • Bnet Realm:none

Posted 31 October 2007 - 07:13 PM

im sure that i didnt missed anything

im sure that i didnt missed anything

#13 TruePsychlown

TruePsychlown

    Newbie

  • Members
  • Pip
  • 18 posts
  • Bnet Name:Pyschlown
  • Bnet Realm:none

Posted 05 February 2008 - 11:07 AM

Will this work on all program languages?

#14 TrabajarTrabajar

TrabajarTrabajar

    Pirates > Ninjas

  • Members
  • PipPipPipPipPip
  • 1699 posts
  • Bnet Name:moskva
  • Bnet Realm:none
  • Potential:R

Posted 09 February 2008 - 12:17 AM

It's in JASS.

So no.

#15 NoFriends[DuRuM

NoFriends[DuRuM

    Newbie

  • Members
  • Pip
  • 4 posts
  • Bnet Name:NoFriends[DuRuM
  • Bnet Realm:Northrend

Posted 13 February 2008 - 04:18 PM

Damn i hate JASS!!! Dont be an *** stop the JASS! biggrin.gif just joking

#16 sapphiron_halcyon

sapphiron_halcyon

    Enthusiast

  • Members
  • PipPipPipPipPip
  • 395 posts
  • Bnet Name:falloutz
  • Bnet Realm:Azeroth

Posted 09 March 2008 - 06:22 AM

Damn. I thought JASS is easy as ABC.

#17 waaaks!™

waaaks!™

    Veteran

  • Members
  • PipPipPipPip
  • 181 posts
  • Interests:playing DotA allstars, world editing
  • Bnet Name:roljohn
  • Bnet Realm:none

Posted 22 May 2008 - 02:59 PM

u will finish studying jass basics in 2 - 3 weeks and 1 year mastering jass, vjass, and other systems

#18 d3st88

d3st88

    Newbie

  • Members
  • Pip
  • 1 posts
  • Bnet Name:emperor_d3st
  • Bnet Realm:Northrend

Posted 06 June 2008 - 09:52 AM

Jass Basics = 5 hours of JASSing (learning about leaks, handles, natives vs BJs, syntaxes, installing NewGen).
Advanced Jass knowledge.. well it can take at least a 100 hours but most probably more.
Mastering Jass? Well you won't. There's always something to discover, something new to learn.

#19 flying banana

flying banana

    Enthusiast

  • Members
  • PipPipPipPipPip
  • 408 posts
  • Bnet Name:Flying_Banana
  • Bnet Realm:Lordaeron

Posted 25 June 2008 - 10:22 PM

I guess I'm off to learn Jass...

#20 azwraith_ftL

azwraith_ftL

    Veteran

  • Members
  • PipPipPipPip
  • 168 posts
  • Interests:vJASS scirpting, DotA
  • Bnet Name:phntmLncr
  • Bnet Realm:Northrend

Posted 27 August 2008 - 09:52 AM

BJs, H2I bug, handle variables ... No wonder late game lag spikes appear....

Edited by azwraith_ftL, 30 August 2008 - 08:45 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users