About Store Forum Documentation Contact



Post Reply 
Base on Game::Chr doesn't work
Author Message
Puffra Offline
Member

Post: #1
Base on Game::Chr doesn't work
Recently we got caused to trouble by esenthels new updates.. now i have no idea what went wrong,
what i'm trying to do is a base STRUCT, with Game::Chr, to base some simple mobs on, before it worked, the mobs were moving with actionMoveTo(Vec(0,0,0));, Now... Nothing interesting happens..

Is there something wrong with my code?

//Monster.h
Code:
STRUCT (Monsters, Game::Chr)
//{
    Bool guard1;
    Str name ;
    virtual void create(Game::ObjParams &monster);
    virtual Bool update();
    virtual void save(File &f);
    virtual Bool load(File &f);
    Monsters();
};

//Monster.cpp
Code:
Monsters::Monsters()
{
}

void Monsters::create(Game::ObjParams &monster)
{
    super::create(monster);
    Bool guard=false; // set base false
    guard1=false;
    if(Param *par=guards.findParam("name" ))
         name =par->asText(); // Get name for visual testing

     for(Game::ObjParamsPtr cur=&monster; cur; cur=cur->base())
         if(CChar *monster1=Game::Objs.name(cur))
         {
            if(Contains(monster1, "Monster"))
            {
             guard=true; //monster is now found, so turn Guard to true,
             guard1=true; //Guard1 made true,
            }
         }

    if(guard)//Set animations for it
    {
        sac.run=&cskel.getSkelAnim("");
        sac.walk=&cskel.getSkelAnim("");
        sac.stand=&cskel.getSkelAnim("");
        speed=10;
    }
    move_walking=true;
}

Bool Monsters::update(){

   if(super::update())
   {
    if(!action) // if not performing any action
    {
        actionMoveTo(Plr->pos()); // Make it move to player position
        ragdollEnable();// Test if the base even works, if you can run through it, success.
    }
    return true;
   }
   return false;
}
    
void Monsters::save(File &f)
{
   super::save(f); // default save

   f.putStr(name); // save custom parameters
}

Bool Monsters::load(File &f)
{
   if(super::load(f)) // if default load was successful
   {
      f.getStr(name); // load custom parameters
      return true;    // return success
   }
   return false; // return failure
}

//Game.cpp
Code:
Game::ObjMemx<Monsters      > Chrs;

      Game::World.init()
          .setObjType(Chrs, OBJ_CHR)

//Draw the name

   FREPA(Chrs)
   {
    if(Dist(Plr->pos(),Chrs[i].pos())<D.viewRange()/4)
    {
            TextDS NPCRED, NPCTITLE;
            NPCTITLE.color = YELLOW;
            NPCTITLE.scale /= 1.5;
                NPCRED.color = CYAN;
                NPCRED.scale /= 1.5;
                Monsters  &Mob=Chrs[i];        

              Vec2 screen;
        if(PosToScreen (Mob.pos()+Vec(-0.1,4,0), screen))
        {  
            D.text(NPCTITLE, screen, Mob.Title);
        }

    if(PosToScreen (Mob.pos()+Vec(-0.1,3.5,0), screen))
    {
            D.text(NPCRED, screen, Mob.name);
    }
      }
   }

I appreciate that you read through this, and i hope you have an answer with me.. The code is 100% working, i just don't know why it doesn't move with actionMoveTo, and doesn't play stand animation either..

I tried enabling the ragdoll, and that seemed to work, then i could run through it.. i tried to change position of it manually and that worked..

Please help me!
05-06-2012 06:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Base on Game::Chr doesn't work
what new updates do you mean?
which SDK are you using now, and which were you using before?

some months ago the pathfinding was changed to recast, but if you check the tutorial codes for pathfinding then they work ok

pathfinding is done based on pathmeshes generated from physical bodies from world editor (check the tuts)

replace:
=&cskel.getSkelAnim(""); -> =NULL

how you want to play the anim if it's empty?
sac.stand=&cskel.getSkelAnim("");

if you enable ragdoll "ragdollEnable();" every frame then the character is assumed dead and will not move
05-10-2012 06:10 AM
Find all posts by this user Quote this message in a reply
Post Reply