示例#1
0
/* potion of healing */
void i_heal(pob o)
{
    if (o->blessing > -1) {
        Objects[o->id].known = 1;
        heal(1+o->plus);
    }
    else heal(-1-abs(o->plus));
}
示例#2
0
文件: B.cpp 项目: FlowInWind/learngit
void skill()
{
	int c,i;
	printf("Choose skills\n");
	if (al[0]) printf("1:get %d damage.CD:%d turns(%d level now)\n",(int)b[0],k[0],al[0]);
	if (al[1]) printf("2:heal you %d health.CD:%d turns(%d level now)\n",(int)b[1],k[1],al[1]);
	if (al[2]) printf("3:(passive)increase your chance to avoid enemy's attack by %d percent(%d level now)\n",(int)b[2],al[2]);
	if (al[3]) printf("4:get %d more attacks in a time.CD:%d turns(%d level now)\n",(int)b[3],k[3],al[3]);
	if (al[4]) printf("5:get %d damage and heal you 50 per cent.CD:%d turns(%d level now)\n",(int)b[4],k[4],al[4]);
	scanf("%d",&c);
	switch (c)
	{
		case 1:if (al[0]&&(!k[0])) {h-=b[0];k[0]=CD[0];if (h<=0) win=1;} else printf("error!");break;
		case 2:if (al[1]&&(!k[1])) {heal();k[1]=CD[1];} else printf("error!");break;
		case 3:printf("error!");break;
		case 4:if (al[3]&&(!k[3])) 
		            {
		            	k[3]=CD[3];
		            	for (i=0;i<=b[3];i++)
		            	       attacke();
		            } 
		            else printf("error!");break;
		case 5:if (al[4]&&(!k[4])) {h-=b[4];k[4]=CD[4];health+=b[4]/2;if (h<=0) win=1;} else printf("error!");break;
		default:printf("cancelled");
	}
	printf("\n");
}
示例#3
0
void i_azoth(pob o)
{
    if (o->plus < 0) {
        mprint("The mercury was poisonous!");
        p_poison(25);
    }
    else if (o->plus == 0) {
        mprint("The partially enchanted azoth makes you sick!");
        Player.con = ((int) (Player.con / 2));
        calc_melee();
    }
    else if (o->blessing < 1) {
        mprint("The unblessed azoth warps your soul!");
        Player.pow = Player.maxpow = ((int) (Player.maxpow / 2));
        level_drain(random_range(10),"cursed azoth");
    }
    else {
        mprint("The azoth fills you with cosmic power!");
        if (Player.str > Player.maxstr*2) {
            mprint("The power rages out of control!");
            p_death("overdose of azoth");
        }
        else {
            heal(10);
            cleanse(1);
            Player.mana = calcmana()*3;
            toggle_item_use(TRUE);
            Player.str = (Player.maxstr++)*3;
            toggle_item_use(FALSE);
        }
    }
}
示例#4
0
文件: car.cpp 项目: sorokin/btanks
void Car::emit(const std::string &event, Object * emitter) {
	if (event == "death") {
		spawn("corpse", "dead-" + animation, v2<float>(), v2<float>());
		_dead = true;
		detachVehicle();
		Object::emit(event, emitter);
		return;
	} else if (emitter != NULL && !_velocity.is0() && event == "collision" && animation == "harvester") {
		const std::string &classname = emitter->classname;
		if (!emitter->get_variants().has("player") && (classname == "trooper" || classname == "civilian" || classname == "kamikaze" || classname == "monster")) {
			//LOG_DEBUG(("bloody harvest"));
			emitter->emit("death", NULL);
			if (classname != "monster")
				heal(5);
		}
	} else if (event == "collision" && !_variants.has("safe")) {
		if (emitter != NULL && emitter->speed > 0) {
			if (emitter->registered_name == "machinegunner" && registered_name.compare(0, 7, "static-") == 0) {
				return;
			}
			Item * item = dynamic_cast<Item *>(emitter);
			//no items.
			if (item == NULL) {
				GET_CONFIG_VALUE("objects.car.damage", int, d, 5);
				emitter->add_damage(this, d);
				emitter->add_effect("stunned", 0.1f);
				emit("death", emitter);
			}
		}
	} 
示例#5
0
文件: effect2.c 项目: anylonen/omega
void regenerate(int blessing)
{
  if (blessing < 0)
    heal(blessing * 10);
  else {
    mprint("You feel abnormally healthy.");
    Player.status[REGENERATING] += (blessing+1)*50;
  }
}
示例#6
0
SAM::StreamSession& StreamSessionAdapter::SessionHolder::getSession()
{
    boost::upgrade_lock<mutex_type> lock(mtx_);
    if (session_->isSick())
    {
        boost::upgrade_to_unique_lock<mutex_type> ulock(lock);
        heal();
    }
    return *session_;
}
示例#7
0
文件: game_mech.c 项目: dvltl/MiniRPG
int battle(struct player* hero, struct creature *enemy)
{
	int act;

	if (enemy -> hp == 200)
	{
		script_speaking("Necromancer", 1, "How dare you, mere human, interfere in my great plans!");
		script_speaking("Hero", 1, "Oh, don't worry. Nothing personal, really. I just like beeing a thorn in someone's side.");
		script_speaking("Necromancer", 1, "Fool! That was your last mistake! You won't leave this place alive!");
		script_speaking("Hero", 2, "Yeah-yeah, whatever you say, pal.", "(to himself) It's showtime!");
	}

	while (1)
	{
		printf("Potions left: %d\n", hero -> potions);
		printf("What should we do???\n");
		printf("HP: %d/%d %s's HP:%d\n", hero -> hp, hero -> max_hp, enemy -> name, enemy -> hp);
		printf("1.Attack\n");
		printf("2.Use potion / +50 HP\n");
		printf("3.Leave the battle\n");
		scanf("%d",&act);
		system("clear");
		switch (act)
		{
			case 1: hit(hero, enemy);
					if (hero -> hp <= 0)
					{
						printf("Bad end!\nGame over...\n");
						return 2;
					}
					if (enemy -> hp <= 0)
					{
						victory(hero, enemy);
						return 0;
					}
					break;
			case 2: heal( hero );
					break;
			case 3:
				if (enemy -> exp != 40)
					return 1;
				else
					printf("Cannot flee from this battle...\n");
				break;
			default:
				printf("Choose action form one of the mentioned above\n");
		}
	}
	return 0;
}
void ComponentHealth::onIncomingDamage(float damage)
{
	if(health <= 0)
	{
		return;
	}

	if(damage > 0) //Daño normal
	{
		hurt(damage);
	}
	else			//Cura
	{
		heal(damage * -1);
	}
}
示例#9
0
void heal_update(void)
{
	CREATURE *crit=0;

	for(crit = creature_list; crit; crit = crit->next)
	{
		if(crit->hp < -4)
			hurt(crit,1);
		else if(crit->hp < crit->max_hp)
			heal(crit,1);

		if(crit->move < crit->max_move && crit->hp > 0)
			crit->move++;

		position_check(crit);
	}
}
示例#10
0
文件: pqueue.c 项目: shamrin/lueve
static void heal(pqueue q, index where)
{
    index left= where<<1;
    index right = left+1;
    index min = where;
    index len = vector_length(q->v);
    
    if (left <= len)
        if (qcompare(q, left, min)) min = left;

    if (right <= len)
        if (qcompare(q, right, min)) min = right;

    if (min != where) {
        swap(q, min, where);
        heal(q, min);
    }
}
示例#11
0
void character::Update(){
	if (action == ATTACK)apply_attack_instruction();
	else if(alive) heal();
}
示例#12
0
bool Medic::update(float dt)
{
    checkUnitDirection();
    setAnimationFromDirection();   // This sets animation according to their angle direction
    coll->setPos(center.x + collider_offset.x, center.y + collider_offset.y);

    switch (state)
    {
    case IDLE:
        if (timer_to_check.read() >= TIME_TO_CHECK)
        {
            target_to_attack = searchAllyToHeal();
            if (target_to_attack != NULL)
                newEntityFound();
            timer_to_check.start();
        }
        break;
    case MOVE:
        if (has_target) move(dt);
        break;
    case MOVE_ALERT:
        if (timer_to_check.read() >= TIME_TO_CHECK)
        {
            target_to_attack = searchAllyToHeal();
            if (target_to_attack != NULL)
                newEntityFound();
            timer_to_check.start();
        }
        if (has_target) move(dt);
        break;
    case MOVE_ALERT_TO_ATTACK:
        if (timer_to_check.read() >= TIME_TO_CHECK)
        {
            target_to_attack = searchAllyToHeal();
            if (target_to_attack != NULL)
                newEntityFound();
            else
            {
                has_target = false;
                state = IDLE;
            }
            timer_to_check.start();
        }
        if (has_target) move(dt);
        break;
    case ATTACK:
        if (timer_attack.read() >= (attack_frequency * attack_frequency_multiplier))
        {
            app->audio->playFx(app->entity_manager->fx_medic_heal, 0);
            if (!heal())
            {
                state = IDLE;
                target_to_attack = NULL;
            }

            timer_attack.start();
        }
        break;
    case DYING:
        if (sound_active == true)
        {
            app->audio->playFx(app->entity_manager->fx_medic_death, 0);
            sound_active = false;
        }
        if (current_animation->finished())
        {
            to_delete = true;
            coll->to_delete = true;
        }
        break;
    case WAITING_PATH_MOVE:
        if (app->path->getPathFound(id, path))
        {
            has_target = true;
            state = MOVE;
            timer_to_check.start();
        }
        break;
    case WAITING_PATH_MOVE_ALERT:
        if (app->path->getPathFound(id, path))
        {
            has_target = true;
            state = MOVE_ALERT;
            timer_to_check.start();
        }
        break;
    case WAITING_PATH_MOVE_ALERT_TO_ATTACK:
        if (app->path->getPathFound(id, path))
        {
            has_target = true;
            state = MOVE_ALERT_TO_ATTACK;
            timer_to_check.start();
        }
        break;
    }

    if (grouped && (state != MOVE && state != MOVE_ALERT && state != WAITING_PATH_MOVE && state != WAITING_PATH_MOVE_ALERT && state != IDLE))
        grouped = false;

    return true;
}
示例#13
0
文件: move.c 项目: anylonen/omega
void l_magic_pool(void)
{
  int possibilities=random_range(100);
  print1("This pool seems to be enchanted....");
  if (gamestatusp(MOUNTED)) {
    if (random_range(2)) {
      print2("Your horse is polymorphed into a fig newton.");
      resetgamestatus(MOUNTED);
    }
    else print2("Whatever it was, your horse enjoyed it....");
  }
  else  if (possibilities == 0) {
    print1("Oh no! You encounter the DREADED AQUAE MORTIS...");
    if (random_range(1000) < Player.level*Player.level*Player.level) {
      print2("The DREADED AQUAE MORTIS throttles you within inches....");
      print3("but for some reason chooses to let you escape.");
      gain_experience(500);
      Player.hp = 1;
    }
    else p_death("the DREADED AQUAE MORTIS!");
  }
  else if (possibilities < 25)
    augment(0);
  else if (possibilities < 30)
    augment(1);
  else if (possibilities < 60)
    augment(-1);
  else if (possibilities < 65)
    cleanse(1);
  else if (possibilities < 80) {
    if (Player.possessions[O_WEAPON_HAND] != NULL) {
      print1("You drop your weapon in the pool! It's gone forever!");
      dispose_lost_objects(1,Player.possessions[O_WEAPON_HAND]);
    }
    else print1("You feel fortunate.");
  }
  else if (possibilities < 90) {
    if (Player.possessions[O_WEAPON_HAND] != NULL) {
      print1("Your weapon leaves the pool with a new edge....");
      Player.possessions[O_WEAPON_HAND]->plus += random_range(10)+1;
      calc_melee();
    }
    else print1("You feel unfortunate.");
  }
  else if (possibilities < 95) {
    Player.hp += 10;
    print1("You feel healthier after the dip...");
  }
  else if (possibilities < 99) {
    print1("Oooh, a tainted pool...");
    p_poison(10);
  }
  else if (possibilities == 99) {
    print1("Wow! A pool of azoth!");
    heal(10);
    cleanse(1);
    Player.mana = calcmana()*3;
    Player.str = (Player.maxstr++)*3;
  }
  print2("The pool seems to have dried up.");
  Level->site[Player.x][Player.y].locchar = TRAP;
  Level->site[Player.x][Player.y].p_locf = L_TRAP_PIT;
  lset(Player.x, Player.y, CHANGED);
}
示例#14
0
void i_lembas(pob o)
{
    heal(10);
    cleanse(0);
    Player.food = 40;
}
示例#15
0
/* Prayer occurs at altars, hence the name of the function */
void l_altar()
{
    int i;
    int deity;
    char response;

    if(Current_Environment == E_COUNTRYSIDE) {
        deity = DRUID;
    }
    else {
        deity = Level->site[Player.x][Player.y].aux;
    }

    switch(deity) {
    case ODIN:
        print1("This granite altar is graven with a gallows.");

        break;
    case SET:
        print1("This sandstone altar has a black hand drawn on it.");

        break;
    case HECATE:
        print1("This silver altar is inlaid with a black cresent moon.");

        break;
    case ATHENA:
        print1("This golden altar is inscribed with an owl.");

        break;
    case DESTINY:
        print1("This crystal altar is in the form of an omega.");

        break;
    case DRUID:
        print1("This oaken altar is ornately engraved with leaves.");

        break;
    default:
        print1("This rude altar has no markings.");

        break;
    }

    print2("Worship at this altar? [yn] ");

    if(ynq2() == 'y') {
        if(Player.rank[PRIESTHOOD] == 0) {
            increase_priest_rank(deity);
        }
        else if(!check_sacrilege(deity)) {
            if(Blessing) {
                print1("You have a sense of immanence.");
            }

            print2("Request a Blessing, Sacrifice an item, or just Pray [b,s,p] ");
            response = mcigetc();

            while((response != 'b')
                  && (response != 's')
                  && (response != 'p')
                  && (response != ESCAPE)) {
                response = mcigetc();
            }

            if(response == 'b') {
                print1("You beg a heavenly benefice.");
                print2("You hear a gong resonating throughout eternity...");
                morewait();

                if(Blessing) {
                    print1("A shaft of lecent radiance lances dwon from the heavens!");
                    print2("You feel uplifted...");
                    morewait();
                    gain_experience(Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * 50);
                    cleanse(1);
                    heal(10);
                    bless(1);
                    Blessing = FALSE;
                    increase_priest_rank(deity);
                }
                else {
                    print1("Your ardent plea is ignored.");
                    print2("You feel ashamed.");
                    Player.xp -= (Player.xp / 4);
                }

                calc_melee();
            }
            else if(response == 's') {
                print1("Which item to Sacrifice?");
                i = getitem('\0');

                if(i == ABORT) {
                    i = 0;
                }

                if(Player.possessions[i] == NULL) {
                    print1("You have insulted your deity!");
                    print2("Not a good idea, as it turns out...");
                    dispel(-1);
                    p_damage(Player.hp - 1, UNSTOPPABLE, "a god's pique");
                }
                else if(true_item_value(Player.possessions[i]) > (Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * Player.rank[PRIESTHOOD] * 50)) {
                    print1("With a burst of blue flame, your offering vanishes!");
                    dispose_lost_objects(1, Player.possessions[i]);
                    print2("A violet nimbus settles around your head and slowly fades.");
                    morewait();
                    Blessing = TRUE;
                }
                else {
                    print1("A darkling glow envelopes your offering!");
                    print2("The glow slowly fades...");
                    morewait();
                    setgamestatus(SUPPRESS_PRINTING);

                    if(Player.possessions[i]->used) {
                        Player.possessions[i]->used = FALSE;
                        item_use(Player.possessions[i]);
                        Player.possessions[i]->blessing = -1 - abs(Player.possessions[i]->blessing);
                        Player.possessions[i]->used = TRUE;
                        item_use(Player.possessions[i]);
                    }
                    else {
                        Player.possessions[i]->blessing = -1 - abs(Player.possessions[i]->blessing);
                    }

                    resetgamestatus(SUPPRESS_PRINTING);
                }
            }
            else if(response == 'p') {
                if(deity != Player.patron) {
                    print1("Nothing seems to happen.");
                }
                else {
                    increase_priest_rank(deity);
                }
            }
        }
    }
}
示例#16
0
void s_heal(void)
{
    heal(3);
}
示例#17
0
int main(){
	personagem per;
	monstro mon;
	char *map;
	char tEnd=1,tQuit=1,tRoom, test,test2;
	
	item it;
	strcpy(it.nome,"Capa Vampirica\0");
	it.categoria='a';
	it.value=80;

	monstro blair;
	blair.magicD = 160;
	blair.fisicalD = 160;
	blair.distD = 160;
	blair.atkType = 'm';
	blair.atk = 250;
	strcpy(blair.nome,"Bruxa Blair\0");
	strcpy(blair.drop,"Camiseta do TUSCA\0");
	blair.HP = 120;
	blair.XP = 0;

	srand(time(NULL));

	do{
		test=start(&per,&map);
		if(test==2)continue;
		if(test==1)break;
		scanf("%*c");
		do{
			system("cls");
			printf("SALA %i\n",per.pos);

			printf("deseja mexer em seu inventario?(s/n):");
			scanf("%c",&test);
			if(test=='s'){
				invMenu(&per);///cuidado olhar argumentos
			}			

			do{
				printf("Digite a direcao que dejeja seguir:norte-w; sul-s; leste-d; oeste-a; quit game-q:");
				scanf("%c",&test);
			}while(test!='w' && test!='a' && test!='s' && test!='d' && test!='q');

			if(test=='q'){
				printf("deseja salvar o seu progresso?(s/n)");
				scanf("%*c");
				scanf("%*c");
				scanf("%c",&test);
				if(test=='s'){
					test2=save(per);
				}
				tQuit=0;
				break;
			}
			else{
				move(test,&(per.pos));
			}

			printf("SALA %i\n",per.pos);

			switch(map[per.pos]){
				case 0://sala qualquer sem importancia
					tRoom=rand()%100;

					if(tRoom>=35){
						mon=monsterGet(rand()%monsterNum);
						tQuit=combat(&per,&mon);
						break;
					}

					if(tRoom>=15){
						printf("nao ha nada na sala\n");
						break;
					}

					if(tRoom>=5){
						printf("voce encontrou uma fonte de cura, e aproveitou para relaxar e tomar um banho, afinal ate os herois ficam cansados(as).");
						printf(" Alem de especialmente fedidos(as) afinal de contas um covil de monstros nao cheiram tao bem assim (na maioria dos casos)\n");
						heal(&per);
						break;
					}

					item it;
					test2=itemGet(rand()%itemNum,&it);
					printf("voce encontrou um '%s' deseja guardar no seu inventario?(s/n)\n",it.nome);
					scanf("%*c");
					scanf("%c",&test);
					if(test=='s'){
						store(it);
					}

					break;
				case 1://sala 0
					printf("SALA ZERO\n\n");
					printf("Voce esta em uma sala ampla com paredes e chao de pedra, ao seu redor existem varios destrocos pedacos de madeira e pedra, provavelmente vindos do telhado, ");
					printf("ja partido com frestas que permitem observar um o azul do ceu, e da decoracao, que antes imponente e bela agora nao passa de escombros\n\n");
					printf("mas voce eh capaz de identificar no meio disso um pedestal de pedra e sobre ele apenas os pes do que um dia ja foi uma estatua e uma inscricao que diz:\n");
					printf("'voce esta agora em um local seguro jovem aventureiro ou aventureira, aproveite este lugar para se preparar para as aventuras que estao a seguir.'");
					printf("\n o resto estva ilegivel apagado pelo tempo. Voce aproveita a seguranca temporaria para se preparar para o que ha a seguir");
					heal(&per);
					break;
				case 2://sala com primeiro boss Alucard
					printf("voce sente seu corpo ser transportado para um local difente das ruinas em que voce estava anteriormnte, voce agora esta em uma sala nao muito grande,mas");
					printf(" muito bem decorada com itens de beleza rara, apesar de ja ser noite a sala esta bem iluminada e ao olhar na direcao da janela voce ve um homem.\n");
					printf("Ele esta vestindo um longo sobretudo preto com detalhes em vermelho por cima da camisa e calca tambem de coras escuras e logo se vira para voce e diz:\n");
					printf("'seja bem vindo ao meu humilde castelo %s,eu estava lhe esperando. Meu nome eh Alucard sou um dos gurdioes das ruinas dos herois, por favor sente-se",per.nome);
					printf(", vou lhe contar a triste historia deste lugar:\n");
					system("pause");
					system("cls");
					printf("Ha muitos anos este lugar era um reduto de aventureiros que que reuniam nos arredores para desafiar as salas e conquistar as recompensas ");
					printf("que aqui existem, ate que um dia a bruxa Blair, que era uma guardia, assasinou o antigo mestre, tomou seu lugar e comecou a enviar os desafiantes para ");
					printf("a morte certa ate que certa vez os aventureiros se revoltaram contra ela. Uma grande batalha foi travada e o resultado foi um massacre. Eles nao puderam ");
					printf("conta as forcas de Blair e tudo o que restou sao os destrocos da sala zero. Apos isso os poucos que fugiram no inicio da batalha lacraram a entada para que " );
					printf("nenhum desavisado caisse em suas garas. Desde entao Blair tem trazido pessoas aqui atravez de armadilhas para que lutem aqui ate a morte certa, destruindo ");
					printf("os ideais do primeiro mestre. Eu nunca pude fazer nada contra o seu poder, mas agora com voce aqui eh diferente, voce tem potencial para mudar isto.");
					system("pause");
					system("cls");
					printf("Torne-se mais forte para poder derrota-la, eu orei lhe ajudar quando a hora chegar.\nComo prova de minha lealdade lhe dou isto:'\n");
					printf("Voce recebeu a 'capa vampirica' e guardou em seu inventario.");
					store(it);
					printf("'um ultimo aviso cuidado com o proximo guardiao ele pode parecer inofensivo mas eh uma fera selvagem e mortal.'");
					system("pause");
					system("cls");
					printf("voce entao retorna para as ruinas");
					per.rooms[0]=0;
					map[per.pos]=0;
					break;
				case 3://sala com segundo boss galinha
					if(per.rooms[0]!=0){
						printf("nao ha nada na sala\n");
						break;
					}
					printf("Ao entrar na sala voce se ve em meio a um palheiro e bem ao centro voce ve uma galinha.\no que voce deseja fazer:");
					printf("1 - matar a galinha e assar sua carne (ela parece suculenta);");
					printf("2 - andar de fininho e passar tentando nao chamar a atencao;");
					printf("outro - gritar por socoro;");
					scanf("%c",&test);
					switch(test){
						case '1':
							printf("A galinha eh mais poderosa que voce e te mata.");
							tQuit=0;
							break;
						case '2':
							printf("voce passa sem cahmar a atencao e se salva");
							per.rooms[1]=0;
							map[per.pos]=0;
							break;
						default:
							printf("Voce chamou a atencao da galinha, sair vivo nao eh mais uma opcao.");
							tQuit=0;
							break;						
					}
					break;				
				case 4:
					if(per.rooms[1]!=0){
						printf("nao ha nada na sala\n");
						break;
					}
					printf("Voce se encontra agora num lugar que aparenta ser uma arena de combate medieval. Blair se encontra a sua frente com seu cajado em posicao de combate");
					printf("Blair diz: 'me surpreende muito que voce tenha chegado ate aqui, achei que fosse apenas mais um idiota, mas voce tem algum valor.'");
					system("pause");
					test=combat(&per,&blair);
					switch(test){
						case 0:
							tQuit = 0;
							break;
						case 1:
							printf("Com a morte de Blair, Alucard assume o comendo das Ruina dos Herois e voce eh nomeado um dos Guardioes da Ruina. \n");
							printf("Novamente, aventureiros se reunem para desafiar as salas e conquistar suas recompensas.\n");
							printf(" Voce jamais volta para casa, afinal, para que voltar para casa?!");
							printf("\n\nFIM.");
							break;
						case 2:
							printf("Voce foi transportado para a SALA ZERO");
							per.pos = 0;
							break;
					}
			}

			if(tQuit==0)break;

			printf("deseja salvar o seu progresso?(s/n)");
			scanf("%c",&test);
			if(test=='s'){
				save(per);
			}

		}while(tQuit);

		printf("deseja voltar ao menu inicial?(s/n)");
		scanf("%*c");
		scanf("%c",&tEnd);
		system("cls");

	}while(tEnd!='n');
	system("pause");
	return 0;
}
示例#18
0
	void game::generate_library()
	{
		m_library = std::make_shared<library>();

		// buffs
		rl::person::status_t poison(10, [&](rl::person &c, rl::person::status_t &s) { c.health() = c.health() - 1; });
		poison.register_apply([&](rl::person &target, rl::person::status_t &s)
		{
			m_broadcasts.emplace_back("* poisoned *", color(0, 1, 0), target.position(), 0.5);
		});
		poison.appearance({ '-', 0xffff00 });
		poison.name("Poison");
		poison.tag("poison");
		m_library->insert(poison);

		// skills

		rl::person::action_t::range_t bite_range(0, 1);
		rl::person::action_t bite(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			if (user && unit)
			{
				point start = user->position();

				// status
				//unit->accept(rl::effect(m_library->prototype<rl::person::status_t>("poison")));

				// popup
				m_broadcasts.emplace_back(std::to_string(-8), color(1, 0, 0), unit->position(), 0.75);

				// visual
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25;
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0);
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0);
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25;
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0);
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0);
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
			}
		}), rl::person::action_t::target_check_fn([&, bite_range](rl::person::caster_t *user, rl::person::target_t unit)
		{
			return user && unit && user != unit.get() && rl::person::action_t::in_range(bite_range, distance(user->position(), unit->position()));
		}));
		bite.name("Bite");
		bite.range(bite_range);
		bite.tag("bite");
		m_library->insert(bite);

		rl::person::action_t pyroblast(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			if (user)
			{
				//broadcast({ "puff!", 0xffffff, user->position() });
			}
			if (user && unit)
			{
				vector start = user->position();
				vector fin = unit->position();
				//m_projectiles.push_back(projectile('*', 0xff0000, color(30, 10, 10), [=](projectile::timespan_t phase) { return start.lerp(fin, (std::min)(phase, 1.0)); }));
			}
		}), rl::person::action_t::target_check_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			return true;
		}));
		pyroblast.tag("pyroblast");
		m_library->insert(pyroblast);

		// heal
		rl::person::action_t::ground_fn h([&](rl::person::caster_t *user, const point &position)
		{
			user->health() = user->health() + 1;
		});
		rl::person::action_t::ground_check_fn hc([&](rl::person::caster_t *user, const point &position)
		{
			return true;
		});
		rl::person::action_t heal(h, hc);
		heal.tag("heal");
		m_library->insert(heal);

		// teleport
		rl::person::action_t::ground_fn teleport_fn([&](rl::person::caster_t *user, const point &position)
		{
			m_scene->focus(position);
			m_scene->move(*user, position);
		});
		rl::person::action_t::ground_check_fn teleport_check_fn([&](rl::person::caster_t *user, const point &position)
		{
			return true;
		});
		rl::person::action_t teleport(teleport_fn, teleport_check_fn);
		teleport.tag("teleport");
		m_library->insert(teleport);

		// npc

		rl::npc rat;
		rat.fraction(0);
		rat.appearance({ 'r', 0xff0000, 0.62f });
		rat.health() = 100;
		rat.tag("mob_rat");
		rat.name("Rat");
		rat.add_skill(bite);
		m_library->insert(rat);

		// ore
		rl::item ore;
		ore.appearance('o');
		ore.name("copper ore");
		ore.tag("ore_copper");
		ore.stackable(true);
		m_library->insert(ore);

		// placeables
		rl::unit lantern;
		lantern.appearance({ ' ', color(1, 1, 1) });
		lantern.light({ { 3, 3, 3 }, true, true });
		lantern.tag("lantern");
		m_library->insert(lantern);

		rl::door door;
		door.appearance({ ' ', 0x333333 }, { '+', 0x333333 });
		door.tag("door");
		m_library->insert(door);

		// items
		{
			rl::item ff;
			ff.name("Firetail Mushroom");
			ff.tag("f_red");
			m_library->insert(ff);
		}
		{
			rl::item flora;
			flora.name("Glowing Moss");
			flora.tag("f_green");
			m_library->insert(flora);
		}
		{
			rl::item flora;
			flora.name("Cave Lily");
			flora.tag("f_blue");
			m_library->insert(flora);
		}

		// flora
		rl::deposit f1(m_library->make<rl::item>("f_red"));
		f1.tag("fireflower");
		f1.name("Gribus Ognelisius");
		f1.appearance({ '*', color(1, 0, 0), 0.75 });
		f1.light({ { 3, 0, 0 }, true, true });
		f1.invincible(true);
		m_library->insert(f1);

		rl::deposit f2(m_library->make<rl::item>("f_blue"));
		f2.tag("iceflower");
		f2.appearance({ '*', color(0, 0, 1), 0.75 });
		f2.light({ { 0, 0, 3 }, true, true });
		f2.invincible(true);
		m_library->insert(f2);

		rl::deposit flower(m_library->make<rl::item>("f_green"));
		flower.tag("felflower");
		flower.appearance({ '*', color(0, 1, 0), 0.75 });
		flower.light({ { 0, 3, 0 }, true, true });
		flower.invincible(true);
		m_library->insert(flower);
	}
