Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / [Patch] Effects for walljump and hangling
- - By Andriel Date 2014-04-22 14:00 Edited 2014-05-31 19:51
Added:
-dust particles and material fragment particles for walljump and hangling (in texture colour)
-3 sound effects: Crumble1.ogg, Crumble2.ogg and Crumble3.ogg
-existing sound effects Rustle?.ogg for both walljump and hangling
-existing sound effects StepHard?.ogg for walljump

Some materials are excluded from the particle creation, because it doesn't look good in my opinion. Those are: Gold, Firestone, Ruby, Amethyst, Granite, Ore, and for corner cases: Lava, DuroLava, Acid, Sky, Water.
What I'm unsure about is the implementation of that exclusion. This is what I came up with:

// certain materials won't crumble (because it doesn't look good), also rule out liquids and sky
var exception_mats = [Material("Gold"), Material("Amethyst"), Material("Ruby"), Material("Firestone"), Material("Ore"), Material("Granite"), Material("Water"), Material("Lava"), Material("DuroLava"), Material("Acid"), Material("Sky")];
var material = GetMaterial(get_tex_x, 9);

for(element in exception_mats)
  if(element == material)
  {  // they'll still do the sounds
    Sound("StepHard?");
    Sound("Rustle?");
    return;
  }


Feel free to optimize!

EDIT:
Old patch deleted, see this post for the updated file.
Reply
Parent - By Maikel Date 2014-04-22 14:21
You can make the array a lot shorter by:

if (Material(element) == material)
Parent - - By Zapper [de] Date 2014-04-22 14:41

>Feel free to optimize!



// do sounds...
// ...

if (GetMaterialVal("DigFree", "Material", material) != 0)
{
    // do particles
}
Parent - - By Andriel Date 2014-04-22 17:37
Ok, I agree with you and Sven on the upwards compatibility, but I'd still need to add exceptions for Firestone (diggable but not wanted), Rock and Brick + BrickSoft:

// These two sounds are always played
Sound("StepHard?");
Sound("Rustle?");

// certain materials shouldn't crumble (because it doesn't look good)
var material = GetMaterial(get_tex_x, 9);
// firestone is an exception from the rule below
if(material == Material("Firestone"))
  return;
// only diggable materials, except for Rock, Brick and BrickSoft
if ((GetMaterialVal("DigFree", "Material", material) != 1) && ((material != Material("Rock")) && (material != Material("Brick")) && (material != Material("BrickSoft"))))
  return;
// particles ...


Is this better?
Reply
Parent - - By Zapper [de] Date 2014-04-22 18:06

>Is this better?


I am still not too happy with the exceptions (see Sven), but in your example, I think it should be:
if (not diggable OR material == A OR material == B OR ...) return; instead of ANDs.

PS: also, Rock and Brick are not diggable, right?
Parent - - By Sven2 Date 2014-04-22 18:10
No, his logic is correct.

He wants no particles if it's not diggable, except if it's rock or brick. Then he wants particles.
Parent - By Zapper [de] Date 2014-04-22 18:13
Ah, I see!
Parent - - By Sven2 Date 2014-04-22 18:09
I don't understand the pattern. Why wouldn't you want the effect on firestone? Why do you want it on brick and rock, but not on granite?
Parent - By Zapper [de] Date 2014-04-22 18:14
I'd also say that the dust effect should be played on all materials that have a dust effect when dug out or when rolled on or when walked over. So, basically all diggable materials.

It can't look that horrendous, can it? :)
Parent - - By Andriel Date 2014-04-22 19:20
The "pattern" is merely my subjective opinion on where the effect fits and where not. I think it looks good on brick and rock, while granite is much harder and therefore, no fragments will brake loose. (Although granite is arguably the least critical exception).
I will of course add the effect for firestone and granite if you all insist on it, but you should at least try out for yourselves how it looks.
Reply
Parent - By Zapper [de] Date 2014-04-22 19:24
I won't insist on it.

I am not sure what happens when the materials are not loaded, though
Parent - - By Sven2 Date 2014-04-22 19:38
If it really depends on the material so much, I think a new property like DustParticle should be introduced to the .ocm file.
Parent - - By Andriel Date 2014-04-27 11:10
If you implement something like this in the near future, I'll adapt my code. Otherwise I think that my initial solution + Maikel's optimization are easier than that huge if:

// These two sounds are always played
Sound("StepHard?");
Sound("Rustle?");

// certain materials shouldn't crumble (because it doesn't look good)
var material = GetMaterial(get_tex_x, 9);

// firestone is an exception from the rule below
if(material == Material("Firestone"))
  return;
   
// only diggable materials should crumble, except for Rock, Brick and BrickSoft
if((GetMaterialVal("DigFree", "Material", material) == 0) && ((material != Material("Rock")) && (material != Material("Brick")) && (material != Material("BrickSoft"))))
  return;
// effects ...


vs

// These two sounds are always played
Sound("StepHard?");
Sound("Rustle?");

// certain materials shouldn't crumble (because it doesn't look good)
var exception_mats = ["Gold", "Firestone", "Ore", "Granite", "Amethyst", "Ruby"];
var material = GetMaterial(get_tex_x, 9);

for(element in exception_mats)
  if(material == Material(element)) return;
// effects ...
Reply
Parent - By Andriel Date 2014-05-31 19:49
Okay, so here is the updated patch with the changes from above.

I hereby license the file 0001-Added-gfx-sfx-for-walljump-and-hang.patch under the CC-BY license
Reply
Parent - - By Sven2 Date 2014-04-22 15:34
I agree with Zapper that you should rather use a generic material property rather than a list because this would give some better upwards compatibility.

We could add new material properties to the .ocm files for that. Another cool idea would be if the engine automatically created a static proplist from all loaded .ocm files that would look like this:

static const Materials = {
  Earth = {
    DigFree=1,
    DustParticle="dust",
    ...
  },
...
};


Then you could just write stuff like:

if (Materials[MaterialName(material)].DustParticle) ...

or

if (Materials.Earth.DigFree) ...
Parent - By Günther [de] Date 2014-05-24 23:03

> Another cool idea would be if the engine automatically created a static proplist from all loaded .ocm files


We could even replace the ocm files with a system.ocg script that defined that proplist and have the material part of the engine read that. (In the far future, the StdCompiler will be reduced to reading network packages and savegames, having lost everything else to the script parser...)
Reply
Up Topic Development / Developer's Corner / [Patch] Effects for walljump and hangling

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill