From 8bc2e5dc3a523af471065752a534d20d878c60b0 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Tue, 24 Jun 2025 15:02:38 -0300 Subject: most of `crnonpl.cc` --- Makefile | 6 +- TODO.md | 5 +- reference/enums.hh | 37 - reference/game.c | 6323 ---------------------------------------------------- reference/types.hh | 12 - src/cr.hh | 109 +- src/crmain.cc | 15 +- src/crnonpl.cc | 2110 ++++++++++++++++++ src/crplayer.cc | 2 +- src/enums.hh | 107 + src/stubs.hh | 2 - 11 files changed, 2328 insertions(+), 6400 deletions(-) create mode 100644 src/crnonpl.cc diff --git a/Makefile b/Makefile index 9294314..8c7a22b 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ endif HEADERS = $(SRCDIR)/common.hh $(SRCDIR)/communication.hh $(SRCDIR)/config.hh $(SRCDIR)/connections.hh $(SRCDIR)/containers.hh $(SRCDIR)/cr.hh $(SRCDIR)/crypto.hh $(SRCDIR)/enums.hh $(SRCDIR)/info.hh $(SRCDIR)/magic.hh $(SRCDIR)/map.hh $(SRCDIR)/moveuse.hh $(SRCDIR)/objects.hh $(SRCDIR)/operate.hh $(SRCDIR)/query.hh $(SRCDIR)/script.hh $(SRCDIR)/stubs.hh $(SRCDIR)/threads.hh -$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/communication.obj $(BUILDDIR)/config.obj $(BUILDDIR)/connections.obj $(BUILDDIR)/cract.obj $(BUILDDIR)/crcombat.obj $(BUILDDIR)/crmain.obj $(BUILDDIR)/crplayer.obj $(BUILDDIR)/crskill.obj $(BUILDDIR)/crypto.obj $(BUILDDIR)/info.obj $(BUILDDIR)/magic.obj $(BUILDDIR)/main.obj $(BUILDDIR)/map.obj $(BUILDDIR)/moveuse.obj $(BUILDDIR)/objects.obj $(BUILDDIR)/operate.obj $(BUILDDIR)/query.obj $(BUILDDIR)/receiving.obj $(BUILDDIR)/script.obj $(BUILDDIR)/sending.obj $(BUILDDIR)/shm.obj $(BUILDDIR)/strings.obj $(BUILDDIR)/threads.obj $(BUILDDIR)/time.obj $(BUILDDIR)/utils.obj +$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/communication.obj $(BUILDDIR)/config.obj $(BUILDDIR)/connections.obj $(BUILDDIR)/cract.obj $(BUILDDIR)/crcombat.obj $(BUILDDIR)/crmain.obj $(BUILDDIR)/crnonpl.obj $(BUILDDIR)/crplayer.obj $(BUILDDIR)/crskill.obj $(BUILDDIR)/crypto.obj $(BUILDDIR)/info.obj $(BUILDDIR)/magic.obj $(BUILDDIR)/main.obj $(BUILDDIR)/map.obj $(BUILDDIR)/moveuse.obj $(BUILDDIR)/objects.obj $(BUILDDIR)/operate.obj $(BUILDDIR)/query.obj $(BUILDDIR)/receiving.obj $(BUILDDIR)/script.obj $(BUILDDIR)/sending.obj $(BUILDDIR)/shm.obj $(BUILDDIR)/strings.obj $(BUILDDIR)/threads.obj $(BUILDDIR)/time.obj $(BUILDDIR)/utils.obj @echo $(CC) $(CFLAGS) $(LFLAGS) -o $@ $^ $(BUILDDIR)/communication.obj: $(SRCDIR)/communication.cc $(HEADERS) @@ -42,6 +42,10 @@ $(BUILDDIR)/crmain.obj: $(SRCDIR)/crmain.cc $(HEADERS) @mkdir -p $(@D) $(CC) -c $(CFLAGS) -o $@ $< +$(BUILDDIR)/crnonpl.obj: $(SRCDIR)/crnonpl.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + $(BUILDDIR)/crplayer.obj: $(SRCDIR)/crplayer.cc $(HEADERS) @mkdir -p $(@D) $(CC) -c $(CFLAGS) -o $@ $< diff --git a/TODO.md b/TODO.md index c389567..251a0a8 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,8 @@ ## TODO NEXT -- RECEIVING.CC -- QUERY.CC -- HOUSES.CC <- GAME - CRNONPL.CC <- GAME - MOVEUSE.CC <- GAME +- HOUSES.CC <- GAME +- QUERY.CC - READER.CC - WRITER.CC - DBFUNCS.CC diff --git a/reference/enums.hh b/reference/enums.hh index 7707e73..6834e5a 100644 --- a/reference/enums.hh +++ b/reference/enums.hh @@ -46,35 +46,6 @@ enum ModifierType: int { MODIFIER_TRUE=2 }; -enum ConditionType: int { - CONDITION_ISPOSITION=0, - CONDITION_ISTYPE=1, - CONDITION_ISCREATURE=2, - CONDITION_ISPLAYER=3, - CONDITION_HASFLAG=4, - CONDITION_HASTYPEATTRIBUTE=5, - CONDITION_HASINSTANCEATTRIBUTE=6, - CONDITION_HASTEXT=7, - CONDITION_ISPEACEFUL=8, - CONDITION_MAYLOGOUT=9, - CONDITION_HASPROFESSION=10, - CONDITION_HASLEVEL=11, - CONDITION_HASRIGHT=12, - CONDITION_HASQUESTVALUE=13, - CONDITION_TESTSKILL=14, - CONDITION_COUNTOBJECTS=15, - CONDITION_COUNTOBJECTSONMAP=16, - CONDITION_ISOBJECTTHERE=17, - CONDITION_ISCREATURETHERE=18, - CONDITION_ISPLAYERTHERE=19, - CONDITION_ISOBJECTININVENTORY=20, - CONDITION_ISPROTECTIONZONE=21, - CONDITION_ISHOUSE=22, - CONDITION_ISHOUSEOWNER=23, - CONDITION_ISDRESSED=24, - CONDITION_RANDOM=25 -}; - enum TWriterThreadReplyType: int { REPLY_BROADCAST=0, REPLY_DIRECT=1, @@ -138,11 +109,3 @@ enum TReaderThreadReplyType: int { REPLY_SECTORDATA=0, REPLY_CHARACTERDATA=1 }; - -enum SITUATION: int { - DEFAULT=0, - ADDRESS=1, - ADDRESSQUEUE=2, - BUSY=3, - VANISH=4 -}; diff --git a/reference/game.c b/reference/game.c index 06d70d8..c44699e 100644 --- a/reference/game.c +++ b/reference/game.c @@ -18537,6285 +18537,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -TNode * NewNode(void) - -{ - TNode *Node; - TNode *pTVar1; - int in_stack_00000004; - TNode *in_stack_00000008; - TNode *in_stack_0000000c; - - pTVar1 = store::getFreeItem(NodeTable); - pTVar1->Type = in_stack_00000004; - pTVar1->Left = in_stack_00000008; - pTVar1->Right = in_stack_0000000c; - return pTVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -TNode * NewNode(void) - -{ - TNode *Node; - TNode *pTVar1; - int in_stack_00000004; - int in_stack_00000008; - - pTVar1 = store::getFreeItem(NodeTable); - pTVar1->Type = in_stack_00000004; - pTVar1->Left = (TNode *)0x0; - pTVar1->Right = (TNode *)0x0; - pTVar1->Data = in_stack_00000008; - return pTVar1; -} - - - -void DeleteNode(TNode *Node) - -{ - store *psVar1; - - if (Node != (TNode *)0x0) { - DeleteNode(Node->Left); - DeleteNode(Node->Right); - psVar1 = NodeTable; - Node->Type = (int)NodeTable->firstFreeItem; - psVar1->firstFreeItem = (storeitem *)Node; - } - return; -} - - - -// DWARF original prototype: bool set(TCondition * this, int Type, void * Data) - -bool __thiscall TCondition::set(TCondition *this,int Type,void *Data) - -{ - ulong uVar1; - int iVar2; - char *pcVar3; - char *pcVar4; - bool bVar5; - - if ((Type != 5) && (Data == (void *)0x0)) { - error("TCondition::set: Data ist NULL.\n"); - this->Type = 0; - return false; - } - this->Type = Type; - bVar5 = Type == 5; - switch(Type) { - default: - error(&DAT_08104a80,Type); - return false; - case 1: - uVar1 = AddDynamicString((char *)Data); - this->Text = uVar1; - break; - case 2: - this->Property = 0; - iVar2 = 8; - pcVar3 = (char *)Data; - pcVar4 = "address"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 1; - } - iVar2 = 5; - pcVar3 = (char *)Data; - pcVar4 = "busy"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 2; - } - iVar2 = 7; - pcVar3 = (char *)Data; - pcVar4 = "vanish"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 3; - } - iVar2 = 5; - pcVar3 = (char *)Data; - pcVar4 = "male"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 4; - } - iVar2 = 7; - pcVar3 = (char *)Data; - pcVar4 = "female"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 5; - } - iVar2 = 7; - pcVar3 = (char *)Data; - pcVar4 = "knight"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 6; - } - iVar2 = 8; - pcVar3 = (char *)Data; - pcVar4 = "paladin"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 7; - } - iVar2 = 9; - pcVar3 = (char *)Data; - pcVar4 = "sorcerer"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 8; - } - iVar2 = 6; - pcVar3 = (char *)Data; - pcVar4 = "druid"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 9; - } - iVar2 = 8; - pcVar3 = (char *)Data; - pcVar4 = "premium"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 10; - } - iVar2 = 9; - pcVar3 = (char *)Data; - pcVar4 = "promoted"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 0xb; - } - iVar2 = 8; - pcVar3 = (char *)Data; - pcVar4 = "pzblock"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 0xc; - } - iVar2 = 7; - pcVar3 = (char *)Data; - pcVar4 = "nonpvp"; - do { - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *pcVar3 == *pcVar4; - pcVar3 = pcVar3 + 1; - pcVar4 = pcVar4 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 0xd; - } - iVar2 = 0xc; - pcVar3 = "pvpenforced"; - do { - // WARNING: Load size is inaccurate - if (iVar2 == 0) break; - iVar2 = iVar2 + -1; - bVar5 = *Data == *pcVar3; - Data = (char *)((int)Data + 1); - pcVar3 = pcVar3 + 1; - } while (bVar5); - if (bVar5) { - this->Property = 0xe; - } - if (this->Property == 0) { - return false; - } - return true; - case 3: - // WARNING: Load size is inaccurate - this->Number = *Data; - break; - case 4: - this->Expression = (TNode *)Data; - break; - case 5: - break; - } - return true; -} - - - -// DWARF original prototype: void clear(TCondition * this) - -void __thiscall TCondition::clear(TCondition *this) - -{ - storeitem *psVar1; - store *psVar2; - int iVar3; - - iVar3 = this->Type; - if ((iVar3 == 4) && - (psVar1 = (storeitem *)this->Expression, psVar1 != (storeitem *)0x0)) { - DeleteNode((psVar1->data).Left); - DeleteNode((psVar1->data).Right); - psVar2 = NodeTable; - psVar1->next = NodeTable->firstFreeItem; - psVar2->firstFreeItem = psVar1; - iVar3 = this->Type; - } - if (iVar3 == 1) { - DeleteDynamicString(this->Text); - } - this->Type = 0; - return; -} - - - -// DWARF original prototype: bool set(TAction * this, int Type, void * Data, void * Data2, void * -// Data3, void * Data4) - -bool __thiscall TAction::set(TAction *this) - -{ - int iVar1; - ulong uVar2; - int in_stack_00000008; - int *in_stack_0000000c; - TNode *in_stack_00000010; - TNode *in_stack_00000014; - TNode *in_stack_00000018; - - this->Type = in_stack_00000008; - switch(in_stack_00000008) { - default: - error(&DAT_08104b00); - return false; - case 1: - uVar2 = AddDynamicString((char *)in_stack_0000000c); - this->Text = uVar2; - break; - case 2: - case 3: - case 5: - iVar1 = *in_stack_0000000c; - this->Expression = in_stack_00000010; - this->Number = iVar1; - break; - case 4: - case 8: - iVar1 = *in_stack_0000000c; - this->Expression2 = in_stack_00000014; - this->Expression = in_stack_00000010; - this->Number = iVar1; - break; - case 6: - case 7: - this->Number = *in_stack_0000000c; - break; - case 9: - break; - case 10: - iVar1 = *in_stack_0000000c; - this->Expression2 = in_stack_00000014; - this->Expression = in_stack_00000010; - this->Number = iVar1; - this->Expression3 = in_stack_00000018; - } - return true; -} - - - -// DWARF original prototype: void clear(TAction * this) - -void __thiscall TAction::clear(TAction *this) - -{ - storeitem *psVar1; - store *psVar2; - int iVar3; - - iVar3 = this->Type; - if ((((iVar3 - 2U < 4) || (iVar3 == 8)) || (iVar3 == 10)) && - (psVar1 = (storeitem *)this->Expression, psVar1 != (storeitem *)0x0)) { - DeleteNode((psVar1->data).Left); - DeleteNode((psVar1->data).Right); - psVar2 = NodeTable; - psVar1->next = NodeTable->firstFreeItem; - psVar2->firstFreeItem = psVar1; - iVar3 = this->Type; - } - if (((iVar3 == 4) || (iVar3 == 8)) || (iVar3 == 10)) { - psVar1 = (storeitem *)this->Expression2; - if (psVar1 != (storeitem *)0x0) { - DeleteNode((psVar1->data).Left); - DeleteNode((psVar1->data).Right); - psVar2 = NodeTable; - psVar1->next = NodeTable->firstFreeItem; - psVar2->firstFreeItem = psVar1; - iVar3 = this->Type; - } - if ((iVar3 == 10) && - (psVar1 = (storeitem *)this->Expression3, psVar1 != (storeitem *)0x0)) { - DeleteNode((psVar1->data).Left); - DeleteNode((psVar1->data).Right); - psVar2 = NodeTable; - psVar1->next = NodeTable->firstFreeItem; - psVar2->firstFreeItem = psVar1; - iVar3 = this->Type; - } - } - if (iVar3 == 1) { - DeleteDynamicString(this->Text); - } - this->Type = 0; - return; -} - - - -// DWARF original prototype: void TBehaviour(TBehaviour * this) - -void __thiscall TBehaviour::TBehaviour(TBehaviour *this) - -{ - vector::vector(&this->Condition,0,5,5); - // try { // try from 080b051d to 080b0521 has its CatchHandler @ 080b0540 - vector::vector(&this->Action,0,5,5); - this->Conditions = 0; - this->Actions = 0; - return; -} - - - -// DWARF original prototype: void TBehaviour(TBehaviour * this) - -void __thiscall TBehaviour::TBehaviour(TBehaviour *this) - -{ - vector::vector(&this->Condition,0,5,5); - // try { // try from 080b05ad to 080b05b1 has its CatchHandler @ 080b05d0 - vector::vector(&this->Action,0,5,5); - this->Conditions = 0; - this->Actions = 0; - return; -} - - - -// DWARF original prototype: void ~TBehaviour(TBehaviour * this, int __in_chrg) - -void __thiscall TBehaviour::~TBehaviour(TBehaviour *this,int __in_chrg) - -{ - TAction *pTVar1; - TCondition *pTVar2; - int i; - int iVar3; - int iVar4; - - iVar3 = 0; - if (0 < this->Conditions) { - do { - iVar4 = iVar3 + 1; - pTVar2 = vector::operator()(&this->Condition,iVar3); - TCondition::clear(pTVar2); - iVar3 = iVar4; - } while (iVar4 < this->Conditions); - } - if (0 < this->Actions) { - iVar3 = 0; - do { - iVar4 = iVar3 + 1; - pTVar1 = vector::operator()(&this->Action,iVar3); - TAction::clear(pTVar1); - iVar3 = iVar4; - } while (iVar4 < this->Actions); - } - pTVar1 = (this->Action).entry; - if (pTVar1 != (TAction *)0x0) { - operator_delete__(pTVar1); - } - pTVar2 = (this->Condition).entry; - if (pTVar2 != (TCondition *)0x0) { - operator_delete__(pTVar2); - return; - } - return; -} - - - -// DWARF original prototype: void ~TBehaviour(TBehaviour * this, int __in_chrg) - -void __thiscall TBehaviour::~TBehaviour(TBehaviour *this,int __in_chrg) - -{ - TAction *pTVar1; - TCondition *pTVar2; - int i; - int iVar3; - int iVar4; - - iVar3 = 0; - if (0 < this->Conditions) { - do { - iVar4 = iVar3 + 1; - pTVar2 = vector::operator()(&this->Condition,iVar3); - TCondition::clear(pTVar2); - iVar3 = iVar4; - } while (iVar4 < this->Conditions); - } - if (0 < this->Actions) { - iVar3 = 0; - do { - iVar4 = iVar3 + 1; - pTVar1 = vector::operator()(&this->Action,iVar3); - TAction::clear(pTVar1); - iVar3 = iVar4; - } while (iVar4 < this->Actions); - } - pTVar1 = (this->Action).entry; - if (pTVar1 != (TAction *)0x0) { - operator_delete__(pTVar1); - } - pTVar2 = (this->Condition).entry; - if (pTVar2 != (TCondition *)0x0) { - operator_delete__(pTVar2); - return; - } - return; -} - - - -// DWARF original prototype: bool addCondition(TBehaviour * this, int Type, void * Data) - -bool __thiscall TBehaviour::addCondition(TBehaviour *this) - -{ - bool bVar1; - TCondition *this_00; - int in_stack_00000008; - void *in_stack_0000000c; - - this_00 = vector::operator()(&this->Condition,this->Conditions); - bVar1 = TCondition::set(this_00,in_stack_00000008,in_stack_0000000c); - if (bVar1) { - this->Conditions = this->Conditions + 1; - } - return bVar1; -} - - - -// DWARF original prototype: bool addAction(TBehaviour * this, int Type, void * Data, void * Data2, -// void * Data3, void * Data4) - -bool __thiscall TBehaviour::addAction(TBehaviour *this) - -{ - bool bVar1; - TAction *this_00; - - this_00 = vector::operator()(&this->Action,this->Actions); - bVar1 = TAction::set(this_00); - if (bVar1) { - this->Actions = this->Actions + 1; - } - return bVar1; -} - - - -// WARNING: Variable defined which should be unmapped: Nr -// DWARF original prototype: void TBehaviourDatabase(TBehaviourDatabase * this, TReadScriptFile * -// Script) - -void __thiscall -TBehaviourDatabase::TBehaviourDatabase(TBehaviourDatabase *this,TReadScriptFile *Script) - -{ - char cVar1; - bool bVar2; - TNode *Node; - TNode *pTVar3; - TNode *pTVar4; - TBehaviour *pTVar5; - TCondition *pTVar6; - TAction *pTVar7; - undefined4 uVar8; - TOKEN TVar9; - int iVar10; - bool Success; - char *pcVar11; - TNode *Right; - char *pcVar12; - undefined1 uVar13; - char *pcVar14; - TNode *local_4c; - TNode *Left_6; - TNode *local_44; - TNode *Left_10; - TNode *Left_8; - TNode *Left_16; - TNode *Left_14; - TNode *Left_12; - TNode *Left_4; - undefined4 local_28; - int Type; - TNode *Left_2; - int Operator; - TNode *Left; - int Data; - int Nr; - - // try { // try from 080b07f7 to 080b07fb has its CatchHandler @ 080b1d30 - vector::vector(&this->Behaviour,0,0x32,0x19); - this->Behaviours = 0; - // try { // try from 080b0815 to 080b0824 has its CatchHandler @ 080b1d20 - TReadScriptFile::readSymbol(Script,'{'); - TReadScriptFile::nextToken(Script); -LAB_080b0825: - TVar9 = Script->Token; - if (TVar9 != SPECIAL) goto LAB_080b0833; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 == '}') { - return; - } - TVar9 = Script->Token; - if (TVar9 != SPECIAL) goto LAB_080b0833; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != 'I') { -LAB_080b0ae0: - TVar9 = Script->Token; -LAB_080b0833: - bVar2 = false; - if (TVar9 == STRING) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pcVar14 = TReadScriptFile::getString(Script); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,1,pcVar14); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - if (TVar9 == IDENTIFIER) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pcVar14 = TReadScriptFile::getIdentifier(Script); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,2,pcVar14); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - if (TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 == '!') { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,5,(void *)0x0); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - else { - TVar9 = Script->Token; - } - if ((TVar9 == SPECIAL) && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '%')) { - Data = TReadScriptFile::readNumber(Script); - if (2 < Data - 1U) { - TReadScriptFile::error(Script,"illegal ordinal number"); - } - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,3,&Data); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - } - } - if (!bVar2) { - // try { // try from 080b0865 to 080b08ad has its CatchHandler @ 080b1bd0 - Operator = (int)readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = (TNode *)Operator; - pTVar4->Right = pTVar3; - Operator = (int)pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b093c; - // try { // try from 080b08cf to 080b0921 has its CatchHandler @ 080b1c4a - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if (Script->Token == SPECIAL) goto LAB_080b094f; - goto LAB_080b093c; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = (TNode *)Operator; - TVar9 = Script->Token; - Operator = (int)pTVar4; - } while( true ); - } - TReadScriptFile::nextToken(Script); - goto LAB_080b0ac1; - } - goto LAB_080b0b09; -LAB_080b093c: - // try { // try from 080b094a to 080b0986 has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,"relational operator expected"); -LAB_080b094f: - Left_2 = (TNode *)0x0; - cVar1 = TReadScriptFile::getSpecial(Script); - switch(cVar1) { - case '<': - Left_2 = (TNode *)0x1; - break; - case '=': - Left_2 = (TNode *)0x3; - break; - case '>': - Left_2 = (TNode *)0x2; - break; - default: - TReadScriptFile::error(Script,"relational operator expected"); - break; - case 'G': - Left_2 = (TNode *)0x6; - break; - case 'L': - Left_2 = (TNode *)0x5; - break; - case 'N': - Left_2 = (TNode *)0x4; - } - TReadScriptFile::nextToken(Script); - // try { // try from 080b0994 to 080b09d9 has its CatchHandler @ 080b1c5b - Type = (int)readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = (TNode *)Type; - pTVar4->Right = pTVar3; - Type = (int)pTVar4; - } - // try { // try from 080b09fb to 080b0a4d has its CatchHandler @ 080b1c70 - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = (TNode *)Type; - TVar9 = Script->Token; - Type = (int)pTVar4; - } - // try { // try from 080b0a68 to 080b0f5a has its CatchHandler @ 080b1d20 - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (int)Left_2; - pTVar3->Left = (TNode *)Operator; - pTVar3->Right = (TNode *)Type; - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,4,pTVar3); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } -LAB_080b0ac1: - if (Script->Token != SPECIAL) goto LAB_080b0af6; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != ',') goto LAB_080b0aea; - TReadScriptFile::nextToken(Script); - goto LAB_080b0ae0; -LAB_080b0aea: - if ((Script->Token != SPECIAL) || (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != 'I')) { -LAB_080b0af6: - TReadScriptFile::error(Script,"\'->\' expected"); - } -LAB_080b0b09: - TReadScriptFile::nextToken(Script); - TVar9 = Script->Token; - if (TVar9 == STRING) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - TReadScriptFile::getString(Script); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - goto LAB_080b0be1; - } - uVar13 = TVar9 == IDENTIFIER; - if ((bool)uVar13) { - pcVar14 = TReadScriptFile::getIdentifier(Script); - local_28 = 0xffffffff; - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "topic"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "price"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "amount"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "type"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "data"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 3; - pcVar11 = pcVar14; - pcVar12 = "hp"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 3; - } - iVar10 = 8; - pcVar11 = pcVar14; - pcVar12 = "burning"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 8; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "poison"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 8; - } - iVar10 = 0xe; - pcVar11 = pcVar14; - pcVar12 = "setquestvalue"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 4; - } - iVar10 = 9; - pcVar11 = pcVar14; - pcVar12 = "effectme"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 10; - pcVar11 = pcVar14; - pcVar12 = "effectopp"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xb; - pcVar11 = pcVar14; - pcVar12 = "profession"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xb; - pcVar11 = pcVar14; - pcVar12 = "teachspell"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "summon"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "create"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "delete"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xc; - pcVar11 = pcVar14; - pcVar12 = "createmoney"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 0xc; - pcVar11 = pcVar14; - pcVar12 = "deletemoney"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "queue"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 9; - pcVar11 = pcVar14; - pcVar12 = "teleport"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 10; - } - iVar10 = 0xe; - pcVar11 = pcVar14; - pcVar12 = "startposition"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 10; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "idle"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 7; - } - iVar10 = 4; - pcVar11 = "nop"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar14 == *pcVar11; - pcVar14 = pcVar14 + 1; - pcVar11 = pcVar11 + 1; - } while ((bool)uVar13); - uVar8 = 0; - if (!(bool)uVar13) { - uVar8 = local_28; - } - switch(uVar8) { - case 0: - goto switchD_080b0f21_caseD_0; - default: - pcVar14 = "unknown identifier"; - goto LAB_080b0b38; - case 2: - case 3: - TReadScriptFile::readSymbol(Script,'='); - TReadScriptFile::nextToken(Script); - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - // try { // try from 080b0f68 to 080b0fb0 has its CatchHandler @ 080b1c72 - Left_12 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_12; - pTVar4->Right = pTVar3; - Left_12 = pTVar4; - } - // try { // try from 080b0fd2 to 080b1024 has its CatchHandler @ 080b1c87 - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_12; - TVar9 = Script->Token; - Left_12 = pTVar4; - } - // try { // try from 080b1049 to 080b10cb has its CatchHandler @ 080b1d20 - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - goto LAB_080b0b43; - case 4: - case 8: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b12a9 to 080b12f1 has its CatchHandler @ 080b1cd1 - Left_10 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_10; - pTVar4->Right = pTVar3; - Left_10 = pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b1384; - // try { // try from 080b1313 to 080b1365 has its CatchHandler @ 080b1ce6 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) - goto LAB_080b1397; - goto LAB_080b1384; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_10; - TVar9 = Script->Token; - Left_10 = pTVar4; - } while( true ); - case 5: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - // try { // try from 080b10dc to 080b1124 has its CatchHandler @ 080b1d05 - local_4c = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = local_4c; - pTVar4->Right = pTVar3; - local_4c = pTVar4; - } - // try { // try from 080b1146 to 080b1198 has its CatchHandler @ 080b1c4a - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = local_4c; - TVar9 = Script->Token; - local_4c = pTVar4; - } - // try { // try from 080b11bd to 080b129b has its CatchHandler @ 080b1d20 - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - if ((Script->Token != SPECIAL) || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != ')')) { - TReadScriptFile::error(Script,") expected"); - } - goto LAB_080b0be1; - case 6: - case 7: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - goto LAB_080b0bcc; - case 10: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b1538 to 080b1580 has its CatchHandler @ 080b1c89 - Left_14 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_14; - pTVar4->Right = pTVar3; - Left_14 = pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b1613; - // try { // try from 080b15a2 to 080b15f4 has its CatchHandler @ 080b1c9e - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) - goto LAB_080b1626; - goto LAB_080b1613; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_14; - TVar9 = Script->Token; - Left_14 = pTVar4; - } while( true ); - } - } - if ((TVar9 == SPECIAL) && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '*')) { - iVar10 = this->Behaviours; - if (iVar10 == 0) { - TReadScriptFile::error(Script,"no previous pattern"); - iVar10 = this->Behaviours; - } - pTVar5 = vector::operator()(&this->Behaviour,iVar10); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - goto LAB_080b0bcc; - } - pcVar14 = "illegal action"; -LAB_080b0b38: - TReadScriptFile::error(Script,pcVar14); - goto LAB_080b0b43; -LAB_080b1613: - // try { // try from 080b1621 to 080b1630 has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,", expected"); -LAB_080b1626: - TReadScriptFile::nextToken(Script); - // try { // try from 080b163e to 080b1686 has its CatchHandler @ 080b1ca0 - Left_16 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_16; - pTVar4->Right = pTVar3; - Left_16 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b16a8 to 080b16fa has its CatchHandler @ 080b1cb5 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) goto LAB_080b172c; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_16; - TVar9 = Script->Token; - Left_16 = pTVar4; - } while( true ); - // try { // try from 080b1727 to 080b1736 has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,", expected"); -LAB_080b172c: - TReadScriptFile::nextToken(Script); - // try { // try from 080b1744 to 080b178c has its CatchHandler @ 080b1cb7 - Left_8 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_8; - pTVar4->Right = pTVar3; - Left_8 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b17ae to 080b1800 has its CatchHandler @ 080b1ccc - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b182e; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_8; - TVar9 = Script->Token; - Left_8 = pTVar4; - } while( true ); - // try { // try from 080b1829 to 080b1bb7 has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,") expected"); -LAB_080b182e: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } -switchD_080b0f21_caseD_0: - goto LAB_080b0be1; -LAB_080b1384: - // try { // try from 080b1392 to 080b13a1 has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,", expected"); -LAB_080b1397: - TReadScriptFile::nextToken(Script); - // try { // try from 080b13af to 080b13f7 has its CatchHandler @ 080b1ceb - local_44 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = local_44; - pTVar4->Right = pTVar3; - local_44 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b1419 to 080b146b has its CatchHandler @ 080b1d00 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b1499; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = local_44; - TVar9 = Script->Token; - local_44 = pTVar4; - } while( true ); - // try { // try from 080b1494 to 080b152a has its CatchHandler @ 080b1d20 - TReadScriptFile::error(Script,") expected"); -LAB_080b1499: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); -LAB_080b0bcc: - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } -LAB_080b0be1: - TReadScriptFile::nextToken(Script); -LAB_080b0b43: - if ((Script->Token != SPECIAL) || (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != ',')) - goto LAB_080b0b57; - goto LAB_080b0b09; -LAB_080b0b57: - this->Behaviours = this->Behaviours + 1; - goto LAB_080b0825; -} - - - -// WARNING: Variable defined which should be unmapped: Nr -// DWARF original prototype: void TBehaviourDatabase(TBehaviourDatabase * this, TReadScriptFile * -// Script) - -void __thiscall -TBehaviourDatabase::TBehaviourDatabase(TBehaviourDatabase *this,TReadScriptFile *Script) - -{ - char cVar1; - bool bVar2; - TNode *Node; - TNode *pTVar3; - TNode *pTVar4; - TBehaviour *pTVar5; - TCondition *pTVar6; - TAction *pTVar7; - undefined4 uVar8; - TOKEN TVar9; - int iVar10; - bool Success; - char *pcVar11; - TNode *Right; - char *pcVar12; - undefined1 uVar13; - char *pcVar14; - TNode *local_4c; - TNode *Left_6; - TNode *local_44; - TNode *Left_10; - TNode *Left_8; - TNode *Left_16; - TNode *Left_14; - TNode *Left_12; - TNode *Left_4; - undefined4 local_28; - int Type; - TNode *Left_2; - int Operator; - TNode *Left; - int Data; - int Nr; - - // try { // try from 080b1d77 to 080b1d7b has its CatchHandler @ 080b32b0 - vector::vector(&this->Behaviour,0,0x32,0x19); - this->Behaviours = 0; - // try { // try from 080b1d95 to 080b1da4 has its CatchHandler @ 080b32a0 - TReadScriptFile::readSymbol(Script,'{'); - TReadScriptFile::nextToken(Script); -LAB_080b1da5: - TVar9 = Script->Token; - if (TVar9 != SPECIAL) goto LAB_080b1db3; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 == '}') { - return; - } - TVar9 = Script->Token; - if (TVar9 != SPECIAL) goto LAB_080b1db3; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != 'I') { -LAB_080b2060: - TVar9 = Script->Token; -LAB_080b1db3: - bVar2 = false; - if (TVar9 == STRING) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pcVar14 = TReadScriptFile::getString(Script); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,1,pcVar14); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - if (TVar9 == IDENTIFIER) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pcVar14 = TReadScriptFile::getIdentifier(Script); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,2,pcVar14); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - if (TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 == '!') { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,5,(void *)0x0); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - TVar9 = Script->Token; - } - else { - TVar9 = Script->Token; - } - if ((TVar9 == SPECIAL) && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '%')) { - Data = TReadScriptFile::readNumber(Script); - if (2 < Data - 1U) { - TReadScriptFile::error(Script,"illegal ordinal number"); - } - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,3,&Data); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } - } - } - if (!bVar2) { - // try { // try from 080b1de5 to 080b1e2d has its CatchHandler @ 080b3150 - Operator = (int)readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = (TNode *)Operator; - pTVar4->Right = pTVar3; - Operator = (int)pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b1ebc; - // try { // try from 080b1e4f to 080b1ea1 has its CatchHandler @ 080b31ca - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if (Script->Token == SPECIAL) goto LAB_080b1ecf; - goto LAB_080b1ebc; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = (TNode *)Operator; - TVar9 = Script->Token; - Operator = (int)pTVar4; - } while( true ); - } - TReadScriptFile::nextToken(Script); - goto LAB_080b2041; - } - goto LAB_080b2089; -LAB_080b1ebc: - // try { // try from 080b1eca to 080b1f06 has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,"relational operator expected"); -LAB_080b1ecf: - Left_2 = (TNode *)0x0; - cVar1 = TReadScriptFile::getSpecial(Script); - switch(cVar1) { - case '<': - Left_2 = (TNode *)0x1; - break; - case '=': - Left_2 = (TNode *)0x3; - break; - case '>': - Left_2 = (TNode *)0x2; - break; - default: - TReadScriptFile::error(Script,"relational operator expected"); - break; - case 'G': - Left_2 = (TNode *)0x6; - break; - case 'L': - Left_2 = (TNode *)0x5; - break; - case 'N': - Left_2 = (TNode *)0x4; - } - TReadScriptFile::nextToken(Script); - // try { // try from 080b1f14 to 080b1f59 has its CatchHandler @ 080b31db - Type = (int)readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = (TNode *)Type; - pTVar4->Right = pTVar3; - Type = (int)pTVar4; - } - // try { // try from 080b1f7b to 080b1fcd has its CatchHandler @ 080b31f0 - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = (TNode *)Type; - TVar9 = Script->Token; - Type = (int)pTVar4; - } - // try { // try from 080b1fe8 to 080b24da has its CatchHandler @ 080b32a0 - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (int)Left_2; - pTVar3->Left = (TNode *)Operator; - pTVar3->Right = (TNode *)Type; - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar6 = vector::operator()(&pTVar5->Condition,pTVar5->Conditions); - bVar2 = TCondition::set(pTVar6,4,pTVar3); - if (bVar2) { - pTVar5->Conditions = pTVar5->Conditions + 1; - } -LAB_080b2041: - if (Script->Token != SPECIAL) goto LAB_080b2076; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != ',') goto LAB_080b206a; - TReadScriptFile::nextToken(Script); - goto LAB_080b2060; -LAB_080b206a: - if ((Script->Token != SPECIAL) || (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != 'I')) { -LAB_080b2076: - TReadScriptFile::error(Script,"\'->\' expected"); - } -LAB_080b2089: - TReadScriptFile::nextToken(Script); - TVar9 = Script->Token; - if (TVar9 == STRING) { - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - TReadScriptFile::getString(Script); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - goto LAB_080b2161; - } - uVar13 = TVar9 == IDENTIFIER; - if ((bool)uVar13) { - pcVar14 = TReadScriptFile::getIdentifier(Script); - local_28 = 0xffffffff; - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "topic"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "price"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "amount"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "type"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "data"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 2; - } - iVar10 = 3; - pcVar11 = pcVar14; - pcVar12 = "hp"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 3; - } - iVar10 = 8; - pcVar11 = pcVar14; - pcVar12 = "burning"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 8; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "poison"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 8; - } - iVar10 = 0xe; - pcVar11 = pcVar14; - pcVar12 = "setquestvalue"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 4; - } - iVar10 = 9; - pcVar11 = pcVar14; - pcVar12 = "effectme"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 10; - pcVar11 = pcVar14; - pcVar12 = "effectopp"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xb; - pcVar11 = pcVar14; - pcVar12 = "profession"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xb; - pcVar11 = pcVar14; - pcVar12 = "teachspell"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "summon"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "create"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 7; - pcVar11 = pcVar14; - pcVar12 = "delete"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 5; - } - iVar10 = 0xc; - pcVar11 = pcVar14; - pcVar12 = "createmoney"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 0xc; - pcVar11 = pcVar14; - pcVar12 = "deletemoney"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 6; - pcVar11 = pcVar14; - pcVar12 = "queue"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 6; - } - iVar10 = 9; - pcVar11 = pcVar14; - pcVar12 = "teleport"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 10; - } - iVar10 = 0xe; - pcVar11 = pcVar14; - pcVar12 = "startposition"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 10; - } - iVar10 = 5; - pcVar11 = pcVar14; - pcVar12 = "idle"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar11 == *pcVar12; - pcVar11 = pcVar11 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_28 = 7; - } - iVar10 = 4; - pcVar11 = "nop"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar14 == *pcVar11; - pcVar14 = pcVar14 + 1; - pcVar11 = pcVar11 + 1; - } while ((bool)uVar13); - uVar8 = 0; - if (!(bool)uVar13) { - uVar8 = local_28; - } - switch(uVar8) { - case 0: - goto switchD_080b24a1_caseD_0; - default: - pcVar14 = "unknown identifier"; - goto LAB_080b20b8; - case 2: - case 3: - TReadScriptFile::readSymbol(Script,'='); - TReadScriptFile::nextToken(Script); - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - // try { // try from 080b24e8 to 080b2530 has its CatchHandler @ 080b31f2 - Left_12 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_12; - pTVar4->Right = pTVar3; - Left_12 = pTVar4; - } - // try { // try from 080b2552 to 080b25a4 has its CatchHandler @ 080b3207 - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_12; - TVar9 = Script->Token; - Left_12 = pTVar4; - } - // try { // try from 080b25c9 to 080b264b has its CatchHandler @ 080b32a0 - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - goto LAB_080b20c3; - case 4: - case 8: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b2829 to 080b2871 has its CatchHandler @ 080b3251 - Left_10 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_10; - pTVar4->Right = pTVar3; - Left_10 = pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b2904; - // try { // try from 080b2893 to 080b28e5 has its CatchHandler @ 080b3266 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) - goto LAB_080b2917; - goto LAB_080b2904; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_10; - TVar9 = Script->Token; - Left_10 = pTVar4; - } while( true ); - case 5: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - // try { // try from 080b265c to 080b26a4 has its CatchHandler @ 080b3285 - local_4c = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = local_4c; - pTVar4->Right = pTVar3; - local_4c = pTVar4; - } - // try { // try from 080b26c6 to 080b2718 has its CatchHandler @ 080b31ca - while ((TVar9 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = local_4c; - TVar9 = Script->Token; - local_4c = pTVar4; - } - // try { // try from 080b273d to 080b281b has its CatchHandler @ 080b32a0 - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } - if ((Script->Token != SPECIAL) || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != ')')) { - TReadScriptFile::error(Script,") expected"); - } - goto LAB_080b2161; - case 6: - case 7: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - goto LAB_080b214c; - case 10: - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b2ab8 to 080b2b00 has its CatchHandler @ 080b3209 - Left_14 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_14; - pTVar4->Right = pTVar3; - Left_14 = pTVar4; - } - do { - if (TVar9 != SPECIAL) goto LAB_080b2b93; - // try { // try from 080b2b22 to 080b2b74 has its CatchHandler @ 080b321e - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) - goto LAB_080b2ba6; - goto LAB_080b2b93; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_14; - TVar9 = Script->Token; - Left_14 = pTVar4; - } while( true ); - } - } - if ((TVar9 == SPECIAL) && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '*')) { - iVar10 = this->Behaviours; - if (iVar10 == 0) { - TReadScriptFile::error(Script,"no previous pattern"); - iVar10 = this->Behaviours; - } - pTVar5 = vector::operator()(&this->Behaviour,iVar10); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - goto LAB_080b214c; - } - pcVar14 = "illegal action"; -LAB_080b20b8: - TReadScriptFile::error(Script,pcVar14); - goto LAB_080b20c3; -LAB_080b2b93: - // try { // try from 080b2ba1 to 080b2bb0 has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,", expected"); -LAB_080b2ba6: - TReadScriptFile::nextToken(Script); - // try { // try from 080b2bbe to 080b2c06 has its CatchHandler @ 080b3220 - Left_16 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_16; - pTVar4->Right = pTVar3; - Left_16 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b2c28 to 080b2c7a has its CatchHandler @ 080b3235 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) goto LAB_080b2cac; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_16; - TVar9 = Script->Token; - Left_16 = pTVar4; - } while( true ); - // try { // try from 080b2ca7 to 080b2cb6 has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,", expected"); -LAB_080b2cac: - TReadScriptFile::nextToken(Script); - // try { // try from 080b2cc4 to 080b2d0c has its CatchHandler @ 080b3237 - Left_8 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = Left_8; - pTVar4->Right = pTVar3; - Left_8 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b2d2e to 080b2d80 has its CatchHandler @ 080b324c - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b2dae; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = Left_8; - TVar9 = Script->Token; - Left_8 = pTVar4; - } while( true ); - // try { // try from 080b2da9 to 080b3137 has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,") expected"); -LAB_080b2dae: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } -switchD_080b24a1_caseD_0: - goto LAB_080b2161; -LAB_080b2904: - // try { // try from 080b2912 to 080b2921 has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,", expected"); -LAB_080b2917: - TReadScriptFile::nextToken(Script); - // try { // try from 080b292f to 080b2977 has its CatchHandler @ 080b326b - local_44 = readValue(this,Script); - while (TVar9 = Script->Token, TVar9 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar9 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = local_44; - pTVar4->Right = pTVar3; - local_44 = pTVar4; - } - do { - if (TVar9 != SPECIAL) break; - // try { // try from 080b2999 to 080b29eb has its CatchHandler @ 080b3280 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b2a19; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar3 = readFactor(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = (cVar1 != '+') + 7; - pTVar4->Right = pTVar3; - pTVar4->Left = local_44; - TVar9 = Script->Token; - local_44 = pTVar4; - } while( true ); - // try { // try from 080b2a14 to 080b2aaa has its CatchHandler @ 080b32a0 - TReadScriptFile::error(Script,") expected"); -LAB_080b2a19: - pTVar5 = vector::operator()(&this->Behaviour,this->Behaviours); - pTVar7 = vector::operator()(&pTVar5->Action,pTVar5->Actions); -LAB_080b214c: - bVar2 = TAction::set(pTVar7); - if (bVar2) { - pTVar5->Actions = pTVar5->Actions + 1; - } -LAB_080b2161: - TReadScriptFile::nextToken(Script); -LAB_080b20c3: - if ((Script->Token != SPECIAL) || (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != ',')) - goto LAB_080b20d7; - goto LAB_080b2089; -LAB_080b20d7: - this->Behaviours = this->Behaviours + 1; - goto LAB_080b1da5; -} - - - -// WARNING: Variable defined which should be unmapped: Left -// DWARF original prototype: TNode * readValue(TBehaviourDatabase * this, TReadScriptFile * Script) - -TNode * __thiscall TBehaviourDatabase::readValue(TBehaviourDatabase *this,TReadScriptFile *Script) - -{ - char cVar1; - TNode *Node_1; - TNode *pTVar2; - TNode *pTVar3; - TOKEN TVar4; - int iVar5; - TNode *Left_1; - TNode *Right; - char *pcVar6; - undefined1 uVar7; - char *pcVar8; - TNode *local_2c; - TNode *Node; - TNode *Left_10; - TNode *Left_8; - TNode *Left_6; - TNode *Left_4; - TNode *Left_2; - TNode *Left; - - local_2c = (TNode *)0x0; - TVar4 = Script->Token; - if (TVar4 == NUMBER) { - iVar5 = TReadScriptFile::getNumber(Script); - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xb; -LAB_080b3db2: - local_2c->Data = iVar5; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - goto LAB_080b3310; - } - if ((int)TVar4 < 3) { - uVar7 = TVar4 == IDENTIFIER; - if (!(bool)uVar7) goto LAB_080b3300; - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 6; - pcVar6 = "topic"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xc; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 6; - pcVar6 = "price"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xd; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 7; - pcVar6 = "amount"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xe; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 6; - pcVar6 = "level"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xf; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 9; - pcVar6 = "maglevel"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xf; - local_2c->Data = 1; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 3; - pcVar6 = "hp"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xf; - local_2c->Data = 2; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 8; - pcVar6 = "burning"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xf; - local_2c->Data = 0x12; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 7; - pcVar6 = "poison"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0xf; - local_2c->Data = 0x11; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 6; - pcVar6 = "count"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b347a to 080b34b9 has its CatchHandler @ 080b3de7 - Left_2 = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Left_2; - pTVar3->Right = pTVar2; - Left_2 = pTVar3; - } - // try { // try from 080b34d5 to 080b3522 has its CatchHandler @ 080b3e00 - while ((TVar4 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Left_2; - TVar4 = Script->Token; - Left_2 = pTVar3; - } - // try { // try from 080b353d to 080b360e has its CatchHandler @ 080b3e50 - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x10; - } - else { - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 0xb; - pcVar6 = "countmoney"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x11; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 5; - pcVar6 = "type"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x12; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 5; - pcVar6 = "data"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x13; - local_2c->Data = 0; - local_2c->Left = (TNode *)0x0; - local_2c->Right = (TNode *)0x0; - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 0xb; - pcVar6 = "spellknown"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b3619 to 080b3658 has its CatchHandler @ 080b3e0b - Left_4 = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Left_4; - pTVar3->Right = pTVar2; - Left_4 = pTVar3; - } - // try { // try from 080b3674 to 080b36c1 has its CatchHandler @ 080b3e16 - while ((TVar4 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Left_4; - TVar4 = Script->Token; - Left_4 = pTVar3; - } - // try { // try from 080b36dc to 080b3725 has its CatchHandler @ 080b3e50 - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x14; - Left_2 = Left_4; - } - else { - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 0xb; - pcVar6 = "spelllevel"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b3730 to 080b376f has its CatchHandler @ 080b3e18 - Left_6 = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Left_6; - pTVar3->Right = pTVar2; - Left_6 = pTVar3; - } - // try { // try from 080b378b to 080b37d8 has its CatchHandler @ 080b3e23 - while ((TVar4 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Left_6; - TVar4 = Script->Token; - Left_6 = pTVar3; - } - // try { // try from 080b37f3 to 080b383c has its CatchHandler @ 080b3e50 - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x15; - Left_2 = Left_6; - } - else { - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 7; - pcVar6 = "random"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if ((bool)uVar7) { - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b3847 to 080b3886 has its CatchHandler @ 080b3e25 - Left_8 = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Left_8; - pTVar3->Right = pTVar2; - Left_8 = pTVar3; - } - do { - if (TVar4 != SPECIAL) goto LAB_080b390b; - // try { // try from 080b38a2 to 080b38ef has its CatchHandler @ 080b3e30 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ',')) - goto LAB_080b391b; - goto LAB_080b390b; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Left_8; - TVar4 = Script->Token; - Left_8 = pTVar3; - } while( true ); - } - pcVar8 = TReadScriptFile::getIdentifier(Script); - iVar5 = 0xb; - pcVar6 = "questvalue"; - do { - if (iVar5 == 0) break; - iVar5 = iVar5 + -1; - uVar7 = *pcVar8 == *pcVar6; - pcVar8 = pcVar8 + 1; - pcVar6 = pcVar6 + 1; - } while ((bool)uVar7); - if (!(bool)uVar7) goto LAB_080b3310; - TReadScriptFile::readSymbol(Script,'('); - TReadScriptFile::nextToken(Script); - // try { // try from 080b3a88 to 080b3ac7 has its CatchHandler @ 080b3e3f - Node = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Node; - pTVar3->Right = pTVar2; - Node = pTVar3; - } - // try { // try from 080b3ae3 to 080b3b30 has its CatchHandler @ 080b3e00 - while ((TVar4 == SPECIAL && - ((cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '+' || - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == '-'))))) { - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Node; - TVar4 = Script->Token; - Node = pTVar3; - } - // try { // try from 080b3b4b to 080b3dde has its CatchHandler @ 080b3e50 - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x17; - Left_2 = Node; - } - } - } - local_2c->Left = Left_2; - local_2c->Right = (TNode *)0x0; - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b3310; - pcVar8 = ") expected"; - } - else { - if (TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '%') { - TReadScriptFile::error(Script,"illegal character"); - } - iVar5 = TReadScriptFile::readNumber(Script); - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 10; - goto LAB_080b3db2; - } -LAB_080b3300: - pcVar8 = "illegal value"; - } - // try { // try from 080b330b to 080b346f has its CatchHandler @ 080b3e50 - TReadScriptFile::error(Script,pcVar8); -LAB_080b3310: - if (local_2c == (TNode *)0x0) { - TReadScriptFile::error(Script,"unknown value"); - } - TReadScriptFile::nextToken(Script); - return local_2c; -LAB_080b390b: - // try { // try from 080b3916 to 080b3922 has its CatchHandler @ 080b3e50 - TReadScriptFile::error(Script,", expected"); -LAB_080b391b: - TReadScriptFile::nextToken(Script); - // try { // try from 080b392d to 080b396c has its CatchHandler @ 080b3e32 - Left_10 = readValue(this,Script); - while (TVar4 = Script->Token, TVar4 == SPECIAL) { - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') { - TVar4 = Script->Token; - break; - } - TReadScriptFile::nextToken(Script); - pTVar2 = readValue(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = 9; - pTVar3->Left = Left_10; - pTVar3->Right = pTVar2; - Left_10 = pTVar3; - } - do { - if (TVar4 != SPECIAL) break; - // try { // try from 080b3988 to 080b39d5 has its CatchHandler @ 080b3e3d - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - if ((Script->Token == SPECIAL) && - (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 == ')')) goto LAB_080b39fd; - break; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - pTVar2 = readFactor(this,Script); - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar2; - pTVar3->Left = Left_10; - TVar4 = Script->Token; - Left_10 = pTVar3; - } while( true ); - // try { // try from 080b39f8 to 080b3a7d has its CatchHandler @ 080b3e50 - TReadScriptFile::error(Script,") expected"); -LAB_080b39fd: - local_2c = store::getFreeItem(NodeTable); - local_2c->Type = 0x16; - local_2c->Left = Left_8; - local_2c->Right = Left_10; - goto LAB_080b3310; -} - - - -// WARNING: Variable defined which should be unmapped: Right -// DWARF original prototype: TNode * readFactor(TBehaviourDatabase * this, TReadScriptFile * Script) - -TNode * __thiscall TBehaviourDatabase::readFactor(TBehaviourDatabase *this,TReadScriptFile *Script) - -{ - char cVar1; - TNode *Node; - TNode *pTVar2; - TNode *pTVar3; - TNode *pTVar4; - TNode *Left; - TNode *Right; - - // try { // try from 080b3e7c to 080b3eb7 has its CatchHandler @ 080b3ed8 - pTVar2 = readValue(this,Script); - while( true ) { - if (Script->Token != SPECIAL) { - return pTVar2; - } - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') break; - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar4 = store::getFreeItem(NodeTable); - pTVar4->Type = 9; - pTVar4->Left = pTVar2; - pTVar4->Right = pTVar3; - pTVar2 = pTVar4; - } - return pTVar2; -} - - - -// WARNING: Variable defined which should be unmapped: Right -// DWARF original prototype: TNode * readTerm(TBehaviourDatabase * this, TReadScriptFile * Script) - -TNode * __thiscall TBehaviourDatabase::readTerm(TBehaviourDatabase *this,TReadScriptFile *Script) - -{ - char cVar1; - char cVar2; - TNode *Node; - TNode *pTVar3; - TNode *pTVar4; - TNode *pTVar5; - TOKEN TVar6; - TNode *pTVar7; - TNode *Left; - TNode *Right_1; - TNode *Left_2; - int Operator; - TNode *Right; - - // try { // try from 080b3f0c to 080b3f49 has its CatchHandler @ 080b4030 - pTVar3 = readValue(this,Script); - while( true ) { - TVar6 = Script->Token; - pTVar4 = pTVar3; - if (TVar6 != SPECIAL) goto LAB_080b3f5d; - cVar1 = TReadScriptFile::getSpecial(Script); - if (cVar1 != '*') break; - TReadScriptFile::nextToken(Script); - pTVar4 = readValue(this,Script); - pTVar5 = store::getFreeItem(NodeTable); - pTVar5->Type = 9; - pTVar5->Left = pTVar3; - pTVar5->Right = pTVar4; - pTVar3 = pTVar5; - } - while( true ) { - TVar6 = Script->Token; - pTVar4 = pTVar3; -LAB_080b3f5d: - if (TVar6 != SPECIAL) break; - // try { // try from 080b3f69 to 080b3fa0 has its CatchHandler @ 080b4048 - cVar1 = TReadScriptFile::getSpecial(Script); - if ((cVar1 != '+') && (cVar1 = TReadScriptFile::getSpecial(Script), cVar1 != '-')) { - return pTVar4; - } - cVar1 = TReadScriptFile::getSpecial(Script); - TReadScriptFile::nextToken(Script); - // try { // try from 080b3fa8 to 080b3fe4 has its CatchHandler @ 080b4030 - pTVar5 = readValue(this,Script); - while ((Script->Token == SPECIAL && - (cVar2 = TReadScriptFile::getSpecial(Script), cVar2 == '*'))) { - TReadScriptFile::nextToken(Script); - pTVar3 = readValue(this,Script); - pTVar7 = store::getFreeItem(NodeTable); - pTVar7->Type = 9; - pTVar7->Left = pTVar5; - pTVar7->Right = pTVar3; - pTVar5 = pTVar7; - } - // try { // try from 080b4001 to 080b4005 has its CatchHandler @ 080b4048 - pTVar3 = store::getFreeItem(NodeTable); - pTVar3->Left = pTVar4; - pTVar3->Type = (cVar1 != '+') + 7; - pTVar3->Right = pTVar5; - } - return pTVar4; -} - - - -// DWARF original prototype: int evaluate(TBehaviourDatabase * this, TNPC * npc, TNode * Node, int * -// Number) - -int __thiscall -TBehaviourDatabase::evaluate(TBehaviourDatabase *this,TNPC *npc,TNode *Node,int *Number) - -{ - TSkill *pTVar1; - bool bVar2; - TPlayer *this_00; - uint uVar3; - int iVar4; - int iVar5; - TPlayer *Opp; - char *pcVar6; - ObjectType local_2c [7]; - - if (Node == (TNode *)0x0) { - pcVar6 = "TBehaviourDatabase::evaluate: Knoten existiert nicht.\n"; -LAB_080b4560: - error(pcVar6); - goto LAB_080b4130; - } - if (Number == (int *)0x0) { - pcVar6 = "TBehaviourDatabase::evaluate: Zahlen existieren nicht.\n"; - goto LAB_080b4560; - } - if (npc == (TNPC *)0x0) { - pcVar6 = "TBehaviourDatabase::evaluate: NPC existiert nicht.\n"; - goto LAB_080b4560; - } - this_00 = GetPlayer(npc->Interlocutor); - if (this_00 == (TPlayer *)0x0) { - pcVar6 = &DAT_08104c40; - goto LAB_080b4560; - } - iVar5 = Node->Type; - switch(iVar5) { - default: - pcVar6 = &DAT_08104b40; - goto LAB_080b412b; - case 1: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar5 < iVar4; - goto LAB_080b4100; - case 2: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar4 < iVar5; - goto LAB_080b4100; - case 3: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar5 == iVar4; - goto LAB_080b4100; - case 4: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar5 == iVar4; - goto LAB_080b41fb; - case 5: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar5 <= iVar4; - goto LAB_080b4100; - case 6: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - bVar2 = iVar4 <= iVar5; - goto LAB_080b4100; - case 7: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - uVar3 = iVar4 + iVar5; - break; - case 8: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - uVar3 = iVar5 - iVar4; - break; - case 9: - iVar5 = evaluate(this,npc,Node->Left,Number); - iVar4 = evaluate(this,npc,Node->Right,Number); - uVar3 = iVar4 * iVar5; - break; - case 10: - iVar5 = Node->Data; - if (iVar5 - 1U < 3) { - if (-1 < Number[iVar5 + -1]) { - return Number[iVar5 + -1]; - } - pcVar6 = "TBehaviourDatabase::evaluate: Zahl-Parameter %d nicht belegt.\n"; - } - else { - pcVar6 = &DAT_08104bc0; - } - goto LAB_080b412b; - case 0xb: - uVar3 = Node->Data; - break; - case 0xc: - uVar3 = npc->Topic; - break; - case 0xd: - uVar3 = npc->Price; - break; - case 0xe: - uVar3 = npc->Amount; - break; - case 0xf: - iVar5 = Node->Data; - if (-1 < iVar5) { - if (iVar5 < 3) { - iVar5 = TSkill::Get((this_00->super_TCreature).super_TSkillBase.Skills[iVar5]); - return iVar5; - } - if (iVar5 - 0x11U < 2) { - pTVar1 = (this_00->super_TCreature).super_TSkillBase.Skills[iVar5]; - iVar5 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1); - return iVar5; - } - } - pcVar6 = &DAT_08104c00; -LAB_080b412b: - error(pcVar6,iVar5); -LAB_080b4130: - uVar3 = 0; - break; - case 0x10: - iVar5 = evaluate(this,npc,Node->Left,Number); - ObjectType::setTypeID(local_2c,iVar5); - uVar3 = CountInventoryObjects(npc->Interlocutor,local_2c,npc->Data); - break; - case 0x11: - uVar3 = CountInventoryMoney(npc->Interlocutor); - break; - case 0x12: - uVar3 = npc->TypeID; - break; - case 0x13: - uVar3 = npc->Data; - break; - case 0x14: - iVar5 = evaluate(this,npc,Node->Left,Number); - bVar2 = TPlayer::SpellKnown(this_00,iVar5); - bVar2 = !bVar2; -LAB_080b41fb: - bVar2 = !bVar2; -LAB_080b4100: - uVar3 = (uint)bVar2; - break; - case 0x15: - iVar5 = evaluate(this,npc,Node->Left,Number); - uVar3 = GetSpellLevel(iVar5); - break; - case 0x16: - evaluate(this,npc,Node->Right,Number); - evaluate(this,npc,Node->Left,Number); - uVar3 = random(); - break; - case 0x17: - iVar5 = evaluate(this,npc,Node->Left,Number); - uVar3 = TPlayer::GetQuestValue(this_00,iVar5); - } - return uVar3; -} - - - -// DWARF original prototype: void react(TBehaviourDatabase * this, TNPC * npc, char * Text, -// SITUATION Situation) - -void __thiscall -TBehaviourDatabase::react(TBehaviourDatabase *this,TNPC *npc,char *Text,SITUATION Situation) - -{ - char cVar1; - TSkill *pTVar2; - byte bVar3; - uchar uVar4; - RESULT r_1; - TPlayer *this_00; - TBehaviour *pTVar5; - TAction *pTVar6; - size_t sVar7; - ulong uVar8; - TMonster *this_01; - int iVar9; - int iVar10; - int iVar11; - TCondition *pTVar12; - undefined4 uVar13; - uint *puVar14; - uint *puVar15; - RESULT r; - uint uVar16; - uint uVar17; - TPlayer *pTVar18; - int Value3; - TAction *A; - uint uVar19; - int Value; - bool bVar20; - bool bVar21; - char *pcVar22; - char *pcVar23; - ObjectType *Type; - TNPC *pTVar24; - int Crystal; - int Value2; - char *AText; - int j; - TBehaviour *B; - int TalkDelay; - int iStack_1cc; - bool StartToDo; - int j_1; - bool fulfilled; - TBehaviour *B_1; - int i; - int bestPattern; - int maxConditions; - TPlayer *Opp; - int local_1ac; - int local_1a8; - int local_1a4; - int Hour; - int Minute; - char Help [50]; - char acStack_15f [3]; - uint local_15c; - char Response [300]; - int local_2c; - int Numbers [3]; - - if (npc == (TNPC *)0x0) { - pcVar22 = "TBehaviourDatabase::react: NPC existiert nicht.\n"; - } - else { - if (Text != (char *)0x0) { - this_00 = GetPlayer(npc->Interlocutor); - if (this_00 == (TPlayer *)0x0) { - error(&DAT_08105220,Text,Situation); - return; - } - local_2c = -1; - Numbers[0] = -1; - bestPattern = -1; - i = -1; - Numbers[1] = -1; - B_1 = (TBehaviour *)0x0; - if (0 < this->Behaviours) { - do { - pTVar5 = vector::operator()(&this->Behaviour,(int)B_1); - iStack_1cc = 0; - bVar21 = true; - iVar9 = pTVar5->Conditions; - pcVar22 = Text; - if (iVar9 < 1) { -LAB_080b5354: - if ((bVar21) && (bestPattern < iVar9)) { - i = (int)B_1; - bestPattern = iVar9; - } - } - else { - do { - pTVar12 = vector::operator()(&pTVar5->Condition,iStack_1cc); - switch(pTVar12->Type) { - case 1: - pcVar23 = GetDynamicString(pTVar12->Text); - pcVar23 = SearchForWord(pcVar23,pcVar22); - if (pcVar23 == (char *)0x0) { -LAB_080b5379: - bVar21 = false; - } - else { - pcVar22 = GetDynamicString(pTVar12->Text); - sVar7 = strlen(pcVar22); - pcVar22 = pcVar23 + sVar7; - } - break; - case 2: - iVar9 = pTVar12->Property; - if (((iVar9 == 1) && (Situation != ADDRESS)) && - (Situation != ADDRESSQUEUE)) { - bVar21 = false; - } - if ((iVar9 == 2) && (Situation != BUSY)) { - bVar21 = false; - } - if ((iVar9 == 3) && (Situation != VANISH)) { - bVar21 = false; - } - if ((iVar9 == 4) && ((this_00->super_TCreature).Sex != 1)) { - bVar21 = false; - } - if ((iVar9 == 5) && ((this_00->super_TCreature).Sex != 2)) { - bVar21 = false; - } - if (iVar9 == 6) { - uVar4 = TPlayer::GetEffectiveProfession(this_00); - if (uVar4 != '\x01') { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if (iVar9 == 7) { - uVar4 = TPlayer::GetEffectiveProfession(this_00); - if (uVar4 != '\x02') { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if (iVar9 == 8) { - uVar4 = TPlayer::GetEffectiveProfession(this_00); - if (uVar4 != '\x03') { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if (iVar9 == 9) { - uVar4 = TPlayer::GetEffectiveProfession(this_00); - if (uVar4 != '\x04') { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if (iVar9 == 10) { - bVar20 = CheckRight((this_00->super_TCreature).ID, - PREMIUM_ACCOUNT); - if (!bVar20) { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if (iVar9 == 0xb) { - bVar3 = TPlayer::GetRealProfession(this_00); - if (bVar3 < 10) { - bVar21 = false; - } - iVar9 = pTVar12->Property; - } - if ((iVar9 == 0xc) && - ((this_00->super_TCreature).EarliestProtectionZoneRound <= - RoundNr)) { - bVar21 = false; - } - if ((iVar9 == 0xd) && (WorldType != NON_PVP)) { - bVar21 = false; - } - if ((iVar9 == 0xe) && (WorldType != PVP_ENFORCED)) - goto LAB_080b5379; - break; - case 3: - pcVar23 = SearchForNumber(pTVar12->Number,pcVar22); - if (pcVar23 == (char *)0x0) goto LAB_080b5379; - iVar9 = pTVar12->Number; - uVar13 = __strtol_internal(pcVar23,0,10,0); - *(undefined4 *)(Response + iVar9 * 4 + 0x128) = uVar13; - if (500 < *(int *)(Response + pTVar12->Number * 4 + 0x128)) { - pcVar22 = Response + pTVar12->Number * 4 + 0x128; - pcVar22[0] = -0xc; - pcVar22[1] = '\x01'; - pcVar22[2] = '\0'; - pcVar22[3] = '\0'; - } - pcVar22 = pcVar23 + 1; - break; - case 4: - iVar9 = evaluate(this,npc,pTVar12->Expression,&local_2c); - if (iVar9 == 0) goto LAB_080b5379; - break; - case 5: - i = (int)B_1; - goto LAB_080b4622; - } - iStack_1cc = iStack_1cc + 1; - iVar9 = pTVar5->Conditions; - if (iVar9 <= iStack_1cc) goto LAB_080b5354; - } while (bVar21); - } - B_1 = (TBehaviour *)((int)&(B_1->Condition).min + 1); - } while ((int)B_1 < this->Behaviours); - } - if (bestPattern == -1) { - return; - } -LAB_080b4622: - if (Situation != BUSY) { - npc->Topic = 0; - } - bVar21 = false; - B = (TBehaviour *)0x3e8; -LAB_080b4645: - pTVar5 = vector::operator()(&this->Behaviour,i); - AText = (char *)0x0; - if (pTVar5->Actions < 1) { -LAB_080b479b: - if (!bVar21) { - return; - } - TCreature::ToDoWait((TCreature *)npc,(int)B); - TCreature::ToDoStart((TCreature *)npc); - if (Situation == BUSY) { - return; - } - npc->LastTalk = (int)B / 1000 + RoundNr; - return; - } - do { - pTVar24 = (TNPC *)AText; - pTVar6 = vector::operator()(&pTVar5->Action,(int)AText); - switch(pTVar6->Type) { - case 1: - puVar15 = &local_15c; - for (iVar9 = 0x4b; iVar9 != 0; iVar9 = iVar9 + -1) { - *puVar15 = 0; - puVar15 = puVar15 + 1; - } - pcVar22 = GetDynamicString(pTVar6->Text); - for (uVar19 = 0; sVar7 = strlen(pcVar22), uVar19 < sVar7; uVar19 = uVar19 + 1) { - if (pcVar22[uVar19] == '%') { - uVar19 = uVar19 + 1; - cVar1 = pcVar22[uVar19]; - if (cVar1 == 'N') { - strcpy((char *)&Minute,(this_00->super_TCreature).Name); - } - else if (cVar1 < 'O') { - if (cVar1 == 'A') { - iVar9 = npc->Amount; -LAB_080b4856: - sprintf((char *)&Minute,"%d",iVar9); - } - else { -LAB_080b4814: - Minute = Minute & 0xffffff00; - } - } - else { - if (cVar1 == 'P') { - iVar9 = npc->Price; - goto LAB_080b4856; - } - if (cVar1 != 'T') goto LAB_080b4814; - GetTime(&local_1a4,&Hour); - if (local_1a4 < 0xc) { - pcVar23 = "%d:%.2d am"; - } - else { - pcVar23 = "%d:%.2d pm"; - } - sprintf((char *)&Minute,pcVar23,(local_1a4 + 0xb) % 0xc + 1,Hour); - } - strcat((char *)&local_15c,(char *)&Minute); - } - else { - puVar15 = &local_15c; - do { - puVar14 = puVar15; - uVar16 = *puVar14 + 0xfefefeff & ~*puVar14; - uVar17 = uVar16 & 0x80808080; - puVar15 = puVar14 + 1; - } while (uVar17 == 0); - bVar20 = (uVar16 & 0x8080) == 0; - if (bVar20) { - uVar17 = uVar17 >> 0x10; - } - if (bVar20) { - puVar15 = (uint *)((int)puVar14 + 6); - } - acStack_15f - [(int)puVar15 + - (-(int)&local_15c - (uint)CARRY1((byte)uVar17,(byte)uVar17))] = - pcVar22[uVar19]; - } - if (Response[0xfc] != '\0') goto LAB_080b4755; - } - if (Response[0xfc] == '\0') { - TCreature::ToDoWait((TCreature *)npc,(int)B); - TCreature::ToDoTalk((TCreature *)npc); - puVar15 = &local_15c; - do { - puVar14 = puVar15; - uVar17 = *puVar14 + 0xfefefeff & ~*puVar14; - uVar19 = uVar17 & 0x80808080; - puVar15 = puVar14 + 1; - } while (uVar19 == 0); - bVar21 = (uVar17 & 0x8080) == 0; - if (bVar21) { - uVar19 = uVar19 >> 0x10; - } - if (bVar21) { - puVar15 = (uint *)((int)puVar14 + 6); - } - B = (TBehaviour *) - ((int)&B[0x1c].Action + - ((int)puVar15 + - ((-3 - (uint)CARRY1((byte)uVar19,(byte)uVar19)) - (int)&local_15c) >> 1 - ) * 100 + 0x1c); -LAB_080b49eb: - bVar21 = true; - } - else { -LAB_080b4755: - Response[0x10] = '\0'; - puVar15 = &local_15c; - pcVar22 = - "TBehaviourDatabase::react: Text von NPC %s wird zu lang (%s...).\n"; -LAB_080b4779: - error(pcVar22,(npc->super_TNonplayer).super_TCreature.Name,puVar15); - } - break; - case 2: - pTVar24 = npc; - uVar8 = evaluate(this,npc,pTVar6->Expression,&local_2c); - switch(pTVar6->Number) { - default: - pcVar22 = &DAT_08104dc0; - goto LAB_080b4a67; - case 1: - npc->Topic = uVar8; - break; - case 2: - npc->Price = uVar8; - break; - case 3: - npc->Amount = uVar8; - break; - case 4: - npc->TypeID = uVar8; - break; - case 6: - npc->Data = uVar8; - } - break; - case 3: - pTVar24 = npc; - iVar9 = evaluate(this,npc,pTVar6->Expression,&local_2c); - if (pTVar6->Number != 2) { - pcVar22 = &DAT_08104e00; - goto LAB_080b4a67; - } - (*(this_00->super_TCreature).super_TSkillBase.Skills[2]->_vptr_TSkill[2]) - ((this_00->super_TCreature).super_TSkillBase.Skills[2],iVar9); - iVar9 = TSkill::Get((this_00->super_TCreature).super_TSkillBase.Skills[2]); - if (iVar9 < 1) { - error(&DAT_08104e40,(npc->super_TNonplayer).super_TCreature.Name); - (*(this_00->super_TCreature)._vptr_TCreature[2])(this_00); - } - break; - case 4: - iVar9 = evaluate(this,npc,pTVar6->Expression,&local_2c); - pTVar24 = npc; - iVar10 = evaluate(this,npc,pTVar6->Expression2,&local_2c); - if (pTVar6->Number != 3) { - pcVar22 = &DAT_08104e80; - goto LAB_080b4a67; - } - TPlayer::SetQuestValue(this_00,iVar9,iVar10); - break; - case 5: - pTVar24 = npc; - iVar9 = evaluate(this,npc,pTVar6->Expression,&local_2c); - switch(pTVar6->Number) { - default: - pcVar22 = &DAT_08104ec0; - goto LAB_080b4a67; - case 1: - pTVar18 = (TPlayer *)npc; - goto LAB_080b4bb8; - case 2: - pTVar18 = this_00; -LAB_080b4bb8: - Minute = (pTVar18->super_TCreature).CrObject.ObjectID; - GraphicalEffect((Object *)&Minute,iVar9); - break; - case 3: - TPlayer::SetProfession(this_00,(uchar)iVar9); - break; - case 4: - TPlayer::LearnSpell(this_00,iVar9); - break; - case 5: - Opp = (TPlayer *)(npc->super_TNonplayer).super_TCreature.posx; - local_1ac = (npc->super_TNonplayer).super_TCreature.posy; - local_1a8 = (npc->super_TNonplayer).super_TCreature.posz; - if (iVar9 - 1U < 0x1ff) { - if (RaceData[iVar9].Name[0] != '\0') { - SearchFreeField((int *)&Opp,&local_1ac,&local_1a8,2,0,false); - this_01 = (TMonster *)operator_new(0x32c); - // try { // try from 080b4cfc to 080b4d00 has its CatchHandler @ 080b5666 - TMonster::TMonster(this_01); - GraphicalEffect(); - break; - } - pcVar22 = &DAT_08104f00; - } - else { - pcVar22 = &DAT_08104f40; - } - error(pcVar22,iVar9); - break; - case 6: - Type = (ObjectType *)&Minute; - ObjectType::setTypeID((ObjectType *)&Minute,iVar9); - iVar9 = npc->Amount; -LAB_080b4d73: - TNPC::GiveTo(npc,Type,iVar9); - break; - case 7: - ObjectType::setTypeID((ObjectType *)&Minute,iVar9); - iVar9 = npc->Amount; - if (iVar9 != 0) { - pcVar22 = ObjectType::getName((ObjectType *)&Minute); - Log("npc","%s <- %ld: %d %s\n", - (npc->super_TNonplayer).super_TCreature.Name,npc->Interlocutor,iVar9 - ,pcVar22); - // try { // try from 080b4e01 to 080b4e28 has its CatchHandler @ 080b5678 - ObjectType::setTypeID((ObjectType *)(Help + 0xc),Minute); - DeleteAtCreature(npc->Interlocutor,(ObjectType *)(Help + 0xc),iVar9, - npc->Data); - } - } - break; - case 6: - iVar9 = pTVar6->Number; - if (iVar9 != 2) { - if (iVar9 < 3) { - if (iVar9 == 1) { - iVar10 = npc->Price; - iVar9 = iVar10 % 100; - Type = (ObjectType *)(Help + 0xc); - GetSpecialObject((SPECIALMEANING)Type); - TNPC::GiveTo(npc,Type,iVar10 / 10000); - GetSpecialObject((SPECIALMEANING)Type); - TNPC::GiveTo(npc,Type,(iVar10 % 10000) / 100); - GetSpecialObject((SPECIALMEANING)Type); - goto LAB_080b4d73; - } - } - else if (iVar9 == 3) { - if (Situation != BUSY) { - error(&DAT_08104fc0); - } - TNPC::Enqueue(npc,npc->Interlocutor,Text); - break; - } - pcVar22 = &DAT_08104f80; - goto LAB_080b4a67; - } - TNPC::GetMoney(npc,npc->Price); - break; - case 7: - if (!bVar21) { - (npc->super_TNonplayer).State = pTVar6->Number; - if (Situation == ADDRESSQUEUE) { - pcVar22 = - "TBehaviourDatabase::react: NPC %s reagiert nicht auf Anrede %s.\n"; - puVar15 = (uint *)Text; - goto LAB_080b4779; - } - goto LAB_080b49eb; - } - iVar9 = pTVar6->Number; - if (iVar9 == 1) { - (npc->super_TNonplayer).State = LEAVING; - iVar9 = pTVar6->Number; - } - TCreature::ToDoChangeState((TCreature *)npc,iVar9); - break; - case 8: - iVar9 = evaluate(this,npc,pTVar6->Expression,&local_2c); - pTVar24 = npc; - evaluate(this,npc,pTVar6->Expression2,&local_2c); - if (1 < pTVar6->Number - 0x11U) { - pcVar22 = &DAT_08105080; - goto LAB_080b4a67; - } - if ((iVar9 == 0) || - (pTVar2 = (this_00->super_TCreature).super_TSkillBase.Skills[pTVar6->Number], - iVar10 = (*pTVar2->_vptr_TSkill[0xd])(pTVar2), iVar10 < iVar9)) { - TSkillBase::SetTimer(&(this_00->super_TCreature).super_TSkillBase); - if (pTVar6->Number == 0x12) { - (this_00->super_TCreature).FireDamageOrigin = 0; - } - else { - (this_00->super_TCreature).PoisonDamageOrigin = 0; - } - } - break; - case 9: - if (i != 0) goto LAB_080b50d7; - pcVar22 = "TBehaviourDatabase::react (9): Kein vorheriges Muster.\n"; -LAB_080b4a67: - error(pcVar22,pTVar24); - break; - case 10: - iVar9 = evaluate(this,npc,pTVar6->Expression,&local_2c); - iVar10 = evaluate(this,npc,pTVar6->Expression2,&local_2c); - pTVar24 = npc; - iVar11 = evaluate(this,npc,pTVar6->Expression3,&local_2c); - if (pTVar6->Number != 1) { - if (pTVar6->Number == 2) { - pTVar24 = (TNPC *)&DAT_08105140; - print(); - if ((this_00->super_TCreature).Type == PLAYER) { - (this_00->super_TCreature).startx = iVar9; - (this_00->super_TCreature).startz = iVar11; - (this_00->super_TCreature).starty = iVar10; - TPlayer::SaveData(this_00); - break; - } - pcVar22 = &DAT_08105180; - } - else { - pcVar22 = &DAT_08105100; - } - goto LAB_080b4a67; - } - print(); - Help[0xc] = (undefined1)::NONE.ObjectID; - Help[0xd] = ::NONE.ObjectID._1_1_; - Help[0xe] = ::NONE.ObjectID._2_1_; - Help[0xf] = ::NONE.ObjectID._3_1_; - // try { // try from 080b5218 to 080b5265 has its CatchHandler @ 080b56be - GetMapContainer((int)&Minute,iVar9,iVar10); - Help._28_4_ = (this_00->super_TCreature).CrObject.ObjectID; - Move(0,(Object *)(Help + 0x1c),(Object *)&Minute,-1,false,(Object *)(Help + 0xc) - ); - } - AText = AText + 1; - if (pTVar5->Actions <= (int)AText) goto LAB_080b479b; - } while( true ); - } - pcVar22 = &DAT_08105280; - } - error(pcVar22); - return; -LAB_080b50d7: - i = i + -1; - goto LAB_080b4645; -} - - - -void StartMonsterhomeTimer(int nr) - -{ - TMonsterhome *pTVar1; - long lVar2; - int NumberOfPlayers; - TMonsterhome *MH; - int PlayerAdjustedTime; - - if ((nr < 1) || (Monsterhomes < nr)) { - error(&DAT_08105380,nr); - } - else { - pTVar1 = vector<>::operator()(&Monsterhome,nr); - if (0 < pTVar1->Timer) { - error(&DAT_081053c0); - return; - } - if (pTVar1->ActMonsters < pTVar1->MaxMonsters) { - GetNumberOfPlayers(); - lVar2 = random(); - pTVar1->Timer = lVar2; - } - else { - error("StartMonsterhomeTimer: Maximale Monsterzahl schon erreicht.\n"); - error("# Monsterhome mit Rasse %d an [%d,%d,%d]\n",pTVar1->Race,pTVar1->x,pTVar1->y, - pTVar1->z); - } - } - return; -} - - - -// WARNING: Removing unreachable block (ram,0x080b5ba0) -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void LoadMonsterhomes(void) - -{ - bool bVar1; - int r; - int iVar2; - TMonsterhome *pTVar3; - TMonster *this; - int *piVar4; - int Race; - TMonsterhome *MH; - char *Text; - char *pcVar5; - int local_5024; - int j; - int i; - int local_5018; - int local_5014; - int local_5010; - int x; - int y; - int z; - int local_5000; - undefined1 local_4ffc [4]; - TReadScriptFile Script; - char local_101c [4]; - char FileName [4096]; - - // try { // try from 080b5821 to 080b5851 has its CatchHandler @ 080b5c40 - print(); - pcVar5 = DATAPATH; - sprintf(local_101c,"%s/monster.db"); - TReadScriptFile::TReadScriptFile((TReadScriptFile *)local_4ffc); - // try { // try from 080b5859 to 080b5955 has its CatchHandler @ 080b5c33 - TReadScriptFile::open((TReadScriptFile *)local_4ffc,local_101c,(int)pcVar5); - Monsterhomes = 0; - while (iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc), iVar2 != 0) { - Monsterhomes = Monsterhomes + 1; - pTVar3 = vector<>::operator()(&Monsterhome,Monsterhomes); - pTVar3->Race = iVar2; - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->x = iVar2; - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->y = iVar2; - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->z = iVar2; - bVar1 = IsOnMap(pTVar3->x,pTVar3->y,iVar2); - if (!bVar1) { - print(); - } - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->Radius = iVar2; - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->MaxMonsters = iVar2; - pTVar3->ActMonsters = 0; - iVar2 = TReadScriptFile::readNumber((TReadScriptFile *)local_4ffc); - pTVar3->RegenerationTime = iVar2; - pTVar3->Timer = 0; - } - pcVar5 = "%d Monsterhomes geladen.\n"; - print(); - TReadScriptFile::close((TReadScriptFile *)local_4ffc,(int)pcVar5); - j = 1; - if (0 < Monsterhomes) { - do { - pcVar5 = (char *)j; - // try { // try from 080b5994 to 080b5b4d has its CatchHandler @ 080b5c33 - pTVar3 = vector<>::operator()(&Monsterhome,j); - local_5024 = 0; - iVar2 = pTVar3->MaxMonsters; - if (0 < iVar2) { - do { - local_5010 = pTVar3->x; - x = pTVar3->y; - y = pTVar3->z; - if (local_5024 == 0) { - local_5000 = 1; - piVar4 = &local_5000; - if (pTVar3->Radius < 1) { - piVar4 = &pTVar3->Radius; - } - iVar2 = *piVar4; - } - else { - z = 10; - piVar4 = &z; - if (pTVar3->Radius < 10) { - piVar4 = &pTVar3->Radius; - } - iVar2 = -*piVar4; - } - pcVar5 = (char *)&x; - bVar1 = SearchSpawnField(&local_5010,(int *)pcVar5,&y,iVar2,false); - if (bVar1) { - pcVar5 = (char *)pTVar3->Race; - i = local_5010; - local_5018 = x; - local_5014 = y; - if ((int)pcVar5 - 1U < 0x1ff) { - if (RaceData[(int)pcVar5].Name[0] == '\0') { - Text = &DAT_08104f00; - goto LAB_080b5a8b; - } - SearchFreeField(&i,&local_5018,&local_5014,2,0,false); - this = (TMonster *)operator_new(0x32c); - // try { // try from 080b5b91 to 080b5b95 has its CatchHandler @ 080b5c04 - TMonster::TMonster(this); - } - else { - Text = &DAT_08104f40; -LAB_080b5a8b: - error(Text); - } - pTVar3->ActMonsters = pTVar3->ActMonsters + 1; - } - local_5024 = local_5024 + 1; - iVar2 = pTVar3->MaxMonsters; - } while (local_5024 < iVar2); - } - if (pTVar3->Timer < 1) { - if (pTVar3->ActMonsters < iVar2) { - StartMonsterhomeTimer(j); - } - } - else { - pcVar5 = (char *)pTVar3->Race; - error(&DAT_08105500,pcVar5,pTVar3->x,pTVar3->y,pTVar3->z); - } - j = j + 1; - } while (j <= Monsterhomes); - } - // try { // try from 080b5971 to 080b5975 has its CatchHandler @ 080b5c40 - TReadScriptFile::~TReadScriptFile((TReadScriptFile *)local_4ffc,(int)pcVar5); - return; -} - - - -// WARNING: Removing unreachable block (ram,0x080b5f11) -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ProcessMonsterhomes(void) - -{ - bool bVar1; - int r; - TMonsterhome *pTVar2; - int iVar3; - int *piVar4; - ulong id; - TCreature *pTVar5; - uint uVar6; - TMonster *this; - int iVar7; - TCreature *cr; - uint uVar8; - TMonsterhome *MH; - int i; - int i_00; - char *Text; - int local_78; - int local_74; - int local_70; - int local_6c; - int x; - int y; - int z; - int local_5c [3]; - int MaxRadius; - undefined1 local_4c [4]; - TFindCreatures Search; - - i_00 = 1; - if (0 < Monsterhomes) { - do { - pTVar2 = vector<>::operator()(&Monsterhome,i_00); - if ((pTVar2->Timer != 0) && - (iVar3 = pTVar2->Timer + -1, pTVar2->Timer = iVar3, iVar3 < 1)) { - local_6c = pTVar2->x; - x = pTVar2->y; - y = pTVar2->z; - MaxRadius = 10; - piVar4 = &MaxRadius; - if (pTVar2->Radius < 10) { - piVar4 = &pTVar2->Radius; - } - local_5c[2] = *piVar4; - iVar3 = 1; - TFindCreatures::TFindCreatures - ((TFindCreatures *)local_4c,local_5c[2] + 9,local_5c[2] + 7,local_6c,x,1); -LAB_080b5d00: - while (id = TFindCreatures::getNext((TFindCreatures *)local_4c), id != 0) { - pTVar5 = GetCreature(id); - if (pTVar5 == (TCreature *)0x0) { - error("ProcessMonsterhomes: Kreatur existiert nicht.\n"); - break; - } - if (pTVar5->posz < 8) goto LAB_080b5d8f; - if ((y - pTVar5->posz) + 2U < 5) goto LAB_080b5d39; - } - if (pTVar2->ActMonsters == 0) { - z = 1; - piVar4 = &z; - if (pTVar2->Radius < 1) { - piVar4 = &pTVar2->Radius; - } - iVar7 = *piVar4; - } - else { - iVar7 = -local_5c[2]; - } - if ((-1 < local_5c[2]) && - (bVar1 = SearchSpawnField(&local_6c,&x,&y,iVar7,false), bVar1)) { - iVar7 = pTVar2->Race; - local_78 = local_6c; - local_74 = x; - local_70 = y; - if (iVar7 - 1U < 0x1ff) { - if (RaceData[iVar7].Name[0] == '\0') { - Text = &DAT_08104f00; - goto LAB_080b5e43; - } - SearchFreeField(&local_78,&local_74,&local_70,2,0,false); - this = (TMonster *)operator_new(0x32c); - iVar3 = i_00; - // try { // try from 080b5f02 to 080b5f06 has its CatchHandler @ 080b5f53 - TMonster::TMonster(this); - } - else { - Text = &DAT_08104f40; -LAB_080b5e43: - error(Text,iVar7); - } - pTVar2->ActMonsters = pTVar2->ActMonsters + 1; - if (0 < pTVar2->Timer) { - error(&DAT_08105580,pTVar2->Race,local_6c,x,y,iVar3); - goto LAB_080b5c95; - } - } - if (pTVar2->ActMonsters < pTVar2->MaxMonsters) { - StartMonsterhomeTimer(i_00); - } - } -LAB_080b5c95: - i_00 = i_00 + 1; - } while (i_00 <= Monsterhomes); - } - return; -LAB_080b5d8f: - if (y < 8) { -LAB_080b5d39: - uVar8 = pTVar5->posx - local_6c; - if (0x7fffffff < uVar8) { - uVar8 = -uVar8; - } - uVar6 = pTVar5->posy - x; - local_5c[1] = uVar8 - 9; - if (0x7fffffff < uVar6) { - uVar6 = -uVar6; - } - local_5c[0] = uVar6 - 7; - piVar4 = local_5c; - if ((int)(uVar6 - 7) <= (int)(uVar8 - 9)) { - piVar4 = local_5c + 1; - } - if (local_5c[2] <= *piVar4) { - piVar4 = local_5c + 2; - } - local_5c[2] = *piVar4; - } - goto LAB_080b5d00; -} - - - -void NotifyMonsterhomeOfDeath(int nr) - -{ - TMonsterhome *pTVar1; - int iVar2; - TMonsterhome *MH; - - if ((nr < 1) || (Monsterhomes < nr)) { - error(&DAT_081055e0,nr); - } - else { - pTVar1 = vector<>::operator()(&Monsterhome,nr); - if (pTVar1->ActMonsters < 1) { - error("NotifyMonsterhomeOfDeath: Monsterhome hat keine lebenden Kreaturen.\n"); - return; - } - iVar2 = pTVar1->ActMonsters + -1; - pTVar1->ActMonsters = iVar2; - if (iVar2 < pTVar1->MaxMonsters) { - if (pTVar1->Timer == 0) { - StartMonsterhomeTimer(nr); - return; - } - } - else { - error("NotifyMonsterhomeOfDeath: Monsterhome %d hatte zu viele Monster (%d statt %d).\n" - ,nr,pTVar1->ActMonsters + 1,pTVar1->MaxMonsters); - } - } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool MonsterhomeInRange(void) - -{ - TMonsterhome *pTVar1; - uint uVar2; - TMonsterhome *MH; - bool bVar3; - int in_stack_00000004; - int in_stack_00000008; - int in_stack_0000000c; - int in_stack_00000010; - - bVar3 = true; - if (in_stack_00000004 != 0) { - if ((in_stack_00000004 < 1) || (Monsterhomes < in_stack_00000004)) { - error(&DAT_081056e0); - bVar3 = false; - } - else { - pTVar1 = vector<>::operator()(&Monsterhome,in_stack_00000004); - uVar2 = in_stack_00000010 - pTVar1->z; - if (0x7fffffff < uVar2) { - uVar2 = -uVar2; - } - bVar3 = false; - if ((int)uVar2 < 3) { - uVar2 = in_stack_00000008 - pTVar1->x; - if (0x7fffffff < uVar2) { - uVar2 = -uVar2; - } - bVar3 = false; - if ((int)uVar2 <= pTVar1->Radius) { - uVar2 = in_stack_0000000c - pTVar1->y; - if (0x7fffffff < uVar2) { - uVar2 = -uVar2; - } - bVar3 = (int)uVar2 <= pTVar1->Radius; - } - } - } - } - return bVar3; -} - - - -// DWARF original prototype: void TNonplayer(TNonplayer * this) - -void __thiscall TNonplayer::TNonplayer(TNonplayer *this) - -{ - TCreature::TCreature(&this->super_TCreature); - (this->super_TCreature)._vptr_TCreature = (_func_int_varargs **)&PTR__TNonplayer_08127d28; - this->State = SLEEPING; - return; -} - - - -// DWARF original prototype: void TNonplayer(TNonplayer * this) - -void __thiscall TNonplayer::TNonplayer(TNonplayer *this) - -{ - TCreature::TCreature(&this->super_TCreature); - (this->super_TCreature)._vptr_TCreature = (_func_int_varargs **)&PTR__TNonplayer_08127d28; - this->State = SLEEPING; - return; -} - - - -// DWARF original prototype: void ~TNonplayer(TNonplayer * this, int __in_chrg) - -void __thiscall TNonplayer::~TNonplayer(TNonplayer *this,int __in_chrg) - -{ - TNonplayer **ppTVar1; - TNonplayer **ppTVar2; - int i; - int i_00; - bool bVar3; - int in_stack_ffffffe8; - - i_00 = 0; - bVar3 = 0 < FirstFreeNonplayer; - (this->super_TCreature)._vptr_TCreature = (_func_int_varargs **)&PTR__TNonplayer_08127d28; - if (bVar3) { - do { - in_stack_ffffffe8 = i_00; - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - if (*ppTVar1 == this) { - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - ppTVar2 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer + -1); - *ppTVar1 = *ppTVar2; - in_stack_ffffffe8 = FirstFreeNonplayer + -1; - ppTVar1 = vector<>::operator()(&NonplayerList,in_stack_ffffffe8); - FirstFreeNonplayer = FirstFreeNonplayer + -1; - *ppTVar1 = (TNonplayer *)0x0; - goto LAB_080b6169; - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeNonplayer); - } - error("TNonplayer::DelInList: Kreatur nicht gefunden.\n"); -LAB_080b6169: - TCreature::~TCreature(&this->super_TCreature,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TNonplayer(TNonplayer * this, int __in_chrg) - -void __thiscall TNonplayer::~TNonplayer(TNonplayer *this,int __in_chrg) - -{ - TNonplayer **ppTVar1; - TNonplayer **ppTVar2; - int i; - int i_00; - bool bVar3; - int in_stack_ffffffe8; - - i_00 = 0; - bVar3 = 0 < FirstFreeNonplayer; - (this->super_TCreature)._vptr_TCreature = (_func_int_varargs **)&PTR__TNonplayer_08127d28; - if (bVar3) { - do { - in_stack_ffffffe8 = i_00; - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - if (*ppTVar1 == this) { - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - ppTVar2 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer + -1); - *ppTVar1 = *ppTVar2; - in_stack_ffffffe8 = FirstFreeNonplayer + -1; - ppTVar1 = vector<>::operator()(&NonplayerList,in_stack_ffffffe8); - FirstFreeNonplayer = FirstFreeNonplayer + -1; - *ppTVar1 = (TNonplayer *)0x0; - goto LAB_080b6219; - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeNonplayer); - } - error("TNonplayer::DelInList: Kreatur nicht gefunden.\n"); -LAB_080b6219: - TCreature::~TCreature(&this->super_TCreature,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TNonplayer(TNonplayer * this, int __in_chrg) - -void __thiscall TNonplayer::~TNonplayer(TNonplayer *this,int __in_chrg) - -{ - TNonplayer **ppTVar1; - TNonplayer **ppTVar2; - int i; - int i_00; - bool bVar3; - int in_stack_ffffffe8; - - i_00 = 0; - bVar3 = 0 < FirstFreeNonplayer; - (this->super_TCreature)._vptr_TCreature = (_func_int_varargs **)&PTR__TNonplayer_08127d28; - if (bVar3) { - do { - in_stack_ffffffe8 = i_00; - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - if (*ppTVar1 == this) { - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - ppTVar2 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer + -1); - *ppTVar1 = *ppTVar2; - in_stack_ffffffe8 = FirstFreeNonplayer + -1; - ppTVar1 = vector<>::operator()(&NonplayerList,in_stack_ffffffe8); - FirstFreeNonplayer = FirstFreeNonplayer + -1; - *ppTVar1 = (TNonplayer *)0x0; - goto LAB_080b62c9; - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeNonplayer); - } - error("TNonplayer::DelInList: Kreatur nicht gefunden.\n"); -LAB_080b62c9: - TCreature::~TCreature(&this->super_TCreature,in_stack_ffffffe8); - operator_delete(this); - return; -} - - - -// DWARF original prototype: void SetInList(TNonplayer * this) - -void __thiscall TNonplayer::SetInList(TNonplayer *this) - -{ - TNonplayer **ppTVar1; - - TCreature::SetInCrList(&this->super_TCreature); - ppTVar1 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer); - *ppTVar1 = this; - FirstFreeNonplayer = FirstFreeNonplayer + 1; - return; -} - - - -// DWARF original prototype: void DelInList(TNonplayer * this) - -void __thiscall TNonplayer::DelInList(TNonplayer *this) - -{ - TNonplayer **ppTVar1; - TNonplayer **ppTVar2; - int i; - int i_00; - - i_00 = 0; - if (0 < FirstFreeNonplayer) { - do { - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - if (*ppTVar1 == this) { - ppTVar1 = vector<>::operator()(&NonplayerList,i_00); - ppTVar2 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer + -1); - *ppTVar1 = *ppTVar2; - ppTVar1 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer + -1); - *ppTVar1 = (TNonplayer *)0x0; - FirstFreeNonplayer = FirstFreeNonplayer + -1; - return; - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeNonplayer); - } - error("TNonplayer::DelInList: Kreatur nicht gefunden.\n"); - return; -} - - - -// DWARF original prototype: void TNPC(TNPC * this, char * FileName) - -void __thiscall TNPC::TNPC(TNPC *this,char *FileName) - -{ - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar1; - bool bVar2; - int GoStrength; - char *pcVar3; - TBehaviourDatabase *this_00; - undefined4 *puVar4; - TOutfit *this_01; - TNonplayer **ppTVar5; - int iVar6; - TSkillBase *this_02; - char *pcVar7; - char *pcVar8; - undefined1 uVar9; - int *__oflag; - int *piVar10; - char local_401c [4]; - char Ident [30]; - TReadScriptFile Script; - - // try { // try from 080b643b to 080b643f has its CatchHandler @ 080b6ae0 - TCreature::TCreature((TCreature *)this); - (this->super_TNonplayer).State = SLEEPING; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TNPC_08127ce8; - // try { // try from 080b6477 to 080b647b has its CatchHandler @ 080b6ad8 - vector<>::vector(&this->QueuedPlayers,0,9,10); - piVar10 = (int *)0xa; - // try { // try from 080b64a5 to 080b64a9 has its CatchHandler @ 080b6ad2 - vector<>::vector(&this->QueuedAddresses,0,9,10); - __oflag = (int *)FileName; - // try { // try from 080b64bd to 080b6560 has its CatchHandler @ 080b6acc - print(); - (this->super_TNonplayer).super_TCreature.Type = NPC; - (this->super_TNonplayer).super_TCreature.Sex = 1; - (this->super_TNonplayer).super_TCreature.Race = 0; - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID = 0; - (this->super_TNonplayer).super_TCreature.Outfit.field_1 = - (anon_union_4_2_730cd3ca_for_TOutfit_2)0x0; - (this->super_TNonplayer).super_TCreature.posz = 0xff; - this->Behaviour = (TBehaviourDatabase *)0x0; - this->Topic = 0; - this->Amount = 1; - this->Price = 0; - this->TypeID = 0; - this->Data = 0; - (this->super_TNonplayer).super_TCreature.Name[0] = '\0'; - this->LastTalk = 0; - this->QueueLength = 0; - (this->super_TNonplayer).super_TCreature.Direction = 2; - TReadScriptFile::TReadScriptFile((TReadScriptFile *)(Ident + 0x1c)); - // try { // try from 080b656e to 080b66f8 has its CatchHandler @ 080b6ac6 - TReadScriptFile::open((TReadScriptFile *)(Ident + 0x1c),FileName,(int)__oflag); - while( true ) { - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffc004 == 0) break; - uVar9 = stack0xffffc004 == 1; - if (!(bool)uVar9) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"identifier expected"); - } - pcVar3 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - strcpy(local_401c,pcVar3); - FileName = (char *)0x3d; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "name"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); - pcVar3 = (this->super_TNonplayer).super_TCreature.Name; - uVar9 = pcVar3 == (char *)0x0; - strcpy(pcVar3,FileName); - } - iVar6 = 4; - pcVar3 = local_401c; - pcVar7 = "sex"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - pcVar3 = TReadScriptFile::readIdentifier((TReadScriptFile *)(Ident + 0x1c)); - (this->super_TNonplayer).super_TCreature.Sex = 0xff; - iVar6 = 5; - pcVar7 = pcVar3; - pcVar8 = "male"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar7 == *pcVar8; - pcVar7 = pcVar7 + 1; - pcVar8 = pcVar8 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - (this->super_TNonplayer).super_TCreature.Sex = 1; - } - iVar6 = 7; - pcVar7 = "female"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - (this->super_TNonplayer).super_TCreature.Sex = 2; - } - uVar9 = (this->super_TNonplayer).super_TCreature.Sex == 0xff; - if ((bool)uVar9) { - FileName = "unknown constant"; - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"unknown constant"); - } - } - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "race"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = (char *)TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - this_02 = &(this->super_TNonplayer).super_TCreature.super_TSkillBase; - uVar9 = this_02 == (TSkillBase *)0x0; - (this->super_TNonplayer).super_TCreature.Race = (int)FileName; - TSkillBase::SetSkills(this_02,(int)FileName); - } - iVar6 = 7; - pcVar3 = local_401c; - pcVar7 = "outfit"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = Ident + 0x1c; - this_01 = &(this->super_TNonplayer).super_TCreature.Outfit; - uVar9 = this_01 == (TOutfit *)0x0; - TOutfit::load(this_01,(TReadScriptFile *)FileName); - } - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "home"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - TReadScriptFile::readCoordinate((TReadScriptFile *)(Ident + 0x1c)); - piVar10 = &(this->super_TNonplayer).super_TCreature.startz; - __oflag = &(this->super_TNonplayer).super_TCreature.starty; - FileName = (char *)&(this->super_TNonplayer).super_TCreature.startx; - uVar9 = (int *)FileName == (int *)0x0; - TReadScriptFile::getCoordinate((TReadScriptFile *)(Ident + 0x1c)); - } - iVar6 = 7; - pcVar3 = local_401c; - pcVar7 = "radius"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - iVar6 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - (this->super_TNonplayer).super_TCreature.Radius = iVar6; - } - iVar6 = 0xb; - pcVar3 = local_401c; - pcVar7 = "gostrength"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - uVar9 = (this->super_TNonplayer).super_TCreature.Race == 0; - if ((bool)uVar9) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4,FileName,__oflag,piVar10); - *puVar4 = "gostrength before race in npc-script-file"; - goto LAB_080b6737; - } - iVar6 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - (this->super_TNonplayer).super_TCreature.super_TSkillBase.Skills[4]->Act = iVar6; - (this->super_TNonplayer).super_TCreature.super_TSkillBase.Skills[4]->Max = iVar6; - } - iVar6 = 10; - pcVar3 = local_401c; - pcVar7 = "behaviour"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - if (this->Behaviour != (TBehaviourDatabase *)0x0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4,FileName,__oflag,piVar10); - *puVar4 = "behaviour database specified twice for NPC"; - goto LAB_080b6737; - } - this_00 = (TBehaviourDatabase *)operator_new(0x8c); - FileName = Ident + 0x1c; - // try { // try from 080b670c to 080b6710 has its CatchHandler @ 080b6a60 - TBehaviourDatabase::TBehaviourDatabase(this_00,(TReadScriptFile *)FileName); - this->Behaviour = this_00; - } - } - TReadScriptFile::close((TReadScriptFile *)(Ident + 0x1c),(int)FileName); - if ((this->super_TNonplayer).super_TCreature.Name[0] == '\0') { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no name specified for NPC"; -LAB_080b6737: - // WARNING: Subroutine does not return - // try { // try from 080b674a to 080b696e has its CatchHandler @ 080b6ac6 - __cxa_throw(puVar4,char_const*::typeinfo,0); - } - iVar6 = (this->super_TNonplayer).super_TCreature.posz; - if (iVar6 == 0xff) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no startpoint specified for NPC"; - goto LAB_080b6737; - } - if (this->Behaviour == (TBehaviourDatabase *)0x0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no behaviour database specified for NPC"; - goto LAB_080b6737; - } - bVar2 = IsOnMap((this->super_TNonplayer).super_TCreature.posx, - (this->super_TNonplayer).super_TCreature.posy,iVar6); - if (bVar2) { - aVar1 = (this->super_TNonplayer).super_TCreature.Outfit.field_1; - (this->super_TNonplayer).super_TCreature.OrgOutfit.OutfitID = - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID; - (this->super_TNonplayer).super_TCreature.OrgOutfit.field_1 = aVar1; - // try { // try from 080b69b0 to 080b6a0c has its CatchHandler @ 080b6ac6 - TCreature::SetID((TCreature *)this,0); - TCreature::SetInCrList((TCreature *)this); - pcVar3 = (char *)FirstFreeNonplayer; - ppTVar5 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer); - FirstFreeNonplayer = FirstFreeNonplayer + 1; - *ppTVar5 = &this->super_TNonplayer; - bVar2 = TCreature::SetOnMap((TCreature *)this); - if (bVar2) { - TCreature::ToDoYield((TCreature *)this); - goto LAB_080b6978; - } - pcVar3 = "WARNUNG: Kann NPC \'%s\' nicht setzen.\n"; - } - else { - pcVar3 = &DAT_08105800; - } - print(); -LAB_080b6978: - // try { // try from 080b6978 to 080b697c has its CatchHandler @ 080b6acc - TReadScriptFile::~TReadScriptFile((TReadScriptFile *)(Ident + 0x1c),(int)pcVar3); - return; -} - - - -// DWARF original prototype: void TNPC(TNPC * this, char * FileName) - -void __thiscall TNPC::TNPC(TNPC *this,char *FileName) - -{ - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar1; - bool bVar2; - int GoStrength; - char *pcVar3; - TBehaviourDatabase *this_00; - undefined4 *puVar4; - TOutfit *this_01; - TNonplayer **ppTVar5; - int iVar6; - TSkillBase *this_02; - char *pcVar7; - char *pcVar8; - undefined1 uVar9; - int *__oflag; - int *piVar10; - char local_401c [4]; - char Ident [30]; - TReadScriptFile Script; - - // try { // try from 080b6b0b to 080b6b0f has its CatchHandler @ 080b71b0 - TCreature::TCreature((TCreature *)this); - (this->super_TNonplayer).State = SLEEPING; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TNPC_08127ce8; - // try { // try from 080b6b47 to 080b6b4b has its CatchHandler @ 080b71a8 - vector<>::vector(&this->QueuedPlayers,0,9,10); - piVar10 = (int *)0xa; - // try { // try from 080b6b75 to 080b6b79 has its CatchHandler @ 080b71a2 - vector<>::vector(&this->QueuedAddresses,0,9,10); - __oflag = (int *)FileName; - // try { // try from 080b6b8d to 080b6c30 has its CatchHandler @ 080b719c - print(); - (this->super_TNonplayer).super_TCreature.Type = NPC; - (this->super_TNonplayer).super_TCreature.Sex = 1; - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID = 0; - (this->super_TNonplayer).super_TCreature.Race = 0; - (this->super_TNonplayer).super_TCreature.Outfit.field_1 = - (anon_union_4_2_730cd3ca_for_TOutfit_2)0x0; - (this->super_TNonplayer).super_TCreature.posz = 0xff; - this->Topic = 0; - this->Behaviour = (TBehaviourDatabase *)0x0; - this->Amount = 1; - this->Price = 0; - this->TypeID = 0; - this->Data = 0; - (this->super_TNonplayer).super_TCreature.Name[0] = '\0'; - this->LastTalk = 0; - this->QueueLength = 0; - (this->super_TNonplayer).super_TCreature.Direction = 2; - TReadScriptFile::TReadScriptFile((TReadScriptFile *)(Ident + 0x1c)); - // try { // try from 080b6c3e to 080b6dc8 has its CatchHandler @ 080b7196 - TReadScriptFile::open((TReadScriptFile *)(Ident + 0x1c),FileName,(int)__oflag); - while( true ) { - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffc004 == 0) break; - uVar9 = stack0xffffc004 == 1; - if (!(bool)uVar9) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"identifier expected"); - } - pcVar3 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - strcpy(local_401c,pcVar3); - FileName = (char *)0x3d; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "name"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); - pcVar3 = (this->super_TNonplayer).super_TCreature.Name; - uVar9 = pcVar3 == (char *)0x0; - strcpy(pcVar3,FileName); - } - iVar6 = 4; - pcVar3 = local_401c; - pcVar7 = "sex"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - pcVar3 = TReadScriptFile::readIdentifier((TReadScriptFile *)(Ident + 0x1c)); - iVar6 = 5; - (this->super_TNonplayer).super_TCreature.Sex = 0xff; - pcVar7 = pcVar3; - pcVar8 = "male"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar7 == *pcVar8; - pcVar7 = pcVar7 + 1; - pcVar8 = pcVar8 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - (this->super_TNonplayer).super_TCreature.Sex = 1; - } - iVar6 = 7; - pcVar7 = "female"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - (this->super_TNonplayer).super_TCreature.Sex = 2; - } - uVar9 = (this->super_TNonplayer).super_TCreature.Sex == 0xff; - if ((bool)uVar9) { - FileName = "unknown constant"; - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"unknown constant"); - } - } - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "race"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = (char *)TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - this_02 = &(this->super_TNonplayer).super_TCreature.super_TSkillBase; - uVar9 = this_02 == (TSkillBase *)0x0; - (this->super_TNonplayer).super_TCreature.Race = (int)FileName; - TSkillBase::SetSkills(this_02,(int)FileName); - } - iVar6 = 7; - pcVar3 = local_401c; - pcVar7 = "outfit"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - FileName = Ident + 0x1c; - this_01 = &(this->super_TNonplayer).super_TCreature.Outfit; - uVar9 = this_01 == (TOutfit *)0x0; - TOutfit::load(this_01,(TReadScriptFile *)FileName); - } - iVar6 = 5; - pcVar3 = local_401c; - pcVar7 = "home"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - TReadScriptFile::readCoordinate((TReadScriptFile *)(Ident + 0x1c)); - piVar10 = &(this->super_TNonplayer).super_TCreature.startz; - __oflag = &(this->super_TNonplayer).super_TCreature.starty; - FileName = (char *)&(this->super_TNonplayer).super_TCreature.startx; - uVar9 = (int *)FileName == (int *)0x0; - TReadScriptFile::getCoordinate((TReadScriptFile *)(Ident + 0x1c)); - } - iVar6 = 7; - pcVar3 = local_401c; - pcVar7 = "radius"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - iVar6 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - (this->super_TNonplayer).super_TCreature.Radius = iVar6; - } - iVar6 = 0xb; - pcVar3 = local_401c; - pcVar7 = "gostrength"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - uVar9 = (this->super_TNonplayer).super_TCreature.Race == 0; - if ((bool)uVar9) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4,FileName,__oflag,piVar10); - *puVar4 = "gostrength before race in npc-script-file"; - goto LAB_080b6e07; - } - iVar6 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - (this->super_TNonplayer).super_TCreature.super_TSkillBase.Skills[4]->Act = iVar6; - (this->super_TNonplayer).super_TCreature.super_TSkillBase.Skills[4]->Max = iVar6; - } - iVar6 = 10; - pcVar3 = local_401c; - pcVar7 = "behaviour"; - do { - if (iVar6 == 0) break; - iVar6 = iVar6 + -1; - uVar9 = *pcVar3 == *pcVar7; - pcVar3 = pcVar3 + 1; - pcVar7 = pcVar7 + 1; - } while ((bool)uVar9); - if ((bool)uVar9) { - if (this->Behaviour != (TBehaviourDatabase *)0x0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4,FileName,__oflag,piVar10); - *puVar4 = "behaviour database specified twice for NPC"; - goto LAB_080b6e07; - } - this_00 = (TBehaviourDatabase *)operator_new(0x8c); - FileName = Ident + 0x1c; - // try { // try from 080b6ddc to 080b6de0 has its CatchHandler @ 080b7130 - TBehaviourDatabase::TBehaviourDatabase(this_00,(TReadScriptFile *)FileName); - this->Behaviour = this_00; - } - } - TReadScriptFile::close((TReadScriptFile *)(Ident + 0x1c),(int)FileName); - if ((this->super_TNonplayer).super_TCreature.Name[0] == '\0') { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no name specified for NPC"; -LAB_080b6e07: - // WARNING: Subroutine does not return - // try { // try from 080b6e1a to 080b703e has its CatchHandler @ 080b7196 - __cxa_throw(puVar4,char_const*::typeinfo,0); - } - iVar6 = (this->super_TNonplayer).super_TCreature.posz; - if (iVar6 == 0xff) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no startpoint specified for NPC"; - goto LAB_080b6e07; - } - if (this->Behaviour == (TBehaviourDatabase *)0x0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "no behaviour database specified for NPC"; - goto LAB_080b6e07; - } - bVar2 = IsOnMap((this->super_TNonplayer).super_TCreature.posx, - (this->super_TNonplayer).super_TCreature.posy,iVar6); - if (bVar2) { - aVar1 = (this->super_TNonplayer).super_TCreature.Outfit.field_1; - (this->super_TNonplayer).super_TCreature.OrgOutfit.OutfitID = - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID; - (this->super_TNonplayer).super_TCreature.OrgOutfit.field_1 = aVar1; - // try { // try from 080b7080 to 080b70dc has its CatchHandler @ 080b7196 - TCreature::SetID((TCreature *)this,0); - TCreature::SetInCrList((TCreature *)this); - pcVar3 = (char *)FirstFreeNonplayer; - ppTVar5 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer); - FirstFreeNonplayer = FirstFreeNonplayer + 1; - *ppTVar5 = &this->super_TNonplayer; - bVar2 = TCreature::SetOnMap((TCreature *)this); - if (bVar2) { - TCreature::ToDoYield((TCreature *)this); - goto LAB_080b7048; - } - pcVar3 = "WARNUNG: Kann NPC \'%s\' nicht setzen.\n"; - } - else { - pcVar3 = &DAT_08105800; - } - print(); -LAB_080b7048: - // try { // try from 080b7048 to 080b704c has its CatchHandler @ 080b719c - TReadScriptFile::~TReadScriptFile((TReadScriptFile *)(Ident + 0x1c),(int)pcVar3); - return; -} - - - -// DWARF original prototype: void ~TNPC(TNPC * this, int __in_chrg) - -void __thiscall TNPC::~TNPC(TNPC *this,int __in_chrg) - -{ - TBehaviourDatabase *pTVar1; - TBehaviour *pTVar2; - ulong *puVar3; - TBehaviour *pTVar4; - int in_stack_ffffffe8; - - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TNPC_08127ce8; - pTVar1 = this->Behaviour; - if (pTVar1 != (TBehaviourDatabase *)0x0) { - pTVar4 = (pTVar1->Behaviour).entry; - if (pTVar4 != (TBehaviour *)0x0) { - pTVar4 = pTVar4 + pTVar4[-1].Actions; - while (pTVar2 = (pTVar1->Behaviour).entry, pTVar2 != pTVar4) { - pTVar4 = pTVar4 + -1; - TBehaviour::~TBehaviour(pTVar4,in_stack_ffffffe8); - } - operator_delete__(&pTVar2[-1].Actions); - } - TBehaviour::~TBehaviour(&(pTVar1->Behaviour).init,in_stack_ffffffe8); - operator_delete(pTVar1); - } - puVar3 = (this->QueuedAddresses).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - puVar3 = (this->QueuedPlayers).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TNPC(TNPC * this, int __in_chrg) - -void __thiscall TNPC::~TNPC(TNPC *this,int __in_chrg) - -{ - TBehaviourDatabase *pTVar1; - TBehaviour *pTVar2; - ulong *puVar3; - TBehaviour *pTVar4; - int in_stack_ffffffe8; - - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TNPC_08127ce8; - pTVar1 = this->Behaviour; - if (pTVar1 != (TBehaviourDatabase *)0x0) { - pTVar4 = (pTVar1->Behaviour).entry; - if (pTVar4 != (TBehaviour *)0x0) { - pTVar4 = pTVar4 + pTVar4[-1].Actions; - while (pTVar2 = (pTVar1->Behaviour).entry, pTVar2 != pTVar4) { - pTVar4 = pTVar4 + -1; - TBehaviour::~TBehaviour(pTVar4,in_stack_ffffffe8); - } - operator_delete__(&pTVar2[-1].Actions); - } - TBehaviour::~TBehaviour(&(pTVar1->Behaviour).init,in_stack_ffffffe8); - operator_delete(pTVar1); - } - puVar3 = (this->QueuedAddresses).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - puVar3 = (this->QueuedPlayers).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TNPC(TNPC * this, int __in_chrg) - -void __thiscall TNPC::~TNPC(TNPC *this,int __in_chrg) - -{ - TBehaviourDatabase *pTVar1; - TBehaviour *pTVar2; - ulong *puVar3; - TBehaviour *pTVar4; - int in_stack_ffffffe8; - - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TNPC_08127ce8; - pTVar1 = this->Behaviour; - if (pTVar1 != (TBehaviourDatabase *)0x0) { - pTVar4 = (pTVar1->Behaviour).entry; - if (pTVar4 != (TBehaviour *)0x0) { - pTVar4 = pTVar4 + pTVar4[-1].Actions; - while (pTVar2 = (pTVar1->Behaviour).entry, pTVar2 != pTVar4) { - pTVar4 = pTVar4 + -1; - TBehaviour::~TBehaviour(pTVar4,in_stack_ffffffe8); - } - operator_delete__(&pTVar2[-1].Actions); - } - TBehaviour::~TBehaviour(&(pTVar1->Behaviour).init,in_stack_ffffffe8); - operator_delete(pTVar1); - } - puVar3 = (this->QueuedAddresses).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - puVar3 = (this->QueuedPlayers).entry; - if (puVar3 != (ulong *)0x0) { - operator_delete__(puVar3); - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - operator_delete(this); - return; -} - - - -// DWARF original prototype: void TalkStimulus(TNPC * this, ulong Speaker, char * Text) - -void __thiscall TNPC::TalkStimulus(TNPC *this,ulong Speaker,char *Text) - -{ - ulong uVar1; - uchar Dir; - TCreature *Opp; - TCreature *pTVar2; - int iVar3; - int dy; - int iVar4; - int iVar5; - int iVar6; - - if (Speaker != (this->super_TNonplayer).super_TCreature.ID) { - if (Text == (char *)0x0) { - this = (TNPC *)&DAT_08105920; -LAB_080b757a: - error((char *)this); - return; - } - if (((this->super_TNonplayer).State == TALKING) || (this->QueueLength != 0)) { - uVar1 = this->Interlocutor; - if (Speaker == uVar1) { - this->LastTalk = RoundNr; - TBehaviourDatabase::react(this->Behaviour,this,Text,DEFAULT); - } - else { - this->Interlocutor = Speaker; - TBehaviourDatabase::react(this->Behaviour,this,Text,BUSY); - this->Interlocutor = uVar1; - } - } - else { - TCreature::ToDoClear((TCreature *)this); - (this->super_TNonplayer).State = TALKING; - uVar1 = RoundNr; - this->Interlocutor = Speaker; - this->LastTalk = uVar1; - TBehaviourDatabase::react(this->Behaviour,this,Text,ADDRESS); - if ((this->super_TNonplayer).State == TALKING) { - pTVar2 = GetCreature(this->Interlocutor); - if (pTVar2 != (TCreature *)0x0) { - iVar5 = pTVar2->posx - (this->super_TNonplayer).super_TCreature.posx; - iVar4 = pTVar2->posy - (this->super_TNonplayer).super_TCreature.posy; - iVar3 = -iVar5; - if (-1 < iVar5) { - iVar3 = iVar5; - } - iVar6 = -iVar4; - if (-1 < iVar4) { - iVar6 = iVar4; - } - if (iVar3 < iVar6) { - Dir = ((char)~(byte)((uint)iVar4 >> 0x18) >> 7) * -2; - } - else { - Dir = (char)(iVar5 >> 0x1f) * -2 + '\x01'; - } - TCreature::Rotate((TCreature *)this,Dir); - return; - } - this = (TNPC *)&DAT_081058e0; - goto LAB_080b757a; - } - } - } - return; -} - - - -// DWARF original prototype: void IdleStimulus(TNPC * this) - -void __thiscall TNPC::IdleStimulus(TNPC *this) - -{ - vector<> *this_00; - vector<> *this_01; - uchar Dir; - int dir; - ulong *puVar1; - TCreature *pTVar2; - ulong uVar3; - int iVar4; - ulong *puVar5; - char *Text; - STATE SVar6; - int dy; - int destX; - int iVar7; - int destY; - int iVar8; - int Try; - int iVar9; - undefined1 local_4c [4]; - TFindCreatures Search; - - SVar6 = (this->super_TNonplayer).State; - if (SVar6 == TALKING) { - if (RoundNr <= this->LastTalk + 0x1e) { - TCreature::ToDoWait((TCreature *)this,2000); -LAB_080b7808: - TCreature::ToDoStart((TCreature *)this); - return; - } - TBehaviourDatabase::react(this->Behaviour,this,"",VANISH); - (this->super_TNonplayer).State = IDLE; - SVar6 = IDLE; - } - if (SVar6 == IDLE) { - if (0 < this->QueueLength) { - this_00 = &this->QueuedPlayers; - this_01 = &this->QueuedAddresses; - do { - (this->super_TNonplayer).State = TALKING; - TCreature::ToDoClear((TCreature *)this); - puVar1 = vector<>::operator()(this_00,0); - uVar3 = *puVar1; - this->Interlocutor = uVar3; - pTVar2 = GetCreature(uVar3); - if (pTVar2 == (TCreature *)0x0) { - error(&DAT_08105960); - (this->super_TNonplayer).State = IDLE; - } - else { - puVar1 = vector<>::operator()(this_01,0); - Text = GetDynamicString(*puVar1); - TBehaviourDatabase::react(this->Behaviour,this,Text,ADDRESSQUEUE); - } - puVar1 = vector<>::operator()(this_01,0); - DeleteDynamicString(*puVar1); - iVar9 = this->QueueLength; - iVar7 = 1; - if (1 < iVar9) { - do { - puVar1 = vector<>::operator()(this_00,iVar7 + -1); - puVar5 = vector<>::operator()(this_00,iVar7); - *puVar1 = *puVar5; - puVar1 = vector<>::operator()(this_01,iVar7 + -1); - iVar8 = iVar7 + 1; - puVar5 = vector<>::operator()(this_01,iVar7); - *puVar1 = *puVar5; - iVar9 = this->QueueLength; - iVar7 = iVar8; - } while (iVar8 < iVar9); - } - SVar6 = (this->super_TNonplayer).State; - this->QueueLength = iVar9 + -1; - if (SVar6 == TALKING) { - pTVar2 = GetCreature(this->Interlocutor); - if (pTVar2 == (TCreature *)0x0) { - error(&DAT_081058e0); - } - else { - iVar8 = pTVar2->posx - (this->super_TNonplayer).super_TCreature.posx; - iVar7 = pTVar2->posy - (this->super_TNonplayer).super_TCreature.posy; - iVar9 = -iVar8; - if (-1 < iVar8) { - iVar9 = iVar8; - } - iVar4 = -iVar7; - if (-1 < iVar7) { - iVar4 = iVar7; - } - if (iVar9 < iVar4) { - Dir = ((char)~(byte)((uint)iVar7 >> 0x18) >> 7) * -2; - } - else { - Dir = (char)(iVar8 >> 0x1f) * -2 + '\x01'; - } - TCreature::Rotate((TCreature *)this,Dir); - } - this->LastTalk = RoundNr; - return; - } - } while (0 < iVar9 + -1); - } - if ((this->super_TNonplayer).super_TCreature.LockToDo == false) { - TFindCreatures::TFindCreatures - ((TFindCreatures *)local_4c,10,10,(this->super_TNonplayer).super_TCreature.ID, - 1); - iVar9 = 0; - uVar3 = TFindCreatures::getNext((TFindCreatures *)local_4c); - if (uVar3 == 0) { - (this->super_TNonplayer).State = SLEEPING; - } - else { - do { - iVar9 = iVar9 + 1; - iVar7 = (this->super_TNonplayer).super_TCreature.posx; - iVar8 = (this->super_TNonplayer).super_TCreature.posy; - if (10 < iVar9) { - TCreature::ToDoWait((TCreature *)this,2000); - goto LAB_080b7808; - } - iVar4 = rand(); - iVar4 = iVar4 % 4; - if (iVar4 == 1) { - iVar7 = iVar7 + 1; - } - else if (iVar4 < 2) { - if (iVar4 == 0) { - iVar7 = iVar7 + -1; - } - } - else if (iVar4 == 2) { - iVar8 = iVar8 + -1; - } - else if (iVar4 == 3) { - iVar8 = iVar8 + 1; - } - iVar4 = (*(this->super_TNonplayer).super_TCreature._vptr_TCreature[3]) - (this,iVar7,iVar8, - (this->super_TNonplayer).super_TCreature.posz,1,0); - } while ((char)iVar4 == '\0'); - // try { // try from 080b77aa to 080b77cc has its CatchHandler @ 080b79ac - TCreature::ToDoGo((TCreature *)this,iVar7,iVar8, - (this->super_TNonplayer).super_TCreature.posz,true,0x7fffffff); - TCreature::ToDoWait((TCreature *)this,2000); - TCreature::ToDoStart((TCreature *)this); - } - } - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: this_local -// DWARF original prototype: void CreatureMoveStimulus(TNPC * this, ulong CreatureID, int Type) - -void __thiscall TNPC::CreatureMoveStimulus(TNPC *this,ulong CreatureID,int Type) - -{ - uchar Dir; - TCreature *Opp; - vector<> *this_00; - ulong *puVar1; - TCreature *pTVar2; - uint uVar3; - ulong uVar4; - TCreature *pTVar5; - int iVar6; - vector<> *this_01; - ulong *puVar7; - int dy; - int iVar8; - int dx; - int iVar9; - TCreature *cr; - int j; - int iVar10; - int local_20; - int i; - int Type_local; - ulong CreatureID_local; - TNPC *this_local; - - if ((0 < this->QueueLength) && (local_20 = 0, 0 < this->QueueLength)) { - this_00 = &this->QueuedPlayers; - do { - puVar1 = vector<>::operator()(this_00,local_20); - if ((CreatureID == *puVar1) || - (CreatureID == (this->super_TNonplayer).super_TCreature.ID)) { - puVar1 = vector<>::operator()(this_00,local_20); - pTVar2 = GetCreature(*puVar1); - if (Type != 0) { - uVar3 = pTVar2->posx - (this->super_TNonplayer).super_TCreature.posx; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; - } - if ((int)uVar3 < 5) { - uVar3 = pTVar2->posy - (this->super_TNonplayer).super_TCreature.posy; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; - } - if (((int)uVar3 < 4) && - (pTVar2->posz == (this->super_TNonplayer).super_TCreature.posz)) - goto LAB_080b7a5c; - } - } - this_01 = &this->QueuedAddresses; - puVar1 = vector<>::operator()(this_01,local_20); - DeleteDynamicString(*puVar1); - iVar6 = this->QueueLength; - iVar8 = local_20 + 1; - if (local_20 + 1 < iVar6) { - do { - puVar1 = vector<>::operator()(this_00,iVar8 + -1); - puVar7 = vector<>::operator()(this_00,iVar8); - *puVar1 = *puVar7; - puVar1 = vector<>::operator()(this_01,iVar8 + -1); - iVar9 = iVar8 + 1; - puVar7 = vector<>::operator()(this_01,iVar8); - *puVar1 = *puVar7; - iVar6 = this->QueueLength; - iVar8 = iVar9; - } while (iVar9 < iVar6); - } - this->QueueLength = iVar6 + -1; - local_20 = local_20 + -1; - } -LAB_080b7a5c: - local_20 = local_20 + 1; - } while (local_20 < this->QueueLength); - } - if ((this->super_TNonplayer).State - TALKING < 2) { - if ((CreatureID == this->Interlocutor) || - (CreatureID == (this->super_TNonplayer).super_TCreature.ID)) { - pTVar2 = GetCreature(this->Interlocutor); - if (pTVar2 == (TCreature *)0x0) { - error(&DAT_081059e0); - (this->super_TNonplayer).State = IDLE; - goto LAB_080b7ac2; - } - if (Type != 0) { - pTVar5 = GetCreature(this->Interlocutor); - if (pTVar5 == (TCreature *)0x0) { - error(&DAT_081058e0); - } - else { - iVar9 = pTVar5->posx - (this->super_TNonplayer).super_TCreature.posx; - iVar8 = pTVar5->posy - (this->super_TNonplayer).super_TCreature.posy; - iVar6 = -iVar9; - if (-1 < iVar9) { - iVar6 = iVar9; - } - iVar10 = -iVar8; - if (-1 < iVar8) { - iVar10 = iVar8; - } - if (iVar6 < iVar10) { - Dir = ((char)~(byte)((uint)iVar8 >> 0x18) >> 7) * -2; - } - else { - Dir = (char)(iVar9 >> 0x1f) * -2 + '\x01'; - } - TCreature::Rotate((TCreature *)this,Dir); - } - } - if ((this->super_TNonplayer).State != LEAVING) { - if (Type != 0) { - uVar3 = pTVar2->posx - (this->super_TNonplayer).super_TCreature.posx; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; - } - if ((int)uVar3 < 5) { - uVar3 = pTVar2->posy - (this->super_TNonplayer).super_TCreature.posy; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; - } - if (((int)uVar3 < 4) && - (pTVar2->posz == (this->super_TNonplayer).super_TCreature.posz)) - goto LAB_080b7b9c; - } - } - TBehaviourDatabase::react(this->Behaviour,this,"",VANISH); - (this->super_TNonplayer).State = IDLE; - TCreature::ToDoYield((TCreature *)this); - } - uVar4 = (this->super_TNonplayer).super_TCreature.ID; - goto LAB_080b7b8e; - } - } - else { -LAB_080b7b9c: - uVar4 = (this->super_TNonplayer).super_TCreature.ID; -LAB_080b7b8e: - if (CreatureID == uVar4) { - return; - } - } - if (((this->super_TNonplayer).State != SLEEPING) || (Type == 0)) { - return; - } - (this->super_TNonplayer).State = IDLE; -LAB_080b7ac2: - TCreature::ToDoYield((TCreature *)this); - return; -} - - - -// DWARF original prototype: void DamageStimulus(TNPC * this, ulong param_1, int param_2, int -// param_3) - -void __thiscall TNPC::DamageStimulus(TNPC *this,ulong param_1,int param_2,int param_3) - -{ - return; -} - - - -// DWARF original prototype: bool MovePossible(TNPC * this, int x, int y, int z, bool param_4, bool -// param_5) - -bool __thiscall TNPC::MovePossible(TNPC *this,int x,int y,int z,bool param_4,bool param_5) - -{ - int iVar1; - bool bVar2; - bool bVar3; - uint uVar4; - - bVar3 = false; - // try { // try from 080b7dbd to 080b7e8a has its CatchHandler @ 080b7ea0 - bVar2 = CoordinateFlag(); - if (bVar2) { - bVar3 = CoordinateFlag(); - bVar3 = !bVar3; - } - if ((bVar3) && (bVar3 = CoordinateFlag(), !bVar3)) { - uVar4 = x - (this->super_TNonplayer).super_TCreature.startx; - if (0x7fffffff < uVar4) { - uVar4 = -uVar4; - } - iVar1 = (this->super_TNonplayer).super_TCreature.Radius; - if ((int)uVar4 <= iVar1) { - uVar4 = y - (this->super_TNonplayer).super_TCreature.starty; - if (0x7fffffff < uVar4) { - uVar4 = -uVar4; - } - if (((int)uVar4 <= iVar1) && (z == (this->super_TNonplayer).super_TCreature.startz)) { - bVar3 = IsHouse(x,y,z); - return !bVar3; - } - } - } - return false; -} - - - -// DWARF original prototype: void GiveTo(TNPC * this, ObjectType * Type, int Amount) - -void __thiscall TNPC::GiveTo(TNPC *this,ObjectType *Type,int Amount) - -{ - bool bVar1; - char *pcVar2; - RESULT r; - int i; - int *piVar3; - int iVar4; - int local_44 [2]; - ObjectType local_3c [4]; - ObjectType local_2c [7]; - - if (Amount != 0) { - bVar1 = false; - ObjectType::setTypeID(local_2c,0); - if ((Type->TypeID == local_2c[0].TypeID) || - (pcVar2 = ObjectType::getName(Type), pcVar2 == (char *)0x0)) { - bVar1 = true; - } - if (bVar1) { - error("TNPC::GiveTo: %s will Objekte vom Typ %d erschaffen.\n", - (this->super_TNonplayer).super_TCreature.Name,Type->TypeID); - } - else { - pcVar2 = ObjectType::getName(Type); - Log("npc","%s -> %ld: %d %s\n",(this->super_TNonplayer).super_TCreature.Name, - this->Interlocutor,Amount,pcVar2); - // try { // try from 080b7f85 to 080b8057 has its CatchHandler @ 080b8083 - bVar1 = ObjectType::getFlag(Type,CUMULATIVE); - if (bVar1) { - for (; 0 < Amount; Amount = Amount - *piVar3) { - local_44[1] = 100; - ObjectType::setTypeID(local_3c,Type->TypeID); - CreateAtCreature((ulong)local_2c,(ObjectType *)this->Interlocutor, - (ulong)local_3c); - local_44[0] = 100; - piVar3 = local_44; - if (Amount < 0x65) { - piVar3 = &Amount; - } - } - } - else { - iVar4 = 0; - if (0 < Amount) { - do { - ObjectType::setTypeID(local_2c,Type->TypeID); - CreateAtCreature((ulong)local_3c,(ObjectType *)this->Interlocutor, - (ulong)local_2c); - iVar4 = iVar4 + 1; - } while (iVar4 < Amount); - } - } - } - } - return; -} - - - -// DWARF original prototype: void GetFrom(TNPC * this, ObjectType * Type, int Amount) - -void __thiscall TNPC::GetFrom(TNPC *this,ObjectType *Type,int Amount) - -{ - char *pcVar1; - RESULT r; - ObjectType local_2c [7]; - - if (Amount != 0) { - pcVar1 = ObjectType::getName(Type); - Log("npc","%s <- %ld: %d %s\n",(this->super_TNonplayer).super_TCreature.Name, - this->Interlocutor,Amount,pcVar1); - // try { // try from 080b814f to 080b8176 has its CatchHandler @ 080b8180 - ObjectType::setTypeID(local_2c,Type->TypeID); - DeleteAtCreature(this->Interlocutor,local_2c,Amount,this->Data); - } - return; -} - - - -// DWARF original prototype: void GiveMoney(TNPC * this, int Amount) - -void __thiscall TNPC::GiveMoney(TNPC *this,int Amount) - -{ - int Crystal; - int Platinum; - - GetSpecialObject((SPECIALMEANING)&Platinum); - GiveTo(this,(ObjectType *)&Platinum,Amount / 10000); - GetSpecialObject((SPECIALMEANING)&Platinum); - GiveTo(this,(ObjectType *)&Platinum,(Amount % 10000) / 100); - GetSpecialObject((SPECIALMEANING)&Platinum); - GiveTo(this,(ObjectType *)&Platinum,Amount % 100); - return; -} - - - -// DWARF original prototype: void GetMoney(TNPC * this, int Amount) - -void __thiscall TNPC::GetMoney(TNPC *this,int Amount) - -{ - int local_28; - int Gold; - int Platinum; - int Crystal; - - GetSpecialObject((SPECIALMEANING)&Crystal); - Platinum = CountInventoryObjects(this->Interlocutor,(ObjectType *)&Crystal,0); - GetSpecialObject((SPECIALMEANING)&Crystal); - Gold = CountInventoryObjects(this->Interlocutor,(ObjectType *)&Crystal,0); - GetSpecialObject((SPECIALMEANING)&Crystal); - local_28 = CountInventoryObjects(this->Interlocutor,(ObjectType *)&Crystal,0); - CalculateChange(Amount,&local_28,&Gold,&Platinum); - if (0 < local_28) { - GetSpecialObject((SPECIALMEANING)&Crystal); - GetFrom(this,(ObjectType *)&Crystal,local_28); - } - if (0 < Gold) { - GetSpecialObject((SPECIALMEANING)&Crystal); - GetFrom(this,(ObjectType *)&Crystal,Gold); - } - if (0 < Platinum) { - GetSpecialObject((SPECIALMEANING)&Crystal); - GetFrom(this,(ObjectType *)&Crystal,Platinum); - } - if (local_28 < 0) { - GetSpecialObject((SPECIALMEANING)&Crystal); - GiveTo(this,(ObjectType *)&Crystal,-local_28); - } - if (Gold < 0) { - GetSpecialObject((SPECIALMEANING)&Crystal); - GiveTo(this,(ObjectType *)&Crystal,-Gold); - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: Interlocutor_local -// DWARF original prototype: void Enqueue(TNPC * this, ulong Interlocutor, char * Text) - -void __thiscall TNPC::Enqueue(TNPC *this,ulong Interlocutor,char *Text) - -{ - ulong *puVar1; - int i_00; - ulong uVar2; - int i; - int i_01; - char *Text_local; - ulong Interlocutor_local; - - if (Interlocutor == 0) { - this = (TNPC *)&DAT_08105ac0; - } - else { - if (Text != (char *)0x0) { - i_00 = this->QueueLength; - i_01 = 0; - if (0 < i_00) { - do { - puVar1 = vector<>::operator()(&this->QueuedPlayers,i_01); - if (*puVar1 == Interlocutor) { - return; - } - i_00 = this->QueueLength; - i_01 = i_01 + 1; - } while (i_01 < i_00); - } - puVar1 = vector<>::operator()(&this->QueuedPlayers,i_00); - *puVar1 = Interlocutor; - uVar2 = AddDynamicString(Text); - puVar1 = vector<>::operator()(&this->QueuedAddresses,this->QueueLength); - *puVar1 = uVar2; - this->QueueLength = this->QueueLength + 1; - return; - } - this = (TNPC *)s_TNPC__Enqueue__Text_ist_NULL__08105aa0; - } - error((char *)this); - return; -} - - - -// DWARF original prototype: void TurnToInterlocutor(TNPC * this) - -void __thiscall TNPC::TurnToInterlocutor(TNPC *this) - -{ - uchar Dir; - TCreature *Opp; - TCreature *pTVar1; - int iVar2; - int dy; - int iVar3; - int iVar4; - int dx; - int iVar5; - - pTVar1 = GetCreature(this->Interlocutor); - if (pTVar1 != (TCreature *)0x0) { - iVar5 = pTVar1->posx - (this->super_TNonplayer).super_TCreature.posx; - iVar3 = pTVar1->posy - (this->super_TNonplayer).super_TCreature.posy; - iVar4 = -iVar5; - if (-1 < iVar5) { - iVar4 = iVar5; - } - iVar2 = -iVar3; - if (-1 < iVar3) { - iVar2 = iVar3; - } - if (iVar4 < iVar2) { - Dir = ((char)~(byte)((uint)iVar3 >> 0x18) >> 7) * -2; - } - else { - Dir = (char)(iVar5 >> 0x1f) * -2 + '\x01'; - } - TCreature::Rotate((TCreature *)this,Dir); - return; - } - error(&DAT_081058e0); - return; -} - - - -// DWARF original prototype: void ChangeState(TNPC * this, STATE NewState, bool Stimulus) - -void __thiscall TNPC::ChangeState(TNPC *this,STATE NewState,bool Stimulus) - -{ - (this->super_TNonplayer).State = NewState; - if (!Stimulus) { - return; - } - TCreature::ToDoYield((TCreature *)this); - return; -} - - - -void ChangeNPCState(TCreature *npc,int NewState,bool Stimulus) - -{ - if (npc == (TCreature *)0x0) { - npc = (TCreature *)s_ChangeNPCState__npc_ist_NULL__08105b40; - } - else { - if (npc->Type == NPC) { - npc[1]._vptr_TCreature = (_func_int_varargs **)NewState; - if (!Stimulus) { - return; - } - TCreature::ToDoYield(npc); - return; - } - npc = (TCreature *)s_ChangeNPCState__npc_ist_kein_NPC_08105b00; - } - error((char *)npc); - return; -} - - - -// DWARF original prototype: void TMonster(TMonster * this, int Race, int x, int y, int z, int Home, -// ulong Father) - -void __thiscall TMonster::TMonster(TMonster *this) - -{ - int iVar1; - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; - bool bVar3; - TCreature *pTVar4; - TNonplayer **ppTVar5; - TItemData *this_00; - long lVar6; - long lVar7; - TCombat *this_01; - int in_stack_00000008; - int in_stack_0000000c; - int in_stack_00000010; - int in_stack_00000014; - int in_stack_00000018; - ulong in_stack_0000001c; - char *Text; - Object *this_02; - int local_88; - int j; - int Repeat; - int i; - Object local_6c [4]; - Object local_5c [4]; - Object local_4c; - Object Obj; - ulong local_3c [4]; - Object local_2c; - Object Bag; - - TCreature::TCreature((TCreature *)this); - (this->super_TNonplayer).super_TCreature.Type = MONSTER; - (this->super_TNonplayer).State = IDLE; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TMonster_08127ca8; - (this->super_TNonplayer).super_TCreature.Race = in_stack_00000008; - (this->super_TNonplayer).super_TCreature.startx = in_stack_0000000c; - (this->super_TNonplayer).super_TCreature.posx = in_stack_0000000c; - this->Home = in_stack_00000018; - (this->super_TNonplayer).super_TCreature.starty = in_stack_00000010; - (this->super_TNonplayer).super_TCreature.posy = in_stack_00000010; - (this->super_TNonplayer).super_TCreature.startz = in_stack_00000014; - (this->super_TNonplayer).super_TCreature.posz = in_stack_00000014; - this->Target = 0; - this->Master = in_stack_0000001c; - do { - if (this->Master == 0) { -LAB_080b873a: - if (RaceData[in_stack_00000008].Article[0] == '\0') { - strcpy((this->super_TNonplayer).super_TCreature.Name, - RaceData[in_stack_00000008].Name); - } - else { - snprintf((this->super_TNonplayer).super_TCreature.Name,0x1e,"%s %s", - in_stack_00000008 * 0x150 + 0x81c477e,RaceData + in_stack_00000008); - } - TSkillBase::SetSkills - (&(this->super_TNonplayer).super_TCreature.super_TSkillBase,in_stack_00000008) - ; - iVar1 = RaceData[in_stack_00000008].Outfit.OutfitID; - aVar2 = RaceData[in_stack_00000008].Outfit.field_1; - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID = iVar1; - (this->super_TNonplayer).super_TCreature.Outfit.field_1 = aVar2; - (this->super_TNonplayer).super_TCreature.OrgOutfit.OutfitID = iVar1; - (this->super_TNonplayer).super_TCreature.OrgOutfit.field_1 = aVar2; - TCreature::SetID((TCreature *)this,0); - TCreature::SetInCrList((TCreature *)this); - ppTVar5 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer); - FirstFreeNonplayer = FirstFreeNonplayer + 1; - *ppTVar5 = &this->super_TNonplayer; - bVar3 = TCreature::SetOnMap((TCreature *)this); - if (bVar3) { - if ((this->Master == 0) && (0 < RaceData[in_stack_00000008].Items)) { - // try { // try from 080b8836 to 080b8904 has its CatchHandler @ 080b8c3e - GetSpecialObject((SPECIALMEANING)local_3c); - GetBodyContainer((ulong)&local_4c,(this->super_TNonplayer).super_TCreature.ID); - Create(&local_2c,(ObjectType *)&local_4c,(ulong)local_3c); - Repeat = 1; - if (0 < RaceData[in_stack_00000008].Items) { - do { - this_00 = vector::operator() - (&RaceData[in_stack_00000008].Item,Repeat); - lVar6 = random(); - if (lVar6 <= this_00->Probability) { - lVar7 = random(); - j = 1; - bVar3 = ObjectType::getFlag(&this_00->Type,CUMULATIVE); - lVar6 = lVar7; - if (!bVar3) { - lVar6 = 0; - j = lVar7; - } - local_88 = 0; - if (0 < j) { - do { - local_4c.ObjectID = 0; - bVar3 = ObjectType::getFlag(&this_00->Type,WEAPON); - if (((((bVar3) || - (bVar3 = ObjectType::getFlag(&this_00->Type,SHIELD), - bVar3)) || - (bVar3 = ObjectType::getFlag(&this_00->Type,BOW), bVar3 - )) || ((bVar3 = ObjectType::getFlag(&this_00->Type, - THROW), bVar3 || - (bVar3 = ObjectType::getFlag(&this_00->Type,WAND - ), bVar3)))) || - ((bVar3 = ObjectType::getFlag(&this_00->Type,WEAROUT), - bVar3 || ((bVar3 = ObjectType::getFlag(&this_00->Type, - EXPIRE), bVar3 || - (bVar3 = ObjectType::getFlag(&this_00->Type, - EXPIRESTOP), - bVar3)))))) { - // try { // try from 080b8a02 to 080b8a2d has its CatchHandler @ 080b8bd5 - ObjectType::setTypeID - ((ObjectType *)local_6c,(this_00->Type).TypeID - ); - lVar7 = 0; - this_02 = local_6c; - i = local_2c.ObjectID; - Create(local_5c,(ObjectType *)&i,(ulong)this_02); - local_4c.ObjectID = local_5c[0].ObjectID; - local_3c[0] = local_5c[0].ObjectID; - } - else { - this_02 = local_5c; - ObjectType::setTypeID - ((ObjectType *)this_02,(this_00->Type).TypeID) - ; - lVar7 = lVar6; - CreateAtCreature((ulong)local_6c, - (ObjectType *) - (this->super_TNonplayer). - super_TCreature.ID,(ulong)this_02); - i = local_6c[0].ObjectID; - local_4c.ObjectID = i; - } - // try { // try from 080b8a44 to 080b8b6d has its CatchHandler @ 080b8c3e - Object::getContainer((Object *)&i); - Object::getObjectType(local_6c); - if (local_6c[0].ObjectID == 0) { - error(&DAT_08105bc0,in_stack_00000008,this_02,lVar7); - local_6c[0].ObjectID = local_4c.ObjectID; - Delete(local_6c,-1); - } - local_88 = local_88 + 1; - } while (local_88 < j); - } - } - Repeat = Repeat + 1; - } while (Repeat <= RaceData[in_stack_00000008].Items); - } - local_6c[0].ObjectID = local_2c.ObjectID; - GetFirstContainerObject((Object *)&i); - local_5c[0].ObjectID = ::NONE.ObjectID; - if (i == ::NONE.ObjectID) { - local_4c.ObjectID = local_2c.ObjectID; - // try { // try from 080b8970 to 080b89ed has its CatchHandler @ 080b8c3e - Delete(&local_4c,-1); - } - } - this_01 = &(this->super_TNonplayer).super_TCreature.Combat; - // try { // try from 080b8921 to 080b8953 has its CatchHandler @ 080b8c50 - TCombat::CheckCombatValues(this_01); - TCombat::SetAttackMode(this_01,'\x02'); - TCreature::ToDoWait((TCreature *)this,0); - TCreature::ToDoStart((TCreature *)this); - } - else { - Text = "TMonster::TMonster: Kann Monster nicht auf die Karte setzen.\n"; -LAB_080b8b89: - // try { // try from 080b8b89 to 080b8b8d has its CatchHandler @ 080b8c50 - error(Text); - } - return; - } - // try { // try from 080b86e6 to 080b87f7 has its CatchHandler @ 080b8c50 - pTVar4 = GetCreature(this->Master); - if (pTVar4 == (TCreature *)0x0) { - Text = "TMonster::TMonster: Master existiert nicht.\n"; - goto LAB_080b8b89; - } - if ((pTVar4->Type != MONSTER) || (pTVar4[1].super_TSkillBase.Skills[1] == (TSkill *)0x0)) { - pTVar4->SummonedCreatures = pTVar4->SummonedCreatures + 1; - (this->super_TNonplayer).super_TCreature.LifeEndRound = pTVar4->LifeEndRound; - goto LAB_080b873a; - } - error(&DAT_08105b60); - this->Master = (ulong)pTVar4[1].super_TSkillBase.Skills[1]; - } while( true ); -} - - - -// DWARF original prototype: void TMonster(TMonster * this, int Race, int x, int y, int z, int Home, -// ulong Father) - -void __thiscall TMonster::TMonster(TMonster *this) - -{ - int iVar1; - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; - bool bVar3; - TCreature *pTVar4; - TNonplayer **ppTVar5; - TItemData *this_00; - long lVar6; - long lVar7; - TCombat *this_01; - int in_stack_00000008; - int in_stack_0000000c; - int in_stack_00000010; - int in_stack_00000014; - int in_stack_00000018; - ulong in_stack_0000001c; - char *Text; - Object *this_02; - int local_88; - int j; - int Repeat; - int i; - Object local_6c [4]; - Object local_5c [4]; - Object local_4c; - Object Obj; - ulong local_3c [4]; - Object local_2c; - Object Bag; - - TCreature::TCreature((TCreature *)this); - (this->super_TNonplayer).super_TCreature.Type = MONSTER; - (this->super_TNonplayer).State = IDLE; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TMonster_08127ca8; - (this->super_TNonplayer).super_TCreature.Race = in_stack_00000008; - (this->super_TNonplayer).super_TCreature.startx = in_stack_0000000c; - (this->super_TNonplayer).super_TCreature.posx = in_stack_0000000c; - this->Home = in_stack_00000018; - (this->super_TNonplayer).super_TCreature.starty = in_stack_00000010; - (this->super_TNonplayer).super_TCreature.posy = in_stack_00000010; - (this->super_TNonplayer).super_TCreature.startz = in_stack_00000014; - (this->super_TNonplayer).super_TCreature.posz = in_stack_00000014; - this->Target = 0; - this->Master = in_stack_0000001c; - do { - if (this->Master == 0) { -LAB_080b8d5a: - if (RaceData[in_stack_00000008].Article[0] == '\0') { - strcpy((this->super_TNonplayer).super_TCreature.Name, - RaceData[in_stack_00000008].Name); - } - else { - snprintf((this->super_TNonplayer).super_TCreature.Name,0x1e,"%s %s", - in_stack_00000008 * 0x150 + 0x81c477e,RaceData + in_stack_00000008); - } - TSkillBase::SetSkills - (&(this->super_TNonplayer).super_TCreature.super_TSkillBase,in_stack_00000008) - ; - iVar1 = RaceData[in_stack_00000008].Outfit.OutfitID; - aVar2 = RaceData[in_stack_00000008].Outfit.field_1; - (this->super_TNonplayer).super_TCreature.Outfit.OutfitID = iVar1; - (this->super_TNonplayer).super_TCreature.Outfit.field_1 = aVar2; - (this->super_TNonplayer).super_TCreature.OrgOutfit.OutfitID = iVar1; - (this->super_TNonplayer).super_TCreature.OrgOutfit.field_1 = aVar2; - TCreature::SetID((TCreature *)this,0); - TCreature::SetInCrList((TCreature *)this); - ppTVar5 = vector<>::operator()(&NonplayerList,FirstFreeNonplayer); - FirstFreeNonplayer = FirstFreeNonplayer + 1; - *ppTVar5 = &this->super_TNonplayer; - bVar3 = TCreature::SetOnMap((TCreature *)this); - if (bVar3) { - if ((this->Master == 0) && (0 < RaceData[in_stack_00000008].Items)) { - // try { // try from 080b8e56 to 080b8f24 has its CatchHandler @ 080b925e - GetSpecialObject((SPECIALMEANING)local_3c); - GetBodyContainer((ulong)&local_4c,(this->super_TNonplayer).super_TCreature.ID); - Create(&local_2c,(ObjectType *)&local_4c,(ulong)local_3c); - Repeat = 1; - if (0 < RaceData[in_stack_00000008].Items) { - do { - this_00 = vector::operator() - (&RaceData[in_stack_00000008].Item,Repeat); - lVar6 = random(); - if (lVar6 <= this_00->Probability) { - lVar7 = random(); - j = 1; - bVar3 = ObjectType::getFlag(&this_00->Type,CUMULATIVE); - lVar6 = lVar7; - if (!bVar3) { - lVar6 = 0; - j = lVar7; - } - local_88 = 0; - if (0 < j) { - do { - local_4c.ObjectID = 0; - bVar3 = ObjectType::getFlag(&this_00->Type,WEAPON); - if (((((bVar3) || - (bVar3 = ObjectType::getFlag(&this_00->Type,SHIELD), - bVar3)) || - (bVar3 = ObjectType::getFlag(&this_00->Type,BOW), bVar3 - )) || ((bVar3 = ObjectType::getFlag(&this_00->Type, - THROW), bVar3 || - (bVar3 = ObjectType::getFlag(&this_00->Type,WAND - ), bVar3)))) || - ((bVar3 = ObjectType::getFlag(&this_00->Type,WEAROUT), - bVar3 || ((bVar3 = ObjectType::getFlag(&this_00->Type, - EXPIRE), bVar3 || - (bVar3 = ObjectType::getFlag(&this_00->Type, - EXPIRESTOP), - bVar3)))))) { - // try { // try from 080b9022 to 080b904d has its CatchHandler @ 080b91f5 - ObjectType::setTypeID - ((ObjectType *)local_6c,(this_00->Type).TypeID - ); - lVar7 = 0; - this_02 = local_6c; - i = local_2c.ObjectID; - Create(local_5c,(ObjectType *)&i,(ulong)this_02); - local_4c.ObjectID = local_5c[0].ObjectID; - local_3c[0] = local_5c[0].ObjectID; - } - else { - this_02 = local_5c; - ObjectType::setTypeID - ((ObjectType *)this_02,(this_00->Type).TypeID) - ; - lVar7 = lVar6; - CreateAtCreature((ulong)local_6c, - (ObjectType *) - (this->super_TNonplayer). - super_TCreature.ID,(ulong)this_02); - i = local_6c[0].ObjectID; - local_4c.ObjectID = i; - } - // try { // try from 080b9064 to 080b918d has its CatchHandler @ 080b925e - Object::getContainer((Object *)&i); - Object::getObjectType(local_6c); - if (local_6c[0].ObjectID == 0) { - error(&DAT_08105bc0,in_stack_00000008,this_02,lVar7); - local_6c[0].ObjectID = local_4c.ObjectID; - Delete(local_6c,-1); - } - local_88 = local_88 + 1; - } while (local_88 < j); - } - } - Repeat = Repeat + 1; - } while (Repeat <= RaceData[in_stack_00000008].Items); - } - local_6c[0].ObjectID = local_2c.ObjectID; - GetFirstContainerObject((Object *)&i); - local_5c[0].ObjectID = ::NONE.ObjectID; - if (i == ::NONE.ObjectID) { - local_4c.ObjectID = local_2c.ObjectID; - // try { // try from 080b8f90 to 080b900d has its CatchHandler @ 080b925e - Delete(&local_4c,-1); - } - } - this_01 = &(this->super_TNonplayer).super_TCreature.Combat; - // try { // try from 080b8f41 to 080b8f73 has its CatchHandler @ 080b9270 - TCombat::CheckCombatValues(this_01); - TCombat::SetAttackMode(this_01,'\x02'); - TCreature::ToDoWait((TCreature *)this,0); - TCreature::ToDoStart((TCreature *)this); - } - else { - Text = "TMonster::TMonster: Kann Monster nicht auf die Karte setzen.\n"; -LAB_080b91a9: - // try { // try from 080b91a9 to 080b91ad has its CatchHandler @ 080b9270 - error(Text); - } - return; - } - // try { // try from 080b8d06 to 080b8e17 has its CatchHandler @ 080b9270 - pTVar4 = GetCreature(this->Master); - if (pTVar4 == (TCreature *)0x0) { - Text = "TMonster::TMonster: Master existiert nicht.\n"; - goto LAB_080b91a9; - } - if ((pTVar4->Type != MONSTER) || (pTVar4[1].super_TSkillBase.Skills[1] == (TSkill *)0x0)) { - pTVar4->SummonedCreatures = pTVar4->SummonedCreatures + 1; - (this->super_TNonplayer).super_TCreature.LifeEndRound = pTVar4->LifeEndRound; - goto LAB_080b8d5a; - } - error(&DAT_08105b60); - this->Master = (ulong)pTVar4[1].super_TSkillBase.Skills[1]; - } while( true ); -} - - - -// DWARF original prototype: void ~TMonster(TMonster * this, int __in_chrg) - -void __thiscall TMonster::~TMonster(TMonster *this,int __in_chrg) - -{ - bool bVar1; - TCreature *pTVar2; - TCreature *master; - ulong in_stack_ffffffe8; - - bVar1 = (this->super_TNonplayer).super_TCreature.IsDead; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TMonster_08127ca8; - if (bVar1 == false) { - in_stack_ffffffe8 = (this->super_TNonplayer).super_TCreature.posy; - GraphicalEffect(); - } - else if (this->Master == 0) { - in_stack_ffffffe8 = RaceData[(this->super_TNonplayer).super_TCreature.Race].ExperiencePoints - ; - TCombat::DistributeExperiencePoints - (&(this->super_TNonplayer).super_TCreature.Combat,in_stack_ffffffe8); - } - if (this->Home != 0) { - NotifyMonsterhomeOfDeath(this->Home); - } - if (this->Master != 0) { - pTVar2 = GetCreature(this->Master); - if ((pTVar2 != (TCreature *)0x0) && (0 < pTVar2->SummonedCreatures)) { - pTVar2->SummonedCreatures = pTVar2->SummonedCreatures + -1; - } - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TMonster(TMonster * this, int __in_chrg) - -void __thiscall TMonster::~TMonster(TMonster *this,int __in_chrg) - -{ - bool bVar1; - TCreature *pTVar2; - TCreature *master; - ulong in_stack_ffffffe8; - - bVar1 = (this->super_TNonplayer).super_TCreature.IsDead; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TMonster_08127ca8; - if (bVar1 == false) { - in_stack_ffffffe8 = (this->super_TNonplayer).super_TCreature.posy; - GraphicalEffect(); - } - else if (this->Master == 0) { - in_stack_ffffffe8 = RaceData[(this->super_TNonplayer).super_TCreature.Race].ExperiencePoints - ; - TCombat::DistributeExperiencePoints - (&(this->super_TNonplayer).super_TCreature.Combat,in_stack_ffffffe8); - } - if (this->Home != 0) { - NotifyMonsterhomeOfDeath(this->Home); - } - if (this->Master != 0) { - pTVar2 = GetCreature(this->Master); - if ((pTVar2 != (TCreature *)0x0) && (0 < pTVar2->SummonedCreatures)) { - pTVar2->SummonedCreatures = pTVar2->SummonedCreatures + -1; - } - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - return; -} - - - -// DWARF original prototype: void ~TMonster(TMonster * this, int __in_chrg) - -void __thiscall TMonster::~TMonster(TMonster *this,int __in_chrg) - -{ - bool bVar1; - TCreature *pTVar2; - TCreature *master; - ulong in_stack_ffffffe8; - - bVar1 = (this->super_TNonplayer).super_TCreature.IsDead; - (this->super_TNonplayer).super_TCreature._vptr_TCreature = - (_func_int_varargs **)&PTR__TMonster_08127ca8; - if (bVar1 == false) { - in_stack_ffffffe8 = (this->super_TNonplayer).super_TCreature.posy; - GraphicalEffect(); - } - else if (this->Master == 0) { - in_stack_ffffffe8 = RaceData[(this->super_TNonplayer).super_TCreature.Race].ExperiencePoints - ; - TCombat::DistributeExperiencePoints - (&(this->super_TNonplayer).super_TCreature.Combat,in_stack_ffffffe8); - } - if (this->Home != 0) { - NotifyMonsterhomeOfDeath(this->Home); - } - if (this->Master != 0) { - pTVar2 = GetCreature(this->Master); - if ((pTVar2 != (TCreature *)0x0) && (0 < pTVar2->SummonedCreatures)) { - pTVar2->SummonedCreatures = pTVar2->SummonedCreatures + -1; - } - } - TNonplayer::~TNonplayer(&this->super_TNonplayer,in_stack_ffffffe8); - operator_delete(this); - return; -} - - - // WARNING: Globals starting with '_' overlap smaller symbols at the same address // DWARF original prototype: void IdleStimulus(TMonster * this) @@ -26737,50 +20458,6 @@ void _GLOBAL__I__Z13BeginSendDataP11TConnection(void) return; } - - -// WARNING: Variable defined which should be unmapped: Text_local - -void SendText(TConnection *Connection,char *Text,int Length) - -{ - int Offset; - int iVar1; - uchar *__dest; - size_t __n; - char *Text_local; - - if (Text == (char *)0x0) { - error("SendText: Text ist NULL.\n"); - return; - } - if (0 < Length) { - if ((Connection->NextToSend - Length) + 0x4000 < Connection->NextToWrite) { - Connection->Overflow = true; - } - else { - iVar1 = Connection->NextToWrite % 0x4000; - if (Length + iVar1 < 0x4001) { - __dest = Connection->OutData + iVar1; - __n = Length; - } - else { - memcpy(Connection->OutData + iVar1,Text,0x4000 - iVar1); - __dest = Connection->OutData; - Text = Text + (0x4000 - iVar1); - __n = (Length + iVar1) - 0x4000; - } - memcpy(__dest,Text,__n); - Connection->NextToWrite = Connection->NextToWrite + Length; - } - return; - } - error(&DAT_08109a60); - return; -} - - - void __static_initialization_and_destruction_0(int __initialize_p,int __priority) { diff --git a/reference/types.hh b/reference/types.hh index 8e749d8..ae021ad 100644 --- a/reference/types.hh +++ b/reference/types.hh @@ -62,18 +62,6 @@ struct TDelayedMail { int PacketSize; }; -struct TMonsterhome { - int Race; - int x; - int y; - int z; - int Radius; - int MaxMonsters; - int ActMonsters; - int RegenerationTime; - int Timer; -}; - struct THelpDepot { ulong CharacterID; struct Object Box; diff --git a/src/cr.hh b/src/cr.hh index f36f7bf..de40fcc 100644 --- a/src/cr.hh +++ b/src/cr.hh @@ -8,6 +8,9 @@ #include "map.hh" struct TCreature; +struct TMonster; +struct TNPC; +struct TPlayer; // Creature Data // ============================================================================= @@ -620,7 +623,10 @@ struct TCreature: TSkillBase { // TNonPlayer // ============================================================================= struct TNonplayer: TCreature { - //TNonplayer(void); + TNonplayer(void); + ~TNonplayer(void) override; + void SetInList(void); + void DelInList(void); // DATA // ================= @@ -630,46 +636,93 @@ struct TNonplayer: TCreature { // TNPC // ============================================================================= -// TODO(fusion): Most of these are probably contained in `crnonpl.cc` because -// `TNPC` has a pointer to `TBehaviourDatabase`. -struct TNode { +struct TBehaviourNode { int Type; int Data; - TNode *Left; - TNode *Right; + TBehaviourNode *Left; + TBehaviourNode *Right; }; -struct TCondition { +struct TBehaviourCondition { + bool set(int Type, void *Data); + void clear(void); + + // DATA + // ================= int Type; uint32 Text; - TNode *Expression; + TBehaviourNode *Expression; int Property; int Number; }; -struct TAction { +struct TBehaviourAction { + bool set(int Type, void *Data, void *Data2, void *Data3, void *Data4); + void clear(void); + + // DATA + // ================= int Type; uint32 Text; int Number; - TNode *Expression; - TNode *Expression2; - TNode *Expression3; + TBehaviourNode *Expression; + TBehaviourNode *Expression2; + TBehaviourNode *Expression3; }; struct TBehaviour { - vector Condition; - vector Action; + TBehaviour(void); + ~TBehaviour(void); + bool addCondition(int Type, void *Data); + bool addAction(int Type, void *Data, void *Data2, void *Data3, void *Data4); + + // TODO(fusion): Same as `TChannel` in `operate.hh`. + TBehaviour(const TBehaviour &Other); + void operator=(const TBehaviour &Other); + + // DATA + // ================= + vector Condition; + vector Action; int Conditions; int Actions; }; struct TBehaviourDatabase { + TBehaviourDatabase(TReadScriptFile *Script); + + // TODO(fusion): These could/should be standalone functions. + TBehaviourNode *readValue(TReadScriptFile *Script); + TBehaviourNode *readFactor(TReadScriptFile *Script); + TBehaviourNode *readTerm(TReadScriptFile *Script); + int evaluate(TNPC *Npc, TBehaviourNode *Node, int *Parameters); + + void react(TNPC *Npc, const char *Text, SITUATION Situation); + + // DATA + // ================= vector Behaviour; int Behaviours; }; -struct TNPC { - //TNPC(void); +struct TNPC: TNonplayer { + TNPC(const char *FileName); + void GiveTo(ObjectType Type, int Amount); + void GetFrom(ObjectType Type, int Amount); + void GiveMoney(int Amount); + void GetMoney(int Amount); + void Enqueue(uint32 InterlocutorID, const char *Text); + void TurnToInterlocutor(void); + void ChangeState(STATE NewState, bool Stimulus); + + // VIRTUAL FUNCTIONS + // ================= + ~TNPC(void) override; + bool MovePossible(int x, int y, int z, bool Execute, bool Jump) override; + void TalkStimulus(uint32 SpeakerID, const char *Text) override; + void DamageStimulus(uint32 AttackerID, int Damage, int DamageType) override; + void IdleStimulus(void) override; + void CreatureMoveStimulus(uint32 CreatureID, int Type) override; // DATA // ================= @@ -689,8 +742,24 @@ struct TNPC { // TMonster // ============================================================================= +struct TMonsterhome { + int Race; + int x; + int y; + int z; + int Radius; + int MaxMonsters; + int ActMonsters; + int RegenerationTime; + int Timer; +}; + struct TMonster: TNonplayer { - //TMonster(void); + TMonster(int Race, int x, int y, int z, int Home, uint32 MasterID); + + // VIRTUAL FUNCTIONS + // ================= + ~TMonster(void) override; // DATA //TNonplayer super_TNonplayer; // IMPLICIT @@ -871,6 +940,12 @@ int GetSkillByName(const char *Name); // crnonpl.cc // ============================================================================= +void StartMonsterhomeTimer(int Nr); +void LoadMonsterhomes(void); +void ProcessMonsterhomes(void); +void NotifyMonsterhomeOfDeath(int Nr); +bool MonsterhomeInRange(int Nr, int x, int y, int z); +void ChangeNPCState(TCreature *Npc, int NewState, bool Stimulus); void InitNonplayer(); void ExitNonplayer(); diff --git a/src/crmain.cc b/src/crmain.cc index 6193515..3d45827 100644 --- a/src/crmain.cc +++ b/src/crmain.cc @@ -12,15 +12,17 @@ TRaceData RaceData[MAX_RACES]; priority_queue ToDoQueue(5000, 1000); -static uint32 NextCreatureID; -static int FirstFreeCreature; static TCreature *HashList[1000]; static matrix *FirstChainCreature; static vector CreatureList(0, 10000, 1000, NULL); -static priority_queue AttackWaveQueue(100, 100); +static int FirstFreeCreature; +static uint32 NextCreatureID; + static int KilledCreatures[MAX_RACES]; static int KilledPlayers[MAX_RACES]; +static priority_queue AttackWaveQueue(100, 100); + // TFindCreatures // ============================================================================= TFindCreatures::TFindCreatures(int RadiusX, int RadiusY, int CenterX, int CenterY, int Mask){ @@ -125,14 +127,19 @@ TCreature::TCreature(void) : this->ID = 0; this->NextHashEntry = NULL; this->NextChainCreature = 0; + this->Name[0] = 0; this->Murderer[0] = 0; + this->OrgOutfit = {}; + this->Outfit = {}; this->startx = 0; this->starty = 0; this->startz = 0; this->posx = 0; this->posy = 0; this->posz = 0; - this->Direction = 0; + this->Sex = 1; + this->Race = 0; + this->Direction = DIRECTION_SOUTH; this->Radius = INT_MAX; this->IsDead = false; this->LoseInventory = LOSE_INVENTORY_ALL; diff --git a/src/crnonpl.cc b/src/crnonpl.cc new file mode 100644 index 0000000..433718a --- /dev/null +++ b/src/crnonpl.cc @@ -0,0 +1,2110 @@ +#include "cr.hh" +#include "config.hh" +#include "containers.hh" +#include "info.hh" +#include "operate.hh" + +#include "stubs.hh" + +static vector NonplayerList(0, 10000, 1000, NULL); +static int FirstFreeNonplayer; + +static vector Monsterhome(1, 5000, 1000); +static int Monsterhomes; + +static store BehaviourNodeTable; + +// Behaviour Database +// ============================================================================= +static TBehaviourNode *NewBehaviourNode(int Type, TBehaviourNode *Left, TBehaviourNode *Right){ + TBehaviourNode *Node = BehaviourNodeTable.getFreeItem(); + Node->Type = Type; + Node->Data = 0; + Node->Left = Left; + Node->Right = Right; + return Node; +} + +static TBehaviourNode *NewBehaviourNode(int Type, int Data){ + TBehaviourNode *Node = BehaviourNodeTable.getFreeItem(); + Node->Type = Type; + Node->Data = Data; + Node->Left = NULL; + Node->Right = NULL; + return Node; +} + +static void DeleteBehaviourNode(TBehaviourNode *Node){ + if(Node != NULL){ + DeleteBehaviourNode(Node->Left); + DeleteBehaviourNode(Node->Right); + BehaviourNodeTable.putFreeItem(Node); + } +} + +bool TBehaviourCondition::set(int Type, void *Data){ + if(Type != BEHAVIOUR_CONDITION_SHORTCIRCUIT && Data == NULL){ + error("TBehaviourCondition::set: Data ist NULL.\n"); + this->Type = BEHAVIOUR_CONDITION_NONE; + return false; + } + + this->Type = Type; + switch(Type){ + case BEHAVIOUR_CONDITION_TEXT:{ + this->Text = AddDynamicString((const char*)Data); + break; + } + + case BEHAVIOUR_CONDITION_PROPERTY:{ + const char *Property = (const char*)Data; + this->Property = BEHAVIOUR_PROPERTY_NONE; + if(strcmp(Property, "address") == 0){ + this->Property = BEHAVIOUR_PROPERTY_ADDRESS; + }else if(strcmp(Property, "busy") == 0){ + this->Property = BEHAVIOUR_PROPERTY_BUSY; + }else if(strcmp(Property, "vanish") == 0){ + this->Property = BEHAVIOUR_PROPERTY_VANISH; + }else if(strcmp(Property, "male") == 0){ + this->Property = BEHAVIOUR_PROPERTY_MALE; + }else if(strcmp(Property, "female") == 0){ + this->Property = BEHAVIOUR_PROPERTY_FEMALE; + }else if(strcmp(Property, "knight") == 0){ + this->Property = BEHAVIOUR_PROPERTY_KNIGHT; + }else if(strcmp(Property, "paladin") == 0){ + this->Property = BEHAVIOUR_PROPERTY_PALADIN; + }else if(strcmp(Property, "sorcerer") == 0){ + this->Property = BEHAVIOUR_PROPERTY_SORCERER; + }else if(strcmp(Property, "druid") == 0){ + this->Property = BEHAVIOUR_PROPERTY_DRUID; + }else if(strcmp(Property, "premium") == 0){ + this->Property = BEHAVIOUR_PROPERTY_PREMIUM; + }else if(strcmp(Property, "promoted") == 0){ + this->Property = BEHAVIOUR_PROPERTY_PROMOTED; + }else if(strcmp(Property, "pzblock") == 0){ + this->Property = BEHAVIOUR_PROPERTY_PZBLOCK; + }else if(strcmp(Property, "nonpvp") == 0){ + this->Property = BEHAVIOUR_PROPERTY_NONPVP; + }else if(strcmp(Property, "pvpenforced") == 0){ + this->Property = BEHAVIOUR_PROPERTY_PVPENFORCED; + } + + if(this->Property == BEHAVIOUR_PROPERTY_NONE){ + return false; + } + break; + } + + case BEHAVIOUR_CONDITION_PARAMETER:{ + this->Number = *(int*)Data; + break; + } + + case BEHAVIOUR_CONDITION_EXPRESSION:{ + this->Expression = (TBehaviourNode*)Data; + break; + } + + case BEHAVIOUR_CONDITION_SHORTCIRCUIT:{ + // no-op + break; + } + + default:{ + error("TBehaviourCondition::set: Ungültiger Bedingungstyp %d\n", Type); + return false; + } + } + + return true; +} + +void TBehaviourCondition::clear(void){ + if(this->Type == BEHAVIOUR_CONDITION_TEXT){ + DeleteDynamicString(this->Text); + }else if(this->Type == BEHAVIOUR_CONDITION_EXPRESSION){ + DeleteBehaviourNode(this->Expression); + } + + this->Type = BEHAVIOUR_CONDITION_NONE; +} + +bool TBehaviourAction::set(int Type, void *Data, void *Data2, void *Data3, void *Data4){ + this->Type = Type; + switch(Type){ + case BEHAVIOUR_ACTION_REPLY:{ + this->Text = AddDynamicString((const char*)Data); + break; + } + + case BEHAVIOUR_ACTION_SET_VARIABLE: + case BEHAVIOUR_ACTION_SET_SKILL: + case BEHAVIOUR_ACTION_FUNCTION1:{ + this->Number = *(int*)Data; + this->Expression = (TBehaviourNode*)Data2; + break; + } + + case BEHAVIOUR_ACTION_FUNCTION2: + case BEHAVIOUR_ACTION_SET_SKILL_TIMER:{ + this->Number = *(int*)Data; + this->Expression = (TBehaviourNode*)Data2; + this->Expression2 = (TBehaviourNode*)Data3; + break; + } + + case BEHAVIOUR_ACTION_FUNCTION0: + case BEHAVIOUR_ACTION_CHANGESTATE:{ + this->Number = *(int*)Data; + break; + } + + case BEHAVIOUR_ACTION_REPEAT:{ + // no-op + break; + } + + case BEHAVIOUR_ACTION_FUNCTION3:{ + this->Number = *(int*)Data; + this->Expression = (TBehaviourNode*)Data2; + this->Expression2 = (TBehaviourNode*)Data3; + this->Expression3 = (TBehaviourNode*)Data4; + break; + } + + default:{ + error("TAction::set: Ungültiger Aktionstyp %d\n", Type); + return false; + } + } + + return true; +} + +void TBehaviourAction::clear(void){ + switch(this->Type){ + case BEHAVIOUR_ACTION_REPLY:{ + DeleteDynamicString(this->Text); + break; + } + + case BEHAVIOUR_ACTION_SET_VARIABLE: + case BEHAVIOUR_ACTION_SET_SKILL: + case BEHAVIOUR_ACTION_FUNCTION1:{ + DeleteBehaviourNode(this->Expression); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION2: + case BEHAVIOUR_ACTION_SET_SKILL_TIMER:{ + DeleteBehaviourNode(this->Expression); + DeleteBehaviourNode(this->Expression2); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION3:{ + DeleteBehaviourNode(this->Expression); + DeleteBehaviourNode(this->Expression2); + DeleteBehaviourNode(this->Expression3); + break; + } + + default:{ + break; + } + } + + this->Type = BEHAVIOUR_ACTION_NONE; +} + +TBehaviour::TBehaviour(void) : + Condition(0, 5, 5), + Action(0, 5, 5) +{ + this->Conditions = 0; + this->Actions = 0; +} + +TBehaviour::~TBehaviour(void){ + for(int i = 0; i < this->Conditions; i += 1){ + this->Condition.at(i)->clear(); + } + + for(int i = 0; i < this->Actions; i += 1){ + this->Action.at(i)->clear(); + } +} + +bool TBehaviour::addCondition(int Type, void *Data){ + bool Result = this->Condition.at(this->Conditions)->set(Type, Data); + if(Result){ + this->Conditions += 1; + } + return Result; +} + +bool TBehaviour::addAction(int Type, void *Data, void *Data2, void *Data3, void *Data4){ + bool Result = this->Action.at(this->Actions)->set(Type, Data, Data2, Data3, Data4); + if(Result){ + this->Actions += 1; + } + return Result; +} + +TBehaviour::TBehaviour(const TBehaviour &Other) : + TBehaviour() +{ + this->operator=(Other); +} + +void TBehaviour::operator=(const TBehaviour &Other){ + this->Conditions = Other.Conditions; + for(int i = 0; i < Other.Conditions; i += 1){ + *this->Condition.at(i) = Other.Condition.copyAt(i); + } + + this->Actions = Other.Actions; + for(int i = 0; i < Other.Actions; i += 1){ + *this->Action.at(i) = Other.Action.copyAt(i); + } +} + + +TBehaviourDatabase::TBehaviourDatabase(TReadScriptFile *Script) : + Behaviour(0, 50, 25) +{ + this->Behaviours = 0; + Script->readSymbol('{'); + Script->nextToken(); + while(Script->Token != SPECIAL || Script->getSpecial() != '}'){ + TBehaviour *Behaviour = this->Behaviour.at(this->Behaviours); + + // NOTE(fusion): Optional conditions. + if(Script->Token != SPECIAL || Script->getSpecial() != 'I'){ + while(true){ + bool Ok = false; + if(Script->Token == STRING){ + Ok = Behaviour->addCondition(BEHAVIOUR_CONDITION_TEXT, Script->getString()); + }else if(Script->Token == IDENTIFIER){ + Ok = Behaviour->addCondition(BEHAVIOUR_CONDITION_PROPERTY, Script->getIdentifier()); + }else if(Script->Token == SPECIAL){ + if(Script->getSpecial() == '!'){ + Ok = Behaviour->addCondition(BEHAVIOUR_CONDITION_SHORTCIRCUIT, NULL); + }else if(Script->getSpecial() == '%'){ + int Parameter = Script->readNumber(); + if(Parameter != 1 && Parameter != 2){ + Script->error("illegal ordinal number"); + } + Ok = Behaviour->addCondition(BEHAVIOUR_CONDITION_PARAMETER, &Parameter); + } + } + + if(!Ok){ + TBehaviourNode *Left = this->readTerm(Script); + Script->nextToken(); + if(Script->Token != SPECIAL){ + Script->error("relational operator expected"); + } + + int Operator = BEHAVIOUR_NODE_NONE; + switch(Script->getSpecial()){ + case '<': Operator = BEHAVIOUR_NODE_CMP_LT; break; + case '>': Operator = BEHAVIOUR_NODE_CMP_GT; break; + case '=': Operator = BEHAVIOUR_NODE_CMP_EQ; break; + case 'N': Operator = BEHAVIOUR_NODE_CMP_NEQ; break; + case 'L': Operator = BEHAVIOUR_NODE_CMP_LE; break; + case 'G': Operator = BEHAVIOUR_NODE_CMP_GE; break; + default:{ + Script->error("relational operator expected"); + break; + } + } + + Script->nextToken(); + TBehaviourNode *Right = this->readTerm(Script); + Behaviour->addCondition(BEHAVIOUR_CONDITION_EXPRESSION, + NewBehaviourNode(Operator, Right, Left)); + } + + Script->nextToken(); + if(Script->Token == SPECIAL && Script->getSpecial() == ','){ + Script->nextToken(); + }else{ + break; + } + } + } + + if(Script->Token != SPECIAL || Script->getSpecial() != 'I'){ + Script->error("'->' expected"); + } + + // NOTE(fusion): Required Actions. + Script->nextToken(); + while(true){ + if(Script->Token == STRING){ + Behaviour->addAction(BEHAVIOUR_ACTION_REPLY, Script->getString(), NULL, NULL, NULL); + }else if(Script->Token == IDENTIFIER){ + int Type = -1; + int Data = 0; + const char *Identifier = Script->getIdentifier(); + if(strcmp(Identifier, "topic") == 0){ + Type = BEHAVIOUR_ACTION_SET_VARIABLE; + Data = 1; // BEHAVIOUR_VARIABLE_TOPIC ? + }else if(strcmp(Identifier, "price") == 0){ + Type = BEHAVIOUR_ACTION_SET_VARIABLE; + Data = 2; // BEHAVIOUR_VARIABLE_PRICE ? + }else if(strcmp(Identifier, "amount") == 0){ + Type = BEHAVIOUR_ACTION_SET_VARIABLE; + Data = 3; // BEHAVIOUR_VARIABLE_AMOUNT ? + }else if(strcmp(Identifier, "type") == 0){ + Type = BEHAVIOUR_ACTION_SET_VARIABLE; + Data = 4; // BEHAVIOUR_VARIABLE_TYPE + }else if(strcmp(Identifier, "data") == 0){ + Type = BEHAVIOUR_ACTION_SET_VARIABLE; + Data = 6; // BEHAVIOUR_VARIABLE_DATA + }else if(strcmp(Identifier, "hp") == 0){ + Type = BEHAVIOUR_ACTION_SET_SKILL; + Data = SKILL_HITPOINTS; + }else if(strcmp(Identifier, "poison") == 0){ + Type = BEHAVIOUR_ACTION_SET_SKILL_TIMER; + Data = SKILL_POISON; + }else if(strcmp(Identifier, "burning") == 0){ + Type = BEHAVIOUR_ACTION_SET_SKILL_TIMER; + Data = SKILL_BURNING; + }else if(strcmp(Identifier, "setquestvalue") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION2; + Data = 3; // BEHAVIOUR_FUNCTION2_SETQUESTVALUE ? + }else if(strcmp(Identifier, "effectme") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 1; // BEHAVIOUR_FUNCTION1_EFFECTME ? + }else if(strcmp(Identifier, "effectopp") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 2; // BEHAVIOUR_FUNCTION1_EFFECTOPP ? + }else if(strcmp(Identifier, "profession") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 3; // BEHAVIOUR_FUNCTION1_SETPROFESSION ? + }else if(strcmp(Identifier, "teachspell") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 4; // BEHAVIOUR_FUNCTION1_TEACHSPELL ? + }else if(strcmp(Identifier, "summon") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 5; // BEHAVIOUR_FUNCTION1_SUMMON ? + }else if(strcmp(Identifier, "create") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 6; // BEHAVIOUR_FUNCTION1_CREATE ? + }else if(strcmp(Identifier, "delete") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION1; + Data = 7; // BEHAVIOUR_FUNCTION1_DELETE ? + }else if(strcmp(Identifier, "createmoney") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION0; + Data = 1; // BEHAVIOUR_FUNCTION0_CREATEMONEY ? + }else if(strcmp(Identifier, "deletemoney") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION0; + Data = 2; // BEHAVIOUR_FUNCTION0_DELETEMONEY ? + }else if(strcmp(Identifier, "queue") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION0; + Data = 3; // BEHAVIOUR_FUNCTION0_ENQUEUE ? + }else if(strcmp(Identifier, "teleport") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION3; + Data = 1; // BEHAVIOUR_FUNCTION3_TELEPORT ? + }else if(strcmp(Identifier, "startposition") == 0){ + Type = BEHAVIOUR_ACTION_FUNCTION3; + Data = 2; // BEHAVIOUR_FUNCTION3_SETSTART ? + }else if(strcmp(Identifier, "idle") == 0){ + Type = BEHAVIOUR_ACTION_CHANGESTATE; + Data = IDLE; + }else if(strcmp(Identifier, "nop") == 0){ + Type = BEHAVIOUR_ACTION_NONE; + Data = 0; + } + + switch(Type){ + case BEHAVIOUR_ACTION_NONE:{ + // no-op + break; + } + + case BEHAVIOUR_ACTION_SET_VARIABLE: + case BEHAVIOUR_ACTION_SET_SKILL:{ + Script->readSymbol('='); + Script->nextToken(); + TBehaviourNode *Value = this->readTerm(Script); + + Behaviour->addAction(Type, &Data, Value, NULL, NULL); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION1:{ + Script->readSymbol('('); + Script->nextToken(); + TBehaviourNode *Param = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Behaviour->addAction(Type, &Data, Param, NULL, NULL); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION2: + case BEHAVIOUR_ACTION_SET_SKILL_TIMER:{ + Script->readSymbol('('); + + Script->nextToken(); + TBehaviourNode *Param1 = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ','){ + Script->error(", expected"); + } + + Script->nextToken(); + TBehaviourNode *Param2 = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Behaviour->addAction(Type, &Data, Param1, Param2, NULL); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION0: + case BEHAVIOUR_ACTION_CHANGESTATE:{ + Behaviour->addAction(Type, &Data, NULL, NULL, NULL); + break; + } + + case BEHAVIOUR_ACTION_FUNCTION3:{ + Script->readSymbol('('); + + Script->nextToken(); + TBehaviourNode *Param1 = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ','){ + Script->error(", expected"); + } + + Script->nextToken(); + TBehaviourNode *Param2 = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ','){ + Script->error(", expected"); + } + + Script->nextToken(); + TBehaviourNode *Param3 = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Behaviour->addAction(Type, &Data, Param1, Param2, Param3); + break; + } + + default:{ + Script->error("unknown identifier"); + break; + } + } + }else if(Script->Token == SPECIAL && Script->getSpecial() == '*'){ + if(this->Behaviours == 0){ + Script->error("no previous pattern"); + } + Behaviour->addAction(BEHAVIOUR_ACTION_REPEAT, NULL, NULL, NULL, NULL); + }else{ + Script->error("illegal action"); + } + + Script->nextToken(); + if(Script->Token == SPECIAL && Script->getSpecial() == ','){ + Script->nextToken(); + }else{ + break; + } + } + + this->Behaviours += 1; + } +} + +TBehaviourNode *TBehaviourDatabase::readValue(TReadScriptFile *Script){ + TBehaviourNode *Node = NULL; + if(Script->Token == NUMBER){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_NUMBER, Script->readNumber()); + }else if(Script->Token == IDENTIFIER){ + const char *Identifier = Script->getIdentifier(); + if(strcmp(Identifier, "topic") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_TOPIC, 0); + }else if(strcmp(Identifier, "price") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_PRICE, 0); + }else if(strcmp(Identifier, "amount") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_AMOUNT, 0); + }else if(strcmp(Identifier, "level") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_SKILL, SKILL_LEVEL); + }else if(strcmp(Identifier, "magiclevel") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_SKILL, SKILL_MAGIC_LEVEL); + }else if(strcmp(Identifier, "hp") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_SKILL, SKILL_HITPOINTS); + }else if(strcmp(Identifier, "poison") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_SKILL, SKILL_POISON); + }else if(strcmp(Identifier, "burning") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_SKILL, SKILL_BURNING); + }else if(strcmp(Identifier, "count") == 0){ + Script->readSymbol('('); + Script->nextToken(); + TBehaviourNode *Left = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Node = NewBehaviourNode(BEHAVIOUR_NODE_COUNT, Left, NULL); + }else if(strcmp(Identifier, "countmoney") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_COUNTMONEY, 0); + }else if(strcmp(Identifier, "type") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_TYPE, 0); + }else if(strcmp(Identifier, "data") == 0){ + Node = NewBehaviourNode(BEHAVIOUR_NODE_DATA, 0); + }else if(strcmp(Identifier, "spellknown") == 0){ + Script->readSymbol('('); + Script->nextToken(); + TBehaviourNode *Left = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Node = NewBehaviourNode(BEHAVIOUR_NODE_SPELLKNOWN, Left, NULL); + }else if(strcmp(Identifier, "spelllevel") == 0){ + Script->readSymbol('('); + Script->nextToken(); + TBehaviourNode *Left = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Node = NewBehaviourNode(BEHAVIOUR_NODE_SPELLLEVEL, Left, NULL); + }else if(strcmp(Identifier, "random") == 0){ + Script->readSymbol('('); + + Script->nextToken(); + TBehaviourNode *Left = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ','){ + Script->error(", expected"); + } + + Script->nextToken(); + TBehaviourNode *Right = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Node = NewBehaviourNode(BEHAVIOUR_NODE_RANDOM, Left, Right); + }else if(strcmp(Identifier, "questvalue") == 0){ + Script->readSymbol('('); + Script->nextToken(); + TBehaviourNode *Left = this->readTerm(Script); + if(Script->Token != SPECIAL || Script->getSpecial() != ')'){ + Script->error(") expected"); + } + + Node = NewBehaviourNode(BEHAVIOUR_NODE_QUESTVALUE, Left, NULL); + } + }else if(Script->Token == SPECIAL){ + if(Script->getSpecial() != '%'){ + Script->error("illegal character"); + } + Node = NewBehaviourNode(BEHAVIOUR_NODE_PARAMETER, Script->readNumber()); + }else{ + Script->error("illegal value"); + } + + if(Node == NULL){ + Script->error("unknown value"); + } + + Script->nextToken(); + return Node; +} + +TBehaviourNode *TBehaviourDatabase::readFactor(TReadScriptFile *Script){ + TBehaviourNode *Node = this->readValue(Script); + while(Script->Token == SPECIAL && Script->getSpecial() == '*'){ + Script->nextToken(); + Node = NewBehaviourNode(BEHAVIOUR_NODE_MUL, Node, this->readValue(Script)); + } + return Node; +} + +TBehaviourNode *TBehaviourDatabase::readTerm(TReadScriptFile *Script){ + TBehaviourNode *Node = this->readFactor(Script); + while(Script->Token == SPECIAL){ + int Type = BEHAVIOUR_NODE_NONE; + if(Script->getSpecial() == '+'){ + Type = BEHAVIOUR_NODE_ADD; + }else if(Script->getSpecial() == '-'){ + Type = BEHAVIOUR_NODE_SUB; + }else{ + break; + } + + Script->nextToken(); + Node = NewBehaviourNode(Type, Node, this->readFactor(Script)); + } + return Node; +} + +int TBehaviourDatabase::evaluate(TNPC *Npc, TBehaviourNode *Node, int *Parameters){ + if(Npc == NULL){ + error("TBehaviourDatabase::evaluate: NPC existiert nicht.\n"); + return 0; + } + + if(Node == NULL){ + error("TBehaviourDatabase::evaluate: Knoten existiert nicht.\n"); + return 0; + } + + if(Parameters == NULL){ + error("TBehaviourDatabase::evaluate: Zahlen existieren nicht.\n"); + return 0; + } + + uint32 InterlocutorID = Npc->Interlocutor; + TPlayer *Interlocutor = GetPlayer(InterlocutorID); + if(Interlocutor == NULL){ + error("TBehaviourDatabase::evaluate: Gesprächspartner existiert nicht.\n"); + return 0; + } + + int Result = 0; + switch(Node->Type){ + case BEHAVIOUR_NODE_CMP_LT:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left < Right; + break; + } + + case BEHAVIOUR_NODE_CMP_GT:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left > Right; + break; + } + + case BEHAVIOUR_NODE_CMP_EQ:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left == Right; + break; + } + + case BEHAVIOUR_NODE_CMP_NEQ:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left != Right; + break; + } + + case BEHAVIOUR_NODE_CMP_LE:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left <= Right; + break; + } + + case BEHAVIOUR_NODE_CMP_GE:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left >= Right; + break; + } + + case BEHAVIOUR_NODE_ADD:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left + Right; + break; + } + + case BEHAVIOUR_NODE_SUB:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left - Right; + break; + } + + case BEHAVIOUR_NODE_MUL:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = Left * Right; + break; + } + + case BEHAVIOUR_NODE_PARAMETER:{ + if(Node->Data != 1 && Node->Data != 2){ + error("TBehaviourDatabase::evaluate: Ungültiger Zahl-Parameter %d.\n", Node->Data); + }else if(Parameters[Node->Data - 1] < 0){ + error("TBehaviourDatabase::evaluate: Zahl-Parameter %d nicht belegt.\n", Node->Data); + }else{ + Result = Parameters[Node->Data - 1]; + } + break; + } + + case BEHAVIOUR_NODE_NUMBER:{ + Result = Node->Data; + break; + } + + case BEHAVIOUR_NODE_TOPIC:{ + Result = Npc->Topic; + break; + } + + case BEHAVIOUR_NODE_PRICE:{ + Result = Npc->Price; + break; + } + + case BEHAVIOUR_NODE_AMOUNT:{ + Result = Npc->Amount; + break; + } + + case BEHAVIOUR_NODE_SKILL:{ + int SkillNr = Node->Data; + if(SkillNr == SKILL_LEVEL + || SkillNr == SKILL_MAGIC_LEVEL + || SkillNr == SKILL_HITPOINTS){ + Result = Interlocutor->Skills[SkillNr]->Get(); + }else if(SkillNr == SKILL_POISON + || SkillNr == SKILL_BURNING){ + Result = Interlocutor->Skills[SkillNr]->TimerValue(); + }else{ + error("TBehaviourDatabase::evaluate: Ungültiger Skill %d.\n", SkillNr); + } + break; + } + + case BEHAVIOUR_NODE_COUNT:{ + int TypeID = this->evaluate(Npc, Node->Left, Parameters); + Result = CountInventoryObjects(InterlocutorID, TypeID, Npc->Data); + break; + } + + case BEHAVIOUR_NODE_COUNTMONEY:{ + Result = CountInventoryMoney(InterlocutorID); + break; + } + + case BEHAVIOUR_NODE_TYPE:{ + Result = Npc->TypeID; + break; + } + + case BEHAVIOUR_NODE_DATA:{ + Result = Npc->Data; + break; + } + + case BEHAVIOUR_NODE_SPELLKNOWN:{ + int SpellNr = this->evaluate(Npc, Node->Left, Parameters); + Result = Interlocutor->SpellKnown(SpellNr); + break; + } + + case BEHAVIOUR_NODE_SPELLLEVEL:{ + int SpellNr = this->evaluate(Npc, Node->Left, Parameters); + Result = GetSpellLevel(SpellNr); + break; + } + + case BEHAVIOUR_NODE_RANDOM:{ + int Left = this->evaluate(Npc, Node->Left, Parameters); + int Right = this->evaluate(Npc, Node->Right, Parameters); + Result = random(Left, Right); + break; + } + + case BEHAVIOUR_NODE_QUESTVALUE:{ + int QuestNr = this->evaluate(Npc, Node->Left, Parameters); + Result = Interlocutor->GetQuestValue(QuestNr); + break; + } + + default:{ + error("TBehaviourDatabase::evaluate: Ungültiger Knotentyp %d.\n", Node->Type); + break; + } + } + return Result; +} + +// NOTE(fusion): These smaller functions were inside `TBehaviourDatabase::react` +// but I figured it would be better to pull them out for readability. +static bool CheckBehaviourProperty(int Property, SITUATION Situation, TPlayer *Interlocutor){ + if(Interlocutor == NULL){ + error("CheckBehaviourProperty: Interlocutor ist NULL."); + return false; + } + + bool Result = false; + switch(Property){ + case BEHAVIOUR_PROPERTY_ADDRESS: + Result = (Situation == ADDRESS || Situation == ADDRESSQUEUE); + break; + case BEHAVIOUR_PROPERTY_BUSY: + Result = (Situation == BUSY); + break; + case BEHAVIOUR_PROPERTY_VANISH: + Result = (Situation == VANISH); + break; + case BEHAVIOUR_PROPERTY_MALE: + Result = (Interlocutor->Sex == 1); + break; + case BEHAVIOUR_PROPERTY_FEMALE: + Result = (Interlocutor->Sex == 2); + break; + case BEHAVIOUR_PROPERTY_KNIGHT: + Result = (Interlocutor->GetEffectiveProfession() == PROFESSION_KNIGHT); + break; + case BEHAVIOUR_PROPERTY_PALADIN: + Result = (Interlocutor->GetEffectiveProfession() == PROFESSION_PALADIN); + break; + case BEHAVIOUR_PROPERTY_SORCERER: + Result = (Interlocutor->GetEffectiveProfession() == PROFESSION_SORCERER); + break; + case BEHAVIOUR_PROPERTY_DRUID: + Result = (Interlocutor->GetEffectiveProfession() == PROFESSION_DRUID); + break; + case BEHAVIOUR_PROPERTY_PREMIUM: + Result = CheckRight(Interlocutor->ID, PREMIUM_ACCOUNT); + break; + case BEHAVIOUR_PROPERTY_PROMOTED: + Result = Interlocutor->GetActivePromotion(); + break; + case BEHAVIOUR_PROPERTY_PZBLOCK: + Result = (Interlocutor->EarliestProtectionZoneRound > RoundNr); + break; + case BEHAVIOUR_PROPERTY_NONPVP: + Result = (WorldType == NON_PVP); + break; + case BEHAVIOUR_PROPERTY_PVPENFORCED: + Result = (WorldType == PVP_ENFORCED); + break; + } + + return Result; +} + +static bool FormatNpcResponse(char *Buffer, int BufferSize, + const char *Template, TNPC *Npc, TPlayer *Interlocutor){ + if(Buffer == NULL || BufferSize <= 0){ + error("FormatNpcResponse: Invalid response buffer."); + return false; + } + + if(Template == NULL || Template[0] == 0){ + error("FormatNpcResponse: Template is NULL or empty."); + return false; + } + + if(Npc == NULL){ + error("FormatNpcResponse: Npc is NULL.\n"); + return false; + } + + if(Interlocutor == NULL){ + error("FormatNpcResponse: Interlocutor is NULL.\n"); + return false; + } + + int WritePos = 0; + int ReadPos = 0; + while(Template[ReadPos] != 0){ + if(Template[ReadPos] == '%' && Template[ReadPos + 1] != 0){ + char Help[50] = {}; + switch(Template[ReadPos + 1]){ + case 'N': strcpy(Help, Interlocutor->Name); break; + case 'A': sprintf(Help, "%d", Npc->Amount); break; + case 'P': sprintf(Help, "%d", Npc->Price); break; + case 'T':{ + int Hour, Minute; + GetTime(&Hour, &Minute); + if(Hour < 12){ + sprintf(Help, "%d:%.2d am", Hour, Minute); + }else{ + sprintf(Help, "%d:%.2d pm", (Hour - 12), Minute); + } + break; + } + } + + // NOTE(fusion): Make sure we don't overflow the buffer. + int HelpLen = strlen(Help); + if(HelpLen > 0){ + if((WritePos + HelpLen) > BufferSize){ + HelpLen = BufferSize - WritePos; + } + + if(HelpLen > 0){ + memcpy(&Buffer[WritePos], Help, HelpLen); + WritePos += HelpLen; + } + } + + ReadPos += 2; + }else{ + // NOTE(fusion): Make sure we don't overflow the buffer. + if(WritePos < BufferSize){ + Buffer[WritePos] = Template[ReadPos]; + WritePos += 1; + } + + ReadPos += 1; + } + } + + if(WritePos < BufferSize){ + Buffer[WritePos] = 0; + return true; + }else{ + Buffer[BufferSize - 1] = 0; + return false; + } +} + +void TBehaviourDatabase::react(TNPC *Npc, const char *Text, SITUATION Situation){ + if(Npc == NULL){ + error("TBehaviourDatabase::react: NPC existiert nicht.\n"); + return; + } + + if(Text == NULL){ + error("TBehaviourDatabase::react: Übergebener Text existiert nicht.\n"); + return; + } + + uint32 InterlocutorID = Npc->Interlocutor; + TPlayer *Interlocutor = GetPlayer(InterlocutorID); + if(Interlocutor == NULL){ + error("TBehaviourDatabase::react: Gesprächspartner existiert nicht" + " (Text=%s, Situation=%d).\n", Text, Situation); + return; + } + + int Parameters[2] = {-1, -1}; + int BestMatch = -1; + int MaxConditions = -1; + for(int BehaviourNr = 0; + BehaviourNr < this->Behaviours; + BehaviourNr += 1){ + TBehaviour *Behaviour = this->Behaviour.at(BehaviourNr); + bool Match = true; + bool ShortCircuit = false; + const char *TextPtr = Text; + for(int ConditionNr = 0; + ConditionNr < Behaviour->Conditions && Match; + ConditionNr += 1){ + TBehaviourCondition *Condition = Behaviour->Condition.at(ConditionNr); + if(Condition->Type == BEHAVIOUR_CONDITION_SHORTCIRCUIT){ + ShortCircuit = true; + break; + } + + switch(Condition->Type){ + case BEHAVIOUR_CONDITION_TEXT:{ + const char *Pattern = GetDynamicString(Condition->Text); + const char *Word = SearchForWord(Pattern, TextPtr); + if(Word != NULL){ + TextPtr = Word + strlen(Pattern); + }else{ + Match = false; + } + break; + } + + case BEHAVIOUR_CONDITION_PROPERTY:{ + if(!CheckBehaviourProperty(Condition->Property, Situation, Interlocutor)){ + Match = false; + } + break; + } + + case BEHAVIOUR_CONDITION_PARAMETER:{ + // TODO(fusion): The original function wouldn't check before + // writing to `Parameters` which could be a problem. + const char *Parameter = SearchForNumber(Condition->Number, TextPtr); + if(Parameter != NULL + && Condition->Number >= 1 + && Condition->Number <= NARRAY(Parameters)){ + Parameters[Condition->Number - 1] = atoi(Parameter); + if(Parameters[Condition->Number - 1] > 500){ + Parameters[Condition->Number - 1] = 500; + } + + // TODO(fusion): This could be problematic if the number + // has more than one digit. + TextPtr = Parameter + 1; + }else{ + Match = false; + } + break; + } + + case BEHAVIOUR_CONDITION_EXPRESSION:{ + if(this->evaluate(Npc, Condition->Expression, Parameters) == 0){ + Match = false; + } + break; + } + + case BEHAVIOUR_CONDITION_SHORTCIRCUIT:{ + // TODO(fusion): Select current and stop loop. + break; + } + } + } + + if(ShortCircuit || (Match && Behaviour->Conditions > MaxConditions)){ + BestMatch = BehaviourNr; + MaxConditions = Behaviour->Conditions; + if(ShortCircuit){ + break; + } + } + } + + if(BestMatch == -1){ + return; + } + + if(Situation != BUSY){ + Npc->Topic = 0; + } + + bool Repeat = false; + bool StartToDo = false; + int TalkDelay = 1000; + int BehaviourNr = BestMatch; + do{ + Repeat = false; + TBehaviour *Behaviour = this->Behaviour.at(BehaviourNr); + for(int ActionNr = 0; + ActionNr < Behaviour->Actions; + ActionNr += 1){ + TBehaviourAction *Action = Behaviour->Action.at(ActionNr); + if(Action->Type == BEHAVIOUR_ACTION_REPEAT){ + if(BehaviourNr > 0){ + BehaviourNr -= 1; + Repeat = true; + }else{ + error("TBehaviourDatabase::react (9): Kein vorheriges Muster.\n"); + } + break; + } + + switch(Action->Type){ + case BEHAVIOUR_ACTION_REPLY:{ + char Response[256] = {}; + const char *Template = GetDynamicString(Action->Text); + if(FormatNpcResponse(Response, sizeof(Response), Template, Npc, Interlocutor)){ + Npc->ToDoWait(TalkDelay); + Npc->ToDoTalk(TALK_SAY, NULL, Response, false); + TalkDelay += 3100 + (int)strlen(Response) * 100; + StartToDo = true; + }else{ + Response[20] = 0; + error("TBehaviourDatabase::react: Text von NPC %s wird zu lang (%s...).\n", + Npc->Name, Response); + } + break; + } + + case BEHAVIOUR_ACTION_SET_VARIABLE:{ + int Variable = Action->Number; + int Value = this->evaluate(Npc, Action->Expression, Parameters); + switch(Variable){ + case 1: Npc->Topic = Value; break; + case 2: Npc->Price = Value; break; + case 3: Npc->Amount = Value; break; + case 4: Npc->TypeID = Value; break; + case 6: Npc->Data = Value; break; + default:{ + error("TBehaviourDatabase::react: Ungültige Variable.\n"); + break; + } + } + break; + } + + case BEHAVIOUR_ACTION_SET_SKILL:{ + int SkillNr = Action->Number; + int Value = this->evaluate(Npc, Action->Expression, Parameters); + if(SkillNr == SKILL_HITPOINTS){ + Interlocutor->Skills[SKILL_HITPOINTS]->Set(Value); + if(Interlocutor->Skills[SKILL_HITPOINTS]->Get() <= 0){ + error("TBehaviourDatabase::react: NPC %s tötet Spieler.\n", Npc->Name); + } + }else{ + error("TBehaviourDatabase::react: Ungültiger Skill.\n"); + } + break; + } + + case BEHAVIOUR_ACTION_FUNCTION2:{ + int FunctionNr = Action->Number; + int Param1 = this->evaluate(Npc, Action->Expression, Parameters); + int Param2 = this->evaluate(Npc, Action->Expression2, Parameters); + switch(FunctionNr){ + case 3: Interlocutor->SetQuestValue(Param1, Param2); break; + default:{ + error("TBehaviourDatabase::react (4): Ungültige Funktionsnummer.\n"); + break; + } + } + break; + } + + case BEHAVIOUR_ACTION_FUNCTION1:{ + int FunctionNr = Action->Number; + int Param = this->evaluate(Npc, Action->Expression, Parameters); + switch(FunctionNr){ + case 1: GraphicalEffect(Npc->CrObject, Param); break; + case 2: GraphicalEffect(Interlocutor->CrObject, Param); break; + case 3: Interlocutor->SetProfession(Param); break; + case 4: Interlocutor->LearnSpell(Param); break; + case 5: CreateMonster(Param, Npc->posx, Npc->posy, Npc->posz, 0, 0, true); break; + case 6: Npc->GiveTo(Param, Npc->Amount); break; + case 7: Npc->GetFrom(Param, Npc->Amount); break; + default:{ + error("TBehaviourDatabase::react (5): Ungültige Funktionsnummer.\n"); + break; + } + } + break; + } + + case BEHAVIOUR_ACTION_FUNCTION0:{ + int FunctionNr = Action->Number; + switch(FunctionNr){ + case 1: Npc->GiveMoney(Npc->Price); break; + case 2: Npc->GetMoney(Npc->Price); break; + case 3:{ + if(Situation == BUSY){ + Npc->Enqueue(InterlocutorID, Text); + }else{ + error("TBehaviourDatabase::react (6): falsche Situation für Aktion \"Queue\".\n"); + } + break; + } + default:{ + error("TBehaviourDatabase::react (6): Ungültige Funktionsnummer.\n"); + break; + } + } + break; + } + + case BEHAVIOUR_ACTION_CHANGESTATE:{ + int NewState = Action->Number; + if(!StartToDo){ + Npc->ChangeState((STATE)NewState, false); + if(Situation != ADDRESSQUEUE){ + StartToDo = true; + }else{ + error("TBehaviourDatabase::react: NPC %s reagiert nicht auf Anrede %s.\n", + Npc->Name, Text); + } + }else{ + if(NewState == IDLE){ + Npc->ChangeState(LEAVING, false); + } + Npc->ToDoChangeState(NewState); + } + break; + } + + case BEHAVIOUR_ACTION_SET_SKILL_TIMER:{ + int SkillNr = Action->Number; + int Cycle = this->evaluate(Npc, Action->Expression, Parameters); + int MaxCount = this->evaluate(Npc, Action->Expression2, Parameters); + if(SkillNr == SKILL_POISON || SkillNr == SKILL_BURNING){ + if(Cycle == 0 || Interlocutor->Skills[SkillNr]->TimerValue() < Cycle){ + Interlocutor->SetTimer(SkillNr, Cycle, MaxCount, MaxCount, -1); + if(SkillNr == SKILL_POISON){ + Interlocutor->PoisonDamageOrigin = 0; + }else{ + Interlocutor->FireDamageOrigin = 0; + } + } + }else{ + error("TBehaviourDatabase::react (8): Ungültiger Skill.\n"); + } + break; + } + + case BEHAVIOUR_ACTION_FUNCTION3:{ + int FunctionNr = Action->Number; + int Param1 = this->evaluate(Npc, Action->Expression, Parameters); + int Param2 = this->evaluate(Npc, Action->Expression2, Parameters); + int Param3 = this->evaluate(Npc, Action->Expression3, Parameters); + switch(FunctionNr){ + case 1:{ + print(3, "NPC teleportiert Gesprächspartner nach [%d,%d,%d].\n", + Param1, Param2, Param3); + try{ + Object Dest = GetMapContainer(Param1, Param2, Param3); + Move(0, Interlocutor->CrObject, Dest, -1, false, NONE); + }catch(RESULT r){ + error("TBehaviourDatabase::react (10): Exception %d.\n", r); + } + break; + } + + case 2:{ + print(3, "NPC setzt Startkoordinate für Gesprächspartner auf [%d,%d,%d].\n", + Param1, Param2, Param3); + Interlocutor->startx = Param1; + Interlocutor->starty = Param2; + Interlocutor->startz = Param3; + Interlocutor->SaveData(); + break; + } + + default:{ + error("TBehaviourDatabase::react (10): Ungültige Unternummer.\n"); + break; + } + } + break; + } + } + } + }while(Repeat); + + if(StartToDo){ + Npc->ToDoWait(TalkDelay); + Npc->ToDoStart(); + if(Situation != BUSY){ + Npc->LastTalk = (TalkDelay / 1000) + RoundNr; + } + } +} + +// Monster Homes +// ============================================================================= +void StartMonsterhomeTimer(int Nr){ + if(Nr < 1 || Nr > Monsterhomes){ + error("StartMonsterhomeTimer: Ungültige Monsterhome-Nummer %d.\n", Nr); + return; + } + + TMonsterhome *MH = Monsterhome.at(Nr); + if(MH->Timer > 0){ + error("StartMonsterhomeTimer: Zähler läuft schon.\n"); + return; + } + + if(MH->ActMonsters >= MH->MaxMonsters){ + error("StartMonsterhomeTimer: Maximale Monsterzahl schon erreicht.\n"); + error("# Monsterhome mit Rasse %d an [%d,%d,%d]\n", MH->Race, MH->x, MH->y, MH->z); + return; + } + + int MaxTimer = MH->RegenerationTime; + int NumPlayers = GetNumberOfPlayers(); + if(NumPlayers > 800){ + MaxTimer = (MaxTimer * 2) / 5; + }else if(NumPlayers > 200){ + MaxTimer = (MaxTimer * 200) / ((NumPlayers / 2) + 100); + } + + MH->Timer = random(MaxTimer / 2, MaxTimer); +} + +void LoadMonsterhomes(void){ + print(1, "Initialisiere Monsterhomes ...\n"); + + char FileName[4096]; + snprintf(FileName, sizeof(FileName), "%s/monster.db", DATAPATH); + + TReadScriptFile Script; + Script.open(FileName); + + Monsterhomes = 0; + while(true){ + int Race = Script.readNumber(); + if(Race == 0){ + break; + } + + Monsterhomes += 1; + TMonsterhome *MH = Monsterhome.at(Monsterhomes); + MH->Race = Race; + MH->x = Script.readNumber(); + MH->y = Script.readNumber(); + MH->z = Script.readNumber(); + MH->Radius = Script.readNumber(); + MH->MaxMonsters = Script.readNumber(); + MH->ActMonsters = 0; + MH->RegenerationTime = Script.readNumber(); + MH->Timer = 0; + + if(!IsOnMap(MH->x, MH->y, MH->z)){ + print(1, "WARNUNG: Monsterhome [%d,%d,%d] befindet sich außerhalb der Karte.\n", MH->x, MH->y, MH->z); + } + } + + print(1, "%d Monsterhomes geladen.\n", Monsterhomes); + Script.close(); + + for(int i = 0; i < Monsterhomes; i += 1){ + TMonsterhome *MH = Monsterhome.at(i); + for (int j = 0; j < MH->MaxMonsters; j += 1){ + int SpawnX = MH->x; + int SpawnY = MH->y; + int SpawnZ = MH->z; + int SpawnRadius = MH->Radius; + + if(j == 0){ + if(SpawnRadius > 1){ + SpawnRadius = 1; + } + }else{ + if(SpawnRadius > 10){ + SpawnRadius = 10; + } + + // NOTE(fusion): `SearchSpawnField` performs an extended search + // if the radius is negative. + SpawnRadius = -SpawnRadius; + } + + if(SearchSpawnField(&SpawnX, &SpawnY, &SpawnZ, SpawnRadius, false)){ + CreateMonster(MH->Race, SpawnX, SpawnY, SpawnZ, i, 0, false); + MH->ActMonsters += 1; + } + } + + if(MH->Timer > 0){ + error("LoadMonsterhomes: Timer läuft schon (Rasse %d an [%d,%d,%d]).\n", + MH->Race, MH->x, MH->y, MH->z); + }else if(MH->ActMonsters < MH->MaxMonsters){ + StartMonsterhomeTimer(i); + } + } +} + +void ProcessMonsterhomes(void){ + for(int i = 0; i < Monsterhomes; i += 1){ + TMonsterhome *MH = Monsterhome.at(i); + if(MH->Timer > 0){ + MH->Timer -= 1; + } + + if(MH->Timer > 0){ + continue; + } + + int MaxRadius = MH->Radius; + if(MaxRadius > 10){ + MaxRadius = 10; + } + + TFindCreatures Search(MaxRadius + 9, MaxRadius + 7, MH->x, MH->y, FIND_PLAYERS); + while(true){ + uint32 CharacterID = Search.getNext(); + if(CharacterID == 0){ + break; + } + + TPlayer *Player = GetPlayer(CharacterID); + if(Player == NULL){ + error("ProcessMonsterhomes: Kreatur existiert nicht.\n"); + break; + } + + // TODO(fusion): There is probably a helper function to check whether + // a floor is visible from another. + if(Player->posz <= 7){ + if(MH->z > 7){ + continue; + } + }else{ + if(std::abs(Player->posz - MH->z) > 2){ + continue; + } + } + + int DistanceX = std::abs(Player->posx - MH->x); + int DistanceY = std::abs(Player->posy - MH->y); + int Radius = std::max(DistanceX - 9, DistanceY - 7); + if(Radius < MaxRadius){ + MaxRadius = Radius; + } + } + + if(MaxRadius >= 0){ + int SpawnX = MH->x; + int SpawnY = MH->y; + int SpawnZ = MH->z; + int SpawnRadius = MaxRadius; + + if(MH->ActMonsters == 0){ + if(SpawnRadius > 1){ + SpawnRadius = 1; + } + }else{ + // NOTE(fusion): `SearchSpawnField` performs an extended search + // if the radius is negative. + SpawnRadius = -SpawnRadius; + } + + if(SearchSpawnField(&SpawnX, &SpawnY, &SpawnZ, SpawnRadius, false)){ + CreateMonster(MH->Race, SpawnX, SpawnY, SpawnZ, i, 0, false); + MH->ActMonsters += 1; + + // TODO(fusion): Not sure why this check is here. + if(MH->Timer > 0){ + error("ProcessMonsterhomes: Timer läuft schon (Rasse %d an [%d,%d,%d]).\n", + MH->Race, SpawnX, SpawnY, SpawnZ); + } + } + } + + if(MH->ActMonsters < MH->MaxMonsters){ + StartMonsterhomeTimer(i); + } + } +} + +void NotifyMonsterhomeOfDeath(int Nr){ + if(Nr < 1 || Nr > Monsterhomes){ + error("NotifyMonsterhomeOfDeath: Ungültige Monsterhome-Nummer %d.\n", Nr); + return; + } + + TMonsterhome *MH = Monsterhome.at(Nr); + if(MH->ActMonsters < 1){ + error("NotifyMonsterhomeOfDeath: Monsterhome hat keine lebenden Kreaturen.\n"); + return; + } + + MH->ActMonsters -= 1; + if(MH->ActMonsters >= MH->MaxMonsters){ + error("NotifyMonsterhomeOfDeath: Monsterhome %d hatte zu viele Monster (%d statt %d).\n", + Nr, (MH->ActMonsters + 1), MH->MaxMonsters); + return; + } + + if(MH->Timer == 0){ + StartMonsterhomeTimer(Nr); + } +} + +bool MonsterhomeInRange(int Nr, int x, int y, int z){ + if(Nr == 0){ + return true; + } + + if(Nr < 1 || Nr > Monsterhomes){ + error("MonsterhomeInRange: Ungültige Monsterhome-Nummer %d.\n", Nr); + return false; + } + + TMonsterhome *MH = Monsterhome.at(Nr); + return std::abs(z - MH->z) <= 2 + && std::abs(x - MH->x) <= MH->Radius + && std::abs(y - MH->y) <= MH->Radius; +} + +// TNonplayer +// ============================================================================= +TNonplayer::TNonplayer(void) : TCreature() { + this->State = SLEEPING; +} + +TNonplayer::~TNonplayer(void){ + this->DelInList(); +} + +void TNonplayer::SetInList(void){ + TCreature::SetInCrList(); + *NonplayerList.at(FirstFreeNonplayer) = this; + FirstFreeNonplayer += 1; +} + +void TNonplayer::DelInList(void){ + bool Removed = false; + for(int i = 0; i < FirstFreeNonplayer; i += 1){ + if(*NonplayerList.at(i) == this){ + FirstFreeNonplayer -= 1; + *NonplayerList.at(i) = *NonplayerList.at(FirstFreeNonplayer); + *NonplayerList.at(FirstFreeNonplayer) = NULL; + Removed = true; + break; + } + } + + if(!Removed){ + error("TNonplayer::DelInList: Kreatur nicht gefunden.\n"); + } +} + +// TNPC +// ============================================================================= +TNPC::TNPC(const char *FileName) : + TNonplayer(), + QueuedPlayers(0, 9, 10), + QueuedAddresses(0, 9, 10) +{ + this->Type = NPC; + this->posz = 255; + this->Interlocutor = 0; + this->Topic = 0; + this->Price = 0; + this->Amount = 1; + this->TypeID = 0; + this->Data = 0; + this->LastTalk = 0; + this->QueueLength = 0; + this->Behaviour = NULL; + + TReadScriptFile Script; + Script.open(FileName); + while(true){ + Script.nextToken(); + if(Script.Token == ENDOFFILE){ + Script.close(); + break; + } + + if(Script.Token != IDENTIFIER){ + Script.error("identifier expected"); + } + + char Identifier[MAX_IDENT_LENGTH]; + strcpy(Identifier, Script.getIdentifier()); + Script.readSymbol('='); + + if(strcmp(Identifier, "name") == 0){ + strcpy(this->Name, Script.readString()); + }else if(strcmp(Identifier, "sex") == 0){ + const char *Sex = Script.readIdentifier(); + if(strcmp(Sex, "male") == 0){ + this->Sex = 1; + }else if(strcmp(Sex, "female") == 0){ + this->Sex = 2; + }else{ + Script.error("unknown constant"); + } + }else if(strcmp(Identifier, "race") == 0){ + this->Race = Script.readNumber(); + this->SetSkills(this->Race); + }else if(strcmp(Identifier, "outfit") == 0){ + this->OrgOutfit = ReadOutfit(&Script); + this->Outfit = this->OrgOutfit; + }else if(strcmp(Identifier, "home") == 0){ + Script.readCoordinate(&this->startx, &this->starty, &this->startx); + this->posx = this->startx; + this->posy = this->starty; + this->posz = this->startz; + }else if(strcmp(Identifier, "radius") == 0){ + this->Radius = Script.readNumber(); + }else if(strcmp(Identifier, "gostrength") == 0){ + if(this->Race == 0){ + Script.error("gostrength before race in npc-script-file"); + } + int GoStrength = Script.readNumber(); + this->Skills[SKILL_GO_STRENGTH]->Act = GoStrength; + this->Skills[SKILL_GO_STRENGTH]->Max = GoStrength; + }else if(strcmp(Identifier, "behaviour") == 0){ + if(this->Behaviour != NULL){ + Script.error("behaviour database specified twice for NPC"); + } + this->Behaviour = new TBehaviourDatabase(&Script); + }else{ + Script.error("unknown npc property"); + } + } + + if(this->Name[0] == 0){ + throw "no name specified for NPC"; + } + + if(this->posz == 255){ + throw "no startpoint specified for NPC"; + } + + if(this->Behaviour == NULL){ + throw "no behaviour database specified for NPC"; + } + + if(!IsOnMap(this->posx, this->posy, this->posz)){ + print(1, "WARNUNG: NPC '%s' steht außerhalb der Karte.\n", this->Name); + return; + } + + this->SetID(0); + this->SetInList(); + if(!this->SetOnMap()){ + print(1, "WARNUNG: Kann NPC \'%s\' nicht setzen.\n", this->Name); + return; + } + + this->ToDoYield(); +} + +TNPC::~TNPC(void){ + delete this->Behaviour; +} + +bool TNPC::MovePossible(int x, int y, int z, bool Execute, bool Jump){ + return CoordinateFlag(x, y, z, BANK) + && !CoordinateFlag(x, y, z, UNPASS) + && !CoordinateFlag(x, y, z, AVOID) + && z == this->startz + && std::abs(x - this->startx) <= this->Radius + && std::abs(y - this->starty) <= this->Radius + && !IsHouse(x, y, z); +} + +void TNPC::TalkStimulus(uint32 SpeakerID, const char *Text){ + if(SpeakerID == this->ID){ + return; + } + + if(Text == NULL){ + error("TNPC::TalkStimulus: Übergebener Text existiert nicht.\n"); + return; + } + + if(this->State == TALKING || this->QueueLength != 0){ + uint32 InterlocutorID = this->Interlocutor; + if(SpeakerID == InterlocutorID){ + this->LastTalk = RoundNr; + this->Behaviour->react(this, Text, DEFAULT); + }else{ + this->Interlocutor = SpeakerID; + this->Behaviour->react(this, Text, BUSY); + this->Interlocutor = InterlocutorID; + } + }else{ + this->ToDoClear(); + this->ChangeState(TALKING, false); + this->Interlocutor = SpeakerID; + this->LastTalk = RoundNr; + this->Behaviour->react(this, Text, ADDRESS); + if(this->State == TALKING){ + this->TurnToInterlocutor(); + } + } +} + +void TNPC::DamageStimulus(uint32 AttackerID, int Damage, int DamageType){ + // no-op +} + +void TNPC::IdleStimulus(void){ + if(this->State == TALKING){ + if((this->LastTalk + 30) > RoundNr){ + this->ToDoWait(2000); + this->ToDoStart(); + return; + } + + this->Behaviour->react(this, "", VANISH); + this->ChangeState(IDLE, false); + } + + if(this->State == IDLE){ + while(this->QueueLength > 0){ + uint32 InterlocutorID = *this->QueuedPlayers.at(0); + uint32 Text = *this->QueuedAddresses.at(0); + + // NOTE(fusion): Ordered removal. + this->QueueLength -= 1; + for(int i = 0; i < this->QueueLength; i += 1){ + *this->QueuedPlayers.at(i) = *this->QueuedPlayers.at(i + 1); + *this->QueuedAddresses.at(i) = *this->QueuedAddresses.at(i + 1); + } + + this->ToDoClear(); + + TCreature *Interlocutor = GetCreature(InterlocutorID); + if(Interlocutor != NULL){ + this->ChangeState(TALKING, false); + this->Interlocutor = InterlocutorID; + this->Behaviour->react(this, GetDynamicString(Text), ADDRESSQUEUE); + }else{ + error("TNPC::IdleStimulus: Gesprächspartner existiert nicht.\n"); + } + + DeleteDynamicString(Text); + if(this->State == TALKING){ + this->TurnToInterlocutor(); + this->LastTalk = RoundNr; + return; + } + } + + if(!this->LockToDo){ + TFindCreatures Search(10, 10, this->ID, FIND_PLAYERS); + if(Search.getNext() == 0){ + this->ChangeState(SLEEPING, false); + return; + } + + bool FoundDest = false; + int DestX, DestY, DestZ; + for(int i = 0; i < 10; i += 1){ + DestX = this->posx; + DestY = this->posy; + DestZ = this->posz; + switch(rand() % 4){ + case 0: DestX -= 1; break; + case 1: DestX += 1; break; + case 2: DestY -= 1; break; + case 3: DestY += 1; break; + } + + if(this->MovePossible(DestX, DestY, DestZ, true, false)){ + FoundDest = true; + break; + } + } + + if(!FoundDest){ + this->ToDoWait(2000); + this->ToDoStart(); + return; + } + + try{ + this->ToDoGo(DestX, DestY, DestZ, true, INT_MAX); + this->ToDoWait(2000); + this->ToDoStart(); + }catch(RESULT r){ + error("TNPC::IdleStimulus: Exception %d!\n", r); + } + } + } +} + +void TNPC::CreatureMoveStimulus(uint32 CreatureID, int Type){ + for(int i = 0; i < this->QueueLength; i += 1){ + uint32 QueuedPlayerID = *this->QueuedPlayers.at(i); + if(CreatureID != QueuedPlayerID && CreatureID != this->ID){ + continue; + } + + TCreature *QueuedPlayer = GetCreature(QueuedPlayerID); + if(Type != OBJECT_DELETED + && QueuedPlayer->posz == this->posz + && std::abs(QueuedPlayer->posx - this->posx) < 5 + && std::abs(QueuedPlayer->posy - this->posy) < 4){ + continue; + } + + // NOTE(fusion): Ordered removal. + this->QueueLength -= 1; + for(int j = i; j < this->QueueLength; j += 1){ + *this->QueuedPlayers.at(j) = *this->QueuedPlayers.at(j + 1); + *this->QueuedAddresses.at(j) = *this->QueuedAddresses.at(j + 1); + } + + // NOTE(fusion): The ordered removal has shifted queued players back one + // place so we need to check the current queue position again. + i -= 1; + } + + if(this->State == TALKING || this->State == LEAVING){ + if(CreatureID == this->Interlocutor || CreatureID == this->ID){ + TCreature *Interlocutor = GetCreature(this->Interlocutor); + if(Interlocutor == NULL){ + error("TNPC::CreatureMoveStimulus: Gesprächspartner existiert nicht.\n"); + this->ChangeState(IDLE, true); + return; + } + + if(Type != OBJECT_DELETED){ + this->Rotate(Interlocutor); + } + + if(this->State == TALKING){ + if(Type == OBJECT_DELETED + || Interlocutor->posz != this->posz + || std::abs(Interlocutor->posx - this->posx) >= 5 + || std::abs(Interlocutor->posy - this->posy) >= 4){ + this->Behaviour->react(this, "", VANISH); + this->ChangeState(IDLE, true); + } + } + } + } + + if(CreatureID != this->ID + && this->State == SLEEPING + && Type != OBJECT_DELETED){ + this->ChangeState(IDLE, true); + } +} + +void TNPC::GiveTo(ObjectType Type, int Amount){ + if(Amount == 0){ + return; + } + + if(Type.isMapContainer() || Type.getName(1) == NULL){ + error("TNPC::GiveTo: %s will Objekte vom Typ %d erschaffen.\n", + this->Name, Type.TypeID); + return; + } + + Log("npc", "%s -> %u: %d %s\n", this->Name, this->Interlocutor, Amount, Type.getName(1)); + + if(Type.getFlag(CUMULATIVE)){ + while(Amount > 0){ + int StackSize = std::min(Amount, 100); + CreateAtCreature(this->Interlocutor, Type, StackSize); + Amount -= StackSize; + } + }else{ + while(Amount > 0){ + CreateAtCreature(this->Interlocutor, Type, this->Data); + Amount -= 1; + } + } +} + +void TNPC::GetFrom(ObjectType Type, int Amount){ + if(Amount > 0){ + Log("npc", "%s <- %u: %d %s\n", this->Name, this->Interlocutor, Amount, Type.getName(1)); + DeleteAtCreature(this->Interlocutor, Type, Amount, this->Data); + } +} + +void TNPC::GiveMoney(int Amount){ + int Crystal = (Amount / 10000); + int Platinum = (Amount % 10000) / 100; + int Gold = (Amount % 10000) % 100; + this->GiveTo(GetSpecialObject(MONEY_TENTHOUSAND), Crystal); + this->GiveTo(GetSpecialObject(MONEY_HUNDRED), Platinum); + this->GiveTo(GetSpecialObject(MONEY_ONE), Gold); +} + +void TNPC::GetMoney(int Amount){ + int Crystal = CountInventoryObjects(this->Interlocutor, GetSpecialObject(MONEY_TENTHOUSAND), 0); + int Platinum = CountInventoryObjects(this->Interlocutor, GetSpecialObject(MONEY_HUNDRED), 0); + int Gold = CountInventoryObjects(this->Interlocutor, GetSpecialObject(MONEY_ONE), 0); + CalculateChange(Amount, &Gold, &Platinum, &Crystal); + + ASSERT(Crystal >= 0); + if(Crystal > 0){ + this->GetFrom(GetSpecialObject(MONEY_TENTHOUSAND), Crystal); + } + + if(Platinum > 0){ + this->GetFrom(GetSpecialObject(MONEY_HUNDRED), Platinum); + }else if(Platinum < 0){ + this->GiveTo(GetSpecialObject(MONEY_HUNDRED), -Platinum); + } + + if(Gold > 0){ + this->GetFrom(GetSpecialObject(MONEY_ONE), Gold); + }else if(Gold < 0){ + this->GiveTo(GetSpecialObject(MONEY_ONE), -Gold); + } +} + +void TNPC::Enqueue(uint32 InterlocutorID, const char *Text){ + if(InterlocutorID == 0){ + error("TNPC::Enqueue: Gesprächspartner ist Null.\n"); + return; + } + + if(Text == NULL){ + error("TNPC::Enqueue: Text ist NULL.\n"); + return; + } + + bool AlreadyQueued = false; + for(int i = 0; i < this->QueueLength; i += 1){ + if(*this->QueuedPlayers.at(i) == InterlocutorID){ + AlreadyQueued = true; + break; + } + } + + if(!AlreadyQueued){ + *this->QueuedPlayers.at(this->QueueLength) = InterlocutorID; + *this->QueuedAddresses.at(this->QueueLength) = AddDynamicString(Text); + this->QueueLength += 1; + } +} + +void TNPC::TurnToInterlocutor(void){ + TCreature *Interlocutor = GetCreature(this->Interlocutor); + if(Interlocutor == NULL){ + error("TNPC::TurnToInterlocutor: Gesprächspartner existiert nicht.\n"); + return; + } + + this->Rotate(Interlocutor); +} + +void TNPC::ChangeState(STATE NewState, bool Stimulus){ + this->State = NewState; + if(Stimulus){ + this->ToDoYield(); + } +} + +void ChangeNPCState(TCreature *Npc, int NewState, bool Stimulus){ + if(Npc == NULL){ + error("ChangeNPCState: npc ist NULL.\n"); + return; + } + + if(Npc->Type != NPC){ + error("ChangeNPCState: npc ist kein NPC.\n"); + return; + } + + ((TNPC*)Npc)->ChangeState((STATE)NewState, Stimulus); +} + +// TMonster +// ============================================================================= +TMonster::TMonster(int Race, int x, int y, int z, int Home, uint32 MasterID) : + TNonplayer() +{ + this->Type = MONSTER; + this->Race = Race; + this->startx = x; + this->starty = y; + this->startz = z; + this->posx = x; + this->posx = y; + this->posx = z; + this->State = IDLE; + this->Home = Home; + this->Master = MasterID; + this->Target = 0; + + while(this->Master != 0){ + TCreature *Master = GetCreature(this->Master); + // TODO(fusion): Do we actually want to return here? + if(Master == NULL){ + error("TMonster::TMonster: Master existiert nicht.\n"); + return; + } + + if(Master->Type != MONSTER || ((TMonster*)Master)->Master != 0){ + this->LifeEndRound = Master->LifeEndRound; + Master->SummonedCreatures += 1; + break; + } + + error("TMonster::TMonster: Kinder dürfen keine eigenen Kinder erschaffen.\n"); + this->Master = ((TMonster*)Master)->Master; + } + + if(RaceData[Race].Article[0] == 0){ + strcpy(this->Name, RaceData[Race].Name); + }else{ + snprintf(this->Name, sizeof(this->Name), "%s %s", + RaceData[Race].Article, RaceData[Race].Name); + } + + this->SetSkills(Race); + this->OrgOutfit = RaceData[Race].Outfit; + this->Outfit = RaceData[Race].Outfit; + this->SetID(0); + this->SetInList(); + if(!this->SetOnMap()){ + error("TMonster::TMonster: Kann Monster nicht auf die Karte setzen.\n"); + return; + } + + try{ + if(this->Master == 0 && RaceData[Race].Items > 0){ + Object Bag = Create(GetBodyContainer(this->ID, INVENTORY_BAG), + GetSpecialObject(DEFAULT_CONTAINER), + 0); + for(int i = 0; i < RaceData[Race].Items; i += 1){ + TItemData *ItemData = RaceData[Race].Item.at(i); + if(random(0, 999) > ItemData->Probability){ + continue; + } + + ObjectType ItemType = ItemData->Type; + int Amount = random(1, ItemData->Maximum); + int Repeat = 1; + if(!ItemType.getFlag(CUMULATIVE)){ + Repeat = Amount; + Amount = 0; + } + + for(int j = 0; j < Repeat; j += 1){ + // TODO(fusion): Same as `ProcessMonsterRaids`. + Object Item = NONE; + try{ + if(ItemType.getFlag(WEAPON) + || ItemType.getFlag(SHIELD) + || ItemType.getFlag(BOW) + || ItemType.getFlag(THROW) + || ItemType.getFlag(WAND) + || ItemType.getFlag(WEAROUT) + || ItemType.getFlag(EXPIRE) + || ItemType.getFlag(EXPIRESTOP)){ + Item = Create(Bag, ItemType, 0); + }else{ + Item = CreateAtCreature(this->ID, ItemType, Amount); + } + }catch(RESULT r){ + error("TMonster::TMonster: Exception %d bei Rasse %d, ggf." + " CarryStrength erhöhen.\n", r, Race); + break; + } + + // NOTE(fusion): Prevent items from being dropped onto the map. + if(Item.getContainer().getObjectType().isMapContainer()){ + error("TMonster::TMonster: Objekt fällt auf die Karte." + " CarryStrength für Rasse %d erhöhen.\n", Race); + Delete(Item, -1); + } + } + } + + // NOTE(fusion): `Bag` could be empty if we failed to add any + // items to it in the loop above. + if(GetFirstContainerObject(Bag) == NONE){ + Delete(Bag, -1); + } + } + }catch(RESULT r){ + error("TMonster::TMonster: Exception %d bei Rasse %d.\n", r, Race); + } + + this->Combat.CheckCombatValues(); + this->Combat.SetAttackMode(ATTACK_MODE_BALANCED); + this->ToDoYield(); +} + +TMonster::~TMonster(void){ + if(!this->IsDead){ + GraphicalEffect(this->posx, this->posy, this->posz, EFFECT_POFF); + }else if(this->Master == 0){ + this->Combat.DistributeExperiencePoints(RaceData[this->Race].ExperiencePoints); + } + + if(this->Master != 0){ + TCreature *Master = GetCreature(this->Master); + if(Master != NULL && Master->SummonedCreatures > 0){ + Master->SummonedCreatures -= 1; + } + } + + if(this->Home != 0){ + NotifyMonsterhomeOfDeath(this->Home); + } +} diff --git a/src/crplayer.cc b/src/crplayer.cc index 5c28855..2660c04 100644 --- a/src/crplayer.cc +++ b/src/crplayer.cc @@ -8,8 +8,8 @@ #include "stubs.hh" static Semaphore PlayerMutex(1); -static int FirstFreePlayer; static vector PlayerList(0, 100, 10, NULL); +static int FirstFreePlayer; static Semaphore PlayerDataPoolMutex(1); static TPlayerData PlayerDataPool[2000]; diff --git a/src/enums.hh b/src/enums.hh index 7eb2671..6d6baf0 100644 --- a/src/enums.hh +++ b/src/enums.hh @@ -31,6 +31,74 @@ enum AttackMode: uint8 { ATTACK_MODE_DEFENSIVE = 3, }; +enum BehaviourActionType: int { + BEHAVIOUR_ACTION_NONE = 0, + BEHAVIOUR_ACTION_REPLY = 1, + BEHAVIOUR_ACTION_SET_VARIABLE = 2, + BEHAVIOUR_ACTION_SET_SKILL = 3, + BEHAVIOUR_ACTION_FUNCTION2 = 4, + BEHAVIOUR_ACTION_FUNCTION1 = 5, + BEHAVIOUR_ACTION_FUNCTION0 = 6, + BEHAVIOUR_ACTION_CHANGESTATE = 7, + BEHAVIOUR_ACTION_SET_SKILL_TIMER = 8, + BEHAVIOUR_ACTION_REPEAT = 9, + BEHAVIOUR_ACTION_FUNCTION3 = 10, +}; + +enum BehaviourConditionType: int { + BEHAVIOUR_CONDITION_NONE = 0, + BEHAVIOUR_CONDITION_TEXT = 1, + BEHAVIOUR_CONDITION_PROPERTY = 2, + BEHAVIOUR_CONDITION_PARAMETER = 3, + BEHAVIOUR_CONDITION_EXPRESSION = 4, + BEHAVIOUR_CONDITION_SHORTCIRCUIT = 5, +}; + +enum BehaviourNodeType: int { + BEHAVIOUR_NODE_NONE = 0, + BEHAVIOUR_NODE_CMP_LT = 1, + BEHAVIOUR_NODE_CMP_GT = 2, + BEHAVIOUR_NODE_CMP_EQ = 3, + BEHAVIOUR_NODE_CMP_NEQ = 4, + BEHAVIOUR_NODE_CMP_LE = 5, + BEHAVIOUR_NODE_CMP_GE = 6, + BEHAVIOUR_NODE_ADD = 7, + BEHAVIOUR_NODE_SUB = 8, + BEHAVIOUR_NODE_MUL = 9, + BEHAVIOUR_NODE_PARAMETER = 10, + BEHAVIOUR_NODE_NUMBER = 11, + BEHAVIOUR_NODE_TOPIC = 12, + BEHAVIOUR_NODE_PRICE = 13, + BEHAVIOUR_NODE_AMOUNT = 14, + BEHAVIOUR_NODE_SKILL = 15, + BEHAVIOUR_NODE_COUNT = 16, + BEHAVIOUR_NODE_COUNTMONEY = 17, + BEHAVIOUR_NODE_TYPE = 18, + BEHAVIOUR_NODE_DATA = 19, + BEHAVIOUR_NODE_SPELLKNOWN = 20, + BEHAVIOUR_NODE_SPELLLEVEL = 21, + BEHAVIOUR_NODE_RANDOM = 22, + BEHAVIOUR_NODE_QUESTVALUE = 23, +}; + +enum BehaviourProperty: int { + BEHAVIOUR_PROPERTY_NONE = 0, + BEHAVIOUR_PROPERTY_ADDRESS = 1, + BEHAVIOUR_PROPERTY_BUSY = 2, + BEHAVIOUR_PROPERTY_VANISH = 3, + BEHAVIOUR_PROPERTY_MALE = 4, + BEHAVIOUR_PROPERTY_FEMALE = 5, + BEHAVIOUR_PROPERTY_KNIGHT = 6, + BEHAVIOUR_PROPERTY_PALADIN = 7, + BEHAVIOUR_PROPERTY_SORCERER = 8, + BEHAVIOUR_PROPERTY_DRUID = 9, + BEHAVIOUR_PROPERTY_PREMIUM = 10, + BEHAVIOUR_PROPERTY_PROMOTED = 11, + BEHAVIOUR_PROPERTY_PZBLOCK = 12, + BEHAVIOUR_PROPERTY_NONPVP = 13, + BEHAVIOUR_PROPERTY_PVPENFORCED = 14, +}; + enum BloodType: int { BT_BLOOD = 0, BT_SLIME = 1, @@ -58,6 +126,37 @@ enum Color: int { COLOR_WHITE = 215, }; +// TODO(fusion): These are used with `TMoveUseCondition`. Probably add a +// `MOVEUSE` prefix not to mix with `TBehaviourCondition`? +enum ConditionType: int { + CONDITION_ISPOSITION = 0, + CONDITION_ISTYPE = 1, + CONDITION_ISCREATURE = 2, + CONDITION_ISPLAYER = 3, + CONDITION_HASFLAG = 4, + CONDITION_HASTYPEATTRIBUTE = 5, + CONDITION_HASINSTANCEATTRIBUTE = 6, + CONDITION_HASTEXT = 7, + CONDITION_ISPEACEFUL = 8, + CONDITION_MAYLOGOUT = 9, + CONDITION_HASPROFESSION = 10, + CONDITION_HASLEVEL = 11, + CONDITION_HASRIGHT = 12, + CONDITION_HASQUESTVALUE = 13, + CONDITION_TESTSKILL = 14, + CONDITION_COUNTOBJECTS = 15, + CONDITION_COUNTOBJECTSONMAP = 16, + CONDITION_ISOBJECTTHERE = 17, + CONDITION_ISCREATURETHERE = 18, + CONDITION_ISPLAYERTHERE = 19, + CONDITION_ISOBJECTININVENTORY = 20, + CONDITION_ISPROTECTIONZONE = 21, + CONDITION_ISHOUSE = 22, + CONDITION_ISHOUSEOWNER = 23, + CONDITION_ISDRESSED = 24, + CONDITION_RANDOM = 25, +}; + enum CONNECTIONSTATE: int { CONNECTION_FREE = 0, CONNECTION_ASSIGNED = 1, @@ -460,6 +559,14 @@ enum SecureMode: uint8 { SECURE_MODE_ENABLED = 1, }; +enum SITUATION: int { + DEFAULT = 0, + ADDRESS = 1, + ADDRESSQUEUE = 2, + BUSY = 3, + VANISH = 4, +}; + // NOTE(fusion): Not in debug symbols. enum Skill: int { SKILL_LEVEL = 0, diff --git a/src/stubs.hh b/src/stubs.hh index e3b694e..d8b9839 100644 --- a/src/stubs.hh +++ b/src/stubs.hh @@ -21,7 +21,6 @@ extern void RemoveBuddyOrder(TCreature *Creature, uint32 BuddyID); extern void ChangeGuests(uint16 HouseID, TPlayer *Player, const char *Text); extern void ChangeSubowners(uint16 HouseID, TPlayer *Player, const char *Text); extern void ChangeNameDoor(Object Door, TPlayer *Player, const char *Text); -extern void ChangeNPCState(TCreature *Npc, int NewState, bool Stimulus); extern void CharacterDeathOrder(TCreature *Creature, int OldLevel, uint32 Offender, const char *Remark, bool Unjustified); extern void CleanHouseField(int x, int y, int z); @@ -43,7 +42,6 @@ extern void LogoutOrder(TPlayer *Player); extern void PrepareHouseCleanup(void); extern void FinishHouseCleanup(void); extern void PlayerlistOrder(int NumberOfPlayers, char *PlayerNames, int *PlayerLevels, int *PlayerProfessions); -extern void ProcessMonsterhomes(void); extern void ProcessReaderThreadReplies(TRefreshSectorFunction *RefreshSector, TSendMailsFunction *SendMails); extern void ProcessWriterThreadReplies(void); extern void PunishmentOrder(TCreature *Creature, const char *Name, const char *IPAddress, -- cgit v1.2.3