News:

Welcome to World of Banished!

Main Menu

How do you add happiness to a building?

Started by angainor88, July 04, 2018, 12:03:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

angainor88

I am finishing up a clocktower that I want to add happiness to. I copied the happiness code from the cemetery and added it to the template file. When I Build it, everything runs smoothly, but in game, it crashed whenever I click on the clocktower. What am I missing?

The cemetery code I copied is just: HappinessDescription happiness
{
HappinessType _happinessType = Spirit;
int _idleRange = 1;
}

Tom Sawyer

Maybe the radius section is missed. You should also add the radius part to the UI section, so it can be seen in game. Can be copied from vanilla market. :)

RedKetchup

happiness function work with radius function.

and you need to call them in the header of your file: (Description _descriptions)

      "happiness",
      "radius",

then explain the functions:

HappinessDescription happiness
{
   HappinessType _happinessType = Spirit;
   int _idleRange = 3;
}

RadiusDescription radius
{
   int _radius = 35;
}
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

angainor88


angainor88

Oh no, now I get a different error message...

Assert: index >= 0 && index < GetLocationCount(type) Error, index out of range!

Component\InteractComponent.cpp(140)

I... have no idea what this means haha

RedKetchup

> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

Discrepancy

do you have interact points with it? If you are using the spirit happiness code I think it needs to have a use_ point... i think. if you already do, then could you send me your template file to review?

angainor88

Ah, that was the missing part of the puzzle! I have build points, but no use points.

Thank you, it works fine now :D

RedKetchup

well thats great Disc pinpointed it :)
dont forget when you will make some consume produced shops... another dummy you will need to know and add is : create_001 ... create_002 ... create_003 ... etc
they set where the recource should drop on the floor
> > > Support Mods Creation developments with Donations by Paypal  < < <
Click here to Donate by PayPal .

angainor88

Yeah the problem was that since it's a building with no workers, I thought I didn't need any points besides build. Whoops haha

Maldrick

Quote from: Tom Sawyer on July 04, 2018, 01:45:07 PM
You should also add the radius part to the UI section, so it can be seen in game. Can be copied from vanilla market. :)

@Tom Sawyer Is this the only thing that needs to be added?

