About Store Forum Documentation Contact



Post Reply 
Trouble with AI script
Author Message
dbuman Offline
Member

Post: #1
Trouble with AI script
Ive been going over and over this code, but for some reason i cannot get the AI code from bloody massacre to add into my game.

here is the error
c2660 EE::Game:Obj:Obj does not take 1 arguements

this is the line of code that causes the error

if(CChar *name=Game::Objs(op))

I dont know what i'm doing wrong with it

I know that Objs doesnt have a () to look for anything, but the code works in bloody massacre so im missing something. I just dont know what.
06-22-2011 02:36 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Trouble with AI script
if statement needs another = to test for equality.

what is the type of op?

anyways, just read the error. Press ctr+shift+space in VS to read the method's parameter information.
06-22-2011 04:12 AM
Find all posts by this user Quote this message in a reply
dbuman Offline
Member

Post: #3
RE: Trouble with AI script
It did not detail anything specific, and I tried the code with 2 ='s and it came back with an error saying I was supposed to put a comma before the ==
06-22-2011 04:33 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Trouble with AI script
It should be only one =, not two.

Do you have the for statement around it?

Code:
for(Game::ObjParams *op=&obj; op; op=op->base())
{
    if(CChar *name=Game::Objs(op))
    // ...
}

Also, must be in the create method, like:

Code:
void AI::create(Game::ObjParams &obj)

----------

I don't think you really need the for statement, this should work as well:

Code:
if(CChar *name=Game::Objs(obj.base()))
(This post was last modified: 06-22-2011 04:53 AM by Driklyn.)
06-22-2011 04:49 AM
Find all posts by this user Quote this message in a reply
dbuman Offline
Member

Post: #5
RE: Trouble with AI script
I made a custom class for the obj type.

I do have the for statement
Everything about the AI code was copied, except I used the term Mob instead of AI.

Its acting like Objs is not supposed to be Objs().

very weird.

heres the code:

void Mob::create(Game::ObjParams &obj)
{
__super::create(obj);

// detect character type
for(Game::ObjParamsPtr op=&obj; op; op=op->base())
{if(CChar *name == Game::Objs(op))
{if(Contains(name, "Skeleton"))
{
type=AI_SKELETON,
speed=3,
anim.speed=1,
move_walking=true,
ctrl.radius(ctrl.radius()*1.3);

}else
if(Contains(name,"Alien"))
{
type=AI_ALIEN;
}

obj_file_path=GetPath(name);
break;
}}}
(This post was last modified: 06-22-2011 04:57 AM by dbuman.)
06-22-2011 04:51 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: Trouble with AI script
Did you change all the AI:: to Mob:: ?

Like from:
Code:
void AI::create(Game::ObjParams &obj)

To:
Code:
void Mob::create(Game::ObjParams &obj)

Does the code build if you comment out that section of code, or do you get other errors as well?
06-22-2011 04:57 AM
Find all posts by this user Quote this message in a reply
dbuman Offline
Member

Post: #7
RE: Trouble with AI script
The code line that has the error is what determines what type of NPC it is, and it is vital to the functionality of each type.
06-22-2011 05:00 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #8
RE: Trouble with AI script
Yeah, but if it doesn't build with that code commented out, then there's something else wrong.

You keep saying Game::Objs() is acting like there is no Game::Objs() which makes me think maybe you're not including your headers properly or something, since Game::Objs() is valid.

One more thing, you only need one equal sign, not two.
06-22-2011 05:15 AM
Find all posts by this user Quote this message in a reply
dbuman Offline
Member

Post: #9
RE: Trouble with AI script
It says that the code line is 95 in my file, but when i go to it, it is just a }

If you guys are good at noticing errors in coding, let me know if you see any red flags in this:

