HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can this be done more efficiently?

07-10-2008, 07:52 PM#1
crayz
Trigger:
Unit Group - Pick every unit in (Units within 2000.00 of (Position of (Dying unit))) and do (Actions)
Collapse Loop - Actions
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Owner of (Picked unit)) Equal to (Player((Integer A)))
Collapse Then - Actions
Hero - Make (Picked player) Heroes gain ((Real(expRate)) / (Real((Number of units in (Units within 2000.00 of (Position of (Dying unit)) matching ((Owner of (Matching unit)) Equal to (Player((Integer A)))))))))% experience from future kills
Else - Actions

Does anyone know if this would leak, or break anywhere?

Thanks!
07-10-2008, 08:00 PM#2
the-thingy
You're leaking a point - Position of (Dying Unit)
You're leaking a group - Units in range of (Position of (Dying Unit))

And there isn't a Picked Player, use Owner of (Picked Unit)
07-10-2008, 08:08 PM#3
crayz
Quote:
Originally Posted by the-thingy
You're leaking a point - Position of (Dying Unit)
You're leaking a group - Units in range of (Position of (Dying Unit))

And there isn't a Picked Player, use Owner of (Picked Unit)

Would this work fine?

Trigger:
Shared Experience
Collapse Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
Collapse Actions
Custom script: local location udg_tempPoint
Set tempPoint = (Position of (Dying unit))
Collapse Unit Group - Pick every unit in (Units within 2000.00 of tempPoint) and do (Actions)
Collapse Loop - Actions
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Owner of (Picked unit)) Equal to (Player((Integer A)))
Collapse Then - Actions
Hero - Make (Owner of (Picked unit)) Heroes gain ((Real(expRate)) / (Real((Number of units in (Units within 2000.00 of tempPoint matching ((Owner of (Matching unit)) Equal to (Player((Integer A)))))))))% experience from future kills
Else - Actions
Custom script: set udg_tempPoint = null


Oh, about the 'Picked Player', I accidently copied the code after forgetting I rearranged it a little bit more :X
07-10-2008, 08:17 PM#4
Anopob
You still need a variable for that group (Units within 2000.00 of tempPoint).
07-10-2008, 08:36 PM#5
the-thingy
1) You don't need to localize the variable.

2) Why are you increasing the EXP rate? Shouldn't you be adding EXP to the heroes?

3) You're still leaking the point. You have to do call RemoveLocation (udg_tempPoint)
07-10-2008, 10:02 PM#6
Themerion
Quote:
Originally Posted by Anopob
You still need a variable for that group (Units within 2000.00 of tempPoint).

No, he doesn't. He can just do this before creating the group:

Trigger:
Custom Script: set bj_wantDestroyGroup=true
07-10-2008, 11:08 PM#7
Anitarf
What are you attempting to achieve anyway? The trigger is confusing.
07-10-2008, 11:49 PM#8
SeruK
Yeah, that's even messier than my shit. Just what do you want to do?
07-11-2008, 08:34 AM#9
the-thingy
Quote:
Originally Posted by SeruK
Yeah, that's even messier than my shit. Just what do you want to do?
I think it's meant to be triggered EXP gain (can't see why he would want to increase the EXP rate for all player-owned heroes for every kill)