-
- m_node = bill;
-
- updateNodePos();
-}
-
-void MobV2CAO::removeFromScene()
-{
- if(m_node == NULL)
- return;
-
- m_node->drop();
- m_node->remove();
- m_node = NULL;
-}
-
-void MobV2CAO::updateLight(u8 light_at_pos)
-{
- if(m_lock_full_brightness)
- light_at_pos = 15;
-
- m_last_light = light_at_pos;
-
- if(m_node == NULL)
- return;
-
- if(m_damage_visual_timer > 0)
- return;
-
- if(m_shooting && m_bright_shooting)
- return;
-
- /*if(light_at_pos <= 2){
- m_node->setVisible(false);
- return;
- }*/
-
- m_node->setVisible(true);
-
- u8 li = decode_light(light_at_pos);
- video::SColor color(255,li,li,li);
- m_node->setColor(color);
-}
-
-v3s16 MobV2CAO::getLightPosition()
-{
- return floatToInt(m_position+v3f(0,0,0), BS);
-}
-
-void MobV2CAO::updateNodePos()
-{
- if(m_node == NULL)
- return;
-
- m_node->setPosition(pos_translator.vect_show + v3f(0,m_sprite_y,0));
-}
-
-void MobV2CAO::step(float dtime, ClientEnvironment *env)
-{
- scene::MyBillboardSceneNode *bill = m_node;
-
- pos_translator.translate(dtime);
-
- if(m_sprite_type == "humanoid_1"){
- scene::ICameraSceneNode* camera = m_node->getSceneManager()->getActiveCamera();
- v3f cam_to_mob = m_node->getAbsolutePosition() - camera->getAbsolutePosition();
- cam_to_mob.normalize();
- int col = 0;
- if(cam_to_mob.Y > 0.75)
- col = 5;
- else if(cam_to_mob.Y < -0.75)
- col = 4;
- else{
- float mob_dir = atan2(cam_to_mob.Z, cam_to_mob.X) / PI * 180.;
- float dir = mob_dir - m_yaw;
- dir = wrapDegrees_180(dir);
- //infostream<<"id="<<m_id<<" dir="<<dir<<std::endl;
- if(fabs(wrapDegrees_180(dir - 0)) <= 45.1)
- col = 2;
- else if(fabs(wrapDegrees_180(dir - 90)) <= 45.1)
- col = 3;
- else if(fabs(wrapDegrees_180(dir - 180)) <= 45.1)
- col = 0;
- else if(fabs(wrapDegrees_180(dir + 90)) <= 45.1)
- col = 1;
- else
- col = 4;
- }
-
- int row = 0;
- if(m_shooting){
- row = 3;
- } else if(m_walking){
- m_walk_timer += dtime;
- if(m_walk_timer >= 0.5){
- m_walk_frame = (m_walk_frame + 1) % 2;
- m_walk_timer = 0;
- }
- if(m_walk_frame == 0)
- row = 1;
- else
- row = 2;
- }
-
- const float txp = 1./192;
- const float txs = txp*32;
- const float typ = 1./240;
- const float tys = typ*48;
- bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
- bill->setTCoords(1, v2f(txs*(1+col), tys*(0+row)));
- bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
- bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
- } else if(m_sprite_type == "simple"){
- m_walk_timer += dtime;
- if(m_walk_timer >= m_simple_anim_frametime){
- m_walk_frame = (m_walk_frame + 1) % m_simple_anim_frames;
- m_walk_timer = 0;
- }
- int col = 0;
- int row = m_walk_frame;
- const float txs = 1.0;
- const float tys = 1.0 / m_simple_anim_frames;
- bill->setTCoords(0, v2f(txs*(1+col), tys*(1+row)));
- bill->setTCoords(1, v2f(txs*(1+col), tys*(0+row)));
- bill->setTCoords(2, v2f(txs*(0+col), tys*(0+row)));
- bill->setTCoords(3, v2f(txs*(0+col), tys*(1+row)));
- } else {
- infostream<<"MobV2CAO::step(): Unknown sprite type \""
- <<m_sprite_type<<"\""<<std::endl;