Spell Help (Spell Damage Enhancer)

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Ok here is a spell I want to make but I don't know how to make it :confused:

The spell works like this

The caster can cast a certain spell many times on a unit depending on how many times the unit casts that spell, he can later use another spell to make an explosion on the unit causing damage * how many times it was cast on. :nuts:
Code:
Using a powerful magic, the Lich can cast a powerful curse that can be add up to cause more damage, the spell can be released separately.

Level 1 - Cast up to 3 times 50 damage per cast.
Level 2 - Cast up to 4 times 60 damage per cast.
Level 3 - Cast up to 5 times 65 damage per cast.
Level 4 - Cast up to 6 times 70 damage per cast.

edit: I want to probably store this unit since I want to make a floating text (for damage) and a special effect, whenever the spell is released.
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Can you show me a quick example on how to use this system on my spell?
 

emjlr3

Change can be a good thing
Reaction score
395
simple sugg would be to use GC

your storing to string would be say

"Spell Name"+H2S(caster)+H2S(target)

you can store/edit the total number of casts, and retrive it later when you want to detonate

the same idea when using PUI, except since you can only attach to the unit itself, I see no way on discerning who casted the spell, or updating different casters numbers independantly, perhaps ask Cohadar for some help with that, if you wan to use PUI, if not, my GC sugg will take care of it
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Well this is what I have at the moment I am learning PUI

JASS:
scope VoodooCurse

globals
    integer array Ticks
    private constant integer ABILITY_ID = 'A00C'
endglobals

public function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local integer pui = GetUnitIndex(u)
    set Ticks[pui] = Ticks[pui] + 1
    if Ticks[pui]>5 then
    set Ticks[pui] = 5
endif
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function Actions )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
endfunction
endscope


JASS:
scope VoodooDamage

globals
    private constant integer ABILITY_ID = 'A00B'
endglobals

public function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction

private function Damage takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local integer pui = GetUnitIndex(u)
    call UnitDamageTarget(u,u,pui*60,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNKNOWN,WEAPON_TYPE_WHOKNOWS)
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function Damage)
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
endfunction
endscope


Now I need to figure out how to damage the right unit, right now I'm causing damage to my caster. :banghead:
 

Cohadar

master of fugue
Reaction score
209
JASS:
//==============================================================================
//  Use this as a starting point for structs that need to be attached to units
//  NOTE: create method is private for a purpose,
//  you should not create nor destroy PUI attached structs directly.
//  Use only GetData function, it will do the rest for you.
//==============================================================================
struct StructName
    unit whichUnit
    private static StructName array PUI

    // add your stuff here
    
    //------------------------------------------------------------------
    private static method create takes unit whichUnit returns StructName
        local StructName dat = StructName.allocate()
        set dat.whichUnit = whichUnit
        // add your stuff here
        return dat
    endmethod
    
    //------------------------------------------------------------------
    static method GetData takes unit whichUnit returns StructName
        local integer index = GetUnitIndex(whichUnit)
        // new struct?
        if StructName.PUI[index] == 0 then
            set  StructName.PUI[index] = StructName.create(whichUnit)
        // recycled struct?
        elseif StructName.PUI[index].whichUnit != whichUnit then
            call StructName.PUI[index].destroy()
            set  StructName.PUI[index] = StructName.create(whichUnit)
        endif
        return StructName.PUI[index]
    endmethod     
    
    //------------------------------------------------------------------
    method onDestroy takes nothing returns nothing
        // add your stuff here
    endmethod    
endstruct
//==============================================================================
//  To actually get a struct from unit simply do:
//  call StructName.GetData(whichUnit)
//==============================================================================
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Thank you very much Cohadar, I just need to read the vjass manual so I can work with this system better ;)
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
Well I tried "another method" to make the spell, now it doesn't harm my caster but it now it doesn't damage it just sets Ticks back to 0

JASS:
scope VoodooCurse

globals
    integer array Ticks
    private constant integer ABILITY_ID_DAMAGE = 'A00B'
    private constant integer ABILITY_ID = 'A00C' 
endglobals

private function Cast takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID
endfunction

private function Damage takes nothing returns boolean
    return GetSpellAbilityId() == ABILITY_ID_DAMAGE
endfunction

private function Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local integer pui = GetUnitIndex(u)
    if ( Cast() ) then
    set Ticks[pui] = Ticks[pui] + 1
    call BJDebugMsg("Spell Cast")
    call BJDebugMsg(I2S(Ticks[pui]))
        if Ticks[pui]>5 then
        set Ticks[pui] = 5
        endif
    else
        if ( Damage() ) then
        call BJDebugMsg("Damage")
        call UnitDamageTarget(GetTriggerUnit(),u,I2R(Ticks[pui]*60),true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_UNKNOWN,WEAPON_TYPE_WHOKNOWS)
        call BJDebugMsg(I2S(Ticks[pui]))
        else
        endif
    endif
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function Actions )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
endfunction
endscope
 

Cohadar

master of fugue
Reaction score
209
JASS:

//===========================================================================
//  Demo spell for using PUI in combination with global arrays
//  to create counters that are attached to unit
//
//  Author: Cohadar
//  Date: 2008.03.08
//===========================================================================

scope FleshHeap

globals
    private constant integer AID_FLESH_HEAP = 'A001'
    private constant integer AID_STR_BONUS  = 'A002'
    
    private constant integer HERO_PERCENT = 30
    private constant integer UNIT_PERCENT = 3
endglobals

globals    
    // do NOT use this arrays directly, use below functions
    private unit array PUI_unit
    private integer array PUI_counter
endglobals

//===========================================================================
private function GetCount takes unit whichUnit returns integer
    local integer index = GetUnitIndex(whichUnit)
    if PUI_unit[index] != whichUnit then
        set PUI_unit[index] = whichUnit
        set PUI_counter[index] = 0
    endif
    return PUI_counter[index]
endfunction

//===========================================================================
private function AddCount takes unit whichUnit, integer count returns nothing
    local integer index = GetUnitIndex(whichUnit)
    if PUI_unit[index] != whichUnit then
        set PUI_unit[index] = whichUnit
        set PUI_counter[index] = count
    else
        set PUI_counter[index] = PUI_counter[index] + count
    endif
endfunction

//===========================================================================
private function SetCount takes unit whichUnit, integer count returns nothing
    local integer index = GetUnitIndex(whichUnit)
    set PUI_unit[index] = whichUnit
    set PUI_counter[index] = count
endfunction

//===========================================================================
private function Actions takes nothing returns nothing
    local unit pudge = GetKillingUnit()
    local integer level = GetUnitAbilityLevel(pudge, AID_FLESH_HEAP)
    
    if IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) then
        call AddCount(pudge, level*HERO_PERCENT)
    else
        call AddCount(pudge, level*UNIT_PERCENT)
    endif
    
    if GetCount(pudge) >= 100 then
        call SetCount(pudge, 0)
        debug call BJDebugMsg("|c0000FF00" + "strength increased")
        call IncUnitAbilityLevel(pudge, AID_STR_BONUS) // green stat way
        //call SetHeroStr(pudge, GetHeroStr(pudge, false)+1, true)  // Dota way
    endif
    
    set pudge = null
endfunction

//===========================================================================
private function Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetKillingUnit(), AID_FLESH_HEAP) > 0
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope
 

emjlr3

Change can be a good thing
Reaction score
395
seriosuly follow that method there
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top