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.)
|