• 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] Abuff and Adamage HOW TO?

Status
Not open for further replies.
Level 16
Joined
Feb 22, 2006
Messages
960
Libraries are there to be used, and ADamage/ABuff isn't any random System.
Warcraft3 Jass coding would be so much better if one would use standard libraries instead of own "random" systems

@Ciebron: I didn't used them before, but I took a fast look over ADamage and there I see a function interface Response, i think you have to create your own function for the units you want to be registered and then create the function interface for it:
JASS:
public function interface Response takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing

this is the function interface... use it like this:

JASS:
//first create a function 
function test takes unit damagedUnit, unit damageSource, real damage, real prevented returns nothing
     call BJDebugMsg("Damage Target: "+GetUnitName(damagedUnit))
     call BJDebugMsg("Damage Source: "+GetUnitName(damageSource))
     call BJDebugMsg("Damage: "+R2S(damage))
endfunction

//then you need a function to register this
function init takes nothing returns nothing
     call ADamage_AddResponse(ADamage_Response.test)
endfunction

now your unit should be registered to the system
btw I didn't test it for myself but should work
And I hate public prefix 'cause they are shitty in vJass^^

hope I could help a bit
 
Level 11
Joined
Apr 6, 2008
Messages
760
It's more the Abuff system im wondeing about since i use another Damage Detection for my map

EDIT:

I have tried to make a spell using Abuff but i have this problem creating "ABuffEvent"

JASS:
scope HealingWave initializer init

globals
    private constant integer SPELL_ID = 'A004'
    private constant integer Max_Level = 4
endglobals

private function Heal takes integer level returns real
    return 100.+50.*level
endfunction

private function Mana takes integer level returns real
    return 50.+25.*level
endfunction

private function Jump takes integer level returns integer
    return 3+level
endfunction

// Setup End

globals
    public aBuffType id = 0
endglobals

private struct Data
unit Caster
unit array Targets [7]

integer Count

group Grp

    static method create takes unit u returns thistype
        local thistype this = thistype.allocate()
        
        set this.Caster = u
        set this.Count = 0
        set this.Grp = CreateGroup()
        
        set u = null
        
        return this
    endmethod
    
    method onDestroy takes nothing returns nothing
        local integer i = 0
        
        call DestroyGroup(this.Grp)
        
        loop
            exitwhen i >= 7
            set this.Targets[i] = null
            set i = i + 1
        endloop
        
        set this.Caster = null
        set this.Grp = null
    endmethod
        
endstruct

private function Create takes aBuff eventBuff returns nothing
    return
endfunction

private function Spell_Cast takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local Data this = Data.create(u)
    local integer level = GetUnitAbilityLevel(this.Caster,SPELL_ID)
endfunction

private function Conds takes nothing returns boolean
    return GetSpellAbilityId()==SPELL_ID
endfunction

private function init takes nothing returns nothing
        local trigger Trig = CreateTrigger()
        local integer index = 0
        
        loop
            call TriggerRegisterPlayerUnitEvent(Trig,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        
        call TriggerAddCondition(Trig,Condition(function Conds))
        call TriggerAddAction(Trig,function Spell_Cast)
        
        set id = aBuffType.create()
        
        set id.eventCreate = ABuffEvent_Create.Create //This line is the problem

endfunction        

endscope

I get this error

Syntax Error said:
Signature (arguments/return types) of function "HealingWave__Create" does not match the one defined for: "ABuffEvent_Create"

Anyone know why this pops?
 
Last edited:
Level 11
Joined
Apr 6, 2008
Messages
760
Bump

Even when i tried to save the Abuff test map i got this error :S

EDIT:

i made a quick test to check if 'interface' functions did work so i made this

JASS:
function interface ABuffEvent_Create takes aBuff eventBuff returns nothing

struct aBuff
endstruct

struct aBuffType
    ABuffEvent_Create eventCreate = 0
endstruct

and it work great ^^

FFS im getting angry now!
 
Level 8
Joined
Aug 6, 2008
Messages
451
Is it possible to use static methods with function interfaces in these days? I thought there was some problem with that stuff.
 
Status
Not open for further replies.
Top