I messed this trigger up.

Exide

I am amazingly focused right now!
Reaction score
448
As the title says, I messed this one up. :p

Probably some condition or something responsible.
I have this GUI trigger; and tried to optimize it a little:

Code:
Crabs Killed Copy
    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Giant Seacrab
        Or - Any (Conditions) are true
            Conditions
                (Owner of (Killing unit)) Equal to Player 1 (Red)
                (Owner of (Killing unit)) Equal to Player 2 (Blue)
                (Owner of (Killing unit)) Equal to Player 3 (Teal)
                (Owner of (Killing unit)) Equal to Player 4 (Purple)
                (Owner of (Killing unit)) Equal to Player 5 (Yellow)
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Death_Counter Equal to 9
            Then - Actions
                Set Quest_Hero = (Killing unit)
                Set Location = (Center of Andrew Lumber <gen>)
                Unit - Order Andrew (Jones' Nephew) 0008 <gen> to Move To Location
                Custom script:   call RemoveLocation(udg_Location)
                Trigger - Turn off Crabs Respawn <gen>
                Trigger - Turn off (This trigger)
                Skip remaining actions
            Else - Actions
        Set Death_Counter = (Death_Counter + 1)
        Game - Display to All_Players for 3.00 seconds the text: <Empty String>
        Game - Display to All_Players for 3.00 seconds the text: ((|cff32cd32 + (String(Death_Counter))) + /10 crabs killed!|r)

The idea is to tell the players how many crabs they've killed, and when they killed 10 the trigger turns itself off, and runs another trigger instead.
This one works, but the following doesn't. Again, I think I removed a condition or something too many, somewhere:

JASS:

function Trig_Crabs_Killed_Func006C takes nothing returns boolean
    local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    return id&lt;5
endfunction

function Trig_Crabs_Killed_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039; ) ) then
        return false
    endif
    if ( not Trig_Crabs_Killed_Func006C() ) then
        return false
    endif
    return true
endfunction

function Trig_Crabs_Killed_Actions takes nothing returns nothing
    local location loc = GetRectCenter(gg_rct_Andrew_Lumber)
    if ( (udg_Death_Counter &gt;= 9) ) then
        set udg_Quest_Hero = GetKillingUnit()
        set udg_Location = GetRectCenter(gg_rct_Andrew_Lumber)
        call IssuePointOrderLocBJ( gg_unit_h005_0008, &quot;move&quot;, loc )
        call DisableTrigger( gg_trg_Crabs_Respawn )
        call DisableTrigger( GetTriggeringTrigger() )
        return
    endif
    call RemoveLocation(loc)
    set loc = null
    set udg_Death_Counter = ( udg_Death_Counter + 1 )
    call DisplayTimedTextToForce( udg_All_Players, 3.00, &quot; &quot; )
    call DisplayTimedTextToForce( udg_All_Players, 3.00, ( ( &quot;|cff32cd32&quot; + I2S(udg_Death_Counter) ) + &quot;/10 crabs killed!|r&quot; ) )
endfunction

//===========================================================================
function InitTrig_Crabs_Killed takes nothing returns nothing
    set gg_trg_Crabs_Killed = CreateTrigger(  )
    call DisableTrigger( gg_trg_Crabs_Killed )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Crabs_Killed, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Crabs_Killed, Condition( function Trig_Crabs_Killed_Conditions ) )
    call TriggerAddAction( gg_trg_Crabs_Killed, function Trig_Crabs_Killed_Actions )
endfunction


Any ideas?
Help appriciated. :)
Thank you.
 
V

Vesper

Guest
You have to use the 'and' operator in the "Crabs Killed" function.

local player id = GetOwningPlayer(GetTriggerUnit())
return (id != Player(0)) and (id != Player(1)) and ...

etc.


Is this trigger supposed the be disabled? Remove the "call DisableTrigger(gg_trg_Crabs_Killed)" line.

