(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > JASS Functions

JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 03-21-2008, 10:50 AM   #1 (permalink)
 
Captain Griffen's Avatar

******
 
Join Date: Nov 2005
Posts: 747

Captain Griffen is a jewel in the rough (241)Captain Griffen is a jewel in the rough (241)Captain Griffen is a jewel in the rough (241)Captain Griffen is a jewel in the rough (241)


[vJASS] CG's Music System

Music is, to put it bluntly, a bit messed up and tricky to work in WC3. So here's my music system, taken out of Destiny's Wake (with a few alterations, mainly taking out the need for Vex's CS safety). Obviously it still needs vJASS. Will store where it is in the track

library MusicSystem initializer Setup_Music

globals
    private string current = null
    private timer t
    constant string FIGHT_MUSIC = "3circles.mp3"
    constant string NORMAL_MUSIC = "Medieval.mp3"
    private real fightTime = 0.
    private real normalTime = 0.
endglobals

// These must have the data of the various songs you use.
private function SetMusicRestart takes string s returns nothing
    if s == FIGHT_MUSIC then
        set fightTime = ModuloReal(fightTime + TimerGetElapsed(t), 620.)

    elseif s == NORMAL_MUSIC then
        set normalTime = ModuloReal(normalTime + TimerGetElapsed(t), 245.)

    endif
endfunction

// This must have the correct returns for the various songs you use.
private function GetMusicRestart takes string s returns real
    if s == FIGHT_MUSIC then
        return fightTime
    elseif s == NORMAL_MUSIC then
        return normalTime
    else
        return 0.
    endif
endfunction

private function StartMusicEx takes nothing returns nothing
    call StopMusic(false)
    if current != null then
        call PlayMusic(current)
        call SetMusicPlayPosition( R2I( GetMusicRestart(current)*1000 ) )
        call TimerStart(t, 99999., false, null)
    endif
    call DestroyTimer(GetExpiredTimer())
endfunction

function StartMusic takes string s returns nothing
    call ClearMapMusic()
    if s != null then
        call SetMapMusic(s, false, 0)
    endif
    if current != null then
        call StopMusic(true)
        call SetMusicRestart(current)
        if s != null then
            call TimerStart(CreateTimer(), 2., false, function StartMusicEx) // This time is to allow time for fade out. Reduce it to make the new music come in faster.
        endif
    else
        call StopMusic(false)
        if s != null then
            call PlayMusic(s)
            call SetMusicPlayPosition( R2I( GetMusicRestart(s)*1000 ) )
            call TimerStart(t, 99999., false, null)
        endif
    endif
    set current = s
endfunction

private function Setup_Music takes nothing returns nothing
    set t = CreateTimer()
endfunction

endlibrary

How to use it? Quite simple. Set up the two functions which I've commented, and the necessary globals, and then whever you want to use it, do this:

    call StartMusic(NORMAL_MUSIC) //this will play the normal music variable
    call StartMusic(null) // This will stop the music
__________________
Quote:
[20-00-13] MasterHaosis: Because I am retarded douchebag
[20-15-23] MasterHaosis: I am faggot, retard and such..
[20-21-22] MasterHaosis: because I am chat moderator. And you dont have right to speak against me
~Void~: Knock it off, for fuck's sake. Get that bullshit out of your signature and stop being so immature. Let it die out.

Last edited by Captain Griffen; 03-22-2008 at 10:41 PM.. Reason: Made a couple of strings constant for inlining purposes.
Captain Griffen is offline  
Old 03-21-2008, 10:56 AM   #2 (permalink)
 
HappyTauren's Avatar

Banned
 
Join Date: Nov 2006
Posts: 6,459

HappyTauren has much of which to be proud (1015)HappyTauren has much of which to be proud (1015)HappyTauren has much of which to be proud (1015)HappyTauren has much of which to be proud (1015)HappyTauren has much of which to be proud (1015)HappyTauren has much of which to be proud (1015)


A very flawless code, I tested it and seems to play music much better than wc3 does (less lag when switching tracks, easier to work with.). Music has always been buggy to work with in wc3 :P
Now I no longer have to use sound variables for music. +LOVE
HappyTauren is offline  
Old 03-22-2008, 10:57 PM   #3 (permalink)
 
HINDYhat's Avatar

WRONG HOLE!
 
Join Date: Apr 2007
Posts: 1,022

HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)HINDYhat is a glorious beacon of light (587)

Super Donor: This user has donated at least $100 to The Hive. 

Seems to work great.


~Approved~

__________________
HINDYhat is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[vJass]VoteKick System Venks "Graveyard" 2 08-08-2008 08:37 AM
[vjass] ORTS - Orc_Tamer's Recipe System 2.0 Orc_Tamer "Graveyard" 7 08-01-2008 07:09 AM
[vJASS] CG's Transmission System Captain Griffen JASS Functions 6 04-05-2008 05:14 PM
Music - Play Music = Tiny lag when it goes off how to fix? LoDown Map Development 1 04-01-2005 01:45 AM
Rhiea's Art Now 2 Cg's presented! Lady_Rhiea Concept Art / Fan Art 24 09-04-2004 07:36 PM

All times are GMT. The time now is 07:46 AM.






Your link here 
Loan | Bad Credit Loan | Debt Consolidation | Remortgages | Xbox Mod Chip
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle