• 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] Not working at all...

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
JASS:
private function DamageType takes nothing returns nothing
    local group kunit = GetUnitsInRectAll(gg_rct_Region_000)
    local unit tempunit = FirstOfGroup(kunit)

        call DisplayTextToForce(GetPlayersAll(), "Casting a 100 damage chain lighting")
        call CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n000', GetRectCenter(gg_rct_Region_001), 90)
        call IssueTargetOrderBJ(GetLastCreatedUnit(), "chainlightning", tempunit)
        call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 3)
        call FDamage()
    call DestroyGroup(kunit)
    set kunit = null
    set tempunit = null
endfunction
The unit don't cast the chain lighting and stay forever in the map...
 
Level 4
Joined
Nov 25, 2008
Messages
76
Ah yeah DisplayTextToForce is not a good way to display text. You can use
JASS:
DisplayTextToPlayer(GetLocalPlayer())
for the same thing for more efficiency.

Also check if the unit can actually *cast* the ability. Make sure that the ability is added to the unit you want. I had cases when the exact same thing happened to me... Hope this helps

Edit: I'm not quite sure but I believe
JASS:
GetRectCenter
leaks. You could assign it to a local variable then remove the location in the end.
 
Level 12
Joined
Mar 23, 2008
Messages
942
About leaks and performance, Its just a test to see the damage of a chain lighting on my unit, don't need to be perfect.

The message shows, also shows that unit took 0 damage, the dummy caster is created, I took control over him and I can cast manually the chain lighting, also, I tried preloading the unit... Nothing worked.

Also, the unit don't have the expiration timer, why?

Edit: Uploaded the test map.
Ps: A cookie to anyone that kills saishy. (The isle in the down / right)

Edit2: Attach removed!
 
Last edited:
Level 4
Joined
Nov 25, 2008
Messages
76
I'm still noob at this so it might be way off,but I think its the GetLastCreatedUnit native that is making the problem here. Try doing something else with it. I tried to get the location (the x y z) of the dummycaster and print it on screen, it just printed all 0's. Also tried to issue a move order to it, wouldn't budge. It just seems the trigger cannot reach the dummy...
 
Level 14
Joined
Nov 23, 2008
Messages
187
Blah... I realized. You have used native CreateUnitAtLoc (not CreateUnitAtLocSaveLast), that's why GetLastCreatedUnit() returns null. I just wonder, how we didn't noticed that earlier...

So the right code would look like this:

JASS:
private function DamageType takes nothing returns nothing
  local group kunit = GetUnitsInRectAll(gg_rct_Region_000)
  local unit tempunit = FirstOfGroup(kunit)
  local unit dummy = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_AGGRESSIVE), 'n000', GetRectCenter(gg_rct_Region_001), 90)
  // --->>
  call DisplayTextToForce(GetPlayersAll(), "Casting a 100 damage chain lighting")
  call IssueTargetOrderBJ(dummy, "chainlightning", tempunit)
  call UnitApplyTimedLife(dummy, 'BTLF', 3)
  call FDamage()
  // <<---
  call DestroyGroup(kunit)
  set kunit = null
  set tempunit = null
  set dummy = null
endfunction
 
Status
Not open for further replies.
Top