Hideout: Fix warnings (shadowing local variable e), clean code

alut-include-path
Mark 2017-01-07 01:09:55 +01:00
parent 172613e0c9
commit df031f600e
5 changed files with 149 additions and 111 deletions

View File

@ -1,57 +1,59 @@
/*--- Pyre Gem ---*/
local e;
local has_graphics_e;
local thrower;
protected func Initialize()
public func Initialize()
{
if(Random(2))
if (Random(2))
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
if(this->GetX() < 920)
if (this->GetX() < 920)
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else if(this->GetX() > 1280)
else if (this->GetX() > 1280)
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
SetR(Random(360));
}
protected func Departure( from)
public func Departure(object from)
{
SetRDir(RandomX(-15,15));
thrower=from;
SetRDir(RandomX(-15, 15));
thrower = from;
}
func Hit()
{
AddEffect("GemPyre",nil,100,1,nil,nil,[GetX(),GetY()],e,this->GetOwner(),thrower->GetOwner());
AddEffect("GemPyre", nil, 100, 1, nil, nil, [GetX(), GetY()], has_graphics_e, this->GetOwner(), thrower->GetOwner());
RemoveObject();
}
global func FxGemPyreStart(object target, effect, int temporary, c, e, owner,thrower)
global func FxGemPyreStart(object target, effect, int temporary, array coordinates, bool e, int owner, int thrower_owner)
{
if (temporary)
return 1;
effect.x=c[0];
effect.y=c[1];
effect.e=e;
effect.thrower=thrower;
effect.owner=owner;
effect.objects=[];
effect.x = coordinates[0];
effect.y = coordinates[1];
effect.e = e;
effect.thrower = thrower_owner;
effect.owner = owner;
effect.objects = [];
effect.particles =
{
@ -59,7 +61,7 @@ global func FxGemPyreStart(object target, effect, int temporary, c, e, owner,thr
Size = PV_Linear(2, 0),
R = PV_Random(120, 140),
G = PV_Random(20, 30),
G = PV_Random(90, 110),
G = PV_Random(90, 110), // TODO: fix this
BlitMode = GFX_BLIT_Additive
};
@ -70,43 +72,57 @@ global func FxGemPyreStart(object target, effect, int temporary, c, e, owner,thr
effect.particles.B = PV_Random(20, 40);
}
}
global func FxGemPyreTimer(object target, effect, int time)
{
var x=effect.x;
var y=effect.y;
var e=effect.e;
var x = effect.x;
var y = effect.y;
var e = effect.e;
if(time > 32) return -1;
if (time > 32) return -1;
for(var i=0; i<(20 + time); i++)
for (var i = 0; i < (20 + time); i++)
{
var r = Random(360);
var d = Random((((time/2)+1)*6)-((time/2)*4))+((time/2)*4)+RandomX(-2,2);
if(!PathFree(x,y,x + Sin(r,d), y - Cos(r,d))) continue;
var clr=RGB(122+Random(20),18+Random(10),90+Random(20));
if(e)clr=RGB(190+Random(10),0,20+Random(20));
var xoff = Sin(r, d);
var d = Random((((time / 2) + 1) * 6) - ((time / 2) * 4)) + ((time / 2) * 4) + RandomX(-2, 2);
var xoff = +Sin(r, d);
var yoff = -Cos(r, d);
if (!PathFree(x, y, x + xoff, y + yoff)) continue;
var color; // TODO: this is not actually used??
if (e)
{
color = RGB(190 + Random(10), 0, 20 + Random(20));
}
else
{
color = RGB(122 + Random(20), 18 + Random(10), 90 + Random(20));
}
CreateParticle("Air", x + xoff, y + yoff, PV_Random(xoff - 3, xoff + 3), PV_Random(yoff - 3, yoff + 3), PV_Random(5, 10), effect.particles, 2);
}
for(var obj in FindObjects(Find_NoContainer(), Find_OCF(OCF_Alive), Find_Distance(((time/2)+1)*6,x,y),Find_Not(Find_Distance((time/2)*4,x,y)),Find_ID(Clonk)))
for (var obj in FindObjects(Find_NoContainer(), Find_OCF(OCF_Alive), Find_Distance(((time / 2) + 1) * 6, x, y), Find_Not(Find_Distance((time / 2) * 4, x, y)), Find_ID(Clonk)))
{
var end=false;
for(var i = 0; i < GetLength(effect.objects); i++)
if(obj == effect.objects[i]) end=true;
if(end) continue;
if(PathFree(x,y,obj->GetX(),obj->GetY()))
var end = false;
for (var i = 0; i < GetLength(effect.objects); i++)
{
obj->DoEnergy((-BoundBy((30-time),1,26)*3)/5,0,0,effect.thrower);
if (obj == effect.objects[i]) end = true;
}
if (end) continue;
if (PathFree(x, y, obj->GetX(), obj->GetY()))
{
obj->DoEnergy((-BoundBy((30-time), 1, 26) * 3) / 5, 0, 0, effect.thrower);
obj->CreateParticle("MagicFire", 0, 0, PV_Random(-15, 15), PV_Random(-15, 15), PV_Random(5, 10), effect.particles, 20);
obj->Fling(RandomX(-2,2),-2-(BoundBy((30-time),10,30)/10));
obj->Fling(RandomX(-2, 2), -2 - (BoundBy((30 - time), 10, 30) / 10));
effect.objects[GetLength(effect.objects)] = obj;
}
}
return 1;
}
local Collectible = 1;
local Collectible = true;
local Name = "$Name$";
local Description = "$Description$";

View File

@ -1,51 +1,53 @@
/*--- Shield Gem ---*/
local e;
local has_graphics_e;
protected func Initialize()
public func Initialize()
{
if(Random(2))
if (Random(2))
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
if(this->GetX() < 920)
if (this->GetX() < 920)
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else if(this->GetX() > 1280)
else if (this->GetX() > 1280)
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
SetR(Random(360));
}
protected func Departure()
public func Departure()
{
SetRDir(RandomX(-15,15));
SetRDir(RandomX(-15, 15));
}
func Hit()
{
AddEffect("GemShieldCreation",nil,100,1,nil,nil,GetX(),GetY(),e);
AddEffect("GemShieldCreation", nil, 100, 1, nil, nil, GetX(), GetY(), has_graphics_e);
RemoveObject();
}
global func FxGemShieldCreationStart(object target, effect, int temporary, x, y, e)
global func FxGemShieldCreationStart(object target, effect, int temporary, int x, int y, bool e)
{
if (temporary)
return 1;
effect.x=x;
effect.var1=y;
effect.var2=e;
effect.x = x;
effect.y = y;
effect.e = e;
effect.particles =
{
@ -62,27 +64,36 @@ global func FxGemShieldCreationStart(object target, effect, int temporary, x, y,
effect.particles.B = PV_Random(20, 40);
}
}
global func FxGemShieldCreationTimer(object target, effect, int time)
{
if(time > 26) return -1;
var x=effect.x;
var y=effect.var1;
var e=effect.var2;
var clr=RGB(122+Random(20),18+Random(10),90+Random(20));
if(e)clr=RGB(190+Random(10),0,20+Random(20));
if (time > 26) return -1;
var x = effect.x;
var y = effect.y;
var e = effect.e;
var color;
if (e)
{
color = RGB(190 + Random(10), 0, 20 + Random(20));
}
else
{
color = RGB(122 + Random(20), 18 + Random(10), 90 + Random(20));
}
var shield=CreateObjectAbove(CrystalShield,x+Sin(time*7,35),y+Cos(time*7,35));
shield->SetR(-time*7);
shield->SetClrModulation(clr);
CreateParticle("MagicSpark", x+Sin(time*7,39),y+Cos(time*7,39), PV_Random(-10, 10), PV_Random(-10, 10), PV_Random(10, 20), effect.particles, 10);
var shield=CreateObjectAbove(CrystalShield,x-Sin(-7+time*7,35),y+Cos(-7+time*7,35));
var shield=CreateObjectAbove(CrystalShield, x + Sin(time * 7, 35), y + Cos(time * 7, 35));
shield->SetR(-time * 7);
shield->SetClrModulation(color);
CreateParticle("MagicSpark", x + Sin(time * 7, 39), y + Cos(time * 7, 39), PV_Random(-10, 10), PV_Random(-10, 10), PV_Random(10, 20), effect.particles, 10);
var shield = CreateObjectAbove(CrystalShield, x - Sin(-7 + time * 7, 35),y + Cos(-7 + time * 7, 35));
shield->SetR(-7 + time*7);
shield->SetClrModulation(clr);
CreateParticle("MagicSpark", x-Sin(-7+time*7,39),y+Cos(-7+time*7,39), PV_Random(-10, 10), PV_Random(-10, 10), PV_Random(10, 20), effect.particles, 10);
shield->SetClrModulation(color);
CreateParticle("MagicSpark", x - Sin(-7 + time * 7, 39), y + Cos(-7 + time * 7, 39), PV_Random(-10, 10), PV_Random(-10, 10), PV_Random(10, 20), effect.particles, 10);
return 1;
}
local Collectible = 1;
local Collectible = true;
local Name = "$Name$";
local Description = "$Description$";

View File

@ -1,9 +1,9 @@
/*-- CrystalShield --*/
protected func Initialize()
public func Initialize()
{
AddEffect("Selfdestruction",this,100,4+Random(2),this,this->GetID());
AddEffect("Selfdestruction", this, 100, 4+Random(2), this, this->GetID());
return;
}
@ -19,7 +19,7 @@ func SetClrModulation(int color, int overlay_id)
}
}
func FxSelfdestructionStart(target, effect, temp)
func FxSelfdestructionStart(object target, proplist effect, temp)
{
if (temp) return;
effect.particles =
@ -29,10 +29,10 @@ func FxSelfdestructionStart(target, effect, temp)
};
}
func FxSelfdestructionTimer(object target, effect, int timer)
func FxSelfdestructionTimer(object target, proplist effect, int timer)
{
CreateParticle("Magic", PV_Random(-4, 4), PV_Random(-4, 4), PV_Random(-3, 3), PV_Random(-3, 3), PV_Random(10, 30), effect.particles, 3);
if(timer>175) target->RemoveObject();
if (timer > 175) target->RemoveObject();
return 1;
}

