Jar of Winds autorelaod

MimmoO 2010-04-17 19:06:52 +02:00
parent 241ec5e2dd
commit 23e1713990
1 changed files with 46 additions and 58 deletions

View File

@ -8,91 +8,78 @@
local Amount;
local MaxCap;
local charging;
local JarTrans;
public func GetCarryMode(clonk) { return CARRY_BothHands; }
public func GetCarryTransform(clonk) { return JarTrans; } // TODO change when ck has fixed the bug
public func GetCarryPhase() { return 600; }
public func FxJarReloadTimer(object target, int effect, int time)
{
target->Load();
}
protected func Initialize()
{
MaxCap = 50; //Changes duration and power of the Jar
MaxCap = 60; //Changes duration and power of the Jar
SetR(-45);
JarTrans = Trans_Translate(-1500,2000,0);
AddEffect("JarReload",this,100,2,this);
}
protected func HoldingEnabled() { return true; }
protected func ControlUseStart(object pClonk, ix, iy)
protected func ControlUse(object pClonk, iX, iY)
{
Sound("WindCharge.ogg",false,nil,nil,1);
charging = 1;
Amount = 0;
return 1;
if(!GetEffect("JarReload",this))
{
if(!GBackLiquid())
{
JarTrans = Trans_Translate(-1500,2000,0);
FireWeapon(pClonk, iX, iY);
Amount=0;
AddEffect("JarReload",this,100,1,this);
Sound("WindCharge.ogg",false,nil,nil,1);
}
return true;
}
else
{
Message("Reloading!",pClonk);
return true;
}
ChargeSoundStop();
}
public func ControlUseHolding(object pClonk, ix, iy)
protected func Load()
{
JarTrans = Trans_Mul(Trans_Translate(-1500,2000,0), Trans_Rotate(Angle(0,0,ix,iy) * (-1 + 2 * pClonk->GetDir()),0,0,1));
// TODO a bit hacky, but i fear using animations here also leads to the bug like the musket and co. So I'll make the animation when the bug is fixed
pClonk->UpdateAttach();
//Angle Finder
if(GBackSolid()) return -1;
if(GBackLiquid()) return -1;
//not in material
if(Amount <= MaxCap)
{
var R=RandomX(-25,25);
var D=RandomX(19,130);
var SX=Sin(180 - Angle(0,0,ix,iy) + R,D);
var SY=Cos(180 - Angle(0,0,ix,iy) + R,D);
var D=RandomX(19,50);
var A=Random(360);
var SX=Sin(A + R,D);
var SY=Cos(A + R,D);
if(!GBackSolid(SX,SY) && !GBackLiquid(SX,SY)) //when on a random spot in front is air...
{
Amount += 2; //Air is sucked in.
Message("Loading...|%3.0d",pClonk,(Amount * 99) / MaxCap);
CreateParticle("AirIntake",
SX,SY,
Sin(180 - Angle(0,0,ix,iy) + R,-D / 2),
Cos(180 - Angle(0,0,ix,iy) + R,-D / 2),
Sin(A + R,-D / 2),
Cos(A + R,-D / 2),
RandomX(35,80),
RGBa(255,255,255,128)
);
}
}
else //Is it full? Say so!
else
{
Message("Full!",pClonk);
if(charging == 1) ChargeSoundStop();
charging = 0;
RemoveEffect("JarReload",this);
ChargeSoundStop();
}
}
protected func ControlUseStop(object pClonk, ix, iy)
{
JarTrans = Trans_Translate(-1500,2000,0);
if(Amount>(MaxCap/5)) //Is there enough air to fire?
{
// Fire
FireWeapon(pClonk, ix, iy);
return 1;
}
ChargeSoundStop();
charging = 0;
return 1;
}
func ControlUseCancel()
{
ChargeSoundStop();
charging = 0;
}
protected func ChargeSoundStop()
{
Sound("WindCharge.ogg",false,nil,nil,-1);
@ -113,15 +100,15 @@ private func FireWeapon(object pClonk,iX,iY)
var SX = Sin(180 - Angle(0,0,iX,iY) + R,i);
var SY = Cos(180 - Angle(0,0,iX,iY) + R,i);
if(!GBackSolid(SX,SY))
{
CreateParticle("Air",
if(!GBackSolid(SX,SY))
{
CreateParticle("Air",
SX,SY,
Sin(180 - Angle(0,0,iX,iY) + (R),(Amount / 2) + 25),
Cos(180 - Angle(0,0,iX,iY) + (R),(Amount / 2) + 25),
Max(i + 30, 90),
);
}
}
}
var sinspeed = Sin(180 - Angle(0,0,iX,iY) + (R / 2),(Amount) + 15);
@ -140,9 +127,11 @@ private func FireWeapon(object pClonk,iX,iY)
Find_Distance(10,Sin(180 - Angle(0,0,iX,iY),20),Cos(180 - Angle(0,0,iX,iY),20)),
Find_Distance(18,Sin(180 - Angle(0,0,iX,iY),40),Cos(180 - Angle(0,0,iX,iY),40)),
Find_Distance(25,Sin(180 - Angle(0,0,iX,iY),70),Cos(180 - Angle(0,0,iX,iY),70))
),
),
Find_Not(Find_Category(C4D_Structure))
)) {
)
)
{
if(obj != pClonk && PathFree(pClonk->GetX(),pClonk->GetY(),obj->GetX(),obj->GetY()))
{
//enemys are pushed back
@ -154,7 +143,6 @@ private func FireWeapon(object pClonk,iX,iY)
}
}
func Definition(def) {
SetProperty("Name", "$Name$", def);
}