/* * Copyright (C) 2002-2007 The Warp Rogue Team * Part of the Warp Rogue Project * * This software is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License. * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY. * * See the license.txt file for more details. */ /* * Module Name: Faction * Description: - */ #define Uses_Character #define Uses_Perception #define Uses_Ui #define Uses_Area #define Uses_Party #include "mheader.h" #include "faction.h" static void make_hostile(CHARACTER *); /* * prevents the player from accidently attacking non-hostile characters * and executes the consequences if the player confirms the attack */ bool hostility_check(CHARACTER *target) { CONFIRMATION_DIALOGUE dialogue; if (hostility_between(player_character(), target)) { return true; } strcpy(dialogue.prompt, "Attack against non-hostile character, sure?"); dialogue.confirmed = false; attack_confirmation_dialogue(&dialogue); if (dialogue.confirmed) { make_hostile(target); return true; } return false; } /* * returns true if there is hostility between the characters */ bool hostility_between(const CHARACTER *c1, const CHARACTER *c2) { if (c1->party == PARTY_PLAYER) { if (c2->is_hostile) return true; return false; } else if (c2->party == PARTY_PLAYER) { if (c1->is_hostile) return true; return false; } return false; } /* * makes a character and all characters who can see him and who * do not belong the player's party hostile */ static void make_hostile(CHARACTER *character) { LIST_NODE *node; CHARACTER *c; character->is_hostile = true; if (character->party == PARTY_PLAYER) { party_leave(character); } for (node = area_character_list()->head; node != NULL; node = node->next) { c = (CHARACTER *)node->data; if (c->party == PARTY_PLAYER) continue; if (!los(&character->location, &c->location)) { continue; } c->is_hostile = true; } }