Inside3D!
     

having issues making mauvebot work correctly with my mod

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Wed May 13, 2009 8:17 pm    Post subject: having issues making mauvebot work correctly with my mod Reply with quote

ok... iv gotten them to spawn to assigned teams. problem being they always target anything thats alive rather than just their teams. also iv noticed that when i make the game and apply "no team damage" and they attack each other (even though their on other teams) they still cant hurt each other.

here's my qc file...

as you can see iv even tried applying shirt+pants colors still no go.


Code:


/*
MauveBot v2.0 by MauveBib              22/4/09

Installation Instructions:

Add the files mauvebot.qc, dpextensions.qc and sv_user.qc to your mod source directory.
Edit the progs.src file, adding "dpextensions.qc" and "sv_user.qc" (without the quotes) right after "defs.qc". Add "mauvebot.qc" just after "weapons.qc"
Open up client.qc, and scroll to the function PlayerPreThink.
Just before the line "CheckRules ();" add a line saying "MauveBot_AI();"

Compile, run, enjoy. (Darkplaces only)

Impulse 100 spawns a bot, impulse 101 removes one.
*/

float bot_number;
//float visible;
.float ai_time;
float() crandom;

string() bot_name =
{
   if (bot_number == 0)
      return "Fender";   
   if (bot_number == 1)
      return "Coffin";   
   if (bot_number == 2)
      return "Fallout";   
   if (bot_number == 3)
      return "Proteus";   
   if (bot_number == 4)
      return "Inxus";   
   if (bot_number == 5)
      return "Basil";   
   if (bot_number == 6)
      return "Meat";   
   if (bot_number == 7)
      return "Fettid";   
   if (bot_number == 8)
      return "Biggles";   
   if (bot_number == 9)
      return "Crusade";   
   else
      return "Bot";
};

void() add_MauveBot =
{
   local entity oldself;
   local float shirt, pants;
   local string str;

   oldself = self;
   self = spawnclient();
   if (!self)
   {
      bprint("Can not add bot, server full.\n");
      self = oldself;
      return;
   }
   
   if (random() < 0.5)
   {
      self.pteam = QUAKE_SQUAD;
      setmodel (self, "progs/QS.mdl"); //Sets your player model to the Quake Squads.
      PutClientInServer();
   pants = 2;
      shirt = 2;
   bot_number = bot_number + 1;
      
   }
      else
         if (random() >= 0.5)
         {
         self.pteam = MARINE;
              setmodel (self, "progs/Marine.mdl");
            PutClientInServer();
   
   bot_number = bot_number + 1;
             
      
   }
   self.netname = bot_name();
   //shirt = floor(random() * 16);
   //pants = floor(random() * 16);
   self.clientcolors = shirt + pants;
   //ClientConnect();
   
   self = oldself;
};

void() remove_MauveBot =
{
   local float flo, i;
   local entity ent;

   flo = floor(random() * bot_number);
   ent = find(world, classname, "player");
   while(ent)
   {
      if (clienttype(ent) == CLIENTTYPE_BOT)
      {
         if (flo == i)
         {
            dropclient(ent);
            if (bot_number > 0)
               bot_number = bot_number - 1;
            return;
         }
         i = i + 1;
      }
      ent = find(ent, classname, "player");
   }
};

void() Mauve_Impulses =
{
   if (self.impulse == 100)
      add_MauveBot();
   if (self.impulse == 101)
      remove_MauveBot();
};

void() bot_set_angle =
{
   local vector view;
   local float flo;
   local entity ent;

   if (self.goalentity)
      ent = self.goalentity;
   if (self.enemy)
      if (visible(self.enemy))
         ent = self.enemy;
   if (ent != world)
   {
                view = ent.origin;
                if (view == '0 0 0')
                        view = (ent.absmin + ent.absmax) * 0.5;
      if (ent.health)
      {
         view = view - ent.velocity * (0.2);
         flo = vlen(view - self.origin) / 10;
         view_x = view_x + (crandom() * flo);
         view_y = view_y + (crandom() * flo);
         view_z = view_z + (crandom() * flo);
      }
                view = view - (self.origin + self.view_ofs);
                self.angles = vectoangles(view);
      self.v_angle = self.angles;
                self.v_angle_x = self.v_angle_x * -1;
      if (self.angles_x > 180)
         self.angles_x = self.angles_x - 360;
      self.angles_x = self.angles_x / 6;
   }
   else
      self.angles_x = 0;// hack!
};

void() MauveToGoal =
{
   local vector vec, en, diff, dir;

   vec = self.origin;
   movetogoal(32);
   en = self.origin;
   self.origin = vec;
   diff = en - self.origin;
   if (diff == '0 0 0')
      diff = self.goalentity.origin - self.origin;
   dir = normalize(diff);
   dir = dir * cvar("sv_maxspeed");
   makevectors(self.v_angle);
   self.movement_x = dir * v_forward;
   self.movement_y = dir * v_right;
   self.movement_z = dir * v_up;
};

