Game Development Community

Drop in enemies?

by Joshua Ayers · in Technical Issues · 12/09/2005 (6:39 am) · 6 replies

Are there any resources for enemy types that can just be dropped into torque? maybe some different types like the enemies in quake (flying, guarding, pacing)...was just wondering since my coding skills aren't the greatest in the world. torque makes it insanely easy to create nice looking environments, but without bad guys running around it's a little boring!

#1
12/16/2005 (2:13 pm)
Try http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6742 as a start. There are also some resources by Mark Halcomb? which cover patroling bots and the like ( the CTF bot can use navigation nodes). My suggestion would be to try the link I posted first as the bots are far less processor intensive.

- Anthony
#2
02/26/2006 (3:57 pm)
I think what he was trying to say is, can you create enemies with the world editor and just point-click them into the mission, or do you have to program them into it?

Actually, I was about to ask the same question.
#3
02/26/2006 (4:24 pm)
The simplest solution: AiGuard. This is actually the resource that Anthony is talking about created by Mark Holcomb.

AiGuard is a great piece of work for some basic Bot/Enemy functionality and is great for extending it beyond what it is into more sophisticated AI. Despite the fact that you have to add two new files to the engine and re-compile, its actually 100% script driven. He just basically made a copy of the AiPlayer for clarity's sake when editing your mission. Check it out!

-Jase
#4
02/27/2006 (6:41 am)
I scripted this without any Source changes, works great, however; it's now my AIPlayer base. Even got each marker's bot to have it's own 'name', and texture[Skin]. Started to stumble when I wanted to set each bot's weapon inventory, since it's set with a Globally scoped variable at the beginning of the script.

Scripting however, will not put the bots on the scoreboard...they are not a gameConnection object and remain just shapeBase[I think...].

There is no 'point/click' with the AI or any object, except to place it within the .MIS file itself and some objects, if scripted to be added to MissionCleanup, will not reappear next running, since..well, I guess because they get deleted after every running of the .MIS.... This is why in the Holcomb Resource the marker object is placed and hidden, never being deleted. I believe vehicles act in the same manner, if placed in a .MIS and saved, then the mission file run and exited, next running; no vehicle.

This is all done beforehand with scripting, so indeed, it must be programmed ahead, to have the functionality available at runtime...by the time the object is manipulated in the Mission environment, it would need to know how to be created and managed by the engine with code/scripting.

I'll preface all the above by stating, I am an artist. An artist who has had to educate himself on the scripting/programming aspects to understand the engine's workings...which is not a bad thing, since I enjoy the whole process. I found it fairly easy to produce content for the engine, it's getting it all working, that's a time consuming task. Good luck.

