Torque Bots and Damage - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Torque Bots and Damage

Description:

Torque Bots and Damage CIS 487/587 Bruce R. Maxim UM-Dearborn Slides based on the Code Sampler Tutorials by Kevin Harris Adding a Bot - 1 The code found in the bot.cs ... – PowerPoint PPT presentation

Number of Views:81
Avg rating:3.0/5.0
Slides: 22
Provided by: BruceM170
Category:

less

Transcript and Presenter's Notes

Title: Torque Bots and Damage


1
Torque Bots and Damage
  • CIS 487/587
  • Bruce R. Maxim
  • UM-Dearborn

2
Slides based on theCode Sampler Tutorialsby
Kevin Harris
3
Adding a Bot - 1
  • The code found in the bot.cs script file was
    taken from a more complicated A.I. script called,
    aiPlayer.cs, which is part of the starter.fps
    example.
  • Copy the bot.cs script to your tutorial.base/serve
    r directory.
  • Open the game.cs script file located in the
    tutorial.base/server directory

4
Adding a Bot - 2
  • Add the following line of script to the function
    onServerCreated( ) add it to the end of the list
    like usual
  • exec("./bot.cs")
  • Besides defining how our bot follows a given
    path, the bot.cs script also defines a special
    object called AIManager which is responsible for
    managing all bots in general
  • For our AIManager to work, we'll need to add some
    code to start and stop it respectively.

5
Adding a Bot - 3
  • Add the highlighted lines to the
    onMissionLoaded() function
  • new ScriptObject(AIManager)
  • MissionCleanup.add(AIManager)
  • AIManager.think()
  • Next, we need add a of line of code to the
    onMissionEnded() function to delete the manager
    object when our game is done.    
    AIManager.delete()

6
Adding a Bot - 4
  • When done, close and save the "game.cs" script
    file.
  • Note We haven't laid-out our path yet with the
    Mission Editor so the function AIManagerspawn(
    ), which actually spawns the bot, will simply
    spawn a regular bot without specifying a path to
    follow.

7
Path Definition - 1
  • Run the test application by double-clicking
    torqueDemo.exe, which is located in the example
    directory.
  • When the main menu comes up, click the "Load
    Mission!" button. A mission named, "F World",
    should load.
  • After the mission starts, move forward a bit and
    turn around. You should see a motionless bot just
    standing there.

8
Path Definition - 2
  • Find a relatively flat area where it will be
    easier to create a path and hit F11 to open the
    Mission Editor and switch to "World Editor
    Creator" mode.
  • Expand the tree in the lower right half of the
    screen by clicking the "Mission Objects" entry.
    Expand it out like so
  • "Mission Objects-gtMission"

9
Path Definition - 3
  • In the Mission directory, you should see several
    entries to choose from.
  • Click the entry labeled "Path" just once to
    create a new Path object. Name the Path object,
    "myPath".
  • In the MissionGroup tree, which is in the upper
    right hand side of the editor, expand out the
    tree and find the node labeled "myPath".

10
Path Definition - 4
  • Make this node the current selection by holding
    down the "Alt" key while clicking it with the
    mouse.
  • If done correctly, the selection color of the
    "myPath" entry should change from white to gray.
  • Make sure the path markers get grouped under our
    new Path object.

11
Path Definition - 5
  • Return to the tree control in the lower right
    hand corner and click the PathMarker in the
    "Mission" directory.
  • Name the new PathMarker, "myMarker0" and check to
    make sure it was correctly grouped under "myPath"
    in the "MissionGroup" tree control.
  • Repeat the process to create two more PathMarkers
    called, "myMarker1, and "myMarker2".

12
Path Definition - 6
  • Make sure to place the markers far enough apart
    so you can see your bot run around.
  • Save the mission file by selecting and exit
    completely out of the game.
  • return to the bot.cs script file located in the
    tutorial.base/server directory and edit the
    function AIManagerspawn()
  • Comment out the line of code that creates "Bot_1"
    and uncomment the code below it that creates
    "Bot_2 and save bot.cs.

13
Test Bot
  • Run the test application again by double-clicking
    torqueDemo.exe.
  • If everything was done correctly, you should see
    a new bot called "Bot_2" running around your new
    Path object's PathMarkers.
  • If not, make sure that your PathMarkers are not
    too low on the terrain and that they're correctly
    grouped under the "myPath" object.

14
Weapons Damage
  • This tutorial demonstrates how to apply weapons
    damage to both players and bots when a weapon's
    projectile collides with them and how to
    calculate "radius damage", which allows an
    exploding projectile to damage a player without
    making direct contact.
  • This tutorial not only requires the Tutorial Base
    application as its starting place, but also
    requires the addition of the Weapons and Bot
    Path-Finding tutorials.

15
Damage - 1
  • Copy the scripts radiusDamage.cs and shapeBase.cs
    to your tutorial.base/server directory.
  • Open the game.cs script file located in the
    tutorial.base/server directory and add the
    following script lines to the function
    onServerCreated()
  • exec("./radiusDamage.cs")
  • exec("./shapeBase.cs")

16
Damage - 2
  • Copy the player_dieknees.dsq animation file to
    the /tutorial.base\data\shapes\player directory.
  • Open the player.cs script file located in the
    \tutorial.base\data\shapes\player directory and
    following highlighted line of script to the
    datablock TSShapeConstructor
  • sequence12 "./player_dieknees.dsq die"

17
Damage - 3
  • This is the last change to this player.cs save
    the file and close it.
  • Open the player.cs script file located in the
    tutorial.base/server directory and add the
    following line of script to the datablock
    PlayerShape
  •     className Armor

18
Damage - 4
  • Add this function to the bottom of the player.cs
    script.
  • function PlayerplayDeathAnimation( this )
  •   this.setActionThread( "die" )
  • Add this function next.
  • function Armordamage
  • (this, obj, sourceObject, position,
          damage, damageType )   

19
Damage - 5
  • Add this function next.
  • function ArmoronDisabled( this, obj, state
    )    
  • This is the last change to this player.cs save
    the file and close it.
  • Open the rocket_launcher.cs script file located
    in the tutorial.base/server directory

20
Damage - 6
  • Modify the datablock RocketProjectile datablock
    like so
  • directDamage 50
  • radiusDamage 25
  • damageRadius 1.5
  • Then modify the function RocketProjectileonColli
    sion
  • function RocketProjectileonCollision
  • ( this, obj, col, fade, pos, normal
    )    

21
Damage - 7
  • That's it for rocket_launcher.cs save the file
    and close it.
  • Run the test application by double-clicking
    torqueDemo.exe
  • You should now be able to shoot and kill the
    path-finding bot as well as blow your self up by
    shooting at your player's feet.
Write a Comment
User Comments (0)
About PowerShow.com