Clonk can throw with the new controls:

+ temporary solution with ControlThrow
+ x,y from playercontrol gets passed as local coordinates
+ changed playercontrols.txt
stable-5.2
Tobias Zwick 2009-10-21 13:55:36 +02:00
parent 3b0d49e8c0
commit 927349e3aa
4 changed files with 65 additions and 25 deletions

View File

@ -13,6 +13,8 @@
local pInventory;
local throwAngle;
/* Initialization */
protected func Initialize()
@ -249,26 +251,50 @@ protected func Swimming2()
SetAction("Swim");
}
// temporary overload for testing...
public func ControlThrow(object thatsme, int x, int y)
{
if(!Contents(selected)) return false;
throwAngle = Angle(0,0,x,y);
SetAction("Throw");
if(throwAngle < 180) SetDir(1);
else SetDir(0);
Throwing();
return true;
}
private func Throwing()
{
// Erstes Inhaltsobjekt werfen
var pObj = Contents(0);
// Wurfparameter berechnen
// throw selected inventory
var obj = Contents(selected);
if(!obj) return;
// parameters...
var iX, iY, iR, iXDir, iYDir, iRDir;
iX = 0; if (!GetDir()) iX = -iX;
iY = -10;
iX = 8; if (!GetDir()) iX = -iX;
iY = Cos(throwAngle,-8);
iR = Random(360);
iXDir = GetPhysical("Throw") / 25000; if(!GetDir()) iXDir = -iXDir;
iYDir = -GetPhysical("Throw") / 25000;
iRDir = Random(40) - 20;
// Reitet? Eigengeschwindigkeit addieren
iRDir = RandomX(-10,10);
var speed = GetPhysical("Throw");
iXDir = speed * Sin(throwAngle,1000) / 17000;
iYDir = speed * Cos(throwAngle,-1000) / 17000;
// throw boost
if(iYDir < 0) iYDir = iYDir * 13/10;
if(iYDir > 0) iYDir = iYDir * 8/10;
Message("angle %d - velocity %d,%d",this,throwAngle,iXDir, iYDir);
// is riding? add it's velocity
if (GetActionTarget())
{
iXDir += GetActionTarget()->GetXDir() / 10;
iYDir += GetActionTarget()->GetYDir() / 10;
}
// Werfen!
pObj->Exit(iX, iY, iR, iXDir, iYDir, iRDir);
// throw
obj->Exit(iX, iY, iR, 0, 0, iRDir);
obj->SetXDir(iXDir,1000);
obj->SetYDir(iYDir,1000);
}
private func Fighting()

View File

@ -96,11 +96,15 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
{
// for standard controls
if(Control2Script(ctrl, x, y, strength, repeat, release, "Control", this)) return true;
}
if(!vehicle && !house)
{
// and a few more...
if(ctrl == CON_Throw) if(this->~ControlThrow(this,x,y)) return true;
if(ctrl == CON_Jump) if(this->~ControlJump(this)) return true;
}
// everything down from here:
// standard controls that are called if not overloaded via script

View File

@ -20,10 +20,19 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
{
// Object controlled by plr
cursor->SetController(plr);
// local coordinates
var cursorX = x, cursorY = y;
if(cursorX || cursorY)
{
cursorX -= cursor->GetX();
cursorY -= cursor->GetY();
}
// Overload by effect?
if (cursor->Control2Effect(plr, ctrl, x, y, strength, repeat, release)) return true;
if (cursor->Control2Effect(plr, ctrl, cursorX, cursorY, strength, repeat, release)) return true;
return cursor->ObjectControl(plr, ctrl, x,y, strength, repeat, release);
return cursor->ObjectControl(plr, ctrl, cursorX, cursorY, strength, repeat, release);
}
// No cursor? Nothing to handle control then
return false;
@ -75,13 +84,13 @@ global func Control2Player(int plr, int ctrl, int x, int y, int strength, bool r
}
StopSelected(plr);
}
/*
if (ctrl == CON_Test)
{
Message(Format("%d %d (%d %d) %d [%d %d]", plr, ctrl, x, y, strength, repeat, release));
return true;
}
*/
return false;
}
@ -102,6 +111,7 @@ global func StopSelected(int plr)
// Call control function in all effects that have "Control" in their name
global func Control2Effect(int ctrl, int x, int y, int strength, bool repeat, bool release)
{
// x and y are local coordinates
if (!this) return false;
// Count down from EffectCount, in case effects get deleted

View File

@ -316,13 +316,13 @@
# MenuUp, Up, Jump x W
# MenuDown, Down x S
#
# NextItem x Scrollwheel-Up (now: Up)
# PreviousItem x Scrollwheel-Down (now: Unassigned)
# NextItem x Scrollwheel-Up (now: Up)
# PreviousItem x Scrollwheel-Down (now: unassigned)
# Hotkey0-9 x (0-9)
#
# Use, Throw x Left mouse button (now: Left)
# Throw x Shift+Left mouse button (now: Right)
# Drop x S+Left mouse button (now: Down)
# Use, Throw x Left mouse button
# Throw x Shift+Left mouse button
# Drop x S+Left mouse button
#
# PushEnter, GrabNext, Ungrab,
# Grab, Exit, Enter x Space
@ -521,7 +521,7 @@
Control=PlayerMenu
#[Assignment]
#Key=Up
#Key=Mouse1Wheel1Down
#Control=PreviousItem
[Assignment]
@ -529,7 +529,7 @@
Control=NextItem
[Assignment]
Key=Left
Key=Mouse1ButtonLeft
Priority=100
Control=Use
@ -539,11 +539,11 @@
Control=Throw
[Assignment]
Key=Right
Key=Shift+Mouse1ButtonLeft
Control=Throw
[Assignment]
Key=Down
Key=S,Mouse1ButtonLeft
Control=Drop
[Assignment]