Esempio n. 1
0
//------------------------------------------------------------------------------
void Tank::init()
{
    loadParameters(CONFIG_PATH + "tanks.xml");
    loadParameters(CONFIG_PATH + "tanks.xml", name_); // XXXX replace this by include directive

    setHitpoints(max_hitpoints_);

    initializeTurret();
    initializeWheels();

    Controllable::init();
}
Esempio n. 2
0
void cNPC::applyDefinition( const cElement *sectionNode )
{
	cBaseChar::applyDefinition( sectionNode );

	// Let's try to assume some unspecified values
	if ( this->strength() && !this->hitpoints() ) // we don't want to instantly die, right?
	{
		if ( !this->maxHitpoints() )
			setMaxHitpoints( strength() );
		setHitpoints( maxHitpoints() );
	}
}
Esempio n. 3
0
/**
 *  Used as substitute for "event-driven" parameter loading
 */
void Tank::parameterLoadCallback(const std::string & key,
                                 const std::string & value)
{
    if (key == "tank.weapon_slot" && getLocation() != CL_REPLAY_SIM)
    {
        std::vector<std::string> slot_info = params_.get<std::vector<std::string> >(key);

        if (slot_info.size() != 3)
        {
            Exception e;
            e << "Incorrect weapon slot format :"
              << key
              << ": "
              << value;
            throw e;
        }
        
        unsigned slot = fromString<unsigned>(slot_info[0]);
        if (slot >= NUM_WEAPON_SLOTS)
        {
            Exception e;
            e << "Incorrect weapon slot: "
              << slot;
            throw e;
        }

        std::string full_weapon_name = slot_info[1];
        std::string section          = slot_info[2];

#ifdef DEDICATED_SERVER
        full_weapon_name += "Server";
#else
        if (getLocation() == CL_SERVER_SIDE)
        {
            full_weapon_name += "Server";
        } else
        {
            full_weapon_name += "Client";
        }
#endif

        // Replace weapon system if neccessary
        if (!weapon_system_[slot] ||
            full_weapon_name != weapon_system_[slot]->getType() ||
            section          != weapon_system_[slot]->getSection())
        {
            delete weapon_system_[slot];
            weapon_system_[slot] = NULL;

            try
            {
                weapon_system_[slot] = s_weapon_system_loader.create(full_weapon_name);
            } catch (Exception & e)
            {
                s_log << Log::error
                      << e
                      << "\n";
            }
        }

        // now load the new section
        if (weapon_system_[slot]) weapon_system_[slot]->init(this, section);
        
    } else if (key == "tank.delta_max_speed")
    {
        max_speed_ += params_.get<float>(key);
    } else if (key == "tank.delta_max_hitpoints")
    {
        int delta = params_.get<int>(key);
        max_hitpoints_ += delta;
        setHitpoints(max_hitpoints_);
    }
}
Esempio n. 4
0
 demon::demon(int newStrength, int newHitpoints)
 {
     setStrength(newStrength);
     setHitpoints(newHitpoints);
 }
Esempio n. 5
0
 demon::demon()
 {
     setStrength(10);
     setHitpoints(10);
 }