World of Banished

MODS Garage => Tips and Help => Topic started by: angainor88 on July 04, 2018, 12:03:02 PM

Title: How do you add happiness to a building?
Post by: angainor88 on July 04, 2018, 12:03:02 PM
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;
}
Title: Re: How do you add happiness to a building?
Post by: Tom Sawyer on July 04, 2018, 01:45:07 PM
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. :)
Title: Re: How do you add happiness to a building?
Post by: RedKetchup on July 04, 2018, 01:52:08 PM
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;
}
Title: Re: How do you add happiness to a building?
Post by: angainor88 on July 04, 2018, 04:56:48 PM
Ah, ok! Thank you so much!
Title: Re: How do you add happiness to a building?
Post by: angainor88 on July 04, 2018, 05:58:52 PM
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
Title: Re: How do you add happiness to a building?
Post by: RedKetchup on July 04, 2018, 06:10:31 PM
 ;D neither !! LOL
Title: Re: How do you add happiness to a building?
Post by: Discrepancy on July 05, 2018, 07:02:57 AM
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?
Title: Re: How do you add happiness to a building?
Post by: angainor88 on July 05, 2018, 06:09:44 PM
Ah, that was the missing part of the puzzle! I have build points, but no use points.

Thank you, it works fine now :D
Title: Re: How do you add happiness to a building?
Post by: RedKetchup on July 05, 2018, 07:10:24 PM
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
Title: Re: How do you add happiness to a building?
Post by: angainor88 on July 06, 2018, 06:00:16 AM
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
Title: Re: How do you add happiness to a building?
Post by: Maldrick on December 09, 2018, 08:19:15 AM
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.
Title: Re: How do you add happiness to a building?
Post by: Tom Sawyer on December 09, 2018, 10:05:31 AM
@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.
Title: Re: How do you add happiness to a building?
Post by: Maldrick on December 09, 2018, 11:31:01 AM
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;
}

Title: Re: How do you add happiness to a building?
Post by: Tom Sawyer on December 09, 2018, 11:37:16 AM
Remove the "//" in front of MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc"; It comments your circle out. :)
Title: Re: How do you add happiness to a building?
Post by: Maldrick on December 09, 2018, 11:47:41 AM
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?
Title: Re: How do you add happiness to a building?
Post by: Maldrick on December 09, 2018, 12:18:38 PM
Played around with this a bit...Thought I would note, in case anyone else sees this thread with the same issue...

If you don't have the "//" in front of MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc" and also have ObjectType _type = RadiusUI; in the ui section you will get a permanent visible radius when the building is selected.

If you don't have the "//" in front of MaterialInstance _decalMaterial = "Terrain/TiledDecals/SelectAreaMaterial.rsc" and DO NOT have ObjectType _type = RadiusUI; in the ui section you will get a visible radius when placing the building but it won't be visible when the footprint or finished building is selected.

If you have the "//" you won't have a visible radius at all.

Awesome, thanks again Tom.  Glad to have that cleared up.
Title: Re: How do you add happiness to a building?
Post by: Tom Sawyer on December 09, 2018, 02:00:45 PM
"marketlocation" defines the object as a market and then "radius" defines the area where citizens are forced to gather food there and where homes profit from happiness. With "tracker" it's not connected as far as I know. I guess it adds functions to track production for statistics.
Title: Re: How do you add happiness to a building?
Post by: Maldrick on December 10, 2018, 06:56:34 AM
Thanks, Tom.  I will keep an eye on those as I get into those buildings.