// __ ___ _ _ __ __ _ ___ ___ _ __ // \ \/ / | | | '_ \ / _` |/ _ \/ _ \| '_ \ // > <| |_| | | | | (_| | __/ (_) | | | | // /_/\_\\__,_|_| |_|\__, |\___|\___/|_| |_| // |___/ // // Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic // // xolatile@chud.cyou - xungeon - Small library for defining dungeon crawler gameplay information. // // This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU // General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish... // // This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied // warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License // for more details, if you dare, it is a lot of text that nobody wants to read... //~typedef struct { //~character * name; //~} * _definition; typedef struct { character * name; // Name string copy. natural temperature; // ; natural humidity; // ; } * dungeon_biome_definition; typedef struct { character * name; // Name string copy. natural biome; // Index in biome array. boolean clip; // Can entities move through? } * dungeon_landmark_definition; typedef struct { character * name; // Name string copy. } * dungeon_expertise_definition; typedef struct { character * name; // Name string copy. natural base; // Default amount of points per entity. natural limit; // After this point, points won't increase. } * dungeon_attribute_definition; typedef struct { character * name; // Name string copy. natural base; // Default amount of points per entity. natural limit; // After this point, points won't increase. } * dungeon_skill_definition; typedef struct { character * name; // Name string copy. natural base; // Default amount of points per entity. natural limit; // After this point, points won't increase. natural value; // Constant trade value per index 0. natural trade; // Trade rate for acquiring the resource. } * dungeon_resource_definition; typedef struct { character * name; // Name string copy. } * dungeon_item_slot_definition; typedef struct { character * name; // Name string copy. natural slot; // Index in item slot array. natural effect; // Index in effect array. } * dungeon_item_definition; typedef struct { natural biome_count; natural landmark_count; natural expertise_count; natural attribute_count; natural skill_count; natural resource_count; natural item_slot_count; natural item_count; dungeon_biome_definition * biome_array; dungeon_landmark_definition * landmark_array; dungeon_expertise_definition * expertise_array; dungeon_attribute_definition * attribute_array; dungeon_skill_definition * skill_array; dungeon_resource_definition * resource_array; dungeon_item_slot_definition * item_slot_array; dungeon_item_definition * item_array; } * dungeon_structure; static natural dungeon_biome_define (dungeon_structure dungeon, character * name, natural temperature, natural humidity) { dungeon_biome_definition biome = arena_add (sizeof (* biome)); fatal_failure (dungeon == null, "biome_define: Dungeon is not configured."); fatal_failure (name == null, "biome_define: Name is null pointer."); string_copy ((biome->name = arena_add ((string_length (name) + 1) * sizeof (* biome->name))), name); biome->temperature = temperature; biome->humidity = humidity; dungeon->biome_count += 1; dungeon->biome_array [dungeon->biome_count - 1] = biome; return (dungeon->biome_count - 1); } static character * dungeon_biome_name (dungeon_structure dungeon, natural index) { return (dungeon->biome_array [index]->name); } static natural dungeon_biome_temperature (dungeon_structure dungeon, natural index) { return (dungeon->biome_array [index]->temperature); } static natural dungeon_biome_humidity (dungeon_structure dungeon, natural index) { return (dungeon->biome_array [index]->humidity); } static natural dungeon_landmark_define (dungeon_structure dungeon, character * name, natural biome, boolean clip) { dungeon_landmark_definition landmark = arena_add (sizeof (* landmark)); fatal_failure (dungeon == null, "landmark_define: Dungeon is not configured."); fatal_failure (name == null, "landmark_define: Name is null pointer."); string_copy ((landmark->name = arena_add ((string_length (name) + 1) * sizeof (* landmark->name))), name); landmark->biome = biome; landmark->clip = clip; dungeon->landmark_count += 1; dungeon->landmark_array [dungeon->landmark_count - 1] = landmark; return (dungeon->landmark_count - 1); } static character * dungeon_landmark_name (dungeon_structure dungeon, natural index) { return (dungeon->landmark_array [index]->name); } static natural dungeon_landmark_biome (dungeon_structure dungeon, natural index) { return (dungeon->landmark_array [index]->biome); } static boolean dungeon_landmark_clip (dungeon_structure dungeon, natural index) { return (dungeon->landmark_array [index]->clip); } static natural dungeon_expertise_define (dungeon_structure dungeon, character * name) { dungeon_expertise_definition expertise = arena_add (sizeof (* expertise)); fatal_failure (dungeon == null, "expertise_define: Dungeon is not configured."); fatal_failure (name == null, "expertise_define: Name is null pointer."); string_copy ((expertise->name = arena_add ((string_length (name) + 1) * sizeof (* expertise->name))), name); dungeon->expertise_count += 1; dungeon->expertise_array [dungeon->expertise_count - 1] = expertise; return (dungeon->expertise_count - 1); } static character * dungeon_expertise_name (dungeon_structure dungeon, natural index) { return (dungeon->expertise_array [index]->name); } static natural dungeon_attribute_define (dungeon_structure dungeon, character * name, natural base, natural limit) { dungeon_attribute_definition attribute = arena_add (sizeof (* attribute)); fatal_failure (dungeon == null, "attribute_define: Dungeon is not configured."); fatal_failure (name == null, "attribute_define: Name is null pointer."); string_copy ((attribute->name = arena_add ((string_length (name) + 1) * sizeof (* attribute->name))), name); attribute->base = base; attribute->limit = limit; dungeon->attribute_count += 1; dungeon->attribute_array [dungeon->attribute_count - 1] = attribute; return (dungeon->attribute_count - 1); } static character * dungeon_attribute_name (dungeon_structure dungeon, natural index) { return (dungeon->attribute_array [index]->name); } static natural dungeon_attribute_base (dungeon_structure dungeon, natural index) { return (dungeon->attribute_array [index]->base); } static natural dungeon_attribute_limit (dungeon_structure dungeon, natural index) { return (dungeon->attribute_array [index]->limit); } static natural dungeon_skill_define (dungeon_structure dungeon, character * name, natural base, natural limit) { dungeon_skill_definition skill = arena_add (sizeof (* skill)); fatal_failure (dungeon == null, "skill_define: Dungeon is not configured."); fatal_failure (name == null, "skill_define: Name is null pointer."); string_copy ((skill->name = arena_add ((string_length (name) + 1) * sizeof (* skill->name))), name); skill->base = base; skill->limit = limit; dungeon->skill_count += 1; dungeon->skill_array [dungeon->skill_count - 1] = skill; return (dungeon->skill_count - 1); } static character * dungeon_skill_name (dungeon_structure dungeon, natural index) { return (dungeon->skill_array [index]->name); } static natural dungeon_skill_base (dungeon_structure dungeon, natural index) { return (dungeon->skill_array [index]->base); } static natural dungeon_skill_limit (dungeon_structure dungeon, natural index) { return (dungeon->skill_array [index]->limit); } static natural dungeon_resource_define (dungeon_structure dungeon, character * name, natural base, natural limit, natural value, natural trade) { dungeon_resource_definition resource = arena_add (sizeof (* resource)); fatal_failure (dungeon == null, "resource_define: Dungeon is not configured."); fatal_failure (name == null, "resource_define: Name is null pointer."); string_copy ((resource->name = arena_add ((string_length (name) + 1) * sizeof (* resource->name))), name); resource->base = base; resource->limit = limit; resource->value = value; resource->trade = trade; dungeon->resource_count += 1; dungeon->resource_array [dungeon->resource_count - 1] = resource; return (dungeon->resource_count - 1); } static character * dungeon_resource_name (dungeon_structure dungeon, natural index) { return (dungeon->resource_array [index]->name); } static natural dungeon_resource_base (dungeon_structure dungeon, natural index) { return (dungeon->resource_array [index]->base); } static natural dungeon_resource_limit (dungeon_structure dungeon, natural index) { return (dungeon->resource_array [index]->limit); } static natural dungeon_resource_value (dungeon_structure dungeon, natural index) { return (dungeon->resource_array [index]->value); } static natural dungeon_resource_trade (dungeon_structure dungeon, natural index) { return (dungeon->resource_array [index]->trade); } static natural dungeon_item_slot_define (dungeon_structure dungeon, character * name) { dungeon_item_slot_definition item_slot = arena_add (sizeof (* item_slot)); fatal_failure (dungeon == null, "item_slot_define: Dungeon is not configured."); fatal_failure (name == null, "item_slot_define: Name is null pointer."); string_copy ((item_slot->name = arena_add ((string_length (name) + 1) * sizeof (* item_slot->name))), name); dungeon->item_slot_count += 1; dungeon->item_slot_array [dungeon->item_slot_count - 1] = item_slot; return (dungeon->item_slot_count - 1); } static character * dungeon_item_slot_name (dungeon_structure dungeon, natural index) { return (dungeon->item_slot_array [index]->name); } static natural dungeon_item_define (dungeon_structure dungeon, character * name, natural slot, natural effect) { dungeon_item_definition item = arena_add (sizeof (* item)); fatal_failure (dungeon == null, "item_define: Dungeon is not configured."); fatal_failure (name == null, "item_define: Name is null pointer."); string_copy ((item->name = arena_add ((string_length (name) + 1) * sizeof (* item->name))), name); item->slot = slot; item->effect = effect; dungeon->item_count += 1; dungeon->item_array [dungeon->item_count - 1] = item; return (dungeon->item_count - 1); } static character * dungeon_item_name (dungeon_structure dungeon, natural index) { return (dungeon->item_array [index]->name); } static natural dungeon_item_slot (dungeon_structure dungeon, natural index) { return (dungeon->item_array [index]->slot); } static natural dungeon_item_effect (dungeon_structure dungeon, natural index) { return (dungeon->item_array [index]->effect); } static dungeon_structure dungeon_configure (natural biome_limit, natural landmark_limit, natural expertise_limit, natural attribute_limit, natural skill_limit, natural resource_limit, natural item_slot_limit, natural item_limit) { dungeon_structure dungeon = arena_add (sizeof (* dungeon)); dungeon->biome_array = arena_add (biome_limit * sizeof (* dungeon->biome_array)); dungeon->landmark_array = arena_add (landmark_limit * sizeof (* dungeon->landmark_array)); dungeon->expertise_array = arena_add (expertise_limit * sizeof (* dungeon->expertise_array)); dungeon->attribute_array = arena_add (attribute_limit * sizeof (* dungeon->attribute_array)); dungeon->skill_array = arena_add (skill_limit * sizeof (* dungeon->skill_array)); dungeon->resource_array = arena_add (resource_limit * sizeof (* dungeon->resource_array)); dungeon->item_slot_array = arena_add (item_slot_limit * sizeof (* dungeon->item_slot_array)); dungeon->item_array = arena_add (item_limit * sizeof (* dungeon->item_array)); return (dungeon); }