void handle_keyword(int tag) { bool cheated= true; switch (tag) { case _tag_health: if (local_player->suit_energy<PLAYER_MAXIMUM_SUIT_ENERGY) { local_player->suit_energy= PLAYER_MAXIMUM_SUIT_ENERGY; } else { if (local_player->suit_energy<2*PLAYER_MAXIMUM_SUIT_ENERGY) { local_player->suit_energy= 2*PLAYER_MAXIMUM_SUIT_ENERGY; } else { local_player->suit_energy= MAX(local_player->suit_energy, 3*PLAYER_MAXIMUM_SUIT_ENERGY); } } mark_shield_display_as_dirty(); break; case _tag_oxygen: local_player->suit_oxygen= MAX(local_player->suit_oxygen,PLAYER_MAXIMUM_SUIT_OXYGEN); mark_oxygen_display_as_dirty(); break; case _tag_map: dynamic_world->game_information.game_options^= (_overhead_map_shows_items|_overhead_map_shows_monsters|_overhead_map_shows_projectiles); break; case _tag_invincible: process_player_powerup(local_player_index, _i_invincibility_powerup); break; case _tag_invisible: process_player_powerup(local_player_index, _i_invisibility_powerup); break; case _tag_infravision: process_player_powerup(local_player_index, _i_infravision_powerup); break; case _tag_extravision: process_player_powerup(local_player_index, _i_extravision_powerup); break; case _tag_jump: accelerate_monster(local_player->monster_index, WORLD_ONE/10, 0, 0); break; // LP: changed these cheats and added new ones: case _tag_pistol: AddOneItemToPlayer(_i_magnum,2); AddItemsToPlayer(_i_magnum_magazine,10); break; case _tag_rifle: AddItemsToPlayer(_i_assault_rifle,10); AddItemsToPlayer(_i_assault_rifle_magazine,10); AddItemsToPlayer(_i_assault_grenade_magazine,10); break; case _tag_missile: AddItemsToPlayer(_i_missile_launcher,1); AddItemsToPlayer(_i_missile_launcher_magazine,10); break; case _tag_toaster: AddItemsToPlayer(_i_flamethrower,1); AddItemsToPlayer(_i_flamethrower_canister,10); break; case _tag_fusion: AddItemsToPlayer(_i_plasma_pistol,1); AddItemsToPlayer(_i_plasma_magazine,10); break; case _tag_pzbxay: AddItemsToPlayer(_i_alien_shotgun,1); break; case _tag_shotgun: AddOneItemToPlayer(_i_shotgun,2); AddItemsToPlayer(_i_shotgun_magazine,10); break; case _tag_smg: AddOneItemToPlayer(_i_smg,2); AddItemsToPlayer(_i_smg_ammo,10); break; case _tag_save: save_game(); break; // LP guess as to what might be good: ammo-only version of "aslag" case _tag_ammo: { short items[]= { _i_assault_rifle, _i_magnum, _i_missile_launcher, _i_flamethrower, _i_plasma_pistol, _i_alien_shotgun, _i_shotgun, _i_assault_rifle_magazine, _i_assault_grenade_magazine, _i_magnum_magazine, _i_missile_launcher_magazine, _i_flamethrower_canister, _i_plasma_magazine, _i_shotgun_magazine, _i_shotgun, _i_smg, _i_smg_ammo}; for(unsigned index= 0; index<sizeof(items)/sizeof(short); ++index) { switch(get_item_kind(items[index])) { case _ammunition: AddItemsToPlayer(items[index],10); break; } } } break; case _tag_aslag: { // LP change: added the SMG and its ammo short items[]= { _i_assault_rifle, _i_magnum, _i_missile_launcher, _i_flamethrower, _i_plasma_pistol, _i_alien_shotgun, _i_shotgun, _i_assault_rifle_magazine, _i_assault_grenade_magazine, _i_magnum_magazine, _i_missile_launcher_magazine, _i_flamethrower_canister, _i_plasma_magazine, _i_shotgun_magazine, _i_shotgun, _i_smg, _i_smg_ammo}; for(unsigned index= 0; index<sizeof(items)/sizeof(short); ++index) { switch(get_item_kind(items[index])) { case _weapon: if(items[index]==_i_shotgun || items[index]==_i_magnum) { AddOneItemToPlayer(items[index],2); } else { AddItemsToPlayer(items[index],1); } break; case _ammunition: AddItemsToPlayer(items[index],10); break; case _powerup: case _weapon_powerup: break; default: break; } process_new_item_for_reloading(local_player_index, items[index]); } } local_player->suit_energy = MAX(local_player->suit_energy, 3*PLAYER_MAXIMUM_SUIT_ENERGY); update_interface(NONE); break; default: cheated= false; break; } // / can't use computer terminals or save in the final version if we've cheated // if (cheated) SET_PLAYER_HAS_CHEATED(local_player); #if 0 if (cheated) { long final_ticks; SetSoundVol(7); play_local_sound(20110); Delay(45, &final_ticks); play_local_sound(20110); Delay(45, &final_ticks); play_local_sound(20110); } #endif return; }
bool try_and_add_player_item(short player_index, short type) { item_definition *definition = get_item_definition(type); // LP change: added idiot-proofing if (!definition) return false; player_data *player = get_player_data(player_index); short grabbed_sound_index = NONE; bool success = false; switch (definition->item_kind) { case _powerup: /* powerups donÕt get added to your inventory */ if (legal_player_powerup(player_index, type)) { process_player_powerup(player_index, type); object_was_just_destroyed(_object_is_item, type); grabbed_sound_index= Sound_GotPowerup(); success= true; } break; case _ball: // START Benad /* Note that you can only carry ONE ball (ever) */ if(find_player_ball_color(player_index)==NONE) { player_data *player= get_player_data(player_index); // When taking ball of your own team, it returns to its original // position on the map, unless it's already in our base (or hill). if ( (GET_GAME_TYPE() == _game_of_capture_the_flag) && (type - BALL_ITEM_BASE == player->team) ) { // START Benad modified oct. 1st polygon_data *polygon= get_polygon_data(player->supporting_polygon_index); if (polygon->type!=_polygon_is_base) { object_was_just_destroyed(_object_is_item, type); grabbed_sound_index= Sound_GotItem(); success= true; goto DONE; } else // _polygon_is_base and base == player->team // base != player->team taken care of in update_net_game // (your ball should NEVER get there) { success= false; goto DONE; } // END Benad modified oct. 1st } else if (GET_GAME_TYPE() == _game_of_rugby) { // ghs: work around for SF 2894880 // if you're in an enemy base // and pick up the ball, you // score polygon_data* polygon = get_polygon_data(player->supporting_polygon_index); if (polygon->type == _polygon_is_base && polygon->permutation != player->team) { /* Goal! */ // defined in network_games.cpp const int _points_scored = 0; player->netgame_parameters[_points_scored]++; team_netgame_parameters[player->team][_points_scored]++; object_was_just_destroyed(_object_is_item, type); grabbed_sound_index = Sound_GotItem(); success = true; goto DONE; } } player->items[type]= 1; // OK, since only for loading weapon. Ignores item_type, cares // only about item_kind (here, _ball). /* Load the ball weapon.. */ process_new_item_for_reloading(player_index, _i_red_ball); /* Tell the interface to redraw next time it has to */ mark_player_inventory_as_dirty(player_index, type); success= true; } grabbed_sound_index= NONE; break; // END Benad case _weapon: case _ammunition: case _item: /* Increment the count */ assert(type>=0 && type<NUMBER_OF_ITEMS); if(player->items[type]==NONE) { /* just got the first one.. */ player->items[type]= 1; success= true; } else if(player->items[type]+1<=definition->maximum_count_per_player || (dynamic_world->game_information.difficulty_level==_total_carnage_level && ((static_world->environment_flags & _environment_m1_weapon_pickups) || definition->item_kind==_ammunition))) { /* Increment your count.. */ player->items[type]++; success= true; } else { /* You have exceeded the count of these items */ } grabbed_sound_index= Sound_GotItem(); if(success) { /* Reload or whatever.. */ process_new_item_for_reloading(player_index, type); /* Tell the interface to redraw next time it has to */ mark_player_inventory_as_dirty(player_index, type); } break; default: assert(false); break; } // Benad. Burk. DONE: //CP Addition: call any script traps available // jkvw: but only if we actually got the item if (success) { //MH: Call Lua script hook L_Call_Got_Item(type, player_index); } /* Play the pickup sound */ if (success && player_index==current_player_index) { SoundManager::instance()->PlayLocalSound(grabbed_sound_index); /* Flash screen */ start_fade(_fade_bonus); } return success; }