Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Triggers & Scripts (http://www.wc3c.net/forumdisplay.php?f=8)
-   -   Is it possible to check to see if... (http://www.wc3c.net/showthread.php?t=108789)

Sunwarrior25 01-22-2010 06:19 AM

Is it possible to check to see if...
 
...the target of an ability is a Unit or a Destructible (for single target spells), or would I have to do what TKoK did and make seperate abilities for each thing? (I'm trying to get one "Interact" ability for both functions).

Anachron 01-22-2010 08:02 AM

Here you go
Collapse JASS:
if GetSpellTargetDestructable() != null then
    
    elseif GetSpellTargetUnit() != null then
    
    endif

Sunwarrior25 01-22-2010 06:24 PM

Thank you! (Opens Notepad) :emote_thumbup:

EDIT: It's been several months since I've seen code like this... Should I start the trigger on a 'casts an ability' event or 'is issued an order targeting an object'?

Themerion 01-22-2010 07:05 PM

Starts effect of ability, unless you want to interrupt it before it's cast.

Sunwarrior25 01-22-2010 07:09 PM

Alright. Do I have to add anything in the parentheses in the code Anachron posted?

Themerion 01-22-2010 07:19 PM

Nope.

Sunwarrior25 01-22-2010 07:20 PM

Alright. Here's what I've got. Gonna test to see if it works:
Collapse JASS:
function Trig_Interact_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A600' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Interact_Actions takes nothing returns nothing

if GetSpellTargetDestructable() != null then

        call ConditionalTriggerExecute( gg_trg_DestCheck )

    elseif GetSpellTargetUnit() != null then

        call ConditionalTriggerExecute( gg_trg_UnitCheck )

    endif

endfunction

//===========================================================================
function InitTrig_Interact takes nothing returns nothing
    set gg_trg_Interact = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Interact, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Interact, Condition( function Trig_Interact_Conditions ) )
    call TriggerAddAction( gg_trg_Interact, function Trig_Interact_Actions )
endfunction

EDIT: It works, but the ability itself is checking to see if destructibles (like crates) are occupied by owls... What should I set the 'targets allowed' to?

EDIT2: Should I use Channel instead of Purge as a base?

Michael Peppers 01-22-2010 08:28 PM

Quote:

Originally Posted by Sunwarrior25
Alright. Here's what I've got. Gonna test to see if it works:
Collapse JASS:
function Trig_Interact_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A600' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Interact_Actions takes nothing returns nothing

if GetSpellTargetDestructable() != null then

        call ConditionalTriggerExecute( gg_trg_DestCheck )

    elseif GetSpellTargetUnit() != null then

        call ConditionalTriggerExecute( gg_trg_UnitCheck )

    endif

endfunction

//===========================================================================
function InitTrig_Interact takes nothing returns nothing
    set gg_trg_Interact = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Interact, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Interact, Condition( function Trig_Interact_Conditions ) )
    call TriggerAddAction( gg_trg_Interact, function Trig_Interact_Actions )
endfunction

EDIT: It works, but the ability itself is checking to see if destructibles (like crates) are occupied by owls... What should I set the 'targets allowed' to?

EDIT2: Should I use Channel instead of Purge as a base?


Uhm, can we see UnitCheck and DestCheck? :emote_wink:
Targets allowed should be: "Air, Land, Neutral, Ally, Alive, Mechanical unit, Friend, Organic, Object (and *maybe* Enemy)" (if I got what you mean)

Anyway...
Collapse JASS:
function Trig_Interact_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A600')
endfunction
It's better this way :emote_thumbup:

Sunwarrior25 01-22-2010 08:52 PM

1 Attachment(s)
DestCheck and UnitCheck are currently both GUI triggers with a debug message. I'll expand them later to have the loops/arrays and stuff that determine what messages/events the player gets by clicking on this or that unit. (Checking first for specific units/destructibles, and then for unit/destructible-type if the 'Interact' ability isn't used on any specific unit (and maybe finishing it off with a "..." message to the player if I forgot to add a unit/destructible-type to the list.))
Both of these GUI triggers are initially off.
Trigger:
Collapse DestCheck
Events
Conditions
Collapse Actions
Game - Display to (All players) the text: You are interacting...
Collapse UnitCheck
Events
Conditions
Collapse Actions
Game - Display to (All players) the text: You are talking to ...

EDIT: Like this? Attachment 47612
Collapse JASS:
function Trig_Interact_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A600')
endfunction

function Trig_Interact_Actions takes nothing returns nothing

if GetSpellTargetDestructable() != null then
        set udg_CheckDest = GetSpellTargetDestructable()
        call ConditionalTriggerExecute( gg_trg_DestCheck )

    elseif GetSpellTargetUnit() != null then
        set udg_CheckUnit = GetSpellTargetUnit()
        call ConditionalTriggerExecute( gg_trg_UnitCheck )

    endif

