Getting the real TriggerUnit on the unit begins construction event.

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
For some reason, my trigger in response to a construction event wasn't firing, so I put some debug messages into the trigger. They both display the name of the structure that is being built, but the GetTriggerUnit() should display the unit building the structure. Does anyone have an idea on how to correct this? I've even tried this on the default builders of all the Warcraft III races, and it still says GetTriggerUnit() is the structure being built...

JASS:
private function Cond takes nothing returns boolean
    call BJDebugMsg("Cond Called")
    call BJDebugMsg("Name of GetConstructingStructure() == " + GetUnitName(GetConstructingStructure()))
    call BJDebugMsg("Name of TriggerUnit == " + GetUnitName(GetTriggerUnit()))
    
.
.
.
.


private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_CONSTRUCT_START)
    call TriggerAddCondition(t,Condition(function Cond))
    call TriggerAddAction(t,function Act)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
No it works for any worker which the race is different to human and undead.
So in most of case it's pretty useless, that's the reason why i don't submit it, but maybe it's enough for you.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
I see. I found a different way to solve my problem though. Thank you for the help though, the builder I'm using is based on human. I know a way you can make that system accurate for all builders, but it would be an inconvenient system that would require users to partially rewrite their map.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I see. I found a different way to solve my problem though. Thank you for the help though, the builder I'm using is based on human. I know a way you can make that system accurate for all builders, but it would be an inconvenient system that would require users to partially rewrite their map.
What is this way ?
I'm really curious how you handle it, i don't figure a way which can work 100 % of the time.
If you have done it and especially for human workers, then you did a very great job.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
here is a freehand framework of it, sorry for the indentation, I did the best I could. I used the Ivory Scout Tower because I only needed to build one structure. I made a tower relocation system for Faust, which allows you to root/uproot hero towers, but it puts them into a caravan unit instead of walking around, so that they can't attack/use abilities like this:

Because the unit entering map executes after the spell cast, you need to do all the actions you want on the map enter. This way of doing things perfectly records the builder and the building, and recycles the unit variables as a side benefit. The downside to doing things this way is it requires the user to remake all of their buildings into a copy of the Ivory Scout Tower, or similar item, one can be used for each race to detect race as well. The user then has to put them in a spellbook if they so desire. I'm not sure about wood/gold cost, the ability in this situation was free because it was used to relocate towers.
JASS:
library h initializer init
globals
     private unit BUILDER
     private unit BUILDING
endglobals


//this function executes AFTER the spellcast of the ivory scout tower!
//note, the ivory scout tower ability can produce ANY building to my knowledge.
//If made into a unit ability, you can put it in a "build" spellbook with a similar icon.
private function CreateCond takes nothing returns boolean
//here, I did a quick check to make sure the building was the correct type
if GetUnitTypeId(GetTriggerUnit()) == Whatever_ID then
     set BUILDING = GetTriggerUnit() //it stores the building
     //I did all of my actions in the condition, as they were rather simple
endif
return false
endfunction

private function UnrootCond takes nothing returns boolean
     if GetSpellAbilityId() == IVORY_TOWER_ID then
          set BUILDER = GetTriggerUnit() //or this_id or that_id type thing
endfunction

private function init takes nothing returns nothing
local trigger t = CreateTrigger()
    call TriggerRegisterEnterRectSimple(t, GetPlayableMapRect())
    call TriggerAddCondition(t,Condition(function CreateCond))
    
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function UnrootCond))
endfunction
 

SanKakU

Member
Reaction score
21
well for a human to have to check if the human is starting the effect of an ability and use repair...but for undead...i don't there is a way.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
well for a human to have to check if the human is starting the effect of an ability and use repair...but for undead...i don't there is a way.
Not really, humans peons can build together and there is no real way to know if a peon will build or is currently building, the only way i see is to check periodically if the peon have the same position and keep the current order "repair".
And i hate inaccurate lame things.

@Frozenhelfir : Will try your solution later.
But you keep all humans peons' characteristics ?
Basically they still can build together ?
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
@Troll-Brain: Not in this system. The building never finishes, it is just used to be replaced with a different one somewhere else on the map. I'm not sure how feasable this will be, the ivory items build the structure automatically... This would work for orc, undead, and nightelf, if its orc/NE, hide the worker inside the building, for UD, don't have to do anything. The only problem seems to come in with humans. For humans I would remove the building generated by the ivory skill, and then have a dummy unit start building it at that location, remove the dummy unit, order the unit that used the ivory to repair the new structure.
 

SanKakU

Member
Reaction score
21
well i don't understand but it sounds like you're saying you figured out how to do it for undead, and i figured out how to do it for human.

could you show me and i'll show you?

or wait a second...i'm not sure...what's the point of it all?

trying to tag the builder or the building? it's easy to tag the building right? with all races...but the builder...it can be difficult, right? i can tag the builder of human but i cannot for undead.

edit: actually i'm not sure i know how to tag night elf and orc workers...i thought i knew how but maybe i forgot...

anyways...like i said, how to do it with human:
Code:
debug2
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to (==) Repair (Human)
    Actions
        Unit - Kill (Triggering unit)//if that is too bloody for you, try this next one:
        Game - Display to (All players) the text: (Name of (Triggering unit))
        Game - Display to (All players) the text: A unit Starts the e...

edit: actually with ivory towers it might not be this simple, huh? hmm i hadn't realized all about all that. in fact, ivory towers act like summoned undead...so i think it might be impossible?!?!?
ok nevermind...it wasn't so hopeless...just change the condition to equal to the item ability you're using, like build tiny scout tower or whatever it is...lol
Code:
debug2
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to (==) Build Tiny Scout Tower 
    Actions
        Game - Display to (All players) the text: (Name of (Triggering unit))
        Game - Display to (All players) the text: A unit Starts the e...
eh, all that gui is ugly...this is it in jass...
JASS:
scope debug2 initializer I
private function A takes nothing returns nothing
if GetSpellAbilityId() == 'AIbt' then
call BJDebugMsg(GetUnitName(GetTriggerUnit()))
set udg_thebuilderisthisguy = GetTriggerUnit()
endif
endfunction

//===========================================================================
function I takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( t, function A )
endfunction

endscope


edit: oh i finally get it now...you are building with ivory tower type things but you are making orcs, night elves, humans all LOOK LIKE MELEE WORKERS rather than letting them look like undead workers, right? yeah well i think this is your solution, heh.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
This system wasn't intended to detect builders for melee settings. This was made to allow the relocation of towers while still maintaining the building footpring when placing them, rather than using the cross-hair that normally appears on spells. I'm just saying it could be used in a melee scenario if the map makers want to rewrite the map.

By using this, you can get the unit using the ability, and the unit that enters the map. So the builder and the building.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
@Sankaku : This kind of event fire with the ability repair ?
Did you try it or it's just a theory ?
 

SanKakU

Member
Reaction score
21
no, it's not a theory, it worked when solving another problem in another thread. furthermore i tested it with the ivory tower deal and it works perfectly.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Oh, nice. I was petty sure that you couldn't detect this ability like this, i was wrong.
I will try to find a way for undead so.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Undead should be the easiest, the ivory scout tower works exactly like the building summon.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Never said you should. I've said that I only needed to do this with one ability, and this was the easiest way to do it :) I also said early on that if you wanted to use this, the user would have to re-write their map.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top