Sign in to follow this  
Kobaltic

Declaring a map object

Recommended Posts

I am trying to declare an object (ball) so that either team can pick up the ball. I am modding existing code and I am stuck. If you look at the code below you will see that there are 2 balls one for each team. I want there to be only 1 ball that both teams use. I do not know how to declare it since it is declared by which team the ball is for. Any help would be great. If more code is needed let me know here is the header info:
class RB_RBTeam : public RB_Team
{
public:
   RB_RBTeam();
   void onBeginRound();
   void setDroppedController(RB_ItemControllerAPI & icapi);
   bool updateTrackedballs();
   void releaseControllers();
   void makeballAvailable();
   bool availableball();
   RB_MenuPageAPI& getballIndicatorPage();
   
   std::string             ball_name;
   std::string             enemy_ball_name;
   std::string             endzone_name;
   std::string             enemy_endzone_name;
   
   bool                    track_dropped_controller;
   RB_ItemControllerAPI  ball_controller;
   RB_ItemControllerAPI  dropped_ball_controller;
	
};
here is the .cpp file info:
RB_RBMode::RB_RBMode()
{
   shortID = "RB";
   mode_index=MODE_RB;
   // create the two teams
   _teams[0] = new RB_RBTeam;
   _teams[1] = new RB_RBTeam;
   getTeam(1)->team_name=TEAM_NAMES[0];     // Definable?
   getTeam(2)->team_name=TEAM_NAMES[1];
   getTeam(1)->team=1;
   getTeam(2)->team=2;
   getTeam(1)->ball_name=("ball1");
   getTeam(1)->enemy_ball_name=("ball2");
   getTeam(2)->ball_name=("ball2");
   getTeam(2)->enemy_ball_name=("ball1");


    onInterfaceLoaded();

Share this post


Link to post
Share on other sites
Another option is to have a static ball object. This way there is only one instance of object when it's referenced by other objects.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this