• 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] Jass, damage bug on spell

Status
Not open for further replies.
Level 10
Joined
Feb 20, 2008
Messages
448
ok this is the jass i have :

my problem is, when other ability been cast near the caster, this spell do no damage, so demage are miss and u only see special effect!!!! i dont know how explain it good!!!! when i use this trigger after another trigger been use this trigger do no damage , did i miss something on trigger that do this ?

function Trig_Kamehameha_Func001C takes nothing returns boolean
return((GetSpellAbilityId()=='A00R'))or((GetSpellAbilityId()=='A01H'))or((GetSpellAbilityId()=='A006'))
endfunction

function Trig_Kamehameha_Conditions takes nothing returns boolean
return(Trig_Kamehameha_Func001C())
endfunction

function Trig_Kamehameha_Func005002003 takes nothing returns boolean
return(IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO))
endfunction

function Trig_Kamehameha_Func006A takes nothing returns nothing
call CameraSetEQNoiseForPlayer(GetOwningPlayer(GetEnumUnit()),(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*2.00))
call CameraSetTargetNoiseForPlayer(GetOwningPlayer(GetEnumUnit()),(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*3.00),200.00)
endfunction

function Trig_Kamehameha_Func022Func005002003001 takes nothing returns boolean
return(IsPlayerAlly(GetOwningPlayer(GetFilterUnit()),GetTriggerPlayer())==false)
endfunction

function Trig_Kamehameha_Func022Func005002003002 takes nothing returns boolean
return(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT)==false)
endfunction

function Trig_Kamehameha_Func022Func005002003 takes nothing returns boolean
return GetBooleanAnd(Trig_Kamehameha_Func022Func005002003001(),Trig_Kamehameha_Func022Func005002003002())
endfunction

function Trig_Kamehameha_Func022Func006A takes nothing returns nothing
call UnitDamageTargetBJ(bj_lastCreatedUnit,GetEnumUnit(),udg_real02,ATTACK_TYPE_MELEE,DAMAGE_TYPE_NORMAL)
call UnitAddType(GetEnumUnit(),UNIT_TYPE_ANCIENT)
endfunction

function Trig_Kamehameha_Func022Func008Func001C takes nothing returns boolean
return((IsDestructableAliveBJ(GetEnumDestructable())))
endfunction

function Trig_Kamehameha_Func022Func008A takes nothing returns nothing
if(Trig_Kamehameha_Func022Func008Func001C())then
call KillDestructable(GetEnumDestructable())
call TriggerExecute(udg_trigger623)
endif
endfunction

function Trig_Kamehameha_Func023Func002002003001 takes nothing returns boolean
return(IsPlayerAlly(GetOwningPlayer(GetFilterUnit()),GetTriggerPlayer())==false)
endfunction

function Trig_Kamehameha_Func023Func002002003002 takes nothing returns boolean
return(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT))
endfunction

function Trig_Kamehameha_Func023Func002002003 takes nothing returns boolean
return GetBooleanAnd(Trig_Kamehameha_Func023Func002002003001(),Trig_Kamehameha_Func023Func002002003002())
endfunction

function Trig_Kamehameha_Func023Func003A takes nothing returns nothing
call UnitRemoveType(GetEnumUnit(),UNIT_TYPE_ANCIENT)
endfunction

function Trig_Kamehameha_Func031A takes nothing returns nothing
call CameraClearNoiseForPlayer(GetEnumPlayer())
endfunction

