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.^
|
// un-comment them as soon as the new controls work with context menus etc.^
|
||||||
// Context menu
|
// Context menu
|
||||||
//#include L_CM
|
//#include L_CMAniF
|
||||||
// Auto production
|
// Auto production
|
||||||
//#include L_AP
|
//#include L_AP
|
||||||
|
|
||||||
|
@ -338,6 +338,114 @@ protected func CheckStuck()
|
||||||
// adaptions
|
// adaptions
|
||||||
public func IsClonk() { return true; }
|
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
|
// Test to synchronize the walkanimation with the movement
|
||||||
local OldPos;
|
local OldPos;
|
||||||
|
@ -400,6 +508,8 @@ func FxIntWalkStart(pTarget, iNumber, fTmp)
|
||||||
var anim = "Stand"; //GetCurrentWalkAnimation();
|
var anim = "Stand"; //GetCurrentWalkAnimation();
|
||||||
EffectVar(0, pTarget, iNumber) = anim;
|
EffectVar(0, pTarget, iNumber) = anim;
|
||||||
EffectVar(1, pTarget, iNumber) = PlayAnimation(anim, 5, GetWalkAnimationPosition(anim), Anim_Const(1000));
|
EffectVar(1, pTarget, iNumber) = PlayAnimation(anim, 5, GetWalkAnimationPosition(anim), Anim_Const(1000));
|
||||||
|
// Update carried items
|
||||||
|
UpdateAttach();
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxIntWalkStop(pTarget, iNumber, fTmp)
|
func FxIntWalkStop(pTarget, iNumber, fTmp)
|
||||||
|
@ -408,6 +518,9 @@ func FxIntWalkStop(pTarget, iNumber, fTmp)
|
||||||
|
|
||||||
// Remove all
|
// Remove all
|
||||||
StopAnimation(GetRootAnimation(5));
|
StopAnimation(GetRootAnimation(5));
|
||||||
|
|
||||||
|
// Update carried items
|
||||||
|
UpdateAttach();
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxIntWalkTimer(pTarget, iNumber)
|
func FxIntWalkTimer(pTarget, iNumber)
|
||||||
|
@ -832,20 +945,27 @@ func FxIntScaleTimer(pTarget, iNumber, iTime)
|
||||||
EffectVar(4, pTarget, iNumber) = iState;
|
EffectVar(4, pTarget, iNumber) = iState;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
local iShovelMesh;
|
|
||||||
|
|
||||||
func StartDigging()
|
func StartDigging()
|
||||||
{
|
{
|
||||||
Digging();
|
Digging();
|
||||||
if(!iShovelMesh)
|
UpdateAttach();
|
||||||
iShovelMesh = AttachMesh(SHVL, "pos_hand1", "main", 2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func StopDigging()
|
func StopDigging()
|
||||||
{
|
{
|
||||||
if(iShovelMesh)
|
UpdateAttach();
|
||||||
DetachMesh(iShovelMesh);
|
}
|
||||||
iShovelMesh = 0;
|
|
||||||
|
func StartJump()
|
||||||
|
{
|
||||||
|
// Update carried items
|
||||||
|
UpdateAttach();
|
||||||
|
}
|
||||||
|
|
||||||
|
func EndJump()
|
||||||
|
{
|
||||||
|
// Update carried items
|
||||||
|
UpdateAttach();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Act Map */
|
/* Act Map */
|
||||||
|
@ -903,6 +1023,7 @@ Tumble = {
|
||||||
NextAction = "Tumble",
|
NextAction = "Tumble",
|
||||||
ObjectDisabled = 1,
|
ObjectDisabled = 1,
|
||||||
InLiquidAction = "Swim",
|
InLiquidAction = "Swim",
|
||||||
|
Animation = "Tumble",
|
||||||
EndCall = "CheckStuck",
|
EndCall = "CheckStuck",
|
||||||
},
|
},
|
||||||
Dig = {
|
Dig = {
|
||||||
|
@ -992,6 +1113,8 @@ Jump = {
|
||||||
InLiquidAction = "Swim",
|
InLiquidAction = "Swim",
|
||||||
PhaseCall = "CheckStuck",
|
PhaseCall = "CheckStuck",
|
||||||
Animation = "Jump",
|
Animation = "Jump",
|
||||||
|
StartCall = "StartJump",
|
||||||
|
AbortCall = "EndJump",
|
||||||
},
|
},
|
||||||
KneelDown = {
|
KneelDown = {
|
||||||
Prototype = Action,
|
Prototype = Action,
|
||||||
|
@ -1006,6 +1129,7 @@ KneelDown = {
|
||||||
Wdt = 8,
|
Wdt = 8,
|
||||||
Hgt = 20,
|
Hgt = 20,
|
||||||
NextAction = "KneelUp",
|
NextAction = "KneelUp",
|
||||||
|
Animation = "KneelDown",
|
||||||
},
|
},
|
||||||
KneelUp = {
|
KneelUp = {
|
||||||
Prototype = Action,
|
Prototype = Action,
|
||||||
|
@ -1020,6 +1144,7 @@ KneelUp = {
|
||||||
Wdt = 8,
|
Wdt = 8,
|
||||||
Hgt = 20,
|
Hgt = 20,
|
||||||
NextAction = "Walk",
|
NextAction = "Walk",
|
||||||
|
Animation = "KneelDown",
|
||||||
},
|
},
|
||||||
Dive = {
|
Dive = {
|
||||||
Prototype = Action,
|
Prototype = Action,
|
||||||
|
@ -1093,9 +1218,10 @@ Dead = {
|
||||||
Y = 240,
|
Y = 240,
|
||||||
Wdt = 8,
|
Wdt = 8,
|
||||||
Hgt = 20,
|
Hgt = 20,
|
||||||
Length = 6,
|
Length = 20,
|
||||||
Delay = 3,
|
Delay = 1,
|
||||||
NextAction = "Hold",
|
NextAction = "Hold",
|
||||||
|
Animation = "Dead",
|
||||||
NoOtherAction = 1,
|
NoOtherAction = 1,
|
||||||
ObjectDisabled = 1,
|
ObjectDisabled = 1,
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,11 @@ private func Hit()
|
||||||
Sound("WoodHit");
|
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)
|
public func ControlUse(object clonk, int x, int y)
|
||||||
{
|
{
|
||||||
if(clonk->GetAction() == "Walk")
|
if(clonk->GetAction() == "Walk")
|
||||||
|
|
|
@ -13,22 +13,19 @@ local aimtime;
|
||||||
local iMesh;
|
local iMesh;
|
||||||
local iAnimLoad;
|
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 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)
|
protected func ControlUseStart(object clonk, int x, int y)
|
||||||
{
|
{
|
||||||
|
fAiming = 1;
|
||||||
// check for ammo
|
// check for ammo
|
||||||
if(!Contents(0))
|
if(!Contents(0))
|
||||||
{
|
{
|
||||||
|
@ -47,7 +44,7 @@ protected func ControlUseStart(object clonk, int x, int y)
|
||||||
clonk->CancelUse();
|
clonk->CancelUse();
|
||||||
}
|
}
|
||||||
iAnimLoad = clonk->PlayAnimation("BowAimArms", 10, Anim_Const(0), Anim_Const(1000));
|
iAnimLoad = clonk->PlayAnimation("BowAimArms", 10, Anim_Const(0), Anim_Const(1000));
|
||||||
Log("iAnimLoad %d", iAnimLoad);
|
clonk->UpdateAttach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +83,9 @@ public func ControlUseHolding(object clonk, int x, int y)
|
||||||
|
|
||||||
protected func ControlUseStop(object clonk, int x, int y)
|
protected func ControlUseStop(object clonk, int x, int y)
|
||||||
{
|
{
|
||||||
|
fAiming = 0;
|
||||||
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
clonk->StopAnimation(clonk->GetRootAnimation(10));
|
||||||
|
clonk->UpdateAttach();
|
||||||
Message("",clonk);
|
Message("",clonk);
|
||||||
|
|
||||||
// "canceled"
|
// "canceled"
|
||||||
|
|
|
@ -6,26 +6,26 @@ material Shield
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
ambient 0.500000 0.500000 0.500000 1.000000
|
ambient 0.500000 0.500000 0.500000 1.000000
|
||||||
diffuse 0.800000 0.800000 0.800000 1.000000
|
diffuse 0.810000 0.810000 0.810000 1.000000
|
||||||
specular 0.210835 0.210835 0.210835 1.000000 3.000000
|
specular 0.000000 0.000000 0.000000 1.000000 3.000000
|
||||||
emissive 0.000000 0.000000 0.000000 1.000000
|
emissive 0.000000 0.000000 0.000000 1.000000
|
||||||
texture_unit
|
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
|
texture Overlay.png
|
||||||
tex_address_mode wrap
|
tex_address_mode wrap
|
||||||
filtering trilinear
|
filtering trilinear
|
||||||
colour_op_ex modulate src_texture src_player_colour
|
colour_op_ex modulate src_texture src_player_colour
|
||||||
// take alpha from texture only, ignore player alpha
|
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
|
||||||
alpha_op_ex add src_current src_player_colour
|
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
|
texture_unit
|
||||||
{
|
{
|
||||||
|
@ -35,4 +35,4 @@ material Shield
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,18 +5,6 @@ private func Hit()
|
||||||
Sound("WoodHit"); //TODO Some metal sond
|
Sound("WoodHit"); //TODO Some metal sond
|
||||||
}
|
}
|
||||||
|
|
||||||
local iMesh;
|
|
||||||
|
|
||||||
public func HoldingEnabled() { return true; }
|
public func HoldingEnabled() { return true; }
|
||||||
|
|
||||||
public func Selection(pTarget, fSecond)
|
public func GetCarryMode() { return CARRY_HandBack; }
|
||||||
{
|
|
||||||
if(fSecond) return;
|
|
||||||
iMesh = pTarget->AttachMesh(SHIE, "pos_hand1", "main", 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public func Deselection(pTarget, fSecond)
|
|
||||||
{
|
|
||||||
if(fSecond) return;
|
|
||||||
pTarget->DetachMesh(iMesh);
|
|
||||||
}
|
|
|
@ -5,6 +5,10 @@ private func Hit()
|
||||||
Sound("WoodHit"); //TODO Some metal sond
|
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 fDrawn;
|
||||||
local fAttack;
|
local fAttack;
|
||||||
local iAnimStrike;
|
local iAnimStrike;
|
||||||
|
@ -55,8 +59,6 @@ public func DrawSword(fUndraw)
|
||||||
func FxIntSwordStart(pTarget, iNumber, fTmp)
|
func FxIntSwordStart(pTarget, iNumber, fTmp)
|
||||||
{
|
{
|
||||||
if(fTmp) return;
|
if(fTmp) return;
|
||||||
if(itemmesh > 0) pTarget->DetachMesh(itemmesh);
|
|
||||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_hand1", "Main", 130);
|
|
||||||
// pTarget->SetPhysical("Walk", 20000, 2);
|
// pTarget->SetPhysical("Walk", 20000, 2);
|
||||||
fDrawn = 1;
|
fDrawn = 1;
|
||||||
fAttack = 0;
|
fAttack = 0;
|
||||||
|
@ -70,8 +72,6 @@ func FxIntSwordTimer(pTarget, iNumber, iTime)
|
||||||
func FxIntSwordStop(pTarget, iNumber, iReason, fTmp)
|
func FxIntSwordStop(pTarget, iNumber, iReason, fTmp)
|
||||||
{
|
{
|
||||||
if(fTmp) return;
|
if(fTmp) return;
|
||||||
if(itemmesh > 0) pTarget->DetachMesh(itemmesh);
|
|
||||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_back", "Main", 130);
|
|
||||||
if(fAttack) StrikeEnd(pTarget);
|
if(fAttack) StrikeEnd(pTarget);
|
||||||
fDrawn = 0;
|
fDrawn = 0;
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,11 @@ local itemmesh;
|
||||||
public func Entrance(pTarget)
|
public func Entrance(pTarget)
|
||||||
{
|
{
|
||||||
fDrawn = 0;
|
fDrawn = 0;
|
||||||
itemmesh = pTarget->AttachMesh(GetID(), "pos_back", "Main", 130);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func Departure()
|
public func Departure()
|
||||||
{
|
{
|
||||||
// if the item had a holdmode detach mesh
|
// if the item had a holdmode detach mesh
|
||||||
if(itemmesh > 0) DetachMesh(itemmesh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func Selection(pTarget, fSecond)
|
public func Selection(pTarget, fSecond)
|
||||||
|
|
Loading…
Reference in New Issue