GoldenEye: Source Forums

  • November 25, 2024, 04:12:29 am
  • Welcome, Guest
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Bot scripting: I've not been able to setup a custom task list  (Read 9068 times)

0 Members and 1 Guest are viewing this topic.

Joe

  • Secret Agent
  • **
  • Posts: 139
  • Reputation Power: 54
  • Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.
  • Offline Offline

Hi,

I've been able to setup a custom schedule list but I haven't been able to setup a custom task list.

GE:S wants my test task to be a schedule, telling me its parent class should be "PYSchedule" instead of "PYTask".

Can someone please tell me if I have made a mistake or is this a bug with the GE:S 4.2.1 bot scripting system?

GE:S console error message:
Quote
Failed to create schedule `TEST_TASK` because Ai.Tasks.DADTasks.TestTask must inherit Ai.Schedules.PySchedule!
Loading NPC bot_dieanotherday from cache
TypeError: No registered converter was able to produce a C++ rvalue of type int from this Python object of type str
Pure Aiyum has connected
Navgtr has connected
Round Ending...
Round Restarting...
TypeError: No registered converter was able to produce a C++ rvalue of type int from this Python object of type str
TypeError: No registered converter was able to produce a C++ rvalue of type int from this Python object of type str

Ai.bot_dieanotherday:
Code: [Select]
'''
@author: Joe
@version: Alpha 1.04
'''

from GamePlay import DieAnotherDay
from Ai.bot_deathmatch import bot_deathmatch
from Ai.Schedules import DADSchedules
from Ai.Schedules.DADSchedules import DADScheduleList
from Ai.Tasks.DADTasks import DADTaskList
import GEMPGameRules,GEGlobal,GEUtil

USING_API = GEGlobal.API_VERSION_1_0_0

class bot_dieanotherday(bot_deathmatch):
def __init__(self,parent):
bot_deathmatch.__init__(self,parent)

bot_deathmatch.SetCustomSchedules(self,DADScheduleList)
bot_deathmatch.SetCustomTasks(self,DADTaskList)

def SelectSchedule(self):
return DADScheduleList.BOT_SEEK_RE

#selectedSchedule = bot_deathmatch.SelectSchedule(self)

#GEUtil.Msg("DAD Bot.SelectSchedule()")
#if usingRE:

#botsTeam = self.GetTeamNumber()

#If there is eliminated players in the bot's team, make it use the DAD bot resurrection behaviour:
# if GEMPGameRules.GetNumInRoundTeamPlayers(botsTeam) < GEMPGameRules.GetNumActiveTeamPlayers(botsTeam):
# if selectedSchedule == Sched.BOT_SEEK_ENEMY or Sched.CHASE_ENEMY:
# GEUtil.Msg("\n A \n")
#
# botsTeam = self.GetTeamNumber()
#
# GEUtil.Msg("\n B \n")
#
# botsOpponents = None
# if botsTeam == GEGlobal.TEAM_MI6: botsOpponents = GEGlobal.TEAM_JANUS
# else: botsOpponents = GEGlobal.TEAM_MI6
#
# GEUtil.Msg("\n C \n")
#
# #When the bot's team doesn't out number its enemies team, its goal will be to survive and resurrect its team mates:
# if GEMPGameRules.GetNumInRoundTeamPlayers(botsTeam) <= GEMPGameRules.GetNumInRoundTeamPlayers(botsOpponents): return "BotSeekRE"
## #Else allow the bot to chase an enemy or make it use a SEEK_ENEMY schedule which has been modified to make it use the nearby REs it finds.
## elif selectedSchedule == Sched.BOT_SEEK_ENEMY: return "BotSeekNearbyEnemyAndRE"
#
# return selectedSchedule

#def GatherConditions():
# bot_deathmatch.GatherConditions()

#self.ClearCondition(DAD_CLOSE_TO_RE)

#Condition set check


Ai.Tasks.DADTasks:
Code: [Select]
'''
@author: Joe
@version: Alpha 1.04
'''
from . import PYTask
from GamePlay import DieAnotherDay
from Ai.Tasks import Task
import GEUtil,GEGlobal,GEMPGameRules as GERules

class DADTaskList(Task):
    _module                  = "Ai.Tasks.DADTasks"
   
    TEST_TASK                = "TestTask"
   
class TestTask(PYTask):
    def Start( self, npc, data ):
        GEUtil.Msg("\n*************** DAD Task ***************\n")   
        self.Complete(npc)

