• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

rotating sun light

This bundle is marked as awaiting update. A staff member has requested changes to it before it can be approved.
In this map the sun/moon's light is rotating and is reflected on the terrain and the units.
Contents

rotating sun light (Map)

Reviews
Wrda
This needs at least JASS tag. The way to import this system is unacceptable as it not only requires MPQ edit, but also editing through war3map.j will make writing triggers, and the rest of the map pretty slow since saving in World Editor will...
Level 23
Joined
Apr 3, 2018
Messages
460
Very impressive and looks good in game.
Somehow no triggers or import show up in the editor but they are there if the map is opened with an MPQ editor.
It can be a bit difficult to import a spell if you can't see the triggers or the imported files. Can you add importing instructions to the resource description?

JASS:
globals
  integer chatCmdNargs = 0
  string array chatCmdArgs

  string array dncTs
  string array dncUs
  integer ndnc
endglobals

function print takes string s returns nothing
  call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.0, 0.0, 10.0, s)
endfunction

function chatCmdsTokenize takes string s returns nothing
  local integer ns = StringLength(s)
  local integer p = 0
  local integer start
  local string c
  set chatCmdNargs = 0
  loop
    loop
      set c = SubString(s, p, p + 1)
      exitwhen " " != c
      set p = p + 1
    endloop
    exitwhen "" == c

    set start = p
    loop
      set c = SubString(s, p, p + 1)
      exitwhen " " == c
      exitwhen "" == c
      set p = p + 1
    endloop

    set chatCmdArgs[chatCmdNargs] = SubString(s, start, p)
    set chatCmdNargs = chatCmdNargs + 1
  endloop
endfunction

function ccI takes integer idx returns integer
  return S2I(chatCmdArgs[idx])
endfunction

function ccF takes integer idx returns real
  return S2R(chatCmdArgs[idx])
endfunction

function ccS takes integer idx returns string
  return chatCmdArgs[idx]
endfunction

function chatCmdsDispatch takes nothing returns nothing
  local integer a = 0 - 1
  loop
    set a = a + 1
    exitwhen 16 == a
    set chatCmdArgs[a] = ""
  endloop
  call chatCmdsTokenize(GetEventPlayerChatString())
  call ExecuteFunc("onPlayerChatEvent")
endfunction

function chatCmdsInit takes nothing returns nothing
  local trigger t = CreateTrigger()
  call TriggerRegisterPlayerChatEvent(t, Player(0), "", false)
  call TriggerAddAction(t, function chatCmdsDispatch)
endfunction

function dncsInit takes nothing returns nothing
  set dncTs[0] = "Environment\\DNC\\DNCAshenvale\\DNCAshenValeTerrain\\DNCAshenValeTerrain.mdx"
  set dncTs[1] = "Environment\\DNC\\DNCDalaran\\DNCDalaranTerrain\\DNCDalaranTerrain.mdx"
  set dncTs[2] = "Environment\\DNC\\DNCDungeon\\DNCDungeonTerrain\\DNCDungeonTerrain.mdx"
  set dncTs[3] = "Environment\\DNC\\DNCFelwood\\DNCFelWoodTerrain\\DNCFelWoodTerrain.mdx"
  set dncTs[4] = "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdx"
  set dncTs[5] = "Environment\\DNC\\DNCUnderground\\DNCUndergroundTerrain\\DNCUndergroundTerrain.mdx"
  set dncTs[6] = "models\\dnctest_t.mdx"

  set dncUs[0] = "Environment\\DNC\\DNCAshenvale\\DNCAshenValeUnit\\DNCAshenValeUnit.mdx"
  set dncUs[1] = "Environment\\DNC\\DNCDalaran\\DNCDalaranUnit\\DNCDalaranUnit.mdx"
  set dncUs[2] = "Environment\\DNC\\DNCDungeon\\DNCDungeonUnit\\DNCDungeonUnit.mdx"
  set dncUs[3] = "Environment\\DNC\\DNCFelwood\\DNCFelWoodUnit\\DNCFelWoodUnit.mdx"
  set dncUs[4] = "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdx"
  set dncUs[5] = "Environment\\DNC\\DNCUnderground\\DNCUndergroundUnit\\DNCUndergroundUnit.mdx"
  set dncUs[6] = dncUs[4]

  set ndnc = 7
endfunction