Replace "IssuePointOrderLocBJ" with "IssuePointOrderLoc". The parameters stay the same.

Also, because you're using a local location already, remove the global variable You used to use earlier.
 

Exide

I am amazingly focused right now!
Reaction score
448
JASS:

function Trig_Crabs_Killed_Func006C takes nothing returns boolean
    local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    return id&lt;5
endfunction


That thing isn't mine. :p
Someone else told me to use that instead of 5 different If / Then functions.. I trust it works?
It seems to be working in another trigger as well, so I believe it does.
Yea, the trigger is supposed to be disabled, another trigger enables it.

EDIT: I solved it! :)
The problem was another condition:

JASS:

function Trig_Crabs_Killed_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039; ) ) then
        return false
    endif
    if ( not Trig_Crabs_Killed_Func006C() ) then
        return false
    endif
    return true
endfunction


This is what it looks like now:

JASS:

function Trig_Crabs_Killed_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039; ) ) then
        return false
    endif
    if ( Trig_Crabs_Killed_Func006C() ) then
        return true
    endif
    return true
endfunction


I believe it got backwards, somehow..
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
You should use if cond and cond instead.

Also, you're code is confusing, the nots are what makes it confusing.
 

Exide

I am amazingly focused right now!
Reaction score
448
I agree, but that's the way WE converts it from GUI to JASS, and it works so why change it.
On top of it, changing it would only switch the place of true and false, plus removing 'not'.

What about using and conditions?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
To optimize it and make it look more user-friendly, especially to yourself. :p

You should do this:
JASS:
function Trig_Crab_Killed_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039; and Trig_Crabs_Killed_Func006C() 
endfunction


It is much more better. :D
 

Exide

I am amazingly focused right now!
Reaction score
448
It sure looks nice, but does it work? :p
Oh and did you ever think of changing your avatar? That Peanut-butter-jellytime banana dude drives me crazy. :p

Oh, and thank you. :)

EDIT: Actually, that function doesn't on the same reason that "I messed it up myself", earlier:

JASS:

function Trig_Crabs_Killed_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039;
    return Trig_Crabs_Killed_Func006C()
endfunction


Works, though. For some weird reason..
 

substance

New Member
Reaction score
34
JASS:

function Trig_Crabs_Killed_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039;
    return Trig_Crabs_Killed_Func006C()
endfunction


Works, though. For some weird reason..

It appears to work because it only runs the first line. You dont need two seperate conditions, just put them together.
JASS:
function Trig_Crabs_Killed_Conditions takes nothing returns boolean
 return GetPlayerId(GetOwningPlayer(GetTriggerUnit())) &lt; 5 and GetUnitTypeId(GetDyingUnit()) == &#039;n003&#039;
endfunction
I think you need to go back to the basics and study other peices of code, you seem to be repeating the same questions in every thread and not fully understanding the answers.
 

Exide

I am amazingly focused right now!
Reaction score
448
These are the basics for me. :p

As I said earlier, and does not work, so why bring it up again?
 

substance

New Member
Reaction score
34
'and' works.

If you're a noob don't ask for help from people that know what they're doing and then say that they're wrong.
 

Exide

I am amazingly focused right now!
Reaction score
448
Well, I did it the way you adviced me to and it didn't work. So I had to figure it out myself.
You can't say that it works then, huh?
 

Sooda

Diversity enchants
Reaction score
318
> I have this GUI trigger; and tried to optimize it a little.

Isn' t that good idea at all, you are doing twice as much work when you could just write it yourself from start like you want it to look in the end.

> I agree, but that's the way WE converts it from GUI to JASS, and it works so why change it.

Because it just sucks ? If you don' t understand how to optimize you will never be able to create better code than GUI already does.
 

Exide

I am amazingly focused right now!
Reaction score
448
>Isn' t that good idea at all, you are doing twice as much work when you could just write it yourself from start like you want it to look in the end.

Well, yes, but I recently "learned" (still learning) how to make triggers in JASS, and I had the trigger in GUI. So.. I sort of already had it. :p

>Because it just sucks ?

How come it sucks? What sucks and what to improve? -Would probably be a better reply.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>How come it sucks? What sucks and what to improve?
yeah it really sucks...

i will gave an example here:
JASS:
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hfoo&#039; ) ) then
        return false
    endif
    return true
endfunction


above is teh gui > jass condition

JASS:
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == &#039;hfoo&#039;
endfunction

this is my condition...what is the diff?

and... Exide u know what is the if/then/else in GUI right?

if u use that function in GUI then convert it to Jass....u will found out that it creates a function for each condition.....but it is no need for it...we could just type our condition after the IF instead of keep on creating a small function for each condition...

see this example:
JASS:
function Trig_Untitled_Trigger_001_Func001C takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hfoo&#039; ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hkni&#039; ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hrif&#039; ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hmtm&#039; ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hgyr&#039; ) ) then
        return false
    endif
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;hgry&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    if ( Trig_Untitled_Trigger_001_Func001C() ) then
    else
    endif
endfunction


it could be simplified to:
JASS:
function Trig_Untitled_Trigger_001_Func001C takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == &#039;hfoo&#039; and GetUnitTypeId(GetTriggerUnit()) == &#039;hfni&#039; and GetUnitTypeId(GetTriggerUnit()) == &#039;hrif&#039; and GetUnitTypeId(GetTriggerUnit()) == &#039;hmtm&#039; and  GetUnitTypeId(GetTriggerUnit()) == &#039;hqvr&#039; and GetUnitTypeId(GetTriggerUnit()) == &#039;hqrv&#039;
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    if ( Trig_Untitled_Trigger_001_Func001C() ) then
    else
    endif
endfunction


note that these trigger are just for explaination...it contains error in it... xP
 

substance

New Member
Reaction score
34
Well, I did it the way you adviced me to and it didn't work. So I had to figure it out myself.
You can't say that it works then, huh?

That's my point, if you knew the basics you'd understand that 'and' works but my code had a tiny syntax error ( missing ')' ). But you dont understand the basics so all you did was copy the code and put it in your map and then see that there was a error in the compile. You didnt try to indentify the problem or check for syntax erros you just simply thought 'well that way doesnt work'.

I explained how to get these conditons down to one line about 3 days ago which was your first (of now 3) threads about this ability in which you took the same appraoch of copying to see if it worked.
 

Exide

I am amazingly focused right now!
Reaction score
448
Thanks, Gals.

@substance, um.. ( missing ')' ) ??
I'm not sure what it is that you don't understand in:

JASS:

function Trig_Crabs_Killed_Func006C takes nothing returns boolean
    local integer id = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
    return id&lt;5
endfunction


As I said, this is how I used to have it, and it was answering to 'Event A unit Dies'. I then changed it to:

JASS:

    local integer id = GetPlayerId(GetOwningPlayer(GetKillinUnit()))


I'll explain this to you: Triggering unit in this case is the same as Dying unit, which is wrong. -This is why the trigger didn't work. Again, I changed it and now it does work. Get it?
 

SerraAvenger

Cuz I can
Reaction score
234
Code:
function Trig_Crabs_Killed_Conditions takes nothing returns boolean
  if ( not ( GetUnitTypeId(GetDyingUnit()) == 'n003' ) ) then
    return false
  endif  
  if ( Trig_Crabs_Killed_Func006C() ) then
    return true
  endif
  return true 
endfunction
...

That's the same as

Code:
function Trig_Crabs_Killed_Conditions takes nothing returns boolean
  if ( not ( GetUnitTypeId(GetDyingUnit()) == 'n003' ) ) then
    return false
  endif  
  return true 
endfunction


local boolean a
If a then
return true
else
return true

Well I'ld say that you can simply change that to
"return true"


Greets Davey

P.S.: I agree to sub.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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

      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