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
508
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
508
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.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top