Effects 'nil' for footsteps on metal

Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
edited October 2013 in Modding
I have an issue where I get errors in the log everytime I move. (Yes, I have finally got enough code working to get me to the ready room, woohoo). Here is the log:
[Predict] Script Error #1: lua/GameEffectsMixin.lua:35: bad argument #2 to 'band' (number expected, got nil)
    Call stack:
    #1: band [C]:-1
    #2: GetGameEffectMask lua/GameEffectsMixin.lua:35
        self = ReadyRoomPlayer-3806 {activeWeaponId=-1, alive=true, animateAngles=false, animateDistance=false, animatePosition=false, animateYOffset=false, animationBlend=0.19999998807907, animationGraphIndex=2, animationGraphNode=14, animationSequence2=0, animationSequence=1, animationSpeed2=1, animationSpeed=1, animationStart2=60.58984375, animationStart=102.78125, armor=0, baseYaw=0, bodyYaw=0, bodyYawRun=0, cameraDistance=0, clientIndex=1, collisionRep=0, communicationStatus=1, countingDown=false, darwinMode=false, desiredCameraAngles=cdata, desiredCameraDistance=0, desiredCameraPosition=cdata, desiredCameraYOffset=0, followingTransition=false, fov=90, frozen=false, fullPrecisionOrigin=cdata, gameEffectsFlags=0, gameStarted=false, giveDamageTime=0, health=100, healthIgnored=false, isMale=true, isMoveBlocked=false, isOnEntity=false, isUsing=false, jumpHandled=false, jumping=false, layer1AnimationBlend=0, layer1AnimationGraphNode=134, layer1AnimationSequence2=-1, layer1AnimationSequence=-1, layer1AnimationSpeed2=1, layer1AnimationSpeed=1, layer1AnimationStart2=0, layer1AnimationStart=0, locationId=1, maxArmor=0, maxHealth=100, mode=1, modeTime=-1, modelIndex=12, moveButtonPressed=true, moveTransition=false, onGround=true, physicsGroup=8, physicsGroupFilterMask=0, physicsType=1, playerLevel=0, playerSkill=129, primaryAttackLastFrame=false, processMove=true, pushImpulse=cdata, pushTime=0, quickSwitchSlot=1, reinforcedTierNum=0, resetMouse=0, runningBodyYaw=6.0274863243103, secondaryAttackLastFrame=false, shoulderPadIndex=0, slowAmount=0, standingBodyYaw=6.0274863243103, startCameraAngles=cdata, startCameraDistance=0, startCameraPosition=cdata, startCameraYOffset=0, stepAmount=0.010000000707805, stepStartTime=60.55078125, syncHealth=false, teamNumber=0, techId=43, timeGroundAllowed=0, timeGroundTouched=0, timeLastHealed=0, timeLastMenu=0, timeOfLastJump=0, timeOfLastUse=0, timeOfLastWeaponSwitch=0, transitionDuration=0, transitionStart=0, tweeningFunction=1, upgrade1=1, upgrade2=1, upgrade3=1, upgrade4=1, upgrade5=1, upgrade6=1, variant=2, velocity=cdata, velocityLength=5, velocityPitch=0, velocityYaw=1.8268841505051, viewModelId=452, viewPitch=0.10718854516745, viewRoll=0, viewYaw=6.0274863243103, weaponsWeight=0 }
        effect = nil
    #3: GetMaterialBelowPlayer lua/Player.lua:1759
        self = ReadyRoomPlayer-3806 {activeWeaponId=-1, alive=true, animateAngles=false, animateDistance=false, animatePosition=false, animateYOffset=false, animationBlend=0.19999998807907, animationGraphIndex=2, animationGraphNode=14, animationSequence2=0, animationSequence=1, animationSpeed2=1, animationSpeed=1, animationStart2=60.58984375, animationStart=102.78125, armor=0, baseYaw=0, bodyYaw=0, bodyYawRun=0, cameraDistance=0, clientIndex=1, collisionRep=0, communicationStatus=1, countingDown=false, darwinMode=false, desiredCameraAngles=cdata, desiredCameraDistance=0, desiredCameraPosition=cdata, desiredCameraYOffset=0, followingTransition=false, fov=90, frozen=false, fullPrecisionOrigin=cdata, gameEffectsFlags=0, gameStarted=false, giveDamageTime=0, health=100, healthIgnored=false, isMale=true, isMoveBlocked=false, isOnEntity=false, isUsing=false, jumpHandled=false, jumping=false, layer1AnimationBlend=0, layer1AnimationGraphNode=134, layer1AnimationSequence2=-1, layer1AnimationSequence=-1, layer1AnimationSpeed2=1, layer1AnimationSpeed=1, layer1AnimationStart2=0, layer1AnimationStart=0, locationId=1, maxArmor=0, maxHealth=100, mode=1, modeTime=-1, modelIndex=12, moveButtonPressed=true, moveTransition=false, onGround=true, physicsGroup=8, physicsGroupFilterMask=0, physicsType=1, playerLevel=0, playerSkill=129, primaryAttackLastFrame=false, processMove=true, pushImpulse=cdata, pushTime=0, quickSwitchSlot=1, reinforcedTierNum=0, resetMouse=0, runningBodyYaw=6.0274863243103, secondaryAttackLastFrame=false, shoulderPadIndex=0, slowAmount=0, standingBodyYaw=6.0274863243103, startCameraAngles=cdata, startCameraDistance=0, startCameraPosition=cdata, startCameraYOffset=0, stepAmount=0.010000000707805, stepStartTime=60.55078125, syncHealth=false, teamNumber=0, techId=43, timeGroundAllowed=0, timeGroundTouched=0, timeLastHealed=0, timeLastMenu=0, timeOfLastJump=0, timeOfLastUse=0, timeOfLastWeaponSwitch=0, transitionDuration=0, transitionStart=0, tweeningFunction=1, upgrade1=1, upgrade2=1, upgrade3=1, upgrade4=1, upgrade5=1, upgrade6=1, variant=2, velocity=cdata, velocityLength=5, velocityPitch=0, velocityYaw=1.8268841505051, viewModelId=452, viewPitch=0.10718854516745, viewRoll=0, viewYaw=6.0274863243103, weaponsWeight=0 }
        fixedOrigin = cdata
        trace = cdata
        material = "metal"

Player is confirming the correct material, but GameEffectsMixin tells me there is no effect for this. I have compared this to vanilla NS2 and cannot see any changes between these two functions, so I think I have messed up somewhere else. Any advice anyone can give?

Here is the kSurfaceList from globals.lua:
// Surface list. Add more materials here to precache ricochets, bashes, footsteps, etc
// Used with PrecacheMultipleAssets
kSurfaceList = { "electronic", "metal", "rock", "thin_metal", "armor", "flame", "glass" }

Here is the get material below player function:
function Player:GetMaterialBelowPlayer()

    local fixedOrigin = Vector(self:GetOrigin())
    
    // Start the trace a bit above the very bottom of the origin because
    // of cases where a large velocity has pushed the origin below the
    // surface the player is on
    fixedOrigin.y = fixedOrigin.y + self:GetExtents().y / 2
    local trace = Shared.TraceRay(fixedOrigin, fixedOrigin + Vector(0, -(2.5*self:GetExtents().y + .1), 0), CollisionRep.Move, PhysicsMask.AllButPCs, EntityFilterOne(self))
    
    local material = trace.surface
    // Default to metal if no surface material is found.
    if not material or string.len(material) == 0 then
        material = "metal"
    end
    
    // Have squishy footsteps on infestation 
    if self:GetGameEffectMask(kGameEffect.OnInfestation) then
        material = "organic"
    end
    
    return material
end

And the mixin code:
function GameEffectsMixin:GetGameEffectMask(effect)
    return bit.band(self.gameEffectsFlags, effect) ~= 0
end

The precache of the events is done in EffectManager.lua in the local function:
local function InternalPrecacheEffectTable(self, globalEffectTable)

I'll let you read the whole function, it's a bit long to be posting in here..

edit - spelling

Comments

  • xDragonxDragon Join Date: 2012-04-04 Member: 149948Members, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow
    GetGameEffectMask uses the GameEffects from Globals.lua - thats different from the SurfaceList - my guess is you removed OnInfestation from that list but your still referencing it there:
    // Have squishy footsteps on infestation 
        if self:GetGameEffectMask(kGameEffect.OnInfestation) then
            material = "organic"
        end
    
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Thanks @xDragon, that solved the issue. The only thing I was wondering is why? I mean, this is an if statement, so the condition should always be false if the element doesn't exist? I guess it is not as simple as that...
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    If the actions performed in a conditional block require a variable to be of a specific data type and/or value, and the actual variable doesn't exist or isn't in scope then the script parsing will fail. In your case the condition was expecting a reference to an ENUM value (basically an alias of Lua Table), since it received nil that is invalid syntax. Also, nil is actually a data type in Lua. Anything that is nil will also be considered a weak assignment and could be cleaned by the garbage collector. One more thing, you can get an almost identical, in nature (not specific to the band() function), error message if a variable/global is not in scope.
Sign In or Register to comment.