Weird functions

Chocobo

White-Flower
Reaction score
409
I found some weird function in common.j of war3x.mpq. Can someone explain what they do?

PHP:
function TextTagSize2Height takes real size returns real
    return size * 0.023 / 10
endfunction

PHP:
function TextTagSpeed2Velocity takes real speed returns real
    return speed * 0.071 / 128
endfunction

PHP:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction

PHP:
function CameraSetEQNoiseForPlayer takes player whichPlayer,real magnitude returns nothing
    local real richter = magnitude
    if (richter > 5.0) then
        set richter = 5.0
    endif
    if (richter < 2.0) then
        set richter = 2.0
    endif
    if (GetLocalPlayer() == whichPlayer) then
        call CameraSetTargetNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true)
        call CameraSetSourceNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true)
    endif
endfunction
//Edit : To who don't know what is EQ, it is Earthquake.

PHP:
constant native ConvertLimitOp takes integer i returns limitop

PHP:
native CreateMIDISound takes string soundLabel,integer fadeInRate,integer fadeOutRate returns sound

PHP:
native CripplePlayer takes player whichPlayer,force toWhichPlayers,boolean flag returns nothing

PHP:
native GetLocalizedString takes string source returns string

PHP:
function PerformStockUpdates takes nothing returns nothing
    local integer  pickedItemId
    local itemtype pickedItemType
    local integer  pickedItemLevel = 0
    local integer  allowedCombinations = 0
    local integer  iLevel
    set iLevel = 1
    loop
        if (bj_stockAllowedPermanent[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_PERMANENT
                set pickedItemLevel = iLevel
            endif
        endif
        if (bj_stockAllowedCharged[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_CHARGED
                set pickedItemLevel = iLevel
            endif
        endif
        if (bj_stockAllowedArtifact[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_ARTIFACT
                set pickedItemLevel = iLevel
            endif
        endif
        set iLevel = iLevel + 1
        exitwhen iLevel > bj_MAX_ITEM_LEVEL
    endloop
    if (allowedCombinations == 0) then
        return
    endif
    call UpdateEachStockBuilding(pickedItemType, pickedItemLevel)
endfunction

PHP:
function StartSoundForPlayerBJ takes player whichPlayer,sound soundHandle returns nothing
    if (whichPlayer == GetLocalPlayer()) then
        call StartSound(soundHandle)
    endif
endfunction

PHP:
native VersionGet takes nothing returns version

PHP:
native VersionSupported takes version whichVersion returns boolean

PHP:
function WaitTransmissionDuration takes sound soundHandle,integer timeType,real timeVal returns nothing
    if (timeType == bj_TIMETYPE_SET) then
        call TriggerSleepAction(timeVal)
    elseif (soundHandle == null) then
        call TriggerSleepAction(bj_NOTHING_SOUND_DURATION)
    elseif (timeType == bj_TIMETYPE_SUB) then
        call WaitForSoundBJ(soundHandle, timeVal)
    elseif (timeType == bj_TIMETYPE_ADD) then
        call WaitForSoundBJ(soundHandle, 0)
        call TriggerSleepAction(timeVal)
    else
    endif
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
PHP:
function TextTagSize2Height takes real size returns real
    return size * 0.023 / 10
endfunction
BJ function, returns the pre set height a texttag with the size 'size' should use.


PHP:
function TextTagSpeed2Velocity takes real speed returns real
    return speed * 0.071 / 128
endfunction
Same as above but for the speed isnteed. Both these functions just make some easy math as you can see.


PHP:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction
Posts a message to all players, with pre set duration.

PHP:
function CameraSetEQNoiseForPlayer takes player whichPlayer,real magnitude returns nothing
    local real richter = magnitude
    if (richter > 5.0) then
        set richter = 5.0
    endif
    if (richter < 2.0) then
        set richter = 2.0
    endif
    if (GetLocalPlayer() == whichPlayer) then
        call CameraSetTargetNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true)
        call CameraSetSourceNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true)
    endif
endfunction
//Edit : To who don't know what is EQ, it is Earthquake.
Chakes the camera for a player.

PHP:
constant native ConvertLimitOp takes integer i returns limitop
Convert an integer to one of blizzards types that is only used as parameters.

PHP:
native CreateMIDISound takes string soundLabel,integer fadeInRate,integer fadeOutRate returns sound
Creates an sound from a label ^^

PHP:
native CripplePlayer takes player whichPlayer,force toWhichPlayers,boolean flag returns nothing
Probably dissable the control for a player, test it yourself.

PHP:
native GetLocalizedString takes string source returns string
Dunno.

PHP:
function PerformStockUpdates takes nothing returns nothing
    local integer  pickedItemId
    local itemtype pickedItemType
    local integer  pickedItemLevel = 0
    local integer  allowedCombinations = 0
    local integer  iLevel
    set iLevel = 1
    loop
        if (bj_stockAllowedPermanent[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_PERMANENT
                set pickedItemLevel = iLevel
            endif
        endif
        if (bj_stockAllowedCharged[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_CHARGED
                set pickedItemLevel = iLevel
            endif
        endif
        if (bj_stockAllowedArtifact[iLevel]) then
            set allowedCombinations = allowedCombinations + 1
            if (GetRandomInt(1, allowedCombinations) == 1) then
                set pickedItemType = ITEM_TYPE_ARTIFACT
                set pickedItemLevel = iLevel
            endif
        endif
        set iLevel = iLevel + 1
        exitwhen iLevel > bj_MAX_ITEM_LEVEL
    endloop
    if (allowedCombinations == 0) then
        return
    endif
    call UpdateEachStockBuilding(pickedItemType, pickedItemLevel)
endfunction
Probably something with the shops in wc3.

PHP:
function StartSoundForPlayerBJ takes player whichPlayer,sound soundHandle returns nothing
    if (whichPlayer == GetLocalPlayer()) then
        call StartSound(soundHandle)
    endif
endfunction
Plays a sound for a player.

PHP:
native VersionGet takes nothing returns version
Returns the version, dunno what version or what you use this for. Probably some blizzard use only function.

PHP:
native VersionSupported takes version whichVersion returns boolean
Something close to the thing above.

PHP:
function WaitTransmissionDuration takes sound soundHandle,integer timeType,real timeVal returns nothing
    if (timeType == bj_TIMETYPE_SET) then
        call TriggerSleepAction(timeVal)
    elseif (soundHandle == null) then
        call TriggerSleepAction(bj_NOTHING_SOUND_DURATION)
    elseif (timeType == bj_TIMETYPE_SUB) then
        call WaitForSoundBJ(soundHandle, timeVal)
    elseif (timeType == bj_TIMETYPE_ADD) then
        call WaitForSoundBJ(soundHandle, 0)
        call TriggerSleepAction(timeVal)
    else
    endif
endfunction
This is used with the 'play sound' bj, it waits eaither a set amount of time or until the sound is compleated or both.

The only functions Ive used when Ive coded is BJDebugMsg and StartSoundForPlayerBJ.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> CripplePlayer

I would guess this is the "you will be revealed unless", as seen in melee games.
Or, at least, some part of it.

> GetLocalizedString

Reads strings from, for example, the game interface.
Useful for international games. Or modified "quest" menus...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top