• 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.

[Trigger] "Collective Gains" within XX Range

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2021
Messages
89
Alright you cool af dudes and dudettes (cause it sounded cool in my head).

I am working on a little something where i have a "repeatable" quest going, where it just resets when it is completed, all is well here and its working.

I have just run into a slight "multiplayer" problem, since the quest is slay XX amount of trolls, and i dont want to credit the one getting the killing blow only, but also i want to give "kill credit" to any Hero within 800 "range".

This is the current trigger i am using, and i have tried many versions of it, none that seem to work.

This is as close as i think i have come (it just returns the player number + 1 and i cannot think of why :| Ples help

  • TrollSlayerCounter
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Troll Hunter
          • (Unit-type of (Dying unit)) Equal to Troll Shaman
          • (Unit-type of (Dying unit)) Equal to Troll Chieftain
          • (Unit-type of (Dying unit)) Equal to Troll High Shaman
    • Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of (Dying unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Set VariableSet TrollSlayerCounter[(Player number of (Owner of (Picked unit)))] = (TrollSlayerCounter[(Player number of (Owner of (Picked unit)))] + 1)
              • Game - Display to (All players matching ((Matching player) Equal to (Owner of (Picked unit))).) the text: (You have slain + ((String(TrollSlayerCounter[(Player number of (Owner of (Picked unit)))])) + |cff008000Trolls|r))
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Yeah, that looks fine. The only issues are the memory leaks, if you care about those: Memory Leaks

You're leaking a Unit Group with your Pick Every Unit function and a Point with your (Position of (Dying unit)) function.

Additionally, you're checking if the Picked unit is a Hero, but you aren't checking to see if they're actually Alive. Dead heroes and Enemy heroes will be picked as well.
 
Level 5
Joined
Feb 5, 2021
Messages
89
Oh really, never thought about them making a leak! i will deffo check that out more specifically! :D

And thanks for the inputs, never thought about dead heroes and the occasionaly enemy hero! thanks a bunch! :D
 
Status
Not open for further replies.
Top