function setDnc takes integer a returns nothing
  call SetDayNightModels(dncTs[a], dncUs[a])
endfunction

function setSun takes integer a returns nothing
  local string s = I2S(a)
  call SetDayNightModels("models\\dnc_t_" + s + ".mdx", "models\\dnc_u_" + s + ".mdx")
endfunction

function updateSun takes nothing returns nothing
  local real t = GetTimeOfDay()
  local integer a

  set a = R2I((t / 24.0) * 360)
  set a = ModuloInteger(a - 0, 360)
  // if a < 0 then
  //   set a = 0
  // elseif 359 < a then
  //   set a = 359
  // endif

  call setSun(a)
  // call print(I2S(a))
endfunction

function onPlayerChatEvent takes nothing returns nothing
  local string C = ccS(0)

  if "a" == C then
    call setDnc(ccI(1))
  elseif "t" == C then
    call SetTimeOfDay(ccF(1))
  elseif "ts" == C then
    call SetTimeOfDayScale(ccF(1))
  elseif "s" == C then
    call setSun(ccI(1))
  elseif "d" == C then
    call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, ccF(1), 0.0)
  endif
endfunction

function onMapInit1 takes nothing returns nothing
  call SetCameraField(CAMERA_FIELD_FARZ, 10*1000.0, 0.0)
  call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 3000.0, 0.0)
  call SetTimeOfDayScale(35.0)

  call CreateUnit(Player(0), 'hfoo', 0.0, 0.0, 270.0)
  call CreateUnit(Player(0), 'Hpal', 0.0, 0.0, 270.0)

  call TimerStart(CreateTimer(), 0.1, true, function updateSun)
endfunction

function onMapInit0 takes nothing returns nothing
  call dncsInit()
  call chatCmdsInit()
  call FogEnable(false)
  call FogMaskEnable(false)
  call SetTimeOfDay(6.0)
endfunction

function main takes nothing returns nothing
  call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
  call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
  call NewSoundEnvironment( "Default" )
  call SetAmbientDaySound( "LordaeronSummerDay" )
  call SetAmbientNightSound( "LordaeronSummerNight" )
  call SetMapMusic( "Music", true, 0 )
  call InitBlizzard(  )

  call onMapInit0()
  call TimerStart(CreateTimer(), 0.0, false, function onMapInit1)
endfunction

function InitCustomPlayerSlots takes nothing returns nothing
  call SetPlayerStartLocation( Player(0), 0 )
  call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
  call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN )
  call SetPlayerRaceSelectable( Player(0), true )
  call SetPlayerController( Player(0), MAP_CONTROL_USER )
endfunction

function config takes nothing returns nothing
  call SetMapName( "TRIGSTR_001" )
  call SetMapDescription( "TRIGSTR_003" )
  call SetPlayers( 1 )
  call SetTeams( 1 )
  call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS )
  call DefineStartLocation( 0, 0.0, 0.0 )

  call InitCustomPlayerSlots(  )
  call SetPlayerSlotAvailable( Player(0), MAP_CONTROL_USER )
  call InitGenericPlayerSlots(  )
endfunction
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,889
This needs at least JASS tag.
The way to import this system is unacceptable as it not only requires MPQ edit, but also editing through war3map.j will make writing triggers, and the rest of the map pretty slow since saving in World Editor will overwrite the script.
Global variables are incouraged, in principle, to start in camelCase, shown here. You don't have to follow 100% of it, but the variable ndnc is inconstent the with others. ndncAmount would be a better option.
It is required a separation between the system and the part of testing. Make clear what's API and what's internal functions (can benefit from VJASS features here). Perhaps add functions to pause and resume timer.
Needs documentation, and how to import (after you overhaul this resource).
local integer ns = StringLength(s) remains unused.

JASS:
function ccI takes integer idx returns integer
  return S2I(chatCmdArgs[idx])
endfunction

function ccF takes integer idx returns real
  return S2R(chatCmdArgs[idx])
endfunction

function ccS takes integer idx returns string
  return chatCmdArgs[idx]
endfunction
These aren't descriptive at all, Chat2Integer/C2I, Chat2Real/C2R, Chat2String/C2S are better names.

Overall, it's quite an interesting effect, useful as something decorative. However, I still wonder this would be applied, since I see no way of doing this for units and buildings.
 
Top