HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simulating in-game error messages

02-18-2006, 04:13 PM#1
Immoralis
How do you easily simulate the yellow error messages like "Unit is already at full health" i dont know if this uses triggers or not.
02-18-2006, 04:14 PM#2
Panto
I remember coming across someone who made a jass function designed to perfectly replicate error messages.

I don't know where that was, but I'm sending you to the triggers forum.
02-18-2006, 04:18 PM#3
Zoxc
Collapse JASS:
function CS_Error takes player ForPlayer, string msg returns nothing
 local sound error=CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
    if (GetLocalPlayer() == ForPlayer) then
        if (msg!="") and (msg!=null) then
            call ClearTextMessages()
            call DisplayTimedTextToPlayer( ForPlayer, 0.52, -1.00, 2.00, "|cffffcc00"+msg+"|r" )
        endif
        call StartSound( error )
    endif
 call KillSoundWhenDone( error)
 set error=null
endfunction

This is from Vexorian's Caster System. The function is also know as 'SimError'.
02-18-2006, 04:19 PM#4
Vexorian
edit: this post had SimError on it.

Anyways if you are gonna use that function without the caster system, rename it to SimError
02-18-2006, 04:24 PM#5
Immoralis
excellent, how do i make it play when a certain item called "Arrows" has no charges left when the hero holding it is trying to ttack
02-18-2006, 05:06 PM#6
Naakaloh
It works like DisplayTextToPlayer(). I think if you have a trigger that detects the event "A unit is attacked" or something like that, you can stop the attacker before it fires, although I've never tried it so I don't know for sure.
02-19-2006, 01:29 AM#7
PerfectlyInsane
Currently I got a dozen triggers like that (basically stuff like stopping a car using a pizza to heal, or stopping a person driving a car from outside of the car, or stopping a person using a shotgun or pistol when they got no bullets)

Bascially you need to detect when a unit attacks OR uses an ability OR uses an item

and check the condition

In your case the number of charges you have on the item arrows, or whether or not the unit has the item arrows.

if if the unit has no arrows order unit to stop.

And display a message to PlayerGroup (Player (owner of triggering unit))

However I'm not sure if you can stop an attack this way. It might work
02-19-2006, 12:58 PM#8
Chuckle_Brother
Alright, in the trigger that detects lack of arrows:

Trigger:
Arrows
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
(Charges remaining in (Item carried by (Attacking unit) of type Arrows)) Equal to 0
Collapse Actions
Custom script: local string msg="No charges remain"
Custom script: local player ForPlayer=GetOwningPlayer(GetAttacker())
Custom script: call SimError(ForPlayer, msg)
//Do your cleanup
//Issue a stop order to the unit and all that

That SHOULD be correct, but I dunno. I might have missed something