Rex
#5
04/23/2006 (5:47 pm)
Rex, how did you get the texture to show up. I try to get a different player to show up but it always show the player model in the game. I am using AIGuard.
#6
04/23/2006 (6:41 pm)
function AIPlayer::spawn(%name, %obj, [b]%skin[/b])//[b]%skin variable added to get dynamic texture on bot[/b]
{
   // Create the demo player object   AIPlayer();
   %player = new AIPlayer() {
   dataBlock = DemoPlayer;
   
   //The marker is the AIPlayer marker object that the guard is associated with.
   //The marker object is kept with the player data because it's location, and
   //dynamic variable values are used in several functions. This also allows the addition
   //of future dynamic variables without having to change the spawn/respawn functions to
   //access them.
   marker = %obj;
 	 botname = %name;
         [b]skin = %skin;//new line added to get a dynamic texture on bot
     //echo("change skin");[/b]
  //Sets whether the bot is AI or not
   isbot=true;
   //Sets the bots field of vision
   fov=$AI_PLAYER_FOV;
      
   //Thinking variables
   //Firing tells whether or not we're in the midst of a firing sequence.
   firing = false;
   //The 'action' variable holds the state of the bot - which controls how it
   //thinks.
   holdcnt=$AI_PLAYER_HOLDCNT_MAX-1;
   action = "Holding";
   //The bots starting attention level is set to half of it's range.
   attentionlevel = $AI_PLAYER_MAX_ATTENTION/2;
   
   //Oldpos holds the position of the bot at the end of it's last 'think' cycle
   //This is used to help determine if a bot is stuck or not.
   oldpos = %obj.getposition();
   };
   MissionCleanup.add(%player);
  	//The following cluster of if-thens sets whether the bot will respawn or not
  	//based on it's markers dynamic variable - or the default respawn variable setting.
   if (%obj.respawn $= "" )
   	{
   		%player.respawn=$AI_PLAYER_DEFAULTRESPAWN;
   	}
   	else
   	{
   		if (%obj.respawn == true)
   			%player.respawn=true;
   		else
   			%player.respawn=false;
   	}
 	 //Equipbot is called to set the bots beginning inventory.
 	 %player.EquipBot(%player);  
   //Sets the name displayed in the hud above the bot.
   %player.setShapeName(%name);
   //Sets the texture of the shape
   [b]%player.setSkinName(%obj.skin);//changed to %obj.skin 12/5/05 & now works!
       echo("I have set my skin to my marker");[/b]
   //Sets the bot's initial position to that of it's marker.
   %player.setTransform(%obj.gettransform());
   //Sets the bot to begin thinking after waiting the length of $AI_PLAYER_CREATION_DELAY
   %player.schedule($AI_PLAYER_CREATION_DELAY,"Think", %player);
		
   return %player;
}

and then again in respawn:
function AIPlayer::respawn(%this, %name, %obj)
{
   // Create the demo player object
   %player = new AIPlayer() {
   dataBlock = DemoPlayer;
   marker = %obj;
   botname = %name;
    fov=$AI_PLAYER_FOV;
   isbot=true;
   firing=false;
   holdcnt=$AI_PLAYER_HOLDCNT_MAX-1;
   action = "Holding";
   attentionlevel = $AI_PLAYER_MAX_ATTENTION/2;
   oldpos = %obj.getposition();
   
   };
   MissionCleanup.add(%player);
    %player.setShapeName(%name); // %name
		%player.EquipBot(%player);
        [b]%player.setSkinName(%obj.skin);//changed to %obj.skin 12/5/05 & now works!
            echo("I have set my skin after respawning");[/b]
   %player.setTransform(%obj.gettransform());
   if (%obj.respawn $="" )
   	{
   		%player.respawn=$AI_PLAYER_DEFAULTRESPAWN;
   	}
   	else
   	{
   		if (%obj.respawn == true)
   			%player.respawn=true;
   		else
   			%player.respawn=false;
   	}
	%player.schedule($AI_PLAYER_CREATION_DELAY,"Think", %player);
   return %player;
}

...keep in mind, I stated I'm an artist and there may be some other places where "skin" needs to be. Right off, as a Dynamic variable of the marker object. The above gave me named ai players, whose skin could be set with the marker object. I'd like to get it to do more, such as give the datablock for the weapon, but I couldn't get past the global constant in the head of the file... Good luck. It took me a bit to get it working...I hope it goes quicker for you! It was fun and satisfying knowing I could figure something like that out. Also, since I have never compiled the .exe and need to script everything, to get the aiGuard resource working for me took the form of taking the aiGuard.cs and changing every instance of the aiGuard reference to aiPlayer and it now became my aiPlayer.cs file. I'm not sure if I also merged some of the original script aiPlayer?? It's been a while since I did this and that project never really got going in developement...eh. Oh, your shape must be textured with the naming convention used for this, player.base.png or whatever you choose, as the 'base' to start swapping, but .base must be appended or no go on the swap.

It may not be a 'clean' way of doing it, I'm sure adding the %skin variable somewhere else 'higer up' might prove better, and it was how I managed to get it working, naming was also a bit tricky for me...;). Be great if someone in the know could demonstrate how to set up this type of 'stocking' correctly and a super addition to the Resource in general.