Add new “death” particles and sound, fix mana bug

master
Wuzzy 2016-03-12 08:39:20 +01:00
parent 093daec544
commit 83d8b33a16
4 changed files with 79 additions and 7 deletions

View File

@ -64,12 +64,20 @@ But the speed in liquids is greatly reduced and your carpet will likely fail.
Long-term usage
---------------
Your carpet is not indestructible! Long flights, scratching and crashes will wear out the carpet over
time and it might get destroyed eventually—even in mid-flight!
time and it might get destroyed eventually.
Crash-landing at high speeds will deal major damage, so you should avoid crashing at all costs.
Sliding on the surface will deal a minor wear but it is often negligible.
A constant wear is also caused by flying, but very slowly.
If you always fly perfectly, you could use a single flying carpet for about 12 hours. Fly safe to make
the most of your flying carpet!
On high wear levels, the carpet will emit black particles behind it which will increase in number
with its wear. As long there are only a few black particles, you're still good as long as you don't
crash-land. You should get a replacement soon. If the number of black particles is about the
same as the yellow/red particles, the wear has reached a critical level.
On a very high wear, the carpet will emit a very annoying loud noise while flying. This is the final warning,
you will have roughly five minutes worth of flight until the carpet finally disintegrates under your feet!
You should land as soon as possible.
Additionally, a flying carpet will disintegrate and is lost forever if it stands still and has no user
for 1 minute.
@ -101,6 +109,7 @@ Authors and licenses of media files:
- flying_carpet_model.obj: Wuzzy, WTFPL
- flying_carpet_flight.ogg: WTFPL
- flying_carpet_out_of_energy.ogg: by p0ss, CC-BY-SA 3.0
- flying_carpet_almost_dead.ogg: by John, WTFPL
- flying_carpet_place.ogg: Unknown authors and Wuzzy (compilation of Public Domain sounds), WTFPL
- flying_carpet_take.ogg: Julien Matthey, modified by Wuzzy, WTFPL
- flying_carpet_surface.png: Roman Zacharij and Wuzzy, WTFPL
@ -111,4 +120,5 @@ Authors and licenses of media files:
- flying_carpet_smoke.png.png: Wuzzy. WTFPL
- flying_carpet_star.png: Wuzzy, WTFPL
- flying_carpet_star_warning.png: Wuzzy, WTFPL
- flying_carpet_star_death.png: Wuzzy, WTFPL
- flying_carpet_star_death_warning.png: Wuzzy, WTFPL
- flying_carpet_death.png: Wuzzy, WTFPL

View File

@ -125,6 +125,7 @@ local carpet = {
wear = 0, -- Damage / wear of carpet, corresponds to tool wear
sound_slide = nil, -- Sound handle for sliding loop
sound_flight = nil, -- Sound handle for flight loop
sound_death_warning=nil, -- Sound handle for flight loop with high damage
slidepos = nil, -- Position of nearby node which has been checked for sliding
slidenode = nil, -- Node definition of nearby node which has been checked for sliding
liquidpos = nil, -- Position of nearby node which has been checked for being a liquid
@ -208,6 +209,10 @@ function carpet:get_staticdata()
minetest.sound_stop(self.sound_slide)
self.sound_slide = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
local data = {}
data.v = self.v
data.h = self.h
@ -237,6 +242,10 @@ function carpet:on_punch(puncher, time_from_last_punch, tool_capabilities, direc
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
-- Someone punches slow non-flying carpet
elseif (self.driver == nil or self.driver == puncher) and (self.v < 1 and math.abs(self.h) < 1) and not self.flying then
-- Collect carpet
@ -252,6 +261,10 @@ function carpet:on_punch(puncher, time_from_last_punch, tool_capabilities, direc
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
if self.sound_slide then
minetest.sound_stop(self.sound_slide)
self.sound_slide = nil
@ -377,6 +390,10 @@ function carpet:on_step(dtime)
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
end
end
@ -411,6 +428,7 @@ function carpet:on_step(dtime)
end
local src = self.object:getpos()
local velo = self.object:getvelocity()
-- Speed indicator particles
minetest.add_particlespawner({
amount = math.ceil(math.min(3,math.max(0,self.v+3))),
time = 0.1,
@ -418,19 +436,48 @@ function carpet:on_step(dtime)
maxpos = {x=src.x+0.6, y=src.y-0.02, z=src.z+0.6},
minvel = {x=velo.x*0.01,y=velo.y*0.01,z=velo.z*0.01},
maxvel = {x=velo.x*0.01,y=velo.y*0.01,z=velo.z*0.01},
minexptime=2.2,
maxexptime=1.8,
minexptime=1.8,
maxexptime=2.2,
minsize=1,
maxsize=1.25,
texture = star,
})
-- Death warning particles
if self.wear > 58499 then
minetest.add_particlespawner({
--[[ More speed and more wear = more particles.
Carefully adjusted to roughly match the number of speed indicator particles
At near full wear, the number of death warning particles should be equal
to the number of speed indicator particles ]]
amount = math.ceil(math.min(3,math.max(0,(self.v+3)/(18-(self.wear-58499)/391)))),
time = 0.1,
minpos = {x=src.x-0.6, y=src.y-0.06, z=src.z-0.6},
maxpos = {x=src.x+0.6, y=src.y-0.06, z=src.z+0.6},
minvel = {x=velo.x*0.005,y=velo.y*0.005,z=velo.z*0.005},
maxvel = {x=velo.x*0.005,y=velo.y*0.005,z=velo.z*0.005},
minexptime=5,
maxexptime=7,
minsize=1,
maxsize=1.25,
texture = "flying_carpet_star_death_warning.png"
})
end
end
if not self.sound_flight then
self.sound_flight = minetest.sound_play("flying_carpet_flight", {object = self.object, gain = 0.6, max_hear_distance = 16, loop = true })
end
elseif self.sound_flight then
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
if self.wear > 64624 and not self.sound_death_warning then
self.sound_death_warning = minetest.sound_play("flying_carpet_death_warning", {object = self.object, gain = 0.2, max_hear_distance = 24, loop = true })
end
else
if self.sound_flight then
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
end
end
@ -521,6 +568,11 @@ function carpet:on_step(dtime)
magic_particle(self.object)
if self.sound_flight then
self.sound_flight = minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
self.sound_death_warning = minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
self.v = self.v - 0.04
end
@ -581,17 +633,26 @@ function carpet:on_step(dtime)
minetest.sound_stop(self.sound_flight)
self.sound_flight = nil
end
if self.sound_death_warning then
minetest.sound_stop(self.sound_death_warning)
self.sound_death_warning = nil
end
if self.sound_slide then
minetest.sound_stop(self.sound_slide)
self.sound_slide = nil
end
-- Detach driver and refund mana
if self.driver ~= nil then
self.driver:set_detach()
if mod_model then
default.player_attached[self.driver:get_player_name()] = false
default.player_set_animation(self.driver, "stand", 30)
end
if mod_mana then
mana.setregen(self.driver:get_player_name(), mana.getregen(self.driver:get_player_name())+mana_regen_cost)
end
end
minetest.sound_play("flying_carpet_out_of_energy", {pos = self.object:getpos(), gain=0.7})
self.object:remove()
return
end
@ -638,6 +699,7 @@ minetest.register_tool("flying_carpet:carpet", {
local ent = minetest.add_entity(place_pos, "flying_carpet:carpet")
ent:setyaw(placer:get_look_yaw())
ent:get_luaentity().wear = itemstack:get_wear()
itemstack:take_item()
minetest.sound_play("flying_carpet_place", {pos = place_pos, gain = 1})
return itemstack

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B