mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- Random monsters will have proper strength.
- Fixed blocking of tiles under objects
This commit is contained in:
parent
11454ef4b3
commit
3c5a65af3d
@ -33,10 +33,10 @@
|
|||||||
},
|
},
|
||||||
"connections" :
|
"connections" :
|
||||||
[
|
[
|
||||||
{ "a" : "1", "b" : "5", "guard" : 1000 },
|
{ "a" : "1", "b" : "5", "guard" : 5000 },
|
||||||
{ "a" : "2", "b" : "5", "guard" : 1000 },
|
{ "a" : "2", "b" : "5", "guard" : 5000 },
|
||||||
{ "a" : "3", "b" : "5", "guard" : 1000 },
|
{ "a" : "3", "b" : "5", "guard" : 5000 },
|
||||||
{ "a" : "4", "b" : "5", "guard" : 1000 }
|
{ "a" : "4", "b" : "5", "guard" : 5000 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Upgrade" :
|
"Upgrade" :
|
||||||
@ -111,18 +111,18 @@
|
|||||||
},
|
},
|
||||||
"connections" :
|
"connections" :
|
||||||
[
|
[
|
||||||
{ "a" : "1", "b" : "4", "guard" : 1000 },
|
{ "a" : "1", "b" : "4", "guard" : 2000 },
|
||||||
{ "a" : "1", "b" : "5", "guard" : 1000 },
|
{ "a" : "1", "b" : "5", "guard" : 2000 },
|
||||||
{ "a" : "2", "b" : "6", "guard" : 1000 },
|
{ "a" : "2", "b" : "6", "guard" : 2000 },
|
||||||
{ "a" : "2", "b" : "7", "guard" : 1000 },
|
{ "a" : "2", "b" : "7", "guard" : 2000 },
|
||||||
{ "a" : "3", "b" : "8", "guard" : 1000 },
|
{ "a" : "3", "b" : "8", "guard" : 2000 },
|
||||||
{ "a" : "3", "b" : "9", "guard" : 1000 },
|
{ "a" : "3", "b" : "9", "guard" : 2000 },
|
||||||
{ "a" : "4", "b" : "10", "guard" : 1000 },
|
{ "a" : "4", "b" : "10", "guard" : 20000 },
|
||||||
{ "a" : "5", "b" : "12", "guard" : 1000 },
|
{ "a" : "5", "b" : "12", "guard" : 20000 },
|
||||||
{ "a" : "6", "b" : "10", "guard" : 1000 },
|
{ "a" : "6", "b" : "10", "guard" : 20000 },
|
||||||
{ "a" : "7", "b" : "11", "guard" : 1000 },
|
{ "a" : "7", "b" : "11", "guard" : 20000 },
|
||||||
{ "a" : "8", "b" : "12", "guard" : 1000 },
|
{ "a" : "8", "b" : "12", "guard" : 20000 },
|
||||||
{ "a" : "9", "b" : "11", "guard" : 1000 }
|
{ "a" : "9", "b" : "11", "guard" : 20000 }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Unfair Game" :
|
"Unfair Game" :
|
||||||
@ -156,12 +156,12 @@
|
|||||||
},
|
},
|
||||||
"connections" :
|
"connections" :
|
||||||
[
|
[
|
||||||
{ "a" : "1", "b" : "3", "guard" : 2000 },
|
{ "a" : "1", "b" : "3", "guard" : 5000 },
|
||||||
{ "a" : "1", "b" : "4", "guard" : 2000 },
|
{ "a" : "1", "b" : "4", "guard" : 5000 },
|
||||||
{ "a" : "2", "b" : "3", "guard" : 2000 },
|
{ "a" : "2", "b" : "3", "guard" : 5000 },
|
||||||
{ "a" : "2", "b" : "4", "guard" : 2000 },
|
{ "a" : "2", "b" : "4", "guard" : 5000 },
|
||||||
{ "a" : "3", "b" : "5", "guard" : 1000 },
|
{ "a" : "3", "b" : "5", "guard" : 2000 },
|
||||||
{ "a" : "4", "b" : "6", "guard" : 1000 }
|
{ "a" : "4", "b" : "6", "guard" : 2000 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "../VCMI_Lib.h"
|
#include "../VCMI_Lib.h"
|
||||||
#include "../CTownHandler.h"
|
#include "../CTownHandler.h"
|
||||||
|
#include "../CCreatureHandler.h"
|
||||||
|
|
||||||
class CMap;
|
class CMap;
|
||||||
class CMapEditManager;
|
class CMapEditManager;
|
||||||
@ -349,7 +350,7 @@ void CRmgTemplateZone::createConnections(CMapGenerator* gen)
|
|||||||
});
|
});
|
||||||
if (guardPos.valid())
|
if (guardPos.valid())
|
||||||
{
|
{
|
||||||
gen->setOccupied (guardPos, ETileType::FREE); //TODO: place monster here
|
addMonster (gen, guardPos, 10000); //TODO: set value according to template
|
||||||
//zones can make paths only in their own area
|
//zones can make paths only in their own area
|
||||||
this->crunchPath (gen, guardPos, this->getPos(), this->getId()); //make connection towards our zone center
|
this->crunchPath (gen, guardPos, this->getPos(), this->getId()); //make connection towards our zone center
|
||||||
gen->getZones()[connection]->crunchPath (gen, guardPos, otherZoneCenter, connection); //make connection towards other zone center
|
gen->getZones()[connection]->crunchPath (gen, guardPos, otherZoneCenter, connection); //make connection towards other zone center
|
||||||
@ -454,6 +455,29 @@ void CRmgTemplateZone::addRequiredObject(CGObjectInstance * obj)
|
|||||||
requiredObjects.push_back(obj);
|
requiredObjects.push_back(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength)
|
||||||
|
{
|
||||||
|
CreatureID creId = CreatureID::NONE;
|
||||||
|
int amount = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
creId = VLC->creh->pickRandomMonster(gen->rand);
|
||||||
|
auto cre = VLC->creh->creatures[creId];
|
||||||
|
amount = strength / cre->AIValue;
|
||||||
|
if (amount >= cre->ammMin && amount <= 100)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto guard = new CGCreature();
|
||||||
|
guard->ID = Obj::MONSTER;
|
||||||
|
guard->subID = creId;
|
||||||
|
auto hlp = new CStackInstance(creId, amount);
|
||||||
|
//will be set during initialization
|
||||||
|
guard->putStack(SlotID(0), hlp);
|
||||||
|
|
||||||
|
placeObject(gen, guard, pos);
|
||||||
|
}
|
||||||
|
|
||||||
bool CRmgTemplateZone::fill(CMapGenerator* gen)
|
bool CRmgTemplateZone::fill(CMapGenerator* gen)
|
||||||
{
|
{
|
||||||
int townId = 0;
|
int townId = 0;
|
||||||
@ -567,7 +591,7 @@ bool CRmgTemplateZone::fill(CMapGenerator* gen)
|
|||||||
|
|
||||||
for(const auto &obj : guarded_objects)
|
for(const auto &obj : guarded_objects)
|
||||||
{
|
{
|
||||||
if ( ! guardObject(gen, obj, 500))
|
if ( ! guardObject(gen, obj, 1000))
|
||||||
{
|
{
|
||||||
//TODO, DEL obj from map
|
//TODO, DEL obj from map
|
||||||
}
|
}
|
||||||
@ -687,11 +711,11 @@ void CRmgTemplateZone::placeObject(CMapGenerator* gen, CGObjectInstance* object,
|
|||||||
if (object->isVisitable())
|
if (object->isVisitable())
|
||||||
points.insert(pos + object->getVisitableOffset());
|
points.insert(pos + object->getVisitableOffset());
|
||||||
points.insert(pos);
|
points.insert(pos);
|
||||||
for(auto const &p : points)
|
for(auto p : points)
|
||||||
{
|
{
|
||||||
if (vstd::contains(tileinfo, pos + p))
|
if (gen->map->isInTheMap(p))
|
||||||
{
|
{
|
||||||
gen->setOccupied(pos + p, ETileType::USED);
|
gen->setOccupied(p, ETileType::USED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto tile : tileinfo)
|
for(auto tile : tileinfo)
|
||||||
@ -723,14 +747,8 @@ bool CRmgTemplateZone::guardObject(CMapGenerator* gen, CGObjectInstance* object,
|
|||||||
}
|
}
|
||||||
auto guard_tile = *RandomGeneratorUtil::nextItem(tiles, gen->rand);
|
auto guard_tile = *RandomGeneratorUtil::nextItem(tiles, gen->rand);
|
||||||
gen->setOccupied (guard_tile, ETileType::USED);
|
gen->setOccupied (guard_tile, ETileType::USED);
|
||||||
auto guard = new CGCreature();
|
|
||||||
guard->ID = Obj::RANDOM_MONSTER;
|
|
||||||
guard->subID = 0;
|
|
||||||
auto hlp = new CStackInstance();
|
|
||||||
hlp->count = 10;
|
|
||||||
//type will be set during initialization
|
|
||||||
guard->putStack(SlotID(0), hlp);
|
|
||||||
|
|
||||||
checkAndPlaceObject(gen, guard, guard_tile);
|
addMonster (gen, guard_tile, str);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ public:
|
|||||||
std::set<int3> getTileInfo () const;
|
std::set<int3> getTileInfo () const;
|
||||||
|
|
||||||
void addRequiredObject(CGObjectInstance * obj);
|
void addRequiredObject(CGObjectInstance * obj);
|
||||||
|
void addMonster(CMapGenerator* gen, int3 &pos, si32 strength);
|
||||||
bool fill(CMapGenerator* gen);
|
bool fill(CMapGenerator* gen);
|
||||||
void createConnections(CMapGenerator* gen);
|
void createConnections(CMapGenerator* gen);
|
||||||
void createBorder(CMapGenerator* gen);
|
void createBorder(CMapGenerator* gen);
|
||||||
|
Loading…
Reference in New Issue
Block a user