Example #1
0
Weapon* Weapon::create(CannonType type)
{
    Weapon* weapon = new Weapon();
    weapon->init(type);
    weapon->autorelease();
    return weapon;
}
Example #2
0
void Orc::init() {
    
    data.strength = 7;
    data.dexterity = 15;
    data.constitution = 9;
    data.intelligence = 8;
    data.wisdom = 7;
    data.charisma = 8;
    data.attackSpeed = 100;
    data.movementSpeed = 150;
    
    data.tohit = 4;
    
    // Orcs need weapons too!
    
    Weapon * weapon = static_cast<Weapon*>(Object::create(Object::Falchion));
    weapon->init();
    weapon->z = VOID_LOCATION; // it's not on a map, it only exists abstractly as the Orc has no dedicated inventory
    data.meleeGuid = weapon->guid;
    
    ofLog() << "Orc initted with falchion id: " << data.meleeGuid;
    
    // hit dice 1d8
    data.maxhp = data.hp = (int)ofRandom(8)+1;
    

};
Example #3
0
Weapon* Weapon::create( Node* pl )
{
	Weapon* wp = new (std::nothrow) Weapon;
	if (wp && wp->init())
	{
		wp->m_CreateType = CreateType::Native;
		wp->autorelease();
		wp->setWeaponParent(pl);
		return wp;
	}
	else
	{
		CC_SAFE_DELETE(wp);
		return nullptr;
	}
}
Example #4
0
Weapon* Weapon::createByConfig( Node* pl, WeaponDelegate config )
{
	Weapon* wp = new (std::nothrow) Weapon;
	if (wp && wp->init())
	{
		wp->m_CreateType = CreateType::Config;
		wp->autorelease();
		wp->initWeaponWithConfig(config);
		wp->setWeaponParent(pl);
		return wp;
	}
	else
	{
		CC_SAFE_DELETE(wp);
		return nullptr;
	}
}