• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help with Trigger (JASS & GUI)

Status
Not open for further replies.
Level 3
Joined
Mar 7, 2012
Messages
30
Help with Trigger (JASS & GUI)

Hello. I'm kinda new to mapmaking & triggering (about 1 month now :) ) and I'm trying to make a trigger. I need to make spells which will "change" the user into an animal and then when the animal uses the ability it will come back to its original form. So this is I got it work so far: First I store the transforming abilities in an array and the form of each ability in another array (I have just put one for now). I also store a Rect which for some reason it won't work.
  • Shape Forms
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Shape_Rect = (Rect(9.00, 225.00, 13.00, 230.00)) //area,will eplain
      • Set Shape_Count = 1 //how many spells there are
      • Set Shape_Abil[1] = Shapeshift (Wolf) //the spell
      • Set Shape_Form[1] = Dire Wolf // the form of each spell
I want the trigger to see when a unit casts one of these abilities and move it to a specific area (Shape_Rect), spawn the Shape_Form unit in its place. Also it will make the caster unit neutral and invulnerable. I have succeed half of that. I have made it possible to place the Shape_Form in its place and make it neutral and invulnerable but it won't move to the rect with the specified coordinates. The trigger is in JASS and I will post it in the end.
The second part: When the Shape_Form unit casts the ability "Shift Back" the original unit will come back to the Shape_Form's place with the normal owner and vulnerable. The Shape_Form unit will be removed. So this is the JASS part (I will put a comment on each line I have a problem)
JASS:
function Trig_Shapeshift_Copy_Actions takes nothing returns nothing
    local integer abil_number //this is the number of the ability found in array
    local unit shape_unit //this is the original unit
    local unit shape_unit2 //this is the unit that will be spawned
    local player shape_player //this is the owner of the original unit
    set abil_number = 0
    set shape_unit = GetTriggerUnit()
    set shape_player = GetOwningPlayer(GetTriggerUnit())
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = udg_Shape_Count
    loop
      exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
      if ( GetSpellAbilityId() == udg_Shape_Abil[GetForLoopIndexA()] ) then
          set abil_number = GetForLoopIndexA()
      else
          call DoNothing(  )
      endif
      exitwhen abil_number > 0
      set bj_forLoopAIndex = bj_forLoopAIndex + 1
  endloop
  if abil_number > 0 then
      call CreateNUnitsAtLocFacingLocBJ( 1, udg_Shape_Form[abil_number], GetOwningPlayer(shape_unit), GetUnitLoc(shape_unit), GetRandomLocInRect(GetPlayableMapRect()) )
      set shape_unit2 = GetLastCreatedUnit()
      call SetUnitInvulnerable( shape_unit, true )
      call SetUnitPositionLoc( shape_unit, GetRandomLocInRect(udg_Shape_Rect) )
      call SetUnitOwner( shape_unit, Player(PLAYER_NEUTRAL_PASSIVE), true )
        loop
            //this is the part I don't know what to add to check for ability until it 
           //gets the ability "Shift Back" (ofc the abilcode)
        endloop //the part below hasn't been tested since I cant make the 
                   //condition
        call SetUnitPositionLoc(shape_unit, GetUnitLoc(shape_unit2) )
        call RemoveUnit( shape_unit2 )
        call SetUnitInvulnerable( shape_unit, false )
        call SetUnitOwner( shape_unit, Player(0), true )           
    else
        call DoNothing(  )
    endif
endfunction

//===========================================================================
function InitTrig_Shapeshift_Copy takes nothing returns nothing
    set gg_trg_Shapeshift_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shapeshift_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddAction( gg_trg_Shapeshift_Copy, function Trig_Shapeshift_Copy_Actions )
endfunction

I have used locals because if I use globals it won't work if multiple players shapeshift. Thanks in advance for any help given :) :D
 
Last edited:
Level 6
Joined
Feb 5, 2012
Messages
1,685
so you just want to change form?

try hiding the original unit add the original unit's skills to the new one.
example
set unit1= druid
create 1 bear
set unit2=last created
hide unit 1
set unit 2=unit 1
add spell 1 to unit 1
set level of spell 1 to level of spell of unit
 
Status
Not open for further replies.
Top