From b53127600c81501da628001f462066087cdbde10 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 26 May 2012 00:48:00 +0300 Subject: [PATCH] script now can restrict monsters to specified dungeons (see AllowedDungeons in char.dat) --- ChangeLog | 1 + NEWZ | 4 ++++ Script/char.dat | 1 + Script/define.dat | 3 +++ src/game/char.cpp | 19 ++++++++++++++++--- src/game/char.h | 3 +++ src/game/confdef.h | 1 + src/game/database.cpp | 1 + src/game/game.cpp | 8 ++------ src/game/level.cpp | 11 +++++++++-- src/game/proto.cpp | 16 ++++++++++++++++ src/game/script.cpp | 8 +------- src/game/script.h | 1 + 13 files changed, 59 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c810cab..a4ec08a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + [+] ALOT OF CHANGES [+] void commandsystem::ConfigureKeys() from IVANX (not used yet) [+] 'Kick down doors by default' option from IVANX [+] set pet name to _none_ to get no starting pet diff --git a/NEWZ b/NEWZ index 8570ac1..bac31f4 100644 --- a/NEWZ +++ b/NEWZ @@ -26,3 +26,7 @@ The enchant bonus is divised by 2, because the bonus value is added to each arm or leg. A +1 Dexterity bonus will add +0.5 Dexterity to each arm so (could be invisible for a +1 item so, unless you're Dexterity is already a bit trained). + + +new character field: +AllowedDungeons == ALL_DUNGEONS; // example: AllowedDungeons = { 2, UNDER_WATER_TUNNEL, MONDEDR; } diff --git a/Script/char.dat b/Script/char.dat index 7302d6a..a488fb6 100644 --- a/Script/char.dat +++ b/Script/char.dat @@ -289,6 +289,7 @@ character WhatCategoryToThrow = NONE; WhatWeaponConfigToThrow = NONE; WhatThrowItemTypesToThrow = NONE; + AllowedDungeons == ALL_DUNGEONS; // example: AllowedDungeons = { 2, UNDER_WATER_TUNNEL, MONDEDR; } } diff --git a/Script/define.dat b/Script/define.dat index 71402b4..cffd871 100644 --- a/Script/define.dat +++ b/Script/define.dat @@ -1053,6 +1053,9 @@ #define KHARAZ_ARAD_SHOP 127 #define UNDER_WATER_TUNNEL_EXIT 128 +/* dungeon tags */ +#define ALL_DUNGEONS 32767 + #define VESANA_LEVEL 2 #define CRYSTAL_LEVEL 3 #define SPIDER_LEVEL 4 diff --git a/src/game/char.cpp b/src/game/char.cpp index 36d6b53..bb31dd3 100644 --- a/src/game/char.cpp +++ b/src/game/char.cpp @@ -4123,9 +4123,8 @@ character *character::PolymorphRandomly (int MinDanger, int MaxDanger, int Time) if (StateIsActivated(POLYMORPH_CONTROL)) { if (IsPlayer()) { if (!GetNewFormForPolymorphWithControl(NewForm)) return NewForm; - } - else { - NewForm = protosystem::CreateMonster(MinDanger * 10, MaxDanger * 10, NO_EQUIPMENT); + } else { + NewForm = protosystem::CreateMonster(MinDanger*10, MaxDanger*10, NO_EQUIPMENT); } } else { NewForm = protosystem::CreateMonster(MinDanger, MaxDanger, NO_EQUIPMENT); @@ -7952,3 +7951,17 @@ truth character::CanHear() const { return DataBase->CanHear && HasHead(); } + + +truth character::IsAllowedInDungeon (int dunIndex) { + const fearray &dlist = GetAllowedDungeons(); + // + for (uInt f = 0; f < dlist.Size; ++f) { + if (dlist[f] == ALL_DUNGEONS || dlist[f] == dunIndex) { + fprintf(stderr, "OK!\n"); + return true; + } + } + fprintf(stderr, "NO!\n"); + return false; +} diff --git a/src/game/char.h b/src/game/char.h index 0eb8ccd..cc813ae 100644 --- a/src/game/char.h +++ b/src/game/char.h @@ -249,6 +249,7 @@ struct characterdatabase : public databasebase { truth IsRangedAttacker; int WhatCategoryToThrow; int WhatWeaponConfigToThrow; + fearray AllowedDungeons; }; @@ -634,6 +635,7 @@ public: DATA_BASE_TRUTH(IsRangedAttacker); DATA_BASE_VALUE(int, WhatCategoryToThrow); DATA_BASE_VALUE(int, WhatWeaponConfigToThrow); + DATA_BASE_VALUE(const fearray&, AllowedDungeons); int GetType () const { return GetProtoType()->GetIndex(); } void TeleportRandomly (truth = false); truth TeleportNear (character *); @@ -1135,6 +1137,7 @@ public: void Haste (); void Slow (); virtual void SurgicallyDetachBodyPart (); + truth IsAllowedInDungeon (int dunIndex); protected: static truth DamageTypeDestroysBodyPart (int); diff --git a/src/game/confdef.h b/src/game/confdef.h index 3c8d8c0..7b9ab98 100644 --- a/src/game/confdef.h +++ b/src/game/confdef.h @@ -503,5 +503,6 @@ #define ROOM_BANANA_DROP_AREA 5 #define ROOM_SUMO_ARENA 6 +#define ALL_DUNGEONS 32767 #endif diff --git a/src/game/database.cpp b/src/game/database.cpp index 5e7cda2..e4e8e62 100644 --- a/src/game/database.cpp +++ b/src/game/database.cpp @@ -545,6 +545,7 @@ template<> void databasecreator::CreateDataBaseMemberMap () { ADD_MEMBER(WhatCategoryToThrow); ADD_MEMBER(WhatWeaponConfigToThrow); ADD_MEMBER(WhatThrowItemTypesToThrow); + ADD_MEMBER(AllowedDungeons); } diff --git a/src/game/game.cpp b/src/game/game.cpp index 5cc897e..7fbe233 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -49,12 +49,8 @@ #include "balance.h" #include "confdef.h" -/* -#define SAVE_FILE_VERSION 119 // Increment this if changes make savefiles incompatible -#define BONE_FILE_VERSION 106 // Increment this if changes make bonefiles incompatible -*/ -#define SAVE_FILE_VERSION 125 // Increment this if changes make savefiles incompatible -#define BONE_FILE_VERSION 110 // Increment this if changes make bonefiles incompatible +#define SAVE_FILE_VERSION 126 // Increment this if changes make savefiles incompatible +#define BONE_FILE_VERSION 111 // Increment this if changes make bonefiles incompatible #define LOADED 0 #define NEW_GAME 1 diff --git a/src/game/level.cpp b/src/game/level.cpp index 6ddf709..fe7cf23 100644 --- a/src/game/level.cpp +++ b/src/game/level.cpp @@ -561,6 +561,13 @@ void level::GenerateNewMonsters (int HowMany, truth ConsiderPlayer) { for (int c1 = 0; c1 < HowMany; ++c1) { v2 Pos; character *Char = protosystem::BalancedCreateMonster(); + // gum solution + /* + while (!Char->IsAllowedInDungeon(GetDungeon()->GetIndex())) { + delete Char; + Char = protosystem::BalancedCreateMonster(); + } + */ // Char->CalculateEnchantments(); for (int c2 = 0; c2 < 30; ++c2) { @@ -580,9 +587,9 @@ void level::GenerateNewMonsters (int HowMany, truth ConsiderPlayer) { int Modifier = Time.Day-EDIT_ATTRIBUTE_DAY_MIN; if (Modifier > 0) Char->EditAllAttributes(Modifier>>EDIT_ATTRIBUTE_DAY_SHIFT); } else { - //delete Char; + delete Char; //k8:delete Char; - Char->SendToHell(); // equipment + //Char->SendToHell(); // equipment } } } diff --git a/src/game/proto.cpp b/src/game/proto.cpp index d3e67fc..5f52406 100644 --- a/src/game/proto.cpp +++ b/src/game/proto.cpp @@ -19,6 +19,9 @@ sLong protosystem::ItemCategoryPossibility[ITEM_CATEGORIES]; sLong protosystem::TotalItemPossibility; +#include "confdef.h" + + character *protosystem::BalancedCreateMonster () { for (int c = 0; ; ++c) { double MinDifficulty = game::GetMinDifficulty(), MaxDifficulty = MinDifficulty*25; @@ -30,6 +33,19 @@ character *protosystem::BalancedCreateMonster () { for (int c = 0; c < ConfigSize; ++c) { const character::database *DataBase = ConfigData[c]; if (!DataBase->IsAbstract && DataBase->CanBeGenerated) { + { + truth allowed = false; + const fearray &dlist = DataBase->AllowedDungeons; + // + //if (dlist[0] != ALL_DUNGEONS) fprintf(stderr, "(%u) [%d] [%d]\n", dlist.Size, dlist[0], game::GetCurrentDungeonIndex()); + for (uInt f = 0; f < dlist.Size; ++f) { + if (dlist[f] == ALL_DUNGEONS || dlist[f] == game::GetCurrentDungeonIndex()) { + allowed = true; + break; + } + } + if (!allowed) continue; + } if (DataBase->IsUnique && DataBase->Flags & HAS_BEEN_GENERATED) continue; truth IsCatacomb = *game::GetCurrentLevel()->GetLevelScript()->IsCatacomb(); if ((IsCatacomb && !DataBase->IsCatacombCreature) || (!IsCatacomb && DataBase->CanBeGeneratedOnlyInTheCatacombs)) continue; diff --git a/src/game/script.cpp b/src/game/script.cpp index ae2627a..764878b 100644 --- a/src/game/script.cpp +++ b/src/game/script.cpp @@ -408,6 +408,7 @@ cchar *contentscript::GetClassID () const { return "olterrain"; } void contentscript::InitDataMap () { INIT_ENTRY(Inventory); INIT_ENTRY(WayPoint); + INIT_ENTRY(AllowedDungeons); INIT_ENTRY(Team); INIT_ENTRY(Flags); } @@ -422,13 +423,6 @@ character *contentscript::Instantiate (int SpecialFlags) const { // //fprintf(stderr, "instantiating character '%s'\n", Instance->GetNameSingular().CStr()); // - /* - if (Instance->GetNameSingular() == "vampire") { - delete Instance; - return 0; - } - */ - // if (!mCode.IsEmpty()) { game::ClearEventData(); if (!game::RunAllowScriptStr(mCode)) { diff --git a/src/game/script.h b/src/game/script.h index 92dc4cb..5cb844a 100644 --- a/src/game/script.h +++ b/src/game/script.h @@ -295,6 +295,7 @@ protected: static datamap DataMap; SCRIPT_MEMBER(fearray >, Inventory); SCRIPT_MEMBER(fearray, WayPoint); + SCRIPT_MEMBER(fearray, AllowedDungeons); FAST_SCRIPT_MEMBER(uChar, Team); FAST_SCRIPT_MEMBER(uChar, Flags); }; -- 2.11.4.GIT