View File

@ -1,29 +1,29 @@
/*--- Flint ---*/
local e;
local has_graphics_e;
protected func Initialize()
{
if(Random(2))
if (Random(2))
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
if(this->GetX() < 920)
if (this->GetX() < 920)
{
SetGraphics("E");
e=true;
has_graphics_e = true;
}
else if(this->GetX() > 1280)
else if (this->GetX() > 1280)
{
SetGraphics("");
e=false;
has_graphics_e = false;
}
SetR(Random(360));
@ -31,23 +31,23 @@ protected func Initialize()
protected func Departure()
{
SetRDir(RandomX(-15,15));
SetRDir(RandomX(-15, 15));
}
func Hit()
{
AddEffect("GemSlowField",nil,100,1,nil,nil,GetX(),GetY(),e);
AddEffect("GemSlowField", nil, 100, 1, nil, nil, GetX(), GetY(), has_graphics_e);
RemoveObject();
}
global func FxGemSlowFieldStart(object target, effect, int temporary, x, y, e)
global func FxGemSlowFieldStart(object target, effect, int temporary, int x, int y, bool e)
{
if (temporary)
return 1;
effect.x=x;
effect.var1=y;
effect.var2=e;
effect.x = x;
effect.y = y;
effect.particles =
{
Prototype = Particles_Spark(),
@ -59,7 +59,7 @@ global func FxGemSlowFieldStart(object target, effect, int temporary, x, y, e)
OnCollision = PC_Die(),
CollisionVertex = 1000
};
if (e)
{
effect.particles.R = PV_Random(190, 210);
@ -67,32 +67,43 @@ global func FxGemSlowFieldStart(object target, effect, int temporary, x, y, e)
effect.particles.B = PV_Random(20, 40);
}
}
global func FxGemSlowFieldTimer(object target, effect, int time)
{
var x=effect.x;
var y=effect.var1;
var e=effect.var2;
if(time > (150)) return -1;
for(var i=0; i<40; i++)
var x = effect.x;
var y = effect.y;
if (time > 150) return FX_Execute_Kill;
var radius = 62;
for (var i = 0; i < 40; i++)
{
var r=Random(360);
var d=Min(Random(20)+Random(130),62);
if(!PathFree(x,y,x + Sin(r,d), y - Cos(r,d))) continue;
CreateParticle("MagicFire", x + Sin(r,d), y - Cos(r,d), PV_Random(-2, 2), PV_Random(0, 4), PV_Random(10, 40), effect.particles, 2);
var r = Random(360);
var d = Min(Random(20) + Random(130), radius);
var xoff = +Sin(r, d);
var yoff = -Cos(r, d);
if (!PathFree(x, y, x + xoff, y + yoff)) continue;
CreateParticle("MagicFire", x + xoff, y + yoff, PV_Random(-2, 2), PV_Random(0, 4), PV_Random(10, 40), effect.particles, 2);
}
for(var obj in FindObjects(Find_Distance(62,x,y)))
for (var obj in FindObjects(Find_Distance(radius, x, y)))
{
if(!PathFree(x,y,obj->GetX(),obj->GetY())) continue;
if(Distance(0,0,obj->GetXDir(),obj->GetYDir()) < 16 ) continue;
var speed=Distance(0,0,obj->GetXDir(),obj->GetYDir());
var dir = Angle(0,0,obj->GetXDir(),obj->GetYDir());
obj->SetXDir(obj->GetXDir(100) + Sin(-dir,speed*3) ,100);
obj->SetYDir(obj->GetYDir(100) + Cos(-dir,speed*3) -10,100);
if (!PathFree(x, y, obj->GetX(), obj->GetY())) continue;
var speed = Distance(0, 0, obj->GetXDir(), obj->GetYDir());
if (speed < 16 ) continue;
var angle = Angle(0, 0, obj->GetXDir(), obj->GetYDir());
obj->SetXDir(obj->GetXDir(100) + Sin(-angle, speed * 3), 100);
obj->SetYDir(obj->GetYDir(100) + Cos(-angle, speed * 3) -10, 100);
obj->SetYDir(obj->GetYDir()-5);
}
return 1;
}
local Collectible = 1;
local Collectible = true;
local Name = "$Name$";
local Description = "$Description$";