#'''
#    This task's code was created by the creator of "CommonTasks.FindEnemy()",
#    I've modified: 1) the last statement 2) the team number condition 3) the radar contact type.
#'''
#class FindNearbyRE(PYTask):
#    def Start( self, npc, data ):
#        range_sort = lambda x, y: x["range"] > y["range"]
#
#        # Grab our contacts from the radar from our perspective and sort by range
#        contacts = [c for c in GERules.GetRadar().ListContactsNear( npc.GetAbsOrigin() ) if c["type"] == GEGlobal.RADAR_TYPE_OBJECTIVE]
#        contacts.sort( range_sort )
#
#        # If we have at least 1 contact, mark him
#        for contact in contacts:
#            if contact["team"] == npc.GetTeamNumber():
#                npc.SetTargetPos( contact["origin"] )
#                self.Complete( npc )
#                return
#           
#        # We didn't find anything
#        self.Fail(npc,"No REs in range")
       
#'''
#    This RE finding task can target distant REs if there are no REs close to the NPC.
#'''
#class FindRE(PYTask):
#    def Start(self,npc,data):
#        RELocation = DieAnotherDay.DieAnotherDay.GetLocationOfRENearestToOrigin(npc.GetTeamNumber(),npc.GetAsbOrigin())
#       
#        if RELocation != None:
#            npc.SetTargetPos(RELocation)
#            self.Complete(npc)
#           
#        # We didn't find anything
#        self.Fail(npc,"No REs found")
   
           

Ai.Schedules.DADSchedules:
Code: [Select]
'''
@author: Joe
@version: Alpha 1.04
'''

from GEAi import ActivityId
from . import PYSchedule, Sched, Cond
from ..Tasks import Task
from Ai.Tasks.DADTasks import DADTaskList
from Ai.Schedules import Sched
import GEUtil,GEAiSched

class DADScheduleList(Sched):
_module = "Ai.Schedules.DADSchedules"

BOT_SEEK_RE = "BotSeekRE"

'''
This schedule's code was created by the creator of "CommonSchedules.BotSeekEnemy", I've only modified two task statements.
'''
class BotSeekRE( PYSchedule ):
def __init__( self ):
PYSchedule.__init__( self )

GEUtil.Msg("\n*************** DAD Schedule init ***************\n")

#TODO remove:
self.AddTask(DADTaskList.TEST_TASK)
self.AddTask( Task.SET_FAIL_SCHEDULE, Sched.BOT_PATROL )
self.AddTask( Task.SET_ROUTE_SEARCH_TIME, 2 )
self.AddTask( Task.SET_TOLERANCE_DISTANCE, 48 )
self.AddTask( Task.GES_FIND_ENEMY )
self.AddTask( Task.GET_PATH_TO_TARGET )
self.AddTask( Task.RUN_PATH_TIMED, 5.0 )

self.AddInterrupt( Cond.NEW_ENEMY )
self.AddInterrupt( Cond.LIGHT_DAMAGE )
self.AddInterrupt( Cond.HEAVY_DAMAGE )
self.AddInterrupt( Cond.HEAR_DANGER )
self.AddInterrupt( Cond.HEAR_COMBAT )
self.AddInterrupt( Cond.GES_CLOSE_TO_ARMOR )

#BotSeekRE
# self.AddTask(Task.SET_ROUTE_SEARCH_TIME,2)
# self.AddTask(Task.SET_TOLERANCE_DISTANCE,48)
# self.AddTask("FindNearbyRE")
# self.AddTask(Task.GET_PATH_TO_TARGET)
# self.AddTask(Task.RUN_PATH_TIMED,5.0)
# self.AddTask("UseRE",5.0)
#
# self.AddInterrupt(Cond.NEW_ENEMY)
# self.AddInterrupt(Cond.LIGHT_DAMAGE)
# self.AddInterrupt(Cond.HEAVY_DAMAGE)
# self.AddInterrupt(Cond.HEAR_DANGER)
# self.AddInterrupt(Cond.HEAR_COMBAT)
# self.AddInterrupt(Cond.GES_CLOSE_TO_ARMOR)

#'''
# This schedule's code was created by the creator of "CommonSchedules.BotSeekEnemy", I've only modified 3 task statements.
#'''
#class BotSeekNearbyEnemyAndRE( PYSchedule ):
# def __init__( self ):
# PYSchedule.__init__( self )
#
# self.AddTask(Task.SET_FAIL_SCHEDULE,"DADBotSeekEnemy")
# self.AddTask(Task.SET_ROUTE_SEARCH_TIME,2)
# self.AddTask(Task.SET_TOLERANCE_DISTANCE,48)
# self.AddTask("FindNearbyRE")
# self.AddTask(Task.GET_PATH_TO_TARGET)
# self.AddTask(Task.RUN_PATH_TIMED,5.0)
# self.AddTask("UseRE",5.0)
#
# self.AddInterrupt(Cond.NEW_ENEMY)
# self.AddInterrupt(Cond.LIGHT_DAMAGE)
# self.AddInterrupt(Cond.HEAVY_DAMAGE)
# self.AddInterrupt(Cond.HEAR_DANGER)
# self.AddInterrupt(Cond.HEAR_COMBAT)
# self.AddInterrupt(Cond.GES_CLOSE_TO_ARMOR)

