forked from Mirrors/openclonk
added carry system
parent
cc65fb8e73
commit
100866ac51
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -7,7 +7,7 @@
|
|||
|
||||
// un-comment them as soon as the new controls work with context menus etc.^
|
||||
// Context menu
|
||||
//#include L_CM
|
||||
//#include L_CMAniF
|
||||
// Auto production
|
||||
//#include L_AP
|
||||
|
||||
|
@ -338,6 +338,114 @@ protected func CheckStuck()
|
|||
// adaptions
|
||||
public func IsClonk() { return true; }
|
||||
|
||||
/* Carry items on the clonk */
|
||||
|
||||
local iHandMesh;
|
||||
// GetSelected
|
||||
|
||||
func OnSelectionChanged(int oldslot, int newslot, bool secondaryslot)
|
||||
{
|
||||
AttachHandItem(secondaryslot);
|
||||
return _inherited(oldslot, newslot, secondaryslot);
|
||||
}
|
||||
func OnSlotEmpty(int slot)
|
||||
{
|
||||
if(GetSelected(0) == slot) AttachHandItem(0);
|
||||
if(GetSelected(1) == slot) AttachHandItem(1);
|
||||
return _inherited(slot);
|
||||
}
|
||||
func OnSlotFull(int slot)
|
||||
{
|
||||
if(GetSelected(0) == slot) AttachHandItem(0);
|
||||
if(GetSelected(1) == slot) AttachHandItem(1);
|
||||
return _inherited(slot);
|
||||
}
|
||||
|
||||
func DetachHandItem(bool secondary)
|
||||
{
|
||||
if(iHandMesh[secondary])
|
||||
DetachMesh(iHandMesh[secondary]);
|
||||
iHandMesh[secondary] = 0;
|
||||
}
|
||||
|
||||
func AttachHandItem(bool secondary)
|
||||
{
|
||||
if(!iHandMesh) iHandMesh = [0,0];
|
||||
DetachHandItem(secondary);
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func UpdateAttach()
|
||||
{
|
||||
DoUpdateAttach(0);
|
||||
DoUpdateAttach(1);
|
||||
}
|
||||
|
||||
func DoUpdateAttach(bool sec)
|
||||
{
|
||||
var obj = GetSelectedItem(sec);
|
||||
if(!obj) return;
|
||||
var iAttachMode = obj->~GetCarryMode();
|
||||
if(iAttachMode == CARRY_None) return;
|
||||
|
||||
if(iHandMesh[sec])
|
||||
{
|
||||
DetachMesh(iHandMesh[sec]);
|
||||
iHandMesh[sec] = 0;
|
||||
}
|
||||
|
||||
var bone = "main";
|
||||
if(obj->~GetCarryBone()) bone = obj->~GetCarryBone();
|
||||
var scale = 1000;
|
||||
if(obj->~GetCarryScale()) scale = obj->~GetCarryScale();
|
||||
|
||||
var pos_hand = "pos_hand2";
|
||||
if(sec) pos_hand = "pos_hand1";
|
||||
var pos_back = "pos_back2";
|
||||
if(sec) pos_back = "pos_back1";
|
||||
|
||||
var special = obj->~GetCarrySpecial(this);
|
||||
if(special)
|
||||
{
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), special, bone, scale);
|
||||
iAttachMode = 0;
|
||||
}
|
||||
|
||||
if(iAttachMode == CARRY_Hand)
|
||||
{
|
||||
if(HasHandAction())
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), pos_hand, bone, scale);
|
||||
else
|
||||
; // Don't display
|
||||
}
|
||||
else if(iAttachMode == CARRY_HandBack)
|
||||
{
|
||||
if(HasHandAction())
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), pos_hand, bone, scale);
|
||||
else
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), pos_back, bone, scale);
|
||||
}
|
||||
else if(iAttachMode == CARRY_HandAlways)
|
||||
{
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), pos_hand, bone, scale);
|
||||
}
|
||||
else if(iAttachMode == CARRY_Back)
|
||||
{
|
||||
iHandMesh[sec] = AttachMesh(obj->GetID(), pos_back, bone, scale);
|
||||
}
|
||||
}
|
||||
|
||||
static const CARRY_None = 0;
|
||||
static const CARRY_Hand = 1;
|
||||
static const CARRY_HandBack = 2;
|
||||
static const CARRY_HandAlways = 3;
|
||||
static const CARRY_Back = 4;
|
||||
|
||||
func HasHandAction()
|
||||
{
|
||||
return (GetAction() == "Walk") || (GetAction() == "Jump");
|
||||
}
|
||||
|
||||
/*
|
||||
// Test to synchronize the walkanimation with the movement
|
||||
local OldPos;
|
||||
|
@ -400,6 +508,8 @@ func FxIntWalkStart(pTarget, iNumber, fTmp)
|
|||
var anim = "Stand"; //GetCurrentWalkAnimation();
|
||||
EffectVar(0, pTarget, iNumber) = anim;
|
||||
EffectVar(1, pTarget, iNumber) = PlayAnimation(anim, 5, GetWalkAnimationPosition(anim), Anim_Const(1000));
|
||||
// Update carried items
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func FxIntWalkStop(pTarget, iNumber, fTmp)
|
||||
|
@ -408,6 +518,9 @@ func FxIntWalkStop(pTarget, iNumber, fTmp)
|
|||
|
||||
// Remove all
|
||||
StopAnimation(GetRootAnimation(5));
|
||||
|
||||
// Update carried items
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func FxIntWalkTimer(pTarget, iNumber)
|
||||
|
@ -832,20 +945,27 @@ func FxIntScaleTimer(pTarget, iNumber, iTime)
|
|||
EffectVar(4, pTarget, iNumber) = iState;
|
||||
}*/
|
||||
|
||||
local iShovelMesh;
|
||||
|
||||
func StartDigging()
|
||||
{
|
||||
Digging();
|
||||
if(!iShovelMesh)
|
||||
iShovelMesh = AttachMesh(SHVL, "pos_hand1", "main", 2000);
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func StopDigging()
|
||||
{
|
||||
if(iShovelMesh)
|
||||
DetachMesh(iShovelMesh);
|
||||
iShovelMesh = 0;
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func StartJump()
|
||||
{
|
||||
// Update carried items
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
func EndJump()
|
||||
{
|
||||
// Update carried items
|
||||
UpdateAttach();
|
||||
}
|
||||
|
||||
/* Act Map */
|
||||
|
@ -903,6 +1023,7 @@ Tumble = {
|
|||
NextAction = "Tumble",
|
||||
ObjectDisabled = 1,
|
||||
InLiquidAction = "Swim",
|
||||
Animation = "Tumble",
|
||||
EndCall = "CheckStuck",
|
||||
},
|
||||
Dig = {
|
||||
|
@ -992,6 +1113,8 @@ Jump = {
|
|||
InLiquidAction = "Swim",
|
||||
PhaseCall = "CheckStuck",
|
||||
Animation = "Jump",
|
||||
StartCall = "StartJump",
|
||||
AbortCall = "EndJump",
|
||||
},
|
||||
KneelDown = {
|
||||
Prototype = Action,
|
||||
|
@ -1006,6 +1129,7 @@ KneelDown = {
|
|||
Wdt = 8,
|
||||
Hgt = 20,
|
||||
NextAction = "KneelUp",
|
||||
Animation = "KneelDown",
|
||||
},
|
||||
KneelUp = {
|
||||
Prototype = Action,
|
||||
|
@ -1020,6 +1144,7 @@ KneelUp = {
|
|||
Wdt = 8,
|
||||
Hgt = 20,
|
||||
NextAction = "Walk",
|
||||
Animation = "KneelDown",
|
||||
},
|
||||
Dive = {
|
||||
Prototype = Action,
|
||||
|
@ -1093,9 +1218,10 @@ Dead = {
|
|||
Y = 240,
|
||||
Wdt = 8,
|
||||
Hgt = 20,
|
||||
Length = 6,
|
||||
Delay = 3,
|
||||
Length = 20,
|
||||
Delay = 1,
|
||||
NextAction = "Hold",
|
||||
Animation = "Dead",
|
||||
NoOtherAction = 1,
|
||||
ObjectDisabled = 1,
|
||||
},
|
||||
|
|
|
@ -5,6 +5,11 @@ private func Hit()
|
|||
Sound("WoodHit");
|
||||
}
|
||||
|
||||
public func GetCarryMode() { return CARRY_Back; }
|
||||
public func GetCarryScale() { return 2000; }
|
||||
|
||||
public func GetCarrySpecial(clonk) { if(clonk->~GetAction() == "Dig") return "pos_hand1"; }
|
||||
|
||||
public func ControlUse(object clonk, int x, int y)
|
||||
{
|
||||
if(clonk->GetAction() == "Walk")
|
||||
|
|
|
@ -13,22 +13,19 @@ local aimtime;
|
|||
local iMesh;
|
||||
local iAnimLoad;
|
||||
|
||||
local fAiming;
|
||||
|
||||
public func GetCarryMode() { return CARRY_HandBack; }
|
||||
public func GetCarryScale() { return 1300; }
|
||||
public func GetCarryBone() { return "Handle"; }
|
||||
|
||||
public func GetCarrySpecial(clonk) { if(fAiming) return "pos_hand2"; }
|
||||
|
||||
public func HoldingEnabled() { return true; }
|
||||
|
||||
public func Selection(pTarget, fSecond)
|
||||
{
|
||||
if(fSecond) return;
|
||||
iMesh = pTarget->AttachMesh(BOW1, "pos_hand2", "Handle", 1300);
|
||||
}
|
||||
|
||||
public func Deselection(pTarget, fSecond)
|
||||
{
|
||||
if(fSecond) return;
|
||||
pTarget->DetachMesh(iMesh);
|
||||
}
|
||||
|
||||
protected func ControlUseStart(object clonk, int x, int y)
|
||||
{
|
||||
fAiming = 1;
|
||||
// check for ammo
|
||||
if(!Contents(0))
|
||||
{
|
||||
|
@ -47,7 +44,7 @@ protected func ControlUseStart(object clonk, int x, int y)
|
|||
clonk->CancelUse();
|
||||
}
|
||||
iAnimLoad = clonk->PlayAnimation("BowAimArms", 10, Anim_Const(0), Anim_Const(1000));
|
||||
Log("iAnimLoad %d", iAnimLoad);
|
||||
clonk->UpdateAttach();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -86,7 +83,9 @@ public func ControlUseHolding(object clonk, int x, int y)
|
|||
|
||||
protected func ControlUseStop(object clonk, int x, int y)
|
||||
{
|
||||
fAiming = 0;
|
||||
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
||||
clonk->UpdateAttach();
|
||||
Message("",clonk);
|
||||
|
||||
// "canceled"
|
||||
|
|
|
@ -6,26 +6,26 @@ material Shield
|
|||
pass
|
||||
{
|
||||
ambient 0.500000 0.500000 0.500000 1.000000
|
||||
diffuse 0.800000 0.800000 0.800000 1.000000
|
||||
specular 0.210835 0.210835 0.210835 1.000000 3.000000
|
||||
diffuse 0.810000 0.810000 0.810000 1.000000
|
||||
specular 0.000000 0.000000 0.000000 1.000000 3.000000
|
||||
emissive 0.000000 0.000000 0.000000 1.000000
|
||||
texture_unit
|
||||
{
|
||||
texture shield.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
colour_op_ex blend_texture_alpha src_texture src_current
|
||||
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
|
||||
// alpha_op_ex source1 src_texture
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture Overlay.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
colour_op_ex modulate src_texture src_player_colour
|
||||
// take alpha from texture only, ignore player alpha
|
||||
alpha_op_ex add src_current src_player_colour
|
||||
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
|
||||
alpha_op_ex source1 src_texture src_player_colour
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
texture shield.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
colour_op_ex blend_current_alpha src_current src_texture
|
||||
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
|
||||
alpha_op_ex add src_current src_texture
|
||||
}
|
||||
texture_unit
|
||||
{
|
||||
|
|
|
@ -5,18 +5,6 @@ private func Hit()
|
|||
Sound("WoodHit"); //TODO Some metal sond
|
||||
}
|
||||
|
||||
local iMesh;
|
||||
|
||||
public func HoldingEnabled() { return true; }
|
||||
|
||||
public func Selection(pTarget, fSecond)
|
||||
{
|
||||
if(fSecond) return;
|
||||
iMesh = pTarget->AttachMesh(SHIE, "pos_hand1", "main", 1000);
|
||||
}
|
||||
|
||||
public func Deselection(pTarget, fSecond)
|
||||
{
|
||||
if(fSecond) return;
|
||||
pTarget->DetachMesh(iMesh);
|
||||
}
|
||||
public func GetCarryMode() { return CARRY_HandBack; }
|
|
@ -5,6 +5,10 @@ private func Hit()
|
|||
Sound("WoodHit"); //TODO Some metal sond
|
||||
}
|
||||
|
||||
public func GetCarryMode() { return CARRY_HandBack; }
|
||||
public func GetCarryScale() { return 130; }
|
||||
public func GetCarryBone() { return "Main"; }
|
||||
|
||||
local fDrawn;
|
||||
local fAttack;
|
||||
local iAnimStrike;
|
||||
|
@ -55,8 +59,6 @@ public func DrawSword(fUndraw)
|
|||
func FxIntSwordStart(pTarget, iNumber, fTmp)
|
||||
{
|
||||
if(fTmp) return;
|
||||
if(itemmesh > 0) pTarget->DetachMesh(itemmesh);
|
||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_hand1", "Main", 130);
|
||||
// pTarget->SetPhysical("Walk", 20000, 2);
|
||||
fDrawn = 1;
|
||||
fAttack = 0;
|
||||
|
@ -70,8 +72,6 @@ func FxIntSwordTimer(pTarget, iNumber, iTime)
|
|||
func FxIntSwordStop(pTarget, iNumber, iReason, fTmp)
|
||||
{
|
||||
if(fTmp) return;
|
||||
if(itemmesh > 0) pTarget->DetachMesh(itemmesh);
|
||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_back", "Main", 130);
|
||||
if(fAttack) StrikeEnd(pTarget);
|
||||
fDrawn = 0;
|
||||
}
|
||||
|
@ -81,13 +81,11 @@ local itemmesh;
|
|||
public func Entrance(pTarget)
|
||||
{
|
||||
fDrawn = 0;
|
||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_back", "Main", 130);
|
||||
}
|
||||
|
||||
public func Departure()
|
||||
{
|
||||
// if the item had a holdmode detach mesh
|
||||
if(itemmesh > 0) DetachMesh(itemmesh);
|
||||
}
|
||||
|
||||
public func Selection(pTarget, fSecond)
|
||||
|
|
Loading…
Reference in New Issue