Skip to content
This repository was archived by the owner on Dec 4, 2020. It is now read-only.

Commit f7e347f

Browse files
authored
Merge pull request #1047 from zach2good/gardening_1
Gardening by jmcmorris
2 parents 9fd279e + d0d05d7 commit f7e347f

File tree

16 files changed

+3764
-4
lines changed

16 files changed

+3764
-4
lines changed

conf/default/map.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ craft_chance_multiplier: 1.0
116116
skillup_amount_multiplier: 1
117117
craft_amount_multiplier: 1
118118

119+
#Gardening Factors: DO NOT change defaults without verifiable proof that your change IS how retail does it. Myths need to be optional.
120+
garden_day_matters: 0
121+
garden_moonphase_matters: 0
122+
garden_pot_matters: 0
123+
garden_mh_aura_matters: 0
124+
119125
#Enable/disable skill-ups from bloodpacts
120126
skillup_bloodpact: 1
121127

sql/gardening_results.sql

Lines changed: 2457 additions & 0 deletions
Large diffs are not rendered by default.

src/map/entities/charentity.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "../utils/attackutils.h"
6363
#include "../utils/charutils.h"
6464
#include "../utils/battleutils.h"
65+
#include "../utils/gardenutils.h"
6566
#include "../item_container.h"
6667
#include "../items/item_weapon.h"
6768
#include "../items/item_usable.h"
@@ -520,6 +521,11 @@ void CCharEntity::Tick(time_point tick)
520521
updatemask |= UPDATE_STATUS;
521522
m_deathSyncTime = tick + death_update_frequency;
522523
}
524+
525+
if (m_moghouseID != 0)
526+
{
527+
gardenutils::UpdateGardening(this, true);
528+
}
523529
}
524530

525531
void CCharEntity::PostTick()
@@ -1973,7 +1979,7 @@ void CCharEntity::SetMoghancement(uint16 moghancementID)
19731979
addModifier(Mod::EXPERIENCE_RETAINED, 5);
19741980
break;
19751981
case MOGHANCEMENT_GARDENING:
1976-
// TODO: Reduces the chances of plants withering when gardening
1982+
addModifier(Mod::GARDENING_WILT_BONUS, 36);
19771983
break;
19781984
case MOGHANCEMENT_DESYNTHESIS:
19791985
addModifier(Mod::DESYNTH_SUCCESS, 2);

src/map/items/item_flowerpot.cpp

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
/*
2+
===========================================================================
3+
4+
Copyright (c) 2010-2015 Darkstar Dev Teams
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see http://www.gnu.org/licenses/
18+
19+
===========================================================================
20+
*/
21+
22+
#include "item_flowerpot.h"
23+
#include "../map.h"
24+
25+
// Flowerpot Extra data explained:
26+
// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17
27+
// Example: 08 40 03 07 01 37 0A 00 17 00 00 00 E5 C8 9A 1F 88 1A 9F 1F 08 3C 04 08
28+
// 00 - Flowerpot stage ID (FLOWERPOT_STAGE_TYPE). Plants do not necessarily follow this sequentially and will skip some stages based on seed type.
29+
// 01 - Tracks if displayed as well as if the plant has been dried
30+
// 02 - Crystal feed element ID (FLOWERPOT_ELEMENT_TYPE). 4095 + element ID is the crystal item ID. This one is only used by trees that take two feedings.
31+
// 03 - Same as 0x02 but is the common one used by all plants.
32+
// 04 - Seed type (FLOWERPOT_PLANT_TYPE) of the plant
33+
// 05 - Unknown
34+
// 06-0B - MH Display info used in CItemFurnishing
35+
// 0C-0F - Vanatime of when the seed was planted in the flowerpot
36+
// 10-13 - Vanatime of when the next plant stage will occur
37+
38+
CItemFlowerpot::CItemFlowerpot(uint16 id)
39+
: CItemFurnishing(id)
40+
{
41+
}
42+
43+
CItemFlowerpot::~CItemFlowerpot()
44+
{
45+
}
46+
47+
void CItemFlowerpot::cleanPot()
48+
{
49+
setDried(false);
50+
setPlant(FLOWERPOT_PLANT_NONE);
51+
setStage(FLOWERPOT_STAGE_EMPTY);
52+
setFirstCrystalFeed(FLOWERPOT_ELEMENT_NONE);
53+
setSecondCrystalFeed(FLOWERPOT_ELEMENT_NONE);
54+
setPlantTimestamp(0);
55+
setStageTimestamp(0);
56+
}
57+
58+
bool CItemFlowerpot::isPlanted()
59+
{
60+
return ref<uint8>(m_extra, 0x00) > 0;
61+
}
62+
63+
bool CItemFlowerpot::isTree()
64+
{
65+
switch (getPlant())
66+
{
67+
case FLOWERPOT_PLANT_FRUIT_SEEDS:
68+
case FLOWERPOT_PLANT_CACTUS_STEMS:
69+
case FLOWERPOT_PLANT_TREE_CUTTINGS:
70+
case FLOWERPOT_PLANT_TREE_SAPLINGS:
71+
return true;
72+
case FLOWERPOT_PLANT_HERB_SEEDS:
73+
case FLOWERPOT_PLANT_GRAIN_SEEDS:
74+
case FLOWERPOT_PLANT_VEGETABLE_SEEDS:
75+
case FLOWERPOT_PLANT_WILDGRASS_SEEDS:
76+
default:
77+
return false;
78+
}
79+
}
80+
81+
void CItemFlowerpot::setDried(bool dried)
82+
{
83+
if (dried)
84+
{
85+
ref<uint8>(m_extra, 0x01) |= 0x80;
86+
}
87+
else
88+
{
89+
ref<uint8>(m_extra, 0x01) &= ~0x80;
90+
}
91+
}
92+
93+
bool CItemFlowerpot::isDried()
94+
{
95+
return ref<uint8>(m_extra, 0x01) & 0x80;
96+
}
97+
98+
bool CItemFlowerpot::canGrow()
99+
{
100+
uint8 stage = ref<uint8>(m_extra, 0x00);
101+
return stage >= FLOWERPOT_STAGE_INITIAL && stage <= FLOWERPOT_STAGE_THIRD_SPROUTS && !isDried();
102+
}
103+
104+
void CItemFlowerpot::setPlant(FLOWERPOT_PLANT_TYPE plant)
105+
{
106+
ref<uint8>(m_extra, 0x04) = plant;
107+
}
108+
109+
FLOWERPOT_PLANT_TYPE CItemFlowerpot::getPlant()
110+
{
111+
return (FLOWERPOT_PLANT_TYPE)ref<uint8>(m_extra, 0x04);
112+
}
113+
114+
uint16 CItemFlowerpot::getSeedID(FLOWERPOT_PLANT_TYPE plantType)
115+
{
116+
switch (plantType)
117+
{
118+
case FLOWERPOT_PLANT_HERB_SEEDS:
119+
return 572;
120+
case FLOWERPOT_PLANT_GRAIN_SEEDS:
121+
return 575;
122+
case FLOWERPOT_PLANT_VEGETABLE_SEEDS:
123+
return 573;
124+
case FLOWERPOT_PLANT_FRUIT_SEEDS:
125+
return 574;
126+
case FLOWERPOT_PLANT_CACTUS_STEMS:
127+
return 1236;
128+
case FLOWERPOT_PLANT_TREE_CUTTINGS:
129+
return 1237;
130+
case FLOWERPOT_PLANT_TREE_SAPLINGS:
131+
return 1238;
132+
case FLOWERPOT_PLANT_WILDGRASS_SEEDS:
133+
return 2235;
134+
case FLOWERPOT_PLANT_NONE:
135+
default:
136+
return 0;
137+
}
138+
}
139+
140+
FLOWERPOT_PLANT_TYPE CItemFlowerpot::getPlantFromSeed(uint16 seedID)
141+
{
142+
switch (seedID)
143+
{
144+
case 572:
145+
return FLOWERPOT_PLANT_HERB_SEEDS;
146+
case 575:
147+
return FLOWERPOT_PLANT_GRAIN_SEEDS;
148+
case 573:
149+
return FLOWERPOT_PLANT_VEGETABLE_SEEDS;
150+
case 574:
151+
return FLOWERPOT_PLANT_FRUIT_SEEDS;
152+
case 1236:
153+
return FLOWERPOT_PLANT_CACTUS_STEMS;
154+
case 1237:
155+
return FLOWERPOT_PLANT_TREE_CUTTINGS;
156+
case 1238:
157+
return FLOWERPOT_PLANT_TREE_SAPLINGS;
158+
case 2235:
159+
return FLOWERPOT_PLANT_WILDGRASS_SEEDS;
160+
default:
161+
return FLOWERPOT_PLANT_NONE;
162+
}
163+
}
164+
165+
void CItemFlowerpot::setStage(FLOWERPOT_STAGE_TYPE stage)
166+
{
167+
ref<uint8>(m_extra, 0x00) = stage;
168+
}
169+
170+
FLOWERPOT_STAGE_TYPE CItemFlowerpot::getStage()
171+
{
172+
return (FLOWERPOT_STAGE_TYPE)ref<uint8>(m_extra, 0x00);
173+
}
174+
175+
void CItemFlowerpot::setFirstCrystalFeed(FLOWERPOT_ELEMENT_TYPE element)
176+
{
177+
ref<uint8>(m_extra, 0x02) = element;
178+
}
179+
180+
void CItemFlowerpot::setSecondCrystalFeed(FLOWERPOT_ELEMENT_TYPE element)
181+
{
182+
ref<uint8>(m_extra, 0x03) = element;
183+
}
184+
185+
FLOWERPOT_ELEMENT_TYPE CItemFlowerpot::getExtraCrystalFeed()
186+
{
187+
return (FLOWERPOT_ELEMENT_TYPE)ref<uint8>(m_extra, 0x02);
188+
}
189+
190+
FLOWERPOT_ELEMENT_TYPE CItemFlowerpot::getCommonCrystalFeed()
191+
{
192+
return (FLOWERPOT_ELEMENT_TYPE)ref<uint8>(m_extra, 0x03);
193+
}
194+
195+
int16 CItemFlowerpot::getItemFromElement(FLOWERPOT_ELEMENT_TYPE element)
196+
{
197+
//Element and crystal item id ordering is the same with an offset
198+
return element + 4095;
199+
}
200+
201+
FLOWERPOT_ELEMENT_TYPE CItemFlowerpot::getElementFromItem(int16 itemID)
202+
{
203+
//Element and crystal item id ordering is the same with an offset
204+
return (FLOWERPOT_ELEMENT_TYPE)(itemID - 4095);
205+
}
206+
207+
void CItemFlowerpot::setPlantTimestamp(uint32 vanatime)
208+
{
209+
ref<uint32>(m_extra, 0x0C) = vanatime;
210+
}
211+
212+
uint32 CItemFlowerpot::getPlantTimestamp()
213+
{
214+
return ref<uint32>(m_extra, 0x0C);
215+
}
216+
217+
void CItemFlowerpot::setStageTimestamp(uint32 vanatime)
218+
{
219+
ref<uint32>(m_extra, 0x10) = vanatime;
220+
}
221+
222+
uint32 CItemFlowerpot::getStageTimestamp()
223+
{
224+
return ref<uint32>(m_extra, 0x10);
225+
}
226+
227+
void CItemFlowerpot::clearExamined()
228+
{
229+
ref<uint8>(m_extra, 0x05) &= ~1;
230+
}
231+
232+
void CItemFlowerpot::markExamined()
233+
{
234+
ref<uint8>(m_extra, 0x05) |= 1;
235+
}
236+
237+
bool CItemFlowerpot::wasExamined()
238+
{
239+
return ref<uint8>(m_extra, 0x05) & 1;
240+
}
241+
242+
void CItemFlowerpot::setStrength(uint8 strength)
243+
{
244+
ref<uint8>(m_extra, 0x05) = strength << 1;
245+
}
246+
247+
uint8 CItemFlowerpot::getStrength()
248+
{
249+
return ref<uint8>(m_extra, 0x05) >> 1;
250+
}

0 commit comments

Comments
 (0)