HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Custom warning messages or whatever they are called.

02-26-2006, 01:22 AM#1
Moss
Is there a way to trigger a custom message like the kind when you don't have enough gold or you try targetting an invalid object? I don't mean just customizing the gameplay interface messages, although I was thinking one possibility could be to use a spare message like "You must target an undead unit" or whatever, change it to something like "Potatoes are not a fruit" and trigger some action that displays that message. But triggering stuff generally doesn't produce those messages does it? Like if you order a dummy caster to do something dumb, it won't say "unable to target that you smeghead" will it?
02-26-2006, 01:25 AM#2
shadow1500
This question has been asked before, u shud use the search feature.
02-26-2006, 06:48 AM#3
Moss
Oops. So it has. I normally do search but for some reason I didn't with this one. The search feature doesn't do a very good job though. Well I learned about the DisplayTimedTextToPlayer function, looks very cool, good example of stuff you can do with JASS that you can't with GUI.

But this doesn't solve the larger problem I am having. I am basically trying to make a custom criteria for what units are targetable by a spell, so I want to cancel the spell if they are not targetable. I am making this message appear when the caster unit is issued an order, which is as soon as I can catch it right? And I am telling the unit to stop or cancel, but it still ends up doing the spell. It will cancel if the unit is out of range or out of mana, but if it can do it immediately it will. Is the only way to control it to trigger every aspect of the spell casting? (Mana usage, cooldown, using a dummy spell instead of directly casting)
02-26-2006, 06:23 PM#4
shadow1500
http://www.wc3campaigns.net/showthre...rning+messages
02-26-2006, 09:17 PM#5
TaintedReality
EVENT_UNIT_SPELL_CAST, EVENT_UNIT_SPELL_CHANNEL, EVENT_UNIT_SPELL_EFFECT, EVENT_UNIT_SPELL_ENDCAST, EVENT_UNIT_SPELL_FINISH are your choices.

Cast gets it before you pay the mana cost or cooldown starts(probly what you want), channel is useless, effect goes off right at the instant cooldown and mana cost go off, endcast goes when they're finished with the animation(i think), finish goes after channeling.

In GUI I think the event is Unit - Starts Casting a Spell or something like that.
02-26-2006, 10:01 PM#6
Anitarf
The problem is that the order event should happen before any spell events, and still it is not fast enough to prevent a unit from casting sometimes. I have a similar problem in my map, when I try to prevent heroes from casting any spells while still in the safe-zone, the problem is that while my trigger (which runs on the order event) stops them before the spell is cast, the mana for the spell is used up nonetheless. Wierd.
02-26-2006, 10:38 PM#7
shadow1500
Quote:
The problem is that the order event should happen before any spell events, and still it is not fast enough to prevent a unit from casting sometimes. I have a similar problem in my map, when I try to prevent heroes from casting any spells while still in the safe-zone, the problem is that while my trigger (which runs on the order event) stops them before the spell is cast, the mana for the spell is used up nonetheless. Wierd.
if the unit is ordered while inside the range (so he deoesnt need to move toward the target) then the Unit is issued an order event is going to activate after mana/cooldown activation, here is a trigger that u shud use for spell casting conditions:
Collapse JASS:
function CastConditionExample_Cond takes nothing returns boolean
    return GetSpellAbilityId()=='1234' or OrderId2String(GetIssuedOrderId())=="spellorder"
endfunction
function CastConditionExample takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t
    if GetTriggerEventId()==EVENT_PLAYER_UNIT_SPELL_CAST then
        set t = GetSpellTargetUnit()
    else
        set t = GetOrderTargetUnit()
    endif
    if not <casting condition goes here> then
        call PauseUnit(u,true)
        call IssueImmediateOrder(u,"stop")
        call PauseUnit(u,false)
        call ForceUIKeyBJ(GetOwningPlayer(u),<spell hotkey goes here>)
        // show error message here
    endif
endfunction
function InitCastConditionExample takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
    call TriggerAddCondition(t,Condition(function CastConditionExample_Cond))
    call TriggerAddAction(t,function CastConditionExample)
endfunction
02-27-2006, 12:57 AM#8
Moss
Hey thanks a lot shadow. At first I thought it wasn't working but on second try it seems to do the trick. So I guess it is important to have both those events and to pause the unit before doing the order?

This isn't a perfect solution though. Normally if a spell is given an invalid target the unit continues doing whatever they were doing, but this way they are stopped. You could get the order of what they were previously doing and re-order them instead of stopping them, but then you would also have to figure out if they are targeting a point or object as well, is it even possible to get target of a current order? And another problem would be if they are channeling another spell, you wouldn't want them to re-cast the channeling spell, you would want them to continue it uninterupted. Is that a possibility?