• 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] Beginner Question

Status
Not open for further replies.
Level 2
Joined
Jan 26, 2005
Messages
10
hiho
I started yesterday in learning JASS with the help of some tutorials
I followed the beginners tutorial to the end and now I tried to advance the created spell a bit.
I tried to add an attack animation and a short waiting phase cause my unit is teleporting in notime between the enemies (you just see the specialeffect)

JASS:
function Slash_Actions takes nothing returns nothing

 local unit caster = GetSpellAbilityUnit() //Create a local variable and set it to the unit that's casting the spell
 local location start_position = GetUnitLoc(caster) //Create the local and set it to the caster's position
 local group enemies = CreateGroup() //When you create a group in JASS, it's like a trigger. First you need it empty, and then you add stuff to it
 local unit temp //Used when looping through the group
 local integer count = 5 //This will be the maximum amount of enemies that can be hit
 local location temp_loc //tmp location of the target unit 
 local effect specialEffect 
 
    call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 500.0, null)

// GroupEnumUnitsInRangeOfLoc takes a group, a location, a radius, and a boolexpr (a condition, kind of) and then gets units within that radius and adds them to our group

   loop
      set temp = FirstOfGroup(enemies)
      exitwhen temp == null or count == 0

      if IsUnitEnemy(temp, GetOwningPlayer(caster)) then //If the enemy unit is an enemy of the owner of the caster

          set temp_loc = GetUnitLoc(temp) //Set a temporary location variable to the enemy position

          set specialEffect = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", temp_loc)
        
          call SetUnitPositionLoc(caster, temp_loc) //Move our unit instantly to the enemy's location
          
          call SetUnitAnimation(caster,"Attack")
          
          call UnitDamageTarget(caster, temp, 50, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_CHOP)


//-----> this is the point where my character should a wait a bit to show the attack animation

                                                       //The caster will instantly damage the enemy for 50 damage with an attack type of chaos
                                                       //You can ignore the damage type, and the last parameter (weapontype) is just for sound, but we will
                                                       //have none for right now
          call SetUnitAnimation(caster,"Stand")  
                                                       
          call DestroyEffect(specialEffect)                                            
                                                       
          set count = count - 1 //A unit has been hit, so now the units left to hit is reduced by 1

      endif

      call GroupRemoveUnit(enemies, temp)
   endloop
   set specialEffect = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl", temp_loc)
   call SetUnitPositionLoc(caster, start_position)
   call DestroyEffect(specialEffect)   
  //Cleaning up memory leaks will be put here
  call RemoveLocation(start_position)
  call RemoveLocation(temp_loc)
  call DestroyGroup(enemies)
  set caster = null
  set start_position = null
  set enemies = null
  set temp = null
  set specialEffect = null
endfunction

I hope someone can answer my question, how I let script wait so that the player can see the attack animationen and the spell lasts more than a tenth of a second
 
Level 2
Joined
Jan 26, 2005
Messages
10
thx
that brings me to the next question
to create a script that is useful for all units it would be good to know the length of an animation
can I get this length?

e.g. I want the TriggerSleepAction to last as long as the attack animation needs to play
 
Status
Not open for further replies.
Top