| 11-24-2007, 11:12 AM | #1 |
*edit* let me be a bit more straight forward.... JASS:function Trig_Collision_Conditions takes nothing returns boolean local unit u = GetTriggerUnit() if ( not ( GetUnitTypeId(u) != 'Hpal' ) ) then set u = null return false endif return true endfunction function Trig_Collision_Actions takes nothing returns nothing endfunction function InitTrig_Collision takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0000) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0001) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0002) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0003) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0004) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0005) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0006) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0007) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0008) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0009) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0010) call TriggerRegisterUnitInRangeSimple(t,50.00,gg_unit_Hpal_0011) call TriggerAddCondition(t,Condition( function Trig_Collision_Conditions)) call TriggerAddAction(t,function Trig_Collision_Actions) endfunction this is how it looks at the moment. here are some events for that trigger. What I want is to know when a unit comes with in 50.00 of any of these units I want to register wich of these 12 units is the event. some thing like this: local unit E_un = dunno local unit T_un = GetTriggeringUnit() or if I could put more triggers in the same so that trig_1 register Unit_1 and does the following actions (would be horrible) |
| 11-24-2007, 11:18 AM | #2 |
The event will not be removed. You cannot remove it. Ever. Not in GUI, not in JASS. Events are permanent. That's not to say that the event will fire again, but it will sure as hell be there. And eventually a trigger with lots of events starts to build up some considerable lag. |
| 11-24-2007, 11:30 AM | #3 |
ok, could I replace this event with some thing else? |
| 11-24-2007, 11:44 AM | #4 |
You can reset triggers to their original states... it's an option somewhere in UMSWE which I don't currently have access to. |
| 11-24-2007, 11:54 AM | #5 |
I don't think call ResetTrigger(trigger) would work. I just recall reading a thread about the same thing, where someone said that doesn't work. |
| 11-24-2007, 12:12 PM | #6 | |
I'll try it.. *EDIT* Quote:
|
| 11-24-2007, 12:34 PM | #7 |
I'm fairly sure that it doesn't clear up the memory, though it's possible it may delink it. |
| 11-24-2007, 01:29 PM | #8 |
Best way to do this is to create a new trigger, and 'attach' the triggeraction to it, so you can remove the triggeraction when you're done with that trigger (you can't use TriggerClearActions I think... someone told me it leaks). Example: JASS:function TrueFilter takes nothing returns boolean return true // Use a filter that always returns true, to prevent leakage endfunction function SomeFunction takes nothing returns nothing local trigger t=GetTriggeringTrigger() call KillUnit(GetTriggerUnit()) call TriggerRemoveAction(t,GetAttachedTriggerAction(t,"triggeraction")) // Removing the triggeraction from this trigger call CleanAttachedVars(t) // Flushing the stored values call DestroyTrigger(t) // Fixin' leaks :P set t=null endfunction function YourFunc takes nothing returns nothing local trigger t=CreateTrigger() call TriggerRegisterUnitInRange(t,GetTriggerUnit(),300.0,Filter(function TrueFilter)) call AttachObject(t,"triggeraction",TriggerAddAction(t,function SomeFunction)) // Attaching the triggeraction to the created trigger set t=null endfunction Of course, that uses CS_Cache by Vexorian, but there are many other ways to attach variables to handles (DataSystem, ABC, HSAS). Have fun! |
| 11-24-2007, 01:57 PM | #9 |
Sry, didn't understan the filter.. |
| 11-24-2007, 01:59 PM | #10 |
That's all you didn't understand? I've heard the filters as null values leak, so you have to have a filter function that always returns true (so it will accept all units that come in range). |
| 11-24-2007, 02:19 PM | #11 | |
Quote:
So my; JASS:function Trig_Collision_Conditions takes nothing returns boolean local unit u = GetTriggerUnit() if ( not ( GetUnitTypeId(u) != 'Hpal' ) ) then set u = null return false endif return true endfunction would not work as a filter even though it only retunrs false at one conidition? *Does it always have to return true, because that makes no sence (for me). |
| 11-24-2007, 02:21 PM | #12 |
No, it doesn't always have to return true, I was just doing that in the example I posted, because I didn't know what you wanted... Just put whatever filter you want, but remember never to use 'null' filters, because they leak. That's all lawl. |
| 11-24-2007, 02:39 PM | #13 |
JASS:function Trig_Collision_Conditions takes nothing returns boolean return GetUnitTypeId(GetTriggerUnit()) != 'Hpal' endfunction |
| 11-24-2007, 02:49 PM | #14 | ||
Quote:
ok, but still the question is unanswered.
|
| 11-24-2007, 07:29 PM | #15 |
You'll need to make a trigger for each one. And DO NOT use and remove TriggerActions. They will fuck up the handle stack, as shown by Vexorian here. Instead, you can use a TriggerCondition and use ExecuteFunc to pass all arguments you want. You may then safely destroy the trigger when you're done with it like so: JASS:globals trigger array YourTriggers private unit array YourUnits private unit RangeUnit endglobals private function True takes nothing returns boolean return boolean endfunction function Collision_Actions takes nothing returns nothing call KillUnit(GetTriggerUnit()) call DestroyEffect(AddSpecialEffect("thunderclap.mdl", GetUnitX(RangeUnit), GetUnitY(RangeUnit))) //You would use RangeUnit to refer to the unit that the unit came in range of. endfunction function Collision_Conditions takes nothing returns boolean local trigger T = GetTriggeringTrigger() local integer I = 0 loop set I = I+1 exitwhen I > 12 if T == YourTriggers[i] then set RangeUnit = YourUnits[i] exitwhen true endif endloop call ExecuteFunc("Collision_Actions") set T = null return false endfunction function InitTrig_Collision takes nothing returns nothing local integer I = 0 set YourUnits[1] = gg_unit_Hpal_0000 set YourUnits[2] = gg_unit_Hpal_0001 set YourUnits[3] = gg_unit_Hpal_0002 set YourUnits[4] = gg_unit_Hpal_0003 set YourUnits[5] = gg_unit_Hpal_0004 set YourUnits[6] = gg_unit_Hpal_0005 set YourUnits[7] = gg_unit_Hpal_0006 set YourUnits[8] = gg_unit_Hpal_0007 set YourUnits[9] = gg_unit_Hpal_0008 set YourUnits[10] = gg_unit_Hpal_0009 set YourUnits[11] = gg_unit_Hpal_0010 set YourUnits[12] = gg_unit_Hpal_0011 loop set I = I+1 exitwhen I > 12 set YourTriggers[i] = CreateTrigger() call TriggerRegisterUnitInRange(YourTriggers[i], YourUnits[1], 50.00, Condition(function True)) call TriggerAddCondition(YourTriggers[i], Condition(function Collision_Conditions)) endloop endfunction |
