mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-04 17:50:45 +03:00
Implemented entity item_airbox
This commit is contained in:
parent
91ca3f0264
commit
3be0b51ec9
152
regamedll/dlls/addons/item_airbox.cpp
Normal file
152
regamedll/dlls/addons/item_airbox.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_airbox, CItemAirBox, CCSItemAirBox);
|
||||
|
||||
void CItemAirBox::Spawn()
|
||||
{
|
||||
CArmoury::Spawn();
|
||||
|
||||
pev->movetype = MOVETYPE_NOCLIP;
|
||||
|
||||
if (!FStringNull(m_iszSpriteName))
|
||||
{
|
||||
m_pSprite = CSprite::SpriteCreate(STRING(m_iszSpriteName), pev->origin, FALSE);
|
||||
m_pSprite->SetTransparency(m_rendermode, m_rendercolor.x, m_rendercolor.y, m_rendercolor.z, m_renderamt, m_renderfx);
|
||||
m_pSprite->SetScale(m_scale);
|
||||
m_pSprite->SetAttachment(edict(), pev->body);
|
||||
m_pSprite->pev->spawnflags |= SF_SPRITE_STARTON;
|
||||
|
||||
m_pSprite->pev->framerate = m_frameRate;
|
||||
m_pSprite->TurnOn();
|
||||
}
|
||||
|
||||
if (m_flyup > 0 && m_delay > 0.01)
|
||||
{
|
||||
SetThink(&CItemAirBox::MoveUp);
|
||||
pev->nextthink = gpGlobals->time + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void CItemAirBox::Touch(CBaseEntity *pOther)
|
||||
{
|
||||
CArmoury::Touch(pOther);
|
||||
|
||||
// airbox was picked up, so sprite to turn off
|
||||
if ((pev->effects & EF_NODRAW) == EF_NODRAW) {
|
||||
m_pSprite->TurnOff();
|
||||
}
|
||||
}
|
||||
|
||||
void CItemAirBox::Restart()
|
||||
{
|
||||
CArmoury::Restart();
|
||||
UTIL_SetOrigin(pev, pev->oldorigin);
|
||||
}
|
||||
|
||||
void CItemAirBox::Precache()
|
||||
{
|
||||
CArmoury::Precache();
|
||||
|
||||
if (!FStringNull(m_iszSpriteName)) {
|
||||
PRECACHE_MODEL(STRING(m_iszSpriteName));
|
||||
}
|
||||
}
|
||||
|
||||
void CItemAirBox::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "flyup"))
|
||||
{
|
||||
m_flyup = Q_atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "delay"))
|
||||
{
|
||||
m_delay = Q_atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_model"))
|
||||
{
|
||||
m_iszSpriteName = ALLOC_STRING(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_renderfx"))
|
||||
{
|
||||
m_renderfx = Q_atoi(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_rendermode"))
|
||||
{
|
||||
m_rendermode = Q_atoi(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_renderamt"))
|
||||
{
|
||||
m_renderamt = Q_atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_rendercolor"))
|
||||
{
|
||||
UTIL_StringToVector(m_rendercolor, pkvd->szValue, ' ');
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_scale"))
|
||||
{
|
||||
m_scale = Q_atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "sprite_framerate"))
|
||||
{
|
||||
m_frameRate = Q_atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CArmoury::KeyValue(pkvd);
|
||||
}
|
||||
}
|
||||
|
||||
void CItemAirBox::MoveUp()
|
||||
{
|
||||
pev->velocity.z = m_flyup;
|
||||
m_flyup = -m_flyup;
|
||||
pev->nextthink = gpGlobals->time + m_delay;
|
||||
}
|
||||
|
||||
void CItemAirBox::OnDestroy()
|
||||
{
|
||||
if (m_pSprite)
|
||||
{
|
||||
m_pSprite->SetTouch(nullptr);
|
||||
m_pSprite->SetThink(&CBaseEntity::SUB_Remove);
|
||||
m_pSprite->pev->nextthink = gpGlobals->time + 0.1f;
|
||||
m_pSprite = nullptr;
|
||||
}
|
||||
}
|
56
regamedll/dlls/addons/item_airbox.h
Normal file
56
regamedll/dlls/addons/item_airbox.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
class CItemAirBox: public CArmoury {
|
||||
public:
|
||||
void Spawn();
|
||||
void Precache();
|
||||
void Restart();
|
||||
void OnDestroy();
|
||||
void Touch(CBaseEntity *pOther);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
int ObjectCaps() { return (CArmoury::ObjectCaps() | FCAP_MUST_RESET); }
|
||||
|
||||
protected:
|
||||
void EXPORT MoveUp();
|
||||
|
||||
private:
|
||||
CSprite *m_pSprite;
|
||||
|
||||
float m_flyup;
|
||||
float m_delay;
|
||||
|
||||
Vector m_rendercolor;
|
||||
int m_renderfx;
|
||||
int m_rendermode;
|
||||
float m_renderamt;
|
||||
float m_scale;
|
||||
float m_frameRate;
|
||||
|
||||
string_t m_iszSpriteName;
|
||||
};
|
@ -1,3 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS(trigger_setorigin, CTriggerSetOrigin, CCSTriggerSetOrigin)
|
||||
|
@ -54,13 +54,13 @@ const int MAX_SETORIGIN_ENTITIES = 64;
|
||||
|
||||
class CTriggerSetOrigin: public CBaseDelay {
|
||||
public:
|
||||
virtual void Spawn() {};
|
||||
virtual void KeyValue(KeyValueData *pkvd);
|
||||
virtual int ObjectCaps() { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
|
||||
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
void Spawn() {};
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
int ObjectCaps() { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
|
||||
virtual void OnCreate();
|
||||
virtual void OnDestroy();
|
||||
void OnCreate();
|
||||
void OnDestroy();
|
||||
|
||||
protected:
|
||||
friend class CTriggerSetOriginManager;
|
||||
|
@ -2091,7 +2091,7 @@ void CWeaponBox::SetObjectCollisionBox()
|
||||
pev->absmax = pev->origin + Vector(16, 16, 16);
|
||||
}
|
||||
|
||||
char *armouryItemModels[] = {
|
||||
char *CArmoury::m_ItemModels[] = {
|
||||
"models/w_mp5.mdl",
|
||||
"models/w_tmp.mdl",
|
||||
"models/w_p90.mdl",
|
||||
@ -2140,9 +2140,9 @@ void CArmoury::Spawn()
|
||||
|
||||
SetTouch(&CArmoury::ArmouryTouch);
|
||||
|
||||
if (m_iItem < ARRAYSIZE(armouryItemModels))
|
||||
if (m_iItem < ARRAYSIZE(m_ItemModels))
|
||||
{
|
||||
SET_MODEL(ENT(pev), armouryItemModels[m_iItem]);
|
||||
SET_MODEL(ENT(pev), m_ItemModels[m_iItem]);
|
||||
}
|
||||
|
||||
if (m_iCount <= 0)
|
||||
@ -2231,9 +2231,9 @@ void CArmoury::Restart()
|
||||
|
||||
void CArmoury::Precache()
|
||||
{
|
||||
if (m_iItem < ARRAYSIZE(armouryItemModels))
|
||||
if (m_iItem < ARRAYSIZE(m_ItemModels))
|
||||
{
|
||||
PRECACHE_MODEL(armouryItemModels[m_iItem]);
|
||||
PRECACHE_MODEL(m_ItemModels[m_iItem]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,8 @@ private:
|
||||
void Hide();
|
||||
|
||||
public:
|
||||
static char *m_ItemModels[];
|
||||
|
||||
ArmouryItemPack m_iItem;
|
||||
int m_iCount;
|
||||
int m_iInitialCount;
|
||||
|
Binary file not shown.
Binary file not shown.
@ -969,7 +969,7 @@
|
||||
]
|
||||
]
|
||||
|
||||
@PointClass iconsprite("sprites/CS/armoury_entity.spr") size(-16 -16 0, 16 16 16) = armoury_entity : "Items in the armoury"
|
||||
@BaseClass base(RenderFields) = ArmouryEntity
|
||||
[
|
||||
item(choices) : "Item" : 0 =
|
||||
[
|
||||
@ -1008,6 +1008,10 @@
|
||||
count(integer) : "Count" : 1
|
||||
]
|
||||
|
||||
@PointClass base(ArmouryEntity) iconsprite("sprites/CS/armoury_entity.spr") size(-16 -16 0, 16 16 16) = armoury_entity : "Items in the armoury"
|
||||
[
|
||||
]
|
||||
|
||||
// line below edited by Dmitrich! -->
|
||||
// was: @PointClass base(Targetname, Angles, RenderFields) size(-16 -16 0, 16 16 72) iconsprite("sprites/CS/cycler.spr") = cycler : "Monster Cycler"
|
||||
@PointClass base(Targetname, Angles, Sequence) size(-16 -16 0, 16 16 72) studio() = cycler : "Monster Cycler"
|
||||
@ -2873,3 +2877,50 @@
|
||||
1 : "Yes"
|
||||
]
|
||||
]
|
||||
|
||||
@PointClass base(ArmouryEntity) size(-16 -16 0, 16 16 16) iconsprite("sprites/CS/armoury_entity.spr") = item_airbox : "Items in the armoury and float in the air"
|
||||
[
|
||||
angles(string) : "Pitch Yaw Roll (Y Z X)" : "-90 0 0"
|
||||
avelocity(string) : "Angular velocity (Y Z X)" : "0 150 0"
|
||||
flyup(string) : "Speed fly up" : "5"
|
||||
delay(string) : "Delay before fly down" : "1"
|
||||
sprite_model(string) : "Sprite Name " : ""
|
||||
sprite_renderfx(choices) :"Sprite Render FX" : 0 =
|
||||
[
|
||||
0: "Normal"
|
||||
1: "Slow Pulse"
|
||||
2: "Fast Pulse"
|
||||
3: "Slow Wide Pulse"
|
||||
4: "Fast Wide Pulse"
|
||||
9: "Slow Strobe"
|
||||
10: "Fast Strobe"
|
||||
11: "Faster Strobe"
|
||||
12: "Slow Flicker"
|
||||
13: "Fast Flicker"
|
||||
// 5: "Slow Fade Away"
|
||||
// 6: "Fast Fade Away"
|
||||
// 7: "Slow Become Solid"
|
||||
// 8: "Fast Become Solid"
|
||||
14: "Constant Glow (Sprites)"
|
||||
15: "Distort (Models)"
|
||||
16: "Hologram (Distort + fade)"
|
||||
17: "Dead Player"
|
||||
18: "Explode"
|
||||
19: "Glow Shell"
|
||||
20 : "Clamp Min Scale"
|
||||
21 : "Light Multiplier"
|
||||
]
|
||||
sprite_rendermode(choices) : "Sprite Render Mode" : 0 =
|
||||
[
|
||||
0: "Normal - no light"
|
||||
1: "Pure Color"
|
||||
2: "Texture - some light"
|
||||
3: "Glow (sprites only)"
|
||||
4: "Solid - no light"
|
||||
5: "Additive"
|
||||
]
|
||||
sprite_renderamt(integer) : "Sprite FX Amount (1 - 255)" : 255
|
||||
sprite_rendercolor(color255) : "Sprite FX Color (R G B)" : "0 0 0"
|
||||
sprite_scale(string) : "Sprite scale" : "1.0"
|
||||
sprite_framerate(string) : "Sprite framerate" : "10"
|
||||
]
|
||||
|
@ -39,6 +39,7 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\dlls\addons\item_airbox.cpp" />
|
||||
<ClCompile Include="..\dlls\addons\trigger_setorigin.cpp" />
|
||||
<ClCompile Include="..\dlls\airtank.cpp" />
|
||||
<ClCompile Include="..\dlls\ammo.cpp" />
|
||||
@ -916,6 +917,7 @@
|
||||
<ClInclude Include="..\common\winsani_in.h" />
|
||||
<ClInclude Include="..\common\winsani_out.h" />
|
||||
<ClInclude Include="..\dlls\activity.h" />
|
||||
<ClInclude Include="..\dlls\addons\item_airbox.h" />
|
||||
<ClInclude Include="..\dlls\addons\trigger_setorigin.h" />
|
||||
<ClInclude Include="..\dlls\airtank.h" />
|
||||
<ClInclude Include="..\dlls\ammo.h" />
|
||||
|
@ -557,6 +557,9 @@
|
||||
<ClCompile Include="..\dlls\addons\trigger_setorigin.cpp">
|
||||
<Filter>dlls\addons</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\dlls\addons\item_airbox.cpp">
|
||||
<Filter>dlls\addons</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\hookers\memory.h">
|
||||
@ -1060,6 +1063,9 @@
|
||||
<ClInclude Include="..\dlls\addons\trigger_setorigin.h">
|
||||
<Filter>dlls\addons</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\dlls\addons\item_airbox.h">
|
||||
<Filter>dlls\addons</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\linux\appversion.sh">
|
||||
|
@ -299,6 +299,7 @@ class CCSTriggerCamera: public CCSDelay {};
|
||||
class CCSWeather: public CCSTrigger {};
|
||||
class CCSClientFog: public CCSEntity {};
|
||||
class CCSTriggerSetOrigin: public CCSDelay {};
|
||||
class CCSItemAirBox: public CCSArmoury {};
|
||||
|
||||
inline CBasePlayer *CCSPlayer::BasePlayer() const {
|
||||
return reinterpret_cast<CBasePlayer *>(this->m_pContainingEntity);
|
||||
|
@ -132,6 +132,7 @@ typedef float& FloatRef;
|
||||
#include "bot/cs_bot.h"
|
||||
|
||||
// Addons
|
||||
#include "addons/item_airbox.h"
|
||||
#include "addons/trigger_setorigin.h"
|
||||
|
||||
// Tutor
|
||||
|
Loading…
x
Reference in New Issue
Block a user