reimplement alt use on right mouse button

This replaces throwing then controlling or inside a vehicle, throwing items remains on RMB as is.
Controls
Maikel de Vries 2015-06-27 16:56:45 +02:00
parent 83124d86f4
commit 91cd15c40c
8 changed files with 89 additions and 90 deletions

View File

@ -50,6 +50,7 @@ static const ACTIONTYPE_EXTRA = 4;
this.control.current_object: object that is being used at the moment this.control.current_object: object that is being used at the moment
this.control.using_type: way of usage this.control.using_type: way of usage
this.control.alt: alternate usage by right mouse button
this.control.mlastx: last x position of the cursor this.control.mlastx: last x position of the cursor
this.control.mlasty: last y position of the cursor this.control.mlasty: last y position of the cursor
this.control.noholdingcallbacks: whether to do HoldingUseControl callbacks this.control.noholdingcallbacks: whether to do HoldingUseControl callbacks
@ -74,6 +75,7 @@ protected func Construction()
menu = nil; menu = nil;
this.control.alt = false;
this.control.current_object = nil; this.control.current_object = nil;
this.control.using_type = nil; this.control.using_type = nil;
this.control.shelved_command = nil; this.control.shelved_command = nil;
@ -256,7 +258,8 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
*/ */
if (this.control.current_object && ctrl == CON_Aim) if (this.control.current_object && ctrl == CON_Aim)
{ {
ctrl = CON_Use; if (this.control.alt) ctrl = CON_UseAlt;
else ctrl = CON_Use;
repeat = true; repeat = true;
release = false; release = false;
@ -287,7 +290,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// save last mouse position: // save last mouse position:
// if the using has to be canceled, no information about the current x,y // if the using has to be canceled, no information about the current x,y
// is available. Thus, the last x,y position needs to be saved // is available. Thus, the last x,y position needs to be saved
if (ctrl == CON_Use) if (ctrl == CON_Use || ctrl == CON_UseAlt)
{ {
this.control.mlastx = x; this.control.mlastx = x;
this.control.mlasty = y; this.control.mlasty = y;
@ -313,7 +316,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
var contents = this->GetHandItem(0); var contents = this->GetHandItem(0);
// usage // usage
var use = (ctrl == CON_Use || ctrl == CON_UseDelayed); var use = (ctrl == CON_Use || ctrl == CON_UseDelayed || ctrl == CON_UseAlt || ctrl == CON_UseAltDelayed);
if (use) if (use)
{ {
if (house) if (house)
@ -588,12 +591,17 @@ func DetermineUsageType(object obj)
func GetUseCallString(string action) func GetUseCallString(string action)
{ {
// Control... or Contained... // Control... or Contained...
var control = "Control"; var control_string = "Control";
if (this.control.using_type == C4D_Structure) control = "Contained"; if (this.control.using_type == C4D_Structure)
control_string = "Contained";
// ..Use.. or ..UseAlt...
var estr = "";
if (this.control.alt && this.control.using_type != C4D_Object)
estr = "Alt";
// Action // Action
if (!action) action = ""; if (!action)
action = "";
return Format("~%sUse%s",control,action); return Format("~%sUse%s%s", control_string, estr, action);
} }
func CanReIssueCommand(proplist data) func CanReIssueCommand(proplist data)
@ -629,6 +637,7 @@ func StartUseControl(int ctrl, int x, int y, object obj)
obj->SetController(GetController()); obj->SetController(GetController());
this.control.current_object = obj; this.control.current_object = obj;
this.control.using_type = DetermineUsageType(obj); this.control.using_type = DetermineUsageType(obj);
this.control.alt = ctrl != CON_Use;
var hold_enabled = obj->Call("~HoldingEnabled"); var hold_enabled = obj->Call("~HoldingEnabled");
@ -675,6 +684,7 @@ func StartUseDelayedControl(int ctrl, object obj)
this.control.current_object = obj; this.control.current_object = obj;
this.control.using_type = DetermineUsageType(obj); this.control.using_type = DetermineUsageType(obj);
this.control.alt = ctrl != CON_UseDelayed;
VirtualCursor()->StartAim(this); VirtualCursor()->StartAim(this);
@ -706,7 +716,7 @@ func StopUseControl(int x, int y, object obj, bool cancel)
var stop = "Stop"; var stop = "Stop";
if (cancel) stop = "Cancel"; if (cancel) stop = "Cancel";
// ControlUseStop, ContainedUseCancel, etc... // ControlUseStop, ControlUseAltStop, ContainedUseAltStop, ContainedUseCancel, etc...
var handled = obj->Call(GetUseCallString(stop),this,x,y); var handled = obj->Call(GetUseCallString(stop),this,x,y);
if (obj == this.control.current_object) if (obj == this.control.current_object)
{ {
@ -728,6 +738,7 @@ func StopUseControl(int x, int y, object obj, bool cancel)
this.control.current_object = nil; this.control.current_object = nil;
this.control.using_type = nil; this.control.using_type = nil;
this.control.alt = false;
if (removal_helper) if (removal_helper)
{ {
@ -749,7 +760,7 @@ func HoldingUseControl(int ctrl, int x, int y, object obj)
{ {
var mex = x; var mex = x;
var mey = y; var mey = y;
if (ctrl == CON_UseDelayed) if (ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
{ {
mex = this.control.mlastx; mex = this.control.mlastx;
mey = this.control.mlasty; mey = this.control.mlasty;
@ -798,11 +809,10 @@ func HoldingUseControl(int ctrl, int x, int y, object obj)
func StopUseDelayedControl(object obj) func StopUseDelayedControl(object obj)
{ {
// ControlUseStop, etc... // ControlUseStop, ControlUseAltStop, ContainedUseAltStop, etc...
var handled = obj->Call(GetUseCallString("Stop"), this, this.control.mlastx, this.control.mlasty);
var handled = obj->Call(GetUseCallString("Stop"),this,this.control.mlastx,this.control.mlasty);
if (!handled) if (!handled)
handled = obj->Call(GetUseCallString(),this,this.control.mlastx,this.control.mlasty); handled = obj->Call(GetUseCallString(), this, this.control.mlastx, this.control.mlasty);
if (obj == this.control.current_object) if (obj == this.control.current_object)
{ {
@ -812,6 +822,7 @@ func StopUseDelayedControl(object obj)
{ {
this.control.current_object = nil; this.control.current_object = nil;
this.control.using_type = nil; this.control.using_type = nil;
this.control.alt = false;
} }
this.control.noholdingcallbacks = false; this.control.noholdingcallbacks = false;
} }
@ -846,7 +857,7 @@ func FxItemRemovalCheckStop(object target, proplist effect, int reason, bool tem
func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool release, object obj) func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool release, object obj)
{ {
// standard use // standard use
if (ctrl == CON_Use) if (ctrl == CON_Use || ctrl == CON_UseAlt)
{ {
if (!release && !repeat) if (!release && !repeat)
{ {
@ -858,7 +869,7 @@ func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool r
} }
} }
// gamepad use // gamepad use
else if (ctrl == CON_UseDelayed) else if (ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
{ {
if (!release && !repeat) if (!release && !repeat)
{ {
@ -871,7 +882,7 @@ func ControlUse2Script(int ctrl, int x, int y, int strength, bool repeat, bool r
} }
// more use (holding) // more use (holding)
if (ctrl == CON_Use || ctrl == CON_UseDelayed) if (ctrl == CON_Use || ctrl == CON_UseAlt || ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
{ {
if (release) if (release)
{ {
@ -894,13 +905,15 @@ func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, b
// overloads of movement commandos // overloads of movement commandos
if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Down || ctrl == CON_Up || ctrl == CON_Jump) if (ctrl == CON_Left || ctrl == CON_Right || ctrl == CON_Down || ctrl == CON_Up || ctrl == CON_Jump)
{ {
var control = "Control"; var control_string = "Control";
if (Contained() == obj) control = "Contained"; if (Contained() == obj)
control_string = "Contained";
if (release) if (release)
{ {
// if any movement key has been released, ControlStop is called // if any movement key has been released, ControlStop is called
if (obj->Call(Format("~%sStop",control),this,ctrl)) return true; if (obj->Call(Format("~%sStop", control_string), this, ctrl))
return true;
} }
else else
{ {
@ -909,10 +922,10 @@ func ControlMovement2Script(int ctrl, int x, int y, int strength, bool repeat, b
return true; return true;
// Control* // Control*
if (ctrl == CON_Left) if (obj->Call(Format("~%sLeft",control),this)) return true; if (ctrl == CON_Left) if (obj->Call(Format("~%sLeft",control_string),this)) return true;
if (ctrl == CON_Right) if (obj->Call(Format("~%sRight",control),this)) return true; if (ctrl == CON_Right) if (obj->Call(Format("~%sRight",control_string),this)) return true;
if (ctrl == CON_Up) if (obj->Call(Format("~%sUp",control),this)) return true; if (ctrl == CON_Up) if (obj->Call(Format("~%sUp",control_string),this)) return true;
if (ctrl == CON_Down) if (obj->Call(Format("~%sDown",control),this)) return true; if (ctrl == CON_Down) if (obj->Call(Format("~%sDown",control_string),this)) return true;
// for attached (e.g. horse: also Jump command // for attached (e.g. horse: also Jump command
if (GetProcedure() == "ATTACH") if (GetProcedure() == "ATTACH")

View File

@ -36,7 +36,7 @@ func Control2Menu(int ctrl, int x, int y, int strength, bool repeat, bool releas
// update angle for visual effect on the menu // update angle for visual effect on the menu
if (repeat) if (repeat)
{ {
if (ctrl == CON_UseDelayed) if (ctrl == CON_UseDelayed || ctrl == CON_UseAltDelayed)
this->GetMenu()->~UpdateCursor(mex,mey); this->GetMenu()->~UpdateCursor(mex,mey);
} }
// click on menu // click on menu
@ -132,7 +132,8 @@ public func TriggerHoldingControl()
if (/*this.control.current_object && */!this.control.noholdingcallbacks) if (/*this.control.current_object && */!this.control.noholdingcallbacks)
{ {
var ctrl = CON_UseDelayed; var ctrl = CON_UseDelayed;
if (this.control.alt)
ctrl = CON_UseAltDelayed;
ObjectControl(GetOwner(), ctrl, 0, 0, 0, true, false); ObjectControl(GetOwner(), ctrl, 0, 0, 0, true, false);
} }

View File

@ -52,16 +52,6 @@ protected func RejectCollect(id def, object obj)
/*-- Control --*/ /*-- Control --*/
public func ControlUseStart(object clonk, int ix, int iy) public func ControlUseStart(object clonk, int ix, int iy)
{
return UseAnyStart(clonk,ix,iy,0);
}
public func ControlUseAltStart(object clonk, int ix, int iy)
{
return UseAnyStart(clonk,ix,iy,1);
}
private func UseAnyStart(object clonk, int ix, int iy, int item)
{ {
var result = CheckForKeg(clonk); var result = CheckForKeg(clonk);
if (!result) if (!result)
@ -70,7 +60,7 @@ private func UseAnyStart(object clonk, int ix, int iy, int item)
return true; return true;
} }
if (!clonk->GetHandItem(item)) if (!clonk->GetHandItem(0))
{ {
PlayerMessage(clonk->GetOwner(),"$TxtNeedsAmmo$"); PlayerMessage(clonk->GetOwner(),"$TxtNeedsAmmo$");
clonk->CancelUse(); clonk->CancelUse();
@ -109,11 +99,6 @@ private func CheckForKeg(object clonk)
public func HoldingEnabled() { return true; } public func HoldingEnabled() { return true; }
public func ControlUseAltHolding(object clonk, int ix, int iy)
{
return ControlUseHolding(clonk, ix, iy);
}
local angPrec = 1000; local angPrec = 1000;
public func ControlUseHolding(object clonk, int ix, int iy) public func ControlUseHolding(object clonk, int ix, int iy)
@ -165,23 +150,12 @@ private func ConvertAngle(int angle)
public func ControlUseStop(object clonk, int ix, int iy) public func ControlUseStop(object clonk, int ix, int iy)
{ {
return UseAnyStop(clonk,ix,iy,0);
}
public func ControlUseAltStop(object clonk, int ix, int iy)
{
return UseAnyStop(clonk,ix,iy,1);
}
private func UseAnyStop(object clonk, int ix, int iy, int item)
{
RemoveTrajectory(this); RemoveTrajectory(this);
if (!CheckForKeg(clonk)) if (!CheckForKeg(clonk))
return true; return true;
var projectile = clonk->GetHandItem(item); var projectile = clonk->GetHandItem(0);
if (!projectile) // Needs a projectile if (!projectile) // Needs a projectile
{ {
PlayerMessage(clonk->GetOwner(),"$TxtNeedsAmmo$"); PlayerMessage(clonk->GetOwner(),"$TxtNeedsAmmo$");
@ -219,11 +193,6 @@ public func ControlUseCancel()
return true; return true;
} }
public func ControlUseAltCancel()
{
return ControlUseCancel();
}
//Stops the player from shooting for the defined amount of frames //Stops the player from shooting for the defined amount of frames
public func FxIntCooldownTimer(object target, effect, int timer) public func FxIntCooldownTimer(object target, effect, int timer)
{ {

View File

@ -81,26 +81,13 @@ public func ControlUseStart(object clonk)
return true; return true;
} }
public func ControlUseAltStart(object clonk) public func HoldingEnabled() { return true; }
{
return true;
}
public func HoldingEnabled() { return true; }
public func ControlUseAnyHolding(object clonk, int x, int y)
{
ArmAnimation(x,y);
}
public func ControlUseHolding(object clonk, int x, int y) public func ControlUseHolding(object clonk, int x, int y)
{ {
ControlUseAnyHolding(clonk,x,y); ArmAnimation(x,y);
} return true;
public func ControlUseAltHolding(object clonk, int x, int y)
{
ControlUseAnyHolding(clonk,x,y);
} }
public func DefinePower(int x, int y) public func DefinePower(int x, int y)
@ -122,26 +109,21 @@ public func DefinePower(int x, int y)
public func ArmAnimation(int x, int y) public func ArmAnimation(int x, int y)
{ {
var power = DefinePower(x,y); var power = DefinePower(x, y);
SetAnimationPosition(aim_anim, Anim_Const(759 - (power * 759 / 100))); SetAnimationPosition(aim_anim, Anim_Const(759 - (power * 759 / 100)));
} }
public func ControlUseStop(object clonk, int x, int y) public func ControlUseStop(object clonk, int x, int y)
{ {
DoFire(clonk,DefinePower(x,y),0); DoFire(clonk, DefinePower(x,y));
}
public func ControlUseAltStop(object clonk, int x, int y)
{
DoFire(clonk,DefinePower(x,y),1);
} }
public func ContainedUse(object clonk, int x, int y) public func ContainedUse(object clonk, int x, int y)
{ {
DoFire(clonk, 70, nil); DoFire(clonk, 70);
} }
protected func DoFire(object clonk, int power, int hand) protected func DoFire(object clonk, int power)
{ {
//Fire the catapult! //Fire the catapult!
// PlayAnimation("Launch", 5, Anim_Linear(0,0, GetAnimationLength("Launch"), 10, ANIM_Remove), Anim_Const(1000)); // PlayAnimation("Launch", 5, Anim_Linear(0,0, GetAnimationLength("Launch"), 10, ANIM_Remove), Anim_Const(1000));
@ -151,10 +133,12 @@ protected func DoFire(object clonk, int power, int hand)
Sound("Catapult_Launch"); Sound("Catapult_Launch");
var projectile = nil; var projectile = nil;
if(Contents(0)) projectile = Contents(0); //Is clonk sitting in the catapult? Then (s)he shall be the projectile! if (Contents(0))
projectile = Contents(0); //Is clonk sitting in the catapult? Then (s)he shall be the projectile!
else else
if(clonk->GetHandItem(hand)) projectile = clonk->GetHandItem(hand); //otherwise, fire what is in the clonk's hand if(clonk->GetHandItem(0))
if(projectile) projectile = clonk->GetHandItem(0); //otherwise, fire what is in the clonk's hand
if (projectile)
{ {
//finding the spot of the catapult's arm depending on rotation //finding the spot of the catapult's arm depending on rotation
var i = 1; var i = 1;

View File

@ -97,6 +97,6 @@ global func IsCrewControl(int ctrl)
/** Control uses selected item */ /** Control uses selected item */
global func IsUseControl(int ctrl) global func IsUseControl(int ctrl)
{ {
if (ctrl == CON_Use) return true; if (ctrl == CON_Use || ctrl == CON_UseAlt) return true;
return false; return false;
} }

View File

@ -246,6 +246,20 @@
Hold=1 Hold=1
SendCursorPos=1 SendCursorPos=1
[ControlDef]
Identifier=UseAlt
GUIName=$CON_UseAlt$
GUIDesc=$CON_UseAlt_Desc$
Hold=1
SendCursorPos=1
[ControlDef]
Identifier=UseAltDelayed
GUIName=$CON_UseAlt$
GUIDesc=$CON_UseAlt_Desc$
Hold=1
SendCursorPos=1
[ControlDef] [ControlDef]
Identifier=CancelUse Identifier=CancelUse
@ -516,8 +530,7 @@
# Use Left mouse button # Use Left mouse button
# Drop S+Left mouse button # Drop S+Left mouse button
# Throw Right mouse button # Throw Right mouse button
# # UseAlt Right mouse button (low priority)
# UseAlt Shift + Left mouse button
# #
# Interact Space # Interact Space
# #
@ -666,6 +679,15 @@
GUIGroup=20 GUIGroup=20
Control=Throw Control=Throw
[Assignment]
Key=Mouse1ButtonRight
Priority=80
GUIName=$KEY_MouseUseAlt$
GUIDesc=$KEY_MouseUseAlt_Desc$
GUIDisabled=1
GUIGroup=20
Control=UseAlt
# Zoom # Zoom
[Assignment] [Assignment]

View File

@ -24,6 +24,8 @@ CON_Use=Benutzen
CON_Use_Desc=Benutzen des Gegenstandes in der Hand. CON_Use_Desc=Benutzen des Gegenstandes in der Hand.
CON_Throw=Werfen CON_Throw=Werfen
CON_Throw_Desc=Werfen des Gegenstandes in der Hand in die anvisierte Richtung. CON_Throw_Desc=Werfen des Gegenstandes in der Hand in die anvisierte Richtung.
CON_UseAlt=Use
CON_UseAlt_Desc=Use the item in the hand alternatively.
CON_Hotkey1=Hotkey 1 CON_Hotkey1=Hotkey 1
CON_Hotkey2=Hotkey 2 CON_Hotkey2=Hotkey 2
@ -68,6 +70,9 @@ KEY_MouseUse_Desc=Benutzen des Gegenstandes in der Hand.
KEY_MouseThrow=Werfen KEY_MouseThrow=Werfen
KEY_MouseThrow_Desc=Werfen des Gegenstandes in der Hand. KEY_MouseThrow_Desc=Werfen des Gegenstandes in der Hand.
KEY_MouseUseAlt=Use Alt
KEY_MouseUseAlt_Desc=Secondary use.
KEY_GamepadUse=Benutzen / Werfen KEY_GamepadUse=Benutzen / Werfen
KEY_GamepadUse_Desc=Benutzen des Gegenstandes in der Hand. Falls der Gegenstand nicht benutzt werden kann, wird er stattdessen bei Loslassen der Taste in die Richtung geworfen in die mit dem Analog Stick gezielt wird. KEY_GamepadUse_Desc=Benutzen des Gegenstandes in der Hand. Falls der Gegenstand nicht benutzt werden kann, wird er stattdessen bei Loslassen der Taste in die Richtung geworfen in die mit dem Analog Stick gezielt wird.

View File

@ -25,6 +25,8 @@ CON_Use=Use
CON_Use_Desc=Use the item in the hand. CON_Use_Desc=Use the item in the hand.
CON_Throw=Throw CON_Throw=Throw
CON_Throw_Desc=Throw the item in the hand into the aimed direction. CON_Throw_Desc=Throw the item in the hand into the aimed direction.
CON_UseAlt=Use
CON_UseAlt_Desc=Use the item in the hand alternatively.
CON_Hotkey1=Hotkey 1 CON_Hotkey1=Hotkey 1
CON_Hotkey2=Hotkey 2 CON_Hotkey2=Hotkey 2
@ -69,6 +71,9 @@ KEY_MouseUse_Desc=Use the item in the hand.
KEY_MouseThrow=Throw KEY_MouseThrow=Throw
KEY_MouseThrow_Desc=Throw the item in the hand. KEY_MouseThrow_Desc=Throw the item in the hand.
KEY_MouseUseAlt=Use Alt
KEY_MouseUseAlt_Desc=Secondary use.
KEY_GamepadUse=Use / Throw KEY_GamepadUse=Use / Throw
KEY_GamepadUse_Desc=Use the item in the hand. If the item cannot be used, it is thrown into the direction in which you aim with the analog stick on release. KEY_GamepadUse_Desc=Use the item in the hand. If the item cannot be used, it is thrown into the direction in which you aim with the analog stick on release.