void actMinotaurTrap(Entity* my) { if ( !my->skill[28] ) { return; } // received on signal if ( my->skill[28] == 2) { if ( !MINOTAURTRAP_FIRED ) { Entity* monster = summonMonster(MINOTAUR, my->x, my->y); if ( monster ) { MINOTAURTRAP_FIRED = 1; if ( strcmp(map.name, "Hell Boss") ) { int c; for ( c = 0; c < MAXPLAYERS; c++ ) { playSoundPlayer( c, 107 + rand() % 3, 128 ); Uint32 color = SDL_MapRGB(mainsurface->format, 255, 128, 0); messagePlayerColor(c, color, language[1113]); } } } } } }
void actHeadstone(Entity* my) { if ( my->flags[INVISIBLE] ) { if ( multiplayer != CLIENT ) { node_t* node; int goldbags = 0; bool artifact = false; for ( node = map.entities->first; node != nullptr; node = node->next ) { Entity* entity = (Entity*)node->element; if ( entity->sprite == 130 ) // gold bag { ++goldbags; } if ( entity->sprite == 508 ) { artifact = true; } } if ( goldbags >= 9 && artifact ) { return; } my->flags[INVISIBLE] = false; my->flags[PASSABLE] = false; serverUpdateEntityFlag(my, INVISIBLE); serverUpdateEntityFlag(my, PASSABLE); } else { return; } } HEADSTONE_AMBIENCE--; if ( HEADSTONE_AMBIENCE <= 0 ) { HEADSTONE_AMBIENCE = TICKS_PER_SECOND * 30; playSoundEntityLocal( my, 149, 32 ); } if ( multiplayer == CLIENT ) { return; } if ( !HEADSTONE_INIT ) { HEADSTONE_INIT = 1; HEADSTONE_MESSAGE = rand(); HEADSTONE_GHOUL = (rand() % 4 == 0); } bool shouldspawn = false; // rightclick message int i; if ( multiplayer != CLIENT ) { for (i = 0; i < MAXPLAYERS; i++) { if ( (i == 0 && selectedEntity == my) || (client_selected[i] == my) ) { if (inrange[i]) { messagePlayer(i, language[485 + HEADSTONE_MESSAGE % 17]); if ( HEADSTONE_GHOUL && !HEADSTONE_FIRED ) { shouldspawn = true; Uint32 color = SDL_MapRGB(mainsurface->format, 255, 128, 0); messagePlayerColor(i, color, language[502]); } } } } } // received on signal if ( my->skill[28] == 2 || shouldspawn ) { if ( !HEADSTONE_FIRED ) { HEADSTONE_FIRED = 1; // make a ghoul Entity* monster = summonMonster(GHOUL, my->x, my->y); if ( monster ) { monster->z = 13; if ( currentlevel >= 15 || !strncmp(map.name, "The Haunted Castle", 18) ) { Stat* tmpStats = monster->getStats(); if ( tmpStats ) { strcpy(tmpStats->name, "enslaved ghoul"); } } } } } }
void initGnome(Entity *my, Stat *myStats) { int c; node_t *node; my->sprite = 295; //Gnome head model my->flags[UPDATENEEDED]=TRUE; my->flags[BLOCKSIGHT]=TRUE; my->flags[INVISIBLE]=FALSE; if( multiplayer!=CLIENT ) { MONSTER_SPOTSND = 220; MONSTER_SPOTVAR = 5; MONSTER_IDLESND = 217; MONSTER_IDLEVAR = 3; } if( multiplayer!=CLIENT && !MONSTER_INIT ) { myStats->sex = static_cast<sex_t>(rand()%2); myStats->appearance = rand(); strcpy(myStats->name,""); myStats->inventory.first = NULL; myStats->inventory.last = NULL; myStats->HP = 50; myStats->MAXHP = 50; myStats->MP = 50; myStats->MAXMP = 50; myStats->OLDHP = myStats->HP; myStats->STR = 2; myStats->DEX = 0; myStats->CON = 4; myStats->INT = 0; myStats->PER = 2; myStats->CHR = -1; myStats->EXP = 0; myStats->LVL = 5; myStats->GOLD = 40+rand()%20; myStats->HUNGER = 900; if( !myStats->leader_uid ) myStats->leader_uid = 0; myStats->FOLLOWERS.first=NULL; myStats->FOLLOWERS.last=NULL; for( c=0; c<std::max(NUMPROFICIENCIES,NUMEFFECTS); c++ ) { if( c<NUMPROFICIENCIES ) myStats->PROFICIENCIES[c]=0; if( c<NUMEFFECTS ) myStats->EFFECTS[c]=FALSE; if( c<NUMEFFECTS ) myStats->EFFECTS_TIMERS[c]=0; } myStats->PROFICIENCIES[PRO_SWORD]=35; myStats->PROFICIENCIES[PRO_MACE]=50; myStats->PROFICIENCIES[PRO_AXE]=45; myStats->PROFICIENCIES[PRO_POLEARM]=25; myStats->PROFICIENCIES[PRO_RANGED]=35; myStats->PROFICIENCIES[PRO_SHIELD]=35; myStats->helmet = NULL; myStats->breastplate = NULL; myStats->gloves = NULL; myStats->shoes = NULL; myStats->shield = NULL; myStats->weapon = NULL; myStats->cloak = NULL; myStats->amulet = NULL; myStats->ring = NULL; myStats->mask = NULL; if( rand()%8==0 ) { myStats->EFFECTS[EFF_ASLEEP] = TRUE; myStats->EFFECTS_TIMERS[EFF_ASLEEP] = 1800+rand()%1800; } if( rand()%3==0 ) newItem( FOOD_FISH, EXCELLENT, 0, 1, rand(), FALSE, &myStats->inventory ); if( rand()%50==0 ) newItem( READABLE_BOOK, EXCELLENT, 0, 1, getBook("Winny's Report"), FALSE, &myStats->inventory ); if( rand()%10==0 ) { int i = 1+rand()%4; for( c=0; c<i; c++ ) newItem( static_cast<ItemType>(GEM_GARNET+rand()%15), static_cast<Status>(1+rand()%4), 0, 1, rand(), FALSE, &myStats->inventory ); } if( rand()%50==0 && !my->flags[USERFLAG2] ) { strcpy(myStats->name,"Rumplewort"); myStats->LVL += 10; newItem( GEM_DIAMOND, static_cast<Status>(1+rand()%4), 0, 1, rand(), TRUE, &myStats->inventory ); int c; for( c=0; c<3; c++ ) { Entity *entity = summonMonster(GNOME,my->x,my->y); if( entity ) entity->parent = my->uid; } } } // torso Entity *entity = newEntity(296, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][1][0]; // 0 entity->focaly = limbs[GNOME][1][1]; // 0 entity->focalz = limbs[GNOME][1][2]; // 0 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // right leg entity = newEntity(297, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][2][0]; // .25 entity->focaly = limbs[GNOME][2][1]; // 0 entity->focalz = limbs[GNOME][2][2]; // 1.5 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // left leg entity = newEntity(298, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][3][0]; // .25 entity->focaly = limbs[GNOME][3][1]; // 0 entity->focalz = limbs[GNOME][3][2]; // 1.5 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // right arm entity = newEntity(299, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][4][0]; // 0 entity->focaly = limbs[GNOME][4][1]; // 0 entity->focalz = limbs[GNOME][4][2]; // 2 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // left arm entity = newEntity(301, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][5][0]; // 0 entity->focaly = limbs[GNOME][5][1]; // 0 entity->focalz = limbs[GNOME][5][2]; // 2 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // world weapon entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[INVISIBLE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][6][0]; // 2 entity->focaly = limbs[GNOME][6][1]; // 0 entity->focalz = limbs[GNOME][6][2]; // -.5 entity->behavior=&actGnomeLimb; entity->parent=my->uid; entity->pitch=.25; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // shield entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[INVISIBLE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][7][0]; // 0 entity->focaly = limbs[GNOME][7][1]; // 0 entity->focalz = limbs[GNOME][7][2]; // 1.5 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // cloak entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->scalex = 1.01; entity->scaley = 1.01; entity->scalez = 1.01; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[INVISIBLE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx = limbs[GNOME][8][0]; // 0 entity->focaly = limbs[GNOME][8][1]; // 0 entity->focalz = limbs[GNOME][8][2]; // 4 entity->behavior=&actGnomeLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); if( multiplayer==CLIENT || MONSTER_INIT ) return; // give shield switch( rand()%10 ) { case 0: case 1: myStats->shield = newItem(TOOL_LANTERN,EXCELLENT,-1+rand()%3,1,rand(),FALSE,NULL); break; case 2: case 3: case 4: case 5: case 6: break; case 7: case 8: case 9: myStats->shield = newItem(WOODEN_SHIELD,static_cast<Status>(WORN+rand()%2),-1+rand()%3,1,rand(),FALSE,NULL); break; } // give weapon switch( rand()%10 ) { case 0: case 1: case 2: case 3: case 4: myStats->weapon = newItem(TOOL_PICKAXE,EXCELLENT,-1+rand()%3,1,rand(),FALSE,NULL); break; case 5: case 6: case 7: case 8: case 9: myStats->GOLD += 100; myStats->weapon = newItem(MAGICSTAFF_LIGHTNING,EXCELLENT,-1+rand()%3,1,rand(),FALSE,NULL); break; } // give cloak switch( rand()%10 ) { case 0: case 1: case 2: case 3: case 4: case 5: break; case 6: case 7: case 8: case 9: myStats->cloak = newItem(CLOAK,SERVICABLE,-1+rand()%3,1,rand(),FALSE,NULL); break; } }
void actFountain(Entity *my) { Entity *entity; //messagePlayer(0, "actFountain()"); //TODO: Temporary mechanism testing code. /* if( multiplayer != CLIENT ) { if (my->skill[28]) { //All it does is change its sprite to sink if it's powered. if (my->skill[28] == 1) { my->sprite = 163; } else { my->sprite = 164; } } }*/ //****************END TEST CODE*************** //TODO: Sounds. // spray water if( my->skill[0] > 0 || ( !my->skill[2] && multiplayer == CLIENT ) ) { #define FOUNTAIN_AMBIENCE my->skill[7] FOUNTAIN_AMBIENCE--; if( FOUNTAIN_AMBIENCE<=0 ) { FOUNTAIN_AMBIENCE = TICKS_PER_SECOND*6; playSoundEntityLocal(my, 135, 32 ); } entity = spawnGib(my); entity->flags[INVISIBLE] = FALSE; entity->y -= 2; entity->z -= 8; entity->flags[SPRITE] = FALSE; entity->flags[NOUPDATE] = TRUE; entity->flags[UPDATENEEDED] = FALSE; entity->skill[4] = 7; entity->sprite = 4; entity->yaw = (rand()%360)*PI/180.0; entity->pitch = (rand()%360)*PI/180.0; entity->roll = (rand()%360)*PI/180.0; entity->vel_x = 0; entity->vel_y = 0; entity->vel_z = .25; entity->fskill[3] = 0.03; } // the rest of the function is server-side. if( multiplayer==CLIENT ) return; // makes the fountain stop spraying water on clients if( my->skill[0] <= 0 ) my->skill[2] = 1; else my->skill[2] = 0; //Using the fountain (TODO: Monsters using it?). int i; for (i = 0; i < MAXPLAYERS; ++i) { if ( (i==0 && selectedEntity==my) || (client_selected[i]==my) ) { if (inrange[i]) { //Act on it only if the player (or monster, if/when this is changed to support monster interaction?) is in range. //First check that it's not depleted. if (my->skill[0] == 0) { //Depleted messagePlayer(i, language[467]); } else { if (players[i]->entity->flags[BURNING]) { messagePlayer(i, language[468]); players[i]->entity->flags[BURNING] = FALSE; if (i > 0) serverUpdateEntityFlag(players[i]->entity, BURNING); } switch (my->skill[1]) { case 0: { playSoundEntity(players[i]->entity, 52, 64); //Spawn succubus. Uint32 color = SDL_MapRGB(mainsurface->format,255,128,0); messagePlayerColor(i, color, language[469]); summonMonster(SUCCUBUS, my->x, my->y); break; } case 1: messagePlayer(i, language[470]); messagePlayer(i, language[471]); playSoundEntity(players[i]->entity, 52, 64); stats[i]->HUNGER += 50; break; case 2: { //Potion effect. Potion effect is stored in my->skill[3], randomly chosen when the fountain is created. messagePlayer(i, language[470]); Item *item = newItem(static_cast<ItemType>(POTION_WATER+my->skill[3]), static_cast<Status>(4), 0,1,0,FALSE,NULL); useItem(item,i); // Long live the mystical fountain of TODO. break; } case 3: { // bless equipment playSoundEntity(players[i]->entity, 52, 64); Uint32 textcolor = SDL_MapRGB(mainsurface->format,0,255,255); messagePlayerColor(i, textcolor, language[471]); messagePlayer(i, language[473]); if( stats[i]->helmet ) stats[i]->helmet->beatitude++; if( stats[i]->breastplate ) stats[i]->breastplate->beatitude++; if( stats[i]->gloves ) stats[i]->gloves->beatitude++; if( stats[i]->shoes ) stats[i]->shoes->beatitude++; if( stats[i]->shield ) stats[i]->shield->beatitude++; if( stats[i]->weapon ) stats[i]->weapon->beatitude++; if( stats[i]->cloak ) stats[i]->cloak->beatitude++; if( stats[i]->amulet ) stats[i]->amulet->beatitude++; if( stats[i]->ring ) stats[i]->ring->beatitude++; if( stats[i]->mask ) stats[i]->mask->beatitude++; if( multiplayer==SERVER && i>0 ) { strcpy((char *)net_packet->data,"BLES"); net_packet->address.host = net_clients[i-1].host; net_packet->address.port = net_clients[i-1].port; net_packet->len = 4; sendPacketSafe(net_sock, -1, net_packet, i-1); } break; } default: break; } messagePlayer(i, language[474]); my->skill[0] = 0; //Dry up fountain. //TODO: messagePlayersInSight() instead. } //Then perform the effect randomly determined when the fountain was created. return; } } } }
void actFountain(Entity* my) { Entity* entity; //messagePlayer(0, "actFountain()"); //TODO: Temporary mechanism testing code. /* if( multiplayer != CLIENT ) { if (my->skill[28]) { //All it does is change its sprite to sink if it's powered. if (my->skill[28] == 1) { my->sprite = 163; } else { my->sprite = 164; } } }*/ //****************END TEST CODE*************** //TODO: Sounds. // spray water if ( my->skill[0] > 0 ) { #define FOUNTAIN_AMBIENCE my->skill[7] FOUNTAIN_AMBIENCE--; if ( FOUNTAIN_AMBIENCE <= 0 ) { FOUNTAIN_AMBIENCE = TICKS_PER_SECOND * 6; playSoundEntityLocal(my, 135, 32 ); } entity = spawnGib(my); entity->flags[INVISIBLE] = false; entity->y -= 2; entity->z -= 8; entity->flags[SPRITE] = false; entity->flags[NOUPDATE] = true; entity->flags[UPDATENEEDED] = false; entity->skill[4] = 7; entity->sprite = 4; entity->yaw = (rand() % 360) * PI / 180.0; entity->pitch = (rand() % 360) * PI / 180.0; entity->roll = (rand() % 360) * PI / 180.0; entity->vel_x = 0; entity->vel_y = 0; entity->vel_z = .25; entity->fskill[3] = 0.03; } // the rest of the function is server-side. if ( multiplayer == CLIENT ) { return; } //Using the fountain (TODO: Monsters using it?). int i; for (i = 0; i < MAXPLAYERS; ++i) { if ( (i == 0 && selectedEntity == my) || (client_selected[i] == my) ) { if (inrange[i]) //Act on it only if the player (or monster, if/when this is changed to support monster interaction?) is in range. { //First check that it's not depleted. if (my->skill[0] == 0) { //Depleted messagePlayer(i, language[467]); } else { if (players[i]->entity->flags[BURNING]) { messagePlayer(i, language[468]); players[i]->entity->flags[BURNING] = false; serverUpdateEntityFlag(players[i]->entity, BURNING); steamAchievementClient(i, "BARONY_ACH_HOT_SHOWER"); } switch (my->skill[1]) { case 0: { playSoundEntity(players[i]->entity, 52, 64); //Spawn succubus. Uint32 color = SDL_MapRGB(mainsurface->format, 255, 128, 0); Entity* spawnedMonster = nullptr; if ( !strncmp(map.name, "Underworld", 10) ) { Monster creature = SUCCUBUS; if ( rand() % 2 ) { creature = INCUBUS; } for ( int c = 0; spawnedMonster == nullptr && c < 5; ++c ) { switch ( c ) { case 0: spawnedMonster = summonMonster(creature, my->x, my->y); break; case 1: spawnedMonster = summonMonster(creature, my->x + 16, my->y); break; case 2: spawnedMonster = summonMonster(creature, my->x - 16, my->y); break; case 3: spawnedMonster = summonMonster(creature, my->x, my->y + 16); break; case 4: spawnedMonster = summonMonster(creature, my->x, my->y - 16); break; } } if ( spawnedMonster ) { if ( creature == INCUBUS ) { messagePlayerColor(i, color, language[2519]); Stat* tmpStats = spawnedMonster->getStats(); if ( tmpStats ) { strcpy(tmpStats->name, "lesser incubus"); } } else { messagePlayerColor(i, color, language[469]); } } } else if ( currentlevel < 10 ) { messagePlayerColor(i, color, language[469]); spawnedMonster = summonMonster(SUCCUBUS, my->x, my->y); } else if ( currentlevel < 20 ) { if ( rand() % 2 ) { spawnedMonster = summonMonster(INCUBUS, my->x, my->y); Stat* tmpStats = spawnedMonster->getStats(); if ( tmpStats ) { strcpy(tmpStats->name, "lesser incubus"); } messagePlayerColor(i, color, language[2519]); } else { messagePlayerColor(i, color, language[469]); spawnedMonster = summonMonster(SUCCUBUS, my->x, my->y); } } else { messagePlayerColor(i, color, language[2519]); spawnedMonster = summonMonster(INCUBUS, my->x, my->y); } break; } case 1: messagePlayer(i, language[470]); messagePlayer(i, language[471]); playSoundEntity(players[i]->entity, 52, 64); stats[i]->HUNGER += 100; players[i]->entity->modHP(5); break; case 2: { //Potion effect. Potion effect is stored in my->skill[3], randomly chosen when the fountain is created. messagePlayer(i, language[470]); Item* item = newItem(static_cast<ItemType>(POTION_WATER + my->skill[3]), static_cast<Status>(4), 0, 1, 0, false, NULL); useItem(item, i); // Long live the mystical fountain of TODO. break; } case 3: { // bless all equipment playSoundEntity(players[i]->entity, 52, 64); Uint32 textcolor = SDL_MapRGB(mainsurface->format, 0, 255, 255); messagePlayerColor(i, textcolor, language[471]); messagePlayer(i, language[473]); if ( stats[i]->helmet ) { stats[i]->helmet->beatitude++; } if ( stats[i]->breastplate ) { stats[i]->breastplate->beatitude++; } if ( stats[i]->gloves ) { stats[i]->gloves->beatitude++; } if ( stats[i]->shoes ) { stats[i]->shoes->beatitude++; } if ( stats[i]->shield ) { stats[i]->shield->beatitude++; } if ( stats[i]->weapon ) { stats[i]->weapon->beatitude++; } if ( stats[i]->cloak ) { stats[i]->cloak->beatitude++; } if ( stats[i]->amulet ) { stats[i]->amulet->beatitude++; } if ( stats[i]->ring ) { stats[i]->ring->beatitude++; } if ( stats[i]->mask ) { stats[i]->mask->beatitude++; } if ( multiplayer == SERVER && i > 0 ) { strcpy((char*)net_packet->data, "BLES"); net_packet->address.host = net_clients[i - 1].host; net_packet->address.port = net_clients[i - 1].port; net_packet->len = 4; sendPacketSafe(net_sock, -1, net_packet, i - 1); } break; } case 4: { // bless one piece of equipment playSoundEntity(players[i]->entity, 52, 64); Uint32 textcolor = SDL_MapRGB(mainsurface->format, 0, 255, 255); messagePlayerColor(i, textcolor, language[471]); //Choose only one piece of equipment to bless. //First, Figure out what equipment is available. std::vector<std::pair<Item*, Uint32>> items; if ( stats[i]->helmet ) { items.push_back(std::pair<Item*,int>(stats[i]->helmet, 0)); } if ( stats[i]->breastplate ) { items.push_back(std::pair<Item*,int>(stats[i]->breastplate, 1)); } if ( stats[i]->gloves ) { items.push_back(std::pair<Item*,int>(stats[i]->gloves, 2)); } if ( stats[i]->shoes ) { items.push_back(std::pair<Item*,int>(stats[i]->shoes, 3)); } if ( stats[i]->shield ) { items.push_back(std::pair<Item*,int>(stats[i]->shield, 4)); } if ( stats[i]->weapon ) { items.push_back(std::pair<Item*,int>(stats[i]->weapon, 5)); } if ( stats[i]->cloak ) { items.push_back(std::pair<Item*,int>(stats[i]->cloak, 6)); } if ( stats[i]->amulet ) { items.push_back(std::pair<Item*,int>(stats[i]->amulet, 7)); } if ( stats[i]->ring ) { items.push_back(std::pair<Item*,int>(stats[i]->ring, 8)); } if ( stats[i]->mask ) { items.push_back(std::pair<Item*,int>(stats[i]->mask, 9)); } if ( items.size() ) { messagePlayer(i, language[2592]); //"The fountain blesses a piece of equipment" //Randomly choose a piece of equipment. std::pair<Item*, Uint32> chosen = items[rand()%items.size()]; chosen.first->beatitude++; if ( multiplayer == SERVER && i > 0 ) { strcpy((char*)net_packet->data, "BLE1"); SDLNet_Write32(chosen.second, &net_packet->data[4]); net_packet->address.host = net_clients[i - 1].host; net_packet->address.port = net_clients[i - 1].port; net_packet->len = 8; sendPacketSafe(net_sock, -1, net_packet, i - 1); } } //Does nothing if no valid items. break; } default: break; } messagePlayer(i, language[474]); my->skill[0] = 0; //Dry up fountain. serverUpdateEntitySkill(my, my->skill[0]); //TODO: messagePlayersInSight() instead. } //Then perform the effect randomly determined when the fountain was created. return; } } } }
void actMinotaurTimer(Entity* my) { node_t* node; MINOTAURTIMER_LIFE++; if (( (currentlevel < 25 && MINOTAURTIMER_LIFE == TICKS_PER_SECOND * 120) || (currentlevel >= 25 && MINOTAURTIMER_LIFE == TICKS_PER_SECOND * 180) ) && rand() % 5 == 0 ) // two minutes if currentlevel < 25, else 3 minutes. { int c; bool spawnedsomebody = false; for ( c = 0; c < 9; c++ ) { Uint32 zapLeaderUid = 0; Entity* monster = summonMonster(HUMAN, my->x, my->y); if ( monster ) { monster->skill[29] = 1; // so we spawn a zap brigadier spawnedsomebody = true; if ( !zapLeaderUid ) { zapLeaderUid = monster->getUID(); } else { Stat* monsterStats = monster->getStats(); monsterStats->leader_uid = zapLeaderUid; } } } if ( spawnedsomebody ) { #ifdef MUSIC fadein_increment = default_fadein_increment * 20; fadeout_increment = default_fadeout_increment * 5; playmusic( sounds[175], false, true, false); #endif for ( c = 0; c < MAXPLAYERS; c++ ) { Uint32 color = SDL_MapRGB(mainsurface->format, 0, 255, 255); if ( stats[c]->type == HUMAN ) { messagePlayerColor(c, color, language[1114], stats[c]->name); } else { messagePlayerColor(c, color, language[3285]); } } } } else if (( (currentlevel < 25 && MINOTAURTIMER_LIFE >= TICKS_PER_SECOND * 150) || (currentlevel >= 25 && MINOTAURTIMER_LIFE >= TICKS_PER_SECOND * 210) ) && !MINOTAURTIMER_ACTIVE ) // two and a half minutes if currentlevel < 25, else 3.5 minutes { Entity* monster = summonMonster(MINOTAUR, my->x, my->y); if ( monster ) { int c; for ( c = 0; c < MAXPLAYERS; c++ ) { playSoundPlayer( c, 107 + rand() % 3, 128 ); Uint32 color = SDL_MapRGB(mainsurface->format, 255, 128, 0); messagePlayerColor(c, color, language[1115]); } MINOTAURTIMER_ACTIVE = MINOTAURTIMER_LIFE; } } if ( MINOTAURTIMER_ACTIVE && MINOTAURTIMER_LIFE >= MINOTAURTIMER_ACTIVE + TICKS_PER_SECOND * 3 ) { int c; for ( c = 0; c < MAXPLAYERS; c++ ) { if ( currentlevel < 25 ) { playSoundPlayer(c, 120 + rand() % 3, 128); Uint32 color = SDL_MapRGB(mainsurface->format, 255, 0, 255); messagePlayerColor(c, color, language[1116]); messagePlayerColor(c, color, language[73]); } else { playSoundPlayer(c, 375, 128); playSoundPlayer(c, 379, 128); messagePlayerColor(c, uint32ColorOrange(*mainsurface), language[1116]); messagePlayerColor(c, uint32ColorOrange(*mainsurface), language[73]); messagePlayerColor(c, uint32ColorBaronyBlue(*mainsurface), language[73]); } } list_RemoveNode(my->mynode); return; } }
int boulderCheckAgainstEntity(Entity *my, Entity *entity) { if (!my || !entity) return 0; if( entity->behavior == &actPlayer || entity->behavior == &actMonster ) { if( entityInsideEntity( my, entity ) ) { Stat *stats = entity->getStats(); if( stats ) { if( entity->behavior==&actPlayer ) { Uint32 color = SDL_MapRGB(mainsurface->format,255,0,0); messagePlayerColor(entity->skill[2],color,language[455]); if( entity->skill[2] == clientnum ) { camera_shakex += .1; camera_shakey += 10; } else { strcpy((char *)net_packet->data,"SHAK"); net_packet->data[4]=10; // turns into .1 net_packet->data[5]=10; net_packet->address.host = net_clients[entity->skill[2]-1].host; net_packet->address.port = net_clients[entity->skill[2]-1].port; net_packet->len = 6; sendPacketSafe(net_sock, -1, net_packet, entity->skill[2]-1); } } playSoundEntity(my,181,128); playSoundEntity(entity,28,64); spawnGib(entity); entity->modHP(-80); entity->setObituary(language[1505]); if( entity->behavior==&actPlayer ) if( stats->HP<=0 ) steamAchievementClient(entity->skill[2],"BARONY_ACH_THROW_ME_THE_WHIP"); if( stats->HP > 0 ) { // spawn several rock items int i = 8+rand()%4; int c; for( c=0; c<i; c++ ) { Entity *entity = newEntity(-1,1,map.entities); entity->flags[INVISIBLE]=TRUE; entity->flags[UPDATENEEDED]=TRUE; entity->x = my->x - 4 + rand()%8; entity->y = my->y - 4 + rand()%8; entity->z = -6+rand()%12; entity->sizex = 4; entity->sizey = 4; entity->yaw = rand()%360 * PI/180; entity->vel_x = (rand()%20-10)/10.0; entity->vel_y = (rand()%20-10)/10.0; entity->vel_z = -.25 - (rand()%5)/10.0; entity->flags[PASSABLE] = TRUE; entity->behavior = &actItem; entity->flags[USERFLAG1] = TRUE; // no collision: helps performance entity->skill[10] = GEM_ROCK; // type entity->skill[11] = WORN; // status entity->skill[12] = 0; // beatitude entity->skill[13] = 1; // count entity->skill[14] = 0; // appearance entity->skill[15] = FALSE; // identified } double ox = my->x; double oy = my->y; // destroy the boulder playSoundEntity(my,67,128); list_RemoveNode(my->mynode); // on sokoban, destroying boulders spawns scorpions if( !strcmp(map.name,"Sokoban") ) { Entity *monster = summonMonster(SCORPION,ox,oy); if( monster ) { int c; for( c=0; c<MAXPLAYERS; c++ ) { Uint32 color = SDL_MapRGB(mainsurface->format,255,128,0); messagePlayerColor(c,color,language[406]); } } } return 1; } } } } else if( entity->behavior == &actGate || entity->behavior == &actBoulder || entity->behavior==&actChest || entity->behavior==&actHeadstone || entity->behavior==&actFountain || entity->behavior==&actSink ) { if( !entity->flags[PASSABLE] ) { if( entityInsideEntity( my, entity ) ) { // stop the boulder BOULDER_STOPPED=1; BOULDER_ROLLING=0; playSoundEntity(my,181,128); if( my->flags[PASSABLE] ) { my->flags[PASSABLE] = FALSE; if( multiplayer==SERVER ) serverUpdateEntityFlag(my,PASSABLE); } } } } else if( entity->behavior == &actDoor ) { if( entityInsideEntity( my, entity ) ) { playSoundEntity(entity,28,64); entity->skill[4] = 0; if( !entity->skill[0] ) entity->skill[6] = (my->x > entity->x); else entity->skill[6] = (my->y < entity->y); playSoundEntity(my,181,128); } } return 0; }
void initGoblin(Entity *my, Stat *myStats) { int c; node_t *node; my->sprite = 180; //Goblin head model //my->flags[GENIUS] = TRUE; my->flags[UPDATENEEDED]=TRUE; my->flags[BLOCKSIGHT]=TRUE; my->flags[INVISIBLE]=FALSE; if( multiplayer!=CLIENT ) { MONSTER_SPOTSND = 60; MONSTER_SPOTVAR = 3; MONSTER_IDLESND = 98; MONSTER_IDLEVAR = 3; } if( multiplayer!=CLIENT && !MONSTER_INIT ) { myStats->sex = static_cast<sex_t>(rand()%2); myStats->appearance = rand(); strcpy(myStats->name,""); myStats->inventory.first = NULL; myStats->inventory.last = NULL; myStats->HP = 60; myStats->MAXHP = 60; myStats->MP = 20; myStats->MAXMP = 20; myStats->OLDHP = myStats->HP; myStats->STR = 6; myStats->DEX = 0; myStats->CON = 2; myStats->INT = -1; myStats->PER = 0; myStats->CHR = -1; myStats->EXP = 0; myStats->LVL = 6; if( rand()%3==0 ) { myStats->GOLD = 10+rand()%20; } else { myStats->GOLD = 0; } myStats->HUNGER = 900; if( !myStats->leader_uid ) myStats->leader_uid = 0; myStats->FOLLOWERS.first=NULL; myStats->FOLLOWERS.last=NULL; for( c=0; c<std::max(NUMPROFICIENCIES,NUMEFFECTS); c++ ) { if( c<NUMPROFICIENCIES ) myStats->PROFICIENCIES[c]=0; if( c<NUMEFFECTS ) myStats->EFFECTS[c]=FALSE; if( c<NUMEFFECTS ) myStats->EFFECTS_TIMERS[c]=0; } myStats->PROFICIENCIES[PRO_SWORD]=35; myStats->PROFICIENCIES[PRO_MACE]=50; myStats->PROFICIENCIES[PRO_AXE]=45; myStats->PROFICIENCIES[PRO_POLEARM]=25; myStats->PROFICIENCIES[PRO_RANGED]=35; myStats->PROFICIENCIES[PRO_SHIELD]=35; myStats->helmet = NULL; myStats->breastplate = NULL; myStats->gloves = NULL; myStats->shoes = NULL; myStats->shield = NULL; myStats->weapon = NULL; myStats->cloak = NULL; myStats->amulet = NULL; myStats->ring = NULL; myStats->mask = NULL; if( rand()%8==0 ) { myStats->EFFECTS[EFF_ASLEEP] = TRUE; myStats->EFFECTS_TIMERS[EFF_ASLEEP] = 1800+rand()%1800; } } // torso Entity *entity = newEntity(183, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->scalex = 1.01; entity->scaley = 1.01; entity->scalez = 1.01; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][1][0]; // 0 entity->focaly=limbs[GOBLIN][1][1]; // 0 entity->focalz=limbs[GOBLIN][1][2]; // 0 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // right leg entity = newEntity(182, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][2][0]; // 0 entity->focaly=limbs[GOBLIN][2][1]; // 0 entity->focalz=limbs[GOBLIN][2][2]; // 2 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // left leg entity = newEntity(181, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][3][0]; // 0 entity->focaly=limbs[GOBLIN][3][1]; // 0 entity->focalz=limbs[GOBLIN][3][2]; // 2 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // right arm entity = newEntity(178, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][4][0]; // 0 entity->focaly=limbs[GOBLIN][4][1]; // 0 entity->focalz=limbs[GOBLIN][4][2]; // 1.5 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // left arm entity = newEntity(176, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][5][0]; // 0 entity->focaly=limbs[GOBLIN][5][1]; // 0 entity->focalz=limbs[GOBLIN][5][2]; // 1.5 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // world weapon entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][6][0]; // 1.5 entity->focaly=limbs[GOBLIN][6][1]; // 0 entity->focalz=limbs[GOBLIN][6][2]; // -.5 entity->behavior=&actGoblinLimb; entity->parent=my->uid; entity->pitch=.25; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // shield entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][7][0]; // 2 entity->focaly=limbs[GOBLIN][7][1]; // 0 entity->focalz=limbs[GOBLIN][7][2]; // 0 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // cloak entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][8][0]; // 0 entity->focaly=limbs[GOBLIN][8][1]; // 0 entity->focalz=limbs[GOBLIN][8][2]; // 4 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // helmet entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->scalex = 1.01; entity->scaley = 1.01; entity->scalez = 1.01; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][9][0]; // 0 entity->focaly=limbs[GOBLIN][9][1]; // 0 entity->focalz=limbs[GOBLIN][9][2]; // -2 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); // mask entity = newEntity(-1, 0, map.entities); entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->uid; entity->flags[PASSABLE]=TRUE; entity->flags[NOUPDATE]=TRUE; entity->flags[USERFLAG2]=my->flags[USERFLAG2]; entity->focalx=limbs[GOBLIN][10][0]; // 0 entity->focaly=limbs[GOBLIN][10][1]; // 0 entity->focalz=limbs[GOBLIN][10][2]; // .25 entity->behavior=&actGoblinLimb; entity->parent=my->uid; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity *); if( multiplayer==CLIENT || MONSTER_INIT ) return; // give cloak switch( rand()%10 ) { case 0: case 1: case 2: case 3: case 4: case 5: break; case 6: case 7: case 8: myStats->cloak = newItem(CLOAK,WORN,-1+rand()%3,1,rand(),FALSE,NULL); break; case 9: myStats->cloak = newItem(CLOAK_MAGICREFLECTION,WORN,0,1,rand(),FALSE,NULL); break; } // give shield switch( rand()%10 ) { case 0: case 1: myStats->shield = newItem(TOOL_TORCH,SERVICABLE,-1+rand()%3,1,rand(),FALSE,NULL); break; case 2: case 3: case 4: break; case 5: case 6: myStats->shield = newItem(WOODEN_SHIELD,DECREPIT,-1+rand()%3,1,rand(),FALSE,NULL); break; case 7: case 8: myStats->shield = newItem(BRONZE_SHIELD,DECREPIT,-1+rand()%3,1,rand(),FALSE,NULL); break; case 9: myStats->shield = newItem(IRON_SHIELD,DECREPIT,-1+rand()%3,1,rand(),FALSE,NULL); break; } // give armor switch( rand()%10 ) { case 0: case 1: case 2: case 3: case 4: break; case 5: case 6: case 7: myStats->breastplate = newItem(LEATHER_BREASTPIECE,DECREPIT,-1+rand()%3,1,rand(),FALSE,NULL); break; case 8: case 9: myStats->breastplate = newItem(IRON_BREASTPIECE,DECREPIT,-1+rand()%3,1,rand(),FALSE,NULL); break; } if( rand()%50 || my->flags[USERFLAG2] ) { // give weapon switch( rand()%10 ) { case 0: case 1: case 2: myStats->weapon = newItem(SHORTBOW,WORN,-1+rand()%3,1,rand(),FALSE,NULL); break; case 3: case 4: case 5: myStats->weapon = newItem(BRONZE_AXE,WORN,-1+rand()%3,1,rand(),FALSE,NULL); break; case 6: case 7: myStats->weapon = newItem(IRON_MACE,WORN,-1+rand()%3,1,rand(),FALSE,NULL); break; case 8: myStats->weapon = newItem(IRON_AXE,WORN,-1+rand()%3,1,rand(),FALSE,NULL); break; case 9: myStats->weapon = newItem(MAGICSTAFF_FIRE,EXCELLENT,-1+rand()%3,1,rand(),FALSE,NULL); break; } // give helmet switch( rand()%10 ) { case 0: case 1: case 2: break; case 3: case 4: myStats->helmet = newItem(HAT_PHRYGIAN,WORN,-1+rand()%3,1,0,FALSE,NULL); break; case 5: myStats->helmet = newItem(HAT_WIZARD,WORN,-1+rand()%3,1,0,FALSE,NULL); break; case 6: case 7: myStats->helmet = newItem(LEATHER_HELM,WORN,-1+rand()%3,1,0,FALSE,NULL); break; case 8: case 9: myStats->helmet = newItem(IRON_HELM,WORN,-1+rand()%3,1,0,FALSE,NULL); break; } } else { myStats->HP = 120; myStats->MAXHP = 120; myStats->OLDHP = myStats->HP; strcpy(myStats->name,"The Potato King"); myStats->weapon = newItem(ARTIFACT_MACE,EXCELLENT,1,1,rand(),TRUE,NULL); myStats->helmet = newItem(HAT_JESTER,SERVICABLE,3+rand()%3,1,0,FALSE,NULL); int c; for( c=0; c<3; c++ ) { Entity *entity = summonMonster(GOBLIN,my->x,my->y); if( entity ) entity->parent = my->uid; } } }
void initHuman(Entity* my, Stat* myStats) { int c; node_t* node; my->initMonster(113); if ( multiplayer != CLIENT ) { MONSTER_SPOTSND = -1; MONSTER_SPOTVAR = 1; MONSTER_IDLESND = -1; MONSTER_IDLEVAR = 1; } if ( multiplayer != CLIENT && !MONSTER_INIT ) { if ( myStats != nullptr ) { if ( !myStats->leader_uid ) { myStats->leader_uid = 0; } my->createPathBoundariesNPC(); Stat baseStats(HUMAN); bool isDefaultStats = isMonsterStatsDefault(*myStats); // apply random stat increases if set in stat_shared.cpp or editor setRandomMonsterStats(myStats); // generate 6 items max, less if there are any forced items from boss variants int customItemsToGenerate = ITEM_CUSTOM_SLOT_LIMIT; // special human variant (named or Zap Brigadier), do not generate any other items int specialMonsterVariant = 0; // boss variants // generate special loadout if ( my->monsterSpecialTimer == 0 ) { if ( rand() % 25 == 0 ) { specialMonsterVariant = 1; int specialMonsterType = rand() % 10; if ( !strncmp(map.name, "Hamlet", 6) ) { while ( specialMonsterType == 6 ) // 2 spiders that spawn cause aggro issues in Hamlet. { specialMonsterType = rand() % 10; } } switch ( rand() % 10 ) { case 0: // red riding hood strcpy(myStats->name, "Red Riding Hood"); myStats->appearance = 2; myStats->sex = FEMALE; myStats->LVL = 1; myStats->HP = 10; myStats->MAXHP = myStats->HP; myStats->MP = 10; myStats->MAXMP = myStats->MP; myStats->STR = 0; myStats->DEX = 0; myStats->CON = 0; myStats->INT = -2; myStats->PER = -2; myStats->CHR = 4; myStats->helmet = newItem(HAT_PHRYGIAN, EXCELLENT, 1, 1, rand(), false, nullptr); myStats->cloak = newItem(CLOAK, EXCELLENT, 1, 1, 2, false, nullptr); myStats->weapon = newItem(QUARTERSTAFF, EXCELLENT, 1, 1, rand(), false, nullptr); break; case 1: // king arthur strcpy(myStats->name, "King Arthur"); myStats->appearance = 0; myStats->sex = MALE; myStats->LVL = 10; myStats->HP = 100; myStats->MAXHP = myStats->HP; myStats->MP = 100; myStats->MAXMP = myStats->MP; myStats->STR = 5; myStats->DEX = 5; myStats->CON = 5; myStats->INT = 5; myStats->PER = 5; myStats->CHR = 5; myStats->breastplate = newItem(STEEL_BREASTPIECE, EXCELLENT, 1, 1, 1, true, nullptr); myStats->gloves = newItem(GAUNTLETS, EXCELLENT, 1, 1, 1, true, nullptr); myStats->shoes = newItem(STEEL_BOOTS, EXCELLENT, 1, 1, 1, true, nullptr); myStats->cloak = newItem(CLOAK, EXCELLENT, 2, 1, 2, true, nullptr); myStats->weapon = newItem(ARTIFACT_SWORD, EXCELLENT, 1, 1, rand(), true, nullptr); myStats->shield = newItem(STEEL_SHIELD_RESISTANCE, EXCELLENT, 1, 1, 1, true, nullptr); break; case 2: // merlin strcpy(myStats->name, "Merlin"); myStats->appearance = 5; myStats->sex = MALE; myStats->LVL = 10; myStats->HP = 60; myStats->MAXHP = myStats->HP; myStats->MP = 200; myStats->MAXMP = myStats->MP; myStats->STR = 2; myStats->DEX = 2; myStats->CON = 3; myStats->INT = 11; myStats->PER = 10; myStats->CHR = 2; myStats->helmet = newItem(HAT_WIZARD, EXCELLENT, 2, 1, 2, false, nullptr); myStats->shoes = newItem(LEATHER_BOOTS_SPEED, EXCELLENT, 2, 1, 2, false, nullptr); myStats->cloak = newItem(CLOAK_PROTECTION, EXCELLENT, 5, 1, 3, false, nullptr); myStats->weapon = newItem(MAGICSTAFF_LIGHTNING, EXCELLENT, 2, 1, 2, false, nullptr); myStats->amulet = newItem(AMULET_MAGICREFLECTION, EXCELLENT, 2, 1, 2, false, nullptr); break; case 3: // robin hood strcpy(myStats->name, "Robin Hood"); myStats->appearance = 1; myStats->sex = MALE; myStats->LVL = 5; myStats->HP = 70; myStats->MAXHP = myStats->HP; myStats->MP = 50; myStats->MAXMP = myStats->MP; myStats->STR = 3; myStats->DEX = 5; myStats->CON = 3; myStats->INT = 2; myStats->PER = 3; myStats->CHR = 5; myStats->gloves = newItem(GLOVES, EXCELLENT, 1, 1, 3, true, nullptr); myStats->shoes = newItem(LEATHER_BOOTS, SERVICABLE, 1, 1, 3, true, nullptr); myStats->cloak = newItem(CLOAK, EXCELLENT, 1, 1, 0, true, nullptr); myStats->weapon = newItem(SHORTBOW, EXCELLENT, 1, 1, 3, true, nullptr); break; case 4: // conan strcpy(myStats->name, "Conan the Barbarian"); myStats->appearance = 7; myStats->sex = MALE; myStats->LVL = 10; myStats->HP = 100; myStats->MAXHP = myStats->HP; myStats->MP = 20; myStats->MAXMP = myStats->MP; myStats->STR = 10; myStats->DEX = 5; myStats->CON = 10; myStats->INT = 3; myStats->PER = 3; myStats->CHR = 20; myStats->helmet = newItem(LEATHER_HELM, EXCELLENT, 2, 1, rand(), false, nullptr); myStats->shield = newItem(WOODEN_SHIELD, EXCELLENT, 2, 1, rand(), false, nullptr); myStats->weapon = newItem(STEEL_AXE, EXCELLENT, 2, 1, rand(), false, nullptr); break; case 5: // othello strcpy(myStats->name, "Othello"); myStats->appearance = 14; myStats->sex = MALE; myStats->LVL = 10; myStats->HP = 50; myStats->MAXHP = myStats->HP; myStats->MP = 20; myStats->MAXMP = myStats->MP; myStats->STR = 3; myStats->DEX = 3; myStats->CON = 3; myStats->INT = 3; myStats->PER = 0; myStats->CHR = 30; myStats->gloves = newItem(BRACERS, EXCELLENT, -1, 1, rand(), false, nullptr); myStats->breastplate = newItem(IRON_BREASTPIECE, EXCELLENT, 1, 1, rand(), false, nullptr); myStats->weapon = newItem(STEEL_SWORD, EXCELLENT, 2, 1, rand(), false, nullptr); myStats->cloak = newItem(CLOAK, EXCELLENT, 0, 1, 2, false, nullptr); break; case 6: // anansi strcpy(myStats->name, "Anansi"); myStats->appearance = 15; myStats->sex = MALE; myStats->LVL = 20; myStats->HP = 100; myStats->MAXHP = myStats->HP; myStats->MP = 100; myStats->MAXMP = myStats->MP; myStats->STR = 5; myStats->DEX = 8; myStats->CON = 5; myStats->INT = 20; myStats->PER = 20; myStats->CHR = 10; myStats->helmet = newItem(HAT_JESTER, EXCELLENT, 5, 1, rand(), false, nullptr); myStats->weapon = newItem(ARTIFACT_MACE, EXCELLENT, 1, 1, rand(), false, nullptr); int c; for ( c = 0; c < 2; c++ ) { Entity* entity = summonMonster(SPIDER, my->x, my->y); if ( entity ) { entity->parent = my->getUID(); entity->flags[USERFLAG2] = true; } } break; case 7: // oya strcpy(myStats->name, "Oya"); myStats->appearance = 13; myStats->sex = FEMALE; myStats->LVL = 20; myStats->HP = 100; myStats->MAXHP = myStats->HP; myStats->MP = 100; myStats->MAXMP = myStats->MP; myStats->STR = 4; myStats->DEX = 10; myStats->CON = 2; myStats->INT = 20; myStats->PER = 10; myStats->CHR = 10; myStats->cloak = newItem(CLOAK_PROTECTION, EXCELLENT, 3, 1, 1, false, nullptr); myStats->helmet = newItem(HAT_HOOD, EXCELLENT, 3, 1, 1, false, nullptr); break; case 8: // vishpala strcpy(myStats->name, "Vishpala"); myStats->appearance = 17; myStats->sex = FEMALE; myStats->LVL = 10; myStats->HP = 70; myStats->MAXHP = myStats->HP; myStats->MP = 20; myStats->MAXMP = myStats->MP; myStats->STR = 5; myStats->DEX = 5; myStats->CON = 5; myStats->INT = 5; myStats->PER = 5; myStats->CHR = 10; myStats->cloak = newItem(CLOAK, EXCELLENT, 0, 1, 2, false, nullptr); myStats->breastplate = newItem(IRON_BREASTPIECE, EXCELLENT, 0, 1, rand(), false, nullptr); myStats->shoes = newItem(IRON_BOOTS, EXCELLENT, 0, 1, rand(), false, nullptr); myStats->weapon = newItem(ARTIFACT_SPEAR, EXCELLENT, 1, 1, rand(), false, nullptr); myStats->shield = newItem(BRONZE_SHIELD, EXCELLENT, 1, 1, rand(), false, nullptr); break; case 9: // kali strcpy(myStats->name, "Kali"); myStats->appearance = 15; myStats->sex = FEMALE; myStats->LVL = 20; myStats->HP = 200; myStats->MAXHP = myStats->HP; myStats->MP = 200; myStats->MAXMP = myStats->MP; myStats->STR = 5; myStats->DEX = 5; myStats->CON = 5; myStats->INT = 20; myStats->PER = 20; myStats->CHR = 20; myStats->cloak = newItem(CLOAK_MAGICREFLECTION, EXCELLENT, 1, 1, 2, false, nullptr); myStats->shoes = newItem(LEATHER_BOOTS_SPEED, EXCELLENT, 1, 1, rand(), false, nullptr); myStats->weapon = newItem(SPELLBOOK_FIREBALL, EXCELLENT, 1, 1, rand(), false, nullptr); break; default: break; } } } else { specialMonsterVariant = 1; // zap brigadier strcpy(myStats->name, "ZAP Brigadier"); myStats->appearance = 1; myStats->sex = static_cast<sex_t>(rand() % 2); myStats->LVL = 10; myStats->HP = 100; myStats->MAXHP = myStats->HP; myStats->MP = 200; myStats->MAXMP = myStats->MP; myStats->STR = 3; myStats->DEX = 3; myStats->CON = 3; myStats->INT = 3; myStats->PER = 10; myStats->CHR = 10; myStats->helmet = newItem(HAT_HOOD, EXCELLENT, 2, 1, 3, false, nullptr); myStats->gloves = newItem(GLOVES, EXCELLENT, 0, 1, 2, false, nullptr); myStats->shoes = newItem(LEATHER_BOOTS_SPEED, EXCELLENT, 0, 1, 2, false, nullptr); myStats->breastplate = newItem(LEATHER_BREASTPIECE, EXCELLENT, 0, 1, 2, false, nullptr); myStats->cloak = newItem(CLOAK_PROTECTION, EXCELLENT, 2, 1, 3, false, nullptr); myStats->weapon = newItem(MAGICSTAFF_LIGHTNING, EXCELLENT, 1, 1, 2, false, nullptr); myStats->amulet = newItem(AMULET_MAGICREFLECTION, EXCELLENT, 1, 1, 2, false, nullptr); } // random effects if ( rand() % 10 == 0 ) { myStats->EFFECTS[EFF_ASLEEP] = true; myStats->EFFECTS_TIMERS[EFF_ASLEEP] = 1800 + rand() % 1800; } // generates equipment and weapons if available from editor createMonsterEquipment(myStats); // create any custom inventory items from editor if available createCustomInventory(myStats, customItemsToGenerate); // count if any custom inventory items from editor int customItems = countCustomItems(myStats); //max limit of 6 custom items per entity. // count any inventory items set to default in edtior int defaultItems = countDefaultItems(myStats); if ( specialMonsterVariant == 0 && my->monsterStoreType > 0 && isDefaultStats ) { myStats->EXP += 100 * my->monsterStoreType; // apply experience to level up the humans with floor depth. } // generate the default inventory items for the monster, provided the editor sprite allowed enough default slots switch ( defaultItems ) { case 6: case 5: case 4: case 3: case 2: case 1: break; default: break; } if ( specialMonsterVariant == 0 ) { // generate random equipment if not a named special human //give shield if ( myStats->shield == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_SHIELD] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: myStats->shield = newItem(TOOL_TORCH, SERVICABLE, 0, 1, rand(), false, nullptr); break; case 3: case 4: break; case 5: case 6: myStats->shield = newItem(WOODEN_SHIELD, WORN, 0, 1, rand(), false, nullptr); break; case 7: case 8: myStats->shield = newItem(BRONZE_SHIELD, WORN, 0, 1, rand(), false, nullptr); break; case 9: myStats->shield = newItem(IRON_SHIELD, WORN, 0, 1, rand(), false, nullptr); break; } } //give weapon if ( myStats->weapon == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_WEAPON] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: myStats->weapon = newItem(SHORTBOW, WORN, 0, 1, rand(), false, nullptr); break; case 2: case 3: myStats->weapon = newItem(BRONZE_AXE, WORN, 0, 1, rand(), false, nullptr); break; case 4: case 5: myStats->weapon = newItem(BRONZE_SWORD, WORN, 0, 1, rand(), false, nullptr); break; case 6: myStats->weapon = newItem(IRON_SPEAR, WORN, 0, 1, rand(), false, nullptr); break; case 7: myStats->weapon = newItem(IRON_AXE, WORN, 0, 1, rand(), false, nullptr); break; case 8: myStats->weapon = newItem(IRON_SWORD, WORN, 0, 1, rand(), false, nullptr); break; case 9: myStats->weapon = newItem(CROSSBOW, WORN, 0, 1, rand(), false, nullptr); break; } } // give helmet if ( myStats->helmet == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_HELM] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: break; case 3: myStats->helmet = newItem(HAT_HOOD, WORN, 0, 1, rand() % 4, false, nullptr); break; case 4: myStats->helmet = newItem(HAT_PHRYGIAN, WORN, 0, 1, rand(), false, nullptr); break; case 5: myStats->helmet = newItem(HAT_WIZARD, WORN, 0, 1, rand(), false, nullptr); break; case 6: case 7: myStats->helmet = newItem(LEATHER_HELM, WORN, 0, 1, rand(), false, nullptr); break; case 8: case 9: myStats->helmet = newItem(IRON_HELM, WORN, 0, 1, rand(), false, nullptr); break; } } // give cloak if ( myStats->cloak == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_CLOAK] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: case 3: case 4: case 5: break; case 6: case 7: case 8: myStats->cloak = newItem(CLOAK, WORN, 0, 1, rand(), false, nullptr); break; case 9: myStats->cloak = newItem(CLOAK_MAGICREFLECTION, WORN, 0, 1, rand(), false, nullptr); break; } } // give armor if ( myStats->breastplate == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_ARMOR] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: case 3: case 4: break; case 5: case 6: case 7: myStats->breastplate = newItem(LEATHER_BREASTPIECE, WORN, 0, 1, rand(), false, nullptr); break; case 8: case 9: myStats->breastplate = newItem(IRON_BREASTPIECE, WORN, 0, 1, rand(), false, nullptr); break; } } // give gloves if ( myStats->gloves == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_GLOVES] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: case 3: case 4: break; case 5: case 6: case 7: myStats->gloves = newItem(GLOVES, WORN, 0, 1, rand(), false, nullptr); break; case 8: case 9: myStats->gloves = newItem(GAUNTLETS, WORN, 0, 1, rand(), false, nullptr); break; } } // give boots if ( myStats->shoes == nullptr && myStats->EDITOR_ITEMS[ITEM_SLOT_BOOTS] == 1 ) { switch ( rand() % 10 ) { case 0: case 1: case 2: case 3: case 4: break; case 5: case 6: case 7: myStats->shoes = newItem(LEATHER_BOOTS, WORN, 0, 1, rand(), false, nullptr); break; case 8: case 9: myStats->shoes = newItem(IRON_BOOTS, WORN, 0, 1, rand(), false, nullptr); break; } } } } } // torso Entity* entity = newEntity(106, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][1][0]; // 0 entity->focaly = limbs[HUMAN][1][1]; // 0 entity->focalz = limbs[HUMAN][1][2]; // 0 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // right leg entity = newEntity(107, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][2][0]; // 0 entity->focaly = limbs[HUMAN][2][1]; // 0 entity->focalz = limbs[HUMAN][2][2]; // 2 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // left leg entity = newEntity(108, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][3][0]; // 0 entity->focaly = limbs[HUMAN][3][1]; // 0 entity->focalz = limbs[HUMAN][3][2]; // 2 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // right arm entity = newEntity(109, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][4][0]; // 0 entity->focaly = limbs[HUMAN][4][1]; // 0 entity->focalz = limbs[HUMAN][4][2]; // 1.5 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // left arm entity = newEntity(110, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][5][0]; // 0 entity->focaly = limbs[HUMAN][5][1]; // 0 entity->focalz = limbs[HUMAN][5][2]; // 1.5 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // world weapon entity = newEntity(-1, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][6][0]; // 1.5 entity->focaly = limbs[HUMAN][6][1]; // 0 entity->focalz = limbs[HUMAN][6][2]; // -.5 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); entity->pitch = .25; node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // shield entity = newEntity(-1, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][7][0]; // 2 entity->focaly = limbs[HUMAN][7][1]; // 0 entity->focalz = limbs[HUMAN][7][2]; // 0 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // cloak entity = newEntity(-1, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->scalex = 1.01; entity->scaley = 1.01; entity->scalez = 1.01; entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][8][0]; // 0 entity->focaly = limbs[HUMAN][8][1]; // 0 entity->focalz = limbs[HUMAN][8][2]; // 4 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // helmet entity = newEntity(-1, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->scalex = 1.01; entity->scaley = 1.01; entity->scalez = 1.01; entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][9][0]; // 0 entity->focaly = limbs[HUMAN][9][1]; // 0 entity->focalz = limbs[HUMAN][9][2]; // -1.75 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); // mask entity = newEntity(-1, 0, map.entities, nullptr); //Limb entity. entity->sizex = 4; entity->sizey = 4; entity->skill[2] = my->getUID(); entity->scalex = .99; entity->scaley = .99; entity->scalez = .99; entity->flags[PASSABLE] = true; entity->flags[NOUPDATE] = true; entity->flags[USERFLAG2] = my->flags[USERFLAG2]; entity->focalx = limbs[HUMAN][10][0]; // 0 entity->focaly = limbs[HUMAN][10][1]; // 0 entity->focalz = limbs[HUMAN][10][2]; // .5 entity->behavior = &actHumanLimb; entity->parent = my->getUID(); node = list_AddNodeLast(&my->children); node->element = entity; node->deconstructor = &emptyDeconstructor; node->size = sizeof(Entity*); my->bodyparts.push_back(entity); if ( multiplayer == CLIENT ) { my->sprite = 113; // human head model return; } // set head model if ( myStats->appearance < 5 ) { my->sprite = 113 + 12 * myStats->sex + myStats->appearance; } else if ( myStats->appearance == 5 ) { my->sprite = 332 + myStats->sex; } else if ( myStats->appearance >= 6 && myStats->appearance < 12 ) { my->sprite = 341 + myStats->sex * 13 + myStats->appearance - 6; } else if ( myStats->appearance >= 12 ) { my->sprite = 367 + myStats->sex * 13 + myStats->appearance - 12; } else { my->sprite = 113; // default } }