Mind ive edited a bunch so there are comments all over the place with no code attached.
Code:
enum AI_TYPE
{
   AI_DEFAULT,
   AI_ZOMBIE ,
   AI_ZARD   ,
   AI_ALIEN  ,
};
class Mob : Game::Chr // define Player class based on Game.Chr
{
   int health =100;
   Bool  alive     () {return _alive                  ;}
   void alive(Bool on                               );
    Byte           type; // AI_TYPE
   int
       Strength2=10,
       Dexterity2=10,
       Agility2=10 ,
       Vitality2=10,
       Intelligence2=10 ,
       Wisdom2=10 ,
       attack_speed2=1 ,
       Defense2=10 ,
       Attack2=10 ,
       Move_speed2=1 ,
       dodge_speed2=1 ,
       Strength=10 + Strength2,
       Dexterity=10 + Dexterity2,
       Agility=10 + Agility2,
       Vitality=10 + Vitality2,
       Intelligence=10 + Intelligence2,
       Wisdom=10 + Wisdom2,
       attack_speed=1 + attack_speed2,
       Defense=10 + Defense2,
       Attack=10 + Attack2,
       Move_speed1=1 + Move_speed2,
       dodge_speed=1 + dodge_speed2,
       mob_backside=0,
      
       Skillpoints=0,
       Statpoints=0,
       level=1;
    Str Battle_role= "Balanced";
        
      
      
   // update / draw
  
   Vec ctrl_center;
   // get / set
    Flt            time_to_random_animation,
                  time_to_random_move,
                  time_to_sense,
                  time_to_update_action,
                  time_to_attack;
   Str             obj_file_path;
   Memb<Motion>     idle_motions, // container for idle   motion animations
                  attack_motions; // container for attack motion animations
   Reference<Chr> target;         // target enemy

   // manage
           void setNonSavedParams();
   virtual void create           (Game::ObjParams &obj);

   // get
   virtual Bool  inAttackRange(Chr &chr);

   // operations
   virtual void attack (Chr &target);
   virtual void hit    ();
   virtual void moveTo (C Vec &pos);
   virtual void animate();
   virtual Bool update ();

   // io
   virtual void save(File &f);
   virtual Bool load(File &f);

   virtual void linkReferences();
   Flt damage_time;
   virtual uint drawPrepare();

   Mob();

  

void addDamage(Flt damage,Chr Player)
{
   damage = (Mob.Attack + ((Mob.Strength + (Mob.Agility / 2)) /2));
   if(alive())
   damage_time=1,
   health -= damage;
   if(health <= 0)
   health = 0;

}

  
private:
   Bool _alive;
};
/******************************************************************************/
Mob::Mob()
{
   type=AI_DEFAULT;
   time_to_random_animation=RandomF(10,15);
   time_to_random_move     =RandomF( 5,10);
   time_to_sense=0;
   time_to_update_action=0;
   time_to_attack=0;
}
void Mob.create(Game.ObjParams &obj)
{
super.create(obj);

// detect character type
   for(Game::ObjParamsPtr op=&obj; op; op=op->base())
      if(CChar *name=Game::Objs(op))
   {
      if(Contains(name,"Zard"))
      {
         type=AI_ZARD;
         speed=6;
         ctrl.radius(ctrl.radius()*1.6);
     }else
     if(Contains(name,"Zombie"))
     {
         type=AI_ZOMBIE;
         speed=6;
         anim.speed=1;
         move_walking=true;
        ctrl.radius(ctrl.radius()*1.3);
      }else
     if(Contains(name,"Alien"))
     {
         type=AI_ALIEN;
      }

      obj_file_path=GetPath(name);
      break;
   }

   setNonSavedParams();
}
void Mob.setNonSavedParams()
{
   // replace default animations
   switch(type)
   {
      case AI_ZARD:
         sac.stand=&cskel.getSkelAnim(obj_file_path+"/idle.anim");
         sac.run  =&cskel.getSkelAnim(obj_file_path+ "/run.anim");
      break;

      case AI_ZOMBIE:
         sac.stand=&cskel.getSkelAnim(obj_file_path+"/idle.anim");
         sac.walk =&cskel.getSkelAnim(obj_file_path+"/walk.anim");
      break;
   }

   // disable turning animations
   sac.turn_l=NULL;
   sac.turn_r=NULL;
}
Bool Mob.inAttackRange(Chr &chr)
{
   return Dist(pos(),chr.pos()) <= ctrl.radius()+chr.ctrl.radius()+0.6;
}
/******************************************************************************/
// OPERATIONS
/******************************************************************************/
void Mob.attack(Chr &target)
{
   T.target=target;
   time_to_update_action=0;
}
/******************************************************************************/
void Mob.hit()
{
   Vec dir; SinCos(dir.z,dir.x,angle.x+PI_2); dir.y=0; // get AI looking direction

   // check all the players
   REPA(Players)
   {
      Player &plr=Players[i];
      if(inAttackRange(plr))
         if(AbsAngleBetween(dir,plr.pos()-pos())<=PI_3) // 60 degrees
            plr.addDamage(RandomF(5,8),T);
   }
}
/******************************************************************************/
void Mob.moveTo(C Vec &pos)
{
   // first try finding path directly to 'pos' location
   // if it fails try finding path to positions near 'pos'

   if(!actionMoveTo(pos))
   {
      for(Int r= 1; r<=3; r++) // radius
      for(Int x=-1; x<=1; x++) // x offset
      for(Int z=-1; z<=1; z++) // z offset
         if(x || z)
            if(actionMoveTo(pos+Vec(x,0,z)*(r*0.6f)))return;
   }
}
/******************************************************************************/
void Mob.animate()
{
   __super.animate();

   REPA(  idle_motions)cskel.animate(  idle_motions[i],true); // apply idle   animations
   REPA(attack_motions)cskel.animate(attack_motions[i],true); // apply attack animations
}
/******************************************************************************/