示例#19
0
void pc_record_type::kill(short type)
{
	short i = 24;
	bool dummy, no_save = false, no_luck = false;
	location item_loc;

	if (type >= 20)
	{
		type -= 10;
		no_save = true;
	}
    if(type >= 10)
    {
    	type -= 10;
	    no_luck = true;
    }

    if(no_save == false){
	if (type != 4)
		i = hasAbilEquip(ITEM_LIFE_SAVING); //check if has life saving items
    else
	    i = hasAbilEquip(ITEM_PROTECT_FROM_PETRIFY); //check if has protection vs petrification items
    }

	short which_pc = getNum();

	if ((no_luck == false) && (type != 0) && (skills[SKILL_LUCK] > 0) &&
		(get_ran(1,0,100) < hit_chance[skills[SKILL_LUCK]])) {
			add_string_to_buf("  But you luck out!          ");
			cur_health = 0;
			}
		else if ((i == 24) || (type == 0)) {
			if (combat_active_pc == which_pc)
				combat_active_pc = 6;

			for (i = 0; i < 24; i++)
				equip[i] = false;

			item_loc = (overall_mode >= MODE_COMBAT) ? pc_pos[which_pc] : c_town.p_loc;

			if (type == 2)
				make_sfx(item_loc.x,item_loc.y,3);
				else if (type == 3)
					make_sfx(item_loc.x,item_loc.y,6);

			if (overall_mode != MODE_OUTDOORS)
				for (i = 0; i < 24; i++)
					if (items[i].variety != ITEM_TYPE_NO_ITEM) {
						dummy = place_item(items[i],item_loc,true);
						items[i].variety = ITEM_TYPE_NO_ITEM;
						}
				if ((type == 2) || (type == 3))
					play_sound(21);
				if(type == 4){
                    play_sound(43);
                    sprintf (create_line, "  %s is turned to stone.                  ",(char *) name);
					add_string_to_buf(create_line);
                    }
				main_status = type;
				pc_moves[which_pc] = 0;
			}
			else {
                if (type == 4) {
                  sprintf (create_line, "  %s is immune to petrification.                  ",(char *) name);
                  add_string_to_buf(create_line); //inform of what has happened
                                    }
                else{
				add_string_to_buf("  Life saved!              ");
				takeItem(i);
				heal(200);
               }
            }

        current_pc = first_active_pc();

	if (current_pc > 5) {
		for (i = 0; i < NUM_OF_PCS; i++)
			if (adven[i].status > 0)
				current_pc = i;
		}

	put_pc_screen();
	set_stat_window(current_pc);
}