HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Could u convert this to jass?

10-05-2009, 03:24 PM#1
Mendel
Hi, i hade made this simple costum spell ^^ (hurray me!).
now could i ask u to convert this to jass so i can use this at a map.
Trigger:
Apocalyptica
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Apocalyptica
Collapse Actions
Set Apocalyptica_Temp_Caster = (Casting unit)
Set Apocalyptica_Temp_Dmg = (Real(((50 + (50 x (Level of (Ability being cast) for Apocalyptica_Temp_Caster))) + ((Integer((Power((Real((Intelligence of Apocalyptica_Temp_Caster (Include bonuses)))), 2.00)))) / 7))))
Set Apocalyptica_Temp_Point = (Target point of ability being cast)
Wait ((Distance between (Position of Apocalyptica_Temp_Caster) and Apocalyptica_Temp_Point) / 680.00) seconds
Special Effect - Create a special effect at Apocalyptica_Temp_Point using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
Collapse Unit Group - Pick every unit in (Units within 200.00 of Apocalyptica_Temp_Point matching (((Owner of (Matching unit)) is an enemy of (Owner of Apocalyptica_Temp_Caster)) Equal to True)) and do (Actions)
Collapse Loop - Actions
Unit - Cause Apocalyptica_Temp_Caster to damage (Picked unit), dealing Apocalyptica_Temp_Dmg damage of attack type Spells and damage type Normal

Here is the jass version of it, (just did convert to text.);

Hidden information:
Collapse JASS:
function Trig_Apocalyptica_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Apocalyptica_Func006001003 takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(udg_Apocalyptica_Temp_Caster)) == true )
endfunction

function Trig_Apocalyptica_Func006A takes nothing returns nothing
    call UnitDamageTargetBJ( udg_Apocalyptica_Temp_Caster, GetEnumUnit(), udg_Apocalyptica_Temp_Dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Apocalyptica_Actions takes nothing returns nothing
    set udg_Apocalyptica_Temp_Caster = GetSpellAbilityUnit()
    set udg_Apocalyptica_Temp_Dmg = I2R(( ( 50 + ( 50 * GetUnitAbilityLevelSwapped(GetSpellAbilityId(), udg_Apocalyptica_Temp_Caster) ) ) + ( R2I(Pow(I2R(GetHeroStatBJ(bj_HEROSTAT_INT, udg_Apocalyptica_Temp_Caster, true)), 2.00)) / 7 ) ))
    set udg_Apocalyptica_Temp_Point = GetSpellTargetLoc()
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(udg_Apocalyptica_Temp_Caster), udg_Apocalyptica_Temp_Point) / 680.00 ) )
    call AddSpecialEffectLocBJ( udg_Apocalyptica_Temp_Point, "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl" )
    call ForGroupBJ( GetUnitsInRangeOfLocMatching(200.00, udg_Apocalyptica_Temp_Point, Condition(function Trig_Apocalyptica_Func006001003)), function Trig_Apocalyptica_Func006A )
endfunction

//===========================================================================
function InitTrig_Apocalyptica takes nothing returns nothing
    set gg_trg_Apocalyptica = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Apocalyptica, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Apocalyptica, Condition( function Trig_Apocalyptica_Conditions ) )
    call TriggerAddAction( gg_trg_Apocalyptica, function Trig_Apocalyptica_Actions )
endfunction


also, can u remove leaks?? ^^
and for my personal learning, can u befor converting to jass. post this as leak free in gui here at the forums, i want to learn to remove leaks by myself using GUI.

Thx :D
10-05-2009, 03:33 PM#2
Vexorian
Quote:
can u befor converting to jass. post this as leak free in gui here at the forums,
No, because it is impossible in GUI.

I don't think I would be helping you by removing the leaks for you. Learn vJass it is easy... All it takes for this spell to be leakless is for you to remove the locations created by GetUnitLoc and GetSpellTargetLoc() and also the group created by GetUnitsInRangeOfLocMatching
10-05-2009, 03:51 PM#3
Mendel
O: ok...
ok so can i ask only to convert it to jass, so it can be played at maps where couple of players could use this skill at the same time with out no bugs ?
10-05-2009, 05:44 PM#4
chobibo
So what you want is to convert this GUI trigger to a jass script?
10-05-2009, 06:10 PM#5
Mendel
yes simple as that, use all this local varbile or private whatever
10-05-2009, 06:54 PM#6
Cheezeman
Your way of saying "please help me convert this to jass so I can learn it" is quite a bit offensive to the reader, especially if he's (unlike me) very experienced...
Try again.
10-05-2009, 11:50 PM#7
TheKid
Quote:
Originally Posted by Vexorian
No, because it is impossible in GUI.

No its not...