endfunction

//===========================================================================
function InitTrig_Interact takes nothing returns nothing
    set gg_trg_Interact = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Interact, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Interact, Condition( function Trig_Interact_Conditions ) )
    call TriggerAddAction( gg_trg_Interact, function Trig_Interact_Actions )
endfunction

Michael Peppers 01-22-2010 09:09 PM

Quote:

Originally Posted by Sunwarrior25
DestCheck and UnitCheck are currently both GUI triggers with a debug message. I'll expand them later to have the loops/arrays and stuff that determine what messages/events the player gets by clicking on this or that unit. (Checking first for specific units/destructibles, and then for unit/destructible-type if the 'Interact' ability isn't used on any specific unit (and maybe finishing it off with a "..." message to the player if I forgot to add a unit/destructible-type to the list.))
Both of these GUI triggers are initially off.
Trigger:
Collapse DestCheck
Events
Conditions
Collapse Actions
Game - Display to (All players) the text: You are interacting...
Collapse UnitCheck
Events
Conditions
Collapse Actions
Game - Display to (All players) the text: You are talking to ...


Ah, ok
Quote:

Originally Posted by Sunwarrior25
EDIT: Like this? Attachment 47612

Uhm... may bad, uncheck debris, check decoration, but maybe destructible interaction is simply hardcoded in some skills, gotta test.
Quote:

Originally Posted by Sunwarrior25
Collapse JASS:
function Trig_Interact_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A600')
endfunction

function Trig_Interact_Actions takes nothing returns nothing

if GetSpellTargetDestructable() != null then
        set udg_CheckDest = GetSpellTargetDestructable()
        call ConditionalTriggerExecute( gg_trg_DestCheck )

    elseif GetSpellTargetUnit() != null then
        set udg_CheckUnit = GetSpellTargetUnit()
        call ConditionalTriggerExecute( gg_trg_UnitCheck )

    endif

endfunction

//===========================================================================
function InitTrig_Interact takes nothing returns nothing
    set gg_trg_Interact = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Interact, Player(0), EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Interact, Condition( function Trig_Interact_Conditions ) )
    call TriggerAddAction( gg_trg_Interact, function Trig_Interact_Actions )
endfunction

Fine, also use TriggerExecute() instead of ConditionalTriggerExecute(), it's faster... well, unless you need conditions later on :emote_grin:

Sunwarrior25 01-22-2010 09:30 PM

1 Attachment(s)
Quote:

Uhm... may bad, uncheck debris, check decoration, but maybe destructible interaction is simply hardcoded in some skills, gotta test.
I would, but crates/cages/levers/gates are classified as "debris" by default (probably meaning they can be attacked), whereas the thrones (Frozen and King's), Rockin' Arthas, the Naga Ruins Circle, and the custom grass doodads I'm using are classified as decoration.
Quote:

also use TriggerExecute() instead of ConditionalTriggerExecute(), it's faster... well, unless you need conditions later on :emote_grin:
I will need conditions later on :emote_wink:

EDIT: Yeah, tested it ingame with "debris" checked...
Attachment 47614
That crate is neither a tree, nor does it contain an owl...

EDIT2: I am so totally going to add an easter egg of this when we finally get this working...

EDIT3: I was hoping it wouldn't come to this thought, but I may have to make a dummy unit for every destructible (not counting trees) in my map...

Michael Peppers 01-22-2010 10:03 PM

Quote:

Originally Posted by Sunwarrior25
EDIT: Yeah, tested it ingame with "debris" checked...
Attachment 47614
That crate is neither a tree, nor does it contain an owl...

EDIT2: I am so totally going to add an easter egg of this when we finally get this working...

EDIT3: I was hoping it wouldn't come to this thought, but I may have to make a dummy unit for every destructible (not counting trees) in my map...

Whoops, so with "owl" you meant... "owl" =D

Check tree... you may want to change base ability, then... maybe "Sentinel" would be the best base ability for it.

Sunwarrior25 01-22-2010 10:47 PM

1 Attachment(s)
Sentinel works!
... to a point: Attachment 47615
It now plays the "You are interacting..." message, but places an owl on that destructible. Trying to use the ability on the same destructible twice is a no-go due to an owl already being in that tree crate.

Michael Peppers 01-22-2010 11:02 PM

Quote:

Originally Posted by Sunwarrior25
Sentinel works!
... to a point: Attachment 47615
It now plays the "You are interacting..." message, but places an owl on that destructible. Trying to use the ability on the same destructible twice is a no-go due to an owl already being in that tree crate.

Erm... did you set the Owl number to 0? :emote_wink:

Sunwarrior25 01-22-2010 11:15 PM

Yes. I now have infinite owls.


All times are GMT. The time now is 04:13 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services