This repository has been archived by the owner on Sep 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
glowstick.cpp
124 lines (108 loc) · 3.04 KB
/
glowstick.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/glowstick.cpp $
// $Revision:: 12 $
// $Author:: Aldie $
// $Date:: 10/24/98 3:14p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/glowstick.cpp $
//
// 12 10/24/98 3:14p Aldie
// Upped the life of sticks
//
// 11 10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
//
// 10 10/07/98 1:17a Aldie
// New model
//
// 9 7/25/98 7:10p Markd
// Put in EV_Removes for demo
//
// 8 7/21/98 7:33p Aldie
// Changed def file
//
// 7 7/20/98 3:52p Aldie
// Fixed the icon
//
// 6 6/25/98 8:47p Markd
// Added keyed items for Triggers, Rewrote Item class, rewrote every pickup
// method
//
// 5 6/24/98 1:36p Aldie
// Implementation of inventory system and picking stuff up
//
// 4 6/20/98 7:03p Aldie
// Changed the avel
//
// 3 6/20/98 6:53p Aldie
// Changed the model back to hvshell.def
//
// 2 6/19/98 6:37p Aldie
// First version of glowstick
//
// DESCRIPTION:
// Glowstick for a lightsource
#include "inventoryitem.h"
class EXPORT_FROM_DLL GlowStick : public InventoryItem
{
public:
CLASS_PROTOTYPE( GlowStick );
GlowStick();
void Use( Event *ev );
};
CLASS_DECLARATION( InventoryItem, GlowStick, "powerups_glowstick" )
ResponseDef GlowStick::Responses[] =
{
{ &EV_InventoryItem_Use, ( Response )GlowStick::Use },
{ NULL, NULL }
};
GlowStick::GlowStick
(
)
{
#ifdef SIN_DEMO
PostEvent( EV_Remove, 0 );
return;
#endif
setModel( "glowstick.def" );
Set( 1 );
}
void GlowStick::Use
(
Event *ev
)
{
Entity *glowstick;
Vector dir;
assert( owner );
// Make sure there is a glowstick to
assert( amount );
amount--;
if (amount <= 0)
{
owner->RemoveItem( this );
}
dir = owner->orientation[ 0 ];
glowstick = new Entity;
glowstick->angles = dir.toAngles();
glowstick->setAngles( glowstick->angles );
glowstick->setMoveType( MOVETYPE_BOUNCE );
glowstick->setSolidType( SOLID_NOT );
glowstick->setModel( "glowstick.def" );
glowstick->edict->s.renderfx |= RF_DLIGHT;
glowstick->avelocity = "500 0 0";
glowstick->velocity = dir * 500;
glowstick->edict->s.color_r = 0.4;
glowstick->edict->s.color_g = 1.0;
glowstick->edict->s.color_b = 0.1;
glowstick->edict->s.radius = 200;
glowstick->setOrigin( owner->worldorigin + Vector(0,0,owner->viewheight) );
glowstick->PostEvent(EV_Remove, 60);
}