/* Copyright (c) 2002-2012 Croteam Ltd. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ 805 %{ #include "StdH.h" #include "Models/Items/ItemHolder/ItemHolder.h" %} uses "EntitiesMP/Item"; // key type enum KeyItemType { 0 KIT_BOOKOFWISDOM "Book of wisdom", 1 KIT_CROSSWOODEN "Wooden cross", 2 KIT_CROSSMETAL "Silver cross", 3 KIT_CROSSGOLD "Gold cross", 4 KIT_JAGUARGOLDDUMMY "Gold jaguar", 5 KIT_HAWKWINGS01DUMMY "Hawk wings - part 1", 6 KIT_HAWKWINGS02DUMMY "Hawk wings - part 2", 7 KIT_HOLYGRAIL "Holy grail", 8 KIT_TABLESDUMMY "Tablet of wisdom", 9 KIT_WINGEDLION "Winged lion", 10 KIT_ELEPHANTGOLD "Gold elephant", 11 KIT_STATUEHEAD01 "Seriously scary ceremonial mask", 12 KIT_STATUEHEAD02 "Hilariously happy ceremonial mask", 13 KIT_STATUEHEAD03 "Ix Chel mask", 14 KIT_KINGSTATUE "Statue of King Tilmun", 15 KIT_CRYSTALSKULL "Crystal Skull", }; // event for sending through receive item event EKey { enum KeyItemType kitType, }; %{ const char *GetKeyName(enum KeyItemType kit) { switch(kit) { case KIT_BOOKOFWISDOM : return TRANS("Book of wisdom"); break; case KIT_CROSSWOODEN : return TRANS("Wooden cross"); break; case KIT_CROSSGOLD : return TRANS("Gold cross"); break; case KIT_CROSSMETAL : return TRANS("Silver cross"); break; case KIT_JAGUARGOLDDUMMY : return TRANS("Gold jaguar"); break; case KIT_HAWKWINGS01DUMMY : return TRANS("Hawk wings - part 1"); break; case KIT_HAWKWINGS02DUMMY : return TRANS("Hawk wings - part 2"); break; case KIT_HOLYGRAIL : return TRANS("Holy grail"); break; case KIT_TABLESDUMMY : return TRANS("Tablet of wisdom"); break; case KIT_WINGEDLION : return TRANS("Winged lion"); break; case KIT_ELEPHANTGOLD : return TRANS("Gold elephant"); break; case KIT_STATUEHEAD01 : return TRANS("Seriously scary ceremonial mask"); break; case KIT_STATUEHEAD02 : return TRANS("Hilariously happy ceremonial mask"); break; case KIT_STATUEHEAD03 : return TRANS("Ix Chel mask"); break; case KIT_KINGSTATUE : return TRANS("Statue of King Tilmun"); break; case KIT_CRYSTALSKULL : return TRANS("Crystal Skull"); break; default: return TRANS("unknown item"); break; }; } %} class CKeyItem : CItem { name "KeyItem"; thumbnail "Thumbnails\\KeyItem.tbn"; features "IsImportant"; properties: 1 enum KeyItemType m_kitType "Type" 'Y' = KIT_BOOKOFWISDOM, // key type 3 INDEX m_iSoundComponent = 0, 5 FLOAT m_fSize "Size" = 1.0f, components: 0 class CLASS_BASE "Classes\\Item.ecl", // ********* ANKH KEY ********* 1 model MODEL_BOOKOFWISDOM "ModelsMP\\Items\\Keys\\BookOfWisdom\\Book.mdl", 2 texture TEXTURE_BOOKOFWISDOM "ModelsMP\\Items\\Keys\\BookOfWisdom\\Book.tex", 5 model MODEL_CROSSWOODEN "ModelsMP\\Items\\Keys\\Cross\\Cross.mdl", 6 texture TEXTURE_CROSSWOODEN "ModelsMP\\Items\\Keys\\Cross\\CrossWooden.tex", 7 model MODEL_CROSSMETAL "ModelsMP\\Items\\Keys\\Cross\\Cross.mdl", 8 texture TEXTURE_CROSSMETAL "ModelsMP\\Items\\Keys\\Cross\\CrossMetal.tex", 10 model MODEL_CROSSGOLD "ModelsMP\\Items\\Keys\\GoldCross\\Cross.mdl", 11 texture TEXTURE_CROSSGOLD "ModelsMP\\Items\\Keys\\GoldCross\\Cross.tex", 15 model MODEL_JAGUARGOLD "ModelsMP\\Items\\Keys\\GoldJaguar\\Jaguar.mdl", 20 model MODEL_HAWKWINGS01 "ModelsMP\\Items\\Keys\\HawkWings\\WingRight.mdl", 21 model MODEL_HAWKWINGS02 "ModelsMP\\Items\\Keys\\HawkWings\\WingLeft.mdl", 22 texture TEXTURE_HAWKWINGS "ModelsMP\\Items\\Keys\\HawkWings\\Wings.tex", 30 model MODEL_HOLYGRAIL "ModelsMP\\Items\\Keys\\HolyGrail\\Grail.mdl", 31 texture TEXTURE_HOLYGRAIL "ModelsMP\\Items\\Keys\\HolyGrail\\Grail.tex", 35 model MODEL_TABLESOFWISDOM "ModelsMP\\Items\\Keys\\TablesOfWisdom\\Tables.mdl", 36 texture TEXTURE_TABLESOFWISDOM "ModelsMP\\Items\\Keys\\TablesOfWisdom\\Tables.tex", 40 model MODEL_WINGEDLION "ModelsMP\\Items\\Keys\\WingLion\\WingLion.mdl", 45 model MODEL_ELEPHANTGOLD "ModelsMP\\Items\\Keys\\GoldElephant\\Elephant.mdl", 50 model MODEL_STATUEHEAD01 "ModelsMP\\Items\\Keys\\Statue01\\Statue.mdl", 51 texture TEXTURE_STATUEHEAD01 "ModelsMP\\Items\\Keys\\Statue01\\Statue.tex", 52 model MODEL_STATUEHEAD02 "ModelsMP\\Items\\Keys\\Statue02\\Statue.mdl", 53 texture TEXTURE_STATUEHEAD02 "ModelsMP\\Items\\Keys\\Statue02\\Statue.tex", 54 model MODEL_STATUEHEAD03 "ModelsMP\\Items\\Keys\\Statue03\\Statue.mdl", 55 texture TEXTURE_STATUEHEAD03 "ModelsMP\\Items\\Keys\\Statue03\\Statue.tex", 58 model MODEL_KINGSTATUE "ModelsMP\\Items\\Keys\\ManStatue\\Statue.mdl", 60 model MODEL_CRYSTALSKULL "ModelsMP\\Items\\Keys\\CrystalSkull\\Skull.mdl", 61 texture TEXTURE_CRYSTALSKULL "ModelsMP\\Items\\Keys\\CrystalSkull\\Skull.tex", // ********* MISC ********* 250 texture TEXTURE_FLARE "ModelsMP\\Items\\Flares\\Flare.tex", 251 model MODEL_FLARE "ModelsMP\\Items\\Flares\\Flare.mdl", 252 texture TEX_REFL_GOLD01 "ModelsMP\\ReflectionTextures\\Gold01.tex", 253 texture TEX_REFL_METAL01 "ModelsMP\\ReflectionTextures\\LightMetal01.tex", 254 texture TEX_SPEC_MEDIUM "ModelsMP\\SpecularTextures\\Medium.tex", 255 texture TEX_SPEC_STRONG "ModelsMP\\SpecularTextures\\Strong.tex", // ************** SOUNDS ************** 300 sound SOUND_KEY "Sounds\\Items\\Key.wav", functions: void Precache(void) { PrecacheSound(SOUND_KEY); } /* Fill in entity statistics - for AI purposes only */ BOOL FillEntityStatistics(EntityStats *pes) { pes->es_strName = GetKeyName(m_kitType); pes->es_ctCount = 1; pes->es_ctAmmount = 1; pes->es_fValue = 1; pes->es_iScore = 0;//m_iScore; return TRUE; } // render particles void RenderParticles(void) { // no particles when not existing if (GetRenderType()!=CEntity::RT_MODEL || !ShowItemParticles()) { return; } switch (m_kitType) { case KIT_BOOKOFWISDOM : case KIT_CRYSTALSKULL : case KIT_HOLYGRAIL : Particles_Stardust(this, 1.0f, 0.5f, PT_STAR08, 64); break; case KIT_JAGUARGOLDDUMMY : Particles_Stardust(this, 2.0f, 2.0f, PT_STAR08, 64); break; case KIT_CROSSWOODEN : case KIT_CROSSMETAL : case KIT_CROSSGOLD : case KIT_HAWKWINGS01DUMMY: case KIT_HAWKWINGS02DUMMY: case KIT_TABLESDUMMY : case KIT_WINGEDLION : case KIT_ELEPHANTGOLD : case KIT_STATUEHEAD01 : case KIT_STATUEHEAD02 : case KIT_STATUEHEAD03 : case KIT_KINGSTATUE : default: Particles_Stardust(this, 1.5f, 1.1f, PT_STAR08, 64); break; } } // set health properties depending on type void SetProperties(void) { m_fRespawnTime = (m_fCustomRespawnTime>0) ? m_fCustomRespawnTime : 10.0f; m_strDescription = GetKeyName(m_kitType); switch (m_kitType) { case KIT_BOOKOFWISDOM : // set appearance AddItem(MODEL_BOOKOFWISDOM, TEXTURE_BOOKOFWISDOM , 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_CROSSWOODEN: // set appearance AddItem(MODEL_CROSSWOODEN, TEXTURE_CROSSWOODEN, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_CROSSMETAL: // set appearance AddItem(MODEL_CROSSMETAL, TEXTURE_CROSSMETAL, TEX_REFL_METAL01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_CROSSGOLD: // set appearance AddItem(MODEL_CROSSGOLD, TEXTURE_CROSSGOLD, TEX_REFL_GOLD01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_JAGUARGOLDDUMMY: // set appearance AddItem(MODEL_JAGUARGOLD, TEX_REFL_GOLD01, TEX_REFL_GOLD01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.5f,0), FLOAT3D(2,2,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_HAWKWINGS01DUMMY: // set appearance AddItem(MODEL_HAWKWINGS01, TEXTURE_HAWKWINGS, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_HAWKWINGS02DUMMY: // set appearance AddItem(MODEL_HAWKWINGS02, TEXTURE_HAWKWINGS, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_HOLYGRAIL: // set appearance AddItem(MODEL_HOLYGRAIL, TEXTURE_HOLYGRAIL, TEX_REFL_METAL01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_TABLESDUMMY: // set appearance AddItem(MODEL_TABLESOFWISDOM, TEXTURE_TABLESOFWISDOM, TEX_REFL_METAL01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_WINGEDLION: // set appearance AddItem(MODEL_WINGEDLION, TEX_REFL_GOLD01, TEX_REFL_GOLD01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_ELEPHANTGOLD: // set appearance AddItem(MODEL_ELEPHANTGOLD, TEX_REFL_GOLD01, TEX_REFL_GOLD01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.5f,0), FLOAT3D(2,2,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_STATUEHEAD01: // set appearance AddItem(MODEL_STATUEHEAD01, TEXTURE_STATUEHEAD01, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_STATUEHEAD02: // set appearance AddItem(MODEL_STATUEHEAD02, TEXTURE_STATUEHEAD02, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_STATUEHEAD03: // set appearance AddItem(MODEL_STATUEHEAD03, TEXTURE_STATUEHEAD03, 0, 0, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_KINGSTATUE: // set appearance AddItem(MODEL_KINGSTATUE, TEX_REFL_GOLD01, TEX_REFL_GOLD01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; case KIT_CRYSTALSKULL: // set appearance AddItem(MODEL_CRYSTALSKULL, TEXTURE_CRYSTALSKULL, TEX_REFL_METAL01, TEX_SPEC_MEDIUM, 0); // add flare AddFlare(MODEL_FLARE, TEXTURE_FLARE, FLOAT3D(0,0.2f,0), FLOAT3D(1,1,0.3f) ); StretchItem(FLOAT3D(1.0f, 1.0f, 1.0f)); m_iSoundComponent = SOUND_KEY; break; } GetModelObject()->StretchModel(FLOAT3D(m_fSize, m_fSize, m_fSize)); }; procedures: ItemCollected(EPass epass) : CItem::ItemCollected { ASSERT(epass.penOther!=NULL); // send key to entity EKey eKey; eKey.kitType = m_kitType; // if health is received if (epass.penOther->ReceiveItem(eKey)) { if(_pNetwork->IsPlayerLocal(epass.penOther)) {IFeel_PlayEffect("PU_Key");} // play the pickup sound m_soPick.Set3DParameters(50.0f, 1.0f, 1.0f, 1.0f); PlaySound(m_soPick, m_iSoundComponent, SOF_3D); m_fPickSoundLen = GetSoundLength(m_iSoundComponent); jump CItem::ItemReceived(); } return; }; Main() { Initialize(); // initialize base class StartModelAnim(ITEMHOLDER_ANIM_SMALLOSCILATION, AOF_LOOPING|AOF_NORESTART); ForceCollisionBoxIndexChange(ITEMHOLDER_COLLISION_BOX_BIG); SetProperties(); // set properties jump CItem::ItemLoop(); }; };