add apple juice, make hud colours change when a boost is in effect

This commit is contained in:
darkrose 2015-06-05 05:54:15 +10:00
parent 9bedc0307d
commit 1e6bb20c7f
9 changed files with 89 additions and 45 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1062,8 +1062,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
u8 hp = readU8(is);
u8 air = readU8(is);
u8 hunger = readU8(is);
player->energy_effect = readU8(is);
player->cold_effect = readU8(is);
player->energy_effectf += readU8(is);
player->cold_effectf += readU8(is);
if (m_server_damage) {
if (!player->hp)
player->setEnergy(hp);

View File

@ -245,8 +245,8 @@ void content_craftitem_init()
f->description = wgettext("Cooked Rat");
f->cook_result = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_ASH)+" 1";
f->consumable = true;
f->hunger_effect = 6;
f->health_effect = 6;
f->hunger_effect = 8;
f->health_effect = 4;
lists::add("creative",i);
lists::add("cooking",i);
@ -267,8 +267,8 @@ void content_craftitem_init()
f->name = "apple";
f->description = wgettext("Apple");
f->consumable = true;
f->hunger_effect = 4;
f->health_effect = 4;
f->hunger_effect = 6;
f->health_effect = 3;
lists::add("creative",i);
i = CONTENT_CRAFTITEM_APPLE_IRON;
@ -278,7 +278,7 @@ void content_craftitem_init()
f->name = "apple_iron";
f->description = wgettext("Iron Apple");
f->consumable = true;
f->hunger_effect = 8;
f->hunger_effect = 16;
f->health_effect = 8;
{
u16 recipe[9] = {
@ -495,7 +495,7 @@ void content_craftitem_init()
f->name = "apple_blossom";
f->description = wgettext("Apple Blossoms");
f->consumable = true;
f->hunger_effect = 1;
f->hunger_effect = 2;
f->health_effect = 1;
f->fuel_time = 30/16;
lists::add("creative",i);
@ -507,7 +507,7 @@ void content_craftitem_init()
f->name = "cactus_fruit";
f->description = wgettext("Cactus Berry");
f->consumable = true;
f->hunger_effect = 3;
f->hunger_effect = 6;
f->health_effect = 3;
lists::add("creative",i);
@ -529,8 +529,8 @@ void content_craftitem_init()
f->name = "pumpkin_slice";
f->description = wgettext("Sliced Pumpkin");
f->consumable = true;
f->hunger_effect = 2;
f->health_effect = 2;
f->hunger_effect = 6;
f->health_effect = 3;
crafting::set1To2Recipe(CONTENT_FARM_PUMPKIN,CONTENT_CRAFTITEM_PUMPKINSLICE);
lists::add("craftguide",i);
lists::add("creative",i);
@ -542,7 +542,7 @@ void content_craftitem_init()
f->name = "pumpkin_pie_slice";
f->description = wgettext("Pumpkin Pie Slice");
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 12;
f->health_effect = 6;
lists::add("craftguide",i);
@ -553,7 +553,7 @@ void content_craftitem_init()
f->name = "apple_pie_slice";
f->description = wgettext("Apple Pie Slice");
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 12;
f->health_effect = 6;
lists::add("creative",i);
@ -564,7 +564,7 @@ void content_craftitem_init()
f->name = "melon_slice";
f->description = wgettext("Sliced Melon");
f->consumable = true;
f->hunger_effect = 4;
f->hunger_effect = 8;
f->health_effect = 4;
crafting::set1To2Recipe(CONTENT_FARM_MELON,CONTENT_CRAFTITEM_MELONSLICE);
lists::add("craftguide",i);
@ -577,7 +577,7 @@ void content_craftitem_init()
f->name = "harvested_wheat";
f->description = wgettext("Wheat");
f->consumable = true;
f->hunger_effect = 1;
f->hunger_effect = 2;
f->health_effect = 1;
lists::add("creative",i);
@ -588,7 +588,7 @@ void content_craftitem_init()
f->name = "flour";
f->description = wgettext("Flour");
f->consumable = true;
f->hunger_effect = 1;
f->hunger_effect = 2;
f->health_effect = 1;
crafting::set1Any2Recipe(CONTENT_CRAFTITEM_WHEAT,CONTENT_CRAFTITEM_WHEAT,CONTENT_CRAFTITEM_FLOUR);
lists::add("craftguide",i);
@ -602,7 +602,7 @@ void content_craftitem_init()
f->description = wgettext("Dough");
f->cook_result = std::string("CraftItem bread 1");
f->consumable = true;
f->hunger_effect = 2;
f->hunger_effect = 4;
f->health_effect = 2;
crafting::set1Any2Recipe(CONTENT_CRAFTITEM_FLOUR,CONTENT_CRAFTITEM_FLOUR,CONTENT_CRAFTITEM_DOUGH);
lists::add("craftguide",i);
@ -616,7 +616,7 @@ void content_craftitem_init()
f->name = "bread";
f->description = wgettext("Bread");
f->consumable = true;
f->hunger_effect = 5;
f->hunger_effect = 10;
f->health_effect = 5;
lists::add("creative",i);
@ -628,7 +628,7 @@ void content_craftitem_init()
f->description = wgettext("Potato");
f->cook_result = std::string("CraftItem roast_potato 1");
f->consumable = true;
f->hunger_effect = 3;
f->hunger_effect = 6;
f->health_effect = 3;
lists::add("creative",i);
lists::add("cooking",i);
@ -650,7 +650,7 @@ void content_craftitem_init()
f->name = "roast_potato";
f->description = wgettext("Roast Potato");
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 12;
f->health_effect = 6;
lists::add("creative",i);
@ -661,7 +661,7 @@ void content_craftitem_init()
f->name = "harvested_carrot";
f->description = wgettext("Carrot");
f->consumable = true;
f->hunger_effect = 4;
f->hunger_effect = 6;
f->health_effect = 4;
lists::add("creative",i);
@ -673,7 +673,7 @@ void content_craftitem_init()
f->description = wgettext("Raw Carrot Cake");
f->cook_result = std::string("CraftItem carrot_cake 1");
f->consumable = true;
f->hunger_effect = 3;
f->hunger_effect = 6;
f->health_effect = 3;
crafting::set1over1Recipe(CONTENT_CRAFTITEM_CARROT,CONTENT_CRAFTITEM_DOUGH,CONTENT_CRAFTITEM_CARROT_CAKE_RAW);
lists::add("craftguide",i);
@ -686,7 +686,7 @@ void content_craftitem_init()
f->name = "carrot_cake";
f->description = wgettext("Carrot Cake");
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 12;
f->health_effect = 6;
lists::add("creative",i);
@ -697,7 +697,7 @@ void content_craftitem_init()
f->name = "harvested_beetroot";
f->description = wgettext("Beetroot");
f->consumable = true;
f->hunger_effect = 3;
f->hunger_effect = 6;
f->health_effect = 3;
lists::add("creative",i);
@ -708,7 +708,7 @@ void content_craftitem_init()
f->name = "harvested_grape";
f->description = wgettext("Bunch of Grapes");
f->consumable = true;
f->hunger_effect = 4;
f->hunger_effect = 6;
f->health_effect = 4;
lists::add("creative",i);
@ -777,7 +777,7 @@ void content_craftitem_init()
f->description = wgettext("Cooked Fish");
f->cook_result = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_ASH)+" 1";
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 8;
f->health_effect = 6;
lists::add("creative",i);
lists::add("cooking",i);
@ -803,7 +803,7 @@ void content_craftitem_init()
f->description = wgettext("Cooked Meat");
f->cook_result = std::string("CraftItem2 ")+itos(CONTENT_CRAFTITEM_ASH)+" 1";
f->consumable = true;
f->hunger_effect = 6;
f->hunger_effect = 10;
f->health_effect = 6;
lists::add("creative",i);
lists::add("cooking",i);
@ -1317,16 +1317,33 @@ void content_craftitem_init()
f = &g_content_craftitem_features[i];
f->content = i;
f->texture = "drink_grape.png^glass_bottle.png";
f->name = "glass_bottle";
f->name = "grape_juice";
f->description = wgettext("Grape Juice");
f->stackable = false;
f->drop_count = 1;
f->consumable = true;
f->hunger_effect = 2;
f->health_effect = 2;
f->cold_effect = 5;
f->hunger_effect = 3;
f->health_effect = 3;
f->energy_effect = 3;
f->onuse_replace_item = CONTENT_CRAFTITEM_GLASS_BOTTLE;
crafting::set1over1Recipe(CONTENT_CRAFTITEM_GRAPE,CONTENT_CRAFTITEM_GLASS_BOTTLE,CONTENT_CRAFTITEM_GRAPE_JUICE);
lists::add("craftguide",i);
lists::add("creative",i);
i = CONTENT_CRAFTITEM_APPLE_JUICE;
f = &g_content_craftitem_features[i];
f->content = i;
f->texture = "drink_apple.png^glass_bottle.png";
f->name = "apple_juice";
f->description = wgettext("Apple Juice");
f->stackable = false;
f->drop_count = 1;
f->consumable = true;
f->hunger_effect = 2;
f->health_effect = 3;
f->energy_effect = 2;
f->onuse_replace_item = CONTENT_CRAFTITEM_GLASS_BOTTLE;
crafting::set1over1Recipe(CONTENT_CRAFTITEM_APPLE,CONTENT_CRAFTITEM_GLASS_BOTTLE,CONTENT_CRAFTITEM_APPLE_JUICE);
lists::add("craftguide",i);
lists::add("creative",i);
}

