Jump to content

GECK: Should I declare/initialize variables before the Begin block?


irswat

Recommended Posts

scn SniperModScript

float hfPlayer
int AlertFlag
ref rSniper

set rSniper to GetSelf
set hfPlayer to 0
set AlertFlag to 0
set rSniper to 00000000
set hfPlayer to rSniper.GetDistance player

begin GameMode

MessageEx "Sniper Mod Debug Game Mode"

if rSniper.GetDead == 0
    MessageEx "Sniper %i is %g units away" rSniper hfPlayer
elseif rSniper.GetDead
    MessageEx "Sniper %i is dead" rSniper
    set hfPlayer to -72
endif

if hfPlayer <= 8000
    if hfPlayer != -72
        set AlertFlag to 1
    endif
elseif hfPlayer > 8000
    set AlertFlag to 0
    MessageEx "Player out of range by %g units." (hfPlayer-8000)
endif

if AlertFlag == 1
    if player.GetDead == 0
        Look rSniper
        rSniper.Look player
        MessageEx "Player within range. Firing."
        rSniper.UseWeapon WeapNVGhillieSniperRifle rSniper player 6 0 0 1 0
    endif
    if player.GetDead == 1
        set AlertFlag to 0
    endif
endif

end

Specifically the highlighted portion. Should this declaration/initialization be inside the Begin GameMode section, or before it as I have it? The reason I am asking is for some reason or another these variables do not seem to be refreshing/updating.

 

I have 4 snipers and the debug messages will go through them one by one, but whether they are alive or dead, and how far away they are isnt changing for some reason.

 

I thought maybe it's because of the declaration/initialization

Edited by irswat
Link to comment
Share on other sites

This stuff needs to be in the gamemode block:


set rSniper to GetSelf

set hfPlayer to 0

set AlertFlag to 0

set rSniper to 00000000

set hfPlayer to rSniper.GetDistance player


And FYI, if you spawn the actor with PlaceAtMe, GetSelf will always return zero.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...