function Trig_Kamehameha_Actions takes nothing returns nothing
set udg_location07=GetUnitLoc(GetTriggerUnit())
set udg_location08=GetSpellTargetLoc()
set udg_location09=PolarProjectionBJ(udg_location07,150.00,AngleBetweenPoints(udg_location07,udg_location08))
set udg_group05=GetUnitsInRangeOfLocMatching(512.00,udg_location07,Condition(function Trig_Kamehameha_Func005002003))
call ForGroupBJ(udg_group05,function Trig_Kamehameha_Func006A)
call DestroyGroup(udg_group05)
call AddSpecialEffectLocBJ(udg_location09,"Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl")
call TriggerExecute(udg_trigger620)
call AddSpecialEffectLocBJ(udg_location09,"Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl")
call TriggerExecute(udg_trigger620)
call CreateNUnitsAtLoc(1,'h018',GetTriggerPlayer(),udg_location09,AngleBetweenPoints(udg_location07,udg_location08))
call SetUnitScalePercent(bj_lastCreatedUnit,(250.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)),(250.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)),(250.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)))
call CreateNUnitsAtLoc(1,'h029',GetTriggerPlayer(),udg_location09,AngleBetweenPoints(udg_location07,udg_location08))
call SetUnitScalePercent(bj_lastCreatedUnit,(350.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)),(350.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)),(350.00+(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*10.00)))
call SetUnitTimeScalePercent(bj_lastCreatedUnit,15.00)
call KillUnit(bj_lastCreatedUnit)
call RemoveLocation(udg_location09)
set udg_real02=((I2R(GetHeroStatBJ(2,GetTriggerUnit(),false))*(I2R(GetUnitAbilityLevelSwapped(GetSpellAbilityId(),GetTriggerUnit()))*2.00))+100.00)
set bj_forLoopAIndex=1
set bj_forLoopAIndexEnd=5
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
set udg_location09=PolarProjectionBJ(udg_location07,(I2R(bj_forLoopAIndex)*200.00),AngleBetweenPoints(udg_location07,udg_location08))
call SetTerrainTypeBJ(udg_location09,'Kdtr',-1,3,0)
call SetTerrainTypeBJ(udg_location09,'Jdtr',-1,2,0)
call CreateNUnitsAtLoc(1,'h028',GetTriggerPlayer(),udg_location09,bj_UNIT_FACING)
set udg_group05=GetUnitsInRangeOfLocMatching(300.00,udg_location09,Condition(function Trig_Kamehameha_Func022Func005002003))
call ForGroupBJ(udg_group05,function Trig_Kamehameha_Func022Func006A)
call DestroyGroup(udg_group05)
call EnumDestructablesInCircleBJ(300.00,udg_location09,function Trig_Kamehameha_Func022Func008A)
call RemoveLocation(udg_location09)
set bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
set bj_forLoopAIndex=1
set bj_forLoopAIndexEnd=5
loop
exitwhen bj_forLoopAIndex>bj_forLoopAIndexEnd
set udg_location09=PolarProjectionBJ(udg_location07,(I2R(bj_forLoopAIndex)*200.00),AngleBetweenPoints(udg_location07,udg_location08))
set udg_group05=GetUnitsInRangeOfLocMatching(300.00,udg_location09,Condition(function Trig_Kamehameha_Func023Func002002003))
call ForGroupBJ(udg_group05,function Trig_Kamehameha_Func023Func003A)
call DestroyGroup(udg_group05)
call RemoveLocation(udg_location09)
set bj_forLoopAIndex=bj_forLoopAIndex+1
endloop
set udg_location09=PolarProjectionBJ(udg_location07,900.00,AngleBetweenPoints(udg_location07,udg_location08))
call TerrainDeformationWaveBJ(3.00,udg_location07,udg_location09,400.00,128.00,1.00)
call RemoveLocation(udg_location09)
call RemoveLocation(udg_location08)
call RemoveLocation(udg_location07)
call TriggerSleepAction(2.00)
call ForForce(bj_FORCE_ALL_PLAYERS,function Trig_Kamehameha_Func031A)
endfunction
 
Level 9
Joined
Oct 28, 2007
Messages
435
Use local variables! That makes your spell more MUI... I have no idea actually what might have caused the problem, but please just some tips:

Don't use bj functions. They just call other functions.
Instead of exicuting a trigger, just execute its function with:
call Execute("the functions name")
or
call the function of the trigger with
call Function's Name()
Use CreateUnitAtLoc instead of CreateNUnitsAtLoc if you create one unit

Your spell script really hurt my eyes when you try to read it. Add the jass text wrap around it.
 
