From 5c0819c7d49ca4bb2399adf86820d9a7c84d7556 Mon Sep 17 00:00:00 2001 From: ThomasMonroe314 Date: Sat, 2 Dec 2017 13:30:12 -0600 Subject: [PATCH] Added Plebs fireworks mod --- mods/firework/README.txt | 15 ++ mods/firework/depends.txt | 1 + mods/firework/init.lua | 221 +++++++++++++++++++ mods/firework/license.txt | 26 +++ mods/firework/textures/firework_blue.png | Bin 0 -> 364 bytes mods/firework/textures/firework_cyan.png | Bin 0 -> 377 bytes mods/firework/textures/firework_fountain.png | Bin 0 -> 164 bytes mods/firework/textures/firework_green.png | Bin 0 -> 363 bytes mods/firework/textures/firework_pink.png | Bin 0 -> 379 bytes mods/firework/textures/firework_red.png | Bin 0 -> 363 bytes mods/firework/textures/firework_rocket.png | Bin 0 -> 235 bytes mods/firework/textures/firework_star.png | Bin 0 -> 354 bytes mods/firework/textures/firework_white.png | Bin 0 -> 381 bytes mods/firework/textures/firework_yellow.png | Bin 0 -> 378 bytes 14 files changed, 263 insertions(+) create mode 100755 mods/firework/README.txt create mode 100755 mods/firework/depends.txt create mode 100755 mods/firework/init.lua create mode 100755 mods/firework/license.txt create mode 100644 mods/firework/textures/firework_blue.png create mode 100644 mods/firework/textures/firework_cyan.png create mode 100644 mods/firework/textures/firework_fountain.png create mode 100644 mods/firework/textures/firework_green.png create mode 100644 mods/firework/textures/firework_pink.png create mode 100644 mods/firework/textures/firework_red.png create mode 100644 mods/firework/textures/firework_rocket.png create mode 100644 mods/firework/textures/firework_star.png create mode 100644 mods/firework/textures/firework_white.png create mode 100644 mods/firework/textures/firework_yellow.png diff --git a/mods/firework/README.txt b/mods/firework/README.txt new file mode 100755 index 0000000..a3cf170 --- /dev/null +++ b/mods/firework/README.txt @@ -0,0 +1,15 @@ +Minetest Game mod +======================= +See license.txt for license information. + +Authors of source code +---------------------- +Plebs + +Authors of media (textures) +--------------------------- + +Plebs + + + diff --git a/mods/firework/depends.txt b/mods/firework/depends.txt new file mode 100755 index 0000000..4ad96d5 --- /dev/null +++ b/mods/firework/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/firework/init.lua b/mods/firework/init.lua new file mode 100755 index 0000000..913bcc1 --- /dev/null +++ b/mods/firework/init.lua @@ -0,0 +1,221 @@ +-- firework mod by Plebs, oct 2017 + +local textures={"firework_white.png","firework_green.png","firework_pink.png","firework_cyan.png","firework_red.png","firework_blue.png","firework_yellow.png","firework_white.png"} +local originsphere={} -- calc vectors only once and store in array to save time + +local time_countdown=3.0; -- particle trajectories are calculated just-in-time +local speed_motor=6.4; -- so all these variables can be adjusted for diffrent needs +local time_flight=3.2; -- the values were adjusted to look like real fireworks on low end hardware +local speed_explosion=3.6; +local time_explosion=0.6; +local acc_gravity=-0.8; +local acc_airdrag=-2.4; + +local function generate_sphere(rings,sectors) + local bla={1,4,8,12,8,4,1} -- bc i'm too stupid to make a dynamic sphere gen + local i=1;local ring;local sector;local s_gap + local r_gap=(1/(rings)) -- spacings + + for ring=0,rings do + for sector=0,bla[ring+1]-1 do + s_gap=(1/(bla[ring+1])) + originsphere[i]={} + originsphere[i].x=math.cos(2*math.pi*sector*s_gap) * math.sin(math.pi*ring*r_gap); + originsphere[i].y=math.sin(-(math.pi/2) + math.pi*ring*r_gap); + originsphere[i].z=math.sin(2*math.pi*sector*s_gap) * math.sin(math.pi*ring*r_gap); + i=i+1 + end + end +end + + +generate_sphere(6,12) -- precalculate sphere only once on start (param: rings, sectors) +minetest.log("firework mod with " .. #textures .." textures loaded. " .. #originsphere .." vectors have been precalculated successfully") + + +minetest.register_craftitem("firework:rocket",{ -- firework code and images by Plebs, Oct 2017 + description = "Firework Rocket", -- uses only built-in sounds + inventory_image = "firework_rocket.png", + + on_use = function(itemstack, player, pointed_thing) + local mypos = minetest.get_pointed_thing_position(pointed_thing,true) -- get placing position + if mypos == nil then return end -- if no solid ground clicked, return + mypos.vx=0;mypos.vy=0;mypos.vz=0; -- needs to be set, could be called in callback, before its generated due lag + local sphere={}; + local i; + local randomtexture=math.random(0,3) -- create a random texture for this firework + local acc_drift_x=(math.random()-0.5) -- random flight drift + local acc_drift_z=(math.random()-0.5) + for i=1,#originsphere do sphere[i]={};sphere[i].x=originsphere[i].x;sphere[i].y=originsphere[i].y;sphere[i].z=originsphere[i].z;sphere[i].vx=0;sphere[i].vy=0;sphere[i].vz=0;end -- make a copy of precalculated sphere + mypos.y=mypos.y-0.25; -- rocket offset, so halfsized texture touches the ground + + minetest.add_particle({ -- place rocket + pos={x=mypos.x,y=mypos.y,z=mypos.z}, + velocity={x=0,y=0,z=0}, + acceleration={x=0,y=0,z=0}, + expirationtime=time_countdown,size=5,collisiondetection=false,vertical=false,glow=LIGHT_MAX*0.8, + texture="firework_rocket.png",minetest.sound_play("default_place_node",{pos=mypos,max_hear_distance=8})}) + + minetest.after(time_countdown,function() + minetest.add_particle({ -- smoke + pos={x=mypos.x,y=mypos.y-0.15,z=mypos.z}, + velocity={x=0,y=-0.04,z=0}, + acceleration={x=0,y=0,z=0}, + expirationtime=2,size=8,collisiondetection=false,vertical=false,glow=2, + texture="default_item_smoke.png",minetest.sound_play("default_cool_lava",{pos=mypos,max_hear_distance=8,})}) + + minetest.add_particle({ -- flight rocket + pos={x=mypos.x,y=mypos.y,z=mypos.z}, + velocity={x=0,y=speed_motor,z=0}, + acceleration={x=acc_drift_x,y=acc_airdrag,z=acc_drift_z}, + expirationtime=time_flight,size=5.0,collisiondetection=false,vertical=false,glow=LIGHT_MAX*0.8, + texture="firework_rocket.png",minetest.sound_play("default_place_node",{pos=mypos,max_hear_distance=8})}) + mypos.x=mypos.x+ (0.5*acc_drift_x*time_flight*time_flight); --update particles to predicted new postions + mypos.y=mypos.y+((0.5*acc_airdrag*time_flight*time_flight)+(speed_motor*time_flight)); + mypos.z=mypos.z+ (0.5*acc_drift_z*time_flight*time_flight); + mypos.vx=(acc_drift_x*time_flight)*0.5 + mypos.vy=((acc_airdrag*time_flight)+speed_motor)*0.25 + mypos.vz=(acc_drift_z*time_flight)*0.5 + end) + + minetest.after(time_countdown+time_flight,function() -- show inital explosion + for i=1,#sphere do + sphere[i].vx=(sphere[i].x*speed_explosion); + sphere[i].vy=(sphere[i].y*speed_explosion); + sphere[i].vz=(sphere[i].z*speed_explosion); + + minetest.add_particle({ + pos={x=mypos.x,y=mypos.y,z=mypos.z}, + velocity={x=mypos.vx,y=mypos.vy,z=mypos.vz}, + acceleration={x=sphere[i].vx,y=sphere[i].vy,z=sphere[i].vz}, + expirationtime=time_explosion,size=0.5,collisiondetection=false,vertical=false,glow=LIGHT_MAX*0.8, + texture="firework_yellow.png"}) + sphere[i].x=mypos.x+(0.5*sphere[i].vx*time_explosion*time_explosion)+(mypos.vx*time_explosion); --update particles to predicted new postions + sphere[i].y=mypos.y+(0.5*sphere[i].vy*time_explosion*time_explosion)+(mypos.vy*time_explosion); + sphere[i].z=mypos.z+(0.5*sphere[i].vz*time_explosion*time_explosion)+(mypos.vz*time_explosion); + sphere[i].vx=((sphere[i].vx*(time_explosion))+mypos.vx)*0.125; + sphere[i].vy=((sphere[i].vy*(time_explosion))+mypos.vy)*0.125; + sphere[i].vz=((sphere[i].vz*(time_explosion))+mypos.vz)*0.125; + end; + end) + + minetest.after(time_countdown+time_flight+time_explosion,function() -- show spectacular particles + for i=1,#sphere do + minetest.add_particle({ + pos={x=sphere[i].x,y=sphere[i].y,z=sphere[i].z}, + velocity={x=sphere[i].vx,y=sphere[i].vy,z=sphere[i].vz}, + acceleration={x=0,y=acc_gravity,z=0}, + expirationtime=(math.random()*0.5)+1.4,size=(math.random()*0.4)+0.6,collisiondetection=false,vertical=false,glow=LIGHT_MAX, + texture=textures[math.random(1,2)+(randomtexture*2)]}) + end; + end) + + + minetest.after(time_countdown+time_flight+0.1,function() -- the sounds are detached, with slight delay for natural feeling + minetest.sound_play("default_dug_node",{pos={x=mypos.x,y=mypos.y,z=mypos.z},max_hear_distance=12})end) + + minetest.after(time_countdown+time_flight+time_explosion+0.1,function() + minetest.sound_play("default_dug_node",{pos={x=mypos.x,y=mypos.y,z=mypos.z},max_hear_distance=12})end) + + minetest.after(time_countdown+time_flight+time_explosion+0.2,function() + minetest.sound_play("default_dug_node",{pos={x=mypos.x,y=mypos.y,z=mypos.z},max_hear_distance=12})end) + + + itemstack:take_item() + return itemstack + end +}) + + + -- fountain code and images by Plebs, Oct 2017 + + +minetest.register_craftitem("firework:fountain",{ + description = "Firework Fountain", -- uses only built-in sounds + inventory_image = "firework_fountain.png", + + on_use=function(itemstack,player,pointed_thing) + local mypos=minetest.get_pointed_thing_position(pointed_thing,true) -- get placing position + if mypos==nil then return end -- if no soild ground clicked, return + local fountain_textures={"heart.png","bubble.png","firework_star.png"} + + minetest.add_particle({ -- place fountain + pos={x=mypos.x,y=mypos.y-0.25,z=mypos.z}, + velocity={x=0,y=0,z=0}, + acceleration={x=0,y=0,z=0}, + expirationtime=16,size=5,collisiondetection=false,vertical=false,glow=LIGHT_MAX*0.8, + texture="firework_fountain.png",minetest.sound_play("default_place_node",{pos=mypos,max_hear_distance=8})}) + + minetest.after(3,function() + minetest.add_particlespawner({ + minpos={x=mypos.x,y=mypos.y-0.14,z=mypos.z},maxpos={x=mypos.x,y=mypos.y,z=mypos.z}, + minvel={x=-0.2,y=1.2,z=-0.2},maxvel={x= 0.2,y=2.0,z= 0.2}, + minacc={x=0,y=-0.5,z=0},maxacc={x=0,y=-0.5,z=0}, + amount=64,time=12,minexptime=4,maxexptime=6,minsize=0.5,maxsize=1.0, + minetest.sound_play("default_cool_lava",{pos=mypos,max_hear_distance=8}), + collisiondetection=false,vertical=false,glow=LIGHT_MAX, + texture=fountain_textures[math.random(1,#fountain_textures)]}) + end) + + itemstack:take_item() + return itemstack + end}) + + + + + +-- craft receipes + +minetest.register_craft{ + type="shapeless", + output="firework:fountain 25", + recipe={"dye:blue","dye:yellow","dye:red", + "default:paper","default:paper","default:paper", + "default:coal_lump","default:coal_lump","default:coal_lump"}} + +minetest.register_craft{ + type="shapeless", + output="firework:rocket 25", + recipe={"dye:pink","dye:yellow","dye:cyan", + "default:paper","default:paper","default:paper", + "default:coal_lump","default:coal_lump","default:coal_lump"}} + + + + + + + + + + +-- snow generator, by Plebs Oct 2017 .. this is is early alpha for tests and special occasions only +-- not for Players. there can be only one snowarea at a time. amount varies with globalstep settings + +local snow=nil; + +minetest.register_craftitem("firework:snow",{ + description="Snow",inventory_image="firework_white.png", + on_use=function(itemstack,player,pointed_thing) + snow=player:getpos() + minetest.after(60,function()snow=nil;end) -- turn snow off after 60 seconds + itemstack:take_item() + return itemstack + end}) + +minetest.register_globalstep(function(dtime) -- snow in area + if snow==nil then return end -- if no solid ground clicked, return + local x=math.random()-0.5; + local y=math.random(); + local z=math.random()-0.5; + + for i=0,3 do + minetest.add_particle({ + pos={x=snow.x+((math.random()-0.5)*48),y=snow.y+y+14,z=snow.z+((math.random()-0.5)*48)}, + velocity={x=x*2,y=-(1.0+y),z=z*2}, + acceleration={x=-x*0.6,y=0,z=-z*0.6}, + expirationtime=y+8,size=1,collisiondetection=false,vertical=false,glow=LIGHT_MAX, + texture="firework_white.png"}) + end +end) diff --git a/mods/firework/license.txt b/mods/firework/license.txt new file mode 100755 index 0000000..eaa7f4e --- /dev/null +++ b/mods/firework/license.txt @@ -0,0 +1,26 @@ +License of source code +---------------------- + +Copyright (C) 2017 Plebs + +Permission is hereby granted, free of charge, to the owners of Minetest +Legends of Survial GameWorld known as ThomasMonroe and CalebDavis to use this Software +and associated files for the limited time of November 1, 2017 to May 31, 2018. +it does not permit any kind of distribution, copy, merge, publish, sublicensing and/or +selling of the software or parts of it. + + +The above copyright notice and this permission notice must not be removed from the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +Licenses of media (textures) +---------------------------- + +Copyright (C) 2017 Plebs diff --git a/mods/firework/textures/firework_blue.png b/mods/firework/textures/firework_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..1c3250f27786a8bbc04b0de1fe346ac30c95f578 GIT binary patch literal 364 zcmV-y0h9iTP)Ur&)D?GJ>lB3reqzW>K)*GfYO5=l%Y zk$ko242W2ZYT$8)dH0+-_uM;scCNaSO^NHTP_4H!_jZ6=Xyb5;V1YT+>KlT(fdic3 zJh7dhbBytv_*T?3H^>gq#Wk+b!)g9aFhCy<7=^SD)UDijjXT`n5}gptaDn3@mwH9D zYDRiHvabTZjhg)cmN?0NiWj_6PfH1hQP9iHT^wzc*h;*_5RZ7mv>B(1iqpv654f1z z%vmQn?SiZPaaHN@I<8J)*b?vf$oHPJS#stDS880Ozk|444BIqul-dW$U8J^ZO+C+$ z^fy|y-Nr}UC+9g+Srk+&>T!mov}*XnAdSmN|9O=E^D+JIIe!9EcV)3j;n`IH0000< KMNUMnLSTXi3Zwe~ literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_cyan.png b/mods/firework/textures/firework_cyan.png new file mode 100644 index 0000000000000000000000000000000000000000..984d12df20bde922c11a3e4e1dc21812a0846458 GIT binary patch literal 377 zcmV-<0fzpGP)@KJ>(695InS92(xVF&Axf_c0k_>;YK@;H2`LHH+9eh9s)5i=@ck|0<)^WKy&LD zm;(=rvHli72J941&L(OV8v_gA30MOwV5WZuAOSYOJFr(#6=-PB1%3sdfh90ifg|t; z+&N!Ds4%M{QIAD?E%1xjj089X_uA*cC-6lGxwkM8gOzSx0Jp6chl)#J3#7mYkVjJ5 zS1?W;*m1@mmubeeR6R(rGjIXE^<8v!R8HYI@3GW;6RGWjwME>k_e8m6 z)0IiCL;)$Ysk^hms7)LJETzkHL^d7w26p00i_ I>zopr03*9HjQ{`u literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_green.png b/mods/firework/textures/firework_green.png new file mode 100644 index 0000000000000000000000000000000000000000..f803ec13401a3e0cb69720295175da754af5a305 GIT binary patch literal 363 zcmV-x0hIoUP)ia*2H%~?af)WhT z1SOc&LuzD^;6WW2dYI|1uI{ecvS~H8b1HTPs@T@r+7P^h8oh4-3(QrPn*r8YyBOd& zw$AGu6FkJe7B-z0SQke)#~Ds>n71iLxWx?~0~&xe?LmUCaDgHE0eHa)_P_WxmMY6m zsMn!=mf*{<*-gM34sxF13C|j{QbI2bPLufvd#w_8Vuu*x4)?49wzKQh+)w6CtI3_* z_2W~QxXK?_l^L(n)oB{`hIf2qzvu2HKJyY+YFuQ#qjbA8tlh-N)IN&uVqIHhr7@34 zZd;@JKE^v-$LArc41>y2V-k^+QH_5P(xgcG&r<%!&-Bah{0U!mWwBq8=R^Pi002ov JPDHLkV1oKjoPGcR literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_pink.png b/mods/firework/textures/firework_pink.png new file mode 100644 index 0000000000000000000000000000000000000000..613a7833bbd12d360e814609cfb04bcb4c210ddb GIT binary patch literal 379 zcmV->0fhdEP)TO*KxmHxzQYYJFiL?poa0*~ zT-8-kR$ZtML;EV=+pswd-~->YpW_!^t2%Ej9EHJUZa&3vuf>DJ3p`?qpO|-1y0JJ3 z?ZbeZ$X(7x$r(0W@sF!y#+#`662U&O#_xRVoV_Jy(QvKDW#&7H+D)*&h|lSLlH4V9 zMcGt!5tBUhMzuZ0DejZ=6jy#SD9Wm;vzVlf>hTLB&6=hAPJ9o|nmJFuvhx3bOn>{F Z{{U47a~Q=L2#x>%002ovPDHLkV1m=#r#Jur literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_red.png b/mods/firework/textures/firework_red.png new file mode 100644 index 0000000000000000000000000000000000000000..45db6f480e8b40123b8de861b9250680137ba22c GIT binary patch literal 363 zcmV-x0hIoUP)pHB%R?GHq)B3-qszW>K)=PD%#j7Tb_ zkbJf93_U_xWCM>o%)95zx#!+#*|2Kb*_OD1DzUj*8^Am0VebdQ0`rRHMuObBi({N7 z_VRmkgf?L`#9ihT;d%45WM0H2SsqrvSQhZ z^j>5S1HOuyZUFB%%>Efqc&T|VCG17PAUB_2zfs~&;yLax!MzZ)eXBT%>~6rt|kbWy@8i$E&zHi(&8hz-PXXoV_MzUT~$xMfy9A+r_Y^i4UoLoZJO;DpvKHahg6K zGz@FDae|xVOf!{h1r^JB%{pqd>h708dMqQo^(g<}WBTiJ{sL=rWwGh&G}r(D002ov JPDHLkV1ivzq8tDK literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_rocket.png b/mods/firework/textures/firework_rocket.png new file mode 100644 index 0000000000000000000000000000000000000000..6a87a55e1986efb3e7d787ea5d4b7e6b82cb3b0b GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf_9t?W;tn;0?<-pO=$XBF#Dayw4(B2nzH9ySd98T9KT|uwu&K@O frIVKLwhHD&k(R4@jx03+x|YGy)z4*}Q$iB}P|{ZL literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_star.png b/mods/firework/textures/firework_star.png new file mode 100644 index 0000000000000000000000000000000000000000..c4b63287b47373aacc83ea948197312db697fa3a GIT binary patch literal 354 zcmV-o0iFJdP)i5QV=<+Cn1+8U)2IT^JNsK48hRkK(Jib5Y2`Wh*L5 zplX$-$+)OVZ<2e1v%7cZoH_FcJ*FwDDcTn!ePAZD{Ub||*dFWkvH!=c1e&5ma~R)% z1TdN5Dn+c0XbwlWzz~Xe_`XNiNLs#QV=uE0A6{|t&3*uBEf0yOWY&k{U|k(xQU z1}}usC5$e>KLtO6;nWJ281VpVl5+b8I)UO1wokUQ8&heFMjxlj`Q1T&`2qP7^5;Vd zt&t8I%)1qopP(y1VY2{T+f`Ietg~0mln{a#HmMtIs2Fsdx`wa&-mD!3jZwBT0l0h; zBV7dsu#%~1qAnt7AB_oYTfMdBk(sOP0y>F+U&TvzAeo$q%K!iX07*qoM6N<$g30uf ADgXcg literal 0 HcmV?d00001 diff --git a/mods/firework/textures/firework_white.png b/mods/firework/textures/firework_white.png new file mode 100644 index 0000000000000000000000000000000000000000..4ec67254dd7a128cd5d6694d5cb577b1a5285234 GIT binary patch literal 381 zcmV-@0fPRCP)={Qr;X bx6k&0Nz~KcR{#Ic@aD+`K~RF? znxF(T>mfDrkl+vct8pCU^@ycE143F)PJlEkLsF z;1I{LeV%8S;y(7ZvFQe2J2=8moZ}1!d3(YbH@L<_Kvw{veVE`&{K6?l0eHa)_CE<% zi&8AQQ13(gJi!-Xvz>r9{K)wkkN91y=T^dQ7@Q^Z5%vZpZpEJB78BgD0@%#%Q}Za9 zyFrt?+>PSXx47aTSILZ*>FQG&_J()-$$rn>OMGT6uGKite8=f_YuK=f52<||-#K)p zSk`J5k=zVM^>vIBT*c=;s$4NB#iCZzh@_3`_8TEho1}+Id=1T-IZwWm^8f!#fBT(3 Y0AK}k7}~|