bool Mob :: update()
  {
  
   if(Game::World.waterUnder(pos()))
{
    ctrl.flying(true);
    flying_speed= 2.1;
    ctrl.actor.gravity(false);
}

/******************************************************************************/

/******************************************************************************/

/******************************************************************************/

else
{
    ctrl.flying(false);
    flying_speed=8;
    ctrl.actor.gravity(true);
}



   return super.update();

}
/******************************************************************************/
uint Mob.drawPrepare()
{
   bool hide_head=(View==VIEW_FPP && !Renderer.mirror() && mesh);
   if(  hide_head)mesh->hide(8"head"); uint modes=super.drawPrepare();
   if(  hide_head)mesh->show(8"head");
  
  
   return modes;
}

Here is the full error when building in EE

Code:
F:\WIPgame\_C++ Build_\Application\Project.vcxproj : warning  : Platform 'x64' referenced in the project file 'Application' cannot be found. Please make sure you have it installed under '%VCTargetsPath%\Platforms\x64'.

1>------ Build started: Project: Application, Configuration: Debug Win32 ------
1>  Mobs.cpp
1>f:\wipgame\_c++ build_\application\source\mobs.cpp(95): error C2660: 'EE::Game::Obj::Obj' : function does not take 1 arguments
1>          This diagnostic occurred in the compiler generated function 'EE::Game::Chr::Chr(EE::Game::Chr &)'
1>f:\wipgame\_c++ build_\application\source\mobs.cpp(95): error C2558: struct 'EE::CSkeleton' : no copy constructor available or copy constructor is declared 'explicit'
1>          This diagnostic occurred in the compiler generated function 'EE::Game::Chr::Chr(EE::Game::Chr &)'
1>f:\wipgame\_c++ build_\application\source\mobs.cpp(95): error C2558: struct 'EE::Grab' : no copy constructor available or copy constructor is declared 'explicit'
1>          This diagnostic occurred in the compiler generated function 'EE::Game::Chr::Chr(EE::Game::Chr &)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
(This post was last modified: 06-22-2011 05:23 PM by dbuman.)
06-22-2011 05:20 PM
Find all posts by this user Quote this message in a reply
Post Reply