Level 10
Joined
Feb 20, 2008
Messages
448
My jass are this bad :/ all jass from spell are like this!!! and im nnot a pro with jass,

but i im sure 2understand the thing bout createunit and creatNunit!! but what will it do ? would i need to make new variable so it dont get broke or not? lol and bout bj my jass skil not enough good to be able to optimize them :/

i would need some help to make local variable !!! do You know any link for this?? it would really help me!!! i could optimze all script and make my work 10 time better than other :p

thanks for ur tips but ill try to find glitch!!! could it happen?? if a variable (bj_last createdunit) could interfer into another spell that being casting 1sec after ? could this be possible?
 
Level 9
Joined
Oct 28, 2007
Messages
435
CreateUnit is a function in Jass that creates a unit. In Gui you have the option to convert your gui to Jass and in Gui you specify the number of units created by createNUnit. So basicly you have a loop internally running once creating a single unit which calls an uneeded function which is just a Waste since you have improved laginess. Now that us why you should use the CreateUnit function. It is a standard jass function that runs no other functions and is thus the best and most efficiant whay of creating a single unit.

Basicly all bj_functions are functions like CreateNUnits that just run other functions using the same variables in a differant order. For example:

JASS:
//
call AddSpecialEffectLocBJ(udg_location09,"Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl")
//


actually only calls another function:

AddSpecialEffectLoc(string model, loc location) so you should replace your:

JASS:
//
call AddSpecialEffectLocBJ(udg_location09,"Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl")
//

with :

JASS:
//
call AddSpecialEffectLoc("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl",udg_location09)
//


which will do the exact same thing just faster and more optimized.

Note that you now need to place the model path first and the location last

I just found a mayor leak in your special effect. Okay firstly :

What is a leak : A leak is a memory leak (sure helps a lot). No. A memory leak is a variable that is created but not destroyed. Gui sometimes create variables (actually Jass also create them) but you can only destroy them with Custom Script a.k.a jass.

Now your leak:
JASS:
//
call AddSpecialEffectLocBJ(udg_location09,"Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl")
//

This function creates a special effect. Kinda obvious, but not so obvious that it leaks. The reason why it leaks is because warcraft special effects are permenant and is only destroyed when destroyed by DestroyEffect function. So what I'm saying is that even though your special effect creates a explosion that goes off the data about the special effect is still stored in warcraft. So how to fix:

Simple:

Add the DestroyEffect function in front of your add special effect function. (I used the non-bj function here which is what you should do)

JASS:
//
call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl",udg_location09))
//

If your not usual jasser your head is probily paining now since the above function is unlike anything you have seen before. Well most functions return a variable for example: CreateUnitAtLoc returns a unit varialbe but you can't use it in Gui, but you can in jass this means that I can instead of using GetlastCreatedUnit() I can just use the returned unit. For Example (a realy stupid example) I want to create a unit and then use that unit and attaching a Special Effect to that unit you could call a function like this:

JASS:
//
call AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl",CreateUnitAtLocation('h00f',udg_Location009),"chest")
//

and don't have to use

JASS:
call CreateUnitAtLocation('h00f',udg_Location009)
call AddSpecialEffectTarget("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\Neutral BuildingExplosion.mdl",GetlastCreatedUnit(),"chest")

Now what is local variables? Local variables is variables that can only be used in your function for example:

JASS:
function MyFunc takes nothing returns unit
local unit u=CreateUnitFacing('h00f',0,0,0)
call SetUnitPosition(u,124,-342)
call AddSpecialEffectTarget("Explosion.mdx",u,"chest")
return u
endfunction

So basically as you can see I added the following line:
local <varibletype> <variablename>
I created a local unit variable with the name u now. That u variable is only used in that function but further acts as a normal variable. Now what do i mean with this. Another function. I want to make a spell that adds improves life of the caster by 20, 4 seconds after the spell is cast.

