Game Development Community

HELP with aiplayer

by Dante · in Game Design and Creative Issues · 02/12/2009 (8:06 am) · 8 replies

Im working with tgea 1.7.2 and I trying to add the aiplayer.cs in to my project and the exec comand in the game.cs .. but when I load the mission it hangs.. Can you tell me how to add the aiplayer.cs or what Im missing here.. Im using the barricade project.. thanks

About the author

Recent Threads

  • Gravity issue

  • #1
    02/12/2009 (8:50 am)
    I'll assume that you placed aiPlayer.cs in the "server/scripts" directory. Did you also start the AIManager?

    It needs to be started in function startGame() in game.cs
    // Start the AIManager
    new ScriptObject(AIManager) {};
    MissionCleanup.add(AIManager);
    AIManager.think();

    It will then need to be terminated in function endGame() also in game.cs
    // Stop the AIManager
    AIManager.delete();

    AIManager::think() calls AIManager::spawn() which in turns calls AIPlayer::spawnOnPath() so you'll also have to place a path for the AI by using pathmarkers in the editor. Refer back to the Stronghold game (the Stronghold & Barebones missions) for an example of how to do that.

    It was those steps and aiPlayer.cs that was the bare minimal I needed to add rudimentary AI into my project.
    #2
    02/12/2009 (9:20 am)
    hi.. thanks for your help.. but I've already did that.. I copied the aiplayer from the stronghold mission
    I want to add the nature package that includes some birds and fish but that requires the aiplayer.cs
    and I still have that problem..

    and I also have a question.. what is (Kork)?
    in the spawn function above



    function AIManager::spawn(%this)
    {
    %player = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");

    if (isObject(%player))
    {
    %player.followPath("MissionGroup/Paths/Path1",-1);

    %player.mountImage(CrossbowImage,0);
    %player.setInventory(CrossbowAmmo,1000);
    return %player;
    }
    else
    return 0;
    }

    Im lost =(

    #3
    02/12/2009 (9:50 am)
    "Korc" is the name given to the bot.

    It's been a while since I even looked at the Barricade Demo but I think I recall that it named the PlayerData datablock differently from other examples. And since the AI inherits from the player datablock that may be a possible problem....

    Look at the player.cs (or was it boombot.cs?) in Barricade and find the name of the PlayerData datablock. You'll need to make the one in aiPlayer.cs match that name.
    datablock PlayerData(DemoPlayer : PlayerBody) 
    {
       shootingDelay = 2000;
    };
    The "PlayerBody" is the likely culprit. "DemoPlayer" is the bot's datablock name and it inherits from the "PlayerBody" datablock. If that datablock doesn't exist then that can cause a problem
    #4
    02/12/2009 (9:50 am)
    if you have the barricade mission, could you help me testing this because in this mission, no aiplayer is used.. thanks.. =)
    #5
    02/12/2009 (12:38 pm)
    THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKS THANKSTHANKS THANKS THANKS.... =).. YOU SAVED ME =)
    #6
    02/12/2009 (2:50 pm)
    Glad to help.
    #7
    02/12/2009 (4:24 pm)
    Btw, mentioning TGEA..... it seemed to me that a good amount of scripting would have to be done to modify the TGEA demo to make it playable. Is this intentional? I am a TGE owner but am looking to upgrade to TGEA soon and it would have been nice to actually PLAY a TGEA demo but this does not seem possible without a good deal of TorqueScript modification.

    Am I missing something?

    #8
    02/13/2009 (6:25 am)
    @Nmuta - Barricade and the other demos are "Feature Demos" so yes scripting will be necessary in order to make them "playable". Should be fairly simple really since you're already an owner. There are community ports of the starter.fps & starter.racing to TGEa somewhere around, that the kits for TGEa are based upon.