HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger Add Action

01-18-2005, 09:31 AM#1
iNfraNe
Code:
TriggerRegisterUnitInRange takes trigger whichTrigger, unit whichUnit, real range, boolexpr filter returns event

This function will take a variable for adding a unit to this. When the variable of the unit changes, the event will stay the same, meaning it will run when the "old" value of the variable is come in range.

now for my problem, I want
Code:
TriggerAddAction takes trigger whichTrigger, code actionFunc returns triggeraction
to keep the variable like the Event does. Is there any way of doing this?
01-18-2005, 01:24 PM#2
PitzerMike
I'm afraind your question didn't make much sense.

TriggerAddAction doesn't take any units as variables, so I don't see how a different unit in the event would have influnce on the trigger action.

As to the trigger action added: it will stay the same anyway.
01-18-2005, 01:37 PM#3
iNfraNe
Well.. Its kinda hard 2 explain... I try to let u know what I am trying to make. I am trying to make a triggered land mine (yes I know about the mine ability, but I WANT to make it triggered)

So, the problem is, there is not "Unit being come in range" event (need that to kill the mine, cause its stupid killing only the unit, and leaving the mine intact). So I thought, I'll just make a trigger for each unit, but then I noticed Add Action didnt work the same way Event did (like I tried 2 explain abit). So... u have any idea on how to make this (without picking all units in range, cuz that sux)
01-18-2005, 01:52 PM#4
PitzerMike
You could use the event
Your Mine - notices a target in range / acquires a target

Set the aquisition range of the mine to the desired radius.
01-18-2005, 02:01 PM#5
iNfraNe
then triggering unit refers to the mine? (and nothing refers to the unit coming within notice Iguess?) Good way btw, didnt think of that, but... aint there a way with AddAction? or is it just impossible using the way I thought of...
01-18-2005, 02:17 PM#6
PitzerMike
I think you misunderstood the concept of TriggerAddAction.
It doesn't register any events, it just points to the function that will be executed, wehn the event fires.

And yes, Triggering Unit will refer to the mine unit.
GetEventTargetUnit might refer to the unit comming in range, but I'm not sure.
01-18-2005, 02:27 PM#7
iNfraNe
I know addaction doesnt register an event -.- I said LIKE that function. Add event can take a variable of a unit, but when the variable itself changes after u add the event the event ITSELF DOESNT change.
Seeing addaction works different, which we have been repeating for 4 times now, I wondered if there was a way around it.

I wanted 2 do something like this.

Unit casts a spell

spell = minedrop

actions:

set temppoint = targetloc
unit create a mine @ targetloc
removeloc targetloc
trigg = createtrigger
triggeraddevent unit comes in range of last created unit
triggeraddaction kill last created unit

maybe u understand now? :\
01-18-2005, 02:40 PM#8
PitzerMike
Sure, you can create triggers dynamically. To attach a unit to a trigger I'd return-bug-cast the trigger to an integer and store the unit under that Id using the local handle functions. But I guess that's a bit too advanced.

You don't need to do that anyway, as the TriggeringUnit will refer to the mine, so just use that instead.
01-18-2005, 02:44 PM#9
iNfraNe
Quote:
Originally Posted by PitzerMike
Sure, you can create triggers dynamically. To attach a unit to a trigger I'd return-bug-cast the trigger to an integer and store the unit under that Id using the local handle functions. But I guess that's a bit too advanced.

You don't need to do that anyway, as the TriggeringUnit will refer to the mine, so just use that instead.
im not really interested on how to make the mine work. I wanna know about how to add actions that work like I said.
You'd returnbugcast the trigger...? :P

something like

function T2I takes trigger t returns integer
return t
return 0
endfunction

? what would that do :P I know jass enough to understand it if you'll explain what u mean youknow. I know u think im noob cuz I explained it bad, but im not ;)
01-18-2005, 02:59 PM#10
PitzerMike
ok let me explain it. As you already suggested we would create a trigger on the fly like:

local trigger T = CreateTrigger()
call TriggerRegisterEvent .... blah
call TriggerAddAction(T,function MyActionHandler)
call StoreInteger(udg_some_gamecache_var, "MineUnits", I2S(H2I(T)), H2I(Mine_Unit))

Now let's look at the action handler function:
Code:
function MyActionHandler takes nothing returns nothing
  local unit Mine = I2U(GetStoredInteger(udg_some_gamecache_var, "MineUnits", I2S(H2I(GetTriggeringTrigger()) ))
  ... now do whatever you want with your Mine unit
endfunction

As you see the trigger handle is used as a part of the hash-string and via the handle of the triggering trigger you can later get back the reference to the stored unit.
For more information on game-cache and return bug exploiting you can also check out the important threads thread.
And yes, this also works in multiplayer, just don't ever save the game cache, this way it will stay in memory.

EDIT: oh and sorry for thinking you were a newbie, I just hadn't seen you posting in the ai/jass forum before, that's why
01-18-2005, 03:19 PM#11
iNfraNe
Ahhh game cache ^_^

Still not REALLY how I was thinking of doing it, but I guess my way was a lil stupid. Thx for help.

btw, np for thinking im noob :P I post very much @ trigger forum and love 2 help noobs myself :P