Beispiel #1
0
void Map::load(TCODZip &zip) {
  seed=zip.getInt();
  init(false);
  for (int i=0; i < width*height; i++) {
    tiles[i].explored=zip.getInt();
  }
}
Beispiel #2
0
void Engine::load()
{
	TCODZip zip;
	zip.loadFromFile("game.sav");
	//load the map
	int width=zip.getInt();
	int height=zip.getInt();
	map = new Map(width,height);
	map->load(zip);
	//then the player
	player=new Actor(0,0,0,NULL,TCODColor::white);
	player->load(zip);
	map->actors.push(player);
	// the stairs
	stairs=new Actor(0,0,0,NULL,TCODColor::white);
	stairs->load(zip);
	map->actors.push(stairs);
	map->sendToBack(stairs);
	//then all other actors
	int nbActors=zip.getInt();
	while (nbActors > 0)
	{
		Actor *actor = new Actor(0,0,0,NULL,TCODColor::white);
		actor->load(zip);
		map->actors.push(actor);
		map->sendToBack(actor);
		nbActors--;
	}
	//finally the message log
	topGui->load(zip);
}
Beispiel #3
0
void Confuser::load(TCODZip &zip) {
	nbTurns = zip.getInt();
	range = zip.getFloat();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
}
Beispiel #4
0
void Poison::load(TCODZip &zip) {
	tick = zip.getFloat();
	duration = zip.getInt();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
}
Beispiel #5
0
void LightningBolt::load(TCODZip &zip) {
	range = zip.getFloat();
	damage = zip.getFloat();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
}
Beispiel #6
0
void Engine::load(){
  if ( TCODSystem::fileExists("game.sav")) {
    TCODZip zip;
    zip.loadFromFile("game.sav");
    //load map
    int width = zip.getInt();
    int height = zip.getInt();
    map = new Map(width,height);
    map->load(zip);
    //Player
    player = new Actor(0,0,0,NULL,TCODColor::white);
    player->load(zip);
    actors.push(player);
    //All other Actors
    int nbActors=zip.getInt();
    while (nbActors > 0) {
      Actor *actor = new Actor(0,0,0,NULL,TCODColor::white);
      actor->load(zip);
      actors.push(actor);
      nbActors--;
    }
    //Last - Logs
    gui->load(zip);
  } else {
    engine.init();
  }
}
Beispiel #7
0
void Map::Load(TCODZip &zip)
{
    seed_=zip.getInt();
    Init(false);
    for (int32_t i = 0; i < width_ * height_; i++) {
        tiles_[i].explored_ = zip.getInt();
    }
}
void Destructible::load(TCODZip &zip) {
	maxHp = zip.getFloat();
	hp = zip.getFloat();
	defense = zip.getFloat();
	corpseName = _strdup(zip.getString());
	maxAp = zip.getInt();
	ap = zip.getInt();
}
Beispiel #9
0
void Fireball::load(TCODZip &zip) {
	range = zip.getFloat();
	aoe = zip.getFloat();
	damage = zip.getFloat();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
}
void
Map::Load(TCODZip& zip) {
    seed = zip.getInt();

    Init(false);

    for(int i = 0; i < width * height; ++i) {
        tiles[i].explored = (zip.getInt() != 0);
    }
}
Beispiel #11
0
void Container::Load(TCODZip &zip)
{
    size_ = zip.getInt();
    int32_t nbActors = zip.getInt();
    while (nbActors > 0) {
        Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white);
        actor->Load(zip);
        inventory.push(actor);
        nbActors--;
    }
}
void Pickable::load(TCODZip &zip){
    bool hasTargetSelector = zip.getInt();
    bool hasEffect = zip.getInt();
    if(hasTargetSelector){
        selector = new TargetSelector(TargetSelector::CLOSEST_MONSTER,0);
        selector->load(zip);
    }
    if(hasEffect){
        effect = Effect::create(zip);
    }
}
void
Actor::Load(TCODZip& zip) {
    x = zip.getInt();
    y = zip.getInt();

    code = zip.getInt();
    color = zip.getColor();

    name = _strdup(zip.getString());

	blocks = zip.getInt() != 0;
	fovOnly = zip.getInt() != 0;

	bool hasDestructible = (zip.getInt() != 0);
	bool hasAi = (zip.getInt() != 0);
	bool hasPickable = (zip.getInt() != 0);
	bool hasContainer = (zip.getInt() != 0);

    if(hasDestructible) {
        destructible = Destructible::Create(zip);
    }

    if(hasAi) {
        ai = Ai::Create(zip);
    }

    if(hasPickable) {
        pickable = Pickable::Create(zip);
    }

    if(hasContainer) {
        container = new Container(0);
        container->Load(zip);
    }
}
void
Container::Load(TCODZip& zip) {
    size = zip.getInt();
    int numberOfallActors = zip.getInt();

    while(numberOfallActors > 0) {
        Actor* actor = new Actor(0, 0);
        actor->Load(zip);

        inventory.push(actor);

        numberOfallActors--;
    }
}
Beispiel #15
0
void Actor::Load(TCODZip &zip)
{
    x_ = zip.getInt();
    y_ = zip.getInt();
    ch_ = zip.getInt();
    col_ = zip.getColor();
    name_ = strdup(zip.getString());
    blocks_ = zip.getInt();
    bool hasAttacker = zip.getInt();
    bool hasDestructible = zip.getInt();
    bool hasAi = zip.getInt();
    bool hasPickable = zip.getInt();
    bool hasContainer = zip.getInt();
    if (hasAttacker) {
        attacker_ = new Attacker(0.0f);
        attacker_->Load(zip);
    }
    if (hasDestructible) {
        destructible_ = Destructible::Create(zip);
    }
    if (hasAi) {
        ai_ = Ai::Create(zip);
    }
    if (hasPickable) {
        pickable_ = Pickable::Create(zip);
    }
    if (hasContainer) {
        container_ = new Container(0);
        container_->Load(zip);
    }
}
Beispiel #16
0
void Actor::load(TCODZip &zip) {
	x = zip.getInt();
	y = zip.getInt();
	ch = zip.getInt();
	col= zip.getColor();
	name = strdup(zip.getString());
	blocks = zip.getInt();
	bool hasAttacker = zip.getInt();
	bool hasDestructible = zip.getInt();
	bool hasAi = zip.getInt();
	bool hasPickable = zip.getInt();
	bool hasContainer = zip.getInt();
	
	if (hasAttacker) {
		attacker = new Attacker(0.0f);
		attacker->load(zip);
	}
	if (hasDestructible) {
		destructible = Destructible::create(zip);
	}
	if (hasAi) {
		ai = Ai::create(zip);
	}
	if (hasPickable) {
		pickable = Pickable::create(zip);
	}
	if (hasContainer) {
		container = new Container(0);
		container->load(zip);
	}
}
Beispiel #17
0
void Map::load(TCODZip &zip, NodeType type){
    seed = zip.getInt();
    init(false);
    for(int i = 0; i < width * height; i++){
        tiles[i].explored = zip.getInt();
        //tiles[i].walkable = zip.getInt();
        //tiles[i].inFOV = zip.getInt();
    }

    int nbActors = zip.getInt();
    while(nbActors > 0){
        Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white);
        actor->load(zip);
        actors.push(actor);
        nbActors--;
    }

    bool hasNextLevel = zip.getInt();
    bool hasPrevLevel = zip.getInt();

    if(hasNextLevel && (type == ROOT || type == BELOW_ROOT)){
        int newWidth = zip.getInt();
        int newHeight = zip.getInt();
        nextLevel = new Map(newWidth, newHeight, NULL, this);
        nextLevel->load(zip, BELOW_ROOT);
    }
    if(hasPrevLevel && (type == ROOT || type == ABOVE_ROOT)){
        int newWidth = zip.getInt();
        int newHeight = zip.getInt();
        prevLevel = new Map(newWidth, newHeight, this, NULL);
        prevLevel->load(zip, ABOVE_ROOT);
    }
}
Beispiel #18
0
void clBuilding::Load(TCODZip &file,VecLoad &bonusdata)
{
     mytile=GetFromLoad(file.getInt(),bonusdata);
    if(mytile==NULL)
        throw "Error loading file";
    int bid=file.getInt();
    t=BTManager::Get().GetTemplate((BuildingID)bid);
    if(t==NULL)
        throw "Error loading building template";
    mypic=file.getInt();
    data=file.getInt();
    int matid=file.getInt();
    mat=MaterialManager::Get().GetMaterial(MATT_ALL,matid);
}
void Destructible::load(TCODZip &zip)
{
    maxHp = zip.getFloat();
    hp = zip.getFloat();
    defense = zip.getFloat();
    isImmortal = zip.getInt();
    corpseName = strdup(zip.getString());
}
Beispiel #20
0
void Destructible::load(TCODZip &zip) {
	maxHp = zip.getFloat();
	hp = zip.getFloat();
	baseDefense = zip.getFloat();
	totalDefense = zip.getFloat();
	corpseName = strdup(zip.getString());
	xp = zip.getInt();
}
Beispiel #21
0
void Engine::Load(void)
{
    engine.gui_->menu_.Clear();
    engine.gui_->menu_.AddItem(Menu::NEW_GAME, "New game");
    if (TCODSystem::fileExists("game.sav")) {
        engine.gui_->menu_.AddItem(Menu::CONTINUE, "Continue");
    }
    engine.gui_->menu_.AddItem(Menu::EXIT, "Exit");

    Menu::MenuItemCode menuItem = engine.gui_->menu_.Pick();
    if ((menuItem == Menu::EXIT) || (menuItem == Menu::NONE )) {
        // Exit or window closed
        exit(0);
    } else if (menuItem == Menu::NEW_GAME) {
        // New game
        engine.Term();
        engine.Init();
    } else {
        TCODZip zip;
        // continue a saved game
        engine.Term();
        zip.loadFromFile("game.sav");
        // load the map
        int32_t width = zip.getInt();
        int32_t height = zip.getInt();
        map_ = new Map(width, height);
        map_->Load(zip);
        // then the player
        player_ = new Actor(0, 0, 0, NULL, TCODColor::white);
        actors_.push(player_);
        player_->Load(zip);
        // then all other actors
        int32_t nbActors = zip.getInt();
        while (nbActors > 0) {
            Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white);
            actor->Load(zip);
            actors_.push(actor);
            nbActors--;
        }
        // finally the message log
        gui_->Load(zip);
        // to force FOV recomputation
        gameStatus = STARTUP;
    }
}
Beispiel #22
0
void Gui::load(TCODZip &zip) {
	int nbMessages = zip.getInt();
	while (nbMessages > 0) {
		const char *text = zip.getString();
		TCODColor col = zip.getColor();
		message(col,text);
		nbMessages--;
	}
}
Beispiel #23
0
void Weapon::load(TCODZip &zip) {
	equipped = zip.getInt();
	slot = (SlotType)zip.getInt();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
	int numBonus = zip.getInt();
	for(int i = 0; i < numBonus; i++){
		ItemBonus *bon = new ItemBonus(ItemBonus::NOBONUS,0);
		bon->load(zip);
		bonus.push(bon);
	}
	ItemReq *req = new ItemReq(ItemReq::NOREQ,0);
	req->load(zip);
	requirement = req;
	diceNum = zip.getInt();
	diceType = zip.getInt();
	critMult = zip.getInt();
	critRange = zip.getInt();
	wType = (WeaponType)zip.getInt();
}
void
Gui::Load(TCODZip& zip) {
    int numberOfMessages = zip.getInt();

    while(numberOfMessages > 0) {
        char* text = (char*)zip.getString();
        TCODColor color = zip.getColor();

        Message(color, text);

        numberOfMessages--;
    }
}
Beispiel #25
0
void DamagingAura::load(TCODZip &zip){
	totalDuration = zip.getInt();
	duration = zip.getInt();
	bonus = zip.getInt();
	life = (LifeStyle)zip.getInt();
	radius = zip.getInt();
	smart = zip.getInt();
}
Beispiel #26
0
void Equipment::load(TCODZip &zip) {
	equipped = zip.getInt();
	slot = (SlotType)zip.getInt();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
	int nbBonus = zip.getInt();
	for (int i = 0; i <nbBonus; i++) {
		ItemBonus *bon = new ItemBonus(ItemBonus::NOBONUS,0);
		bon->load(zip);
		bonus.push(bon);
	}
	ItemReq *req = new ItemReq(ItemReq::NOREQ,0);
	req->load(zip);
	requirement = req;
}
Beispiel #27
0
void ConfusedMonsterAi::load(TCODZip &zip) {
	nbTurns = zip.getInt();
	oldAi = Ai::create(zip);
}
Beispiel #28
0
void MonsterAi::load(TCODZip &zip) {
	moveCount = zip.getInt();
}
Beispiel #29
0
void Confuser::Load(TCODZip &zip)
{
    nbTurns_ = zip.getInt();
    range_ = zip.getFloat();
}
Beispiel #30
0
void Aura::load(TCODZip &zip) {
	totalDuration = zip.getInt();
	duration = zip.getInt();
	bonus = zip.getInt();
	life = (LifeStyle)zip.getInt();
}