UIDescription ui
{
int _displayPage = 0; // set to 1 for tab layout
Dialog _dialog = "Dialog/StandardDialog.rsc:entity";
ElementController _controllers
[
{
ObjectType _type = RadiusUI;
}


Trying to make the radius visible on a chapel and having no luck.  Also tried moving any remotely relevant dialogs and terrain files over to the project and I can't find anything else on the template for Market or other buildings with radii that I'm missing.
"We are the architects of our actions and we must live with their consequences, whether glorious or tragic."
― Ezio Auditore da Firenze

Tom Sawyer

@Maldrick your snippet is to make it visible permanently and that's optional. What I meant is:

RadiusDescription radius
{
int _radius = 30;
MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc";
}


And not to forget to add "radius" to the resource section on top. If you already had it, it must be something else and it would be good we can see the whole template file.

Maldrick

Ya, I built it from the default chapel template.  All of that was already there.  Added the section you mentioned in your older post, quoted earler, and I'm not getting a visible radius.  The only other thing I can find in the market and other buildings is an item called "marketlocation" in the market and "tracker" in the others.  Tried adding those and still not getting a visible radius, so thought I would ask.

Here is my template, with the RadiusUI section added:

// layout of the entity
ComponentDescription resource
{
// how often to update
UpdatePriority _updatePriority = Fourth;

// declare types that will be used
Description _descriptions
[
"ui",

"map",
"zone",
"toolbar",
"createplaced",
"decal",
"model",
"highlight",
"picking",
"interact",
"particle",
"storage",
"work",
"radius",
"statusicon",
"ambientemitter",
"Common.rsc:fireStoneBuilding",

"statemachine",
"cleararea",
"workplace",
"build",
"destroy",
"happiness",
"attendance"
]
}

AmbientEmitterDescription ambientemitter
{
bool _addOnCreate = false;
SoundEffect _soundEffects [ "Audio/Effects/FireEffect.rsc" ]
}

ClearAreaDescription cleararea { }
StateMachineDescription statemachine { }
ZoneDescription zone { }

HappinessDescription happiness
{
HappinessType _happinessType = Spirit;
bool _requireWorker = true;
int _idleRange = 3;
}

RadiusDescription radius
{
int _radius = 35;
// MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc";
}
AttendanceDescription attendance
{
int _maxCitizens = 200;
}

DestroyDescription destroy
{
int _damagedSkin = 1;
int _damagedDecal = 1;
}

WorkPlaceDescription workplace
{
Profession _profession = "Game/Profession/Profession.rsc:priest";
}

StatusIconDescription statusicon
{
SpriteSheet _spriteSheet = "StatusIcons\BuildingIconSpriteSheet.rsc";
bool _fixedSize = true;
float _size = 0.04;
float _zoffset = 1.33;
}

ToolbarDescription toolbar
{
SpriteSheet _spriteSheet = "UI/MDChurchSpriteSheet.rsc";
String _spriteName = "BuildMDChurch";

StringTable _stringTable = "UI/MDChurchStringTable.rsc";
String _stringName = "MDChurch";
String _stringNameLwr = "MDChurchLwr";
String _toolTip = "MDChurchTip";

String _statusStrings
[
"CreateOk",
"CreateBlocked",
]

int _group = 2;
}

CreatePlacedDescription createplaced
{
PathBits _placeBits = Normal | Obstacle;

int _width = 6;
int _height = 6;

int _footprintRotation = 0;

PathBits _placeBitArray
[
Normal | Obstacle,
Normal | Obstacle | Fast | Faster,
]
String _placeBitmap =
"111111
100001
100001
100001
100001
111111";

ComponentDescription _allowAndRemove = "Template/Clear.rsc";
}

MapDescription map
{
PathType _pathType = Immovable;
String _pathBitmap =
"......
.####.
.####.
.####.
.####.
......";

bool _addToOverhead = true;
Color _mapColor = 0xFF545454;
}

DecalDescription decal
{
MaterialInstance _materials
[
"Models/MaterialInstance/MDChurchFootprintMaterial.rsc"
"Models/MaterialInstance/MDChurchFootprintDamageMaterial.rsc"
]
bool _tiled = false;
float _initialAlpha = 0.5;
float _mapWidth = 256.0;

DecalLocation _decalLocations
[
{
float _x0 = 0.0;
float _y0 = 0.0;
float _x1 = 256.0;
float _y1 = 256.0;
}
]
}

PickingDescription picking
{
MaterialInstance _selectMaterial = "Material/SelectionMask/SelectionMask.rsc";
PickingGroup _meshes
[
{
PickingMesh _mesh
[
"Models\MDChurchBuild01Picking.rsc",
"Models\MDChurchBuild02Picking.rsc",
"Models\MDChurchBuild03Picking.rsc",
"Models\MDChurchPicking.rsc"
]
}
]
}

ModelDescription model
{
MeshGroup _meshes
[
{
GraphicsMesh _mesh
[
"Models\MDChurchBuild01Mesh.rsc",
"Models\MDChurchBuild02Mesh.rsc",
"Models\MDChurchBuild03Mesh.rsc",
"Models\MDChurchMesh.rsc"
]
}
]

int _displayIndex = 0;
int _subIndex = 0;
bool _randomIndex = false;
}

HighlightDescription highlight
{
EdgeGroup _meshes
[
{
EdgeMesh _mesh
[
"Models\MDChurchBuild01Mesh.rsc:edge"
"Models\MDChurchBuild02Mesh.rsc:edge"
"Models\MDChurchBuild03Mesh.rsc:edge"
"Models\MDChurchMesh.rsc:edge"
]
}
]

// materials for drawing selection with no mesh
MaterialInstance _maskMaterial = "Material/SelectionMask/SelectionMask.rsc";
MaterialInstance _edgeMaterial = "Material/SelectionEdge/SelectionEdge.rsc";
}


InteractDescription interact
{
PointList _pointList = "Models\Buildings\Chapel\ChapelPoints.rsc";
}

ParticleDescription particle
{
PointList _pointList = "Models\Buildings\Chapel\ChapelPoints.rsc";

ParticleAttachment _systems
[
{
Time _fadeInOutTime = 2.0;
bool _addOnCreate = false;
bool _addOnNotify = false;
Particle _particle = "ParticleSystems\Fire\FireLarge.rsc";
}
]
}

StorageDescription storage
{
bool _areaBasedLimit = false;
bool _available = false;
}

WorkDescription work
{
int _defaultWorkers = 1;
}

BuildDescription build
{
int _workRequired = 150;

BuildRequirement _buildRequirement
[
{
ComponentDescription _rawMaterial = "Template/RawMaterialWood.rsc";
int _count = 50;
}
{
ComponentDescription _rawMaterial = "Template/RawMaterialStone.rsc";
int _count = 130;
}
{
ComponentDescription _rawMaterial = "Template/RawMaterialIron.rsc";
int _count = 30;
}
]
}


UIDescription ui
{
int _displayPage = 0; // set to 1 for tab layout
Dialog _dialog = "Dialog/StandardDialog.rsc:entity";
ElementController _controllers
[
{
ObjectType _type = RadiusUI;
}
{
ObjectType _type = ControlUI;
ElementDescription _element = "enableSchoolWorkButton";
String _insertAt = "userButton0";
DialogControllerConfig _config = "workButtonConfig";
}
{
ObjectType _type = WorkPlaceUI;
ElementDescription _element = "Dialog/Work.rsc:workPlace";
String _insertAt = "userTitle0";
}
{
ObjectType _type = StatusIconUI;
ElementDescription _element = "Dialog/Building.rsc:icons";
String _insertAt = "userTitle1";
}
{
ObjectType _type = BuildUI;
ElementDescription _element = "Dialog/Build.rsc:build";
String _insertAt = "pageBuild";
}
{
ObjectType _type = DestroyUI;
ElementDescription _element = "Dialog/Destroy.rsc:destroy";
String _insertAt = "pageDestroy";
}
{
ObjectType _type = AttendanceUI;
ElementDescription _element = "Dialog/Attendance.rsc:chapel";
String _insertAt = "userButton1";
}
]
}

ControlUIConfig workButtonConfig
{
ObjectType _type = AttendanceComponent;
int _controlId = 0;
}

CheckDescription enableSchoolWorkButton : "Dialog/Work.rsc:enableWorkCheck"
{
ElementDescription _content = "labelSchoolWorkUncheck";
ElementDescription _check = "labelSchoolWorkCheck";

String _toolTipText = "EnablePriestTip";
}

LabelDescription labelSchoolWorkCheck : "Dialog/Work.rsc:labelEnableWork"
{
SpriteSheet _spriteSheet = "UI/MDChurchSpriteSheet.rsc";
String _spriteName = "MDChurchWork";
}

LabelDescription labelSchoolWorkUncheck : "labelSchoolWorkCheck"
{
Color _color = 0xFF2E2B28;
}

"We are the architects of our actions and we must live with their consequences, whether glorious or tragic."
― Ezio Auditore da Firenze

Tom Sawyer

Remove the "//" in front of MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc"; It comments your circle out. :)

Maldrick

Good eye.  That did it.  Thank you! :)

I just looked at the kit and I didn't add those.  Came from the template in the modkit like that.  lol

Question, since we are discussing this....What do "marketlocation" on the market and "tracker" on the other buildings with radii do?
"We are the architects of our actions and we must live with their consequences, whether glorious or tragic."
― Ezio Auditore da Firenze