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

[Solved] Fog of War

Status
Not open for further replies.
Use a simple trick:
When the spell is cast, create dummy unit (let it has "blink" ability with Minimal range field set to 0 and Maximum to 99999) at caster's position and order it to cast "blink" in target position. It's easier in case IssueOrder functions return boolean (meaning true if spell is able to be cast, or false if it's not); following line with help you archieving this:

  • Custom script: if IssuePointOrderById(bj_lastCreatedUnit, 852525, GetUnitX(bj_lastCreatedUnit), GetUnitY(bj_lastCreatedUnit)) then
    • // everything is okey
  • Custom script: else
    • Unit - Order <caster> to stop, plus display warning
  • Custom script: endif
EDIT: Fixed parameter order in case it was written wrongly.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I'd do it like this:

  • Cast
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(flamestrike))
    • Actions
      • Set point = (Target point of issued order)
      • Custom script: if not(IsLocationVisibleToPlayer(udg_point, GetTriggerPlayer())) then
      • Custom script: call SimError(GetTriggerPlayer(), "Can not cast there.")
      • Set point2 = (Position of (Triggering unit))
      • Unit - Pause (Triggering unit)
      • Unit - Move (Triggering unit) instantly to point2
      • Unit - Unpause (Triggering unit)
      • Custom script: call RemoveLocation(udg_point2)
      • Custom script: endif
      • Custom script: call RemoveLocation(udg_point)


Link

On a side note, the maximum map size is 480x480. Therefore the max distance in a map is about sqrt((480*128)^2*2) = 87000. No need to use an insane max range.
 
Level 37
Joined
Aug 14, 2006
Messages
7,602
I was trying Maker's method. It's working but when I disabled "SimEr" trigger then I just couldn't put it back on. I wonder why? Would this lead to any bugs?
 

Attachments

  • Hubba Bubba.jpg
    Hubba Bubba.jpg
    447.2 KB · Views: 97
I see you aren't using JNPG. Even touching the vJass trigger without JNPG leads to troubles ^^

Remove the SimErr trigger and create new one (make sure it's at the top of spell trigger in case functions below can't be called, or just paste script below to map's header)
JASS:
function SimError takes player ForPlayer, string msg returns nothing
    set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r"
    if (GetLocalPlayer() == ForPlayer) then
        call ClearTextMessages()
        call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg )
        call StartSound(udg_Error)
    endif
endfunction

function InitTrig_SimError takes nothing returns nothing
    set udg_Error=CreateSoundFromLabel("InterfaceError", false, false, false, 10, 10)
    //call StartSound(udg_Error)
endfunction
It's GUI-friendly SimError version. Note that you have to create new "Sound" type variable from GUI variable editor. Name it "Error".

When, whenever you want to call the sim error just use custom script:
  • Custom script: call SimError(udg_someplayer, someMessage)
 
Level 9
Joined
Apr 26, 2011
Messages
403
Follow function may be useful.

I don't know what the difference between default, Fogged and Masked.

JASS:
IsVisibleToPlayer           takes real x, real y, player whichPlayer returns boolean
IsLocationVisibleToPlayer   takes location whichLocation, player whichPlayer returns boolean

IsFoggedToPlayer            takes real x, real y, player whichPlayer returns boolean
IsLocationFoggedToPlayer    takes location whichLocation, player whichPlayer returns boolean

IsMaskedToPlayer            takes real x, real y, player whichPlayer returns boolean
IsLocationMaskedToPlayer    takes location whichLocation, player whichPlayer returns boolean
 
Status
Not open for further replies.
Top