• 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.

What is wrong with this [JASS] function?

Status
Not open for further replies.
Here it is:
JASS:
function GrappleDamageFunction takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    call UnitDamageTargetBJ(c, t, (50.00 * (I2R(GetUnitAbilityLevelSwapped(SPELL_ID, c)))), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
    //Leak Fixes
    set c = null
    set t = null
endfunction
PS: SPELL_ID = 'A000'

The unit won't deal damage when it is initiated by this trigger:
  • GrappleInit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Grapple
    • Actions
      • Custom script: call GrappleDamageFunction()

What's wrong with it? (It actually works on occation, but not often. Actually only when the spell is cast very fast many times.)
 
Level 4
Joined
May 4, 2008
Messages
113
Why even bother using a JASS function?

Code:
Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing <your damage> of damage type Spells and attack type Normal

That's all the JASS function is doing, really =\. It isn't even changed from a BJ to a native...
 
Yeah, you're right. Jass isn't needed here..

EDIT: But! Then it won't use locals, and therefore not be MUI :O Won't it?

Yes, it would, because there's no waits :p
That is, the trigger is pratically instant, so many units could use it at almost the same time.

Maybe you should tell us what is SPELL_ID in the function?
(Although I'd tell you to use GUI :p)

EDIT: Lol just realized the line under the code >.>
 
Level 6
Joined
Nov 3, 2008
Messages
117
well i guess i know your problem
JASS:
function GrappleDamageFunction takes nothing returns nothing    
local unit c = GetTriggerUnit()    
local unit t = GetSpellTargetUnit()    
call UnitDamageTargetBJ(c, t, (50.00 * (I2R(GetUnitAbilityLevelSwapped(SPELL_ID, c)))), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)   
 //Leak Fixes    
set c = null    
set t = nullendfunction

In this case unit c and unit t are null, because this function has nothing to do with the spell function, so you can't set them as GetTriggerUnit() and GetSpellTargetUnit().

I would do it like this

JASS:
function GrappleDamageFunction takes unit u, unit v returns nothing    
local unit c = u  
local unit t = v
call UnitDamageTargetBJ(c, t, (50.00 * (I2R(GetUnitAbilityLevelSwapped(SPELL_ID, c)))), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)   
 //Leak Fixes    
set c = null    
set t = null
endfunction

so at the spellevent you have to do it llike this
  • GrappleInit
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Grapple
  • Actions
    • Custom script: call GrappleDamageFunction(GetSpellAbilityUnit( ) , GetSpellTargetUnit( ) )
and i think it will work now
 
I see what you mean... But I don't think it works like that. See this code:
JASS:
function GrappleFunction takes nothing returns nothing
    //Knockback Effect
    local unit c = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x1 = GetUnitX(c)
    local real y1 = GetUnitY(c)
    local real x2 = GetUnitX(t)
    local real y2 = GetUnitY(t)
    local location pc = GetUnitLoc(c)
    local location pt = GetUnitLoc(t)
    local effect effect1
    local real dist = -1 * ((DistanceBetweenPoints(pc, pt)) - 100)
    local real angle = Atan2(y2 - y1, x2 - x1)
    local real dur = 1
    local real radius = 100
    local integer effects = 0
    local string effectmdl = ""
    local string effectpoint = ""
    call KnockbackEx(t, dist, angle, dur, radius, effects, effectmdl, effectpoint)
    //Leak Fixes
    set c = null
    set t = null
    set pc = null
    set pt = null
endfunction

it doesn't take anything, but it still works as it should... Maybe I should put all my func. into this one?

EDIT: It's working now, I just put everything into 1 function (I had three different for one event :S) +rep for trying to help, though! :D
 
Status
Not open for further replies.
Top