View File

@ -205,5 +205,6 @@ CraftItemFeatures & content_craftitem_features(std::string subname);
#define CONTENT_CRAFTITEM_OERKKI_DUST_BLACK (CONTENT_CRAFTITEM_MASK | 0x74)
#define CONTENT_CRAFTITEM_GLASS_BOTTLE (CONTENT_CRAFTITEM_MASK | 0x75)
#define CONTENT_CRAFTITEM_GRAPE_JUICE (CONTENT_CRAFTITEM_MASK | 0x76)
#define CONTENT_CRAFTITEM_APPLE_JUICE (CONTENT_CRAFTITEM_MASK | 0x77)
#endif

View File

@ -3467,11 +3467,6 @@ void ClientEnvironment::step(float dtime)
damageLocalPlayerWithVacuum(pressure_per_second);
if (warmth_per_second != 0)
damageLocalPlayerWithWarmth(warmth_per_second);
if (lplayer->cold_effect)
lplayer->cold_effect--;
if (lplayer->energy_effect)
lplayer->energy_effect--;
}
if (m_hunger_interval.step(dtime,5.0)) {

View File

@ -557,11 +557,13 @@ void draw_hud(
Inventory *inventory,
bool have_health,
s32 halfheartcount,
bool have_cold_boost,
bool have_suffocation,
s32 halfbubblecount,
bool have_hunger,
s32 halfhungercount,
float energy,
bool have_energy_boost,
int crosshair,
bool nodeinfo,
bool selected,
@ -785,11 +787,23 @@ void draw_hud(
if (e < 0.0)
e = 0.0;
{
const video::SColor color(255,c,0,0);
u8 r = c;
u8 b = 0;
if (have_energy_boost) {
r = 0;
b = c;
}
const video::SColor color(255,r,0,b);
draw_progress_ring(driver,screensize,core::position2d<s32>(84,screensize.Y-84),30,e,color);
}
{
const video::SColor color(220,c,c,c);
u8 r = c;
u8 b = 0;
if (have_cold_boost) {
r = 0;
b = c;
}
const video::SColor color(220,r,0,b);
const video::SColor colors[] = {color,color,color,color};
video::ITexture *texture = driver->getTexture(getTexturePath("heart.png").c_str());
core::rect<s32> rect(60,screensize.Y-108,108,screensize.Y-60);
@ -2995,6 +3009,11 @@ void the_game(
snode = client.getEnv().getMap().getNodeNoEx(spos,NULL);
}
LocalPlayer *p = client.getLocalPlayer();
bool energy_boost = (p->energy_effectf > 0.0);
bool cold_boost = (p->cold_effectf > 0.0);
draw_hud(
driver,
font,
@ -3004,11 +3023,13 @@ void the_game(
&local_inventory,
client.getServerDamage(),
client.getHP(),
cold_boost,
client.getServerSuffocation(),
client.getAir(),
client.getServerHunger(),
hunger,
client.getEnergy(),
energy_boost,
crosshair,
show_debug,
has_selected_node,

View File

@ -740,6 +740,8 @@ video::ITexture* RemotePlayer::getTexture()
*/
LocalPlayer::LocalPlayer():
energy_effectf(0.0),
cold_effectf(0.0),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false),
m_can_use_energy(true)
@ -1006,7 +1008,7 @@ void LocalPlayer::applyControl(float dtime)
raising the height at which the jump speed is kept
at its starting value
*/
if (speed.Y < 6*BS && !energy_effect)
if (speed.Y < 6*BS && !energy_effectf)
m_energy -= 0.6;
speed.Y = 6.5*BS;
setSpeed(speed);
@ -1017,9 +1019,9 @@ void LocalPlayer::applyControl(float dtime)
speed.Y = 1.2*BS;
setSpeed(speed);
swimming_up = true;
if (!energy_effect)
if (!energy_effectf)
m_energy -= dtime;
}else if (in_water_stable && !energy_effect) {
}else if (in_water_stable && !energy_effectf) {
m_energy -= dtime;
}
}
@ -1040,14 +1042,14 @@ void LocalPlayer::applyControl(float dtime)
speed.Y = 1.5*BS;
setSpeed(speed);
swimming_up = true;
if (!energy_effect)
if (!energy_effectf)
m_energy -= dtime;
}
}else if (is_climbing) {
v3f speed = getSpeed();
speed.Y = 3*BS;
setSpeed(speed);
}else if (in_water_stable && m_can_use_energy && !energy_effect) {
}else if (in_water_stable && m_can_use_energy && !energy_effectf) {
m_energy -= dtime;
}
}
@ -1074,7 +1076,7 @@ void LocalPlayer::applyControl(float dtime)
// The speed of the player (Y is ignored)
if (control.fast && m_can_use_energy) {
if (!energy_effect && (speed.X || speed.Y || speed.Z))
if (!energy_effectf && (speed.X || speed.Y || speed.Z))
m_energy -= dtime;
if (control.free) {
speed = speed.normalize() * walkspeed_max * 6.0;
@ -1082,7 +1084,7 @@ void LocalPlayer::applyControl(float dtime)
speed = speed.normalize() * walkspeed_max * 3.0;
}
}else{
if (energy_effect) {
if (energy_effectf) {
if (m_energy < hp)
m_energy += dtime*5.0;
}else if (control.digging) {
@ -1109,6 +1111,11 @@ void LocalPlayer::applyControl(float dtime)
m_can_use_energy = true;
}
if (energy_effectf > 0.0)
energy_effectf -= dtime;
if (energy_effectf < 0.0)
energy_effectf = 0.0;
f32 inc = walk_acceleration * BS * dtime;
// Faster acceleration if fast and free movement

View File

@ -527,6 +527,9 @@ public:
PlayerControl control;
float energy_effectf;
float cold_effectf;
private:
// This is used for determining the sneaking range
v3s16 m_sneak_node;