• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Odds and Ends questions

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
Just throwing a few questions out there.

1) If you Set r = udg_rect, and then later Call DestroyRect (r), will udg_rect also be destroyed?

2) Is it possible to increase a unit's max life using the SetUnitState command?

3) How do you activate the in-game text messages, such as "Not enough lumber" and "Cannot summon there"?

4) If you use the variable local group g (initially, but without "= CreateGroup ()"), but then an actual group is created only later in the trigger and when certain conditions are met, is it necessary to Call DestroyGroup (g) and set g = null when these conditions are NOT met? For example:

function
local group (g)
loca integer z = GetRandomInt (1, 2)
if z == 2 then
set g = CreateGroup ()
blah
blah
blah
call DestroyGroup (g)
endif
endfunction

In this case, if z = 1, no group is really created, so is it still necessary to destroy and null the group g?

5) What is the most efficient and leak-proof way to display a message to a single player?
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
1)The object it points to will be destroyed (so no leak).
2) No, but there is a system that lets you do that.
3) Dunno, but I guess you can find the sound files somewhere and then use them like any other sound.
4) No
5) call DisplayTextToPlayer(Player(X), 0., 0., "STRING")
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
1) yes

2) no, but you can use blade.dk's SetUnitMaxState function. Since wc3campaigns is down at the moment, you'll have to wait before getting it for a bit.

3) you don't. However, you can color your text yellow, change it's position on the screen, (with DisplayTextToPlayer) and play the error sound.

4) No, because the group isn't created otherwise.

5) DisplayTextToPlayer

Here's a little hint about that ;)

JASS:
native DisplayTextToPlayer          takes player toPlayer, real x, real y, string message returns nothing
function DisplayTextToForce takes force toForce, string message returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, message)
    endif
endfunction



EDIT: Blarg, griffen beat me to it


EDIT2: Here's the SimError function from (CasterSystem, I think)

JASS:
function SimulateError takes player p,string st returns nothing
    local sound s = CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
    if GetLocalPlayer() == p then
        if st !="" and st !=null then
            call DisplayTimedTextToPlayer(p,.52, -1,2,"|cffffcc00"+st+"|r")
        endif
        call StartSound(s)
    endif
    call KillSoundWhenDone(s)
    set s = null
endfunction
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Here's the SimError function from (CasterSystem, I think)

Not from CasterSystem.....

Isn't it named SimError? Not SimulateError.

I don't understand this line:

if st !="" and st !=null then

How can a string be null?

Can anyone explain me what do coordinate parameters do in DisplayTimedTextToPlayer?

Uhmm.....doesn't DisplayTimedTextToPlayer already do the GetLocatPlayer thing?
 
Status
Not open for further replies.
Top