About Store Forum Documentation Contact
Donations:
327$/mo



Post Reply 
ai attack
Author Message
1991mirec Offline
Member

Post: #1
ai attack
hi

I am trying to get a attack function to work but it doesn t. it worked while we had it set for a client but it doesn t work any more when we set it to server.

ai is created like this

Code:
ai.New().spawn(name, obj, id, Pos);

Code:
void AI::spawn(Str name, Game.ObjParamsPtr &obj, Int id, Vec pos)
   {

      super.create(*Game.Objs(obj.id())); //Create the object.
and its container is
Code:
Memc<AI> ai;

and here is the attack function

Code:
if(Cur.obj.valid() && Players.elms() && Ms.bd(0))    // attack when double clicked and object is valid
            {
               if(Chr *chr=CAST(Chr, &Cur.obj()))Players[0].actionAttack(*chr);  
            }

Code:
virtual void actionAttack(Chr &chr) // set action to attack character
   {
      actionBreak();
      
      action_target=chr;
      action=ACTION_ATTACK;
   }

it loads the game fine ai is there and everything works fine until attack ai. then it crashes. i figured that if i change container from memc to memx it works but it doesnt do anything at all at least game doesn t crash. i looked at the others. how they are made and i found that their cntainer is Game.ObjMemx so i think it might be that but if i use it , it doesn t compile because Game.ObjMemx is without control of manual adding. so i can t use new().

maybe i m wrong and it is something else. please help I m begginer and i am still learning so if you have any ideas please help. thank you in advance
07-27-2013 05:59 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #2
RE: ai attack
Try using Memb instead.
Memx and ObjMemx is different from eachother.

ObjMemx is for world container objects(objects loaded with the world from the editor or created through Game::World.objCreate or Game::World.objCreateNear
07-27-2013 07:05 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #3
RE: ai attack
hi..thank you for replay.. well,,, it does the same thing as memx... game doesnt crash when i attack but it doesn t attack ai at all either...
07-28-2013 11:49 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #4
RE: ai attack
Not sure about all of your code, but most likely you need to check actionAttack.
07-28-2013 12:03 PM
Find all posts by this user Quote this message in a reply
1991mirec Offline
Member

Post: #5
RE: ai attack
never mind .. i figured it out.. thank you for your help anyway
07-29-2013 11:42 AM
Find all posts by this user Quote this message in a reply
Post Reply