JASS:
function SpellActions takes nothing returns nothing 
local unit u=GetSpellAbilityUnit()
// Firstly I set my local variable
call TriggerSleepAction(4)
//Now my wait
call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+20)
// I can now use my local variable without worries about other spells. This spell is now  
//100% mui. In other words: Any unit can cast it any where without any interverance on
// Each other's spells
set u=null
// Okay. Very important about locals: They leak like hell and you always need to set 
//Clear the by setting them to null. This destroys the stored unit variable "u" and 
// does nothing with the unit itself.
endfunction
Okay now the magic starts : I want to create a spell that creates a globe of magical energy around the caster, makes it invulnerable and makes it vulnerable again after a duration. Also after becoming vulnerable again I want it to heal 200 life. Your action:

JASS:
function MySpell takes nothig returns nothing
local unit u=GetSpellAbilityUnit()
// Firsly I set u to the spellcasting unit
local effect fx=AddSpecialEffectToTarget(Your Special Effect model path,u,"chest")
// Now create a new local variable. This is my special effect. Why don't I use last
// Created Special Effect? Because last created special effect gets the last 
// created special effect created by any trigger not by your current trigger so I use a 
// local effect (in GUI its special effect) variable.

//Now:
call SetUnitVulnerability(u,false)
// This makes the unit invulnerable
call TriggerSleepAction(3)
// Wait 3 seconds
call SetUnitVulnerability(u,true)
//This makes the unit vulnerable again
call DestroyEffect(fx)
// This destroys my stored local special effect around the caster
call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+200)
// This increases the life of the caster by 200
set u=null
set fx=null
// Just destroying my local variables
endfunction

You can also have a series of other local variables for example reals or integers or strings: SO lets say in my above spells I want it to improve with levels then I will do the following:


JASS:
function MySpell takes nothig returns nothing
local unit u=GetSpellAbilityUnit()
local effect fx=AddSpecialEffectToTarget(Your Special Effect model path,u,"chest")
local integer lvl=GetUnitAbilityLevel(u,GetSpellAbilityId())

// You now store an integer that is the level of the spell when cast
// The reason why I do this is because spells you already cast
// shouldn't imrpove if you improve the level of an ability. Only spells that
// you cast after you improved the level of an ability should improve.
// For example: If I cast divine shield. And while I'm under
// The effects of divine shield I gain a skill level in divine shield, the duration
// Shouldn't improve because I casted it on a lower level. So back to busness

call SetUnitVulnerability(u,false)
call TriggerSleepAction(3+lvl) 

// Wait for 2 seconds + one for each level you have. SO you will
// be invulnerable for  3 seconds on level 1, 4 seconds on level 2,
// 5 seconds on level 3 and 12 seconds on level 10

call SetUnitVulnerability(u,true)
call DestroyEffect(fx)
call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+lvl*25)

// This increases the life of the the caster by the level you of the ability times 25
// So on level 1 it heals 25 life; level 2 50; level 3 150 and level 10: 500

set u=null
set fx=null

// Just destroying my local variables. Integers don't leak so you don't have to 
//destroy them
endfunction

I hope you understand local variables more now. Just ask if there is still something you will want to fix
I might rewrite your spell for you, but I'd rather show you how to do it yourself so you can improve your map and
learn instead how to do it yourself.

For additional help on local variables use Search the Jass Forums for Local Variables and the GuI forums for MUI GUI which would also help you,

Also the bj_last createdunit would bug serriosly if you have other spells that is casted at the same time.
 
Last edited:
Level 10
Joined
Feb 20, 2008
Messages
448
well actualy u found tha major bug thats happening now!!! thats cauing dmg to do no dmg or end on a specific place in map i remember i was walking and i died when my friend spelled!!!!, i understand a lot more jass and local variable but im not sure if ill but able to all optimize my script!!!!, i wish i could at base optimize my spell to remove 75 % game of my game memory leak, we can say some1 cast evry 20 sec, so that huge in a game of 45 min!!!! we could try to work together im visual if i see 1 spell how its make i will be able to do it with most of same kind of spell!!! im working with jasscraft i dont really like newjassgen wich made my map unable to be hosted :/ thanks a lot man if u can help me pm me my msn is [email protected] [email protected]
 
Status
Not open for further replies.
Top