#'''
# This schedule's code was created by the creator of "CommonSchedules.BotSeekEnemy", I've only modified the second statement.
#'''
#class DADBotSeekEnemy( PYSchedule ):
# def __init__( self ):
# PYSchedule.__init__( self )
#
# self.AddTask( Task.SET_FAIL_SCHEDULE, "DADBotPatrol" )
# self.AddTask( Task.SET_ROUTE_SEARCH_TIME, 2 )
# self.AddTask( Task.SET_TOLERANCE_DISTANCE, 48 )
# self.AddTask( Task.GES_FIND_ENEMY )
# self.AddTask( Task.GET_PATH_TO_TARGET )
# self.AddTask( Task.RUN_PATH_TIMED, 5.0 )
#
# self.AddInterrupt( Cond.NEW_ENEMY )
# self.AddInterrupt( Cond.LIGHT_DAMAGE )
# self.AddInterrupt( Cond.HEAVY_DAMAGE )
# self.AddInterrupt( Cond.HEAR_DANGER )
# self.AddInterrupt( Cond.HEAR_COMBAT )
# self.AddInterrupt( Cond.GES_CLOSE_TO_ARMOR )

#'''
# This schedule's code was created by the creator of "CommonSchedules.BotSeekEnemy", I've only added the last statement.
#'''
#class DADBotPatrol( PYSchedule ):
# def __init__( self ):
# PYSchedule.__init__( self )
#
# self.AddTask( Task.SET_ROUTE_SEARCH_TIME, 2 )
# self.AddTask( Task.GET_PATH_TO_RANDOM_NODE, 2048 )
# self.AddTask( Task.RUN_PATH_WITHIN_DIST, 20 )
# self.AddTask( Task.CLEAR_GOAL )
# self.AddTask( Task.GET_PATH_TO_RANDOM_NODE, 2048 )
# self.AddTask( Task.RUN_PATH_WITHIN_DIST, 20 )
# self.AddTask( Task.WAIT_RANDOM, 1.0 )
#
# self.AddInterrupt( Cond.NO_PRIMARY_AMMO )
# self.AddInterrupt( Cond.HEAR_DANGER )
# self.AddInterrupt( Cond.HEAR_COMBAT )
# self.AddInterrupt( Cond.HEAR_BULLET_IMPACT )
# self.AddInterrupt( Cond.NEW_ENEMY )
# self.AddInterrupt( Cond.SEE_ENEMY )
# self.AddInterrupt( Cond.HEAVY_DAMAGE )
# self.AddInterrupt( Cond.LIGHT_DAMAGE )
# self.AddInterrupt( Cond.GES_CLOSE_TO_ARMOR )
# self.AddInterrupt( Cond.GES_CLOSE_TO_WEAPON )
#
# #self.AddInterrupt( Cond.DAD_CLOSE_TO_RE )




« Last Edit: April 13, 2013, 01:07:28 pm by Joe »
Logged
Free games:FPS + RTS: Renegade X & Battlezone 1.5,RTS: 7 Kingdoms & Open Red Alert, TBS:Hedgewars, playcatan.com & www.wesnoth.org

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: Bot scripting: I've not been able to setup a custom task list
« Reply #1 on: April 13, 2013, 12:48:52 pm »

I've overhauled the way tasks and schedules are defined in 4.2.3. Please hold off on your bot until then. The current implementation is very weak and prone to the error that you are seeing.
Logged

Joe

  • Secret Agent
  • **
  • Posts: 139
  • Reputation Power: 54
  • Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.Joe has an aura about them.
  • Offline Offline
Re: Bot scripting: I've not been able to setup a custom task list
« Reply #2 on: April 13, 2013, 12:57:36 pm »

Thanks KillerMonkey, I will wait until I can use the new bot scripting system.
« Last Edit: April 13, 2013, 01:06:05 pm by Joe »
Logged
Free games:FPS + RTS: Renegade X & Battlezone 1.5,RTS: 7 Kingdoms & Open Red Alert, TBS:Hedgewars, playcatan.com & www.wesnoth.org
Pages: [1]   Go Up