Quote:
Originally Posted by Cheezeman
Your way of saying "please help me convert this to jass so I can learn it" is quite a bit offensive to the reader, especially if he's (unlike me) very experienced...

What would you prefer him do? This is the triggers & scripts help section of the forum. This is where he should be posting these types of questions. If you get offended by a simple question then you shouldn't visit this forum.


I don't see what the big problem is here. As long as he doesn't constantly ask people to convert spells to JASS for him there really should be no hesitation in helping him out.

I will do it. GUI leak-less too. Give me a bit.

Trigger:
Untitled Trigger 010
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Acid Bomb
Collapse Actions
Set Apocalyptica_Temp_Caster = (Triggering unit)
Set Apocalyptica_Temp_Dmg = 50.00
-------- ------------------------------------------------------------------------------------------------------------------ --------
-------- The location will have to be removed via "RemoveLocation" when it is no longer needed. --------
-------- ------------------------------------------------------------------------------------------------------------------ --------
Set Apocalytpica_Temp_Point = (Target point of ability being cast)
-------- ------------------------------------------------------------------------------------------------------------------ --------
-------- Using "Wait" is never a good solution, but in heart of the situation I'll use it anyways. --------
-------- ------------------------------------------------------------------------------------------------------------------ --------
Wait 2.00 seconds
-------- ------------------------------------------------------------------------------------------------------------------ --------
-------- In order to remove memory leaks caused by an effect, you must destroy it after. In order to reference it I use a variable. --------
-------- ------------------------------------------------------------------------------------------------------------------ --------
Special Effect - Create a special effect at Apocalytpica_Temp_Point using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
Set Apocalyptica_Temp_Effect = (Last created special effect)
Custom script: call DestroyEffect( udg_Apocalyptica_Temp_Effect )
-------- ------------------------------------------------------------------------------------------------------------------ --------
-------- The function "GetUnitInRangeOfLocMatching" uses a group variable to create a group, so we must destroy it after it is used (this still leaks the group created by default at Initialization). --------
-------- ------------------------------------------------------------------------------------------------------------------ --------
Set Apocalyptica_Temp_Group = (Units within 200.00 of Apocalytpica_Temp_Point matching (((Owner of (Matching unit)) is an enemy of (Owner of Apocalyptica_Temp_Caster)) Equal to True))
Collapse Unit Group - Pick every unit in Apocalyptica_Temp_Group and do (Actions)
Collapse Loop - Actions
Unit - Cause Apocalyptica_Temp_Caster to damage (Picked unit), dealing Apocalyptica_Temp_Dmg damage of attack type Spells and damage type Normal
Custom script: call DestroyGroup( udg_Apocalyptica_Temp_Group )
-------- ------------------------------------------------------------------------------------------------------------------ --------
Custom script: call RemoveLocation( udg_Apocalyptic_Temp_Point )

I believe this is the leak-less version of your code. I don't use GUI, so its harder for me to spot these things (especially with BJ functions). The numbers (and the ability) are not the same, but those differences don't change anything.

**Actually, that's not true. When you use "Get location of unit" it creates a location variable that is not removed. You will need to set the caster's location as its own separate variable, then use RemoveLocation like I have (after you are done using the location).

I'll post the vJass in a second.

Collapse JASS:
function Trig_Apocalyptica_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Apocalyptica_Func006001003 takes nothing returns boolean
    return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(udg_Apocalyptica_Temp_Caster)) == true )
endfunction

