• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Saga system

Ysha

New Member
Joined
Jul 31, 2019
Messages
13
Reaction score
0
Hello, I have a problem with my saga system, when the player gets storage close to the monster then the monster doesn't attack and you have to move away from him to lose his goal.

How to fix this?


I have this code in my source:

 
No idea if this is gonna fix it but have you tried using monster->removeTarget + monster->addTarget after adding storagevalue?
 
Hello, I have a problem with my saga system, when the player gets storage close to the monster then the monster doesn't attack and you have to move away from him to lose his goal.

How to fix this?


I have this code in my source:

I'm using google translator *

If you use this saga system, this will happen when you gain storage on the monster screen, for example, you get 8000.1 if a monster with 8000.2 storage is on the screen, it will attack, then let it out, which It works normally!
 
I'm using google translator *

If you use this saga system, this will happen when you gain storage on the monster screen, for example, you get 8000.1 if a monster with 8000.2 storage is on the screen, it will attack, then let it out, which It works normally!


The point is that, I wants to make the monster attack when you get storage if the monster is on screen.
 
UPDATE!

When i compile tfs have this error


C++:
monster.cpp: In member function 'bool Monster::isTarget(Creature*)':
monster.cpp:519:18: error: 'class Creature' has no member named 'isSagaMonster'; did you mean 'getMonster'?
     if(creature->isSagaMonster()){
                  ^~~~~~~~~~~~~
monster.cpp:520:82: error: 'class Creature' has no member named 'isSagaMonster'; did you mean 'getMonster'?
         return (!creature->isRemoved() && creature->isAttackable() && (creature->isSagaMonster() && getStorage(8000, creature->sagaNumber)) && creature->getZone() != ZONE_PROTECTION
                                                                                  ^~~~~~~~~~~~~
monster.cpp:520:128: error: 'class Creature' has no member named 'sagaNumber'
         return (!creature->isRemoved() && creature->isAttackable() && (creature->isSagaMonster() && getStorage(8000, creature->sagaNumber)) && creature->getZone() != ZONE_PROTECTION

Code:


C++:
bool Monster::isTarget(Creature* creature)
{
    if(creature->isSagaMonster()){
        return (!creature->isRemoved() && creature->isAttackable() && (creature->isSagaMonster() && getStorage(8000, creature->sagaNumber)) && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }else{
    return (!creature->isRemoved() && creature->isAttackable() && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }
}

Anyone have ideas?
 
I tried this before.

Here is error after remove "creature->"
C++:
In file included from monster.cpp:19:0:
monster.h:63:27: note: declared here
         const std::string sagaNumber() const {return mType->sagaNumber;}
 
Without creature-> it is correct.
You probalby have error here:
getStorage(8000, sagaNumber)

Ym.. what tfs are you using?
 
Try:
creature->getStorage(8000, sagaNumber)
or
std::string value = "1";
creature->getStorage(8000, value) == sagaNumber
(Yolo)

if it display same error.. show that lanes xd
 
I tried both options and again..

error in 2 option

C++:
monster.cpp: In member function 'bool Monster::isTarget(Creature*)':
monster.cpp:520:18: error: 'class Creature' has no member named 'isSagaMonster'; did you mean 'getMonster'?
     if(creature->isSagaMonster()){
                  ^~~~~~~~~~~~~
monster.cpp:521:150: error: expected ')' before '->' token
         return (!creature->isRemoved() && creature->isAttackable() && isSagaMonster() && creature->getStorage(8000, value) == sagaNumber( && creature->getZone() != ZONE_PROTECTION
                                                                                                                                                      ^~
monster.cpp:522:88: error: no matching function for call to 'Monster::sagaNumber(void*)'
             && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
                                                                                        ^
In file included from monster.cpp:19:0:
monster.h:63:27: note: candidate: const string Monster::sagaNumber() const
         const std::string sagaNumber() const {return mType->sagaNumber;}
                           ^~~~~~~~~~
monster.h:63:27: note:   candidate expects 0 arguments, 1 provided
monster.cpp:522:89: error: expected ')' before ';' token
             && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
                                                                                         ^
monster.cpp:521:142: error: label 'creature' used but not defined
         return (!creature->isRemoved() && creature->isAttackable() && isSagaMonster() && creature->getStorage(8000, value) == sagaNumber( && creature->getZone() != ZONE_PROTECTION

Code:

Code:
bool Monster::isTarget(Creature* creature)
{
    std::string value = "1";
    if(creature->isSagaMonster()){
        return (!creature->isRemoved() && creature->isAttackable() && isSagaMonster() && creature->getStorage(8000, value) == sagaNumber( && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }else{
    return (!creature->isRemoved() && creature->isAttackable() && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }
}
I may have made a mistake somewhere idk
 
But why you use again creature->isSagaMonster()
XD

C++:
bool Monster::isTarget(Creature* creature)
{
    std::string value = "1";
    if(isSagaMonster()){
        return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber) && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }else{
    return (!creature->isRemoved() && creature->isAttackable() && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }
}

Or

C++:
bool Monster::isTarget(Creature* creature)
{

    if(isSagaMonster()){
        return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, sagaNumber)) && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }else{
    return (!creature->isRemoved() && creature->isAttackable() && creature->getZone() != ZONE_PROTECTION
            && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
    }
}
 
First error:
C++:
monster.cpp: In member function 'bool Monster::isTarget(Creature*)':
monster.cpp:521:128: error: invalid use of member function 'const string Monster::sagaNumber() const' (did you forget the '()' ?)
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber) && creature->getZone() != ZONE_PROTECTION


Second error:
C++:
monster.cpp: In member function 'bool Monster::isTarget(Creature*)':
monster.cpp:521:128: error: invalid use of non-static member function 'const string Monster::sagaNumber() const'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, sagaNumber)) && creature->getZone() != ZONE_PROTECTION
                                                                                                                                ^
In file included from monster.cpp:19:0:
monster.h:63:27: note: declared here
         const std::string sagaNumber() const {return mType->sagaNumber;}
 
Now have this error:


C++:
In file included from /usr/include/x86_64-linux-gnu/c++/6/bits/c++allocator.h:33:0,
                 from /usr/include/c++/6/bits/allocator.h:46,
                 from /usr/include/c++/6/string:41,
                 from /usr/include/unicode/std_string.h:33,
                 from /usr/include/unicode/unistr.h:31,
                 from /usr/include/unicode/strenum.h:14,
                 from /usr/include/unicode/uenum.h:24,
                 from /usr/include/unicode/ucnv.h:51,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:810,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from otpch.h:28,
                 from monster.cpp:17:
/usr/include/c++/6/ext/new_allocator.h:139:5: note: candidate: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)
     operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
     ^~~~~~~~
/usr/include/c++/6/ext/new_allocator.h:139:5: note:   template argument deduction/substitution failed:
monster.cpp:521:139: note:   mismatched types 'const __gnu_cxx::new_allocator<_Tp>' and 'bool'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber() && creature->getZone() != ZONE_PROTECTION
                                                                                                                                           ^
In file included from /usr/include/c++/6/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/unicode/std_string.h:33,
                 from /usr/include/unicode/unistr.h:31,
                 from /usr/include/unicode/strenum.h:14,
                 from /usr/include/unicode/uenum.h:24,
                 from /usr/include/unicode/ucnv.h:51,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:810,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from otpch.h:28,
                 from monster.cpp:17:
/usr/include/c++/6/bits/stl_iterator.h:863:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^~~~~~~~
/usr/include/c++/6/bits/stl_iterator.h:863:5: note:   template argument deduction/substitution failed:
monster.cpp:521:139: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'bool'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber() && creature->getZone() != ZONE_PROTECTION
                                                                                                                                           ^
In file included from /usr/include/c++/6/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/unicode/std_string.h:33,
                 from /usr/include/unicode/unistr.h:31,
                 from /usr/include/unicode/strenum.h:14,
                 from /usr/include/unicode/uenum.h:24,
                 from /usr/include/unicode/ucnv.h:51,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:810,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from otpch.h:28,
                 from monster.cpp:17:
/usr/include/c++/6/bits/stl_iterator.h:856:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
     ^~~~~~~~
/usr/include/c++/6/bits/stl_iterator.h:856:5: note:   template argument deduction/substitution failed:
monster.cpp:521:139: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'bool'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber() && creature->getZone() != ZONE_PROTECTION
                                                                                                                                           ^
monster.cpp:522:89: error: expected ')' before ';' token
             && canSeeCreature(creature) && creature->getPosition().z == getPosition().z);
                                                                                         ^

Idk, I can share for you complete file monster.cpp
 
error: expected ')'

Here:

sagaNumber()

This have to look like this:

(isSagaMonster() && creature->getStorage(8000, value) == sagaNumber())
 
C++:
In file included from /usr/include/c++/6/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/unicode/std_string.h:33,
                 from /usr/include/unicode/unistr.h:31,
                 from /usr/include/unicode/strenum.h:14,
                 from /usr/include/unicode/uenum.h:24,
                 from /usr/include/unicode/ucnv.h:51,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:810,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from otpch.h:28,
                 from monster.cpp:17:
/usr/include/c++/6/bits/stl_iterator.h:863:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^~~~~~~~
/usr/include/c++/6/bits/stl_iterator.h:863:5: note:   template argument deduction/substitution failed:
monster.cpp:521:139: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'bool'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber()) && creature->getZone() != ZONE_PROTECTION
                                                                                                                                           ^
In file included from /usr/include/c++/6/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/unicode/std_string.h:33,
                 from /usr/include/unicode/unistr.h:31,
                 from /usr/include/unicode/strenum.h:14,
                 from /usr/include/unicode/uenum.h:24,
                 from /usr/include/unicode/ucnv.h:51,
                 from /usr/include/libxml2/libxml/encoding.h:31,
                 from /usr/include/libxml2/libxml/parser.h:810,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from otpch.h:28,
                 from monster.cpp:17:
/usr/include/c++/6/bits/stl_iterator.h:856:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
     ^~~~~~~~
/usr/include/c++/6/bits/stl_iterator.h:856:5: note:   template argument deduction/substitution failed:
monster.cpp:521:139: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'bool'
         return (!creature->isRemoved() && creature->isAttackable() && (isSagaMonster() && creature->getStorage(8000, value) == sagaNumber()) && creature->getZone() != ZONE_PROTECTION
 
Back
Top