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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top