openclonk/planet/Objects.ocd/Structures.ocd/Chest.ocd/Script.c

61 lines
1.3 KiB
C
Raw Normal View History

2010-03-26 11:42:05 +00:00
/*
Chest
Author: Maikel
Storage for items.
*/
#include Library_ItemContainer
2010-03-26 11:42:05 +00:00
2011-10-01 15:39:59 +00:00
local chestanim;
protected func Construction()
2010-06-01 01:52:57 +00:00
{
2011-10-01 15:39:59 +00:00
chestanim = PlayAnimation("Open", 1, Anim_Linear(0, 0, 1, 20, ANIM_Hold), Anim_Const(1000));
SetProperty("MeshTransformation",Trans_Rotate(RandomX(20,80),0,1,0));
2010-06-01 01:52:57 +00:00
}
/*-- Contents --*/
private func MenuOnInteraction() { return true; }
private func MaxContentsCount()
2010-03-26 11:42:05 +00:00
{
return 5;
2010-03-26 11:42:05 +00:00
}
func GetInteractionMetaInfo(object clonk)
2010-06-01 01:52:57 +00:00
{
if(content_menu)
return { Description = "$CloseChest$", IconName = nil, IconID = nil, Selected = true };
else
return { Description = "$OpenChest$", IconName = nil, IconID = nil, Selected = false };
}
2010-06-01 01:52:57 +00:00
// callback: menu was closed
func MenuClosed()
{
Close();
}
private func OnContentMenuOpen() { Open(); }
private func Open()
{
2011-10-01 15:39:59 +00:00
chestanim = PlayAnimation("Open", 5, Anim_Linear(0, 0, GetAnimationLength("Open"), 22, ANIM_Hold), Anim_Const(1000));
Sound("ChestOpen.ogg");
}
private func Close()
{
2011-10-01 15:39:59 +00:00
PlayAnimation("Close", 5, Anim_Linear(0, 0, GetAnimationLength("Close"), 15, ANIM_Hold), Anim_Const(1000));
Sound("ChestClose.ogg");
2010-06-01 01:52:57 +00:00
}
protected func Definition(def)
2010-03-26 11:42:05 +00:00
{
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0,-3000,-5000), Trans_Rotate(-30,1,0,0), Trans_Rotate(30,0,1,0), Trans_Translate(1000,1,0)),def);
}
local Name = "$Name$";