HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Discussion: My first JASS spell

05-06-2008, 02:24 AM#1
marven15
This is my first attempt on making a JASS spell. I made a passive skill where whenever the hero attacks, she gains agility. When she gains the maximum agility, it will reset back to 1. I got it working fine. Though some problems occur:
1. The first attack does not give bonus agility. I know it because the dummy ability's level 1 gives 0 agility, then 1 on level 2 and so on. What should I type or how should I type the actions? Note that the dummy ability is already at the hero that is why the first level is set to 0.
2. The trigger runs everytime she attacks. So gains agility even if she just attempts to attack. What should I type to prevent the player from abusing it.
Collapse JASS:
//////////////////////////////////////////////////////////////////////////////
//My first JASS Spell!                                                      //
//                                                                          //
//LUST ver. 1.                                                              //
//                                                                          //
//Description: Everytime the Arachnian Huntress attacks, her lust           // 
//for battle increases. Increases her agility by 1 points for every attack  //
//attack made. Once the maximum agility gain is reached, it will be set     //
//back to 1.                                                                //                       
//                                                                          //
//Author: marven15                                                          //
//////////////////////////////////////////////////////////////////////////////
scope Lust

globals
    private constant integer Lust_Ability_ID = 'A03U'
//Main Passive Ability Raw Code
    private constant integer Lust_Dummy_Ability_ID = 'A03Y'
//Dummy Attribute Bonus Ability
    private constant integer Lust_Max_Agi_Gain = 15
//Integer which will set the level of the dummy skill
    private integer array LustCounter
//Counter of the accumulated agility
endglobals    

//====================Filter Conditions======================================
//===========================================================================
private function LustConditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetAttacker(), Lust_Ability_ID) >= 1
endfunction
private function LustTargets takes nothing returns boolean
    return IsUnitType(GetAttackedUnitBJ(), UNIT_TYPE_STRUCTURE) == false and IsUnitEnemy(GetAttackedUnitBJ(), GetOwningPlayer(GetAttacker())) == true
endfunction
//====================End of Configuration===================================    
//====Don't edit anything beyond these lines unless you know you are doing===
private function LustActions takes nothing returns nothing
    local unit luster = GetAttacker()
    local integer lustlevel = GetUnitAbilityLevel(luster, Lust_Ability_ID)
    local integer index = GetUnitIndex(luster)

    if LustCounter[index] <= Lust_Max_Agi_Gain*lustlevel then
       set LustCounter[index] = LustCounter[index] + 1
       call SetUnitAbilityLevel( luster, Lust_Dummy_Ability_ID, LustCounter[index] )
    else
       set LustCounter[index] = 2
       call SetUnitAbilityLevel( luster, Lust_Dummy_Ability_ID, LustCounter[index] )
    endif
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger lusttrig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( lusttrig, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( lusttrig, Condition( function LustConditions ) )
    call TriggerAddCondition( lusttrig, Condition( function LustTargets ) )
    call TriggerAddAction( lusttrig, function LustActions )
endfunction

endscope
05-06-2008, 03:04 AM#2
Castlemaster
1. I'm not entirely sure what you mean by "What should I type or how should I type the actions?" If you are asking how to make the first attack give agility, I would assume you just set the ability so that the first lvl gives +1, the second level gives +2, etc. It should be a simple edit in the WE.

2. This can be remedied in two tedious, but effective ways. (1) Use a damage detection trigger (some can be found on wc3jass.com) that will add the agility after the unit has received damage from the attack, or (2) use searing arrows. Searing Arrows gives a buff when the attacking unit's attack hits (so just wait until the attacked unit has the buff to add the agility), however this has the problem that the searing arrows can be turned on or off. I'm assuming that you wouldn't want the player to max out the agility, then turn off the searing arrows and keep the max agility.

As far as I know, those are your options.
05-06-2008, 03:08 AM#3
marven15
hmmm.. Thanks... To clarify the number 1 problem, I edited the first post. I'll think I'll go check the damage detection system. :P