• 🏆 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!

[JASS] Missile With Vision Problem

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
Hello, I'm using BPower(Missile [GUI] version 1.6.1) missile system in my map.

I want to make a missile that gives vision around it when it's travelling.

I tired to do this in two ways.

1. With Fogmodifier. I create one fogmodifier when the missile is travelling. In the system there is a missile event ID i can use to check that.
This works, but the integers can go really high like 5000 and over. Also i've been told that fogmodifiers are bad for performances.
Is this a problem?
JASS:
globals
 fogmodifier array lightfogmod
 integer fogmodn = 0
 integer fogmodn2 = 0
endglobals

function lightfogmodremove takes nothing returns nothing

 call PolledWait(0.8)
  if fogmodn2 == fogmodn then
 
   else
       call DestroyFogModifier(lightfogmod[fogmodn2])

       call DisplayTimedTextToPlayer(Player(0),0,0,1,"fogmodn2 = " + I2S(fogmodn2))
 
    set fogmodn2 = fogmodn2+1
  endif
 
endfunction

if udg_Missile__EventId == udg_EVENT_MISSILE_PERIODIC then

set lightfogmod[fogmodn] = CreateFogModifierRadius(Player(i), FOG_OF_WAR_VISIBLE, tx,ty, 400, true,false)
        call FogModifierStart(lightfogmod[fogmodn])
        set fogmodn = fogmodn + 1
        call BJDebugMsg(I2S(fogmodn))
        call lightfogmodremove()
endif

The other way it didi it was to create a dummy unit and move it on the missile position. It workjs but i had some problems, especially when firing multiple missiles.

Can someone suggest me the better way to do this?
 
Level 19
Joined
Aug 16, 2007
Messages
881
If you want sight vision for all missiles, simply edit the missile dummy in the object editor and increase it's Sight Radius as it's set to 0 in the demo map.

Otherwise if you're using the latest version, 1.31, you can modify the line of sight directly with a simple trigger action (Unit - Set Unit Real Field):
  • Unit - Set Unit: your_unit Real Field: Sight Radius ('usir') to Value: the_amount_of_vision_range_you_want
 
Level 9
Joined
Sep 20, 2015
Messages
385
If you want sight vision for all missiles, simply edit the missile dummy in the object editor and increase it's Sight Radius as it's set to 0 in the demo map.

Otherwise if you're using the latest version, 1.31, you can modify the line of sight directly with a simple trigger action (Unit - Set Unit Real Field):
  • Unit - Set Unit: your_unit Real Field: Sight Radius ('usir') to Value: the_amount_of_vision_range_you_want

I can't edit the dummy directly because i have other types of missiles that uses the same dummy. The function didn't work the last time i tried. I will try again.

But i got a another problem if i use units.

How can i detect the last missile created? If i change the missile dummy vision, it changes the first missile created and not the last one.


Example.

I have missiles with low speed.
So I fire the first missile. (1stmissile)
While the first missile is travelling , i fire another missile. (2ndmissile)

Now if i create a trigger that refers to the udg_Missile__Dummy variable, it only consider the 1st missile.
I tired to use udg_Missile_Dummy[udg_Missile__EventIndex] but still onlyt the missile is considered.

Maybe you can help with this?
 
Level 9
Joined
Sep 20, 2015
Messages
385
I tried myself but couldn't get it to work either with the system, but my own experiment on another map worked fine.

Even if you give the dummy unit sight range in the object editor, you won't have vision in-game with the missile, so I'm not sure how this system is coded and maybe someone else have more insight than me.

Yeah i tested it and it seems that the GUI version is not working, when i tested it with JASS

JASS:
natvie  BlzSetUnitRealField                         takes unit whichUnit, unitrealfield whichField, real value returns boolean

This works just fine. Not on dummy missiles units tho.

So well, i think im gonna use that FogModifier method for now, thanks
 
Level 19
Joined
Aug 16, 2007
Messages
881
The missiles are probably just owned by a neutral player instead of you, so it’s not showing the vision for you.
Yeah, this was the case apparently.
JASS:
set bj_lastCreatedUnit = CreateUnit(Missile_GetDummyOwner(), udg_Missile__DummyTypeId, originX, originY, face)
JASS:
// Set the owning player of all dummy units.
// It should be a neutral player in your map.
constant function Missile_GetDummyOwner takes nothing returns player
    return Player(PLAYER_NEUTRAL_PASSIVE)
endfunction
 
Status
Not open for further replies.
Top