Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
# HG changeset patch # Parent 4234d1b8f0a925fa043995ccdce7fe1ba815fe75 diff --git a/src/person.cpp b/src/person.cpp --- a/src/person.cpp +++ b/src/person.cpp @@ -25,6 +25,8 @@ #include "viewport.h" #include "weather.h" +static const int MEAN_LITTER_DROPCOUNT = 30; ///< Average number of tiles after finishing eating to drop wrapper as litter. + static PersonTypeData _person_type_datas[PERSON_TYPE_COUNT]; ///< Data about each type of person. /** @@ -382,6 +384,11 @@ TileEdge Person::GetCurrentEdge() const } /** + * @fn Person::DecideMoveDirection() + * Decide where to go from the current position. + */ + +/** * Decide whether visiting the exit edge is useful. * @param current_edge Edge at the current position. * @param x X coordinate of the current voxel. @@ -626,13 +633,32 @@ static int GetDesiredEdgeIndex(TileEdge } /** - * @fn Person::DecideMoveDirection() - * Decide where to go from the current position. + * Attempt to drop the wrapper onto the path in the voxel. + * @param v %Voxel to drop the wrapper. + * @param wrapper_counter Counter of number of tiles to wait until the wrapper is forcibly dropped. + * @return Whether or not the wrapper was dropped. */ +static bool TryDropWrapper(Voxel *v, uint16 wrapper_counter) +{ + uint16 path_instance_data = v->GetInstanceData(); + if (wrapper_counter > 1 && (GetPathDecoration(path_instance_data) != PDEC_LITTERBIN || GetVisiblePathLitter(path_instance_data) > 0)) { + return false; // Wait for a better place to drop the litter. + } + + /* Should drop the wrapper asap. */ + if (GetVisiblePathLitter(path_instance_data) == 3) return false; // Already maximal litter, wait until the next tile. + + uint litter = GetPathLitter(path_instance_data); + path_instance_data = SetPathLitter(path_instance_data, litter + 1); + v->SetInstanceData(path_instance_data); + return true; // Dropped. + +} + void Guest::DecideMoveDirection() { - const VoxelStack *vs = _world.GetStack(this->vox_pos.x, this->vox_pos.y); - const Voxel *v = vs->Get(this->vox_pos.z); + VoxelStack *vs = _world.GetModifyStack(this->vox_pos.x, this->vox_pos.y); + Voxel *v = vs->GetCreate(this->vox_pos.z, false); TileEdge start_edge = this->GetCurrentEdge(); // Edge the person is currently. if (this->activity == GA_ENTER_PARK && vs->owner == OWN_PARK) { @@ -641,10 +667,19 @@ void Guest::DecideMoveDirection() // Add some happiness?? (Somewhat useless as every guest enters the park. On the other hand, a nice point to configure difficulty level perhaps?) } - /* Find feasible exits and shops. */ uint8 exits, shops; bool queue_path; if (HasValidPath(v)) { + /* Can we drop the wrapper? */ + if (this->food == 0 && this->drink == 0 && this->wrapper_counter > 0) { // Guest has finished eating, and is holding a wrapper. + if (TryDropWrapper(v, this->wrapper_counter)) { + this->wrapper_counter = 0; + } else { + if (this->wrapper_counter > 1) this->wrapper_counter--; + } + } + + /* Find feasible exits and shops. */ bool seen_wanted_ride; exits = GetExitDirections(v, start_edge, &seen_wanted_ride, &queue_path); shops = exits >> 4; @@ -1019,8 +1054,8 @@ void Guest::Activate(const Point16 &star this->has_map = false; this->has_umbrella = false; this->has_balloon = false; - this->has_wrapper = false; this->salty_food = false; + this->wrapper_counter = 0; this->food = 0; this->drink = 0; this->hunger_level = 50; @@ -1104,7 +1139,6 @@ void Guest::ChangeHappiness(int16 amount * Daily ponderings of a guest. * @return If \c false, de-activate the guest. * @todo Make going home a bit more random. - * @todo Implement dropping litter (Guest::has_wrapper) to the path, and also drop the wrapper when passing a non-empty litter bin. * @todo Implement nausea (Guest::nausea). * @todo Implement energy (for tiredness of guests). */ @@ -1134,10 +1168,7 @@ bool Guest::DailyUpdate() } int16 happiness_change = 0; - if (!eating) { - if (this->has_wrapper && this->rnd.Success1024(25)) this->has_wrapper = false; // XXX Drop litter. - if (this->hunger_level > 200) happiness_change--; - } + if (!eating && this->hunger_level > 200) happiness_change--; if (this->waste > 170) happiness_change -= 2; switch (_weather.GetWeatherType()) { @@ -1159,7 +1190,10 @@ bool Guest::DailyUpdate() this->ChangeHappiness(happiness_change); - if (this->activity == GA_WANDER && this->happiness <= 10) this->activity = GA_GO_HOME; // Go home when bored. + if (this->activity == GA_WANDER && this->happiness <= 10) { + this->wrapper_counter = 0; + this->activity = GA_GO_HOME; // Go home when bored. + } return true; } @@ -1248,23 +1282,23 @@ void Guest::AddItem(ItemType it) case ITP_DRINK: this->drink = 5; - this->has_wrapper = true; + this->wrapper_counter = this->rnd.Exponential(MEAN_LITTER_DROPCOUNT); break; case ITP_ICE_CREAM: this->drink = 7; - this->has_wrapper = false; + this->wrapper_counter = 0; break; case ITP_NORMAL_FOOD: this->food = 10; - this->has_wrapper = true; + this->wrapper_counter = this->rnd.Exponential(MEAN_LITTER_DROPCOUNT); this->salty_food = false; break; case ITP_SALTY_FOOD: this->food = 15; - this->has_wrapper = true; + this->wrapper_counter = this->rnd.Exponential(MEAN_LITTER_DROPCOUNT); this->salty_food = true; break; diff --git a/src/person.h b/src/person.h --- a/src/person.h +++ b/src/person.h @@ -189,9 +189,9 @@ public: /* Possessions of the guest. */ bool has_map; ///< Whether guest has a park map. bool has_umbrella; ///< Whether guest has an umbrella. - bool has_wrapper; ///< Guest has a wrapper for the food or drink. bool has_balloon; ///< Guest has a balloon. bool salty_food; ///< The food in #food is salty. + uint16 wrapper_counter; ///< When non-zero, guest is holding a wrapper that gets dropped when the counter becomes \c 0. uint8 souvenirs; ///< Number of souvenirs bought by the guest. int8 food; ///< Amount of food in the hand (one unit/day). int8 drink; ///< Amount of drink in the hand (one unit/day). diff --git a/src/person_gui.cpp b/src/person_gui.cpp --- a/src/person_gui.cpp +++ b/src/person_gui.cpp @@ -107,7 +107,7 @@ void GuestInfoWindow::SetWidgetStringPar break; case GIW_ITEMS: - _str_params.SetStrID(1, (this->guest->has_wrapper ? GUI_ITEM_WRAPPER : GUI_ITEM_NONE)); + _str_params.SetStrID(1, ((this->guest->wrapper_counter > 0) ? GUI_ITEM_WRAPPER : GUI_ITEM_NONE)); break; default: break;
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever