diff --git a/planet/Objects.ocd/System.ocg/Effects.c b/planet/Objects.ocd/System.ocg/Effects.c new file mode 100644 index 000000000..e120059e2 --- /dev/null +++ b/planet/Objects.ocd/System.ocg/Effects.c @@ -0,0 +1,77 @@ +/* + Contains functions for (visual) effects that require particles or definitions from Objects.ocd to be loaded. +*/ + +/* +Creates a visual explosion effect at a position. +smoothness (in percent) determines how round the effect will look like +*/ +global func ExplosionEffect(int level, int x, int y, int smoothness, bool silent, int damage_level) +{ + // Zero-size explosion doesn't affect anything + if (level <= 0) return; + + if(!silent) //Does object use it's own explosion sound effect? + { + var grade = BoundBy(level / 10 - 1, 1, 3); + if(GBackLiquid(x, y)) + SoundAt(Format("BlastLiquid%d",grade), x, y); + else + SoundAt(Format("Blast%d", grade), x, y); + } + + // possibly init particle definitions? + if (!ExplosionParticles_Blast) + ExplosionParticles_Init(); + + smoothness = smoothness ?? 0; + var level_pow = level ** 2; + var level_pow_fraction = Max(level_pow / 25, 5 * level); + var wilderness_level = level * (100 - smoothness) / 100; + var smoothness_level = level * smoothness / 100; + + var smoke_size = PV_KeyFrames(0, 180, level, 1000, level * 2); + var blast_size = PV_KeyFrames(0, 0, 0, 260, level * 2, 1000, level); + var blast_smooth_size = PV_KeyFrames(0, 0, 0, 250, PV_Random(level, level * 2), 1000, level); + var star_size = PV_KeyFrames(0, 0, 0, 500, level * 2, 1000, 0); + var shockwave_size = PV_Linear(0, level * 4); + + CreateParticle("SmokeDirty", PV_Random(x - 10,x + 10), PV_Random(y - 10, y + 10), 0, PV_Random(-2, 0), PV_Random(50, 100), {Prototype = ExplosionParticles_Smoke, Size = smoke_size}, Max(2, wilderness_level / 10)); + CreateParticle("SmokeDirty", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-1, 1), PV_Random(-1, 1), PV_Random(20, 40), {Prototype = ExplosionParticles_BlastSmoothBackground, Size = blast_smooth_size}, smoothness_level / 5); + CreateParticle("SmokeDirty", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-1, 1), PV_Random(-1, 1), PV_Random(20, 40), {Prototype = ExplosionParticles_BlastSmooth, Size = blast_smooth_size}, smoothness_level / 5); + CreateParticle("Dust", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), 0, 0, PV_Random(18, 25), {Prototype = ExplosionParticles_Blast, Size = blast_size}, smoothness_level / 5); + CreateParticle("StarFlash", PV_Random(x - 6, x + 6), PV_Random(y - 6, y + 6), PV_Random(-wilderness_level/4, wilderness_level/4), PV_Random(-wilderness_level/4, wilderness_level/4), PV_Random(10, 12), {Prototype = ExplosionParticles_Star, Size = star_size}, wilderness_level / 3); + CreateParticle("Shockwave", x, y, 0, 0, 15, {Prototype = ExplosionParticles_Shockwave, Size = shockwave_size}, nil); + + // cast either some sparks on land or bubbles under water + if(GBackLiquid(x, y) && Global.CastBubbles) + { + Global->CastBubbles(level * 7 / 10, level, x, y); + } + else + { + CreateParticle("Magic", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-level_pow_fraction, level_pow_fraction), PV_Random(-level_pow_fraction, level_pow_fraction), PV_Random(25, 70), ExplosionParticles_Glimmer, level); + } + + // very wild explosion? Smoke trails! + var smoke_trail_count = wilderness_level / 10; + var angle = Random(360); + var failsafe = 0; // against infinite loops + while (smoke_trail_count > 0 && (++failsafe < smoke_trail_count * 10)) + { + angle += RandomX(40, 80); + var smokex = Sin(angle, RandomX(level / 4, level / 2)); + var smokey = -Cos(angle, RandomX(level / 4, level / 2)); + if (GBackSolid(x + smokex, y + smokey)) + continue; + var lvl = 2 * wilderness_level; + CreateSmokeTrail(lvl, angle, x + smokex, y + smokey); + smoke_trail_count--; + } + + // Temporary light effect + if (level > 5) + Global->CreateLight(x, y, level, Fx_Light.LGT_Blast); + + return; +} diff --git a/planet/System.ocg/FindLocation.c b/planet/Objects.ocd/System.ocg/FindLocation.c similarity index 100% rename from planet/System.ocg/FindLocation.c rename to planet/Objects.ocd/System.ocg/FindLocation.c diff --git a/planet/Objects.ocd/System.ocg/GUI.c b/planet/Objects.ocd/System.ocg/GUI.c new file mode 100644 index 000000000..f8f98c309 --- /dev/null +++ b/planet/Objects.ocd/System.ocg/GUI.c @@ -0,0 +1,15 @@ +/** + Contains UI related functions that require definitions from Objects.ocd to be loaded. +*/ + +// The default menu decoration used in most places. +global func GetDefaultMenuDecoration() +{ + return GUI_MenuDeco; +} + +// Returns the symbol used for aborting or canceling. +global func GetDefaultCancelSymbol() +{ + return Icon_Cancel; +} diff --git a/planet/System.ocg/Explode.c b/planet/System.ocg/Explode.c index 60805ade3..88d589bd9 100644 --- a/planet/System.ocg/Explode.c +++ b/planet/System.ocg/Explode.c @@ -185,75 +185,13 @@ global func DoExplosion(int x, int y, int level, object inobj, int cause_plr, ob /* Creates a visual explosion effect at a position. -smoothness (in percent) determines how round the effect will look like -*/ -global func ExplosionEffect(int level, int x, int y, int smoothness, bool silent, int damage_level) -{ - // Zero-size explosion doesn't affect anything - if (level <= 0) return; - - if(!silent) //Does object use it's own explosion sound effect? - { - var grade = BoundBy(level / 10 - 1, 1, 3); - if(GBackLiquid(x, y)) - SoundAt(Format("BlastLiquid%d",grade), x, y); - else - SoundAt(Format("Blast%d", grade), x, y); - } - - // possibly init particle definitions? - if (!ExplosionParticles_Blast) - ExplosionParticles_Init(); - - smoothness = smoothness ?? 0; - var level_pow = level ** 2; - var level_pow_fraction = Max(level_pow / 25, 5 * level); - var wilderness_level = level * (100 - smoothness) / 100; - var smoothness_level = level * smoothness / 100; - - var smoke_size = PV_KeyFrames(0, 180, level, 1000, level * 2); - var blast_size = PV_KeyFrames(0, 0, 0, 260, level * 2, 1000, level); - var blast_smooth_size = PV_KeyFrames(0, 0, 0, 250, PV_Random(level, level * 2), 1000, level); - var star_size = PV_KeyFrames(0, 0, 0, 500, level * 2, 1000, 0); - var shockwave_size = PV_Linear(0, level * 4); - - CreateParticle("SmokeDirty", PV_Random(x - 10,x + 10), PV_Random(y - 10, y + 10), 0, PV_Random(-2, 0), PV_Random(50, 100), {Prototype = ExplosionParticles_Smoke, Size = smoke_size}, Max(2, wilderness_level / 10)); - CreateParticle("SmokeDirty", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-1, 1), PV_Random(-1, 1), PV_Random(20, 40), {Prototype = ExplosionParticles_BlastSmoothBackground, Size = blast_smooth_size}, smoothness_level / 5); - CreateParticle("SmokeDirty", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-1, 1), PV_Random(-1, 1), PV_Random(20, 40), {Prototype = ExplosionParticles_BlastSmooth, Size = blast_smooth_size}, smoothness_level / 5); - CreateParticle("Dust", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), 0, 0, PV_Random(18, 25), {Prototype = ExplosionParticles_Blast, Size = blast_size}, smoothness_level / 5); - CreateParticle("StarFlash", PV_Random(x - 6, x + 6), PV_Random(y - 6, y + 6), PV_Random(-wilderness_level/4, wilderness_level/4), PV_Random(-wilderness_level/4, wilderness_level/4), PV_Random(10, 12), {Prototype = ExplosionParticles_Star, Size = star_size}, wilderness_level / 3); - CreateParticle("Shockwave", x, y, 0, 0, 15, {Prototype = ExplosionParticles_Shockwave, Size = shockwave_size}, nil); - - // cast either some sparks on land or bubbles under water - if(GBackLiquid(x, y) && Global.CastBubbles) - { - Global->CastBubbles(level * 7 / 10, level, x, y); - } - else - { - CreateParticle("Magic", PV_Random(x - 5, x + 5), PV_Random(y - 5, y + 5), PV_Random(-level_pow_fraction, level_pow_fraction), PV_Random(-level_pow_fraction, level_pow_fraction), PV_Random(25, 70), ExplosionParticles_Glimmer, level); - } - - // very wild explosion? Smoke trails! - var smoke_trail_count = wilderness_level / 10; - var angle = Random(360); - var failsafe = 0; // against infinite loops - while (smoke_trail_count > 0 && (++failsafe < smoke_trail_count * 10)) - { - angle += RandomX(40, 80); - var smokex = Sin(angle, RandomX(level / 4, level / 2)); - var smokey = -Cos(angle, RandomX(level / 4, level / 2)); - if (GBackSolid(x + smokex, y + smokey)) - continue; - var lvl = 2 * wilderness_level; - CreateSmokeTrail(lvl, angle, x + smokex, y + smokey); - smoke_trail_count--; - } - - // Temporary light effect - if (level>5) CreateLight(x, y, level, Fx_Light.LGT_Blast); +smoothness (in percent) determines how round the effect will look like. - return; +Defined in Objects.ocd/System.ocg because it depends on particles/definitions to be loaded. +*/ +global func ExplosionEffect(...) +{ + return _inherited(...); } /*-- Blast objects & shockwaves --*/ diff --git a/planet/System.ocg/GUIs.c b/planet/System.ocg/GUIs.c index c554cd89b..5f7a44da8 100644 --- a/planet/System.ocg/GUIs.c +++ b/planet/System.ocg/GUIs.c @@ -20,7 +20,7 @@ global func GuiAddCloseButton(proplist menu, proplist target, string callback, p Priority = 0x0fffff, Left = "100%-2em", Top = "0%+0em", Right = "100%", Bottom = "0%+2em", - Symbol = Icon_Cancel, + Symbol = GetDefaultCancelSymbol(), BackgroundColor = {Std = 0, Hover = 0x50ffff00}, OnMouseIn = GuiAction_SetTag("Hover"), OnMouseOut = GuiAction_SetTag("Std"), @@ -115,3 +115,9 @@ global func CanBeStackedWith(object other) { return this->GetID() == other->GetID(); } + +// Returns the default symbol used for the "cancel" icon displayed e.g. in the top-right corner of menus. +global func GetDefaultCancelSymbol() +{ + return _inherited(...); +} diff --git a/planet/System.ocg/Player.c b/planet/System.ocg/Player.c index 551d7cedc..4306337f4 100644 --- a/planet/System.ocg/Player.c +++ b/planet/System.ocg/Player.c @@ -139,10 +139,17 @@ global func MessageWindow(string msg, int for_plr, id icon, string caption) if (!caption) caption = GetName(); // Create msg window as regular text - CustomMessage(Format("%s: %s", caption, msg), nil, for_plr, 0,150, nil, GUI_MenuDeco, icon, MSG_HCenter); + CustomMessage(Format("%s: %s", caption, msg), nil, for_plr, 0,150, nil, GetDefaultMenuDecoration(), icon, MSG_HCenter); return true; } +// Returns the default menu decoration used in most places. +// The return value should be a definition, e.g. GUI_MenuDeco. +global func GetDefaultMenuDecoration() +{ + return _inherited(...); +} + // Find a base of the given player. Use index to search through all bases. global func FindBase (int iPlr, int iIndex) {