Announcement

Collapse
No announcement yet.

Bot sight based on light

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Bot sight based on light

    I've got a mod that has some night maps and in these maps whether you can see enemies or not is a significant part of gameplay, unfortunately bots don't rely on eyes so they can see in the dark.

    Their vision can be limited from within the editor on a per-map basis which would work for totally dark maps or totally fogged maps but I have areas of light and being able to barely see in the light is as silly as being able to see perfectly in darkness.

    Obviously this means there's some coding to be done, if I only had static light I presume I could make a new volume and code it so any enemies in that volume can be seen at greater distance but I also have some dynamic lighting in the form of muzzle flashes (which I suppose can be handled in the HearNoise() code as a fire noise will occur at the same time) and a Flare Gun which lights up a good sized area.

    The ideal solution would be some kind of system based on if the light in the area the enemy is in is above X then the bot can see that enemy and engage it but I'm not aware of or able to find anything even vaguely similar to this.

    Unless I've misinterpreted the code this function looks like the place to add extra conditions:
    Code:
    event SeePlayer(Pawn SeenPlayer)
    {
    	// 
    	// This if looks like a place you can influence the sight system by adding more if conditions
    	// 
    	if ( Enemy == SeenPlayer )
    	{
    		VisibleEnemy = Enemy;
    		EnemyVisibilityTime = WorldInfo.TimeSeconds;
    		bEnemyIsVisible = true;
    	}
    }
    Can anyone offer any helpful input?

    #2
    Could you spawn a temporary volume at the location of the muzzle flashes?

    Comment


      #3
      Or have a permanent volume which gets activated for a short time when shooting?

      Comment


        #4
        Well I can have shots be handled by HearNoise() by removing the projectiles and pickups condition it currently has. It's just the flare that'll need a temporary volume as that's supposed to highlight players on the opposite team to the flare firer.

        I've got this as my SeePlayer event:
        Code:
        event SeePlayer(Pawn SeenPlayer)
        {
        	if (Squad == None && !WorldInfo.GRI.OnSameTeam(self, SeenPlayer))
        	{
        		// maybe scripted pawn; just notify Kismet
        		Pawn.TriggerEventClass(class'SeqEvent_AISeeEnemy', SeenPlayer);
        	}
        	else if (Squad.SetEnemy(self, SeenPlayer))
        	{
        		// check for any Kismet scripts that might care
        		Pawn.TriggerEventClass(class'SeqEvent_AISeeEnemy', SeenPlayer);
        
        		WhatToDoNext();
        	}
        
        	if ( left(WorldInfo.GetMapName(), 8) ~= "RIFNIGHT" )
        	{
        		if ( SeenPlayer.TouchingRiflesLitAreaVolume() )
        		{
        			if ( Enemy == SeenPlayer )
        			{
        				VisibleEnemy = Enemy;
        				EnemyVisibilityTime = WorldInfo.TimeSeconds;
        				bEnemyIsVisible = true;
        			}
        		}
        		else
        		{
        
        		}
        	}
        	else if ( left(WorldInfo.GetMapName(), 8) != "RIFNIGHT" )
        	{
        		if ( Enemy == SeenPlayer )
        		{
        			VisibleEnemy = Enemy;
        			EnemyVisibilityTime = WorldInfo.TimeSeconds;
        			bEnemyIsVisible = true;
        		}
        	}
        }
        Which won't compile because SeenPlayer.TouchingRiflesLitAreaVolume() (ie Pawn.TouchingRiflesLitAreaVolume() ) doesn't exist (the function is only in my custom pawn) and I can't make it RiflesPawn SeenPlayer because it doesn't like the redefinition.

        I also noticed more SeePlayer events in two of UTBot's states which I presume I'll have to add this to aswell.

        Comment


          #5
          I'd not use hear noise for muzzle flashes, and instead set the object that is firing to bInvisible = false for a limited duration whilst firing.

          In Blue (which you won't know of yet - no public info), custom lights were used to determine when a player is or is not in shadow, and therefore visible.

          Comment

          Working...
          X