• 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.

Spell requiements at night

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
Hi, im making a new map and I wanted to know how to make a spell requiements but only when its the night and day the requiements disapear. :vw_wtf:

a example already was wrote but u can make a trick too.

i use this trick.

Simple make:
-1 dummy unit (movement:fly, ability:locust, 0 food cost, model: none.mdl, attack:none, sight range to 0;)
- add requiment this dummy unit to your ability.

i give a example

  • Create Unit Night
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dummy_Unit[(Integer A)] Equal to No unit
            • Then - Actions
              • Set TempPoint = (Random point in (Playable map area))
              • Unit - Create 1 *You Dummy Unit* for (Player((Integer A))) at TempPoint facing Default building facing degrees
              • Set Dummy_Unit[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
Day

  • Remove Unit Morning
    • Events
      • Game - The in-game time of day becomes Equal to 8.00
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Unit - Remove Dummy_Unit[(Integer A)] from the game
another way the disable

  • Create Unit Night
    • Events
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Enable *Your Ability* for (Player((Integer A)))
Day

  • Remove Unit Morning
    • Events
      • Game - The in-game time of day becomes Equal to 8.00
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable *Your Ability* for (Player((Integer A)))
 
Level 6
Joined
Jun 16, 2007
Messages
235
JASS:
//==============================================================================
//  Library creates invisible sun and moon units for all players.
//  These units are then used as tech requirements for spells.
//  If a player has a sun unit in his ownership than he can use sun spells.
//  Same goes for moon ofc.
//  Sun units are owned by players only during day time.
//  Moon units are owned by players only during night time.
//==============================================================================
library Daytime initializer Init uses Trig

globals
    private constant player NEUTRAL = Player(13)
    private unit array sun
    private unit array moon
endglobals


//==============================================================================
//  For testing purposes
//==============================================================================
public function Off takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i>=12
        call SetUnitOwner(sun[i], NEUTRAL, false)
        call SetUnitOwner(moon[i], NEUTRAL, false)
        set i = i + 1
    endloop
endfunction

//==============================================================================
private function Dawn takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i>=12
        call SetUnitOwner(sun[i], Player(i), false)
        call SetUnitOwner(moon[i], NEUTRAL, false)
        set i = i + 1
    endloop
endfunction

//==============================================================================
private function Dusk takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i>=12
        call SetUnitOwner(moon[i], Player(i), false)
        call SetUnitOwner(sun[i], NEUTRAL, false)
        set i = i + 1
    endloop
endfunction

//==============================================================================
public function isDay takes nothing returns boolean
    return (GetTimeOfDay() >= 6.00) and (GetTimeOfDay() < 18.00)
endfunction

//==============================================================================
private function Actions takes nothing returns nothing
    if isDay() then
        call Dawn()
    else
        call Dusk()
    endif
endfunction

//==============================================================================
private function Init takes nothing returns nothing
    local trigger trig
    local item it
    
    local integer i = 0
    loop
        exitwhen i>=12
        set sun[i] = CreateUnit(NEUTRAL, UID_sun, 0-i*100, 0, 0)
        set moon[i] = CreateUnit(NEUTRAL, UID_moon, 0+i*100, 0, 0)
        call PauseUnit(sun[i], true)
        call PauseUnit(moon[i], true)
        set i = i + 1
    endloop
    
    // empire sun gets all map regen aura, scourge moon gets all map regen aura
    call UnitAddAbility(sun[Players_EMPIRE], AID_sun_aura)
    call UnitAddAbility(moon[Players_SCOURGE], AID_moon_aura)
    
    call Trig_TimeOfDay(function Dawn, 6.00)
    call Trig_TimeOfDay(function Dusk, 18.00)    
    call Trig_TimerSingle(function Actions, 0.01)
endfunction

endlibrary
 
Status
Not open for further replies.
Top