void() look_for_stuff =
{
   local entity item, best, best2, backup;
   local float dist, tdist, dist2;
   
        item = findradius(self.origin, 1000);
   
   if (self.search_time < time)
   {
      
      self.enemy = world;
      self.goalentity = world;
   }
   if (self.enemy.health < 0)
      self.enemy = world;
   if (self.enemy.deadflag)
      self.enemy = world;
   dist = dist2 = 1000;
   while(item)
   {
                if (item.flags & FL_CLIENT)
      {
         if (!(item.flags & FL_NOTARGET))
         if (item != self)
         if ((item.health > 0) && (!item.deadflag))
         if (visible(item))
         {
            tdist = vlen(item.origin - self.origin);
            if (tdist < dist)
            {
               best = item;
               dist = tdist;
            }
         }
      }
           else if (( (item.flags & FL_ITEM) && item.model != string_null) && (item.search_time < time))
      {
         tdist = vlen(item.origin - self.origin);
         if (tdist < dist2)
         {
            if (visible(item))
            {
               best2 = item;
               dist2 = tdist;
            }
            else
               backup = item;
         }
      }
      item = item.chain;
        }
   if ((best != self.enemy) && (best != world))
      self.enemy = best;
   if ((best2 != self.goalentity) && (best2 != world))
   {
      self.goalentity = best2;
      self.search_time = time + 5;
   }
   if (self.goalentity == world)
   {
      if (self.enemy)
         self.goalentity = self.enemy;
      else
         self.goalentity = backup;
      self.search_time = time + 5;
   }
};

void() MauveBot_AI =
{
   if (clienttype(self) != CLIENTTYPE_BOT)
   {
      Mauve_Impulses();
      return;
   }
   self.button0 = 0;
   self.button2 = 0;
   self.button3 = 0;
   self.movement = '0 0 0';
   if (self.deadflag == DEAD_RESPAWNABLE)
   {
      self.button0 = 1;
      return;
   }
   else if (self.deadflag)
      return;
   if (self.goalentity.model == string_null)
      self.goalentity = world;
   if ((vlen(self.goalentity.origin - self.origin) < 50) && (self.goalentity != world))
   {
      self.goalentity.search_time = time + 10;
      self.goalentity = world;
   }
   if (time > self.ai_time)
   {
      self.ai_time = time + random();

      look_for_stuff();
   
      if (self.enemy)
      {
         if (self.search_time == 100000)
            self.search_time = time + 5;
         if (self.goalentity == world)
            self.goalentity = self.enemy;
      }

      if (random() < 0.03)
         self.button2 = 1;
   }
   if (visible(self.enemy))
   {
      self.button0 = 1;
      self.search_time = 100000;
   }
   bot_set_angle();
   if (self.goalentity != world)
      MauveToGoal();
};

_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Wed May 13, 2009 9:45 pm    Post subject: Reply with quote

There is no teamplay check in MauveBot by default, but it's easy to add:

Find this bit of code in look_for_stuff():

Code:

   while(item)
   {
                if (item.flags & FL_CLIENT)
      {
         if (!(item.flags & FL_NOTARGET))
         if (item != self)
         if ((item.health > 0) && (!item.deadflag))
         if (visible(item))
         {
            tdist = vlen(item.origin - self.origin);
            if (tdist < dist)
            {
               best = item;
               dist = tdist;
            }
         }
      }


Replace it with:

Code:

   while(item)
   {
                if (item.flags & FL_CLIENT)
      {
         if (!(item.flags & FL_NOTARGET))
         if (item != self)
         if ((!teamplay) || (item.team != self.team))
         if ((item.health > 0) && (!item.deadflag))
         if (visible(item))
         {
            tdist = vlen(item.origin - self.origin);
            if (tdist < dist)
            {
               best = item;
               dist = tdist;
            }
         }
      }


This is untested but should work.
_________________
Apathy Now!
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Wed May 13, 2009 9:47 pm    Post subject: Reply with quote

k thnx gunna check it out now.

-=edit=-

it works... kinda ... problem being now is the other team gets - points for killing the other team? ( my pant colors = brown other = blue )

oh and the color is set like this.

self.clientcolors = self.pteam;
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri May 15, 2009 12:25 am    Post subject: Reply with quote

im having issues with this really really freakin bad and im close to giving up....

and im actually releasing my source out of frustration...

anyways my problem is that when the bots kill each other they get negative points... anyways...

thnx if anyone can actually help me so luck so far...

http://files.filefront.com/02azip/;13757388;/fileinfo.html
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
avirox



Joined: 16 Aug 2006
Posts: 109

PostPosted: Fri May 15, 2009 12:34 am    Post subject: Reply with quote

Code:

   if (bot_number == 5)
      return "Basil"; 


There's your problem.



Arrow
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Fri May 15, 2009 12:39 am    Post subject: Reply with quote

how's that an issue?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Fri May 15, 2009 1:31 am    Post subject: Reply with quote

I'm guessing it's because you're using self.pteam for the team, whereas the frag code checks self.team, which will be the same for all bots, so it will assume every kill is a teamkill, so every kill will cause a frag to be lost.

You need to either alter the frag code, or set self.team on the bots.
_________________
Apathy Now!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group