Digging w/ shovel, minor bugfixes

Tobias Zwick 2009-12-07 14:33:04 +01:00
parent bfc7e3b074
commit be53401c54
5 changed files with 28 additions and 13 deletions

View File

@ -138,16 +138,24 @@ public func FxIntSearchInteractionObjectsTimer(object target, int num, int time)
var max = EffectVar(1,target,num);
// target->FindObjects(Find_AtPoint(0,0),Find_OCF(OCF_Grab),Find_NoContainer());
// doesnt work!! -> BUG!
// doesnt work!! -> BUG! (TODO)
var vehicles = FindObjects(Find_AtPoint(target->GetX()-GetX(),target->GetY()-GetY()),Find_OCF(OCF_Grab),Find_NoContainer());
// don't forget the vehicle that the clonk is pushing (might not be found
// by the findobjects because it is not at that point)
var vehicles = CreateArray();
var pushed = nil;
if(target->GetProcedure() == "PUSH" && (pushed = target->GetActionTarget()))
// if contained, don't search for vehicles...
// TODO: change to: list vehicles inside buildings to push out?
if((!target->Contained()))
{
ActionButton(target,i++,pushed,ACTIONTYPE_VEHICLE);
if(max) if(i >= max) return ClearButtons(i);
vehicles = FindObjects(Find_AtPoint(target->GetX()-GetX(),target->GetY()-GetY()),Find_OCF(OCF_Grab),Find_NoContainer());
// don't forget the vehicle that the clonk is pushing (might not be found
// by the findobjects because it is not at that point)
if(target->GetProcedure() == "PUSH" && (pushed = target->GetActionTarget()))
{
ActionButton(target,i++,pushed,ACTIONTYPE_VEHICLE);
if(max) if(i >= max) return ClearButtons(i);
}
}
for(var vehicle in vehicles)

View File

@ -9,6 +9,7 @@ public func ControlUse(object clonk, int x, int y)
{
if(clonk->GetAction() == "Walk")
{
clonk->SetAction("Dig");
clonk->SetComDir(COMD_None);
clonk->SetXDir(0);
@ -21,6 +22,7 @@ public func ControlUse(object clonk, int x, int y)
public func ControlUseHolding(object clonk, int x, int y)
{
// something happened - don't try to dig anymore
if(clonk->GetAction() != "Dig") return -1;
@ -40,6 +42,7 @@ public func ControlUseHolding(object clonk, int x, int y)
public func ControlUseStop(object clonk, int x, int y)
{
RemoveEffect("ShovelDust",clonk,0);
if(clonk->GetAction() != "Dig") return true;

View File

@ -85,7 +85,7 @@ public func SelectItem(selection)
*/
// cancel the use of another item
if(using == item) { using->~ControlUseStop(this,mlastx,mlasty); using = nil; }
if(item) if(using == item) { using->~ControlUseStop(this,mlastx,mlasty); using = nil; }
// de-select previous (if any)
if(item) item->~Deselection(this);
@ -231,6 +231,9 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
{
if (!this) return false;
//Log(Format("%d, %d, %d, %v, %v", x,y,ctrl, repeat, release));
// Any control resets a previously given command
SetCommand("None");
@ -353,6 +356,7 @@ private func Control2Script(int ctrl, int x, int y, int strength, bool repeat, b
// for the use command
if (ctrl == CON_Use)
{
var handled = false;
if(!release && !repeat)

View File

@ -23,7 +23,7 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
// local coordinates
var cursorX = x, cursorY = y;
if(cursorX || cursorY)
if(x != nil || y != nil)
{
cursorX -= cursor->GetX();
cursorY -= cursor->GetY();

View File

@ -546,10 +546,10 @@
Key=S,GameMouse1ButtonLeft
Control=Drop
[Assignment]
Key=GameMouse1Move
Priority=50
Control=Test
#[Assignment]
#Key=GameMouse1Move
#Priority=50
#Control=Test