function Trig_Apocalyptica_Func006A takes nothing returns nothing
    call UnitDamageTargetBJ( udg_Apocalyptica_Temp_Caster, GetEnumUnit(), udg_Apocalyptica_Temp_Dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

function Trig_Apocalyptica_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()        //* In this case, GetTriggerUnit returns the same unit as GetSpellAbilityUnit
    local location loc = GetSpellTargetLoc()
    local location casterloc = GetUnitLoc(caster)   //* This is so that I can clean it up later
    local group enum = CreateGroup()
    
    
    //** I set these globals to the local equivilant so that they can be referenced from your enumeration functions
    set udg_Apocalyptica_Temp_Dmg = I2R(( (50 + (50 * GetUnitAbilityLevel(caster, GetSpellAbilityId()))) + (R2I(Pow(I2R(GetHeroInt( caster, true ), 2.0)) / 7))))
    set udg_Apocalyptica_Temp_Caster = caster
    //**
    
    call TriggerSleepAction( DistanceBetweenPoints( casterloc, loc ) / 680 )
    
    call DestroyEffect( AddSpecialEffect( "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl", GetLocationX(loc), GetLocationY(loc) ) )
    
    call GroupEnumUnitsInRange( enum, GetLocationX(loc), GetLocationY(loc), 200, Filter(function Trig_Apocalyptica_Func006001003))
    call ForGroup( enum, function Trig_Apocalyptica_Func006A )
    
    //** Now, clean up all of your handles
    call RemoveLocation(loc)
    call RemoveLocation(casterloc)
    call DestroyGroup(enum)
    
    //** Since they are locals (not globals) you have to set them to null as well
    set caster = null
    set loc = null
    set casterloc = null
    set enum = null
    
endfunction

I hope this helps. Don't be asking for this all the time though.
10-06-2009, 01:02 AM#8
Anopob
@TheKid: Custom script is JASS, which was what Vexorian probably was referring to.
10-06-2009, 10:45 AM#9
chobibo
I didn't find anything offensive in the starters question, I actually took the time trying to convert this, but then it came to me that the spell is more complex than what it looks like, so I just want to suggest the thread starter to read beginner jass tutorials. This spell would require attachment systems, so it's better to have a read at that.
10-06-2009, 07:17 PM#10
Mendel
well what i meant is to make that spell MUI...
after abit more learning, and understanding...
i have came up with this:

Collapse JASS:
function Trig_Apocalyptica_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Apocalyptica_Actions takes nothing returns nothing
    local unit Apocalyptica_Temp_Caster = GetSpellAbilityUnit()
    local location Apocalyptica_Temp_Point = GetSpellTargetLoc()
    local real Apocalyptica_Temp_Dmg = I2R(( ( 50 + ( 50 * GetUnitAbilityLevelSwapped(GetSpellAbilityId(), GetSpellAbilityUnit()) ) ) + ( R2I(Pow(I2R(GetHeroStatBJ(bj_HEROSTAT_INT, Apocalyptica_Temp_Caster, true)), 2.00)) / 7 ) ))
    local group Apocalyptica_Enemis = CreateGroup()
    local unit Apocalyptica_Temp_Unit
    call TriggerSleepAction( ( DistanceBetweenPoints(GetUnitLoc(Apocalyptica_Temp_Caster), Apocalyptica_Temp_Point) / 680.00 ) )
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "war3mapImported\\NewGroundEX.mdx" )
    call GroupEnumUnitsInRangeOfLoc(Apocalyptica_Enemis, Apocalyptica_Temp_Point, 150.0, null)
    loop 
       set Apocalyptica_Temp_Unit = FirstOfGroup(Apocalyptica_Enemis)
       exitwhen Apocalyptica_Temp_Unit == null
       if IsUnitEnemy(Apocalyptica_Temp_Unit, GetOwningPlayer(Apocalyptica_Temp_Caster)) then 
       call UnitDamageTargetBJ( Apocalyptica_Temp_Caster, Apocalyptica_Temp_Unit, Apocalyptica_Temp_Dmg, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
       endif
       call GroupRemoveUnit(Apocalyptica_Enemis, Apocalyptica_Temp_Unit)
    endloop
    call AddSpecialEffectLocBJ( Apocalyptica_Temp_Point, "Abilities\\Weapons\\SteamTank\\SteamTankImpact.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )
    call CameraSetEQNoiseForPlayer( GetOwningPlayer(Apocalyptica_Temp_Caster), 3 )
    call TriggerSleepAction( 0.50 )
    call CameraClearNoiseForPlayer( GetOwningPlayer(Apocalyptica_Temp_Caster) )
    call RemoveLocation( Apocalyptica_Temp_Point)
    call DestroyGroup(Apocalyptica_Enemis)
    set Apocalyptica_Temp_Caster = null
    set Apocalyptica_Enemis = null
endfunction

//===========================================================================
function InitTrig_Apocalyptica takes nothing returns nothing
    set gg_trg_Apocalyptica = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Apocalyptica, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Apocalyptica, Condition( function Trig_Apocalyptica_Conditions ) )
    call TriggerAddAction( gg_trg_Apocalyptica, function Trig_Apocalyptica_Actions )
endfunction

Does this leak in anyway?
And it's MUI?
10-06-2009, 07:36 PM#11
Anopob
For your group loop, your condition is too vague. It could trigger even on corpses which, if I'm not wrong, you wouldn't want. Another note: at the end of code, make sure to set locations to null too, as well as groups and units.

This does not necessarily have to due with MUI or leaks, but you are using a lot, a lot of BJ's. You should probably get JNGP or something and make them natives. Also, you use TriggerSleepAction, and while that probably works, keep a note that it is very inaccurate especially in multiplayer games.
10-06-2009, 09:25 PM#12
Mendel
erm, i am kinda knew for jass, what is BJ's? what is the diffrence?
and for triggersleep action, so what do i write instead of it? i am not familiar with jass i have learned only today ^^
10-07-2009, 03:46 AM#13
TheKid
I was trying to keep it as close to the original as I could, so it wouldn't confuse you.