added fixed cs16nd (animation.cpp from regamedll).
This commit is contained in:
parent
c427c15854
commit
40da08ddc3
148
dlls/Makefile
148
dlls/Makefile
|
@ -1,148 +0,0 @@
|
|||
#
|
||||
# Half-Life Standard SDK 2.3 mp_i386.so Makefile for i386 Linux
|
||||
#
|
||||
# October 2002 by Leon Hartwig (hartwig@valvesoftware.com)
|
||||
#
|
||||
|
||||
DLLNAME=mp
|
||||
|
||||
ARCH=i386
|
||||
|
||||
#make sure this is the correct compiler for your system
|
||||
CC=gcc
|
||||
|
||||
DLL_SRCDIR=.
|
||||
ENGINE_SRCDIR=../engine
|
||||
COMMON_SRCDIR=../common
|
||||
WPN_SHARED_SRCDIR=./wpn_shared
|
||||
PM_SHARED_SRCDIR=../pm_shared
|
||||
GAME_SHARED_SRCDIR=../game_shared
|
||||
|
||||
DLL_OBJDIR=$(DLL_SRCDIR)/obj
|
||||
WPN_SHARED_OBJDIR=$(WPN_SHARED_SRCDIR)/obj
|
||||
PM_SHARED_OBJDIR=$(PM_SHARED_SRCDIR)/obj
|
||||
GAME_SHARED_OBJDIR=$(GAME_SHARED_SRCDIR)/obj
|
||||
|
||||
BASE_CFLAGS= -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
||||
-DCLIENT_WEAPONS -fpermissive
|
||||
|
||||
#safe optimization
|
||||
CFLAGS=$(BASE_CFLAGS) -w -m32 -O1
|
||||
|
||||
#full optimization
|
||||
#CFLAGS=$(BASE_CFLAGS) -w -O1 -m486 -ffast-math -funroll-loops \
|
||||
-fomit-frame-pointer -fexpensive-optimizations \
|
||||
-malign-loops=2 -malign-jumps=2 -malign-functions=2
|
||||
|
||||
#use these when debugging
|
||||
#CFLAGS=$(BASE_CFLAGS) -g
|
||||
|
||||
INCLUDEDIRS=-I. -I$(ENGINE_SRCDIR) -I$(COMMON_SRCDIR) -I$(PM_SHARED_SRCDIR) -I$(GAME_SHARED_SRCDIR)
|
||||
|
||||
LDFLAGS= -m32
|
||||
|
||||
SHLIBEXT=so
|
||||
SHLIBCFLAGS=-fPIC
|
||||
SHLIBLDFLAGS=-shared
|
||||
|
||||
DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) $(INCLUDEDIRS) -o $@ -c $<
|
||||
|
||||
#############################################################################
|
||||
# SETUP AND BUILD
|
||||
# GAME
|
||||
#############################################################################
|
||||
|
||||
$(DLL_OBJDIR)/%.o: $(DLL_SRCDIR)/%.cpp
|
||||
$(DO_CC)
|
||||
|
||||
$(WPN_SHARED_OBJDIR)/%.o: $(WPN_SHARED_SRCDIR)/%.cpp
|
||||
$(DO_CC)
|
||||
|
||||
$(GAME_SHARED_OBJDIR)/%.o: $(GAME_SHARED_SRCDIR)/%.cpp
|
||||
$(DO_CC)
|
||||
|
||||
$(PM_SHARED_OBJDIR)/%.o: $(PM_SHARED_SRCDIR)/%.c
|
||||
$(DO_CC)
|
||||
|
||||
OBJ = \
|
||||
$(DLL_OBJDIR)/airtank.o \
|
||||
$(DLL_OBJDIR)/animating.o \
|
||||
$(DLL_OBJDIR)/animation.o \
|
||||
$(DLL_OBJDIR)/bmodels.o \
|
||||
$(DLL_OBJDIR)/buttons.o \
|
||||
$(DLL_OBJDIR)/cbase.o \
|
||||
$(DLL_OBJDIR)/client.o \
|
||||
$(DLL_OBJDIR)/combat.o \
|
||||
$(DLL_OBJDIR)/crossbow.o \
|
||||
$(DLL_OBJDIR)/crowbar.o \
|
||||
$(DLL_OBJDIR)/doors.o \
|
||||
$(DLL_OBJDIR)/effects.o \
|
||||
$(DLL_OBJDIR)/egon.o \
|
||||
$(DLL_OBJDIR)/explode.o \
|
||||
$(DLL_OBJDIR)/func_break.o \
|
||||
$(DLL_OBJDIR)/func_tank.o \
|
||||
$(DLL_OBJDIR)/game.o \
|
||||
$(DLL_OBJDIR)/gamerules.o \
|
||||
$(DLL_OBJDIR)/gauss.o \
|
||||
$(DLL_OBJDIR)/ggrenade.o \
|
||||
$(DLL_OBJDIR)/globals.o \
|
||||
$(DLL_OBJDIR)/h_ai.o \
|
||||
$(DLL_OBJDIR)/h_battery.o \
|
||||
$(DLL_OBJDIR)/h_cycler.o \
|
||||
$(DLL_OBJDIR)/h_export.o \
|
||||
$(DLL_OBJDIR)/handgrenade.o \
|
||||
$(DLL_OBJDIR)/healthkit.o \
|
||||
$(DLL_OBJDIR)/hornet.o \
|
||||
$(DLL_OBJDIR)/hornetgun.o \
|
||||
$(DLL_OBJDIR)/items.o \
|
||||
$(DLL_OBJDIR)/lights.o \
|
||||
$(DLL_OBJDIR)/maprules.o \
|
||||
$(DLL_OBJDIR)/mortar.o \
|
||||
$(DLL_OBJDIR)/mp5.o \
|
||||
$(DLL_OBJDIR)/mpstubb.o \
|
||||
$(DLL_OBJDIR)/multiplay_gamerules.o \
|
||||
$(DLL_OBJDIR)/pathcorner.o \
|
||||
$(DLL_OBJDIR)/plane.o \
|
||||
$(DLL_OBJDIR)/plats.o \
|
||||
$(DLL_OBJDIR)/player.o \
|
||||
$(DLL_OBJDIR)/python.o \
|
||||
$(DLL_OBJDIR)/rpg.o \
|
||||
$(DLL_OBJDIR)/satchel.o \
|
||||
$(DLL_OBJDIR)/shotgun.o \
|
||||
$(DLL_OBJDIR)/singleplay_gamerules.o \
|
||||
$(DLL_OBJDIR)/skill.o \
|
||||
$(DLL_OBJDIR)/sound.o \
|
||||
$(DLL_OBJDIR)/soundent.o \
|
||||
$(DLL_OBJDIR)/spectator.o \
|
||||
$(DLL_OBJDIR)/squeakgrenade.o \
|
||||
$(DLL_OBJDIR)/subs.o \
|
||||
$(DLL_OBJDIR)/teamplay_gamerules.o \
|
||||
$(DLL_OBJDIR)/triggers.o \
|
||||
$(DLL_OBJDIR)/tripmine.o \
|
||||
$(DLL_OBJDIR)/util.o \
|
||||
$(DLL_OBJDIR)/weapons.o \
|
||||
$(DLL_OBJDIR)/world.o \
|
||||
$(DLL_OBJDIR)/xen.o \
|
||||
$(WPN_SHARED_OBJDIR)/hl_wpn_glock.o \
|
||||
$(GAME_SHARED_OBJDIR)/voice_gamemgr.o \
|
||||
$(PM_SHARED_OBJDIR)/pm_debug.o \
|
||||
$(PM_SHARED_OBJDIR)/pm_math.o \
|
||||
$(PM_SHARED_OBJDIR)/pm_shared.o
|
||||
|
||||
$(DLLNAME)_$(ARCH).$(SHLIBEXT) : neat $(OBJ)
|
||||
$(CC) $(CFLAGS) $(SHLIBLDFLAGS) $(LDFLAGS) -o $@ $(OBJ)
|
||||
|
||||
neat:
|
||||
-mkdir $(DLL_OBJDIR)
|
||||
-mkdir $(WPN_SHARED_OBJDIR)
|
||||
-mkdir $(GAME_SHARED_OBJDIR)
|
||||
-mkdir $(PM_SHARED_OBJDIR)
|
||||
clean:
|
||||
-rm -f $(OBJ)
|
||||
-rm -f $(DLLNAME)_$(ARCH).$(SHLIBEXT)
|
||||
spotless: clean
|
||||
-rm -r $(DLL_OBJDIR)
|
||||
-rm -r $(WPN_SHARED_OBJDIR)
|
||||
-rm -r $(GAME_SHARED_OBJDIR)
|
||||
-rm -r $(PM_SHARED_OBJDIR)
|
||||
|
139
dlls/activity.h
139
dlls/activity.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,32 +12,31 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef ACTIVITY_H
|
||||
#define ACTIVITY_H
|
||||
|
||||
#ifndef ACTIVITY_H
|
||||
#define ACTIVITY_H
|
||||
|
||||
|
||||
typedef enum {
|
||||
ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity
|
||||
ACT_IDLE = 1,
|
||||
typedef enum
|
||||
{
|
||||
ACT_RESET,
|
||||
ACT_IDLE,
|
||||
ACT_GUARD,
|
||||
ACT_WALK,
|
||||
ACT_RUN,
|
||||
ACT_FLY, // Fly (and flap if appropriate)
|
||||
ACT_FLY,
|
||||
ACT_SWIM,
|
||||
ACT_HOP, // vertical jump
|
||||
ACT_LEAP, // long forward jump
|
||||
ACT_HOP,
|
||||
ACT_LEAP,
|
||||
ACT_FALL,
|
||||
ACT_LAND,
|
||||
ACT_STRAFE_LEFT,
|
||||
ACT_STRAFE_RIGHT,
|
||||
ACT_ROLL_LEFT, // tuck and roll, left
|
||||
ACT_ROLL_RIGHT, // tuck and roll, right
|
||||
ACT_TURN_LEFT, // turn quickly left (stationary)
|
||||
ACT_TURN_RIGHT, // turn quickly right (stationary)
|
||||
ACT_CROUCH, // the act of crouching down from a standing position
|
||||
ACT_CROUCHIDLE, // holding body in crouched position (loops)
|
||||
ACT_STAND, // the act of standing from a crouched position
|
||||
ACT_ROLL_LEFT,
|
||||
ACT_ROLL_RIGHT,
|
||||
ACT_TURN_LEFT,
|
||||
ACT_TURN_RIGHT,
|
||||
ACT_CROUCH,
|
||||
ACT_CROUCHIDLE,
|
||||
ACT_STAND,
|
||||
ACT_USE,
|
||||
ACT_SIGNAL1,
|
||||
ACT_SIGNAL2,
|
||||
|
@ -51,43 +50,43 @@ typedef enum {
|
|||
ACT_MELEE_ATTACK1,
|
||||
ACT_MELEE_ATTACK2,
|
||||
ACT_RELOAD,
|
||||
ACT_ARM, // pull out gun, for instance
|
||||
ACT_DISARM, // reholster gun
|
||||
ACT_EAT, // monster chowing on a large food item (loop)
|
||||
ACT_ARM,
|
||||
ACT_DISARM,
|
||||
ACT_EAT,
|
||||
ACT_DIESIMPLE,
|
||||
ACT_DIEBACKWARD,
|
||||
ACT_DIEFORWARD,
|
||||
ACT_DIEVIOLENT,
|
||||
ACT_BARNACLE_HIT, // barnacle tongue hits a monster
|
||||
ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop )
|
||||
ACT_BARNACLE_CHOMP, // barnacle latches on to the monster
|
||||
ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop )
|
||||
ACT_BARNACLE_HIT,
|
||||
ACT_BARNACLE_PULL,
|
||||
ACT_BARNACLE_CHOMP,
|
||||
ACT_BARNACLE_CHEW,
|
||||
ACT_SLEEP,
|
||||
ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor
|
||||
ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall )
|
||||
ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop)
|
||||
ACT_WALK_HURT, // limp (loop)
|
||||
ACT_RUN_HURT, // limp (loop)
|
||||
ACT_HOVER, // Idle while in flight
|
||||
ACT_GLIDE, // Fly (don't flap)
|
||||
ACT_FLY_LEFT, // Turn left in flight
|
||||
ACT_FLY_RIGHT, // Turn right in flight
|
||||
ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air
|
||||
ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster
|
||||
ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops.
|
||||
ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc )
|
||||
ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of
|
||||
ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever.
|
||||
ACT_SPECIAL_ATTACK1, // very monster specific special attacks.
|
||||
ACT_SPECIAL_ATTACK2,
|
||||
ACT_COMBAT_IDLE, // agitated idle.
|
||||
ACT_INSPECT_FLOOR,
|
||||
ACT_INSPECT_WALL,
|
||||
ACT_IDLE_ANGRY,
|
||||
ACT_WALK_HURT,
|
||||
ACT_RUN_HURT,
|
||||
ACT_HOVER,
|
||||
ACT_GLIDE,
|
||||
ACT_FLY_LEFT,
|
||||
ACT_FLY_RIGHT,
|
||||
ACT_DETECT_SCENT,
|
||||
ACT_SNIFF,
|
||||
ACT_BITE,
|
||||
ACT_THREAT_DISPLAY,
|
||||
ACT_FEAR_DISPLAY,
|
||||
ACT_EXCITED,
|
||||
ACT_SPECIAL_ATTACK1,
|
||||
ACT_SPECIAL_ATTACK2,
|
||||
ACT_COMBAT_IDLE,
|
||||
ACT_WALK_SCARED,
|
||||
ACT_RUN_SCARED,
|
||||
ACT_VICTORY_DANCE, // killed a player, do a victory dance.
|
||||
ACT_DIE_HEADSHOT, // die, hit in head.
|
||||
ACT_DIE_CHESTSHOT, // die, hit in chest
|
||||
ACT_DIE_GUTSHOT, // die, hit in gut
|
||||
ACT_DIE_BACKSHOT, // die, hit in back
|
||||
ACT_VICTORY_DANCE,
|
||||
ACT_DIE_HEADSHOT,
|
||||
ACT_DIE_CHESTSHOT,
|
||||
ACT_DIE_GUTSHOT,
|
||||
ACT_DIE_BACKSHOT,
|
||||
ACT_FLINCH_HEAD,
|
||||
ACT_FLINCH_CHEST,
|
||||
ACT_FLINCH_STOMACH,
|
||||
|
@ -95,15 +94,39 @@ typedef enum {
|
|||
ACT_FLINCH_RIGHTARM,
|
||||
ACT_FLINCH_LEFTLEG,
|
||||
ACT_FLINCH_RIGHTLEG,
|
||||
} Activity;
|
||||
ACT_FLINCH,
|
||||
ACT_LARGE_FLINCH,
|
||||
ACT_HOLDBOMB,
|
||||
ACT_IDLE_FIDGET,
|
||||
ACT_IDLE_SCARED,
|
||||
ACT_IDLE_SCARED_FIDGET,
|
||||
ACT_FOLLOW_IDLE,
|
||||
ACT_FOLLOW_IDLE_FIDGET,
|
||||
ACT_FOLLOW_IDLE_SCARED,
|
||||
ACT_FOLLOW_IDLE_SCARED_FIDGET,
|
||||
ACT_CROUCH_IDLE,
|
||||
ACT_CROUCH_IDLE_FIDGET,
|
||||
ACT_CROUCH_IDLE_SCARED,
|
||||
ACT_CROUCH_IDLE_SCARED_FIDGET,
|
||||
ACT_CROUCH_WALK,
|
||||
ACT_CROUCH_WALK_SCARED,
|
||||
ACT_CROUCH_DIE,
|
||||
ACT_WALK_BACK,
|
||||
ACT_IDLE_SNEAKY,
|
||||
ACT_IDLE_SNEAKY_FIDGET,
|
||||
ACT_WALK_SNEAKY,
|
||||
ACT_WAVE,
|
||||
ACT_YES,
|
||||
ACT_NO
|
||||
}
|
||||
Activity;
|
||||
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
char *name;
|
||||
} activity_map_t;
|
||||
}
|
||||
activity_map_t;
|
||||
|
||||
extern activity_map_t activity_map[];
|
||||
|
||||
|
||||
#endif //ACTIVITY_H
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -13,85 +13,109 @@
|
|||
*
|
||||
****/
|
||||
|
||||
#define _A( a ) { a, #a }
|
||||
#define _A(a) { a, #a }
|
||||
|
||||
activity_map_t activity_map[] =
|
||||
{
|
||||
_A( ACT_IDLE ),
|
||||
_A( ACT_GUARD ),
|
||||
_A( ACT_WALK ),
|
||||
_A( ACT_RUN ),
|
||||
_A( ACT_FLY ),
|
||||
_A( ACT_SWIM ),
|
||||
_A( ACT_HOP ),
|
||||
_A( ACT_LEAP ),
|
||||
_A( ACT_FALL ),
|
||||
_A( ACT_LAND ),
|
||||
_A( ACT_STRAFE_LEFT ),
|
||||
_A( ACT_STRAFE_RIGHT ),
|
||||
_A( ACT_ROLL_LEFT ),
|
||||
_A( ACT_ROLL_RIGHT ),
|
||||
_A( ACT_TURN_LEFT ),
|
||||
_A( ACT_TURN_RIGHT ),
|
||||
_A( ACT_CROUCH ),
|
||||
_A( ACT_CROUCHIDLE ),
|
||||
_A( ACT_STAND ),
|
||||
_A( ACT_USE ),
|
||||
_A( ACT_SIGNAL1 ),
|
||||
_A( ACT_SIGNAL2 ),
|
||||
_A( ACT_SIGNAL3 ),
|
||||
_A( ACT_TWITCH ),
|
||||
_A( ACT_COWER ),
|
||||
_A( ACT_SMALL_FLINCH ),
|
||||
_A( ACT_BIG_FLINCH ),
|
||||
_A( ACT_RANGE_ATTACK1 ),
|
||||
_A( ACT_RANGE_ATTACK2 ),
|
||||
_A( ACT_MELEE_ATTACK1 ),
|
||||
_A( ACT_MELEE_ATTACK2 ),
|
||||
_A( ACT_RELOAD ),
|
||||
_A( ACT_ARM ),
|
||||
_A( ACT_DISARM ),
|
||||
_A( ACT_EAT ),
|
||||
_A( ACT_DIESIMPLE ),
|
||||
_A( ACT_DIEBACKWARD ),
|
||||
_A( ACT_DIEFORWARD ),
|
||||
_A( ACT_DIEVIOLENT ),
|
||||
_A( ACT_BARNACLE_HIT ),
|
||||
_A( ACT_BARNACLE_PULL ),
|
||||
_A( ACT_BARNACLE_CHOMP ),
|
||||
_A( ACT_BARNACLE_CHEW ),
|
||||
_A( ACT_SLEEP ),
|
||||
_A( ACT_INSPECT_FLOOR ),
|
||||
_A( ACT_INSPECT_WALL ),
|
||||
_A( ACT_IDLE_ANGRY ),
|
||||
_A( ACT_WALK_HURT ),
|
||||
_A( ACT_RUN_HURT ),
|
||||
_A( ACT_HOVER ),
|
||||
_A( ACT_GLIDE ),
|
||||
_A( ACT_FLY_LEFT ),
|
||||
_A( ACT_FLY_RIGHT ),
|
||||
_A( ACT_DETECT_SCENT ),
|
||||
_A( ACT_SNIFF ),
|
||||
_A( ACT_BITE ),
|
||||
_A( ACT_THREAT_DISPLAY ),
|
||||
_A( ACT_FEAR_DISPLAY ),
|
||||
_A( ACT_EXCITED ),
|
||||
_A( ACT_SPECIAL_ATTACK1 ),
|
||||
_A( ACT_SPECIAL_ATTACK2 ),
|
||||
_A( ACT_COMBAT_IDLE ),
|
||||
_A( ACT_WALK_SCARED ),
|
||||
_A( ACT_RUN_SCARED ),
|
||||
_A( ACT_VICTORY_DANCE ),
|
||||
_A( ACT_DIE_HEADSHOT ),
|
||||
_A( ACT_DIE_CHESTSHOT ),
|
||||
_A( ACT_DIE_GUTSHOT ),
|
||||
_A( ACT_DIE_BACKSHOT ),
|
||||
_A( ACT_FLINCH_HEAD ),
|
||||
_A( ACT_FLINCH_CHEST ),
|
||||
_A( ACT_FLINCH_STOMACH ),
|
||||
_A( ACT_FLINCH_LEFTARM ),
|
||||
_A( ACT_FLINCH_RIGHTARM ),
|
||||
_A( ACT_FLINCH_LEFTLEG ),
|
||||
_A( ACT_FLINCH_RIGHTLEG ),
|
||||
0, NULL
|
||||
};
|
||||
_A(ACT_IDLE),
|
||||
_A(ACT_GUARD),
|
||||
_A(ACT_WALK),
|
||||
_A(ACT_RUN),
|
||||
_A(ACT_FLY),
|
||||
_A(ACT_SWIM),
|
||||
_A(ACT_HOP),
|
||||
_A(ACT_LEAP),
|
||||
_A(ACT_FALL),
|
||||
_A(ACT_LAND),
|
||||
_A(ACT_STRAFE_LEFT),
|
||||
_A(ACT_STRAFE_RIGHT),
|
||||
_A(ACT_ROLL_LEFT),
|
||||
_A(ACT_ROLL_RIGHT),
|
||||
_A(ACT_TURN_LEFT),
|
||||
_A(ACT_TURN_RIGHT),
|
||||
_A(ACT_CROUCH),
|
||||
_A(ACT_CROUCHIDLE),
|
||||
_A(ACT_STAND),
|
||||
_A(ACT_USE),
|
||||
_A(ACT_SIGNAL1),
|
||||
_A(ACT_SIGNAL2),
|
||||
_A(ACT_SIGNAL3),
|
||||
_A(ACT_TWITCH),
|
||||
_A(ACT_COWER),
|
||||
_A(ACT_SMALL_FLINCH),
|
||||
_A(ACT_BIG_FLINCH),
|
||||
_A(ACT_RANGE_ATTACK1),
|
||||
_A(ACT_RANGE_ATTACK2),
|
||||
_A(ACT_MELEE_ATTACK1),
|
||||
_A(ACT_MELEE_ATTACK2),
|
||||
_A(ACT_RELOAD),
|
||||
_A(ACT_ARM),
|
||||
_A(ACT_DISARM),
|
||||
_A(ACT_EAT),
|
||||
_A(ACT_DIESIMPLE),
|
||||
_A(ACT_DIEBACKWARD),
|
||||
_A(ACT_DIEFORWARD),
|
||||
_A(ACT_DIEVIOLENT),
|
||||
_A(ACT_BARNACLE_HIT),
|
||||
_A(ACT_BARNACLE_PULL),
|
||||
_A(ACT_BARNACLE_CHOMP),
|
||||
_A(ACT_BARNACLE_CHEW),
|
||||
_A(ACT_SLEEP),
|
||||
_A(ACT_INSPECT_FLOOR),
|
||||
_A(ACT_INSPECT_WALL),
|
||||
_A(ACT_IDLE_ANGRY),
|
||||
_A(ACT_WALK_HURT),
|
||||
_A(ACT_RUN_HURT),
|
||||
_A(ACT_HOVER),
|
||||
_A(ACT_GLIDE),
|
||||
_A(ACT_FLY_LEFT),
|
||||
_A(ACT_FLY_RIGHT),
|
||||
_A(ACT_DETECT_SCENT),
|
||||
_A(ACT_SNIFF),
|
||||
_A(ACT_BITE),
|
||||
_A(ACT_THREAT_DISPLAY),
|
||||
_A(ACT_FEAR_DISPLAY),
|
||||
_A(ACT_EXCITED),
|
||||
_A(ACT_SPECIAL_ATTACK1),
|
||||
_A(ACT_SPECIAL_ATTACK2),
|
||||
_A(ACT_COMBAT_IDLE),
|
||||
_A(ACT_WALK_SCARED),
|
||||
_A(ACT_RUN_SCARED),
|
||||
_A(ACT_VICTORY_DANCE),
|
||||
_A(ACT_DIE_HEADSHOT),
|
||||
_A(ACT_DIE_CHESTSHOT),
|
||||
_A(ACT_DIE_GUTSHOT),
|
||||
_A(ACT_DIE_BACKSHOT),
|
||||
_A(ACT_FLINCH_HEAD),
|
||||
_A(ACT_FLINCH_CHEST),
|
||||
_A(ACT_FLINCH_STOMACH),
|
||||
_A(ACT_FLINCH_LEFTARM),
|
||||
_A(ACT_FLINCH_RIGHTARM),
|
||||
_A(ACT_FLINCH_LEFTLEG),
|
||||
_A(ACT_FLINCH_RIGHTLEG),
|
||||
_A(ACT_FLINCH),
|
||||
_A(ACT_LARGE_FLINCH),
|
||||
_A(ACT_HOLDBOMB),
|
||||
_A(ACT_IDLE_FIDGET),
|
||||
_A(ACT_IDLE_SCARED),
|
||||
_A(ACT_IDLE_SCARED_FIDGET),
|
||||
_A(ACT_FOLLOW_IDLE),
|
||||
_A(ACT_FOLLOW_IDLE_FIDGET),
|
||||
_A(ACT_FOLLOW_IDLE_SCARED),
|
||||
_A(ACT_FOLLOW_IDLE_SCARED_FIDGET),
|
||||
_A(ACT_CROUCH_IDLE),
|
||||
_A(ACT_CROUCH_IDLE_FIDGET),
|
||||
_A(ACT_CROUCH_IDLE_SCARED),
|
||||
_A(ACT_CROUCH_IDLE_SCARED_FIDGET),
|
||||
_A(ACT_CROUCH_WALK),
|
||||
_A(ACT_CROUCH_WALK_SCARED),
|
||||
_A(ACT_CROUCH_DIE),
|
||||
_A(ACT_WALK_BACK),
|
||||
_A(ACT_IDLE_SNEAKY),
|
||||
_A(ACT_IDLE_SNEAKY_FIDGET),
|
||||
_A(ACT_WALK_SNEAKY),
|
||||
_A(ACT_WAVE),
|
||||
_A(ACT_YES),
|
||||
_A(ACT_NO),
|
||||
{ 0, NULL }
|
||||
};
|
104
dlls/airtank.cpp
104
dlls/airtank.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,8 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
|
@ -22,97 +22,85 @@
|
|||
|
||||
class CAirtank : public CGrenade
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void EXPORT TankThink( void );
|
||||
void EXPORT TankTouch( CBaseEntity *pOther );
|
||||
int BloodColor( void ) { return DONT_BLEED; };
|
||||
void Killed( entvars_t *pevAttacker, int iGib );
|
||||
public:
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
void Killed(entvars_t *pevAttacker, int iGib);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
void EXPORT TankThink(void);
|
||||
void EXPORT TankTouch(CBaseEntity *pOther);
|
||||
|
||||
int m_state;
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
public:
|
||||
int m_state;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_airtank, CAirtank);
|
||||
|
||||
LINK_ENTITY_TO_CLASS( item_airtank, CAirtank );
|
||||
TYPEDESCRIPTION CAirtank::m_SaveData[] =
|
||||
TYPEDESCRIPTION CAirtank::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ),
|
||||
DEFINE_FIELD(CAirtank, m_state, FIELD_INTEGER)
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CAirtank, CGrenade );
|
||||
IMPLEMENT_SAVERESTORE(CAirtank, CGrenade);
|
||||
|
||||
|
||||
void CAirtank :: Spawn( void )
|
||||
void CAirtank::Spawn(void)
|
||||
{
|
||||
Precache( );
|
||||
// motor
|
||||
Precache();
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/w_oxygen.mdl");
|
||||
UTIL_SetSize(pev, Vector( -16, -16, 0), Vector(16, 16, 36));
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 36));
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
|
||||
SetTouch( TankTouch );
|
||||
SetThink( TankThink );
|
||||
SetThink(&CAirtank::TankThink);
|
||||
SetTouch(&CAirtank::TankTouch);
|
||||
|
||||
pev->flags |= FL_MONSTER;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->health = 20;
|
||||
pev->dmg = 50;
|
||||
m_state = 1;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->health = 20;
|
||||
pev->dmg = 50;
|
||||
m_state = 1;
|
||||
}
|
||||
|
||||
void CAirtank::Precache( void )
|
||||
void CAirtank::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_oxygen.mdl");
|
||||
PRECACHE_SOUND("doors/aliendoor3.wav");
|
||||
}
|
||||
|
||||
|
||||
void CAirtank :: Killed( entvars_t *pevAttacker, int iGib )
|
||||
void CAirtank::Killed(entvars_t *pevAttacker, int iGib)
|
||||
{
|
||||
pev->owner = ENT( pevAttacker );
|
||||
|
||||
// UNDONE: this should make a big bubble cloud, not an explosion
|
||||
|
||||
Explode( pev->origin, Vector( 0, 0, -1 ) );
|
||||
pev->owner = ENT(pevAttacker);
|
||||
Explode(pev->origin, Vector(0, 0, -1));
|
||||
}
|
||||
|
||||
|
||||
void CAirtank::TankThink( void )
|
||||
void CAirtank::TankThink(void)
|
||||
{
|
||||
// Fire trigger
|
||||
m_state = 1;
|
||||
SUB_UseTargets( this, USE_TOGGLE, 0 );
|
||||
SUB_UseTargets(this, USE_TOGGLE, 0);
|
||||
}
|
||||
|
||||
|
||||
void CAirtank::TankTouch( CBaseEntity *pOther )
|
||||
void CAirtank::TankTouch(CBaseEntity *pOther)
|
||||
{
|
||||
if ( !pOther->IsPlayer() )
|
||||
if (!pOther->IsPlayer())
|
||||
return;
|
||||
|
||||
if (!m_state)
|
||||
{
|
||||
// "no oxygen" sound
|
||||
EMIT_SOUND( ENT(pev), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_swim2.wav", VOL_NORM, ATTN_NORM);
|
||||
return;
|
||||
}
|
||||
|
||||
// give player 12 more seconds of air
|
||||
|
||||
pOther->pev->air_finished = gpGlobals->time + 12;
|
||||
|
||||
// suit recharge sound
|
||||
EMIT_SOUND( ENT(pev), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM );
|
||||
|
||||
// recharge airtank in 30 seconds
|
||||
EMIT_SOUND(ENT(pev), CHAN_VOICE, "doors/aliendoor3.wav", VOL_NORM, ATTN_NORM);
|
||||
pev->nextthink = gpGlobals->time + 30;
|
||||
m_state = 0;
|
||||
SUB_UseTargets( this, USE_TOGGLE, 1 );
|
||||
}
|
||||
SUB_UseTargets(this, USE_TOGGLE, 1);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,307 +12,244 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== monsters.cpp ========================================================
|
||||
|
||||
Monster-related utility code
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "animation.h"
|
||||
#include "saverestore.h"
|
||||
|
||||
TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
|
||||
TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CBaseMonster, m_flFrameRate, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseMonster, m_flGroundSpeed, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseMonster, m_flLastEventCheck, FIELD_TIME ),
|
||||
DEFINE_FIELD( CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN ),
|
||||
DEFINE_FIELD( CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN ),
|
||||
DEFINE_FIELD(CBaseMonster, m_flFrameRate, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseMonster, m_flGroundSpeed, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseMonster, m_flLastEventCheck, FIELD_TIME),
|
||||
DEFINE_FIELD(CBaseMonster, m_fSequenceFinished, FIELD_BOOLEAN),
|
||||
DEFINE_FIELD(CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CBaseAnimating, CBaseDelay );
|
||||
IMPLEMENT_SAVERESTORE(CBaseAnimating, CBaseDelay);
|
||||
|
||||
|
||||
//=========================================================
|
||||
// StudioFrameAdvance - advance the animation frame up to the current time
|
||||
// if an flInterval is passed in, only advance animation that number of seconds
|
||||
//=========================================================
|
||||
float CBaseAnimating :: StudioFrameAdvance ( float flInterval )
|
||||
float CBaseAnimating::StudioFrameAdvance(float flInterval)
|
||||
{
|
||||
if (flInterval == 0.0)
|
||||
if (flInterval == 0)
|
||||
{
|
||||
flInterval = (gpGlobals->time - pev->animtime);
|
||||
|
||||
if (flInterval <= 0.001)
|
||||
{
|
||||
pev->animtime = gpGlobals->time;
|
||||
return 0.0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (! pev->animtime)
|
||||
flInterval = 0.0;
|
||||
|
||||
|
||||
if (!pev->animtime)
|
||||
flInterval = 0;
|
||||
|
||||
pev->frame += flInterval * m_flFrameRate * pev->framerate;
|
||||
pev->animtime = gpGlobals->time;
|
||||
|
||||
if (pev->frame < 0.0 || pev->frame >= 256.0)
|
||||
if (pev->frame < 0 || pev->frame >= 256)
|
||||
{
|
||||
if (m_fSequenceLoops)
|
||||
pev->frame -= (int)(pev->frame / 256.0) * 256.0;
|
||||
else
|
||||
pev->frame = (pev->frame < 0.0) ? 0 : 255;
|
||||
m_fSequenceFinished = TRUE; // just in case it wasn't caught in GetEvents
|
||||
pev->frame = (pev->frame < 0) ? 0 : 255;
|
||||
|
||||
m_fSequenceFinished = TRUE;
|
||||
}
|
||||
|
||||
return flInterval;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// LookupActivity
|
||||
//=========================================================
|
||||
int CBaseAnimating :: LookupActivity ( int activity )
|
||||
int CBaseAnimating::LookupActivity(int activity)
|
||||
{
|
||||
ASSERT( activity != 0 );
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::LookupActivity( pmodel, pev, activity );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return ::LookupActivity(pmodel, pev, activity);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// LookupActivityHeaviest
|
||||
//
|
||||
// Get activity with highest 'weight'
|
||||
//
|
||||
//=========================================================
|
||||
int CBaseAnimating :: LookupActivityHeaviest ( int activity )
|
||||
int CBaseAnimating::LookupActivityHeaviest(int activity)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::LookupActivityHeaviest( pmodel, pev, activity );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return ::LookupActivityHeaviest(pmodel, pev, activity);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CBaseAnimating :: LookupSequence ( const char *label )
|
||||
int CBaseAnimating::LookupSequence(const char *label)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::LookupSequence( pmodel, label );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return ::LookupSequence(pmodel, label);
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CBaseAnimating :: ResetSequenceInfo ( )
|
||||
void CBaseAnimating::ResetSequenceInfo(void)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
|
||||
GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
|
||||
GetSequenceInfo(pmodel, pev, &m_flFrameRate, &m_flGroundSpeed);
|
||||
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
|
||||
pev->animtime = gpGlobals->time;
|
||||
pev->framerate = 1.0;
|
||||
pev->framerate = 1;
|
||||
m_fSequenceFinished = FALSE;
|
||||
m_flLastEventCheck = gpGlobals->time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CBaseAnimating :: GetSequenceFlags( )
|
||||
BOOL CBaseAnimating::GetSequenceFlags(void)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::GetSequenceFlags( pmodel, pev );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return ::GetSequenceFlags(pmodel, pev);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DispatchAnimEvents
|
||||
//=========================================================
|
||||
void CBaseAnimating :: DispatchAnimEvents ( float flInterval )
|
||||
void CBaseAnimating::DispatchAnimEvents(float flInterval)
|
||||
{
|
||||
MonsterEvent_t event;
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
if ( !pmodel )
|
||||
if (!pmodel)
|
||||
{
|
||||
ALERT( at_aiconsole, "Gibbed monster is thinking!\n" );
|
||||
ALERT(at_aiconsole, "Gibbed monster is thinking!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: I have to do this or some events get missed, and this is probably causing the problem below
|
||||
flInterval = 0.1;
|
||||
|
||||
// FIX: this still sometimes hits events twice
|
||||
float flStart = pev->frame + (m_flLastEventCheck - pev->animtime) * m_flFrameRate * pev->framerate;
|
||||
float flEnd = pev->frame + flInterval * m_flFrameRate * pev->framerate;
|
||||
m_flLastEventCheck = pev->animtime + flInterval;
|
||||
|
||||
m_fSequenceFinished = FALSE;
|
||||
if (flEnd >= 256 || flEnd <= 0.0)
|
||||
|
||||
if (flEnd >= 256 || flEnd <= 0)
|
||||
m_fSequenceFinished = TRUE;
|
||||
|
||||
int index = 0;
|
||||
MonsterEvent_t event;
|
||||
|
||||
while ( (index = GetAnimationEvent( pmodel, pev, &event, flStart, flEnd, index ) ) != 0 )
|
||||
{
|
||||
HandleAnimEvent( &event );
|
||||
}
|
||||
while ((index = GetAnimationEvent(pmodel, pev, &event, flStart, flEnd, index)) != 0)
|
||||
HandleAnimEvent(&event);
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CBaseAnimating :: SetBoneController ( int iController, float flValue )
|
||||
float CBaseAnimating::SetBoneController(int iController, float flValue)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return SetController( pmodel, pev, iController, flValue );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return SetController(pmodel, pev, iController, flValue);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CBaseAnimating :: InitBoneControllers ( void )
|
||||
void CBaseAnimating::InitBoneControllers(void)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
|
||||
SetController( pmodel, pev, 0, 0.0 );
|
||||
SetController( pmodel, pev, 1, 0.0 );
|
||||
SetController( pmodel, pev, 2, 0.0 );
|
||||
SetController( pmodel, pev, 3, 0.0 );
|
||||
SetController(pmodel, pev, 0, 0);
|
||||
SetController(pmodel, pev, 1, 0);
|
||||
SetController(pmodel, pev, 2, 0);
|
||||
SetController(pmodel, pev, 3, 0);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CBaseAnimating :: SetBlending ( int iBlender, float flValue )
|
||||
float CBaseAnimating::SetBlending(int iBlender, float flValue)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
return ::SetBlending( pmodel, pev, iBlender, flValue );
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
return ::SetBlending(pmodel, pev, iBlender, flValue);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles )
|
||||
void CBaseAnimating::GetBonePosition(int iBone, Vector &origin, Vector &angles)
|
||||
{
|
||||
GET_BONE_POSITION( ENT(pev), iBone, origin, angles );
|
||||
GET_BONE_POSITION(ENT(pev), iBone, origin, angles);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles )
|
||||
void CBaseAnimating::GetAttachment(int iAttachment, Vector &origin, Vector &angles)
|
||||
{
|
||||
GET_ATTACHMENT( ENT(pev), iAttachment, origin, angles );
|
||||
GET_ATTACHMENT(ENT(pev), iAttachment, origin, angles);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir )
|
||||
int CBaseAnimating::FindTransition(int iEndingSequence, int iGoalSequence, int *piDir)
|
||||
{
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
|
||||
if (piDir == NULL)
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
|
||||
if (!piDir)
|
||||
{
|
||||
int iDir;
|
||||
int sequence = ::FindTransition( pmodel, iEndingSequence, iGoalSequence, &iDir );
|
||||
int sequence = ::FindTransition(pmodel, iEndingSequence, iGoalSequence, &iDir);
|
||||
|
||||
if (iDir != 1)
|
||||
return -1;
|
||||
else
|
||||
return sequence;
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
return ::FindTransition( pmodel, iEndingSequence, iGoalSequence, piDir );
|
||||
return ::FindTransition(pmodel, iEndingSequence, iGoalSequence, piDir);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval )
|
||||
void CBaseAnimating::GetAutomovement(Vector &origin, Vector &angles, float flInterval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue )
|
||||
void CBaseAnimating::SetBodygroup(int iGroup, int iValue)
|
||||
{
|
||||
::SetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup, iValue );
|
||||
::SetBodygroup(GET_MODEL_PTR(ENT(pev)), pev, iGroup, iValue);
|
||||
}
|
||||
|
||||
int CBaseAnimating :: GetBodygroup( int iGroup )
|
||||
int CBaseAnimating::GetBodygroup(int iGroup)
|
||||
{
|
||||
return ::GetBodygroup( GET_MODEL_PTR( ENT(pev) ), pev, iGroup );
|
||||
return ::GetBodygroup(GET_MODEL_PTR(ENT(pev)), pev, iGroup);
|
||||
}
|
||||
|
||||
|
||||
int CBaseAnimating :: ExtractBbox( int sequence, float *mins, float *maxs )
|
||||
int CBaseAnimating::ExtractBbox(int sequence, float *mins, float *maxs)
|
||||
{
|
||||
return ::ExtractBbox( GET_MODEL_PTR( ENT(pev) ), sequence, mins, maxs );
|
||||
return ::ExtractBbox(GET_MODEL_PTR(ENT(pev)), sequence, mins, maxs);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
|
||||
void CBaseAnimating :: SetSequenceBox( void )
|
||||
void CBaseAnimating::SetSequenceBox(void)
|
||||
{
|
||||
Vector mins, maxs;
|
||||
|
||||
// Get sequence bbox
|
||||
if ( ExtractBbox( pev->sequence, mins, maxs ) )
|
||||
if (ExtractBbox(pev->sequence, mins, maxs))
|
||||
{
|
||||
// expand box for rotation
|
||||
// find min / max for rotations
|
||||
float yaw = pev->angles.y * (M_PI / 180.0);
|
||||
|
||||
float yaw = pev->angles.y * (M_PI / 180);
|
||||
|
||||
Vector xvector, yvector;
|
||||
xvector.x = cos(yaw);
|
||||
xvector.y = sin(yaw);
|
||||
yvector.x = -sin(yaw);
|
||||
yvector.y = cos(yaw);
|
||||
Vector bounds[2];
|
||||
|
||||
bounds[0] = mins;
|
||||
bounds[1] = maxs;
|
||||
|
||||
Vector rmin( 9999, 9999, 9999 );
|
||||
Vector rmax( -9999, -9999, -9999 );
|
||||
Vector bounds[2] = { mins, maxs };
|
||||
Vector rmin(9999, 9999, 9999);
|
||||
Vector rmax(-9999, -9999, -9999);
|
||||
Vector base, transformed;
|
||||
|
||||
for (int i = 0; i <= 1; i++ )
|
||||
for (int i = 0; i <= 1; i++)
|
||||
{
|
||||
base.x = bounds[i].x;
|
||||
for ( int j = 0; j <= 1; j++ )
|
||||
|
||||
for (int j = 0; j <= 1; j++)
|
||||
{
|
||||
base.y = bounds[j].y;
|
||||
for ( int k = 0; k <= 1; k++ )
|
||||
|
||||
for (int k = 0; k <= 1; k++)
|
||||
{
|
||||
base.z = bounds[k].z;
|
||||
|
||||
// transform the point
|
||||
transformed.x = xvector.x*base.x + yvector.x*base.y;
|
||||
transformed.y = xvector.y*base.x + yvector.y*base.y;
|
||||
transformed.x = xvector.x * base.x + yvector.x * base.y;
|
||||
transformed.y = xvector.y * base.x + yvector.y * base.y;
|
||||
transformed.z = base.z;
|
||||
|
||||
|
||||
if (transformed.x < rmin.x)
|
||||
rmin.x = transformed.x;
|
||||
|
||||
if (transformed.x > rmax.x)
|
||||
rmax.x = transformed.x;
|
||||
|
||||
if (transformed.y < rmin.y)
|
||||
rmin.y = transformed.y;
|
||||
|
||||
if (transformed.y > rmax.y)
|
||||
rmax.y = transformed.y;
|
||||
|
||||
if (transformed.z < rmin.z)
|
||||
rmin.z = transformed.z;
|
||||
|
||||
if (transformed.z > rmax.z)
|
||||
rmax.z = transformed.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rmin.z = 0;
|
||||
rmax.z = rmin.z + 1;
|
||||
UTIL_SetSize( pev, rmin, rmax );
|
||||
UTIL_SetSize(pev, rmin, rmax);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
1168
dlls/animation.cpp
1168
dlls/animation.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,36 +12,65 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef ANIMATION_H
|
||||
#define ANIMATION_H
|
||||
|
||||
#define ACTIVITY_NOT_AVAILABLE -1
|
||||
|
||||
#ifndef MONSTEREVENT_H
|
||||
#include "monsterevent.h"
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
extern int IsSoundEvent( int eventNumber );
|
||||
#define ANIM_SWIM_1 8
|
||||
#define ANIM_SWIM_2 9
|
||||
#define ANIM_FIRST_DEATH_SEQUENCE 101
|
||||
|
||||
int LookupActivity( void *pmodel, entvars_t *pev, int activity );
|
||||
int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity );
|
||||
int LookupSequence( void *pmodel, const char *label );
|
||||
void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed );
|
||||
int GetSequenceFlags( void *pmodel, entvars_t *pev );
|
||||
int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd );
|
||||
float SetController( void *pmodel, entvars_t *pev, int iController, float flValue );
|
||||
float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue );
|
||||
void GetEyePosition( void *pmodel, float *vecEyePosition );
|
||||
void SequencePrecache( void *pmodel, const char *pSequenceName );
|
||||
int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir );
|
||||
void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue );
|
||||
int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup );
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
#include "r_studioint.h"
|
||||
|
||||
int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index );
|
||||
int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs );
|
||||
#define NOXREF
|
||||
#define C_DLLEXPORT
|
||||
#define ACTIVITY_NOT_AVAILABLE -1
|
||||
|
||||
// From /engine/studio.h
|
||||
#define STUDIO_LOOPING 0x0001
|
||||
int ExtractBbox(void *pmodel, int sequence, float *mins, float *maxs);
|
||||
int LookupActivity(void *pmodel, entvars_t *pev, int activity);
|
||||
int LookupActivityHeaviest(void *pmodel, entvars_t *pev, int activity);
|
||||
NOXREF void GetEyePosition(void *pmodel, float *vecEyePosition);
|
||||
int LookupSequence(void *pmodel, const char *label);
|
||||
int IsSoundEvent(int eventNumber);
|
||||
NOXREF void SequencePrecache(void *pmodel, const char *pSequenceName);
|
||||
void GetSequenceInfo(void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed);
|
||||
int GetSequenceFlags(void *pmodel, entvars_t *pev);
|
||||
int GetAnimationEvent(void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index);
|
||||
float SetController(void *pmodel, entvars_t *pev, int iController, float flValue);
|
||||
float SetBlending(void *pmodel, entvars_t *pev, int iBlender, float flValue);
|
||||
int FindTransition(void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir);
|
||||
void SetBodygroup(void *pmodel, entvars_t *pev, int iGroup, int iValue);
|
||||
int GetBodygroup(void *pmodel, entvars_t *pev, int iGroup);
|
||||
C_DLLEXPORT int Server_GetBlendingInterface(int version, struct sv_blending_interface_s **ppinterface, struct engine_studio_api_s *pstudio, float *rotationmatrix, float *bonetransform);
|
||||
void AngleQuaternion(vec_t *angles, vec_t *quaternion);
|
||||
void QuaternionSlerp(vec_t *p, vec_t *q, float t, vec_t *qt);
|
||||
void QuaternionMatrix(vec_t *quaternion, float (*matrix)[4]);
|
||||
mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc);
|
||||
mstudioanim_t *LookupAnimation(model_t *model, mstudioseqdesc_t *pseqdesc, int index);
|
||||
void StudioCalcBoneAdj(float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen);
|
||||
void StudioCalcBoneQuaterion(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q);
|
||||
void StudioCalcBonePosition(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos);
|
||||
void StudioSlerpBones(vec4_t *q1, float pos1[][3], vec4_t *q2, float pos2[][3], float s);
|
||||
void StudioCalcRotations(mstudiobone_t *pbones, int *chain, int chainlength, float *adj, float pos[128][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f, float s);
|
||||
void ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
void SV_StudioSetupBones(struct model_s *pModel, float frame, int sequence, const vec3_t angles, const vec3_t origin, const byte *pcontroller, const byte *pblending,int iBone, const edict_t *pEdict);
|
||||
|
||||
|
||||
#endif //ANIMATION_H
|
||||
extern struct sv_blending_interface_s svBlending;
|
||||
extern server_studio_api_t IEngineStudio;
|
||||
extern studiohdr_t *g_pstudiohdr;
|
||||
extern float (*g_pRotationMatrix)[3][4];
|
||||
extern float (*g_pBoneTransform)[128][3][4];
|
||||
extern float omega;
|
||||
extern float cosom;
|
||||
extern float sinom;
|
||||
extern float sclp;
|
||||
extern float sclq;
|
||||
|
||||
#endif // ANIMATION_H
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -18,77 +18,73 @@
|
|||
class CBaseMonster : public CBaseToggle
|
||||
{
|
||||
public:
|
||||
Activity m_Activity;// what the monster is doing (animation)
|
||||
Activity m_IdealActivity;// monster should switch to this activity
|
||||
int m_LastHitGroup; // the last body region that took damage
|
||||
int m_bitsDamageType; // what types of damage has monster (player) taken
|
||||
BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED];
|
||||
MONSTERSTATE m_MonsterState;// monster's current state
|
||||
MONSTERSTATE m_IdealMonsterState;// monster should change to this state
|
||||
int m_afConditions;
|
||||
int m_afMemory;
|
||||
float m_flNextAttack; // cannot attack again until this time
|
||||
EHANDLE m_hEnemy; // the entity that the monster is fighting.
|
||||
EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach
|
||||
float m_flFieldOfView;// width of monster's field of view ( dot product )
|
||||
int m_bloodColor; // color of blood particless
|
||||
Vector m_HackedGunPos; // HACK until we can query end of gun
|
||||
Vector m_vecEnemyLKP;// last known position of enemy. (enemy's origin)
|
||||
virtual void KeyValue(KeyValueData *pkvd);
|
||||
virtual float ChangeYaw(int speed);
|
||||
virtual BOOL HasHumanGibs(void);
|
||||
virtual BOOL HasAlienGibs(void);
|
||||
virtual void FadeMonster(void);
|
||||
virtual void GibMonster(void);
|
||||
virtual Activity GetDeathActivity(void);
|
||||
virtual void BecomeDead(void);
|
||||
virtual BOOL ShouldFadeOnDeath(void);
|
||||
virtual int IRelationship(CBaseEntity *pTarget);
|
||||
virtual int TakeHealth(float flHealth, int bitsDamageType);
|
||||
virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
|
||||
virtual void Killed(entvars_t *pevAttacker, int iGib);
|
||||
virtual void PainSound(void) { return; }
|
||||
virtual void ResetMaxSpeed(void) {};
|
||||
virtual void ReportAIState(void);
|
||||
virtual void MonsterInitDead(void);
|
||||
virtual void Look(int iDistance);
|
||||
virtual CBaseEntity *BestVisibleEnemy(void);
|
||||
virtual BOOL FInViewCone(CBaseEntity *pEntity);
|
||||
virtual BOOL FInViewCone(Vector *pOrigin);
|
||||
virtual int BloodColor(void) { return m_bloodColor; }
|
||||
virtual BOOL IsAlive(void) { return (pev->deadflag != DEAD_DEAD); }
|
||||
|
||||
public:
|
||||
void MakeIdealYaw(Vector vecTarget);
|
||||
Activity GetSmallFlinchActivity(void);
|
||||
BOOL ShouldGibMonster(int iGib);
|
||||
void CallGibMonster(void);
|
||||
BOOL FCheckAITrigger(void);
|
||||
int DeadTakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
|
||||
float DamageForce(float damage);
|
||||
void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType);
|
||||
void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType);
|
||||
void EXPORT CorpseFallThink(void);
|
||||
CBaseEntity *CheckTraceHullAttack(float flDist, int iDamage, int iDmgType);
|
||||
void TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
void MakeDamageBloodDecal(int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir);
|
||||
void BloodSplat(const Vector &vecPos, const Vector &vecDir, int hitgroup, int iDamage);
|
||||
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
|
||||
void MakeIdealYaw( Vector vecTarget );
|
||||
virtual float ChangeYaw ( int speed );
|
||||
virtual BOOL HasHumanGibs( void );
|
||||
virtual BOOL HasAlienGibs( void );
|
||||
virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled
|
||||
virtual void GibMonster( void );
|
||||
virtual Activity GetDeathActivity ( void );
|
||||
Activity GetSmallFlinchActivity( void );
|
||||
virtual void BecomeDead( void );
|
||||
BOOL ShouldGibMonster( int iGib );
|
||||
void CallGibMonster( void );
|
||||
virtual BOOL ShouldFadeOnDeath( void );
|
||||
BOOL FCheckAITrigger( void );// checks and, if necessary, fires the monster's trigger target.
|
||||
virtual int IRelationship ( CBaseEntity *pTarget );
|
||||
virtual int TakeHealth( float flHealth, int bitsDamageType );
|
||||
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType);
|
||||
int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
float DamageForce( float damage );
|
||||
virtual void Killed( entvars_t *pevAttacker, int iGib );
|
||||
virtual void PainSound ( void ) { return; };
|
||||
|
||||
void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType );
|
||||
void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType );
|
||||
|
||||
inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; }
|
||||
inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; }
|
||||
inline BOOL HasConditions( int iConditions ) { if ( m_afConditions & iConditions ) return TRUE; return FALSE; }
|
||||
inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; }
|
||||
|
||||
inline void Remember( int iMemory ) { m_afMemory |= iMemory; }
|
||||
inline void Forget( int iMemory ) { m_afMemory &= ~iMemory; }
|
||||
inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; }
|
||||
inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; }
|
||||
|
||||
// This will stop animation until you call ResetSequenceInfo() at some point in the future
|
||||
inline void StopAnimation( void ) { pev->framerate = 0; }
|
||||
|
||||
virtual void ReportAIState( void );
|
||||
virtual void MonsterInitDead( void ); // Call after animation/pose is set up
|
||||
void EXPORT CorpseFallThink( void );
|
||||
|
||||
virtual void Look ( int iDistance );// basic sight function for monsters
|
||||
virtual CBaseEntity* BestVisibleEnemy ( void );// finds best visible enemy for attack
|
||||
CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType );
|
||||
virtual BOOL FInViewCone ( CBaseEntity *pEntity );// see if pEntity is in monster's view cone
|
||||
virtual BOOL FInViewCone ( Vector *pOrigin );// see if given location is in monster's view cone
|
||||
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
void MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir );
|
||||
virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); }
|
||||
public:
|
||||
inline void SetConditions(int iConditions) { m_afConditions |= iConditions; }
|
||||
inline void ClearConditions(int iConditions) { m_afConditions &= ~iConditions; }
|
||||
inline BOOL HasConditions(int iConditions) { if (m_afConditions & iConditions) return TRUE; return FALSE; }
|
||||
inline BOOL HasAllConditions(int iConditions) { if ((m_afConditions & iConditions) == iConditions) return TRUE; return FALSE; }
|
||||
inline void Remember(int iMemory) { m_afMemory |= iMemory; }
|
||||
inline void Forget(int iMemory) { m_afMemory &= ~iMemory; }
|
||||
inline BOOL HasMemory(int iMemory) { if (m_afMemory & iMemory) return TRUE; return FALSE; }
|
||||
inline BOOL HasAllMemories(int iMemory) { if ((m_afMemory & iMemory) == iMemory) return TRUE; return FALSE; }
|
||||
inline void StopAnimation(void) { pev->framerate = 0; }
|
||||
|
||||
public:
|
||||
Activity m_Activity;
|
||||
Activity m_IdealActivity;
|
||||
int m_LastHitGroup;
|
||||
int m_bitsDamageType;
|
||||
BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED];
|
||||
MONSTERSTATE m_MonsterState;
|
||||
MONSTERSTATE m_IdealMonsterState;
|
||||
int m_afConditions;
|
||||
int m_afMemory;
|
||||
float m_flNextAttack;
|
||||
EHANDLE m_hEnemy;
|
||||
EHANDLE m_hTargetEnt;
|
||||
float m_flFieldOfView;
|
||||
int m_bloodColor;
|
||||
Vector m_HackedGunPos;
|
||||
Vector m_vecEnemyLKP;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
964
dlls/bmodels.cpp
964
dlls/bmodels.cpp
File diff suppressed because it is too large
Load Diff
1174
dlls/buttons.cpp
1174
dlls/buttons.cpp
File diff suppressed because it is too large
Load Diff
1087
dlls/cbase.cpp
1087
dlls/cbase.cpp
File diff suppressed because it is too large
Load Diff
1380
dlls/cbase.h
1380
dlls/cbase.h
File diff suppressed because it is too large
Load Diff
105
dlls/cdll_dll.h
105
dlls/cdll_dll.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,35 +12,88 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// cdll_dll.h
|
||||
|
||||
// this file is included by both the game-dll and the client-dll,
|
||||
|
||||
#ifndef CDLL_DLL_H
|
||||
#define CDLL_DLL_H
|
||||
|
||||
#define MAX_WEAPONS 32 // ???
|
||||
#define MAX_WEAPONS 32
|
||||
#define MAX_WEAPON_SLOTS 5
|
||||
#define MAX_ITEM_TYPES 6
|
||||
#define MAX_ITEMS 4
|
||||
|
||||
#define MAX_WEAPON_SLOTS 5 // hud item selection slots
|
||||
#define MAX_ITEM_TYPES 6 // hud item selection slots
|
||||
#define HIDEHUD_WEAPONS (1<<0)
|
||||
#define HIDEHUD_FLASHLIGHT (1<<1)
|
||||
#define HIDEHUD_ALL (1<<2)
|
||||
#define HIDEHUD_HEALTH (1<<3)
|
||||
#define HIDEHUD_TIMER (1<<4)
|
||||
#define HIDEHUD_MONEY (1<<5)
|
||||
#define HIDEHUD_CROSSHAIR (1<<6)
|
||||
|
||||
#define MAX_ITEMS 5 // hard coded item types
|
||||
#define MAX_AMMO_TYPES 32
|
||||
#define MAX_AMMO_SLOTS 32
|
||||
|
||||
#define HIDEHUD_WEAPONS ( 1<<0 )
|
||||
#define HIDEHUD_FLASHLIGHT ( 1<<1 )
|
||||
#define HIDEHUD_ALL ( 1<<2 )
|
||||
#define HIDEHUD_HEALTH ( 1<<3 )
|
||||
|
||||
#define MAX_AMMO_TYPES 32 // ???
|
||||
#define MAX_AMMO_SLOTS 32 // not really slots
|
||||
|
||||
#define HUD_PRINTNOTIFY 1
|
||||
#define HUD_PRINTCONSOLE 2
|
||||
#define HUD_PRINTTALK 3
|
||||
#define HUD_PRINTCENTER 4
|
||||
#define HUD_PRINTNOTIFY 1
|
||||
#define HUD_PRINTCONSOLE 2
|
||||
#define HUD_PRINTTALK 3
|
||||
#define HUD_PRINTCENTER 4
|
||||
#define HUD_PRINTRADIO 5
|
||||
|
||||
|
||||
#define WEAPON_SUIT 31
|
||||
#define SCORE_STATUS_DEAD (1<<0)
|
||||
#define SCORE_STATUS_BOMB (1<<1)
|
||||
#define SCORE_STATUS_VIP (1<<2)
|
||||
|
||||
#endif
|
||||
#define STATUSICON_HIDE 0
|
||||
#define STATUSICON_SHOW 1
|
||||
#define STATUSICON_FLASH 2
|
||||
|
||||
#define TEAM_UNASSIGNED 0
|
||||
#define TEAM_TERRORIST 1
|
||||
#define TEAM_CT 2
|
||||
#define TEAM_SPECTATOR 3
|
||||
|
||||
#define CLASS_UNASSIGNED 0
|
||||
#define CLASS_URBAN 1
|
||||
#define CLASS_TERROR 2
|
||||
#define CLASS_LEET 3
|
||||
#define CLASS_ARCTIC 4
|
||||
#define CLASS_GSG9 5
|
||||
#define CLASS_GIGN 6
|
||||
#define CLASS_SAS 7
|
||||
#define CLASS_GUERILLA 8
|
||||
#define CLASS_VIP 9
|
||||
#define CLASS_MILITIA 10
|
||||
#define CLASS_SPETSNAZ 11
|
||||
|
||||
#define MENU_KEY_1 (1<<0)
|
||||
#define MENU_KEY_2 (1<<1)
|
||||
#define MENU_KEY_3 (1<<2)
|
||||
#define MENU_KEY_4 (1<<3)
|
||||
#define MENU_KEY_5 (1<<4)
|
||||
#define MENU_KEY_6 (1<<5)
|
||||
#define MENU_KEY_7 (1<<6)
|
||||
#define MENU_KEY_8 (1<<7)
|
||||
#define MENU_KEY_9 (1<<8)
|
||||
#define MENU_KEY_0 (1<<9)
|
||||
|
||||
#define MENU_TEAM 2
|
||||
#define MENU_MAPBRIEFING 4
|
||||
#define MENU_CLASS_T 26
|
||||
#define MENU_CLASS_CT 27
|
||||
#define MENU_BUY 28
|
||||
#define MENU_BUY_PISTOL 29
|
||||
#define MENU_BUY_SHOTGUN 30
|
||||
#define MENU_BUY_RIFLE 31
|
||||
#define MENU_BUY_SUBMACHINEGUN 32
|
||||
#define MENU_BUY_MACHINEGUN 33
|
||||
#define MENU_BUY_ITEM 34
|
||||
|
||||
#define IUSER3_CANSHOOT (1<<0)
|
||||
#define IUSER3_FREEZETIMEOVER (1<<1)
|
||||
#define IUSER3_INBOMBZONE (1<<2)
|
||||
#define IUSER3_HOLDINGSHIELD (1<<3)
|
||||
|
||||
#define ITEMSTATE_HASNIGHTVISION (1<<0)
|
||||
#define ITEMSTATE_HASDEFUSER (1<<1)
|
||||
|
||||
#define WEAPON_SUIT 31
|
||||
#endif
|
5430
dlls/client.cpp
5430
dlls/client.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,51 +15,42 @@
|
|||
#ifndef CLIENT_H
|
||||
#define CLIENT_H
|
||||
|
||||
extern void respawn( entvars_t* pev, BOOL fCopyCorpse );
|
||||
extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] );
|
||||
extern void ClientDisconnect( edict_t *pEntity );
|
||||
extern void ClientKill( edict_t *pEntity );
|
||||
extern void ClientPutInServer( edict_t *pEntity );
|
||||
extern void ClientCommand( edict_t *pEntity );
|
||||
extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer );
|
||||
extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax );
|
||||
extern void ServerDeactivate( void );
|
||||
extern void StartFrame( void );
|
||||
extern void PlayerPostThink( edict_t *pEntity );
|
||||
extern void PlayerPreThink( edict_t *pEntity );
|
||||
extern void ParmsNewLevel( void );
|
||||
extern void ParmsChangeLevel( void );
|
||||
extern "C" EXPORT float g_flTimeLimit;
|
||||
extern "C" EXPORT int CountTeams(void);
|
||||
extern "C" EXPORT int CountTeamPlayers(int iTeam);
|
||||
|
||||
extern void ClientPrecache( void );
|
||||
|
||||
extern const char *GetGameDescription( void );
|
||||
extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust );
|
||||
|
||||
extern void SpectatorConnect ( edict_t *pEntity );
|
||||
extern void SpectatorDisconnect ( edict_t *pEntity );
|
||||
extern void SpectatorThink ( edict_t *pEntity );
|
||||
|
||||
extern void Sys_Error( const char *error_string );
|
||||
|
||||
extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas );
|
||||
extern void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd );
|
||||
extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet );
|
||||
extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs );
|
||||
extern void RegisterEncoders( void );
|
||||
|
||||
extern int GetWeaponData( struct edict_s *player, struct weapon_data_s *info );
|
||||
|
||||
extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed );
|
||||
extern void CmdEnd ( const edict_t *player );
|
||||
|
||||
extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
|
||||
|
||||
extern int GetHullBounds( int hullnumber, float *mins, float *maxs );
|
||||
|
||||
extern void CreateInstancedBaselines ( void );
|
||||
|
||||
extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message );
|
||||
|
||||
extern int AllowLagCompensation( void );
|
||||
|
||||
#endif // CLIENT_H
|
||||
extern void respawn(entvars_t *pev, BOOL fCopyCorpse);
|
||||
extern BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
|
||||
extern void ClientDisconnect(edict_t *pEntity);
|
||||
extern void ClientKill(edict_t *pEntity);
|
||||
extern void ClientPutInServer(edict_t *pEntity);
|
||||
extern void ClientCommand(edict_t *pEntity);
|
||||
extern void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer);
|
||||
extern void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||
extern void ServerDeactivate(void);
|
||||
extern void StartFrame(void);
|
||||
extern void PlayerPostThink(edict_t *pEntity);
|
||||
extern void PlayerPreThink(edict_t *pEntity);
|
||||
extern void ParmsNewLevel(void);
|
||||
extern void ParmsChangeLevel(void);
|
||||
extern void ClientPrecache(void);
|
||||
extern const char *GetGameDescription(void);
|
||||
extern void PlayerCustomization(edict_t *pEntity, customization_t *pCust);
|
||||
extern void SpectatorConnect(edict_t *pEntity);
|
||||
extern void SpectatorDisconnect(edict_t *pEntity);
|
||||
extern void SpectatorThink(edict_t *pEntity);
|
||||
extern void Sys_Error(const char *error_string);
|
||||
extern void SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas);
|
||||
extern void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd);
|
||||
extern int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet);
|
||||
extern void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs);
|
||||
extern void RegisterEncoders(void);
|
||||
extern int GetWeaponData(struct edict_s *player, struct weapon_data_s *info);
|
||||
extern void CmdStart(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed);
|
||||
extern void CmdEnd(const edict_t *player);
|
||||
extern int ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size);
|
||||
extern int GetHullBounds(int hullnumber, float *mins, float *maxs);
|
||||
extern void CreateInstancedBaselines(void);
|
||||
extern int InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message);
|
||||
extern int AllowLagCompensation(void);
|
||||
#endif
|
2155
dlls/combat.cpp
2155
dlls/combat.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,548 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
#define BOLT_AIR_VELOCITY 2000
|
||||
#define BOLT_WATER_VELOCITY 1000
|
||||
|
||||
// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS()
|
||||
//
|
||||
// OVERLOADS SOME ENTVARS:
|
||||
//
|
||||
// speed - the ideal magnitude of my velocity
|
||||
class CCrossbowBolt : public CBaseEntity
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
int Classify ( void );
|
||||
void EXPORT BubbleThink( void );
|
||||
void EXPORT BoltTouch( CBaseEntity *pOther );
|
||||
void EXPORT ExplodeThink( void );
|
||||
|
||||
int m_iTrail;
|
||||
|
||||
public:
|
||||
static CCrossbowBolt *BoltCreate( void );
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt );
|
||||
|
||||
CCrossbowBolt *CCrossbowBolt::BoltCreate( void )
|
||||
{
|
||||
// Create a new entity with CCrossbowBolt private data
|
||||
CCrossbowBolt *pBolt = GetClassPtr( (CCrossbowBolt *)NULL );
|
||||
pBolt->pev->classname = MAKE_STRING("bolt");
|
||||
pBolt->Spawn();
|
||||
|
||||
return pBolt;
|
||||
}
|
||||
|
||||
void CCrossbowBolt::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
pev->gravity = 0.5;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/crossbow_bolt.mdl");
|
||||
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
|
||||
|
||||
SetTouch( BoltTouch );
|
||||
SetThink( BubbleThink );
|
||||
pev->nextthink = gpGlobals->time + 0.2;
|
||||
}
|
||||
|
||||
|
||||
void CCrossbowBolt::Precache( )
|
||||
{
|
||||
PRECACHE_MODEL ("models/crossbow_bolt.mdl");
|
||||
PRECACHE_SOUND("weapons/xbow_hitbod1.wav");
|
||||
PRECACHE_SOUND("weapons/xbow_hitbod2.wav");
|
||||
PRECACHE_SOUND("weapons/xbow_fly1.wav");
|
||||
PRECACHE_SOUND("weapons/xbow_hit1.wav");
|
||||
PRECACHE_SOUND("fvox/beep.wav");
|
||||
m_iTrail = PRECACHE_MODEL("sprites/streak.spr");
|
||||
}
|
||||
|
||||
|
||||
int CCrossbowBolt :: Classify ( void )
|
||||
{
|
||||
return CLASS_NONE;
|
||||
}
|
||||
|
||||
void CCrossbowBolt::BoltTouch( CBaseEntity *pOther )
|
||||
{
|
||||
ResetTouch( );
|
||||
ResetThink( );
|
||||
|
||||
if (pOther->pev->takedamage)
|
||||
{
|
||||
TraceResult tr = UTIL_GetGlobalTrace( );
|
||||
entvars_t *pevOwner;
|
||||
|
||||
pevOwner = VARS( pev->owner );
|
||||
|
||||
// UNDONE: this needs to call TraceAttack instead
|
||||
ClearMultiDamage( );
|
||||
|
||||
if ( pOther->IsPlayer() )
|
||||
{
|
||||
pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowClient, pev->velocity.Normalize(), &tr, DMG_NEVERGIB );
|
||||
}
|
||||
else
|
||||
{
|
||||
pOther->TraceAttack(pevOwner, gSkillData.plrDmgCrossbowMonster, pev->velocity.Normalize(), &tr, DMG_BULLET | DMG_NEVERGIB );
|
||||
}
|
||||
|
||||
ApplyMultiDamage( pev, pevOwner );
|
||||
|
||||
pev->velocity = Vector( 0, 0, 0 );
|
||||
// play body "thwack" sound
|
||||
switch( RANDOM_LONG(0,1) )
|
||||
{
|
||||
case 0:
|
||||
EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM); break;
|
||||
case 1:
|
||||
EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM); break;
|
||||
}
|
||||
|
||||
if ( !g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
Killed( pev, GIB_NEVER );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/xbow_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0,7));
|
||||
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit.
|
||||
|
||||
if ( FClassnameIs( pOther->pev, "worldspawn" ) )
|
||||
{
|
||||
// if what we hit is static architecture, can stay around for a while.
|
||||
Vector vecDir = pev->velocity.Normalize( );
|
||||
UTIL_SetOrigin( pev, pev->origin - vecDir * 12 );
|
||||
pev->angles = UTIL_VecToAngles( vecDir );
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->velocity = Vector( 0, 0, 0 );
|
||||
pev->avelocity.z = 0;
|
||||
pev->angles.z = RANDOM_LONG(0,360);
|
||||
pev->nextthink = gpGlobals->time + 10.0;
|
||||
}
|
||||
|
||||
if (UTIL_PointContents(pev->origin) != CONTENTS_WATER)
|
||||
{
|
||||
UTIL_Sparks( pev->origin );
|
||||
}
|
||||
}
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
SetThink( ExplodeThink );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
void CCrossbowBolt::BubbleThink( void )
|
||||
{
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
if (pev->waterlevel == 0)
|
||||
return;
|
||||
|
||||
UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 );
|
||||
}
|
||||
|
||||
void CCrossbowBolt::ExplodeThink( void )
|
||||
{
|
||||
int iContents = UTIL_PointContents ( pev->origin );
|
||||
int iScale;
|
||||
|
||||
pev->dmg = 40;
|
||||
iScale = 10;
|
||||
|
||||
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
|
||||
WRITE_BYTE( TE_EXPLOSION);
|
||||
WRITE_COORD( pev->origin.x );
|
||||
WRITE_COORD( pev->origin.y );
|
||||
WRITE_COORD( pev->origin.z );
|
||||
if (iContents != CONTENTS_WATER)
|
||||
{
|
||||
WRITE_SHORT( g_sModelIndexFireball );
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE_SHORT( g_sModelIndexWExplosion );
|
||||
}
|
||||
WRITE_BYTE( iScale ); // scale * 10
|
||||
WRITE_BYTE( 15 ); // framerate
|
||||
WRITE_BYTE( TE_EXPLFLAG_NONE );
|
||||
MESSAGE_END();
|
||||
|
||||
entvars_t *pevOwner;
|
||||
|
||||
if ( pev->owner )
|
||||
pevOwner = VARS( pev->owner );
|
||||
else
|
||||
pevOwner = NULL;
|
||||
|
||||
pev->owner = NULL; // can't traceline attack owner if this is set
|
||||
|
||||
::RadiusDamage( pev->origin, pev, pevOwner, pev->dmg, 128, CLASS_NONE, DMG_BLAST | DMG_ALWAYSGIB );
|
||||
|
||||
UTIL_Remove(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
enum crossbow_e {
|
||||
CROSSBOW_IDLE1 = 0, // full
|
||||
CROSSBOW_IDLE2, // empty
|
||||
CROSSBOW_FIDGET1, // full
|
||||
CROSSBOW_FIDGET2, // empty
|
||||
CROSSBOW_FIRE1, // full
|
||||
CROSSBOW_FIRE2, // reload
|
||||
CROSSBOW_FIRE3, // empty
|
||||
CROSSBOW_RELOAD, // from empty
|
||||
CROSSBOW_DRAW1, // full
|
||||
CROSSBOW_DRAW2, // empty
|
||||
CROSSBOW_HOLSTER1, // full
|
||||
CROSSBOW_HOLSTER2, // empty
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_crossbow, CCrossbow );
|
||||
|
||||
void CCrossbow::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_CROSSBOW;
|
||||
SET_MODEL(ENT(pev), "models/w_crossbow.mdl");
|
||||
|
||||
m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
int CCrossbow::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CCrossbow::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_crossbow.mdl");
|
||||
PRECACHE_MODEL("models/v_crossbow.mdl");
|
||||
PRECACHE_MODEL("models/p_crossbow.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/xbow_fire1.wav");
|
||||
PRECACHE_SOUND("weapons/xbow_reload1.wav");
|
||||
|
||||
UTIL_PrecacheOther( "crossbow_bolt" );
|
||||
|
||||
m_usCrossbow = PRECACHE_EVENT( 1, "events/crossbow1.sc" );
|
||||
m_usCrossbow2 = PRECACHE_EVENT( 1, "events/crossbow2.sc" );
|
||||
}
|
||||
|
||||
|
||||
int CCrossbow::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "bolts";
|
||||
p->iMaxAmmo1 = BOLT_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = CROSSBOW_MAX_CLIP;
|
||||
p->iSlot = 2;
|
||||
p->iPosition = 2;
|
||||
p->iId = WEAPON_CROSSBOW;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = CROSSBOW_WEIGHT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
BOOL CCrossbow::Deploy( )
|
||||
{
|
||||
if (m_iClip)
|
||||
return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW1, "bow" );
|
||||
return DefaultDeploy( "models/v_crossbow.mdl", "models/p_crossbow.mdl", CROSSBOW_DRAW2, "bow" );
|
||||
}
|
||||
|
||||
void CCrossbow::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_fInReload = FALSE;// cancel any reload in progress.
|
||||
|
||||
if ( m_fInZoom )
|
||||
{
|
||||
SecondaryAttack( );
|
||||
}
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
if (m_iClip)
|
||||
SendWeaponAnim( CROSSBOW_HOLSTER1 );
|
||||
else
|
||||
SendWeaponAnim( CROSSBOW_HOLSTER2 );
|
||||
}
|
||||
|
||||
void CCrossbow::PrimaryAttack( void )
|
||||
{
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( m_fInZoom && bIsMultiplayer() )
|
||||
#else
|
||||
if ( m_fInZoom && g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
FireSniperBolt();
|
||||
return;
|
||||
}
|
||||
|
||||
FireBolt();
|
||||
}
|
||||
|
||||
// this function only gets called in multiplayer
|
||||
void CCrossbow::FireSniperBolt()
|
||||
{
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
|
||||
|
||||
if (m_iClip == 0)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
TraceResult tr;
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
m_iClip--;
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 );
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
||||
UTIL_MakeVectors( anglesAim );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2;
|
||||
Vector vecDir = gpGlobals->v_forward;
|
||||
|
||||
UTIL_TraceLine(vecSrc, vecSrc + vecDir * 8192, dont_ignore_monsters, m_pPlayer->edict(), &tr);
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if ( tr.pHit->v.takedamage )
|
||||
{
|
||||
ClearMultiDamage( );
|
||||
CBaseEntity::Instance(tr.pHit)->TraceAttack(m_pPlayer->pev, 120, vecDir, &tr, DMG_BULLET | DMG_NEVERGIB );
|
||||
ApplyMultiDamage( pev, m_pPlayer->pev );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CCrossbow::FireBolt()
|
||||
{
|
||||
TraceResult tr;
|
||||
|
||||
if (m_iClip == 0)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
|
||||
m_iClip--;
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usCrossbow, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0 );
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
||||
UTIL_MakeVectors( anglesAim );
|
||||
|
||||
anglesAim.x = -anglesAim.x;
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( ) - gpGlobals->v_up * 2;
|
||||
Vector vecDir = gpGlobals->v_forward;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate();
|
||||
pBolt->pev->origin = vecSrc;
|
||||
pBolt->pev->angles = anglesAim;
|
||||
pBolt->pev->owner = m_pPlayer->edict();
|
||||
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY;
|
||||
pBolt->pev->speed = BOLT_WATER_VELOCITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY;
|
||||
pBolt->pev->speed = BOLT_AIR_VELOCITY;
|
||||
}
|
||||
pBolt->pev->avelocity.z = 10;
|
||||
#endif
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
|
||||
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
|
||||
|
||||
if (m_iClip != 0)
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
|
||||
else
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
|
||||
}
|
||||
|
||||
|
||||
void CCrossbow::SecondaryAttack()
|
||||
{
|
||||
if ( m_pPlayer->pev->fov != 0 )
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
m_fInZoom = 0;
|
||||
}
|
||||
else if ( m_pPlayer->pev->fov != 20 )
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 20;
|
||||
m_fInZoom = 1;
|
||||
}
|
||||
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.1;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
}
|
||||
|
||||
|
||||
void CCrossbow::Reload( void )
|
||||
{
|
||||
if ( m_pPlayer->ammo_bolts <= 0 )
|
||||
return;
|
||||
|
||||
if ( m_pPlayer->pev->fov != 0 )
|
||||
{
|
||||
SecondaryAttack();
|
||||
}
|
||||
|
||||
if ( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) )
|
||||
{
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0,0xF));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCrossbow::WeaponIdle( void )
|
||||
{
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM
|
||||
|
||||
ResetEmptySound( );
|
||||
|
||||
if ( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
|
||||
{
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.75)
|
||||
{
|
||||
if (m_iClip)
|
||||
{
|
||||
SendWeaponAnim( CROSSBOW_IDLE1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendWeaponAnim( CROSSBOW_IDLE2 );
|
||||
}
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_iClip)
|
||||
{
|
||||
SendWeaponAnim( CROSSBOW_FIDGET1 );
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendWeaponAnim( CROSSBOW_FIDGET2 );
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 30.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CCrossbowAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_crossbow_clip.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_crossbow_clip.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_crossbow, CCrossbowAmmo );
|
||||
|
||||
|
||||
|
||||
#endif
|
318
dlls/crowbar.cpp
318
dlls/crowbar.cpp
|
@ -1,318 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
#define CROWBAR_BODYHIT_VOLUME 128
|
||||
#define CROWBAR_WALLHIT_VOLUME 512
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar );
|
||||
|
||||
|
||||
|
||||
enum gauss_e {
|
||||
CROWBAR_IDLE = 0,
|
||||
CROWBAR_DRAW,
|
||||
CROWBAR_HOLSTER,
|
||||
CROWBAR_ATTACK1HIT,
|
||||
CROWBAR_ATTACK1MISS,
|
||||
CROWBAR_ATTACK2MISS,
|
||||
CROWBAR_ATTACK2HIT,
|
||||
CROWBAR_ATTACK3MISS,
|
||||
CROWBAR_ATTACK3HIT
|
||||
};
|
||||
|
||||
|
||||
void CCrowbar::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_CROWBAR;
|
||||
SET_MODEL(ENT(pev), "models/w_crowbar.mdl");
|
||||
m_iClip = -1;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CCrowbar::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_crowbar.mdl");
|
||||
PRECACHE_MODEL("models/w_crowbar.mdl");
|
||||
PRECACHE_MODEL("models/p_crowbar.mdl");
|
||||
PRECACHE_SOUND("weapons/cbar_hit1.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hit2.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod1.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod2.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod3.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_miss1.wav");
|
||||
|
||||
m_usCrowbar = PRECACHE_EVENT ( 1, "events/crowbar.sc" );
|
||||
}
|
||||
|
||||
int CCrowbar::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = NULL;
|
||||
p->iMaxAmmo1 = -1;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 0;
|
||||
p->iId = WEAPON_CROWBAR;
|
||||
p->iWeight = CROWBAR_WEIGHT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CCrowbar::Deploy( )
|
||||
{
|
||||
return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" );
|
||||
}
|
||||
|
||||
void CCrowbar::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
SendWeaponAnim( CROWBAR_HOLSTER );
|
||||
}
|
||||
|
||||
|
||||
void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
|
||||
{
|
||||
int i, j, k;
|
||||
float distance;
|
||||
float *minmaxs[2] = {mins, maxs};
|
||||
TraceResult tmpTrace;
|
||||
Vector vecHullEnd = tr.vecEndPos;
|
||||
Vector vecEnd;
|
||||
|
||||
distance = 1e6f;
|
||||
|
||||
vecHullEnd = vecSrc + ((vecHullEnd - vecSrc)*2);
|
||||
UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace );
|
||||
if ( tmpTrace.flFraction < 1.0 )
|
||||
{
|
||||
tr = tmpTrace;
|
||||
return;
|
||||
}
|
||||
|
||||
for ( i = 0; i < 2; i++ )
|
||||
{
|
||||
for ( j = 0; j < 2; j++ )
|
||||
{
|
||||
for ( k = 0; k < 2; k++ )
|
||||
{
|
||||
vecEnd.x = vecHullEnd.x + minmaxs[i][0];
|
||||
vecEnd.y = vecHullEnd.y + minmaxs[j][1];
|
||||
vecEnd.z = vecHullEnd.z + minmaxs[k][2];
|
||||
|
||||
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace );
|
||||
if ( tmpTrace.flFraction < 1.0 )
|
||||
{
|
||||
float thisDistance = (tmpTrace.vecEndPos - vecSrc).Length();
|
||||
if ( thisDistance < distance )
|
||||
{
|
||||
tr = tmpTrace;
|
||||
distance = thisDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCrowbar::PrimaryAttack()
|
||||
{
|
||||
if (! Swing( 1 ))
|
||||
{
|
||||
SetThink( SwingAgain );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCrowbar::Smack( )
|
||||
{
|
||||
DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR );
|
||||
}
|
||||
|
||||
|
||||
void CCrowbar::SwingAgain( void )
|
||||
{
|
||||
Swing( 0 );
|
||||
}
|
||||
|
||||
|
||||
int CCrowbar::Swing( int fFirst )
|
||||
{
|
||||
int fDidHit = FALSE;
|
||||
|
||||
TraceResult tr;
|
||||
|
||||
UTIL_MakeVectors (m_pPlayer->pev->v_angle);
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
|
||||
|
||||
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if ( tr.flFraction >= 1.0 )
|
||||
{
|
||||
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
|
||||
if ( tr.flFraction < 1.0 )
|
||||
{
|
||||
// Calculate the point of intersection of the line (or hull) and the object we hit
|
||||
// This is and approximation of the "best" intersection
|
||||
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
|
||||
if ( !pHit || pHit->IsBSPModel() )
|
||||
FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
|
||||
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar,
|
||||
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
|
||||
0.0, 0, 0.0 );
|
||||
|
||||
|
||||
if ( tr.flFraction >= 1.0 )
|
||||
{
|
||||
if (fFirst)
|
||||
{
|
||||
// miss
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( ((m_iSwing++) % 2) + 1 )
|
||||
{
|
||||
case 0:
|
||||
SendWeaponAnim( CROWBAR_ATTACK1HIT ); break;
|
||||
case 1:
|
||||
SendWeaponAnim( CROWBAR_ATTACK2HIT ); break;
|
||||
case 2:
|
||||
SendWeaponAnim( CROWBAR_ATTACK3HIT ); break;
|
||||
}
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
// hit
|
||||
fDidHit = TRUE;
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
ClearMultiDamage( );
|
||||
|
||||
if ( (m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// first swing does full damage
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
|
||||
}
|
||||
else
|
||||
{
|
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB );
|
||||
}
|
||||
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
|
||||
|
||||
// play thwack, smack, or dong sound
|
||||
float flVol = 1.0;
|
||||
int fHitWorld = TRUE;
|
||||
|
||||
if (pEntity)
|
||||
{
|
||||
if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
|
||||
{
|
||||
// play thwack or smack sound
|
||||
switch( RANDOM_LONG(0,2) )
|
||||
{
|
||||
case 0:
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break;
|
||||
case 1:
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break;
|
||||
case 2:
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break;
|
||||
}
|
||||
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;
|
||||
if ( !pEntity->IsAlive() )
|
||||
return TRUE;
|
||||
else
|
||||
flVol = 0.1;
|
||||
|
||||
fHitWorld = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// play texture hit sound
|
||||
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
|
||||
|
||||
if (fHitWorld)
|
||||
{
|
||||
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR);
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// override the volume here, cause we don't play texture sounds in multiplayer,
|
||||
// and fvolbar is going to be 0 from the above call.
|
||||
|
||||
fvolbar = 1;
|
||||
}
|
||||
|
||||
// also play crowbar strike
|
||||
switch( RANDOM_LONG(0,1) )
|
||||
{
|
||||
case 0:
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
|
||||
break;
|
||||
case 1:
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
|
||||
break;
|
||||
}
|
||||
|
||||
// delay the decal a bit
|
||||
m_trHit = tr;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME;
|
||||
#endif
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25;
|
||||
|
||||
SetThink( Smack );
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
|
||||
|
||||
|
||||
}
|
||||
return fDidHit;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,15 +12,13 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DECALS_H
|
||||
#define DECALS_H
|
||||
|
||||
//
|
||||
// Dynamic Decals
|
||||
//
|
||||
enum decal_e
|
||||
{
|
||||
DECAL_GUNSHOT1 = 0,
|
||||
{
|
||||
DECAL_GUNSHOT1 = 0,
|
||||
DECAL_GUNSHOT2,
|
||||
DECAL_GUNSHOT3,
|
||||
DECAL_GUNSHOT4,
|
||||
|
@ -33,18 +31,18 @@ enum decal_e
|
|||
DECAL_LAMBDA6,
|
||||
DECAL_SCORCH1,
|
||||
DECAL_SCORCH2,
|
||||
DECAL_BLOOD1,
|
||||
DECAL_BLOOD2,
|
||||
DECAL_BLOOD3,
|
||||
DECAL_BLOOD4,
|
||||
DECAL_BLOOD5,
|
||||
DECAL_BLOOD6,
|
||||
DECAL_YBLOOD1,
|
||||
DECAL_YBLOOD2,
|
||||
DECAL_YBLOOD3,
|
||||
DECAL_YBLOOD4,
|
||||
DECAL_YBLOOD5,
|
||||
DECAL_YBLOOD6,
|
||||
DECAL_BLOOD1,
|
||||
DECAL_BLOOD2,
|
||||
DECAL_BLOOD3,
|
||||
DECAL_BLOOD4,
|
||||
DECAL_BLOOD5,
|
||||
DECAL_BLOOD6,
|
||||
DECAL_YBLOOD1,
|
||||
DECAL_YBLOOD2,
|
||||
DECAL_YBLOOD3,
|
||||
DECAL_YBLOOD4,
|
||||
DECAL_YBLOOD5,
|
||||
DECAL_YBLOOD6,
|
||||
DECAL_GLASSBREAK1,
|
||||
DECAL_GLASSBREAK2,
|
||||
DECAL_GLASSBREAK3,
|
||||
|
@ -55,21 +53,21 @@ enum decal_e
|
|||
DECAL_BIGSHOT5,
|
||||
DECAL_SPIT1,
|
||||
DECAL_SPIT2,
|
||||
DECAL_BPROOF1, // Bulletproof glass decal
|
||||
DECAL_GARGSTOMP1, // Gargantua stomp crack
|
||||
DECAL_SMALLSCORCH1, // Small scorch mark
|
||||
DECAL_SMALLSCORCH2, // Small scorch mark
|
||||
DECAL_SMALLSCORCH3, // Small scorch mark
|
||||
DECAL_MOMMABIRTH, // Big momma birth splatter
|
||||
DECAL_BPROOF1,
|
||||
DECAL_GARGSTOMP1,
|
||||
DECAL_SMALLSCORCH1,
|
||||
DECAL_SMALLSCORCH2,
|
||||
DECAL_SMALLSCORCH3,
|
||||
DECAL_MOMMABIRTH,
|
||||
DECAL_MOMMASPLAT,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
int index;
|
||||
} DLL_DECALLIST;
|
||||
char *name;
|
||||
int index;
|
||||
}
|
||||
DLL_DECALLIST;
|
||||
|
||||
extern DLL_DECALLIST gDecals[];
|
||||
|
||||
#endif // DECALS_H
|
||||
#endif
|
1248
dlls/doors.cpp
1248
dlls/doors.cpp
File diff suppressed because it is too large
Load Diff
35
dlls/doors.h
35
dlls/doors.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,22 +12,19 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef DOORS_H
|
||||
#define DOORS_H
|
||||
|
||||
// doors
|
||||
#define SF_DOOR_ROTATE_Y 0
|
||||
#define SF_DOOR_START_OPEN 1
|
||||
#define SF_DOOR_ROTATE_BACKWARDS 2
|
||||
#define SF_DOOR_PASSABLE 8
|
||||
#define SF_DOOR_ONEWAY 16
|
||||
#define SF_DOOR_NO_AUTO_RETURN 32
|
||||
#define SF_DOOR_ROTATE_Z 64
|
||||
#define SF_DOOR_ROTATE_X 128
|
||||
#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button.
|
||||
#define SF_DOOR_NOMONSTERS 512 // Monster can't open
|
||||
#define SF_DOOR_SILENT 0x80000000
|
||||
|
||||
|
||||
|
||||
#endif //DOORS_H
|
||||
#define SF_DOOR_ROTATE_Y 0
|
||||
#define SF_DOOR_START_OPEN 1
|
||||
#define SF_DOOR_ROTATE_BACKWARDS 2
|
||||
#define SF_DOOR_PASSABLE 8
|
||||
#define SF_DOOR_ONEWAY 16
|
||||
#define SF_DOOR_NO_AUTO_RETURN 32
|
||||
#define SF_DOOR_ROTATE_Z 64
|
||||
#define SF_DOOR_ROTATE_X 128
|
||||
#define SF_DOOR_USE_ONLY 256
|
||||
#define SF_DOOR_NOMONSTERS 512
|
||||
#define SF_DOOR_SILENT 0x80000000
|
||||
#endif
|
2129
dlls/effects.cpp
2129
dlls/effects.cpp
File diff suppressed because it is too large
Load Diff
276
dlls/effects.h
276
dlls/effects.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,44 +15,46 @@
|
|||
#ifndef EFFECTS_H
|
||||
#define EFFECTS_H
|
||||
|
||||
#define SF_BEAM_STARTON 0x0001
|
||||
#define SF_BEAM_TOGGLE 0x0002
|
||||
#define SF_BEAM_RANDOM 0x0004
|
||||
#define SF_BEAM_RING 0x0008
|
||||
#define SF_BEAM_SPARKSTART 0x0010
|
||||
#define SF_BEAM_SPARKEND 0x0020
|
||||
#define SF_BEAM_DECALS 0x0040
|
||||
#define SF_BEAM_SHADEIN 0x0080
|
||||
#define SF_BEAM_SHADEOUT 0x0100
|
||||
#define SF_BEAM_TEMPORARY 0x8000
|
||||
#define SF_BEAM_STARTON 0x0001
|
||||
#define SF_BEAM_TOGGLE 0x0002
|
||||
#define SF_BEAM_RANDOM 0x0004
|
||||
#define SF_BEAM_RING 0x0008
|
||||
#define SF_BEAM_SPARKSTART 0x0010
|
||||
#define SF_BEAM_SPARKEND 0x0020
|
||||
#define SF_BEAM_DECALS 0x0040
|
||||
#define SF_BEAM_SHADEIN 0x0080
|
||||
#define SF_BEAM_SHADEOUT 0x0100
|
||||
#define SF_BEAM_TEMPORARY 0x8000
|
||||
|
||||
#define SF_SPRITE_STARTON 0x0001
|
||||
#define SF_SPRITE_ONCE 0x0002
|
||||
#define SF_SPRITE_TEMPORARY 0x8000
|
||||
#define SF_SPRITE_STARTON 0x0001
|
||||
#define SF_SPRITE_ONCE 0x0002
|
||||
#define SF_SPRITE_TEMPORARY 0x8000
|
||||
|
||||
class CSprite : public CPointEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void Spawn(void);
|
||||
void Restart(void);
|
||||
void Precache(void);
|
||||
|
||||
int ObjectCaps( void )
|
||||
{
|
||||
int flags = 0;
|
||||
if ( pev->spawnflags & SF_SPRITE_TEMPORARY )
|
||||
flags = FCAP_DONT_SAVE;
|
||||
return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
void EXPORT AnimateThink( void );
|
||||
void EXPORT ExpandThink( void );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void Animate( float frames );
|
||||
void Expand( float scaleSpeed, float fadeSpeed );
|
||||
void SpriteInit( const char *pSpriteName, const Vector &origin );
|
||||
|
||||
inline void SetAttachment( edict_t *pEntity, int attachment )
|
||||
int ObjectCaps(void)
|
||||
{
|
||||
if ( pEntity )
|
||||
int flags = 0;
|
||||
|
||||
if (pev->spawnflags & SF_SPRITE_TEMPORARY)
|
||||
flags = FCAP_DONT_SAVE;
|
||||
|
||||
return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
void Animate(float frames);
|
||||
void Expand(float scaleSpeed, float fadeSpeed);
|
||||
void SpriteInit(const char *pSpriteName, const Vector &origin);
|
||||
|
||||
inline void SetAttachment(edict_t *pEntity, int attachment)
|
||||
{
|
||||
if (pEntity)
|
||||
{
|
||||
pev->skin = ENTINDEX(pEntity);
|
||||
pev->body = attachment;
|
||||
|
@ -60,10 +62,13 @@ public:
|
|||
pev->movetype = MOVETYPE_FOLLOW;
|
||||
}
|
||||
}
|
||||
void TurnOff( void );
|
||||
void TurnOn( void );
|
||||
inline float Frames( void ) { return m_maxFrame; }
|
||||
inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx )
|
||||
void TurnOff(void);
|
||||
void TurnOn(void);
|
||||
|
||||
public:
|
||||
inline float Frames(void){ return m_maxFrame; }
|
||||
|
||||
inline void SetTransparency(int rendermode, int r, int g, int b, int a, int fx)
|
||||
{
|
||||
pev->rendermode = rendermode;
|
||||
pev->rendercolor.x = r;
|
||||
|
@ -72,138 +77,143 @@ public:
|
|||
pev->renderamt = a;
|
||||
pev->renderfx = fx;
|
||||
}
|
||||
inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; }
|
||||
inline void SetScale( float scale ) { pev->scale = scale; }
|
||||
inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
|
||||
inline void SetBrightness( int brightness ) { pev->renderamt = brightness; }
|
||||
inline void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; }
|
||||
inline void SetScale(float scale) { pev->scale = scale; }
|
||||
inline void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
|
||||
inline void SetBrightness(int brightness){ pev->renderamt = brightness; }
|
||||
|
||||
inline void AnimateAndDie( float framerate )
|
||||
{
|
||||
inline void AnimateAndDie(float framerate)
|
||||
{
|
||||
SetThink(&CSprite::AnimateUntilDead);
|
||||
pev->framerate = framerate;
|
||||
pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate);
|
||||
pev->nextthink = gpGlobals->time;
|
||||
pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate);
|
||||
pev->nextthink = gpGlobals->time;
|
||||
}
|
||||
|
||||
void EXPORT AnimateUntilDead( void );
|
||||
public:
|
||||
void EXPORT AnimateThink(void);
|
||||
void EXPORT ExpandThink(void);
|
||||
void EXPORT AnimateUntilDead(void);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate );
|
||||
virtual int Save(CSave &save);
|
||||
virtual int Restore(CRestore &restore);
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
static CSprite *SpriteCreate(const char *pSpriteName, const Vector &origin, BOOL animate);
|
||||
|
||||
private:
|
||||
|
||||
float m_lastTime;
|
||||
float m_maxFrame;
|
||||
float m_lastTime;
|
||||
float m_maxFrame;
|
||||
};
|
||||
|
||||
|
||||
class CBeam : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
int ObjectCaps( void )
|
||||
{
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
|
||||
int ObjectCaps(void)
|
||||
{
|
||||
int flags = 0;
|
||||
if ( pev->spawnflags & SF_BEAM_TEMPORARY )
|
||||
|
||||
if (pev->spawnflags & SF_BEAM_TEMPORARY)
|
||||
flags = FCAP_DONT_SAVE;
|
||||
return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
|
||||
return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
|
||||
}
|
||||
|
||||
void EXPORT TriggerTouch( CBaseEntity *pOther );
|
||||
public:
|
||||
inline void SetType(int type) { pev->rendermode = (pev->rendermode & 0xF0) | (type & 0x0F); }
|
||||
inline void SetFlags(int flags) { pev->rendermode = (pev->rendermode & 0x0F) | (flags & 0xF0); }
|
||||
inline void SetStartPos(const Vector &pos) { pev->origin = pos; }
|
||||
inline void SetEndPos(const Vector &pos){ pev->angles = pos; }
|
||||
|
||||
// These functions are here to show the way beams are encoded as entities.
|
||||
// Encoding beams as entities simplifies their management in the client/server architecture
|
||||
inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); }
|
||||
inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); }
|
||||
inline void SetStartPos( const Vector& pos ) { pev->origin = pos; }
|
||||
inline void SetEndPos( const Vector& pos ) { pev->angles = pos; }
|
||||
void SetStartEntity( int entityIndex );
|
||||
void SetEndEntity( int entityIndex );
|
||||
void SetStartEntity(int entityIndex);
|
||||
void SetEndEntity(int entityIndex);
|
||||
|
||||
inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); }
|
||||
inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); }
|
||||
inline void SetStartAttachment(int attachment) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment & 0xF) << 12); }
|
||||
inline void SetEndAttachment(int attachment) { pev->skin = (pev->skin & 0x0FFF) | ((attachment & 0xF) << 12); }
|
||||
inline void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; }
|
||||
inline void SetWidth(int width) { pev->scale = width; }
|
||||
inline void SetNoise(int amplitude) { pev->body = amplitude; }
|
||||
inline void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
|
||||
inline void SetBrightness(int brightness) { pev->renderamt = brightness; }
|
||||
inline void SetFrame(float frame) { pev->frame = frame; }
|
||||
inline void SetScrollRate(int speed){ pev->animtime = speed; }
|
||||
|
||||
inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; }
|
||||
inline void SetWidth( int width ) { pev->scale = width; }
|
||||
inline void SetNoise( int amplitude ) { pev->body = amplitude; }
|
||||
inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
|
||||
inline void SetBrightness( int brightness ) { pev->renderamt = brightness; }
|
||||
inline void SetFrame( float frame ) { pev->frame = frame; }
|
||||
inline void SetScrollRate( int speed ) { pev->animtime = speed; }
|
||||
public:
|
||||
inline int GetType(void) { return pev->rendermode & 0x0F; }
|
||||
inline int GetFlags(void) { return pev->rendermode & 0xF0; }
|
||||
inline int GetStartEntity(void) { return pev->sequence & 0xFFF; }
|
||||
inline int GetEndEntity(void) { return pev->skin & 0xFFF; }
|
||||
const Vector &GetStartPos(void);
|
||||
const Vector &GetEndPos(void);
|
||||
|
||||
inline int GetType( void ) { return pev->rendermode & 0x0F; }
|
||||
inline int GetFlags( void ) { return pev->rendermode & 0xF0; }
|
||||
inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; }
|
||||
inline int GetEndEntity( void ) { return pev->skin & 0xFFF; }
|
||||
public:
|
||||
Vector Center(void){ return (GetStartPos() + GetEndPos()) * 0.5; }
|
||||
|
||||
const Vector &GetStartPos( void );
|
||||
const Vector &GetEndPos( void );
|
||||
public:
|
||||
inline int GetTexture(void) { return pev->modelindex; }
|
||||
inline int GetWidth(void) { return (int)(pev->scale); }
|
||||
inline int GetNoise(void) { return pev->body; }
|
||||
inline int GetBrightness(void) { return (int)(pev->renderamt); }
|
||||
inline int GetFrame(void) { return (int)(pev->frame); }
|
||||
inline int GetScrollRate(void){ return (int)(pev->animtime); }
|
||||
|
||||
Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam
|
||||
public:
|
||||
void EXPORT TriggerTouch(CBaseEntity *pOther);
|
||||
void RelinkBeam(void);
|
||||
void DoSparks(const Vector &start, const Vector &end);
|
||||
CBaseEntity *RandomTargetname(const char *szName);
|
||||
void BeamDamage(TraceResult *ptr);
|
||||
void BeamInit(const char *pSpriteName, int width);
|
||||
void PointsInit(const Vector &start, const Vector &end);
|
||||
void PointEntInit(const Vector &start, int endIndex);
|
||||
void EntsInit(int startIndex, int endIndex);
|
||||
void HoseInit(const Vector &start, const Vector &direction);
|
||||
|
||||
inline int GetTexture( void ) { return pev->modelindex; }
|
||||
inline int GetWidth( void ) { return pev->scale; }
|
||||
inline int GetNoise( void ) { return pev->body; }
|
||||
// inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
|
||||
inline int GetBrightness( void ) { return pev->renderamt; }
|
||||
inline int GetFrame( void ) { return pev->frame; }
|
||||
inline int GetScrollRate( void ) { return pev->animtime; }
|
||||
public:
|
||||
static CBeam *BeamCreate(const char *pSpriteName, int width);
|
||||
|
||||
// Call after you change start/end positions
|
||||
void RelinkBeam( void );
|
||||
// void SetObjectCollisionBox( void );
|
||||
public:
|
||||
inline void LiveForTime(float time){ SetThink(&CBaseEntity::SUB_Remove); pev->nextthink = gpGlobals->time + time; }
|
||||
|
||||
void DoSparks( const Vector &start, const Vector &end );
|
||||
CBaseEntity *RandomTargetname( const char *szName );
|
||||
void BeamDamage( TraceResult *ptr );
|
||||
// Init after BeamCreate()
|
||||
void BeamInit( const char *pSpriteName, int width );
|
||||
void PointsInit( const Vector &start, const Vector &end );
|
||||
void PointEntInit( const Vector &start, int endIndex );
|
||||
void EntsInit( int startIndex, int endIndex );
|
||||
void HoseInit( const Vector &start, const Vector &direction );
|
||||
|
||||
static CBeam *BeamCreate( const char *pSpriteName, int width );
|
||||
|
||||
inline void LiveForTime( float time ) { SetThink(&CBeam::SUB_Remove); pev->nextthink = gpGlobals->time + time; }
|
||||
inline void BeamDamageInstant( TraceResult *ptr, float damage )
|
||||
{
|
||||
pev->dmg = damage;
|
||||
inline void BeamDamageInstant(TraceResult *ptr, float damage)
|
||||
{
|
||||
pev->dmg = damage;
|
||||
pev->dmgtime = gpGlobals->time - 1;
|
||||
BeamDamage(ptr);
|
||||
BeamDamage(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
|
||||
#define SF_MESSAGE_ALL 0x0002 // Send to all clients
|
||||
|
||||
#define SF_MESSAGE_ONCE 0x0001
|
||||
#define SF_MESSAGE_ALL 0x0002
|
||||
|
||||
class CLaser : public CBeam
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
void TurnOn( void );
|
||||
void TurnOff( void );
|
||||
int IsOn( void );
|
||||
public:
|
||||
void TurnOn(void);
|
||||
void TurnOff(void);
|
||||
int IsOn(void);
|
||||
|
||||
void FireAtPoint( TraceResult &point );
|
||||
public:
|
||||
void FireAtPoint(TraceResult &point);
|
||||
void EXPORT StrikeThink(void);
|
||||
|
||||
void EXPORT StrikeThink( void );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
CSprite *m_pSprite;
|
||||
int m_iszSpriteName;
|
||||
Vector m_firePosition;
|
||||
public:
|
||||
CSprite *m_pSprite;
|
||||
int m_iszSpriteName;
|
||||
Vector m_firePosition;
|
||||
};
|
||||
|
||||
#endif //EFFECTS_H
|
||||
#endif
|
568
dlls/egon.cpp
568
dlls/egon.cpp
|
@ -1,568 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "effects.h"
|
||||
#include "customentity.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#define EGON_PRIMARY_VOLUME 450
|
||||
#define EGON_BEAM_SPRITE "sprites/xbeam1.spr"
|
||||
#define EGON_FLARE_SPRITE "sprites/XSpark1.spr"
|
||||
#define EGON_SOUND_OFF "weapons/egon_off1.wav"
|
||||
#define EGON_SOUND_RUN "weapons/egon_run3.wav"
|
||||
#define EGON_SOUND_STARTUP "weapons/egon_windup2.wav"
|
||||
|
||||
#define EGON_SWITCH_NARROW_TIME 0.75 // Time it takes to switch fire modes
|
||||
#define EGON_SWITCH_WIDE_TIME 1.5
|
||||
|
||||
enum egon_e {
|
||||
EGON_IDLE1 = 0,
|
||||
EGON_FIDGET1,
|
||||
EGON_ALTFIREON,
|
||||
EGON_ALTFIRECYCLE,
|
||||
EGON_ALTFIREOFF,
|
||||
EGON_FIRE1,
|
||||
EGON_FIRE2,
|
||||
EGON_FIRE3,
|
||||
EGON_FIRE4,
|
||||
EGON_DRAW,
|
||||
EGON_HOLSTER
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_egon, CEgon );
|
||||
|
||||
void CEgon::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_EGON;
|
||||
SET_MODEL(ENT(pev), "models/w_egon.mdl");
|
||||
|
||||
m_iDefaultAmmo = EGON_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CEgon::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_egon.mdl");
|
||||
PRECACHE_MODEL("models/v_egon.mdl");
|
||||
PRECACHE_MODEL("models/p_egon.mdl");
|
||||
|
||||
PRECACHE_MODEL("models/w_9mmclip.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
PRECACHE_SOUND( EGON_SOUND_OFF );
|
||||
PRECACHE_SOUND( EGON_SOUND_RUN );
|
||||
PRECACHE_SOUND( EGON_SOUND_STARTUP );
|
||||
|
||||
PRECACHE_MODEL( EGON_BEAM_SPRITE );
|
||||
PRECACHE_MODEL( EGON_FLARE_SPRITE );
|
||||
|
||||
PRECACHE_SOUND ("weapons/357_cock1.wav");
|
||||
|
||||
m_usEgonFire = PRECACHE_EVENT ( 1, "events/egon_fire.sc" );
|
||||
m_usEgonStop = PRECACHE_EVENT ( 1, "events/egon_stop.sc" );
|
||||
}
|
||||
|
||||
|
||||
BOOL CEgon::Deploy( void )
|
||||
{
|
||||
m_deployed = FALSE;
|
||||
m_fireState = FIRE_OFF;
|
||||
return DefaultDeploy( "models/v_egon.mdl", "models/p_egon.mdl", EGON_DRAW, "egon" );
|
||||
}
|
||||
|
||||
int CEgon::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CEgon::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
SendWeaponAnim( EGON_HOLSTER );
|
||||
|
||||
EndAttack();
|
||||
}
|
||||
|
||||
int CEgon::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "uranium";
|
||||
p->iMaxAmmo1 = URANIUM_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 3;
|
||||
p->iPosition = 2;
|
||||
p->iId = m_iId = WEAPON_EGON;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = EGON_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define EGON_PULSE_INTERVAL 0.1
|
||||
#define EGON_DISCHARGE_INTERVAL 0.1
|
||||
|
||||
float CEgon::GetPulseInterval( void )
|
||||
{
|
||||
return EGON_PULSE_INTERVAL;
|
||||
}
|
||||
|
||||
float CEgon::GetDischargeInterval( void )
|
||||
{
|
||||
return EGON_DISCHARGE_INTERVAL;
|
||||
}
|
||||
|
||||
BOOL CEgon::HasAmmo( void )
|
||||
{
|
||||
if ( m_pPlayer->ammo_uranium <= 0 )
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CEgon::UseAmmo( int count )
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= count )
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= count;
|
||||
else
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = 0;
|
||||
}
|
||||
|
||||
void CEgon::Attack( void )
|
||||
{
|
||||
// don't fire underwater
|
||||
if ( m_pPlayer->pev->waterlevel == 3 )
|
||||
{
|
||||
|
||||
if ( m_fireState != FIRE_OFF || m_pBeam )
|
||||
{
|
||||
EndAttack();
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayEmptySound( );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
switch( m_fireState )
|
||||
{
|
||||
case FIRE_OFF:
|
||||
{
|
||||
if ( !HasAmmo() )
|
||||
{
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25;
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP.
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 );
|
||||
|
||||
m_shakeTime = 0;
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1;
|
||||
pev->fuser1 = UTIL_WeaponTimeBase() + 2;
|
||||
|
||||
pev->dmgtime = gpGlobals->time + GetPulseInterval();
|
||||
m_fireState = FIRE_CHARGE;
|
||||
}
|
||||
break;
|
||||
|
||||
case FIRE_CHARGE:
|
||||
{
|
||||
Fire( vecSrc, vecAiming );
|
||||
m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME;
|
||||
|
||||
if ( pev->fuser1 <= UTIL_WeaponTimeBase() )
|
||||
{
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 );
|
||||
pev->fuser1 = 1000;
|
||||
}
|
||||
|
||||
if ( !HasAmmo() )
|
||||
{
|
||||
EndAttack();
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CEgon::PrimaryAttack( void )
|
||||
{
|
||||
m_fireMode = FIRE_WIDE;
|
||||
Attack();
|
||||
|
||||
}
|
||||
|
||||
void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir )
|
||||
{
|
||||
Vector vecDest = vecOrigSrc + vecDir * 2048;
|
||||
edict_t *pentIgnore;
|
||||
TraceResult tr;
|
||||
|
||||
pentIgnore = m_pPlayer->edict();
|
||||
Vector tmpSrc = vecOrigSrc + gpGlobals->v_up * -8 + gpGlobals->v_right * 3;
|
||||
|
||||
// ALERT( at_console, "." );
|
||||
|
||||
UTIL_TraceLine( vecOrigSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr );
|
||||
|
||||
if (tr.fAllSolid)
|
||||
return;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
if (pEntity == NULL)
|
||||
return;
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
if ( m_pSprite && pEntity->pev->takedamage )
|
||||
{
|
||||
m_pSprite->pev->effects &= ~EF_NODRAW;
|
||||
}
|
||||
else if ( m_pSprite )
|
||||
{
|
||||
m_pSprite->pev->effects |= EF_NODRAW;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
float timedist;
|
||||
|
||||
switch ( m_fireMode )
|
||||
{
|
||||
case FIRE_NARROW:
|
||||
#ifndef CLIENT_DLL
|
||||
if ( pev->dmgtime < gpGlobals->time )
|
||||
{
|
||||
// Narrow mode only does damage to the entity it hits
|
||||
ClearMultiDamage();
|
||||
if (pEntity->pev->takedamage)
|
||||
{
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM );
|
||||
}
|
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// multiplayer uses 1 ammo every 1/10th second
|
||||
if ( gpGlobals->time >= m_flAmmoUseTime )
|
||||
{
|
||||
UseAmmo( 1 );
|
||||
m_flAmmoUseTime = gpGlobals->time + 0.1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// single player, use 3 ammo/second
|
||||
if ( gpGlobals->time >= m_flAmmoUseTime )
|
||||
{
|
||||
UseAmmo( 1 );
|
||||
m_flAmmoUseTime = gpGlobals->time + 0.166;
|
||||
}
|
||||
}
|
||||
|
||||
pev->dmgtime = gpGlobals->time + GetPulseInterval();
|
||||
}
|
||||
#endif
|
||||
timedist = ( pev->dmgtime - gpGlobals->time ) / GetPulseInterval();
|
||||
break;
|
||||
|
||||
case FIRE_WIDE:
|
||||
#ifndef CLIENT_DLL
|
||||
if ( pev->dmgtime < gpGlobals->time )
|
||||
{
|
||||
// wide mode does damage to the ent, and radius damage
|
||||
ClearMultiDamage();
|
||||
if (pEntity->pev->takedamage)
|
||||
{
|
||||
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonWide, vecDir, &tr, DMG_ENERGYBEAM | DMG_ALWAYSGIB);
|
||||
}
|
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// radius damage a little more potent in multiplayer.
|
||||
::RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, gSkillData.plrDmgEgonWide/4, 128, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB );
|
||||
}
|
||||
|
||||
if ( !m_pPlayer->IsAlive() )
|
||||
return;
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
//multiplayer uses 5 ammo/second
|
||||
if ( gpGlobals->time >= m_flAmmoUseTime )
|
||||
{
|
||||
UseAmmo( 1 );
|
||||
m_flAmmoUseTime = gpGlobals->time + 0.2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wide mode uses 10 charges per second in single player
|
||||
if ( gpGlobals->time >= m_flAmmoUseTime )
|
||||
{
|
||||
UseAmmo( 1 );
|
||||
m_flAmmoUseTime = gpGlobals->time + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
pev->dmgtime = gpGlobals->time + GetDischargeInterval();
|
||||
if ( m_shakeTime < gpGlobals->time )
|
||||
{
|
||||
UTIL_ScreenShake( tr.vecEndPos, 5.0, 150.0, 0.75, 250.0 );
|
||||
m_shakeTime = gpGlobals->time + 1.5;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
timedist = ( pev->dmgtime - gpGlobals->time ) / GetDischargeInterval();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( timedist < 0 )
|
||||
timedist = 0;
|
||||
else if ( timedist > 1 )
|
||||
timedist = 1;
|
||||
timedist = 1-timedist;
|
||||
|
||||
UpdateEffect( tmpSrc, tr.vecEndPos, timedist );
|
||||
}
|
||||
|
||||
|
||||
void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, float timeBlend )
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
if ( !m_pBeam )
|
||||
{
|
||||
CreateEffect();
|
||||
}
|
||||
|
||||
m_pBeam->SetStartPos( endPoint );
|
||||
m_pBeam->SetBrightness( 255 - (timeBlend*180) );
|
||||
m_pBeam->SetWidth( 40 - (timeBlend*20) );
|
||||
|
||||
if ( m_fireMode == FIRE_WIDE )
|
||||
m_pBeam->SetColor( 30 + (25*timeBlend), 30 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) );
|
||||
else
|
||||
m_pBeam->SetColor( 60 + (25*timeBlend), 120 + (30*timeBlend), 64 + 80*fabs(sin(gpGlobals->time*10)) );
|
||||
|
||||
|
||||
UTIL_SetOrigin( m_pSprite->pev, endPoint );
|
||||
m_pSprite->pev->frame += 8 * gpGlobals->frametime;
|
||||
if ( m_pSprite->pev->frame > m_pSprite->Frames() )
|
||||
m_pSprite->pev->frame = 0;
|
||||
|
||||
m_pNoise->SetStartPos( endPoint );
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void CEgon::CreateEffect( void )
|
||||
{
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
DestroyEffect();
|
||||
|
||||
m_pBeam = CBeam::BeamCreate( EGON_BEAM_SPRITE, 40 );
|
||||
m_pBeam->PointEntInit( pev->origin, m_pPlayer->entindex() );
|
||||
m_pBeam->SetFlags( BEAM_FSINE );
|
||||
m_pBeam->SetEndAttachment( 1 );
|
||||
m_pBeam->pev->spawnflags |= SF_BEAM_TEMPORARY; // Flag these to be destroyed on save/restore or level transition
|
||||
m_pBeam->pev->flags |= FL_SKIPLOCALHOST;
|
||||
m_pBeam->pev->owner = m_pPlayer->edict();
|
||||
|
||||
m_pNoise = CBeam::BeamCreate( EGON_BEAM_SPRITE, 55 );
|
||||
m_pNoise->PointEntInit( pev->origin, m_pPlayer->entindex() );
|
||||
m_pNoise->SetScrollRate( 25 );
|
||||
m_pNoise->SetBrightness( 100 );
|
||||
m_pNoise->SetEndAttachment( 1 );
|
||||
m_pNoise->pev->spawnflags |= SF_BEAM_TEMPORARY;
|
||||
m_pNoise->pev->flags |= FL_SKIPLOCALHOST;
|
||||
m_pNoise->pev->owner = m_pPlayer->edict();
|
||||
|
||||
m_pSprite = CSprite::SpriteCreate( EGON_FLARE_SPRITE, pev->origin, FALSE );
|
||||
m_pSprite->pev->scale = 1.0;
|
||||
m_pSprite->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxNoDissipation );
|
||||
m_pSprite->pev->spawnflags |= SF_SPRITE_TEMPORARY;
|
||||
m_pSprite->pev->flags |= FL_SKIPLOCALHOST;
|
||||
m_pSprite->pev->owner = m_pPlayer->edict();
|
||||
|
||||
if ( m_fireMode == FIRE_WIDE )
|
||||
{
|
||||
m_pBeam->SetScrollRate( 50 );
|
||||
m_pBeam->SetNoise( 20 );
|
||||
m_pNoise->SetColor( 50, 50, 255 );
|
||||
m_pNoise->SetNoise( 8 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pBeam->SetScrollRate( 110 );
|
||||
m_pBeam->SetNoise( 5 );
|
||||
m_pNoise->SetColor( 80, 120, 255 );
|
||||
m_pNoise->SetNoise( 2 );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CEgon::DestroyEffect( void )
|
||||
{
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if ( m_pBeam )
|
||||
{
|
||||
UTIL_Remove( m_pBeam );
|
||||
m_pBeam = NULL;
|
||||
}
|
||||
if ( m_pNoise )
|
||||
{
|
||||
UTIL_Remove( m_pNoise );
|
||||
m_pNoise = NULL;
|
||||
}
|
||||
if ( m_pSprite )
|
||||
{
|
||||
if ( m_fireMode == FIRE_WIDE )
|
||||
m_pSprite->Expand( 10, 500 );
|
||||
else
|
||||
UTIL_Remove( m_pSprite );
|
||||
m_pSprite = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CEgon::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
if ( m_flTimeWeaponIdle > gpGlobals->time )
|
||||
return;
|
||||
|
||||
if ( m_fireState != FIRE_OFF )
|
||||
EndAttack();
|
||||
|
||||
int iAnim;
|
||||
|
||||
float flRand = RANDOM_FLOAT(0,1);
|
||||
|
||||
if ( flRand <= 0.5 )
|
||||
{
|
||||
iAnim = EGON_IDLE1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = EGON_FIDGET1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3;
|
||||
}
|
||||
|
||||
SendWeaponAnim( iAnim );
|
||||
m_deployed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CEgon::EndAttack( void )
|
||||
{
|
||||
bool bMakeNoise = false;
|
||||
|
||||
if ( m_fireState != FIRE_OFF ) //Checking the button just in case!.
|
||||
bMakeNoise = true;
|
||||
|
||||
PLAYBACK_EVENT_FULL( FEV_GLOBAL | FEV_RELIABLE, m_pPlayer->edict(), m_usEgonStop, 0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, bMakeNoise, 0, 0, 0 );
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
m_fireState = FIRE_OFF;
|
||||
|
||||
DestroyEffect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CEgonAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_chainammo.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_chainammo.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_egonclip, CEgonAmmo );
|
||||
|
||||
#endif
|
|
@ -72,6 +72,7 @@ extern enginefuncs_t g_engfuncs;
|
|||
#define RANDOM_LONG (*g_engfuncs.pfnRandomLong)
|
||||
#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat)
|
||||
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
|
||||
#define GAME_TIME (*g_engfuncs.pfnTime)
|
||||
|
||||
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) {
|
||||
(*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed);
|
||||
|
@ -158,5 +159,10 @@ inline void *GET_PRIVATE( edict_t *pent )
|
|||
#define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified )
|
||||
|
||||
#define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats )
|
||||
|
||||
#define CREATE_FAKE_CLIENT ( *g_engfuncs.pfnCreateFakeClient )
|
||||
#define GET_USERINFO ( *g_engfuncs.pfnGetInfoKeyBuffer )
|
||||
#define SET_KEY_VALUE ( *g_engfuncs.pfnSetKeyValue )
|
||||
#define SET_CLIENT_KEY_VALUE ( *g_engfuncs.pfnSetClientKeyValue )
|
||||
#define GET_INFO_BUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
||||
#define GET_KEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
|
||||
#endif //ENGINECALLBACK_H
|
||||
|
|
277
dlls/explode.cpp
277
dlls/explode.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,101 +12,101 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== explode.cpp ========================================================
|
||||
|
||||
Explosion-related code
|
||||
|
||||
*/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "decals.h"
|
||||
#include "explode.h"
|
||||
|
||||
// Spark Shower
|
||||
class CShower : public CBaseEntity
|
||||
{
|
||||
void Spawn( void );
|
||||
void Think( void );
|
||||
void Touch( CBaseEntity *pOther );
|
||||
int ObjectCaps( void ) { return FCAP_DONT_SAVE; }
|
||||
public:
|
||||
void Spawn(void);
|
||||
void Think(void);
|
||||
void Touch(CBaseEntity *pOther);
|
||||
int ObjectCaps(void) { return FCAP_DONT_SAVE; }
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( spark_shower, CShower );
|
||||
LINK_ENTITY_TO_CLASS(spark_shower, CShower);
|
||||
|
||||
void CShower::Spawn( void )
|
||||
void CShower::Spawn(void)
|
||||
{
|
||||
pev->velocity = RANDOM_FLOAT( 200, 300 ) * pev->angles;
|
||||
pev->velocity.x += RANDOM_FLOAT(-100.f,100.f);
|
||||
pev->velocity.y += RANDOM_FLOAT(-100.f,100.f);
|
||||
if ( pev->velocity.z >= 0 )
|
||||
pev->velocity = RANDOM_FLOAT(200, 300) * pev->angles;
|
||||
pev->velocity.x += RANDOM_FLOAT(-100, 100);
|
||||
pev->velocity.y += RANDOM_FLOAT(-100, 100);
|
||||
|
||||
if (pev->velocity.z >= 0)
|
||||
pev->velocity.z += 200;
|
||||
else
|
||||
pev->velocity.z -= 200;
|
||||
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
pev->gravity = 0.5;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
pev->solid = SOLID_NOT;
|
||||
SET_MODEL( edict(), "models/grenade.mdl"); // Need a model, just use the grenade, we don't draw it anyway
|
||||
UTIL_SetSize(pev, g_vecZero, g_vecZero );
|
||||
pev->effects |= EF_NODRAW;
|
||||
pev->speed = RANDOM_FLOAT( 0.5, 1.5 );
|
||||
|
||||
SET_MODEL(edict(), "models/grenade.mdl");
|
||||
UTIL_SetSize(pev, g_vecZero, g_vecZero);
|
||||
|
||||
pev->effects |= EF_NODRAW;
|
||||
pev->speed = RANDOM_FLOAT(0.5, 1.5);
|
||||
pev->angles = g_vecZero;
|
||||
}
|
||||
|
||||
|
||||
void CShower::Think( void )
|
||||
void CShower::Think(void)
|
||||
{
|
||||
UTIL_Sparks( pev->origin );
|
||||
|
||||
UTIL_Sparks(pev->origin);
|
||||
pev->speed -= 0.1;
|
||||
if ( pev->speed > 0 )
|
||||
|
||||
if (pev->speed > 0)
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
else
|
||||
UTIL_Remove( this );
|
||||
UTIL_Remove(this);
|
||||
|
||||
pev->flags &= ~FL_ONGROUND;
|
||||
}
|
||||
|
||||
void CShower::Touch( CBaseEntity *pOther )
|
||||
void CShower::Touch(CBaseEntity *pOther)
|
||||
{
|
||||
if ( pev->flags & FL_ONGROUND )
|
||||
if (pev->flags & FL_ONGROUND)
|
||||
pev->velocity = pev->velocity * 0.1;
|
||||
else
|
||||
pev->velocity = pev->velocity * 0.6;
|
||||
|
||||
if ( (pev->velocity.x*pev->velocity.x+pev->velocity.y*pev->velocity.y) < 10.0 )
|
||||
if ((pev->velocity.x * pev->velocity.x + pev->velocity.y * pev->velocity.y) < 10)
|
||||
pev->speed = 0;
|
||||
}
|
||||
|
||||
class CEnvExplosion : public CBaseMonster
|
||||
{
|
||||
public:
|
||||
void Spawn( );
|
||||
void EXPORT Smoke ( void );
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void Spawn(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
void EXPORT Smoke(void);
|
||||
|
||||
int m_iMagnitude;// how large is the fireball? how much damage?
|
||||
int m_spriteScale; // what's the exact fireball sprite scale?
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
public:
|
||||
int m_iMagnitude;
|
||||
int m_spriteScale;
|
||||
};
|
||||
|
||||
TYPEDESCRIPTION CEnvExplosion::m_SaveData[] =
|
||||
TYPEDESCRIPTION CEnvExplosion::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CEnvExplosion, m_iMagnitude, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CEnvExplosion, m_spriteScale, FIELD_INTEGER ),
|
||||
DEFINE_FIELD(CEnvExplosion, m_iMagnitude, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CEnvExplosion, m_spriteScale, FIELD_INTEGER),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CEnvExplosion, CBaseMonster );
|
||||
LINK_ENTITY_TO_CLASS( env_explosion, CEnvExplosion );
|
||||
IMPLEMENT_SAVERESTORE(CEnvExplosion, CBaseMonster);
|
||||
LINK_ENTITY_TO_CLASS(env_explosion, CEnvExplosion);
|
||||
|
||||
void CEnvExplosion::KeyValue( KeyValueData *pkvd )
|
||||
void CEnvExplosion::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "iMagnitude"))
|
||||
{
|
||||
|
@ -114,160 +114,123 @@ void CEnvExplosion::KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseEntity::KeyValue( pkvd );
|
||||
CBaseEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
void CEnvExplosion::Spawn( void )
|
||||
{
|
||||
void CEnvExplosion::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->effects = EF_NODRAW;
|
||||
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
/*
|
||||
if ( m_iMagnitude > 250 )
|
||||
{
|
||||
m_iMagnitude = 250;
|
||||
}
|
||||
*/
|
||||
|
||||
float flSpriteScale;
|
||||
flSpriteScale = ( m_iMagnitude - 50) * 0.6;
|
||||
|
||||
/*
|
||||
if ( flSpriteScale > 50 )
|
||||
{
|
||||
flSpriteScale = 50;
|
||||
}
|
||||
*/
|
||||
if ( flSpriteScale < 10 )
|
||||
{
|
||||
float flSpriteScale = (m_iMagnitude - 50) * 0.6;
|
||||
|
||||
if (flSpriteScale < 10)
|
||||
flSpriteScale = 10;
|
||||
}
|
||||
|
||||
m_spriteScale = (int)flSpriteScale;
|
||||
}
|
||||
|
||||
void CEnvExplosion::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
{
|
||||
void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
pev->model = iStringNull;
|
||||
pev->solid = SOLID_NOT;
|
||||
|
||||
TraceResult tr;
|
||||
Vector vecSpot = pev->origin + Vector(0, 0, 8);
|
||||
UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr);
|
||||
|
||||
pev->model = iStringNull;//invisible
|
||||
pev->solid = SOLID_NOT;// intangible
|
||||
|
||||
Vector vecSpot;// trace starts here!
|
||||
|
||||
vecSpot = pev->origin + Vector ( 0 , 0 , 8 );
|
||||
|
||||
UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr);
|
||||
|
||||
// Pull out of the wall a bit
|
||||
if ( tr.flFraction != 1.0 )
|
||||
{
|
||||
if (tr.flFraction != 1)
|
||||
pev->origin = tr.vecEndPos + (tr.vecPlaneNormal * (m_iMagnitude - 24) * 0.6);
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
pev->origin = pev->origin;
|
||||
}
|
||||
*/
|
||||
|
||||
// draw decal
|
||||
if (! ( pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
|
||||
{
|
||||
if ( RANDOM_FLOAT( 0 , 1 ) < 0.5 )
|
||||
{
|
||||
UTIL_DecalTrace( &tr, DECAL_SCORCH1 );
|
||||
}
|
||||
if (RANDOM_FLOAT(0, 1) < 0.5)
|
||||
UTIL_DecalTrace(&tr, DECAL_SCORCH1);
|
||||
else
|
||||
{
|
||||
UTIL_DecalTrace( &tr, DECAL_SCORCH2 );
|
||||
}
|
||||
UTIL_DecalTrace(&tr, DECAL_SCORCH2);
|
||||
}
|
||||
|
||||
// draw fireball
|
||||
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) )
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_NOFIREBALL))
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
|
||||
WRITE_BYTE( TE_EXPLOSION);
|
||||
WRITE_COORD( pev->origin.x );
|
||||
WRITE_COORD( pev->origin.y );
|
||||
WRITE_COORD( pev->origin.z );
|
||||
WRITE_SHORT( g_sModelIndexFireball );
|
||||
WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
|
||||
WRITE_BYTE( 15 ); // framerate
|
||||
WRITE_BYTE( TE_EXPLFLAG_NONE );
|
||||
MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin);
|
||||
WRITE_BYTE(TE_EXPLOSION);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z);
|
||||
WRITE_SHORT(g_sModelIndexFireball);
|
||||
WRITE_BYTE((BYTE)m_spriteScale);
|
||||
WRITE_BYTE(15);
|
||||
WRITE_BYTE(TE_EXPLFLAG_NONE);
|
||||
MESSAGE_END();
|
||||
}
|
||||
else
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
|
||||
WRITE_BYTE( TE_EXPLOSION);
|
||||
WRITE_COORD( pev->origin.x );
|
||||
WRITE_COORD( pev->origin.y );
|
||||
WRITE_COORD( pev->origin.z );
|
||||
WRITE_SHORT( g_sModelIndexFireball );
|
||||
WRITE_BYTE( 0 ); // no sprite
|
||||
WRITE_BYTE( 15 ); // framerate
|
||||
WRITE_BYTE( TE_EXPLFLAG_NONE );
|
||||
MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin);
|
||||
WRITE_BYTE(TE_EXPLOSION);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z);
|
||||
WRITE_SHORT(g_sModelIndexFireball);
|
||||
WRITE_BYTE(0);
|
||||
WRITE_BYTE(15);
|
||||
WRITE_BYTE(TE_EXPLFLAG_NONE);
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
// do damage
|
||||
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE ) )
|
||||
{
|
||||
RadiusDamage ( pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST );
|
||||
}
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_NODAMAGE))
|
||||
RadiusDamage(pev, pev, m_iMagnitude, CLASS_NONE, DMG_BLAST);
|
||||
|
||||
SetThink( Smoke );
|
||||
SetThink(&CEnvExplosion::Smoke);
|
||||
pev->nextthink = gpGlobals->time + 0.3;
|
||||
|
||||
// draw sparks
|
||||
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS ) )
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSPARKS))
|
||||
{
|
||||
int sparkCount = RANDOM_LONG(0,3);
|
||||
int sparkCount = RANDOM_LONG(0, 3);
|
||||
|
||||
for ( int i = 0; i < sparkCount; i++ )
|
||||
{
|
||||
Create( "spark_shower", pev->origin, tr.vecPlaneNormal, NULL );
|
||||
}
|
||||
for (int i = 0; i < sparkCount; i++)
|
||||
Create("spark_shower", pev->origin, tr.vecPlaneNormal, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void CEnvExplosion::Smoke( void )
|
||||
void CEnvExplosion::Smoke(void)
|
||||
{
|
||||
if ( !( pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE ) )
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_NOSMOKE))
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
|
||||
WRITE_BYTE( TE_SMOKE );
|
||||
WRITE_COORD( pev->origin.x );
|
||||
WRITE_COORD( pev->origin.y );
|
||||
WRITE_COORD( pev->origin.z );
|
||||
WRITE_SHORT( g_sModelIndexSmoke );
|
||||
WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
|
||||
WRITE_BYTE( 12 ); // framerate
|
||||
MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin);
|
||||
WRITE_BYTE(TE_SMOKE);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z);
|
||||
WRITE_SHORT(g_sModelIndexSmoke);
|
||||
WRITE_BYTE((BYTE)m_spriteScale);
|
||||
WRITE_BYTE(12);
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
if ( !(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE) )
|
||||
{
|
||||
UTIL_Remove( this );
|
||||
}
|
||||
|
||||
if (!(pev->spawnflags & SF_ENVEXPLOSION_REPEATABLE))
|
||||
UTIL_Remove(this);
|
||||
}
|
||||
|
||||
|
||||
// HACKHACK -- create one of these and fake a keyvalue to get the right explosion setup
|
||||
void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage )
|
||||
void ExplosionCreate(const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage)
|
||||
{
|
||||
KeyValueData kvd;
|
||||
char buf[128];
|
||||
CBaseEntity *pExplosion = CBaseEntity::Create("env_explosion", center, angles, pOwner);
|
||||
|
||||
CBaseEntity *pExplosion = CBaseEntity::Create( "env_explosion", center, angles, pOwner );
|
||||
sprintf( buf, "%3d", magnitude );
|
||||
char buf[128];
|
||||
sprintf(buf, "%3d", magnitude);
|
||||
|
||||
KeyValueData kvd;
|
||||
kvd.szKeyName = "iMagnitude";
|
||||
kvd.szValue = buf;
|
||||
pExplosion->KeyValue( &kvd );
|
||||
if ( !doDamage )
|
||||
pExplosion->KeyValue(&kvd);
|
||||
|
||||
if (!doDamage)
|
||||
pExplosion->pev->spawnflags |= SF_ENVEXPLOSION_NODAMAGE;
|
||||
|
||||
pExplosion->Spawn();
|
||||
pExplosion->Use( NULL, NULL, USE_TOGGLE, 0 );
|
||||
}
|
||||
pExplosion->Use(NULL, NULL, USE_TOGGLE, 0);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,18 +15,15 @@
|
|||
#ifndef EXPLODE_H
|
||||
#define EXPLODE_H
|
||||
|
||||
#define SF_ENVEXPLOSION_NODAMAGE (1<<0)
|
||||
#define SF_ENVEXPLOSION_REPEATABLE (1<< 1)
|
||||
#define SF_ENVEXPLOSION_NOFIREBALL (1<< 2)
|
||||
#define SF_ENVEXPLOSION_NOSMOKE (1<<3)
|
||||
#define SF_ENVEXPLOSION_NODECAL (1<<4)
|
||||
#define SF_ENVEXPLOSION_NOSPARKS (1<<5)
|
||||
|
||||
#define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage
|
||||
#define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired?
|
||||
#define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball
|
||||
#define SF_ENVEXPLOSION_NOSMOKE ( 1 << 3 ) // don't draw the smoke
|
||||
#define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark
|
||||
#define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark
|
||||
extern DLL_GLOBAL short g_sModelIndexFireball;
|
||||
extern DLL_GLOBAL short g_sModelIndexSmoke;
|
||||
|
||||
extern DLL_GLOBAL short g_sModelIndexFireball;
|
||||
extern DLL_GLOBAL short g_sModelIndexSmoke;
|
||||
|
||||
|
||||
extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage );
|
||||
|
||||
#endif //EXPLODE_H
|
||||
extern void ExplosionCreate(const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage);
|
||||
#endif
|
|
@ -1,6 +1,6 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
* Copyright (c) 1996-2001, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
|
@ -15,7 +15,6 @@
|
|||
#ifndef EXTDLL_H
|
||||
#define EXTDLL_H
|
||||
|
||||
|
||||
//
|
||||
// Global header file for extension DLLs
|
||||
//
|
||||
|
@ -32,6 +31,8 @@
|
|||
#pragma warning(disable : 4514) // unreferenced inline function removed
|
||||
#pragma warning(disable : 4100) // unreferenced formal parameter
|
||||
|
||||
#include "archtypes.h" // DAL
|
||||
|
||||
// Prevent tons of unused windows definitions
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
@ -43,19 +44,15 @@
|
|||
#else // _WIN32
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
typedef unsigned long ULONG;
|
||||
typedef uint32 ULONG;
|
||||
typedef unsigned char BYTE;
|
||||
typedef int BOOL;
|
||||
#define MAX_PATH PATH_MAX
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#include <string.h> // memset
|
||||
|
||||
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
||||
#endif
|
||||
#endif //_WIN32
|
||||
|
||||
// Misc C-runtime library headers
|
||||
|
@ -63,9 +60,16 @@ typedef int BOOL;
|
|||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// Header file containing definition of globalvars_t and entvars_t
|
||||
typedef int func_t; //
|
||||
typedef int string_t; // from engine's pr_comp.h;
|
||||
//typedef unsigned int func_t; //
|
||||
//typedef unsigned int string_t; // from engine's pr_comp.h;
|
||||
typedef float vec_t; // needed before including progdefs.h
|
||||
|
||||
// Vector class
|
||||
|
@ -84,5 +88,4 @@ typedef float vec_t; // needed before including progdefs.h
|
|||
|
||||
// Shared header between the client DLL and the game DLLs
|
||||
#include "cdll_dll.h"
|
||||
|
||||
#endif //EXTDLL_H
|
||||
|
|
1137
dlls/func_break.cpp
1137
dlls/func_break.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,45 +15,44 @@
|
|||
#ifndef FUNC_BREAK_H
|
||||
#define FUNC_BREAK_H
|
||||
|
||||
typedef enum { expRandom, expDirected} Explosions;
|
||||
typedef enum { expRandom, expDirected } Explosions;
|
||||
typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials;
|
||||
|
||||
#define NUM_SHARDS 6 // this many shards spawned when breakable objects break;
|
||||
#define NUM_SHARDS 6
|
||||
|
||||
class CBreakable : public CBaseDelay
|
||||
{
|
||||
public:
|
||||
// basic functions
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void KeyValue( KeyValueData* pkvd);
|
||||
void EXPORT BreakTouch( CBaseEntity *pOther );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void DamageSound( void );
|
||||
void Spawn(void);
|
||||
void Restart(void);
|
||||
void Precache(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
void DamageSound(void);
|
||||
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
|
||||
void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
BOOL IsBreakable(void);
|
||||
BOOL SparkWhenHit(void);
|
||||
int DamageDecal(int bitsDamageType);
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
// breakables use an overridden takedamage
|
||||
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
|
||||
// To spark when hit
|
||||
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
|
||||
public:
|
||||
void EXPORT Die(void);
|
||||
void EXPORT BreakTouch(CBaseEntity *pOther);
|
||||
|
||||
BOOL IsBreakable( void );
|
||||
BOOL SparkWhenHit( void );
|
||||
public:
|
||||
inline BOOL Explodable(void) { return ExplosionMagnitude() > 0; }
|
||||
inline int ExplosionMagnitude(void) { return pev->impulse; }
|
||||
inline void ExplosionSetMagnitude(int magnitude) { pev->impulse = magnitude; }
|
||||
|
||||
int DamageDecal( int bitsDamageType );
|
||||
|
||||
void EXPORT Die( void );
|
||||
virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; }
|
||||
inline int ExplosionMagnitude( void ) { return pev->impulse; }
|
||||
inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; }
|
||||
|
||||
static void MaterialSoundPrecache( Materials precacheMaterial );
|
||||
static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume );
|
||||
static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount );
|
||||
public:
|
||||
static void MaterialSoundPrecache(Materials precacheMaterial);
|
||||
static void MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, float volume);
|
||||
static const char **MaterialSoundList(Materials precacheMaterial, int &soundCount);
|
||||
|
||||
public:
|
||||
static const char *pSoundsWood[];
|
||||
static const char *pSoundsFlesh[];
|
||||
static const char *pSoundsGlass[];
|
||||
|
@ -61,14 +60,17 @@ public:
|
|||
static const char *pSoundsConcrete[];
|
||||
static const char *pSpawnObjects[];
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
Materials m_Material;
|
||||
Explosions m_Explosion;
|
||||
int m_idShard;
|
||||
float m_angle;
|
||||
int m_iszGibModel;
|
||||
int m_iszSpawnObject;
|
||||
public:
|
||||
Materials m_Material;
|
||||
Explosions m_Explosion;
|
||||
int m_idShard;
|
||||
float m_angle;
|
||||
int m_iszGibModel;
|
||||
int m_iszSpawnObject;
|
||||
float m_flSaveHealth;
|
||||
};
|
||||
|
||||
#endif // FUNC_BREAK_H
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
1252
dlls/game.cpp
1252
dlls/game.cpp
File diff suppressed because it is too large
Load Diff
89
dlls/game.h
89
dlls/game.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,34 +12,71 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
extern void GameDLLInit( void );
|
||||
extern void GameDLLInit(void);
|
||||
|
||||
extern cvar_t *g_psv_gravity, *g_psv_aim;
|
||||
extern cvar_t *g_footsteps;
|
||||
extern cvar_t *g_psv_accelerate, *g_psv_friction, *g_psv_stopspeed;
|
||||
|
||||
extern cvar_t displaysoundlist;
|
||||
extern cvar_t displaysoundlist;
|
||||
|
||||
// multiplayer server rules
|
||||
extern cvar_t teamplay;
|
||||
extern cvar_t fraglimit;
|
||||
extern cvar_t timelimit;
|
||||
extern cvar_t friendlyfire;
|
||||
extern cvar_t falldamage;
|
||||
extern cvar_t weaponstay;
|
||||
extern cvar_t forcerespawn;
|
||||
extern cvar_t flashlight;
|
||||
extern cvar_t aimcrosshair;
|
||||
extern cvar_t decalfrequency;
|
||||
extern cvar_t teamlist;
|
||||
extern cvar_t teamoverride;
|
||||
extern cvar_t defaultteam;
|
||||
extern cvar_t allowmonsters;
|
||||
extern cvar_t timelimit;
|
||||
extern cvar_t friendlyfire;
|
||||
extern cvar_t flashlight;
|
||||
|
||||
// Engine Cvars
|
||||
extern cvar_t *g_psv_gravity;
|
||||
extern cvar_t *g_psv_aim;
|
||||
extern cvar_t *g_footsteps;
|
||||
extern cvar_t decalfrequency;
|
||||
|
||||
#endif // GAME_H
|
||||
extern cvar_t allowmonsters;
|
||||
extern cvar_t roundtime;
|
||||
extern cvar_t buytime;
|
||||
extern cvar_t freezetime;
|
||||
extern cvar_t c4timer;
|
||||
|
||||
extern cvar_t ghostfrequency;
|
||||
extern cvar_t autokick;
|
||||
|
||||
extern cvar_t restartround;
|
||||
extern cvar_t sv_restart;
|
||||
|
||||
extern cvar_t limitteams;
|
||||
extern cvar_t autoteambalance;
|
||||
extern cvar_t tkpunish;
|
||||
extern cvar_t hostagepenalty;
|
||||
extern cvar_t mirrordamage;
|
||||
extern cvar_t logmessages;
|
||||
|
||||
#define FORCECAMERA_SPECTATE_ANYONE 0
|
||||
#define FORCECAMERA_SPECTATE_ONLY_TEAM 1
|
||||
#define FORCECAMERA_ONLY_FRIST_PERSON 2
|
||||
|
||||
extern cvar_t forcecamera;
|
||||
extern cvar_t forcechasecam;
|
||||
extern cvar_t mapvoteratio;
|
||||
|
||||
#define LOG_ENEMYATTACK 0x1
|
||||
#define LOG_TEAMMATEATTACK 0x2
|
||||
|
||||
extern cvar_t logdetail;
|
||||
extern cvar_t startmoney;
|
||||
extern cvar_t maxrounds;
|
||||
extern cvar_t fadetoblack;
|
||||
|
||||
#define PLAYERID_EVERYONE 0
|
||||
#define PLAYERID_TEAMONLY 1
|
||||
#define PLAYERID_OFF 2
|
||||
|
||||
extern cvar_t playerid;
|
||||
extern cvar_t winlimit;
|
||||
extern cvar_t allow_spectators;
|
||||
extern cvar_t mp_chattime;
|
||||
extern cvar_t kick_percent;
|
||||
|
||||
extern cvar_t fragsleft;
|
||||
extern cvar_t timeleft;
|
||||
|
||||
extern cvar_t humans_join_team;
|
||||
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,336 +12,104 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// GameRules.cpp
|
||||
//=========================================================
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "gamerules.h"
|
||||
#include "teamplay_gamerules.h"
|
||||
#include "skill.h"
|
||||
#include "game.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "gamerules.h"
|
||||
#include "training_gamerules.h"
|
||||
#include "skill.h"
|
||||
#include "game.h"
|
||||
|
||||
extern edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer );
|
||||
extern edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer);
|
||||
|
||||
DLL_GLOBAL CGameRules* g_pGameRules = NULL;
|
||||
extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
extern int gmsgDeathMsg; // client dll messages
|
||||
DLL_GLOBAL CHalfLifeMultiplay *g_pGameRules = NULL;
|
||||
extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
extern int gmsgDeathMsg;
|
||||
extern int gmsgMOTD;
|
||||
|
||||
int g_teamplay = 0;
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CGameRules::CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry )
|
||||
BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry)
|
||||
{
|
||||
int iAmmoIndex;
|
||||
|
||||
if ( pszAmmoName )
|
||||
if (pszAmmoName)
|
||||
{
|
||||
iAmmoIndex = pPlayer->GetAmmoIndex( pszAmmoName );
|
||||
int iAmmoIndex = pPlayer->GetAmmoIndex(pszAmmoName);
|
||||
|
||||
if ( iAmmoIndex > -1 )
|
||||
if (iAmmoIndex > -1)
|
||||
{
|
||||
if ( pPlayer->AmmoInventory( iAmmoIndex ) < iMaxCarry )
|
||||
{
|
||||
// player has room for more of this type of ammo
|
||||
if (pPlayer->AmmoInventory(iAmmoIndex) < iMaxCarry)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
edict_t *CGameRules :: GetPlayerSpawnSpot( CBasePlayer *pPlayer )
|
||||
edict_t *CGameRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer)
|
||||
{
|
||||
edict_t *pentSpawnSpot = EntSelectSpawnPoint( pPlayer );
|
||||
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
|
||||
|
||||
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0,0,1);
|
||||
pPlayer->pev->v_angle = g_vecZero;
|
||||
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1);
|
||||
pPlayer->pev->v_angle = g_vecZero;
|
||||
pPlayer->pev->velocity = g_vecZero;
|
||||
pPlayer->pev->angles = VARS(pentSpawnSpot)->angles;
|
||||
pPlayer->pev->punchangle = g_vecZero;
|
||||
pPlayer->pev->fixangle = TRUE;
|
||||
|
||||
return pentSpawnSpot;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CGameRules::CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon )
|
||||
BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
||||
{
|
||||
// only living players can have items
|
||||
if ( pPlayer->pev->deadflag != DEAD_NO )
|
||||
if (pPlayer->pev->deadflag != DEAD_NO)
|
||||
return FALSE;
|
||||
|
||||
if ( pWeapon->pszAmmo1() )
|
||||
if (pWeapon->pszAmmo1())
|
||||
{
|
||||
if ( !CanHaveAmmo( pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1() ) )
|
||||
if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1()))
|
||||
{
|
||||
// we can't carry anymore ammo for this gun. We can only
|
||||
// have the gun if we aren't already carrying one of this type
|
||||
if ( pPlayer->HasPlayerItem( pWeapon ) )
|
||||
{
|
||||
if (pPlayer->HasPlayerItem(pWeapon))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// weapon doesn't use ammo, don't take another if you already have it.
|
||||
if ( pPlayer->HasPlayerItem( pWeapon ) )
|
||||
{
|
||||
if (pPlayer->HasPlayerItem(pWeapon))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// note: will fall through to here if GetItemInfo doesn't fill the struct!
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// load the SkillData struct with the proper values based on the skill level.
|
||||
//=========================================================
|
||||
void CGameRules::RefreshSkillData ( void )
|
||||
void CGameRules::RefreshSkillData(void)
|
||||
{
|
||||
int iSkill;
|
||||
int iSkill = (int)CVAR_GET_FLOAT("skill");
|
||||
|
||||
iSkill = (int)CVAR_GET_FLOAT("skill");
|
||||
g_iSkillLevel = iSkill;
|
||||
|
||||
if ( iSkill < 1 )
|
||||
{
|
||||
if (iSkill < 1)
|
||||
iSkill = 1;
|
||||
}
|
||||
else if ( iSkill > 3 )
|
||||
{
|
||||
iSkill = 3;
|
||||
}
|
||||
else if (iSkill > 3)
|
||||
iSkill = 3;
|
||||
|
||||
gSkillData.iSkillLevel = iSkill;
|
||||
ALERT(at_console, "\nGAME SKILL LEVEL:%d\n", iSkill);
|
||||
|
||||
ALERT ( at_console, "\nGAME SKILL LEVEL:%d\n",iSkill );
|
||||
|
||||
//Agrunt
|
||||
gSkillData.agruntHealth = GetSkillCvar( "sk_agrunt_health" );
|
||||
gSkillData.agruntDmgPunch = GetSkillCvar( "sk_agrunt_dmg_punch");
|
||||
|
||||
// Apache
|
||||
gSkillData.apacheHealth = GetSkillCvar( "sk_apache_health");
|
||||
|
||||
// Barney
|
||||
gSkillData.barneyHealth = GetSkillCvar( "sk_barney_health");
|
||||
|
||||
// Big Momma
|
||||
gSkillData.bigmommaHealthFactor = GetSkillCvar( "sk_bigmomma_health_factor" );
|
||||
gSkillData.bigmommaDmgSlash = GetSkillCvar( "sk_bigmomma_dmg_slash" );
|
||||
gSkillData.bigmommaDmgBlast = GetSkillCvar( "sk_bigmomma_dmg_blast" );
|
||||
gSkillData.bigmommaRadiusBlast = GetSkillCvar( "sk_bigmomma_radius_blast" );
|
||||
|
||||
// Bullsquid
|
||||
gSkillData.bullsquidHealth = GetSkillCvar( "sk_bullsquid_health");
|
||||
gSkillData.bullsquidDmgBite = GetSkillCvar( "sk_bullsquid_dmg_bite");
|
||||
gSkillData.bullsquidDmgWhip = GetSkillCvar( "sk_bullsquid_dmg_whip");
|
||||
gSkillData.bullsquidDmgSpit = GetSkillCvar( "sk_bullsquid_dmg_spit");
|
||||
|
||||
// Gargantua
|
||||
gSkillData.gargantuaHealth = GetSkillCvar( "sk_gargantua_health");
|
||||
gSkillData.gargantuaDmgSlash = GetSkillCvar( "sk_gargantua_dmg_slash");
|
||||
gSkillData.gargantuaDmgFire = GetSkillCvar( "sk_gargantua_dmg_fire");
|
||||
gSkillData.gargantuaDmgStomp = GetSkillCvar( "sk_gargantua_dmg_stomp");
|
||||
|
||||
// Hassassin
|
||||
gSkillData.hassassinHealth = GetSkillCvar( "sk_hassassin_health");
|
||||
|
||||
// Headcrab
|
||||
gSkillData.headcrabHealth = GetSkillCvar( "sk_headcrab_health");
|
||||
gSkillData.headcrabDmgBite = GetSkillCvar( "sk_headcrab_dmg_bite");
|
||||
|
||||
// Hgrunt
|
||||
gSkillData.hgruntHealth = GetSkillCvar( "sk_hgrunt_health");
|
||||
gSkillData.hgruntDmgKick = GetSkillCvar( "sk_hgrunt_kick");
|
||||
gSkillData.hgruntShotgunPellets = GetSkillCvar( "sk_hgrunt_pellets");
|
||||
gSkillData.hgruntGrenadeSpeed = GetSkillCvar( "sk_hgrunt_gspeed");
|
||||
|
||||
// Houndeye
|
||||
gSkillData.houndeyeHealth = GetSkillCvar( "sk_houndeye_health");
|
||||
gSkillData.houndeyeDmgBlast = GetSkillCvar( "sk_houndeye_dmg_blast");
|
||||
|
||||
// ISlave
|
||||
gSkillData.slaveHealth = GetSkillCvar( "sk_islave_health");
|
||||
gSkillData.slaveDmgClaw = GetSkillCvar( "sk_islave_dmg_claw");
|
||||
gSkillData.slaveDmgClawrake = GetSkillCvar( "sk_islave_dmg_clawrake");
|
||||
gSkillData.slaveDmgZap = GetSkillCvar( "sk_islave_dmg_zap");
|
||||
|
||||
// Icthyosaur
|
||||
gSkillData.ichthyosaurHealth = GetSkillCvar( "sk_ichthyosaur_health");
|
||||
gSkillData.ichthyosaurDmgShake = GetSkillCvar( "sk_ichthyosaur_shake");
|
||||
|
||||
// Leech
|
||||
gSkillData.leechHealth = GetSkillCvar( "sk_leech_health");
|
||||
|
||||
gSkillData.leechDmgBite = GetSkillCvar( "sk_leech_dmg_bite");
|
||||
|
||||
// Controller
|
||||
gSkillData.controllerHealth = GetSkillCvar( "sk_controller_health");
|
||||
gSkillData.controllerDmgZap = GetSkillCvar( "sk_controller_dmgzap");
|
||||
gSkillData.controllerSpeedBall = GetSkillCvar( "sk_controller_speedball");
|
||||
gSkillData.controllerDmgBall = GetSkillCvar( "sk_controller_dmgball");
|
||||
|
||||
// Nihilanth
|
||||
gSkillData.nihilanthHealth = GetSkillCvar( "sk_nihilanth_health");
|
||||
gSkillData.nihilanthZap = GetSkillCvar( "sk_nihilanth_zap");
|
||||
|
||||
// Scientist
|
||||
gSkillData.scientistHealth = GetSkillCvar( "sk_scientist_health");
|
||||
|
||||
// Snark
|
||||
gSkillData.snarkHealth = GetSkillCvar( "sk_snark_health");
|
||||
gSkillData.snarkDmgBite = GetSkillCvar( "sk_snark_dmg_bite");
|
||||
gSkillData.snarkDmgPop = GetSkillCvar( "sk_snark_dmg_pop");
|
||||
|
||||
// Zombie
|
||||
gSkillData.zombieHealth = GetSkillCvar( "sk_zombie_health");
|
||||
gSkillData.zombieDmgOneSlash = GetSkillCvar( "sk_zombie_dmg_one_slash");
|
||||
gSkillData.zombieDmgBothSlash = GetSkillCvar( "sk_zombie_dmg_both_slash");
|
||||
|
||||
//Turret
|
||||
gSkillData.turretHealth = GetSkillCvar( "sk_turret_health");
|
||||
|
||||
// MiniTurret
|
||||
gSkillData.miniturretHealth = GetSkillCvar( "sk_miniturret_health");
|
||||
|
||||
// Sentry Turret
|
||||
gSkillData.sentryHealth = GetSkillCvar( "sk_sentry_health");
|
||||
|
||||
// PLAYER WEAPONS
|
||||
|
||||
// Crowbar whack
|
||||
gSkillData.plrDmgCrowbar = GetSkillCvar( "sk_plr_crowbar");
|
||||
|
||||
// Glock Round
|
||||
gSkillData.plrDmg9MM = GetSkillCvar( "sk_plr_9mm_bullet");
|
||||
|
||||
// 357 Round
|
||||
gSkillData.plrDmg357 = GetSkillCvar( "sk_plr_357_bullet");
|
||||
|
||||
// MP5 Round
|
||||
gSkillData.plrDmgMP5 = GetSkillCvar( "sk_plr_9mmAR_bullet");
|
||||
|
||||
// M203 grenade
|
||||
gSkillData.plrDmgM203Grenade = GetSkillCvar( "sk_plr_9mmAR_grenade");
|
||||
|
||||
// Shotgun buckshot
|
||||
gSkillData.plrDmgBuckshot = GetSkillCvar( "sk_plr_buckshot");
|
||||
|
||||
// Crossbow
|
||||
gSkillData.plrDmgCrossbowClient = GetSkillCvar( "sk_plr_xbow_bolt_client");
|
||||
gSkillData.plrDmgCrossbowMonster = GetSkillCvar( "sk_plr_xbow_bolt_monster");
|
||||
|
||||
// RPG
|
||||
gSkillData.plrDmgRPG = GetSkillCvar( "sk_plr_rpg");
|
||||
|
||||
// Gauss gun
|
||||
gSkillData.plrDmgGauss = GetSkillCvar( "sk_plr_gauss");
|
||||
|
||||
// Egon Gun
|
||||
gSkillData.plrDmgEgonNarrow = GetSkillCvar( "sk_plr_egon_narrow");
|
||||
gSkillData.plrDmgEgonWide = GetSkillCvar( "sk_plr_egon_wide");
|
||||
|
||||
// Hand Grendade
|
||||
gSkillData.plrDmgHandGrenade = GetSkillCvar( "sk_plr_hand_grenade");
|
||||
|
||||
// Satchel Charge
|
||||
gSkillData.plrDmgSatchel = GetSkillCvar( "sk_plr_satchel");
|
||||
|
||||
// Tripmine
|
||||
gSkillData.plrDmgTripmine = GetSkillCvar( "sk_plr_tripmine");
|
||||
|
||||
// MONSTER WEAPONS
|
||||
gSkillData.monDmg12MM = GetSkillCvar( "sk_12mm_bullet");
|
||||
gSkillData.monDmgMP5 = GetSkillCvar ("sk_9mmAR_bullet" );
|
||||
gSkillData.monDmg9MM = GetSkillCvar( "sk_9mm_bullet");
|
||||
|
||||
// MONSTER HORNET
|
||||
gSkillData.monDmgHornet = GetSkillCvar( "sk_hornet_dmg");
|
||||
|
||||
// PLAYER HORNET
|
||||
// Up to this point, player hornet damage and monster hornet damage were both using
|
||||
// monDmgHornet to determine how much damage to do. In tuning the hivehand, we now need
|
||||
// to separate player damage and monster hivehand damage. Since it's so late in the project, we've
|
||||
// added plrDmgHornet to the SKILLDATA struct, but not to the engine CVar list, so it's inaccesible
|
||||
// via SKILLS.CFG. Any player hivehand tuning must take place in the code. (sjb)
|
||||
gSkillData.plrDmgHornet = 7;
|
||||
|
||||
|
||||
// HEALTH/CHARGE
|
||||
gSkillData.suitchargerCapacity = GetSkillCvar( "sk_suitcharger" );
|
||||
gSkillData.batteryCapacity = GetSkillCvar( "sk_battery" );
|
||||
gSkillData.healthchargerCapacity = GetSkillCvar ( "sk_healthcharger" );
|
||||
gSkillData.healthkitCapacity = GetSkillCvar ( "sk_healthkit" );
|
||||
gSkillData.scientistHeal = GetSkillCvar ( "sk_scientist_heal" );
|
||||
|
||||
// monster damage adj
|
||||
gSkillData.monHead = GetSkillCvar( "sk_monster_head" );
|
||||
gSkillData.monChest = GetSkillCvar( "sk_monster_chest" );
|
||||
gSkillData.monStomach = GetSkillCvar( "sk_monster_stomach" );
|
||||
gSkillData.monLeg = GetSkillCvar( "sk_monster_leg" );
|
||||
gSkillData.monArm = GetSkillCvar( "sk_monster_arm" );
|
||||
|
||||
// player damage adj
|
||||
gSkillData.plrHead = GetSkillCvar( "sk_player_head" );
|
||||
gSkillData.plrChest = GetSkillCvar( "sk_player_chest" );
|
||||
gSkillData.plrStomach = GetSkillCvar( "sk_player_stomach" );
|
||||
gSkillData.plrLeg = GetSkillCvar( "sk_player_leg" );
|
||||
gSkillData.plrArm = GetSkillCvar( "sk_player_arm" );
|
||||
gSkillData.bullsquidDmgBite = 8;
|
||||
gSkillData.bullsquidHealth = 3;
|
||||
gSkillData.bigmommaRadiusBlast = 5;
|
||||
gSkillData.bullsquidDmgWhip = 75;
|
||||
gSkillData.bullsquidDmgSpit = 15;
|
||||
gSkillData.gargantuaHealth = 50;
|
||||
gSkillData.gargantuaDmgSlash = 15;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// instantiate the proper game rules object
|
||||
//=========================================================
|
||||
|
||||
CGameRules *InstallGameRules( void )
|
||||
CGameRules *InstallGameRules(void)
|
||||
{
|
||||
SERVER_COMMAND( "exec game.cfg\n" );
|
||||
SERVER_EXECUTE( );
|
||||
SERVER_COMMAND("exec game.cfg\n");
|
||||
SERVER_EXECUTE();
|
||||
|
||||
if ( !gpGlobals->deathmatch )
|
||||
{
|
||||
// generic half-life
|
||||
g_teamplay = 0;
|
||||
return new CHalfLifeRules;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( teamplay.value > 0 )
|
||||
{
|
||||
// teamplay
|
||||
if (!gpGlobals->deathmatch)
|
||||
return new CHalfLifeTraining;
|
||||
|
||||
g_teamplay = 1;
|
||||
return new CHalfLifeTeamplay;
|
||||
}
|
||||
if ((int)gpGlobals->deathmatch == 1)
|
||||
{
|
||||
// vanilla deathmatch
|
||||
g_teamplay = 0;
|
||||
return new CHalfLifeMultiplay;
|
||||
}
|
||||
else
|
||||
{
|
||||
// vanilla deathmatch??
|
||||
g_teamplay = 0;
|
||||
return new CHalfLifeMultiplay;
|
||||
}
|
||||
}
|
||||
return new CHalfLifeMultiplay;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
785
dlls/gamerules.h
785
dlls/gamerules.h
|
@ -1,390 +1,397 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
class CBasePlayerItem;
|
||||
class CBasePlayer;
|
||||
class CItem;
|
||||
class CBasePlayerAmmo;
|
||||
|
||||
enum
|
||||
{
|
||||
GR_NONE = 0,
|
||||
GR_WEAPON_RESPAWN_YES,
|
||||
GR_WEAPON_RESPAWN_NO,
|
||||
GR_AMMO_RESPAWN_YES,
|
||||
GR_AMMO_RESPAWN_NO,
|
||||
GR_ITEM_RESPAWN_YES,
|
||||
GR_ITEM_RESPAWN_NO,
|
||||
GR_PLR_DROP_GUN_ALL,
|
||||
GR_PLR_DROP_GUN_ACTIVE,
|
||||
GR_PLR_DROP_GUN_NO,
|
||||
GR_PLR_DROP_AMMO_ALL,
|
||||
GR_PLR_DROP_AMMO_ACTIVE,
|
||||
GR_PLR_DROP_AMMO_NO
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GR_NOTTEAMMATE = 0,
|
||||
GR_TEAMMATE,
|
||||
GR_ENEMY,
|
||||
GR_ALLY,
|
||||
GR_NEUTRAL
|
||||
};
|
||||
|
||||
class CGameRules
|
||||
{
|
||||
public:
|
||||
virtual void RefreshSkillData(void);
|
||||
virtual void Think(void) = 0;
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0;
|
||||
virtual BOOL FAllowFlashlight(void) = 0;
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0;
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0;
|
||||
virtual BOOL IsMultiplayer(void) = 0;
|
||||
virtual BOOL IsDeathmatch(void) = 0;
|
||||
virtual BOOL IsTeamplay(void) { return FALSE; }
|
||||
virtual BOOL IsCoOp(void) = 0;
|
||||
virtual const char *GetGameDescription(void) { return "Counter-Strike"; }
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0;
|
||||
virtual void InitHUD(CBasePlayer *pl) = 0;
|
||||
virtual void ClientDisconnected(edict_t *pClient) = 0;
|
||||
virtual void UpdateGameMode(CBasePlayer *pPlayer) {}
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0;
|
||||
virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { return TRUE; }
|
||||
virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) { return TRUE; }
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0;
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer) = 0;
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0;
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0;
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void) { return TRUE; }
|
||||
virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) { return FALSE; }
|
||||
virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) { return FALSE; }
|
||||
virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) {}
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0;
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0;
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0;
|
||||
virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0;
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0;
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0;
|
||||
virtual int ItemShouldRespawn(CItem *pItem) = 0;
|
||||
virtual float FlItemRespawnTime(CItem *pItem) = 0;
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem) = 0;
|
||||
virtual BOOL CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0;
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual float FlHealthChargerRechargeTime(void) = 0;
|
||||
virtual float FlHEVChargerRechargeTime(void) { return 0; }
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0;
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0;
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) = 0;
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget) = 0;
|
||||
virtual int GetTeamIndex(const char *pTeamName) { return -1; }
|
||||
virtual const char *GetIndexedTeamName(int teamIndex) { return ""; }
|
||||
virtual BOOL IsValidTeam(const char *pTeamName) { return TRUE; }
|
||||
virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) {}
|
||||
virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) { return ""; }
|
||||
virtual BOOL PlayTextureSounds(void) { return TRUE; }
|
||||
virtual BOOL FAllowMonsters(void) = 0;
|
||||
virtual void EndMultiplayerGame(void) {}
|
||||
virtual BOOL IsFreezePeriod(void) { return m_bFreezePeriod; }
|
||||
virtual void ServerDeactivate(void) {}
|
||||
virtual void CheckMapConditions(void) {}
|
||||
|
||||
public:
|
||||
BOOL m_bFreezePeriod;
|
||||
BOOL m_bBombDropped;
|
||||
};
|
||||
|
||||
extern char *GetTeam(int teamNo);
|
||||
extern void Broadcast(const char *sentence);
|
||||
extern CGameRules *InstallGameRules(void);
|
||||
|
||||
class CHalfLifeRules : public CGameRules
|
||||
{
|
||||
public:
|
||||
CHalfLifeRules(void);
|
||||
|
||||
public:
|
||||
virtual void Think(void);
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity);
|
||||
virtual BOOL FAllowFlashlight(void) { return TRUE; }
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
virtual BOOL IsMultiplayer(void);
|
||||
virtual BOOL IsDeathmatch(void);
|
||||
virtual BOOL IsCoOp(void);
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
|
||||
virtual void InitHUD(CBasePlayer *pl);
|
||||
virtual void ClientDisconnected(edict_t *pClient);
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer);
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer);
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer);
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void);
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled);
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon);
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual int ItemShouldRespawn(CItem *pItem);
|
||||
virtual float FlItemRespawnTime(CItem *pItem);
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount);
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo);
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlHealthChargerRechargeTime(void);
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer);
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer);
|
||||
virtual BOOL FAllowMonsters(void);
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) { return ""; }
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget);
|
||||
};
|
||||
|
||||
#define MAX_MAPS 100
|
||||
#define MAX_VIPQUEUES 5
|
||||
|
||||
enum
|
||||
{
|
||||
WINSTATUS_CT = 1,
|
||||
WINSTATUS_TERRORIST,
|
||||
WINSTATUS_DRAW
|
||||
};
|
||||
|
||||
#define Target_Bombed 1
|
||||
#define VIP_Escaped 2
|
||||
#define VIP_Assassinated 3
|
||||
#define Terrorists_Escaped 4
|
||||
#define CTs_PreventEscape 5
|
||||
#define Escaping_Terrorists_Neutralized 6
|
||||
#define Bomb_Defused 7
|
||||
#define CTs_Win 8
|
||||
#define Terrorists_Win 9
|
||||
#define Round_Draw 10
|
||||
#define All_Hostages_Rescued 11
|
||||
#define Target_Saved 12
|
||||
#define Hostages_Not_Rescued 13
|
||||
#define Terrorists_Not_Escaped 14
|
||||
#define VIP_Not_Escaped 15
|
||||
#define Game_Commencing 16
|
||||
|
||||
#include "voice_gamemgr.h"
|
||||
|
||||
class CHalfLifeMultiplay : public CGameRules
|
||||
{
|
||||
public:
|
||||
CHalfLifeMultiplay(void);
|
||||
|
||||
public:
|
||||
virtual void Think(void);
|
||||
virtual void RefreshSkillData(void);
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity);
|
||||
virtual BOOL FAllowFlashlight(void);
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
virtual BOOL IsMultiplayer(void);
|
||||
virtual BOOL IsDeathmatch(void);
|
||||
virtual BOOL IsCoOp(void);
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
|
||||
virtual void InitHUD(CBasePlayer *pl);
|
||||
virtual void ClientDisconnected(edict_t *pClient);
|
||||
virtual void UpdateGameMode(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker);
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer);
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer);
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void);
|
||||
virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd);
|
||||
virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd);
|
||||
virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer);
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled);
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon);
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual int ItemShouldRespawn(CItem *pItem);
|
||||
virtual float FlItemRespawnTime(CItem *pItem);
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount);
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo);
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlHealthChargerRechargeTime(void);
|
||||
virtual float FlHEVChargerRechargeTime(void);
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer);
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer);
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) { return ""; }
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget);
|
||||
virtual BOOL PlayTextureSounds(void) { return FALSE; }
|
||||
virtual BOOL FAllowMonsters(void);
|
||||
virtual void EndMultiplayerGame(void) { GoToIntermission(); }
|
||||
virtual void CheckMapConditions(void);
|
||||
virtual void ServerDeactivate(void);
|
||||
virtual void CleanUpMap(void);
|
||||
virtual void RestartRound(void);
|
||||
virtual void CheckWinConditions(void);
|
||||
virtual void RemoveGuns(void);
|
||||
virtual void GiveC4(void);
|
||||
virtual void ChangeLevel(void);
|
||||
virtual void GoToIntermission(void);
|
||||
|
||||
public:
|
||||
void SendMOTDToClient(edict_t *client);
|
||||
void InitializePlayerCounts(int &NumAliveTerrorist, int &NumAliveCT, int &NumDeadTerrorist, int &NumDeadCT);
|
||||
BOOL NeededPlayersCheck(BOOL &bNeededPlayers);
|
||||
BOOL VIPRoundEndCheck(BOOL bNeededPlayers);
|
||||
BOOL PrisonRoundEndCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, BOOL bNeededPlayers);
|
||||
BOOL BombRoundEndCheck(BOOL bNeededPlayers);
|
||||
BOOL TeamExterminationCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, BOOL bNeededPlayers);
|
||||
BOOL HostageRescueRoundEndCheck(BOOL bNeededPlayers);
|
||||
void BalanceTeams(void);
|
||||
BOOL IsThereABomber(void);
|
||||
BOOL IsThereABomb(void);
|
||||
BOOL TeamFull(int team_id);
|
||||
BOOL TeamStacked(int newTeam_id, int curTeam_id);
|
||||
void StackVIPQueue(void);
|
||||
void CheckVIPQueue(void);
|
||||
BOOL IsVIPQueueEmpty(void);
|
||||
BOOL AddToVIPQueue(CBasePlayer *pPlayer);
|
||||
void ResetCurrentVIP(void);
|
||||
void PickNextVIP(void);
|
||||
void CheckFreezePeriodExpired(void);
|
||||
void CheckRoundTimeExpired(void);
|
||||
void CheckLevelInitialized(void);
|
||||
void CheckRestartRound(void);
|
||||
BOOL CheckTimeLimit(void);
|
||||
BOOL CheckMaxRounds(void);
|
||||
BOOL CheckGameOver(void);
|
||||
BOOL CheckWinLimit(void);
|
||||
void CheckAllowSpecator(void);
|
||||
void CheckGameCvar(void);
|
||||
void DisplayMaps(CBasePlayer *pPlayer, int mapId);
|
||||
void ResetAllMapVotes(void);
|
||||
void ProcessMapVote(CBasePlayer *pPlayer, int mapId);
|
||||
void UpdateTeamScores(void);
|
||||
void SwapAllPlayers(void);
|
||||
void TerminateRound(float tmDelay, int iWinStatus);
|
||||
void QueueCareerRoundEndMenu(float tmDelay, int iWinStatus);
|
||||
float TimeRemaining(void) { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundCount; }
|
||||
BOOL HasRoundTimeExpired(void);
|
||||
BOOL IsBombPlanted(void);
|
||||
void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int team);
|
||||
void CareerRestart(void);
|
||||
BOOL IsCareer(void) { return FALSE; }
|
||||
|
||||
public:
|
||||
CVoiceGameMgr m_VoiceGameMgr;
|
||||
float m_fTeamCount;
|
||||
float m_flCheckWinConditions;
|
||||
float m_fRoundCount;
|
||||
int m_iRoundTime;
|
||||
int m_iRoundTimeSecs;
|
||||
int m_iIntroRoundTime;
|
||||
float m_fIntroRoundCount;
|
||||
int m_iAccountTerrorist;
|
||||
int m_iAccountCT;
|
||||
int m_iNumTerrorist;
|
||||
int m_iNumCT;
|
||||
int m_iNumSpawnableTerrorist;
|
||||
int m_iNumSpawnableCT;
|
||||
int m_iSpawnPointCount_Terrorist;
|
||||
int m_iSpawnPointCount_CT;
|
||||
int m_iHostagesRescued;
|
||||
int m_iHostagesTouched;
|
||||
int m_iRoundWinStatus;
|
||||
short m_iNumCTWins;
|
||||
short m_iNumTerroristWins;
|
||||
bool m_bTargetBombed;
|
||||
bool m_bBombDefused;
|
||||
bool m_bMapHasBombTarget;
|
||||
bool m_bMapHasBombZone;
|
||||
bool m_bMapHasBuyZone;
|
||||
bool m_bMapHasRescueZone;
|
||||
bool m_bMapHasEscapeZone;
|
||||
int m_iMapHasVIPSafetyZone;
|
||||
bool m_bMapHasCameras;
|
||||
int m_iC4Timer;
|
||||
int m_iC4Guy;
|
||||
int m_iLoserBonus;
|
||||
int m_iNumConsecutiveCTLoses;
|
||||
int m_iNumConsecutiveTerroristLoses;
|
||||
float m_fMaxIdlePeriod;
|
||||
int m_iLimitTeams;
|
||||
bool m_bLevelInitialized;
|
||||
bool m_bRoundTerminating;
|
||||
bool m_bCompleteReset;
|
||||
float m_flRequiredEscapeRatio;
|
||||
int m_iNumEscapers;
|
||||
int m_iHaveEscaped;
|
||||
bool m_bCTCantBuy;
|
||||
bool m_bTCantBuy;
|
||||
float m_flBombRadius;
|
||||
int m_iConsecutiveVIP;
|
||||
int m_iTotalGunCount;
|
||||
int m_iTotalGrenadeCount;
|
||||
int m_iTotalArmourCount;
|
||||
int m_iUnBalancedRounds;
|
||||
int m_iNumEscapeRounds;
|
||||
int m_iMapVotes[MAX_MAPS];
|
||||
int m_iLastPick;
|
||||
int m_iMaxMapTime;
|
||||
int m_iMaxRounds;
|
||||
int m_iTotalRoundsPlayed;
|
||||
int m_iMaxRoundsWon;
|
||||
int m_iStoredSpectValue;
|
||||
float m_flForceCameraValue;
|
||||
float m_flForceChaseCamValue;
|
||||
float m_flFadeToBlackValue;
|
||||
CBasePlayer *m_pVIP;
|
||||
CBasePlayer *VIPQueue[MAX_VIPQUEUES];
|
||||
float m_flIntermissionEndTime;
|
||||
float m_flIntermissionStartTime;
|
||||
int m_iEndIntermissionButtonHit;
|
||||
float m_tmNextPeriodicThink;
|
||||
bool m_bFirstConnected;
|
||||
bool m_bInCareerGame;
|
||||
float m_fCareerRoundMenuTime;
|
||||
int m_iCareerMatchWins;
|
||||
int m_iRoundWinDifference;
|
||||
float m_fCareerMatchMenuTime;
|
||||
bool m_bSkipSpawn;
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
class CBasePlayerItem;
|
||||
class CBasePlayer;
|
||||
class CItem;
|
||||
class CBasePlayerAmmo;
|
||||
|
||||
#define MAX_MOTD_CHUNK 60
|
||||
#define MAX_MOTD_LENGTH 1536
|
||||
|
||||
#define STARTMONEY_MAX 32000
|
||||
#define STARTMONEY_MIN 800
|
||||
enum
|
||||
{
|
||||
GR_NONE = 0,
|
||||
GR_WEAPON_RESPAWN_YES,
|
||||
GR_WEAPON_RESPAWN_NO,
|
||||
GR_AMMO_RESPAWN_YES,
|
||||
GR_AMMO_RESPAWN_NO,
|
||||
GR_ITEM_RESPAWN_YES,
|
||||
GR_ITEM_RESPAWN_NO,
|
||||
GR_PLR_DROP_GUN_ALL,
|
||||
GR_PLR_DROP_GUN_ACTIVE,
|
||||
GR_PLR_DROP_GUN_NO,
|
||||
GR_PLR_DROP_AMMO_ALL,
|
||||
GR_PLR_DROP_AMMO_ACTIVE,
|
||||
GR_PLR_DROP_AMMO_NO
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GR_NOTTEAMMATE = 0,
|
||||
GR_TEAMMATE,
|
||||
GR_ENEMY,
|
||||
GR_ALLY,
|
||||
GR_NEUTRAL
|
||||
};
|
||||
|
||||
class CGameRules
|
||||
{
|
||||
public:
|
||||
virtual void RefreshSkillData(void);
|
||||
virtual void Think(void) = 0;
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity) = 0;
|
||||
virtual BOOL FAllowFlashlight(void) = 0;
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0;
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon) = 0;
|
||||
virtual BOOL IsMultiplayer(void) = 0;
|
||||
virtual BOOL IsDeathmatch(void) = 0;
|
||||
virtual BOOL IsTeamplay(void) { return FALSE; }
|
||||
virtual BOOL IsCoOp(void) = 0;
|
||||
virtual const char *GetGameDescription(void) { return "Counter-Strike"; }
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) = 0;
|
||||
virtual void InitHUD(CBasePlayer *pl) = 0;
|
||||
virtual void ClientDisconnected(edict_t *pClient) = 0;
|
||||
virtual void UpdateGameMode(CBasePlayer *pPlayer) {}
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer) = 0;
|
||||
virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker) { return TRUE; }
|
||||
virtual BOOL ShouldAutoAim(CBasePlayer *pPlayer, edict_t *target) { return TRUE; }
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer) = 0;
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer) = 0;
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer) = 0;
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer) = 0;
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void) { return TRUE; }
|
||||
virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd) { return FALSE; }
|
||||
virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd) { return FALSE; }
|
||||
virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer) {}
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled) = 0;
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0;
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor) = 0;
|
||||
virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon) = 0;
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon) = 0;
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem) = 0;
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem) = 0;
|
||||
virtual int ItemShouldRespawn(CItem *pItem) = 0;
|
||||
virtual float FlItemRespawnTime(CItem *pItem) = 0;
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem) = 0;
|
||||
virtual BOOL CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount) = 0;
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo) = 0;
|
||||
virtual float FlHealthChargerRechargeTime(void) = 0;
|
||||
virtual float FlHEVChargerRechargeTime(void) { return 0; }
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer) = 0;
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer) = 0;
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) = 0;
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget) = 0;
|
||||
virtual int GetTeamIndex(const char *pTeamName) { return -1; }
|
||||
virtual const char *GetIndexedTeamName(int teamIndex) { return ""; }
|
||||
virtual BOOL IsValidTeam(const char *pTeamName) { return TRUE; }
|
||||
virtual void ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib) {}
|
||||
virtual const char *SetDefaultPlayerTeam(CBasePlayer *pPlayer) { return ""; }
|
||||
virtual BOOL PlayTextureSounds(void) { return TRUE; }
|
||||
virtual BOOL FAllowMonsters(void) = 0;
|
||||
virtual void EndMultiplayerGame(void) {}
|
||||
virtual BOOL IsFreezePeriod(void) { return m_bFreezePeriod; }
|
||||
virtual void ServerDeactivate(void) {}
|
||||
virtual void CheckMapConditions(void) {}
|
||||
|
||||
public:
|
||||
BOOL m_bFreezePeriod;
|
||||
BOOL m_bBombDropped;
|
||||
};
|
||||
|
||||
extern char *GetTeam(int teamNo);
|
||||
extern void Broadcast(const char *sentence);
|
||||
extern CGameRules *InstallGameRules(void);
|
||||
|
||||
class CHalfLifeRules : public CGameRules
|
||||
{
|
||||
public:
|
||||
CHalfLifeRules(void);
|
||||
|
||||
public:
|
||||
virtual void Think(void);
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity);
|
||||
virtual BOOL FAllowFlashlight(void) { return TRUE; }
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
virtual BOOL IsMultiplayer(void);
|
||||
virtual BOOL IsDeathmatch(void);
|
||||
virtual BOOL IsCoOp(void);
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
|
||||
virtual void InitHUD(CBasePlayer *pl);
|
||||
virtual void ClientDisconnected(edict_t *pClient);
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer);
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer);
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer);
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void);
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled);
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon);
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual int ItemShouldRespawn(CItem *pItem);
|
||||
virtual float FlItemRespawnTime(CItem *pItem);
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount);
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo);
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlHealthChargerRechargeTime(void);
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer);
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer);
|
||||
virtual BOOL FAllowMonsters(void);
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) { return ""; }
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget);
|
||||
};
|
||||
|
||||
#define MAX_MAPS 100
|
||||
#define MAX_VIPQUEUES 5
|
||||
|
||||
enum
|
||||
{
|
||||
WINSTATUS_CT = 1,
|
||||
WINSTATUS_TERRORIST,
|
||||
WINSTATUS_DRAW
|
||||
};
|
||||
|
||||
#define Target_Bombed 1
|
||||
#define VIP_Escaped 2
|
||||
#define VIP_Assassinated 3
|
||||
#define Terrorists_Escaped 4
|
||||
#define CTs_PreventEscape 5
|
||||
#define Escaping_Terrorists_Neutralized 6
|
||||
#define Bomb_Defused 7
|
||||
#define CTs_Win 8
|
||||
#define Terrorists_Win 9
|
||||
#define Round_Draw 10
|
||||
#define All_Hostages_Rescued 11
|
||||
#define Target_Saved 12
|
||||
#define Hostages_Not_Rescued 13
|
||||
#define Terrorists_Not_Escaped 14
|
||||
#define VIP_Not_Escaped 15
|
||||
#define Game_Commencing 16
|
||||
|
||||
#include "voice_gamemgr.h"
|
||||
|
||||
class CHalfLifeMultiplay : public CGameRules
|
||||
{
|
||||
public:
|
||||
CHalfLifeMultiplay(void);
|
||||
|
||||
public:
|
||||
virtual void Think(void);
|
||||
virtual void RefreshSkillData(void);
|
||||
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity);
|
||||
virtual BOOL FAllowFlashlight(void);
|
||||
virtual BOOL FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual BOOL GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
virtual BOOL IsMultiplayer(void);
|
||||
virtual BOOL IsDeathmatch(void);
|
||||
virtual BOOL IsCoOp(void);
|
||||
virtual BOOL ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]);
|
||||
virtual void InitHUD(CBasePlayer *pl);
|
||||
virtual void ClientDisconnected(edict_t *pClient);
|
||||
virtual void UpdateGameMode(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerFallDamage(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanTakeDamage(CBasePlayer *pPlayer, CBaseEntity *pAttacker);
|
||||
virtual void PlayerSpawn(CBasePlayer *pPlayer);
|
||||
virtual void PlayerThink(CBasePlayer *pPlayer);
|
||||
virtual BOOL FPlayerCanRespawn(CBasePlayer *pPlayer);
|
||||
virtual float FlPlayerSpawnTime(CBasePlayer *pPlayer);
|
||||
virtual edict_t *GetPlayerSpawnSpot(CBasePlayer *pPlayer);
|
||||
virtual BOOL AllowAutoTargetCrosshair(void);
|
||||
virtual BOOL ClientCommand_DeadOrAlive(CBasePlayer *pPlayer, const char *pcmd);
|
||||
virtual BOOL ClientCommand(CBasePlayer *pPlayer, const char *pcmd);
|
||||
virtual void ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer);
|
||||
virtual int IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled);
|
||||
virtual void PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual void DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor);
|
||||
virtual BOOL CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual void PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||
virtual int WeaponShouldRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponRespawnTime(CBasePlayerItem *pWeapon);
|
||||
virtual float FlWeaponTryRespawn(CBasePlayerItem *pWeapon);
|
||||
virtual Vector VecWeaponRespawnSpot(CBasePlayerItem *pWeapon);
|
||||
virtual BOOL CanHaveItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual void PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem);
|
||||
virtual int ItemShouldRespawn(CItem *pItem);
|
||||
virtual float FlItemRespawnTime(CItem *pItem);
|
||||
virtual Vector VecItemRespawnSpot(CItem *pItem);
|
||||
virtual void PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount);
|
||||
virtual int AmmoShouldRespawn(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo);
|
||||
virtual Vector VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo);
|
||||
virtual float FlHealthChargerRechargeTime(void);
|
||||
virtual float FlHEVChargerRechargeTime(void);
|
||||
virtual int DeadPlayerWeapons(CBasePlayer *pPlayer);
|
||||
virtual int DeadPlayerAmmo(CBasePlayer *pPlayer);
|
||||
virtual const char *GetTeamID(CBaseEntity *pEntity) { return ""; }
|
||||
virtual int PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget);
|
||||
virtual BOOL PlayTextureSounds(void) { return FALSE; }
|
||||
virtual BOOL FAllowMonsters(void);
|
||||
virtual void EndMultiplayerGame(void) { GoToIntermission(); }
|
||||
virtual void CheckMapConditions(void);
|
||||
virtual void ServerDeactivate(void);
|
||||
virtual void CleanUpMap(void);
|
||||
virtual void RestartRound(void);
|
||||
virtual void CheckWinConditions(void);
|
||||
virtual void RemoveGuns(void);
|
||||
virtual void GiveC4(void);
|
||||
virtual void ChangeLevel(void);
|
||||
virtual void GoToIntermission(void);
|
||||
virtual void SetRestartServerAtRoundEnd();
|
||||
virtual BOOL ShouldRestart();
|
||||
public:
|
||||
void SendMOTDToClient(edict_t *client);
|
||||
void InitializePlayerCounts(int &NumAliveTerrorist, int &NumAliveCT, int &NumDeadTerrorist, int &NumDeadCT);
|
||||
BOOL NeededPlayersCheck(BOOL &bNeededPlayers);
|
||||
BOOL VIPRoundEndCheck(BOOL bNeededPlayers);
|
||||
BOOL PrisonRoundEndCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, BOOL bNeededPlayers);
|
||||
BOOL BombRoundEndCheck(BOOL bNeededPlayers);
|
||||
BOOL TeamExterminationCheck(int NumAliveTerrorist, int NumAliveCT, int NumDeadTerrorist, int NumDeadCT, BOOL bNeededPlayers);
|
||||
BOOL HostageRescueRoundEndCheck(BOOL bNeededPlayers);
|
||||
void BalanceTeams(void);
|
||||
BOOL IsThereABomber(void);
|
||||
BOOL IsThereABomb(void);
|
||||
BOOL TeamFull(int team_id);
|
||||
BOOL TeamStacked(int newTeam_id, int curTeam_id);
|
||||
void StackVIPQueue(void);
|
||||
void CheckVIPQueue(void);
|
||||
BOOL IsVIPQueueEmpty(void);
|
||||
BOOL AddToVIPQueue(CBasePlayer *pPlayer);
|
||||
void ResetCurrentVIP(void);
|
||||
void PickNextVIP(void);
|
||||
void CheckFreezePeriodExpired(void);
|
||||
void CheckRoundTimeExpired(void);
|
||||
void CheckLevelInitialized(void);
|
||||
void CheckRestartRound(void);
|
||||
BOOL CheckTimeLimit(void);
|
||||
BOOL CheckMaxRounds(void);
|
||||
BOOL CheckGameOver(void);
|
||||
BOOL CheckWinLimit(void);
|
||||
void CheckAllowSpecator(void);
|
||||
void CheckGameCvar(void);
|
||||
void DisplayMaps(CBasePlayer *pPlayer, int mapId);
|
||||
void ResetAllMapVotes(void);
|
||||
void ProcessMapVote(CBasePlayer *pPlayer, int mapId);
|
||||
void UpdateTeamScores(void);
|
||||
void SwapAllPlayers(void);
|
||||
void TerminateRound(float tmDelay, int iWinStatus);
|
||||
void QueueCareerRoundEndMenu(float tmDelay, int iWinStatus);
|
||||
float TimeRemaining(void) { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundCount; }
|
||||
BOOL HasRoundTimeExpired(void);
|
||||
BOOL IsBombPlanted(void);
|
||||
void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int team);
|
||||
void CareerRestart(void);
|
||||
BOOL IsCareer(void) { return FALSE; }
|
||||
|
||||
public:
|
||||
CVoiceGameMgr m_VoiceGameMgr;
|
||||
float m_fTeamCount;
|
||||
float m_flCheckWinConditions;
|
||||
float m_fRoundCount;
|
||||
int m_iRoundTime;
|
||||
int m_iRoundTimeSecs;
|
||||
int m_iIntroRoundTime;
|
||||
float m_fIntroRoundCount;
|
||||
int m_iAccountTerrorist;
|
||||
int m_iAccountCT;
|
||||
int m_iNumTerrorist;
|
||||
int m_iNumCT;
|
||||
int m_iNumSpawnableTerrorist;
|
||||
int m_iNumSpawnableCT;
|
||||
int m_iSpawnPointCount_Terrorist;
|
||||
int m_iSpawnPointCount_CT;
|
||||
int m_iHostagesRescued;
|
||||
int m_iHostagesTouched;
|
||||
int m_iRoundWinStatus;
|
||||
short m_iNumCTWins;
|
||||
short m_iNumTerroristWins;
|
||||
bool m_bTargetBombed;
|
||||
bool m_bBombDefused;
|
||||
bool m_bMapHasBombTarget;
|
||||
bool m_bMapHasBombZone;
|
||||
bool m_bMapHasBuyZone;
|
||||
bool m_bMapHasRescueZone;
|
||||
bool m_bMapHasEscapeZone;
|
||||
int m_iMapHasVIPSafetyZone;
|
||||
int m_bMapHasCameras;
|
||||
int m_iC4Timer;
|
||||
int m_iC4Guy;
|
||||
int m_iLoserBonus;
|
||||
int m_iNumConsecutiveCTLoses;
|
||||
int m_iNumConsecutiveTerroristLoses;
|
||||
float m_fMaxIdlePeriod;
|
||||
int m_iLimitTeams;
|
||||
bool m_bLevelInitialized;
|
||||
bool m_bRoundTerminating;
|
||||
bool m_bCompleteReset;
|
||||
float m_flRequiredEscapeRatio;
|
||||
int m_iNumEscapers;
|
||||
int m_iHaveEscaped;
|
||||
bool m_bCTCantBuy;
|
||||
bool m_bTCantBuy;
|
||||
float m_flBombRadius;
|
||||
int m_iConsecutiveVIP;
|
||||
int m_iTotalGunCount;
|
||||
int m_iTotalGrenadeCount;
|
||||
int m_iTotalArmourCount;
|
||||
int m_iUnBalancedRounds;
|
||||
int m_iNumEscapeRounds;
|
||||
int m_iMapVotes[MAX_MAPS];
|
||||
int m_iLastPick;
|
||||
int m_iMaxMapTime;
|
||||
int m_iMaxRounds;
|
||||
int m_iTotalRoundsPlayed;
|
||||
int m_iMaxRoundsWon;
|
||||
int m_iStoredSpectValue;
|
||||
float m_flForceCameraValue;
|
||||
float m_flForceChaseCamValue;
|
||||
float m_flFadeToBlackValue;
|
||||
CBasePlayer *m_pVIP;
|
||||
CBasePlayer *VIPQueue[MAX_VIPQUEUES];
|
||||
float m_flIntermissionEndTime;
|
||||
float m_flIntermissionStartTime;
|
||||
int m_iEndIntermissionButtonHit;
|
||||
float m_tmNextPeriodicThink;
|
||||
bool m_bFirstConnected;
|
||||
bool m_bInCareerGame;
|
||||
float m_fCareerRoundMenuTime;
|
||||
int m_iCareerMatchWins;
|
||||
int m_iRoundWinDifference;
|
||||
float m_fCareerMatchMenuTime;
|
||||
bool m_bSkipSpawn;
|
||||
BOOL m_bShouldRestart;
|
||||
};
|
||||
|
||||
extern DLL_GLOBAL CHalfLifeMultiplay *g_pGameRules;
|
623
dlls/gauss.cpp
623
dlls/gauss.cpp
|
@ -1,623 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "soundent.h"
|
||||
#include "shake.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging
|
||||
#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged
|
||||
|
||||
enum gauss_e {
|
||||
GAUSS_IDLE = 0,
|
||||
GAUSS_IDLE2,
|
||||
GAUSS_FIDGET,
|
||||
GAUSS_SPINUP,
|
||||
GAUSS_SPIN,
|
||||
GAUSS_FIRE,
|
||||
GAUSS_FIRE2,
|
||||
GAUSS_HOLSTER,
|
||||
GAUSS_DRAW
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss );
|
||||
|
||||
float CGauss::GetFullChargeTime( void )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
return 1.5;
|
||||
}
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
extern int g_irunninggausspred;
|
||||
#endif
|
||||
|
||||
void CGauss::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_GAUSS;
|
||||
SET_MODEL(ENT(pev), "models/w_gauss.mdl");
|
||||
|
||||
m_iDefaultAmmo = GAUSS_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CGauss::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_gauss.mdl");
|
||||
PRECACHE_MODEL("models/v_gauss.mdl");
|
||||
PRECACHE_MODEL("models/p_gauss.mdl");
|
||||
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
PRECACHE_SOUND("weapons/gauss2.wav");
|
||||
PRECACHE_SOUND("weapons/electro4.wav");
|
||||
PRECACHE_SOUND("weapons/electro5.wav");
|
||||
PRECACHE_SOUND("weapons/electro6.wav");
|
||||
PRECACHE_SOUND("ambience/pulsemachine.wav");
|
||||
|
||||
m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" );
|
||||
m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" );
|
||||
m_iBeam = PRECACHE_MODEL( "sprites/smoke.spr" );
|
||||
|
||||
m_usGaussFire = PRECACHE_EVENT( 1, "events/gauss.sc" );
|
||||
m_usGaussSpin = PRECACHE_EVENT( 1, "events/gaussspin.sc" );
|
||||
}
|
||||
|
||||
int CGauss::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CGauss::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "uranium";
|
||||
p->iMaxAmmo1 = URANIUM_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 3;
|
||||
p->iPosition = 1;
|
||||
p->iId = m_iId = WEAPON_GAUSS;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = GAUSS_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CGauss::Deploy( )
|
||||
{
|
||||
m_pPlayer->m_flPlayAftershock = 0.0;
|
||||
return DefaultDeploy( "models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss" );
|
||||
}
|
||||
|
||||
void CGauss::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
SendWeaponAnim( GAUSS_HOLSTER );
|
||||
m_fInAttack = 0;
|
||||
}
|
||||
|
||||
|
||||
void CGauss::PrimaryAttack()
|
||||
{
|
||||
// don't fire underwater
|
||||
if ( m_pPlayer->pev->waterlevel == 3 )
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] < 2 )
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
|
||||
m_fPrimaryFire = TRUE;
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 2;
|
||||
|
||||
StartFire();
|
||||
m_fInAttack = 0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
void CGauss::SecondaryAttack()
|
||||
{
|
||||
// don't fire underwater
|
||||
if ( m_pPlayer->pev->waterlevel == 3 )
|
||||
{
|
||||
if ( m_fInAttack != 0 )
|
||||
{
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f));
|
||||
SendWeaponAnim( GAUSS_IDLE );
|
||||
m_fInAttack = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayEmptySound( );
|
||||
}
|
||||
|
||||
m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_fInAttack == 0 )
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
|
||||
{
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM);
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
return;
|
||||
}
|
||||
|
||||
m_fPrimaryFire = FALSE;
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin
|
||||
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase();
|
||||
|
||||
// spin up
|
||||
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
|
||||
|
||||
SendWeaponAnim( GAUSS_SPINUP );
|
||||
m_fInAttack = 1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_pPlayer->m_flStartCharge = gpGlobals->time;
|
||||
m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime();
|
||||
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 );
|
||||
|
||||
m_iSoundState = SND_CHANGE_PITCH;
|
||||
}
|
||||
else if (m_fInAttack == 1)
|
||||
{
|
||||
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase())
|
||||
{
|
||||
SendWeaponAnim( GAUSS_SPIN );
|
||||
m_fInAttack = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// during the charging process, eat one bit of ammo every once in a while
|
||||
if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
|
||||
{
|
||||
// out of ammo! force the gun to fire
|
||||
StartFire();
|
||||
m_fInAttack = 0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge )
|
||||
{
|
||||
// don't eat any more ammo after gun is fully charged.
|
||||
m_pPlayer->m_flNextAmmoBurn = 1000;
|
||||
}
|
||||
|
||||
int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100;
|
||||
if ( pitch > 250 )
|
||||
pitch = 250;
|
||||
|
||||
// ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch );
|
||||
|
||||
if ( m_iSoundState == 0 )
|
||||
ALERT( at_console, "sound state %d\n", m_iSoundState );
|
||||
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 );
|
||||
|
||||
m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME;
|
||||
|
||||
// m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1;
|
||||
if ( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 )
|
||||
{
|
||||
// Player charged up too long. Zap him.
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f));
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0,0x3f));
|
||||
|
||||
m_fInAttack = 0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_pPlayer->TakeDamage( VARS(eoNullEntity), VARS(eoNullEntity), 50, DMG_SHOCK );
|
||||
UTIL_ScreenFade( m_pPlayer, Vector(255,128,0), 2, 0.5, 128, FFADE_IN );
|
||||
#endif
|
||||
SendWeaponAnim( GAUSS_IDLE );
|
||||
|
||||
// Player may have been killed and this weapon dropped, don't execute any more code after this!
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// StartFire- since all of this code has to run and then
|
||||
// call Fire(), it was easier at this point to rip it out
|
||||
// of weaponidle() and make its own function then to try to
|
||||
// merge this into Fire(), which has some identical variable names
|
||||
//=========================================================
|
||||
void CGauss::StartFire( void )
|
||||
{
|
||||
float flDamage;
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( ); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8;
|
||||
|
||||
if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() )
|
||||
{
|
||||
flDamage = 200;
|
||||
}
|
||||
else
|
||||
{
|
||||
flDamage = 200 * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() );
|
||||
}
|
||||
|
||||
if ( m_fPrimaryFire )
|
||||
{
|
||||
// fixed damage on primary attack
|
||||
#ifdef CLIENT_DLL
|
||||
flDamage = 20;
|
||||
#else
|
||||
flDamage = gSkillData.plrDmgGauss;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (m_fInAttack != 3)
|
||||
{
|
||||
//ALERT ( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
float flZVel = m_pPlayer->pev->velocity.z;
|
||||
|
||||
if ( !m_fPrimaryFire )
|
||||
{
|
||||
m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5;
|
||||
}
|
||||
|
||||
if ( !g_pGameRules->IsMultiplayer() )
|
||||
|
||||
{
|
||||
// in deathmatch, gauss can pop you up into the air. Not in single play.
|
||||
m_pPlayer->pev->velocity.z = flZVel;
|
||||
}
|
||||
#endif
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
}
|
||||
|
||||
// time until aftershock 'static discharge' sound
|
||||
m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3, 0.8 );
|
||||
|
||||
Fire( vecSrc, vecAiming, flDamage );
|
||||
}
|
||||
|
||||
void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage )
|
||||
{
|
||||
m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME;
|
||||
|
||||
Vector vecSrc = vecOrigSrc;
|
||||
Vector vecDest = vecSrc + vecDir * 8192;
|
||||
edict_t *pentIgnore;
|
||||
TraceResult tr, beam_tr;
|
||||
float flMaxFrac = 1.0;
|
||||
int nTotal = 0;
|
||||
int fHasPunched = 0;
|
||||
int fFirstBeam = 1;
|
||||
int nMaxHits = 10;
|
||||
|
||||
pentIgnore = ENT( m_pPlayer->pev );
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( m_fPrimaryFire == false )
|
||||
g_irunninggausspred = true;
|
||||
#endif
|
||||
|
||||
// The main firing event is sent unreliably so it won't be delayed.
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 );
|
||||
|
||||
// This reliable event is used to stop the spinning sound
|
||||
// It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client
|
||||
// It's sent reliably anyway, which could lead to other delays
|
||||
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 );
|
||||
|
||||
|
||||
/*ALERT( at_console, "%f %f %f\n%f %f %f\n",
|
||||
vecSrc.x, vecSrc.y, vecSrc.z,
|
||||
vecDest.x, vecDest.y, vecDest.z );*/
|
||||
|
||||
|
||||
// ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
while (flDamage > 10 && nMaxHits > 0)
|
||||
{
|
||||
nMaxHits--;
|
||||
|
||||
// ALERT( at_console, "." );
|
||||
UTIL_TraceLine(vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr);
|
||||
|
||||
if (tr.fAllSolid)
|
||||
break;
|
||||
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
if (pEntity == NULL)
|
||||
break;
|
||||
|
||||
if ( fFirstBeam )
|
||||
{
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
fFirstBeam = 0;
|
||||
|
||||
nTotal += 26;
|
||||
}
|
||||
|
||||
if (pEntity->pev->takedamage)
|
||||
{
|
||||
ClearMultiDamage();
|
||||
pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET );
|
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
|
||||
}
|
||||
|
||||
if ( pEntity->ReflectGauss() )
|
||||
{
|
||||
float n;
|
||||
|
||||
pentIgnore = NULL;
|
||||
|
||||
n = -DotProduct(tr.vecPlaneNormal, vecDir);
|
||||
|
||||
if (n < 0.5) // 60 degrees
|
||||
{
|
||||
// ALERT( at_console, "reflect %f\n", n );
|
||||
// reflect
|
||||
Vector r;
|
||||
|
||||
r = 2.0 * tr.vecPlaneNormal * n + vecDir;
|
||||
flMaxFrac = flMaxFrac - tr.flFraction;
|
||||
vecDir = r;
|
||||
vecSrc = tr.vecEndPos + vecDir * 8;
|
||||
vecDest = vecSrc + vecDir * 8192;
|
||||
|
||||
// explode a bit
|
||||
m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST );
|
||||
|
||||
nTotal += 34;
|
||||
|
||||
// lose energy
|
||||
if (n == 0) n = 0.1;
|
||||
flDamage = flDamage * (1 - n);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTotal += 13;
|
||||
|
||||
// limit it to one hole punch
|
||||
if (fHasPunched)
|
||||
break;
|
||||
fHasPunched = 1;
|
||||
|
||||
// try punching through wall if secondary attack (primary is incapable of breaking through)
|
||||
if ( !m_fPrimaryFire )
|
||||
{
|
||||
UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr);
|
||||
if (!beam_tr.fAllSolid)
|
||||
{
|
||||
// trace backwards to find exit point
|
||||
UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr);
|
||||
|
||||
float n = (beam_tr.vecEndPos - tr.vecEndPos).Length( );
|
||||
|
||||
if (n < flDamage)
|
||||
{
|
||||
if (n == 0) n = 1;
|
||||
flDamage -= n;
|
||||
|
||||
// ALERT( at_console, "punch %f\n", n );
|
||||
nTotal += 21;
|
||||
|
||||
// exit blast damage
|
||||
//m_pPlayer->RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, CLASS_NONE, DMG_BLAST );
|
||||
float damage_radius;
|
||||
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
damage_radius = flDamage * 1.75; // Old code == 2.5
|
||||
}
|
||||
else
|
||||
{
|
||||
damage_radius = flDamage * 2.5;
|
||||
}
|
||||
|
||||
::RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, damage_radius, CLASS_NONE, DMG_BLAST );
|
||||
|
||||
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 );
|
||||
|
||||
nTotal += 53;
|
||||
|
||||
vecSrc = beam_tr.vecEndPos + vecDir;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ALERT( at_console, "blocked %f\n", n );
|
||||
flDamage = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ALERT( at_console, "blocked solid\n" );
|
||||
|
||||
flDamage = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vecSrc = tr.vecEndPos + vecDir;
|
||||
pentIgnore = ENT( pEntity->pev );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// ALERT( at_console, "%d bytes\n", nTotal );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CGauss::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
// play aftershock static discharge
|
||||
if ( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time )
|
||||
{
|
||||
switch (RANDOM_LONG(0,3))
|
||||
{
|
||||
case 0: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
|
||||
case 1: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
|
||||
case 2: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
|
||||
case 3: break; // no sound
|
||||
}
|
||||
m_pPlayer->m_flPlayAftershock = 0.0;
|
||||
}
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
if (m_fInAttack != 0)
|
||||
{
|
||||
StartFire();
|
||||
m_fInAttack = 0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int iAnim;
|
||||
float flRand = RANDOM_FLOAT(0, 1);
|
||||
if (flRand <= 0.5)
|
||||
{
|
||||
iAnim = GAUSS_IDLE;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
else if (flRand <= 0.75)
|
||||
{
|
||||
iAnim = GAUSS_IDLE2;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = GAUSS_FIDGET;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3;
|
||||
}
|
||||
|
||||
return;
|
||||
SendWeaponAnim( iAnim );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CGaussAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_gaussammo.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_gaussammo.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_URANIUMBOX_GIVE, "uranium", URANIUM_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo );
|
||||
|
||||
#endif
|
2464
dlls/ggrenade.cpp
2464
dlls/ggrenade.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,28 +12,16 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== globals.cpp ========================================================
|
||||
|
||||
DLL-wide global variable definitions.
|
||||
They're all defined here, for convenient centralization.
|
||||
Source files that need them should "extern ..." declare each
|
||||
variable, to better document what globals they care about.
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "soundent.h"
|
||||
|
||||
DLL_GLOBAL ULONG g_ulFrameCount;
|
||||
DLL_GLOBAL ULONG g_ulModelIndexEyes;
|
||||
DLL_GLOBAL ULONG g_ulModelIndexPlayer;
|
||||
DLL_GLOBAL Vector g_vecAttackDir;
|
||||
DLL_GLOBAL int g_iSkillLevel;
|
||||
DLL_GLOBAL int gDisplayTitle;
|
||||
DLL_GLOBAL BOOL g_fGameOver;
|
||||
DLL_GLOBAL const Vector g_vecZero = Vector(0,0,0);
|
||||
DLL_GLOBAL int g_Language;
|
||||
DLL_GLOBAL ULONG g_ulFrameCount;
|
||||
DLL_GLOBAL ULONG g_ulModelIndexEyes;
|
||||
DLL_GLOBAL Vector g_vecAttackDir;
|
||||
DLL_GLOBAL int g_iSkillLevel;
|
||||
DLL_GLOBAL int gDisplayTitle;
|
||||
DLL_GLOBAL BOOL g_fGameOver;
|
||||
DLL_GLOBAL const Vector g_vecZero = Vector(0, 0, 0);
|
||||
DLL_GLOBAL int g_Language;
|
185
dlls/h_ai.cpp
185
dlls/h_ai.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,188 +12,111 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
h_ai.cpp - halflife specific ai code
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "game.h"
|
||||
|
||||
*/
|
||||
#define NUM_LATERAL_CHECKS 13
|
||||
#define NUM_LATERAL_LOS_CHECKS 6
|
||||
|
||||
DLL_GLOBAL BOOL g_fDrawLines = FALSE;
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "game.h"
|
||||
|
||||
#define NUM_LATERAL_CHECKS 13 // how many checks are made on each side of a monster looking for lateral cover
|
||||
#define NUM_LATERAL_LOS_CHECKS 6 // how many checks are made on each side of a monster looking for lateral cover
|
||||
|
||||
//float flRandom = RANDOM_FLOAT(0,1);
|
||||
|
||||
DLL_GLOBAL BOOL g_fDrawLines = FALSE;
|
||||
|
||||
//=========================================================
|
||||
//
|
||||
// AI UTILITY FUNCTIONS
|
||||
//
|
||||
// !!!UNDONE - move CBaseMonster functions to monsters.cpp
|
||||
//=========================================================
|
||||
|
||||
//=========================================================
|
||||
// FBoxVisible - a more accurate ( and slower ) version
|
||||
// of FVisible.
|
||||
//
|
||||
// !!!UNDONE - make this CBaseMonster?
|
||||
//=========================================================
|
||||
BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize )
|
||||
BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize)
|
||||
{
|
||||
// don't look through water
|
||||
if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3)
|
||||
|| (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0))
|
||||
if ((pevLooker->waterlevel != 3 && pevTarget->waterlevel == 3) || (pevLooker->waterlevel == 3 && pevTarget->waterlevel == 0))
|
||||
return FALSE;
|
||||
|
||||
TraceResult tr;
|
||||
Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs;//look through the monster's 'eyes'
|
||||
Vector vecLookerOrigin = pevLooker->origin + pevLooker->view_ofs;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Vector vecTarget = pevTarget->origin;
|
||||
vecTarget.x += RANDOM_FLOAT( pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize);
|
||||
vecTarget.y += RANDOM_FLOAT( pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize);
|
||||
vecTarget.z += RANDOM_FLOAT( pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize);
|
||||
vecTarget.x += RANDOM_FLOAT(pevTarget->mins.x + flSize, pevTarget->maxs.x - flSize);
|
||||
vecTarget.y += RANDOM_FLOAT(pevTarget->mins.y + flSize, pevTarget->maxs.y - flSize);
|
||||
vecTarget.z += RANDOM_FLOAT(pevTarget->mins.z + flSize, pevTarget->maxs.z - flSize);
|
||||
|
||||
UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker)/*pentIgnore*/, &tr);
|
||||
|
||||
if (tr.flFraction == 1.0)
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine(vecLookerOrigin, vecTarget, ignore_monsters, ignore_glass, ENT(pevLooker), &tr);
|
||||
|
||||
if (tr.flFraction == 1)
|
||||
{
|
||||
vecTargetOrigin = vecTarget;
|
||||
return TRUE;// line of sight is valid.
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;// Line of sight is not established
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// VecCheckToss - returns the velocity at which an object should be lobbed from vecspot1 to land near vecspot2.
|
||||
// returns g_vecZero if toss is not feasible.
|
||||
//
|
||||
Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj )
|
||||
Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj)
|
||||
{
|
||||
TraceResult tr;
|
||||
Vector vecMidPoint;// halfway point between Spot1 and Spot2
|
||||
Vector vecApex;// highest point
|
||||
Vector vecScale;
|
||||
Vector vecGrenadeVel;
|
||||
Vector vecTemp;
|
||||
float flGravity = g_psv_gravity->value * flGravityAdj;
|
||||
float flGravity = CVAR_GET_FLOAT("sv_gravity") * flGravityAdj;
|
||||
|
||||
if (vecSpot2.z - vecSpot1.z > 500)
|
||||
{
|
||||
// to high, fail
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
UTIL_MakeVectors (pev->angles);
|
||||
UTIL_MakeVectors(pev->angles);
|
||||
vecSpot2 = vecSpot2 + gpGlobals->v_right * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16));
|
||||
vecSpot2 = vecSpot2 + gpGlobals->v_forward * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16));
|
||||
|
||||
// toss a little bit to the left or right, not right down on the enemy's bean (head).
|
||||
vecSpot2 = vecSpot2 + gpGlobals->v_right * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) );
|
||||
vecSpot2 = vecSpot2 + gpGlobals->v_forward * ( RANDOM_FLOAT(-8,8) + RANDOM_FLOAT(-16,16) );
|
||||
|
||||
// calculate the midpoint and apex of the 'triangle'
|
||||
// UNDONE: normalize any Z position differences between spot1 and spot2 so that triangle is always RIGHT
|
||||
|
||||
// How much time does it take to get there?
|
||||
|
||||
// get a rough idea of how high it can be thrown
|
||||
vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
|
||||
UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0,0,500), ignore_monsters, ENT(pev), &tr);
|
||||
TraceResult tr;
|
||||
Vector vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
|
||||
UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0, 0, 500), ignore_monsters, ENT(pev), &tr);
|
||||
vecMidPoint = tr.vecEndPos;
|
||||
// (subtract 15 so the grenade doesn't hit the ceiling)
|
||||
vecMidPoint.z -= 15;
|
||||
vecMidPoint.z -= 50;
|
||||
|
||||
if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z)
|
||||
{
|
||||
// to not enough space, fail
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
// How high should the grenade travel to reach the apex
|
||||
float distance1 = (vecMidPoint.z - vecSpot1.z);
|
||||
float distance2 = (vecMidPoint.z - vecSpot2.z);
|
||||
|
||||
// How long will it take for the grenade to travel this distance
|
||||
float time1 = sqrt( distance1 / (0.5 * flGravity) );
|
||||
float time2 = sqrt( distance2 / (0.5 * flGravity) );
|
||||
float time1 = sqrt(distance1 / (0.5 * flGravity));
|
||||
float time2 = sqrt(distance2 / (0.5 * flGravity));
|
||||
|
||||
if (time1 < 0.1)
|
||||
{
|
||||
// too close
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
// how hard to throw sideways to get there in time.
|
||||
vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2);
|
||||
// how hard upwards to reach the apex at the right time.
|
||||
Vector vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2);
|
||||
vecGrenadeVel.z = flGravity * time1;
|
||||
|
||||
// find the apex
|
||||
vecApex = vecSpot1 + vecGrenadeVel * time1;
|
||||
Vector vecApex = vecSpot1 + vecGrenadeVel * time1;
|
||||
vecApex.z = vecMidPoint.z;
|
||||
|
||||
UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr);
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
// fail!
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
// UNDONE: either ignore monsters or change it to not care if we hit our enemy
|
||||
UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
// fail!
|
||||
if (tr.flFraction != 1)
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
|
||||
UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);
|
||||
|
||||
if (tr.flFraction != 1)
|
||||
return g_vecZero;
|
||||
|
||||
return vecGrenadeVel;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// VecCheckThrow - returns the velocity vector at which an object should be thrown from vecspot1 to hit vecspot2.
|
||||
// returns g_vecZero if throw is not feasible.
|
||||
//
|
||||
Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj )
|
||||
Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj)
|
||||
{
|
||||
float flGravity = g_psv_gravity->value * flGravityAdj;
|
||||
|
||||
float flGravity = CVAR_GET_FLOAT("sv_gravity") * flGravityAdj;
|
||||
Vector vecGrenadeVel = (vecSpot2 - vecSpot1);
|
||||
|
||||
// throw at a constant time
|
||||
float time = vecGrenadeVel.Length( ) / flSpeed;
|
||||
vecGrenadeVel = vecGrenadeVel * (1.0 / time);
|
||||
|
||||
// adjust upward toss to compensate for gravity loss
|
||||
float time = vecGrenadeVel.Length() / flSpeed;
|
||||
vecGrenadeVel = vecGrenadeVel * (1 / time);
|
||||
vecGrenadeVel.z += flGravity * time * 0.5;
|
||||
|
||||
Vector vecApex = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
|
||||
vecApex.z += 0.5 * flGravity * (time * 0.5) * (time * 0.5);
|
||||
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr);
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
// fail!
|
||||
|
||||
if (tr.flFraction != 1)
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);
|
||||
if (tr.flFraction != 1.0)
|
||||
{
|
||||
// fail!
|
||||
|
||||
if (tr.flFraction != 1)
|
||||
return g_vecZero;
|
||||
}
|
||||
|
||||
return vecGrenadeVel;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,16 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== h_battery.cpp ========================================================
|
||||
|
||||
battery-related code
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "saverestore.h"
|
||||
#include "skill.h"
|
||||
|
@ -30,46 +22,44 @@
|
|||
class CRecharge : public CBaseToggle
|
||||
{
|
||||
public:
|
||||
void Spawn( );
|
||||
void Precache( void );
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int ObjectCaps(void) { return (CBaseToggle::ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
public:
|
||||
void EXPORT Off(void);
|
||||
void EXPORT Recharge(void);
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
virtual int ObjectCaps( void ) { return (CBaseToggle :: ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; }
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
float m_flNextCharge;
|
||||
int m_iReactivate ; // DeathMatch Delay until reactvated
|
||||
int m_iJuice;
|
||||
int m_iOn; // 0 = off, 1 = startup, 2 = going
|
||||
float m_flSoundTime;
|
||||
public:
|
||||
float m_flNextCharge;
|
||||
int m_iReactivate;
|
||||
int m_iJuice;
|
||||
int m_iOn;
|
||||
float m_flSoundTime;
|
||||
};
|
||||
|
||||
TYPEDESCRIPTION CRecharge::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CRecharge, m_flNextCharge, FIELD_TIME ),
|
||||
DEFINE_FIELD( CRecharge, m_iReactivate, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CRecharge, m_iJuice, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CRecharge, m_iOn, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CRecharge, m_flSoundTime, FIELD_TIME ),
|
||||
DEFINE_FIELD(CRecharge, m_flNextCharge, FIELD_TIME),
|
||||
DEFINE_FIELD(CRecharge, m_iReactivate, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CRecharge, m_iJuice, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CRecharge, m_iOn, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CRecharge, m_flSoundTime, FIELD_TIME),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CRecharge, CBaseEntity );
|
||||
|
||||
IMPLEMENT_SAVERESTORE(CRecharge, CBaseEntity);
|
||||
LINK_ENTITY_TO_CLASS(func_recharge, CRecharge);
|
||||
|
||||
|
||||
void CRecharge::KeyValue( KeyValueData *pkvd )
|
||||
void CRecharge::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if ( FStrEq(pkvd->szKeyName, "style") ||
|
||||
FStrEq(pkvd->szKeyName, "height") ||
|
||||
FStrEq(pkvd->szKeyName, "value1") ||
|
||||
FStrEq(pkvd->szKeyName, "value2") ||
|
||||
FStrEq(pkvd->szKeyName, "value3"))
|
||||
if (FStrEq(pkvd->szKeyName, "style") || FStrEq(pkvd->szKeyName, "height") || FStrEq(pkvd->szKeyName, "value1") || FStrEq(pkvd->szKeyName, "value2") || FStrEq(pkvd->szKeyName, "value3"))
|
||||
{
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
|
@ -79,89 +69,80 @@ void CRecharge::KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseToggle::KeyValue( pkvd );
|
||||
CBaseToggle::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
void CRecharge::Spawn()
|
||||
void CRecharge::Spawn(void)
|
||||
{
|
||||
Precache( );
|
||||
Precache();
|
||||
|
||||
pev->solid = SOLID_BSP;
|
||||
pev->movetype = MOVETYPE_PUSH;
|
||||
pev->solid = SOLID_BSP;
|
||||
pev->movetype = MOVETYPE_PUSH;
|
||||
|
||||
UTIL_SetOrigin(pev, pev->origin); // set size and link into world
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
UTIL_SetSize(pev, pev->mins, pev->maxs);
|
||||
SET_MODEL(ENT(pev), STRING(pev->model) );
|
||||
m_iJuice = gSkillData.suitchargerCapacity;
|
||||
pev->frame = 0;
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
|
||||
m_iJuice = (int)gSkillData.suitchargerCapacity;
|
||||
pev->frame = 0;
|
||||
}
|
||||
|
||||
void CRecharge::Precache()
|
||||
void CRecharge::Precache(void)
|
||||
{
|
||||
PRECACHE_SOUND("items/suitcharge1.wav");
|
||||
PRECACHE_SOUND("items/suitchargeno1.wav");
|
||||
PRECACHE_SOUND("items/suitchargeok1.wav");
|
||||
}
|
||||
|
||||
|
||||
void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
{
|
||||
// if it's not a player, ignore
|
||||
void CRecharge::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
if (!FClassnameIs(pActivator->pev, "player"))
|
||||
return;
|
||||
|
||||
// if there is no juice left, turn it off
|
||||
if (m_iJuice <= 0)
|
||||
{
|
||||
pev->frame = 1;
|
||||
pev->frame = 1;
|
||||
Off();
|
||||
}
|
||||
|
||||
// if the player doesn't have the suit, or there is no juice left, make the deny noise
|
||||
if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1<<WEAPON_SUIT))))
|
||||
if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1 << WEAPON_SUIT))))
|
||||
{
|
||||
if (m_flSoundTime <= gpGlobals->time)
|
||||
{
|
||||
m_flSoundTime = gpGlobals->time + 0.62;
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeno1.wav", 0.85, ATTN_NORM);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pev->nextthink = pev->ltime + 0.25;
|
||||
SetThink(Off);
|
||||
|
||||
// Time to recharge yet?
|
||||
SetThink(&CRecharge::Off);
|
||||
|
||||
if (m_flNextCharge >= gpGlobals->time)
|
||||
return;
|
||||
|
||||
// Make sure that we have a caller
|
||||
if (!pActivator)
|
||||
return;
|
||||
|
||||
m_hActivator = pActivator;
|
||||
|
||||
//only recharge the player
|
||||
|
||||
if (!m_hActivator->IsPlayer() )
|
||||
if (!m_hActivator->IsPlayer())
|
||||
return;
|
||||
|
||||
// Play the on sound or the looping charging sound
|
||||
|
||||
if (!m_iOn)
|
||||
{
|
||||
m_iOn++;
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/suitchargeok1.wav", 0.85, ATTN_NORM);
|
||||
m_flSoundTime = 0.56 + gpGlobals->time;
|
||||
}
|
||||
|
||||
if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->time))
|
||||
{
|
||||
m_iOn++;
|
||||
EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav", 0.85, ATTN_NORM);
|
||||
}
|
||||
|
||||
|
||||
// charge the player
|
||||
if (m_hActivator->pev->armorvalue < 100)
|
||||
{
|
||||
m_iJuice--;
|
||||
|
@ -171,30 +152,28 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
|
|||
m_hActivator->pev->armorvalue = 100;
|
||||
}
|
||||
|
||||
// govern the rate of charge
|
||||
m_flNextCharge = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
void CRecharge::Recharge(void)
|
||||
{
|
||||
m_iJuice = gSkillData.suitchargerCapacity;
|
||||
pev->frame = 0;
|
||||
SetThink( SUB_DoNothing );
|
||||
m_iJuice = (int)gSkillData.suitchargerCapacity;
|
||||
pev->frame = 0;
|
||||
SetThink(&CBaseEntity::SUB_DoNothing);
|
||||
}
|
||||
|
||||
void CRecharge::Off(void)
|
||||
{
|
||||
// Stop looping sound.
|
||||
if (m_iOn > 1)
|
||||
STOP_SOUND( ENT(pev), CHAN_STATIC, "items/suitcharge1.wav" );
|
||||
STOP_SOUND(ENT(pev), CHAN_STATIC, "items/suitcharge1.wav");
|
||||
|
||||
m_iOn = 0;
|
||||
|
||||
if ((!m_iJuice) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0) )
|
||||
if ((!m_iJuice) && ((m_iReactivate = (int)g_pGameRules->FlHEVChargerRechargeTime()) > 0))
|
||||
{
|
||||
pev->nextthink = pev->ltime + m_iReactivate;
|
||||
SetThink(Recharge);
|
||||
SetThink(&CRecharge::Recharge);
|
||||
}
|
||||
else
|
||||
SetThink( SUB_DoNothing );
|
||||
}
|
||||
SetThink(&CBaseEntity::SUB_DoNothing);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,124 +12,105 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== h_cycler.cpp ========================================================
|
||||
|
||||
The Halflife Cycler Monsters
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "animation.h"
|
||||
#include "weapons.h"
|
||||
#include "player.h"
|
||||
|
||||
|
||||
#define TEMP_FOR_SCREEN_SHOTS
|
||||
#ifdef TEMP_FOR_SCREEN_SHOTS //===================================================
|
||||
#ifdef TEMP_FOR_SCREEN_SHOTS
|
||||
|
||||
class CCycler : public CBaseMonster
|
||||
{
|
||||
public:
|
||||
void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax);
|
||||
virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() | FCAP_IMPULSE_USE); }
|
||||
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
|
||||
void Spawn( void );
|
||||
void Think( void );
|
||||
//void Pain( float flDamage );
|
||||
void Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE); }
|
||||
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
|
||||
void Spawn(void);
|
||||
void Think(void);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
BOOL IsAlive(void) { return FALSE; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
// Don't treat as a live target
|
||||
virtual BOOL IsAlive( void ) { return FALSE; }
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
int m_animate;
|
||||
public:
|
||||
int m_animate;
|
||||
};
|
||||
|
||||
TYPEDESCRIPTION CCycler::m_SaveData[] =
|
||||
TYPEDESCRIPTION CCycler::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CCycler, m_animate, FIELD_INTEGER ),
|
||||
DEFINE_FIELD(CCycler, m_animate, FIELD_INTEGER),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CCycler, CBaseMonster );
|
||||
IMPLEMENT_SAVERESTORE(CCycler, CBaseMonster);
|
||||
|
||||
|
||||
//
|
||||
// we should get rid of all the other cyclers and replace them with this.
|
||||
//
|
||||
class CGenericCycler : public CCycler
|
||||
{
|
||||
public:
|
||||
void Spawn( void ) { GenericCyclerSpawn( (char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72) ); }
|
||||
void Spawn(void) { GenericCyclerSpawn((char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72)); }
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( cycler, CGenericCycler );
|
||||
|
||||
LINK_ENTITY_TO_CLASS(cycler, CGenericCycler);
|
||||
|
||||
|
||||
// Probe droid imported for tech demo compatibility
|
||||
//
|
||||
// PROBE DROID
|
||||
//
|
||||
class CCyclerProbe : public CCycler
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
public:
|
||||
void Spawn(void);
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( cycler_prdroid, CCyclerProbe );
|
||||
void CCyclerProbe :: Spawn( void )
|
||||
|
||||
LINK_ENTITY_TO_CLASS(cycler_prdroid, CCyclerProbe);
|
||||
|
||||
void CCyclerProbe::Spawn(void)
|
||||
{
|
||||
pev->origin = pev->origin + Vector ( 0, 0, 16 );
|
||||
GenericCyclerSpawn( "models/prdroid.mdl", Vector(-16,-16,-16), Vector(16,16,16));
|
||||
pev->origin = pev->origin + Vector(0, 0, 16);
|
||||
GenericCyclerSpawn("models/prdroid.mdl", Vector(-16, -16, -16), Vector(16, 16, 16));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Cycler member functions
|
||||
|
||||
void CCycler :: GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax)
|
||||
void CCycler::GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax)
|
||||
{
|
||||
if (!szModel || !*szModel)
|
||||
{
|
||||
ALERT(at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z );
|
||||
ALERT(at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z);
|
||||
REMOVE_ENTITY(ENT(pev));
|
||||
return;
|
||||
}
|
||||
|
||||
pev->classname = MAKE_STRING("cycler");
|
||||
PRECACHE_MODEL( szModel );
|
||||
SET_MODEL(ENT(pev), szModel);
|
||||
if (pev->classname)
|
||||
RemoveEntityHashValue(pev, STRING(pev->classname), CLASSNAME);
|
||||
|
||||
CCycler::Spawn( );
|
||||
pev->classname = MAKE_STRING("cycler");
|
||||
AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME);
|
||||
|
||||
PRECACHE_MODEL(szModel);
|
||||
SET_MODEL(ENT(pev), szModel);
|
||||
CCycler::Spawn();
|
||||
UTIL_SetSize(pev, vecMin, vecMax);
|
||||
}
|
||||
|
||||
|
||||
void CCycler :: Spawn( )
|
||||
void CCycler::Spawn(void)
|
||||
{
|
||||
InitBoneControllers();
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->effects = 0;
|
||||
pev->health = 80000;// no cycler should die
|
||||
pev->yaw_speed = 5;
|
||||
pev->ideal_yaw = pev->angles.y;
|
||||
ChangeYaw( 360 );
|
||||
|
||||
m_flFrameRate = 75;
|
||||
m_flGroundSpeed = 0;
|
||||
|
||||
pev->nextthink += 1.0;
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->effects = 0;
|
||||
pev->health = 80000;
|
||||
pev->yaw_speed = 5;
|
||||
pev->ideal_yaw = pev->angles.y;
|
||||
ChangeYaw(360);
|
||||
|
||||
ResetSequenceInfo( );
|
||||
m_flFrameRate = 75;
|
||||
m_flGroundSpeed = 0;
|
||||
pev->nextthink += 1;
|
||||
|
||||
ResetSequenceInfo();
|
||||
|
||||
if (pev->sequence != 0 || pev->frame != 0)
|
||||
{
|
||||
|
@ -137,76 +118,60 @@ void CCycler :: Spawn( )
|
|||
pev->framerate = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_animate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// cycler think
|
||||
//
|
||||
void CCycler :: Think( void )
|
||||
void CCycler::Think(void)
|
||||
{
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
if (m_animate)
|
||||
{
|
||||
StudioFrameAdvance ( );
|
||||
}
|
||||
StudioFrameAdvance();
|
||||
|
||||
if (m_fSequenceFinished && !m_fSequenceLoops)
|
||||
{
|
||||
// ResetSequenceInfo();
|
||||
// hack to avoid reloading model every frame
|
||||
pev->animtime = gpGlobals->time;
|
||||
pev->framerate = 1.0;
|
||||
pev->framerate = 1;
|
||||
m_fSequenceFinished = FALSE;
|
||||
m_flLastEventCheck = gpGlobals->time;
|
||||
pev->frame = 0;
|
||||
|
||||
if (!m_animate)
|
||||
pev->framerate = 0.0; // FIX: don't reset framerate
|
||||
pev->framerate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CyclerUse - starts a rotation trend
|
||||
//
|
||||
void CCycler :: Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void CCycler::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
m_animate = !m_animate;
|
||||
|
||||
if (m_animate)
|
||||
pev->framerate = 1.0;
|
||||
pev->framerate = 1;
|
||||
else
|
||||
pev->framerate = 0.0;
|
||||
pev->framerate = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// CyclerPain , changes sequences when shot
|
||||
//
|
||||
//void CCycler :: Pain( float flDamage )
|
||||
int CCycler :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
|
||||
int CCycler::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
|
||||
{
|
||||
if (m_animate)
|
||||
{
|
||||
pev->sequence++;
|
||||
ResetSequenceInfo();
|
||||
|
||||
ResetSequenceInfo( );
|
||||
|
||||
if (m_flFrameRate == 0.0)
|
||||
if (m_flFrameRate == 0)
|
||||
{
|
||||
pev->sequence = 0;
|
||||
ResetSequenceInfo( );
|
||||
ResetSequenceInfo();
|
||||
}
|
||||
|
||||
pev->frame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->framerate = 1.0;
|
||||
StudioFrameAdvance ( 0.1 );
|
||||
StudioFrameAdvance(0.1);
|
||||
pev->framerate = 0;
|
||||
ALERT( at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame );
|
||||
ALERT(at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -214,258 +179,271 @@ int CCycler :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, floa
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
class CCyclerSprite : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Think( void );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE); }
|
||||
virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
|
||||
void Animate( float frames );
|
||||
void Spawn(void);
|
||||
void Restart(void);
|
||||
void Think(void);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE); }
|
||||
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
|
||||
void Animate(float frames);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
inline int ShouldAnimate(void) { return m_animate && m_maxFrame > 1.0; }
|
||||
|
||||
inline int ShouldAnimate( void ) { return m_animate && m_maxFrame > 1.0; }
|
||||
int m_animate;
|
||||
float m_lastTime;
|
||||
float m_maxFrame;
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
int m_animate;
|
||||
float m_lastTime;
|
||||
float m_maxFrame;
|
||||
int m_renderfx;
|
||||
int m_rendermode;
|
||||
float m_renderamt;
|
||||
vec3_t m_rendercolor;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( cycler_sprite, CCyclerSprite );
|
||||
LINK_ENTITY_TO_CLASS(cycler_sprite, CCyclerSprite);
|
||||
|
||||
TYPEDESCRIPTION CCyclerSprite::m_SaveData[] =
|
||||
TYPEDESCRIPTION CCyclerSprite::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CCyclerSprite, m_animate, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CCyclerSprite, m_lastTime, FIELD_TIME ),
|
||||
DEFINE_FIELD( CCyclerSprite, m_maxFrame, FIELD_FLOAT ),
|
||||
DEFINE_FIELD(CCyclerSprite, m_animate, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CCyclerSprite, m_lastTime, FIELD_TIME),
|
||||
DEFINE_FIELD(CCyclerSprite, m_maxFrame, FIELD_FLOAT),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CCyclerSprite, CBaseEntity );
|
||||
IMPLEMENT_SAVERESTORE(CCyclerSprite, CBaseEntity);
|
||||
|
||||
|
||||
void CCyclerSprite::Spawn( void )
|
||||
void CCyclerSprite::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->effects = 0;
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->effects = 0;
|
||||
pev->frame = 0;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
pev->frame = 0;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
m_animate = 1;
|
||||
m_lastTime = gpGlobals->time;
|
||||
m_animate = 1;
|
||||
m_lastTime = gpGlobals->time;
|
||||
|
||||
PRECACHE_MODEL( (char *)STRING(pev->model) );
|
||||
SET_MODEL( ENT(pev), STRING(pev->model) );
|
||||
PRECACHE_MODEL((char *)STRING(pev->model));
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
|
||||
m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1;
|
||||
m_maxFrame = (float)MODEL_FRAMES(pev->modelindex) - 1;
|
||||
m_renderfx = pev->renderfx;
|
||||
m_rendermode = pev->rendermode;
|
||||
m_renderamt = pev->renderamt;
|
||||
m_rendercolor[0] = pev->rendercolor[0];
|
||||
m_rendercolor[1] = pev->rendercolor[1];
|
||||
m_rendercolor[2] = pev->rendercolor[2];
|
||||
}
|
||||
|
||||
|
||||
void CCyclerSprite::Think( void )
|
||||
void CCyclerSprite::Restart(void)
|
||||
{
|
||||
if ( ShouldAnimate() )
|
||||
Animate( pev->framerate * (gpGlobals->time - m_lastTime) );
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->effects = 0;
|
||||
pev->frame = 0;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
m_animate = 1;
|
||||
m_lastTime = gpGlobals->time;
|
||||
|
||||
pev->renderfx = m_renderfx;
|
||||
pev->rendermode = m_rendermode;
|
||||
pev->renderamt = m_renderamt;
|
||||
pev->rendercolor[0] = m_rendercolor[0];
|
||||
pev->rendercolor[1] = m_rendercolor[1];
|
||||
pev->rendercolor[2] = m_rendercolor[2];
|
||||
}
|
||||
|
||||
void CCyclerSprite::Think(void)
|
||||
{
|
||||
if (ShouldAnimate())
|
||||
Animate(pev->framerate * (gpGlobals->time - m_lastTime));
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
m_lastTime = gpGlobals->time;
|
||||
}
|
||||
|
||||
|
||||
void CCyclerSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void CCyclerSprite::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
m_animate = !m_animate;
|
||||
ALERT( at_console, "Sprite: %s\n", STRING(pev->model) );
|
||||
ALERT(at_console, "Sprite: %s\n", STRING(pev->model));
|
||||
}
|
||||
|
||||
|
||||
int CCyclerSprite::TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
|
||||
int CCyclerSprite::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
|
||||
{
|
||||
if ( m_maxFrame > 1.0 )
|
||||
{
|
||||
Animate( 1.0 );
|
||||
}
|
||||
if (m_maxFrame > 1)
|
||||
Animate(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CCyclerSprite::Animate( float frames )
|
||||
{
|
||||
void CCyclerSprite::Animate(float frames)
|
||||
{
|
||||
pev->frame += frames;
|
||||
if ( m_maxFrame > 0 )
|
||||
pev->frame = fmod( pev->frame, m_maxFrame );
|
||||
|
||||
if (m_maxFrame > 0)
|
||||
pev->frame = fmod(pev->frame, m_maxFrame);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CWeaponCycler : public CBasePlayerWeapon
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
int iItemSlot( void ) { return 1; }
|
||||
int GetItemInfo(ItemInfo *p) {return 0; }
|
||||
void Spawn(void);
|
||||
int iItemSlot(void) { return 1; }
|
||||
int GetItemInfo(ItemInfo *p) { return 0; }
|
||||
void PrimaryAttack(void);
|
||||
void SecondaryAttack(void);
|
||||
BOOL Deploy(void);
|
||||
void Holster(int skiplocal = 0);
|
||||
|
||||
void PrimaryAttack( void );
|
||||
void SecondaryAttack( void );
|
||||
BOOL Deploy( void );
|
||||
void Holster( int skiplocal = 0 );
|
||||
public:
|
||||
int m_iszModel;
|
||||
int m_iModel;
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( cycler_weapon, CWeaponCycler );
|
||||
|
||||
LINK_ENTITY_TO_CLASS(cycler_weapon, CWeaponCycler);
|
||||
|
||||
void CWeaponCycler::Spawn( )
|
||||
void CWeaponCycler::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->solid = SOLID_SLIDEBOX;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
|
||||
PRECACHE_MODEL((char *)STRING(pev->model));
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
|
||||
PRECACHE_MODEL( (char *)STRING(pev->model) );
|
||||
SET_MODEL( ENT(pev), STRING(pev->model) );
|
||||
m_iszModel = pev->model;
|
||||
m_iModel = pev->modelindex;
|
||||
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
|
||||
SetTouch( DefaultTouch );
|
||||
SetTouch(&CBasePlayerItem::DefaultTouch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CWeaponCycler::Deploy( )
|
||||
BOOL CWeaponCycler::Deploy(void)
|
||||
{
|
||||
m_pPlayer->pev->viewmodel = m_iszModel;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
SendWeaponAnim( 0 );
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
|
||||
|
||||
SendWeaponAnim(0);
|
||||
m_iClip = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CWeaponCycler::Holster( int skiplocal /* = 0 */ )
|
||||
void CWeaponCycler::Holster(int skiplocal)
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
}
|
||||
|
||||
|
||||
void CWeaponCycler::PrimaryAttack()
|
||||
void CWeaponCycler::PrimaryAttack(void)
|
||||
{
|
||||
|
||||
SendWeaponAnim( pev->sequence );
|
||||
|
||||
SendWeaponAnim(pev->sequence);
|
||||
m_flNextPrimaryAttack = gpGlobals->time + 0.3;
|
||||
}
|
||||
|
||||
|
||||
void CWeaponCycler::SecondaryAttack( void )
|
||||
void CWeaponCycler::SecondaryAttack(void)
|
||||
{
|
||||
float flFrameRate, flGroundSpeed;
|
||||
|
||||
pev->sequence = (pev->sequence + 1) % 8;
|
||||
|
||||
pev->modelindex = m_iModel;
|
||||
void *pmodel = GET_MODEL_PTR( ENT(pev) );
|
||||
GetSequenceInfo( pmodel, pev, &flFrameRate, &flGroundSpeed );
|
||||
|
||||
void *pmodel = GET_MODEL_PTR(ENT(pev));
|
||||
|
||||
float flFrameRate, flGroundSpeed;
|
||||
GetSequenceInfo(pmodel, pev, &flFrameRate, &flGroundSpeed);
|
||||
pev->modelindex = 0;
|
||||
|
||||
if (flFrameRate == 0.0)
|
||||
{
|
||||
if (flFrameRate == 0)
|
||||
pev->sequence = 0;
|
||||
}
|
||||
|
||||
SendWeaponAnim( pev->sequence );
|
||||
|
||||
SendWeaponAnim(pev->sequence);
|
||||
m_flNextSecondaryAttack = gpGlobals->time + 0.3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Flaming Wreakage
|
||||
class CWreckage : public CBaseMonster
|
||||
{
|
||||
int Save( CSave &save );
|
||||
int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void Think(void);
|
||||
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void Think( void );
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
public:
|
||||
int m_flStartTime;
|
||||
};
|
||||
TYPEDESCRIPTION CWreckage::m_SaveData[] =
|
||||
|
||||
TYPEDESCRIPTION CWreckage::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CWreckage, m_flStartTime, FIELD_TIME ),
|
||||
DEFINE_FIELD(CWreckage, m_flStartTime, FIELD_TIME),
|
||||
};
|
||||
IMPLEMENT_SAVERESTORE( CWreckage, CBaseMonster );
|
||||
|
||||
IMPLEMENT_SAVERESTORE(CWreckage, CBaseMonster);
|
||||
LINK_ENTITY_TO_CLASS(cycler_wreckage, CWreckage);
|
||||
|
||||
LINK_ENTITY_TO_CLASS( cycler_wreckage, CWreckage );
|
||||
|
||||
void CWreckage::Spawn( void )
|
||||
void CWreckage::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = 0;
|
||||
pev->effects = 0;
|
||||
|
||||
pev->frame = 0;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->takedamage = 0;
|
||||
pev->effects = 0;
|
||||
pev->frame = 0;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
if (pev->model)
|
||||
{
|
||||
PRECACHE_MODEL( (char *)STRING(pev->model) );
|
||||
SET_MODEL( ENT(pev), STRING(pev->model) );
|
||||
PRECACHE_MODEL((char *)STRING(pev->model));
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
}
|
||||
// pev->scale = 5.0;
|
||||
|
||||
m_flStartTime = gpGlobals->time;
|
||||
m_flStartTime = (int)(gpGlobals->time);
|
||||
}
|
||||
|
||||
void CWreckage::Precache( )
|
||||
void CWreckage::Precache(void)
|
||||
{
|
||||
if ( pev->model )
|
||||
PRECACHE_MODEL( (char *)STRING(pev->model) );
|
||||
if (pev->model)
|
||||
PRECACHE_MODEL((char *)STRING(pev->model));
|
||||
}
|
||||
|
||||
void CWreckage::Think( void )
|
||||
void CWreckage::Think(void)
|
||||
{
|
||||
StudioFrameAdvance( );
|
||||
StudioFrameAdvance();
|
||||
pev->nextthink = gpGlobals->time + 0.2;
|
||||
|
||||
if (pev->dmgtime)
|
||||
{
|
||||
if (pev->dmgtime < gpGlobals->time)
|
||||
{
|
||||
UTIL_Remove( this );
|
||||
UTIL_Remove(this);
|
||||
return;
|
||||
}
|
||||
else if (RANDOM_FLOAT( 0, pev->dmgtime - m_flStartTime ) > pev->dmgtime - gpGlobals->time)
|
||||
else
|
||||
{
|
||||
return;
|
||||
if (RANDOM_FLOAT(0, pev->dmgtime - m_flStartTime) > pev->dmgtime - gpGlobals->time)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector VecSrc;
|
||||
|
||||
VecSrc.x = RANDOM_FLOAT( pev->absmin.x, pev->absmax.x );
|
||||
VecSrc.y = RANDOM_FLOAT( pev->absmin.y, pev->absmax.y );
|
||||
VecSrc.z = RANDOM_FLOAT( pev->absmin.z, pev->absmax.z );
|
||||
|
||||
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, VecSrc );
|
||||
WRITE_BYTE( TE_SMOKE );
|
||||
WRITE_COORD( VecSrc.x );
|
||||
WRITE_COORD( VecSrc.y );
|
||||
WRITE_COORD( VecSrc.z );
|
||||
WRITE_SHORT( g_sModelIndexSmoke );
|
||||
WRITE_BYTE( RANDOM_LONG(0,49) + 50 ); // scale * 10
|
||||
WRITE_BYTE( RANDOM_LONG(0, 3) + 8 ); // framerate
|
||||
Vector VecSrc;
|
||||
VecSrc.x = RANDOM_FLOAT(pev->absmin.x, pev->absmax.x);
|
||||
VecSrc.y = RANDOM_FLOAT(pev->absmin.y, pev->absmax.y);
|
||||
VecSrc.z = RANDOM_FLOAT(pev->absmin.z, pev->absmax.z);
|
||||
|
||||
MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, VecSrc);
|
||||
WRITE_BYTE(TE_SMOKE);
|
||||
WRITE_COORD(VecSrc.x);
|
||||
WRITE_COORD(VecSrc.y);
|
||||
WRITE_COORD(VecSrc.z);
|
||||
WRITE_SHORT(g_sModelIndexSmoke);
|
||||
WRITE_BYTE(RANDOM_LONG(0, 49) + 50);
|
||||
WRITE_BYTE(RANDOM_LONG(0, 3) + 8);
|
||||
MESSAGE_END();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,58 +12,52 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== h_export.cpp ========================================================
|
||||
|
||||
Entity classes exported by Halflife.
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
|
||||
// Holds engine functionality callbacks
|
||||
enginefuncs_t g_engfuncs;
|
||||
globalvars_t *gpGlobals;
|
||||
globalvars_t *gpGlobals;
|
||||
|
||||
#undef DLLEXPORT
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT __stdcall
|
||||
#else
|
||||
#define DLLEXPORT __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// Required DLL entry point
|
||||
BOOL WINAPI DllMain(
|
||||
HINSTANCE hinstDLL,
|
||||
DWORD fdwReason,
|
||||
LPVOID lpvReserved)
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
}
|
||||
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
}
|
||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DLLEXPORT GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
|
||||
{
|
||||
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
extern "C" {
|
||||
|
||||
void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
|
||||
{
|
||||
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(__GNUC__) && defined (_MSC_VER)
|
||||
#pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
||||
#pragma comment(linker, "/SECTION:.data,RW")
|
||||
#endif
|
||||
|
||||
extern "C" void DLLEXPORT GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, globalvars_t *pGlobals)
|
||||
{
|
||||
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
}
|
||||
#else
|
||||
extern "C"
|
||||
{
|
||||
void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
|
||||
{
|
||||
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
|
||||
gpGlobals = pGlobals;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,233 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
|
||||
|
||||
#define HANDGRENADE_PRIMARY_VOLUME 450
|
||||
|
||||
enum handgrenade_e {
|
||||
HANDGRENADE_IDLE = 0,
|
||||
HANDGRENADE_FIDGET,
|
||||
HANDGRENADE_PINPULL,
|
||||
HANDGRENADE_THROW1, // toss
|
||||
HANDGRENADE_THROW2, // medium
|
||||
HANDGRENADE_THROW3, // hard
|
||||
HANDGRENADE_HOLSTER,
|
||||
HANDGRENADE_DRAW
|
||||
};
|
||||
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_handgrenade, CHandGrenade );
|
||||
|
||||
|
||||
void CHandGrenade::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_HANDGRENADE;
|
||||
SET_MODEL(ENT(pev), "models/w_grenade.mdl");
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
pev->dmg = gSkillData.plrDmgHandGrenade;
|
||||
#endif
|
||||
|
||||
m_iDefaultAmmo = HANDGRENADE_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CHandGrenade::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_grenade.mdl");
|
||||
PRECACHE_MODEL("models/v_grenade.mdl");
|
||||
PRECACHE_MODEL("models/p_grenade.mdl");
|
||||
}
|
||||
|
||||
int CHandGrenade::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "Hand Grenade";
|
||||
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 4;
|
||||
p->iPosition = 0;
|
||||
p->iId = m_iId = WEAPON_HANDGRENADE;
|
||||
p->iWeight = HANDGRENADE_WEIGHT;
|
||||
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
BOOL CHandGrenade::Deploy( )
|
||||
{
|
||||
m_flReleaseThrow = -1;
|
||||
return DefaultDeploy( "models/v_grenade.mdl", "models/p_grenade.mdl", HANDGRENADE_DRAW, "crowbar" );
|
||||
}
|
||||
|
||||
BOOL CHandGrenade::CanHolster( void )
|
||||
{
|
||||
// can only holster hand grenades when not primed!
|
||||
return ( m_flStartThrow == 0 );
|
||||
}
|
||||
|
||||
void CHandGrenade::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
|
||||
{
|
||||
SendWeaponAnim( HANDGRENADE_HOLSTER );
|
||||
}
|
||||
else
|
||||
{
|
||||
// no more grenades!
|
||||
m_pPlayer->pev->weapons &= ~(1<<WEAPON_HANDGRENADE);
|
||||
SetThink( DestroyItem );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM);
|
||||
}
|
||||
|
||||
void CHandGrenade::PrimaryAttack()
|
||||
{
|
||||
if ( !m_flStartThrow && m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] > 0 )
|
||||
{
|
||||
m_flStartThrow = gpGlobals->time;
|
||||
m_flReleaseThrow = 0;
|
||||
|
||||
SendWeaponAnim( HANDGRENADE_PINPULL );
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHandGrenade::WeaponIdle( void )
|
||||
{
|
||||
if ( m_flReleaseThrow == 0 && m_flStartThrow )
|
||||
m_flReleaseThrow = gpGlobals->time;
|
||||
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
if ( m_flStartThrow )
|
||||
{
|
||||
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
||||
|
||||
if ( angThrow.x < 0 )
|
||||
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
|
||||
else
|
||||
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
|
||||
|
||||
float flVel = ( 90 - angThrow.x ) * 4;
|
||||
if ( flVel > 500 )
|
||||
flVel = 500;
|
||||
|
||||
UTIL_MakeVectors( angThrow );
|
||||
|
||||
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
|
||||
|
||||
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
|
||||
|
||||
// alway explode 3 seconds after the pin was pulled
|
||||
float time = m_flStartThrow - gpGlobals->time + 3.0;
|
||||
if (time < 0)
|
||||
time = 0;
|
||||
|
||||
CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time );
|
||||
|
||||
if ( flVel < 500 )
|
||||
{
|
||||
SendWeaponAnim( HANDGRENADE_THROW1 );
|
||||
}
|
||||
else if ( flVel < 1000 )
|
||||
{
|
||||
SendWeaponAnim( HANDGRENADE_THROW2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendWeaponAnim( HANDGRENADE_THROW3 );
|
||||
}
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
m_flReleaseThrow = 0;
|
||||
m_flStartThrow = 0;
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ]--;
|
||||
|
||||
if ( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
|
||||
{
|
||||
// just threw last grenade
|
||||
// set attack times in the future, and weapon idle in the future so we can see the whole throw
|
||||
// animation, weapon idle will automatically retire the weapon for us.
|
||||
m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;// ensure that the animation can finish playing
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ( m_flReleaseThrow > 0 )
|
||||
{
|
||||
// we've finished the throw, restart.
|
||||
m_flStartThrow = 0;
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
|
||||
{
|
||||
SendWeaponAnim( HANDGRENADE_DRAW );
|
||||
}
|
||||
else
|
||||
{
|
||||
RetireWeapon();
|
||||
return;
|
||||
}
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
m_flReleaseThrow = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
||||
{
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.75)
|
||||
{
|
||||
iAnim = HANDGRENADE_IDLE;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = HANDGRENADE_FIDGET;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0 / 30.0;
|
||||
}
|
||||
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,8 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
|
@ -26,69 +26,41 @@ extern int gmsgItemPickup;
|
|||
|
||||
class CHealthKit : public CItem
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
BOOL MyTouch( CBasePlayer *pPlayer );
|
||||
|
||||
/*
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
*/
|
||||
|
||||
public:
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
BOOL MyTouch(CBasePlayer *pPlayer);
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_healthkit, CHealthKit);
|
||||
|
||||
LINK_ENTITY_TO_CLASS( item_healthkit, CHealthKit );
|
||||
|
||||
/*
|
||||
TYPEDESCRIPTION CHealthKit::m_SaveData[] =
|
||||
void CHealthKit::Spawn(void)
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CHealthKit, CItem);
|
||||
*/
|
||||
|
||||
void CHealthKit :: Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_medkit.mdl");
|
||||
|
||||
CItem::Spawn();
|
||||
}
|
||||
|
||||
void CHealthKit::Precache( void )
|
||||
void CHealthKit::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_medkit.mdl");
|
||||
PRECACHE_SOUND("items/smallmedkit1.wav");
|
||||
}
|
||||
|
||||
BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer )
|
||||
BOOL CHealthKit::MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if ( pPlayer->pev->deadflag != DEAD_NO )
|
||||
if (pPlayer->TakeHealth(gSkillData.healthkitCapacity, DMG_GENERIC))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( pPlayer->TakeHealth( gSkillData.healthkitCapacity, DMG_GENERIC ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
|
||||
WRITE_STRING( STRING(pev->classname) );
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
|
||||
WRITE_STRING(STRING(pev->classname));
|
||||
MESSAGE_END();
|
||||
|
||||
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", 1, ATTN_NORM);
|
||||
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
if ( g_pGameRules->ItemShouldRespawn( this ) )
|
||||
{
|
||||
if (g_pGameRules->ItemShouldRespawn(this))
|
||||
Respawn();
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_Remove(this);
|
||||
}
|
||||
UTIL_Remove(this);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -96,54 +68,47 @@ BOOL CHealthKit::MyTouch( CBasePlayer *pPlayer )
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Wall mounted health kit
|
||||
//-------------------------------------------------------------
|
||||
class CWallHealth : public CBaseToggle
|
||||
{
|
||||
public:
|
||||
void Spawn( );
|
||||
void Precache( void );
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int ObjectCaps(void) { return (CBaseToggle::ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
public:
|
||||
void EXPORT Off(void);
|
||||
void EXPORT Recharge(void);
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
virtual int ObjectCaps( void ) { return (CBaseToggle :: ObjectCaps() | FCAP_CONTINUOUS_USE) & ~FCAP_ACROSS_TRANSITION; }
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
float m_flNextCharge;
|
||||
int m_iReactivate ; // DeathMatch Delay until reactvated
|
||||
int m_iJuice;
|
||||
int m_iOn; // 0 = off, 1 = startup, 2 = going
|
||||
float m_flSoundTime;
|
||||
public:
|
||||
float m_flNextCharge;
|
||||
int m_iReactivate;
|
||||
int m_iJuice;
|
||||
int m_iOn;
|
||||
float m_flSoundTime;
|
||||
};
|
||||
|
||||
TYPEDESCRIPTION CWallHealth::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CWallHealth, m_flNextCharge, FIELD_TIME),
|
||||
DEFINE_FIELD( CWallHealth, m_iReactivate, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CWallHealth, m_iJuice, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CWallHealth, m_iOn, FIELD_INTEGER),
|
||||
DEFINE_FIELD( CWallHealth, m_flSoundTime, FIELD_TIME),
|
||||
DEFINE_FIELD(CWallHealth, m_flNextCharge, FIELD_TIME),
|
||||
DEFINE_FIELD(CWallHealth, m_iReactivate, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CWallHealth, m_iJuice, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CWallHealth, m_iOn, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CWallHealth, m_flSoundTime, FIELD_TIME),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CWallHealth, CBaseEntity );
|
||||
|
||||
IMPLEMENT_SAVERESTORE(CWallHealth, CBaseEntity);
|
||||
LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth);
|
||||
|
||||
|
||||
void CWallHealth::KeyValue( KeyValueData *pkvd )
|
||||
void CWallHealth::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if ( FStrEq(pkvd->szKeyName, "style") ||
|
||||
FStrEq(pkvd->szKeyName, "height") ||
|
||||
FStrEq(pkvd->szKeyName, "value1") ||
|
||||
FStrEq(pkvd->szKeyName, "value2") ||
|
||||
FStrEq(pkvd->szKeyName, "value3"))
|
||||
if (FStrEq(pkvd->szKeyName, "style") || FStrEq(pkvd->szKeyName, "height") || FStrEq(pkvd->szKeyName, "value1") || FStrEq(pkvd->szKeyName, "value2") || FStrEq(pkvd->szKeyName, "value3"))
|
||||
{
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
|
@ -153,112 +118,100 @@ void CWallHealth::KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseToggle::KeyValue( pkvd );
|
||||
CBaseToggle::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
void CWallHealth::Spawn()
|
||||
void CWallHealth::Spawn(void)
|
||||
{
|
||||
Precache( );
|
||||
Precache();
|
||||
|
||||
pev->solid = SOLID_BSP;
|
||||
pev->movetype = MOVETYPE_PUSH;
|
||||
pev->solid = SOLID_BSP;
|
||||
pev->movetype = MOVETYPE_PUSH;
|
||||
|
||||
UTIL_SetOrigin(pev, pev->origin); // set size and link into world
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
UTIL_SetSize(pev, pev->mins, pev->maxs);
|
||||
SET_MODEL(ENT(pev), STRING(pev->model) );
|
||||
m_iJuice = gSkillData.healthchargerCapacity;
|
||||
pev->frame = 0;
|
||||
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
m_iJuice = (int)gSkillData.healthchargerCapacity;
|
||||
pev->frame = 0;
|
||||
}
|
||||
|
||||
void CWallHealth::Precache()
|
||||
void CWallHealth::Precache(void)
|
||||
{
|
||||
PRECACHE_SOUND("items/medshot4.wav");
|
||||
PRECACHE_SOUND("items/medshotno1.wav");
|
||||
PRECACHE_SOUND("items/medcharge4.wav");
|
||||
}
|
||||
|
||||
|
||||
void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
{
|
||||
// Make sure that we have a caller
|
||||
void CWallHealth::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
if (!pActivator)
|
||||
return;
|
||||
// if it's not a player, ignore
|
||||
if ( !pActivator->IsPlayer() )
|
||||
|
||||
if (!pActivator->IsPlayer())
|
||||
return;
|
||||
|
||||
// if there is no juice left, turn it off
|
||||
if (m_iJuice <= 0)
|
||||
{
|
||||
pev->frame = 1;
|
||||
pev->frame = 1;
|
||||
Off();
|
||||
}
|
||||
|
||||
// if the player doesn't have the suit, or there is no juice left, make the deny noise
|
||||
if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1<<WEAPON_SUIT))))
|
||||
if ((m_iJuice <= 0) || (!(pActivator->pev->weapons & (1 << WEAPON_SUIT))))
|
||||
{
|
||||
if (m_flSoundTime <= gpGlobals->time)
|
||||
{
|
||||
m_flSoundTime = gpGlobals->time + 0.62;
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshotno1.wav", 1.0, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshotno1.wav", VOL_NORM, ATTN_NORM);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pev->nextthink = pev->ltime + 0.25;
|
||||
SetThink(Off);
|
||||
|
||||
// Time to recharge yet?
|
||||
SetThink(&CWallHealth::Off);
|
||||
|
||||
if (m_flNextCharge >= gpGlobals->time)
|
||||
return;
|
||||
|
||||
// Play the on sound or the looping charging sound
|
||||
if (!m_iOn)
|
||||
{
|
||||
m_iOn++;
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM);
|
||||
m_flSoundTime = 0.56 + gpGlobals->time;
|
||||
}
|
||||
|
||||
if ((m_iOn == 1) && (m_flSoundTime <= gpGlobals->time))
|
||||
{
|
||||
m_iOn++;
|
||||
EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", 1.0, ATTN_NORM );
|
||||
EMIT_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav", VOL_NORM, ATTN_NORM);
|
||||
}
|
||||
|
||||
|
||||
// charge the player
|
||||
if ( pActivator->TakeHealth( 1, DMG_GENERIC ) )
|
||||
{
|
||||
if (pActivator->TakeHealth(1, DMG_GENERIC))
|
||||
m_iJuice--;
|
||||
}
|
||||
|
||||
// govern the rate of charge
|
||||
m_flNextCharge = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
void CWallHealth::Recharge(void)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM );
|
||||
m_iJuice = gSkillData.healthchargerCapacity;
|
||||
pev->frame = 0;
|
||||
SetThink( SUB_DoNothing );
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/medshot4.wav", VOL_NORM, ATTN_NORM);
|
||||
m_iJuice = (int)gSkillData.healthchargerCapacity;
|
||||
pev->frame = 0;
|
||||
SetThink(&CBaseEntity::SUB_DoNothing);
|
||||
}
|
||||
|
||||
void CWallHealth::Off(void)
|
||||
{
|
||||
// Stop looping sound.
|
||||
if (m_iOn > 1)
|
||||
STOP_SOUND( ENT(pev), CHAN_STATIC, "items/medcharge4.wav" );
|
||||
STOP_SOUND(ENT(pev), CHAN_STATIC, "items/medcharge4.wav");
|
||||
|
||||
m_iOn = 0;
|
||||
|
||||
if ((!m_iJuice) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0) )
|
||||
if ((!m_iJuice) && ((m_iReactivate = (int)g_pGameRules->FlHealthChargerRechargeTime()) > 0))
|
||||
{
|
||||
pev->nextthink = pev->ltime + m_iReactivate;
|
||||
SetThink(Recharge);
|
||||
SetThink(&CWallHealth::Recharge);
|
||||
}
|
||||
else
|
||||
SetThink( SUB_DoNothing );
|
||||
SetThink(&CBaseEntity::SUB_DoNothing);
|
||||
}
|
||||
|
|
419
dlls/hornet.cpp
419
dlls/hornet.cpp
|
@ -1,419 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// Hornets
|
||||
//=========================================================
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "soundent.h"
|
||||
#include "hornet.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
int iHornetTrail;
|
||||
int iHornetPuff;
|
||||
|
||||
LINK_ENTITY_TO_CLASS( hornet, CHornet );
|
||||
|
||||
//=========================================================
|
||||
// Save/Restore
|
||||
//=========================================================
|
||||
TYPEDESCRIPTION CHornet::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CHornet, m_flStopAttack, FIELD_TIME ),
|
||||
DEFINE_FIELD( CHornet, m_iHornetType, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CHornet, m_flFlySpeed, FIELD_FLOAT ),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CHornet, CBaseMonster );
|
||||
|
||||
//=========================================================
|
||||
// don't let hornets gib, ever.
|
||||
//=========================================================
|
||||
int CHornet :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
||||
{
|
||||
// filter these bits a little.
|
||||
bitsDamageType &= ~ ( DMG_ALWAYSGIB );
|
||||
bitsDamageType |= DMG_NEVERGIB;
|
||||
|
||||
return CBaseMonster :: TakeDamage ( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHornet :: Spawn( void )
|
||||
{
|
||||
Precache();
|
||||
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->solid = SOLID_BBOX;
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->flags |= FL_MONSTER;
|
||||
pev->health = 1;// weak!
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// hornets don't live as long in multiplayer
|
||||
m_flStopAttack = gpGlobals->time + 3.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flStopAttack = gpGlobals->time + 5.0;
|
||||
}
|
||||
|
||||
m_flFieldOfView = 0.9; // +- 25 degrees
|
||||
|
||||
if ( RANDOM_LONG ( 1, 5 ) <= 2 )
|
||||
{
|
||||
m_iHornetType = HORNET_TYPE_RED;
|
||||
m_flFlySpeed = HORNET_RED_SPEED;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iHornetType = HORNET_TYPE_ORANGE;
|
||||
m_flFlySpeed = HORNET_ORANGE_SPEED;
|
||||
}
|
||||
|
||||
SET_MODEL(ENT( pev ), "models/hornet.mdl");
|
||||
UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) );
|
||||
|
||||
SetTouch( DieTouch );
|
||||
SetThink( StartTrack );
|
||||
|
||||
edict_t *pSoundEnt = pev->owner;
|
||||
if ( !pSoundEnt )
|
||||
pSoundEnt = edict();
|
||||
|
||||
if ( !FNullEnt(pev->owner) && (pev->owner->v.flags & FL_CLIENT) )
|
||||
{
|
||||
pev->dmg = gSkillData.plrDmgHornet;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no real owner, or owner isn't a client.
|
||||
pev->dmg = gSkillData.monDmgHornet;
|
||||
}
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
ResetSequenceInfo( );
|
||||
}
|
||||
|
||||
|
||||
void CHornet :: Precache()
|
||||
{
|
||||
PRECACHE_MODEL("models/hornet.mdl");
|
||||
|
||||
PRECACHE_SOUND( "agrunt/ag_fire1.wav" );
|
||||
PRECACHE_SOUND( "agrunt/ag_fire2.wav" );
|
||||
PRECACHE_SOUND( "agrunt/ag_fire3.wav" );
|
||||
|
||||
PRECACHE_SOUND( "hornet/ag_buzz1.wav" );
|
||||
PRECACHE_SOUND( "hornet/ag_buzz2.wav" );
|
||||
PRECACHE_SOUND( "hornet/ag_buzz3.wav" );
|
||||
|
||||
PRECACHE_SOUND( "hornet/ag_hornethit1.wav" );
|
||||
PRECACHE_SOUND( "hornet/ag_hornethit2.wav" );
|
||||
PRECACHE_SOUND( "hornet/ag_hornethit3.wav" );
|
||||
|
||||
iHornetPuff = PRECACHE_MODEL( "sprites/muz1.spr" );
|
||||
iHornetTrail = PRECACHE_MODEL("sprites/laserbeam.spr");
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// hornets will never get mad at each other, no matter who the owner is.
|
||||
//=========================================================
|
||||
int CHornet::IRelationship ( CBaseEntity *pTarget )
|
||||
{
|
||||
if ( pTarget->pev->modelindex == pev->modelindex )
|
||||
{
|
||||
return R_NO;
|
||||
}
|
||||
|
||||
return CBaseMonster :: IRelationship( pTarget );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// ID's Hornet as their owner
|
||||
//=========================================================
|
||||
int CHornet::Classify ( void )
|
||||
{
|
||||
|
||||
if ( pev->owner && pev->owner->v.flags & FL_CLIENT)
|
||||
{
|
||||
return CLASS_PLAYER_BIOWEAPON;
|
||||
}
|
||||
|
||||
return CLASS_ALIEN_BIOWEAPON;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// StartTrack - starts a hornet out tracking its target
|
||||
//=========================================================
|
||||
void CHornet :: StartTrack ( void )
|
||||
{
|
||||
IgniteTrail();
|
||||
|
||||
SetTouch( TrackTouch );
|
||||
SetThink( TrackTarget );
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// StartDart - starts a hornet out just flying straight.
|
||||
//=========================================================
|
||||
void CHornet :: StartDart ( void )
|
||||
{
|
||||
IgniteTrail();
|
||||
|
||||
SetTouch( DartTouch );
|
||||
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 4;
|
||||
}
|
||||
|
||||
void CHornet::IgniteTrail( void )
|
||||
{
|
||||
/*
|
||||
|
||||
ted's suggested trail colors:
|
||||
|
||||
r161
|
||||
g25
|
||||
b97
|
||||
|
||||
r173
|
||||
g39
|
||||
b14
|
||||
|
||||
old colors
|
||||
case HORNET_TYPE_RED:
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
WRITE_BYTE( 128 ); // r, g, b
|
||||
WRITE_BYTE( 0 ); // r, g, b
|
||||
break;
|
||||
case HORNET_TYPE_ORANGE:
|
||||
WRITE_BYTE( 0 ); // r, g, b
|
||||
WRITE_BYTE( 100 ); // r, g, b
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
break;
|
||||
|
||||
*/
|
||||
|
||||
// trail
|
||||
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
||||
WRITE_BYTE( TE_BEAMFOLLOW );
|
||||
WRITE_SHORT( entindex() ); // entity
|
||||
WRITE_SHORT( iHornetTrail ); // model
|
||||
WRITE_BYTE( 10 ); // life
|
||||
WRITE_BYTE( 2 ); // width
|
||||
|
||||
switch ( m_iHornetType )
|
||||
{
|
||||
case HORNET_TYPE_RED:
|
||||
WRITE_BYTE( 179 ); // r, g, b
|
||||
WRITE_BYTE( 39 ); // r, g, b
|
||||
WRITE_BYTE( 14 ); // r, g, b
|
||||
break;
|
||||
case HORNET_TYPE_ORANGE:
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
WRITE_BYTE( 128 ); // r, g, b
|
||||
WRITE_BYTE( 0 ); // r, g, b
|
||||
break;
|
||||
}
|
||||
|
||||
WRITE_BYTE( 128 ); // brightness
|
||||
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Hornet is flying, gently tracking target
|
||||
//=========================================================
|
||||
void CHornet :: TrackTarget ( void )
|
||||
{
|
||||
Vector vecFlightDir;
|
||||
Vector vecDirToEnemy;
|
||||
float flDelta;
|
||||
|
||||
StudioFrameAdvance( );
|
||||
|
||||
if (gpGlobals->time > m_flStopAttack)
|
||||
{
|
||||
ResetTouch( );
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
// UNDONE: The player pointer should come back after returning from another level
|
||||
if ( m_hEnemy == NULL )
|
||||
{// enemy is dead.
|
||||
Look( 512 );
|
||||
m_hEnemy = BestVisibleEnemy( );
|
||||
}
|
||||
|
||||
if ( m_hEnemy != NULL && FVisible( m_hEnemy ))
|
||||
{
|
||||
m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1;
|
||||
}
|
||||
|
||||
vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize();
|
||||
|
||||
if (pev->velocity.Length() < 0.1)
|
||||
vecFlightDir = vecDirToEnemy;
|
||||
else
|
||||
vecFlightDir = pev->velocity.Normalize();
|
||||
|
||||
// measure how far the turn is, the wider the turn, the slow we'll go this time.
|
||||
flDelta = DotProduct ( vecFlightDir, vecDirToEnemy );
|
||||
|
||||
if ( flDelta < 0.5 )
|
||||
{// hafta turn wide again. play sound
|
||||
switch (RANDOM_LONG(0,2))
|
||||
{
|
||||
case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED )
|
||||
{// no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far.
|
||||
flDelta = 0.25;
|
||||
}
|
||||
|
||||
pev->velocity = ( vecFlightDir + vecDirToEnemy).Normalize();
|
||||
|
||||
if ( pev->owner && (pev->owner->v.flags & FL_MONSTER) )
|
||||
{
|
||||
// random pattern only applies to hornets fired by monsters, not players.
|
||||
|
||||
pev->velocity.x += RANDOM_FLOAT ( -0.10, 0.10 );// scramble the flight dir a bit.
|
||||
pev->velocity.y += RANDOM_FLOAT ( -0.10, 0.10 );
|
||||
pev->velocity.z += RANDOM_FLOAT ( -0.10, 0.10 );
|
||||
}
|
||||
|
||||
switch ( m_iHornetType )
|
||||
{
|
||||
case HORNET_TYPE_RED:
|
||||
pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn )
|
||||
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 );
|
||||
break;
|
||||
case HORNET_TYPE_ORANGE:
|
||||
pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn.
|
||||
pev->nextthink = gpGlobals->time + 0.1;// fixed think time
|
||||
break;
|
||||
}
|
||||
|
||||
pev->angles = UTIL_VecToAngles (pev->velocity);
|
||||
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
// if hornet is close to the enemy, jet in a straight line for a half second.
|
||||
// (only in the single player game)
|
||||
if ( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
if ( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
|
||||
WRITE_BYTE( TE_SPRITE );
|
||||
WRITE_COORD( pev->origin.x); // pos
|
||||
WRITE_COORD( pev->origin.y);
|
||||
WRITE_COORD( pev->origin.z);
|
||||
WRITE_SHORT( iHornetPuff ); // model
|
||||
// WRITE_BYTE( 0 ); // life * 10
|
||||
WRITE_BYTE( 2 ); // size * 10
|
||||
WRITE_BYTE( 128 ); // brightness
|
||||
MESSAGE_END();
|
||||
|
||||
switch (RANDOM_LONG(0,2))
|
||||
{
|
||||
case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM); break;
|
||||
}
|
||||
pev->velocity = pev->velocity * 2;
|
||||
pev->nextthink = gpGlobals->time + 1.0;
|
||||
// don't attack again
|
||||
m_flStopAttack = gpGlobals->time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Tracking Hornet hit something
|
||||
//=========================================================
|
||||
void CHornet :: TrackTouch ( CBaseEntity *pOther )
|
||||
{
|
||||
if ( pOther->edict() == pev->owner || pOther->pev->modelindex == pev->modelindex )
|
||||
{// bumped into the guy that shot it.
|
||||
pev->solid = SOLID_NOT;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( IRelationship( pOther ) <= R_NO )
|
||||
{
|
||||
// hit something we don't want to hurt, so turn around.
|
||||
|
||||
pev->velocity = pev->velocity.Normalize();
|
||||
|
||||
pev->velocity.x *= -1;
|
||||
pev->velocity.y *= -1;
|
||||
|
||||
pev->origin = pev->origin + pev->velocity * 4; // bounce the hornet off a bit.
|
||||
pev->velocity = pev->velocity * m_flFlySpeed;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DieTouch( pOther );
|
||||
}
|
||||
|
||||
void CHornet::DartTouch( CBaseEntity *pOther )
|
||||
{
|
||||
DieTouch( pOther );
|
||||
}
|
||||
|
||||
void CHornet::DieTouch ( CBaseEntity *pOther )
|
||||
{
|
||||
if ( pOther && pOther->pev->takedamage )
|
||||
{// do the damage
|
||||
|
||||
switch (RANDOM_LONG(0,2))
|
||||
{// buzz when you plug someone
|
||||
case 0: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM); break;
|
||||
case 1: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM); break;
|
||||
case 2: EMIT_SOUND( ENT(pev), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM); break;
|
||||
}
|
||||
|
||||
pOther->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET );
|
||||
}
|
||||
|
||||
pev->modelindex = 0;// so will disappear for the 0.1 secs we wait until NEXTTHINK gets rid
|
||||
pev->solid = SOLID_NOT;
|
||||
|
||||
SetThink ( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 1;// stick around long enough for the sound to finish!
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// Hornets
|
||||
//=========================================================
|
||||
|
||||
//=========================================================
|
||||
// Hornet Defines
|
||||
//=========================================================
|
||||
#define HORNET_TYPE_RED 0
|
||||
#define HORNET_TYPE_ORANGE 1
|
||||
#define HORNET_RED_SPEED (float)600
|
||||
#define HORNET_ORANGE_SPEED (float)800
|
||||
#define HORNET_BUZZ_VOLUME (float)0.8
|
||||
|
||||
extern int iHornetPuff;
|
||||
|
||||
//=========================================================
|
||||
// Hornet - this is the projectile that the Alien Grunt fires.
|
||||
//=========================================================
|
||||
class CHornet : public CBaseMonster
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
int Classify ( void );
|
||||
int IRelationship ( CBaseEntity *pTarget );
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
void IgniteTrail( void );
|
||||
void EXPORT StartTrack ( void );
|
||||
void EXPORT StartDart ( void );
|
||||
void EXPORT TrackTarget ( void );
|
||||
void EXPORT TrackTouch ( CBaseEntity *pOther );
|
||||
void EXPORT DartTouch( CBaseEntity *pOther );
|
||||
void EXPORT DieTouch ( CBaseEntity *pOther );
|
||||
|
||||
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
|
||||
float m_flStopAttack;
|
||||
int m_iHornetType;
|
||||
float m_flFlySpeed;
|
||||
};
|
||||
|
|
@ -1,305 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "hornet.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
enum hgun_e {
|
||||
HGUN_IDLE1 = 0,
|
||||
HGUN_FIDGETSWAY,
|
||||
HGUN_FIDGETSHAKE,
|
||||
HGUN_DOWN,
|
||||
HGUN_UP,
|
||||
HGUN_SHOOT
|
||||
};
|
||||
|
||||
enum firemode_e
|
||||
{
|
||||
FIREMODE_TRACK = 0,
|
||||
FIREMODE_FAST
|
||||
};
|
||||
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_hornetgun, CHgun );
|
||||
|
||||
BOOL CHgun::IsUseable( void )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CHgun::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_HORNETGUN;
|
||||
SET_MODEL(ENT(pev), "models/w_hgun.mdl");
|
||||
|
||||
m_iDefaultAmmo = HIVEHAND_DEFAULT_GIVE;
|
||||
m_iFirePhase = 0;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CHgun::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_hgun.mdl");
|
||||
PRECACHE_MODEL("models/w_hgun.mdl");
|
||||
PRECACHE_MODEL("models/p_hgun.mdl");
|
||||
|
||||
m_usHornetFire = PRECACHE_EVENT ( 1, "events/firehornet.sc" );
|
||||
|
||||
UTIL_PrecacheOther("hornet");
|
||||
}
|
||||
|
||||
int CHgun::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// in multiplayer, all hivehands come full.
|
||||
pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] = HORNET_MAX_CARRY;
|
||||
}
|
||||
#endif
|
||||
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int CHgun::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "Hornets";
|
||||
p->iMaxAmmo1 = HORNET_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 3;
|
||||
p->iPosition = 3;
|
||||
p->iId = m_iId = WEAPON_HORNETGUN;
|
||||
p->iFlags = ITEM_FLAG_NOAUTOSWITCHEMPTY | ITEM_FLAG_NOAUTORELOAD;
|
||||
p->iWeight = HORNETGUN_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
BOOL CHgun::Deploy( )
|
||||
{
|
||||
return DefaultDeploy( "models/v_hgun.mdl", "models/p_hgun.mdl", HGUN_UP, "hive" );
|
||||
}
|
||||
|
||||
void CHgun::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
SendWeaponAnim( HGUN_DOWN );
|
||||
|
||||
//!!!HACKHACK - can't select hornetgun if it's empty! no way to get ammo for it, either.
|
||||
if ( !m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] )
|
||||
{
|
||||
m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHgun::PrimaryAttack()
|
||||
{
|
||||
Reload( );
|
||||
|
||||
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
|
||||
CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12, m_pPlayer->pev->v_angle, m_pPlayer->edict() );
|
||||
pHornet->pev->velocity = gpGlobals->v_forward * 300;
|
||||
|
||||
m_flRechargeTime = gpGlobals->time + 0.5;
|
||||
#endif
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_TRACK, 0, 0, 0 );
|
||||
|
||||
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25;
|
||||
|
||||
if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
|
||||
{
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25;
|
||||
}
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CHgun::SecondaryAttack( void )
|
||||
{
|
||||
Reload();
|
||||
|
||||
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Wouldn't be a bad idea to completely predict these, since they fly so fast...
|
||||
#ifndef CLIENT_DLL
|
||||
CBaseEntity *pHornet;
|
||||
Vector vecSrc;
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
|
||||
vecSrc = m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12;
|
||||
|
||||
m_iFirePhase++;
|
||||
switch ( m_iFirePhase )
|
||||
{
|
||||
case 1:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * 8;
|
||||
break;
|
||||
case 2:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * 8;
|
||||
vecSrc = vecSrc + gpGlobals->v_right * 8;
|
||||
break;
|
||||
case 3:
|
||||
vecSrc = vecSrc + gpGlobals->v_right * 8;
|
||||
break;
|
||||
case 4:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * -8;
|
||||
vecSrc = vecSrc + gpGlobals->v_right * 8;
|
||||
break;
|
||||
case 5:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * -8;
|
||||
break;
|
||||
case 6:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * -8;
|
||||
vecSrc = vecSrc + gpGlobals->v_right * -8;
|
||||
break;
|
||||
case 7:
|
||||
vecSrc = vecSrc + gpGlobals->v_right * -8;
|
||||
break;
|
||||
case 8:
|
||||
vecSrc = vecSrc + gpGlobals->v_up * 8;
|
||||
vecSrc = vecSrc + gpGlobals->v_right * -8;
|
||||
m_iFirePhase = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
pHornet = CBaseEntity::Create( "hornet", vecSrc, m_pPlayer->pev->v_angle, m_pPlayer->edict() );
|
||||
pHornet->pev->velocity = gpGlobals->v_forward * 1200;
|
||||
pHornet->pev->angles = UTIL_VecToAngles( pHornet->pev->velocity );
|
||||
|
||||
pHornet->SetThink( CHornet::StartDart );
|
||||
|
||||
m_flRechargeTime = gpGlobals->time + 0.5;
|
||||
#endif
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_FAST, 0, 0, 0 );
|
||||
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
|
||||
void CHgun::Reload( void )
|
||||
{
|
||||
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] >= HORNET_MAX_CARRY)
|
||||
return;
|
||||
|
||||
while (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time)
|
||||
{
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++;
|
||||
m_flRechargeTime += 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHgun::WeaponIdle( void )
|
||||
{
|
||||
Reload( );
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.75)
|
||||
{
|
||||
iAnim = HGUN_IDLE1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2);
|
||||
}
|
||||
else if (flRand <= 0.875)
|
||||
{
|
||||
iAnim = HGUN_FIDGETSWAY;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = HGUN_FIDGETSHAKE;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 35.0 / 16.0;
|
||||
}
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
|
||||
#endif
|
407
dlls/items.cpp
407
dlls/items.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,16 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== items.cpp ========================================================
|
||||
|
||||
functions governing the selection/use of weapons for players
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "weapons.h"
|
||||
#include "player.h"
|
||||
|
@ -29,14 +21,24 @@
|
|||
#include "items.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
extern int gmsgItemPickup;
|
||||
extern int gmsgArmorType;
|
||||
extern int gmsgStatusIcon;
|
||||
|
||||
class CWorldItem : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void KeyValue(KeyValueData *pkvd );
|
||||
void Spawn( void );
|
||||
int m_iType;
|
||||
void Spawn(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
|
||||
public:
|
||||
int m_iType;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(world_items, CWorldItem);
|
||||
|
@ -49,34 +51,22 @@ void CWorldItem::KeyValue(KeyValueData *pkvd)
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseEntity::KeyValue( pkvd );
|
||||
CBaseEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
void CWorldItem::Spawn( void )
|
||||
void CWorldItem::Spawn(void)
|
||||
{
|
||||
CBaseEntity *pEntity = NULL;
|
||||
|
||||
switch (m_iType)
|
||||
switch (m_iType)
|
||||
{
|
||||
case 44: // ITEM_BATTERY:
|
||||
pEntity = CBaseEntity::Create( "item_battery", pev->origin, pev->angles );
|
||||
break;
|
||||
case 42: // ITEM_ANTIDOTE:
|
||||
pEntity = CBaseEntity::Create( "item_antidote", pev->origin, pev->angles );
|
||||
break;
|
||||
case 43: // ITEM_SECURITY:
|
||||
pEntity = CBaseEntity::Create( "item_security", pev->origin, pev->angles );
|
||||
break;
|
||||
case 45: // ITEM_SUIT:
|
||||
pEntity = CBaseEntity::Create( "item_suit", pev->origin, pev->angles );
|
||||
break;
|
||||
case 44: pEntity = CBaseEntity::Create("item_battery", pev->origin, pev->angles); break;
|
||||
case 42: pEntity = CBaseEntity::Create("item_antidote", pev->origin, pev->angles); break;
|
||||
case 43: pEntity = CBaseEntity::Create("item_security", pev->origin, pev->angles); break;
|
||||
case 45: pEntity = CBaseEntity::Create("item_suit", pev->origin, pev->angles); break;
|
||||
}
|
||||
|
||||
if (!pEntity)
|
||||
{
|
||||
ALERT( at_console, "unable to create world_item %d\n", m_iType );
|
||||
}
|
||||
else
|
||||
if (pEntity)
|
||||
{
|
||||
pEntity->pev->target = pev->target;
|
||||
pEntity->pev->targetname = pev->targetname;
|
||||
|
@ -86,194 +76,163 @@ void CWorldItem::Spawn( void )
|
|||
REMOVE_ENTITY(edict());
|
||||
}
|
||||
|
||||
|
||||
void CItem::Spawn( void )
|
||||
void CItem::Spawn(void)
|
||||
{
|
||||
pev->movetype = MOVETYPE_TOSS;
|
||||
pev->solid = SOLID_TRIGGER;
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
|
||||
SetTouch(ItemTouch);
|
||||
SetTouch(&CItem::ItemTouch);
|
||||
|
||||
if (DROP_TO_FLOOR(ENT(pev)) == 0)
|
||||
{
|
||||
ALERT(at_error, "Item %s fell out of level at %f,%f,%f", STRING( pev->classname ), pev->origin.x, pev->origin.y, pev->origin.z);
|
||||
UTIL_Remove( this );
|
||||
UTIL_Remove(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern int gEvilImpulse101;
|
||||
|
||||
void CItem::ItemTouch( CBaseEntity *pOther )
|
||||
void CItem::ItemTouch(CBaseEntity *pOther)
|
||||
{
|
||||
// if it's not a player, ignore
|
||||
if ( !pOther->IsPlayer() )
|
||||
{
|
||||
if (!pOther->IsPlayer())
|
||||
return;
|
||||
}
|
||||
|
||||
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
|
||||
|
||||
// ok, a player is touching this item, but can he have it?
|
||||
if ( !g_pGameRules->CanHaveItem( pPlayer, this ) )
|
||||
{
|
||||
// no? Ignore the touch.
|
||||
if (!g_pGameRules->CanHaveItem(pPlayer, this))
|
||||
return;
|
||||
}
|
||||
|
||||
if (MyTouch( pPlayer ))
|
||||
if (MyTouch(pPlayer))
|
||||
{
|
||||
SUB_UseTargets( pOther, USE_TOGGLE, 0 );
|
||||
ResetTouch( );
|
||||
|
||||
// player grabbed the item.
|
||||
g_pGameRules->PlayerGotItem( pPlayer, this );
|
||||
if ( g_pGameRules->ItemShouldRespawn( this ) == GR_ITEM_RESPAWN_YES )
|
||||
{
|
||||
Respawn();
|
||||
}
|
||||
SUB_UseTargets(pOther, USE_TOGGLE, 0);
|
||||
SetTouch(NULL);
|
||||
g_pGameRules->PlayerGotItem(pPlayer, this);
|
||||
|
||||
if (g_pGameRules->ItemShouldRespawn(this) == GR_ITEM_RESPAWN_YES)
|
||||
Respawn();
|
||||
else
|
||||
{
|
||||
UTIL_Remove( this );
|
||||
}
|
||||
UTIL_Remove(this);
|
||||
}
|
||||
else if (gEvilImpulse101)
|
||||
{
|
||||
UTIL_Remove( this );
|
||||
}
|
||||
UTIL_Remove(this);
|
||||
}
|
||||
|
||||
CBaseEntity* CItem::Respawn( void )
|
||||
CBaseEntity *CItem::Respawn(void)
|
||||
{
|
||||
ResetTouch( );
|
||||
SetTouch(NULL);
|
||||
pev->effects |= EF_NODRAW;
|
||||
|
||||
UTIL_SetOrigin( pev, g_pGameRules->VecItemRespawnSpot( this ) );// blip to whereever you should respawn.
|
||||
|
||||
SetThink ( Materialize );
|
||||
pev->nextthink = g_pGameRules->FlItemRespawnTime( this );
|
||||
UTIL_SetOrigin(pev, g_pGameRules->VecItemRespawnSpot(this));
|
||||
SetThink(&CItem::Materialize);
|
||||
pev->nextthink = g_pGameRules->FlItemRespawnTime(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
void CItem::Materialize( void )
|
||||
void CItem::Materialize(void)
|
||||
{
|
||||
if ( pev->effects & EF_NODRAW )
|
||||
if (pev->effects & EF_NODRAW)
|
||||
{
|
||||
// changing from invisible state to visible.
|
||||
EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 );
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", VOL_NORM, ATTN_NORM, 0, 150);
|
||||
pev->effects &= ~EF_NODRAW;
|
||||
pev->effects |= EF_MUZZLEFLASH;
|
||||
}
|
||||
|
||||
SetTouch( ItemTouch );
|
||||
SetTouch(&CItem::ItemTouch);
|
||||
}
|
||||
|
||||
#define SF_SUIT_SHORTLOGON 0x0001
|
||||
#define SF_SUIT_SHORTLOGON 0x0001
|
||||
|
||||
class CItemSuit : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_suit.mdl");
|
||||
CItem::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
void Spawn(void)
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_suit.mdl");
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_kevlar.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
BOOL MyTouch( CBasePlayer *pPlayer )
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
if ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) )
|
||||
PRECACHE_MODEL("models/w_kevlar.mdl");
|
||||
PRECACHE_SOUND("items/tr_kevlar.wav");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if (pPlayer->pev->weapons & (1 << WEAPON_SUIT))
|
||||
return FALSE;
|
||||
|
||||
if ( pev->spawnflags & SF_SUIT_SHORTLOGON )
|
||||
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_A0"); // short version of suit logon,
|
||||
else
|
||||
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_AAx"); // long version of suit logon
|
||||
|
||||
pPlayer->pev->weapons |= (1<<WEAPON_SUIT);
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_VOICE, "items/tr_kevlar.wav", VOL_NORM, ATTN_NORM);
|
||||
pPlayer->pev->weapons |= (1 << WEAPON_SUIT);
|
||||
pPlayer->m_iHideHUD &= ~HIDEHUD_HEALTH;
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_suit, CItemSuit);
|
||||
|
||||
|
||||
|
||||
class CItemBattery : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
void Spawn(void)
|
||||
{
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_battery.mdl");
|
||||
CItem::Spawn( );
|
||||
CItem::Spawn();
|
||||
}
|
||||
void Precache( void )
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_battery.mdl");
|
||||
PRECACHE_SOUND( "items/gunpickup2.wav" );
|
||||
PRECACHE_MODEL("models/w_battery.mdl");
|
||||
PRECACHE_SOUND("items/gunpickup2.wav");
|
||||
}
|
||||
BOOL MyTouch( CBasePlayer *pPlayer )
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if ( pPlayer->pev->deadflag != DEAD_NO )
|
||||
if (pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY && (pPlayer->pev->weapons & (1 << WEAPON_SUIT)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) &&
|
||||
(pPlayer->pev->weapons & (1<<WEAPON_SUIT)))
|
||||
{
|
||||
int pct;
|
||||
char szcharge[64];
|
||||
|
||||
pPlayer->pev->armorvalue += gSkillData.batteryCapacity;
|
||||
pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY);
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
|
||||
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
|
||||
WRITE_STRING( STRING(pev->classname) );
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
|
||||
WRITE_STRING(STRING(pev->classname));
|
||||
MESSAGE_END();
|
||||
|
||||
|
||||
// Suit reports new power level
|
||||
// For some reason this wasn't working in release build -- round it.
|
||||
pct = (int)( (float)(pPlayer->pev->armorvalue * 100.0) * (1.0/MAX_NORMAL_BATTERY) + 0.5);
|
||||
int pct = (int)((float)(pPlayer->pev->armorvalue * 100) * (1.0 / MAX_NORMAL_BATTERY) + 0.5);
|
||||
pct = (pct / 5);
|
||||
|
||||
if (pct > 0)
|
||||
pct--;
|
||||
|
||||
sprintf( szcharge,"!HEV_%1dP", pct );
|
||||
|
||||
//EMIT_SOUND_SUIT(ENT(pev), szcharge);
|
||||
|
||||
char szcharge[64];
|
||||
sprintf(szcharge, "!HEV_%1dP", pct);
|
||||
pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC);
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_battery, CItemBattery);
|
||||
|
||||
|
||||
class CItemAntidote : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_antidote.mdl");
|
||||
CItem::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
void Spawn(void)
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_antidote.mdl");
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_antidote.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
BOOL MyTouch( CBasePlayer *pPlayer )
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_antidote.mdl");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
pPlayer->SetSuitUpdate("!HEV_DET4", FALSE, SUIT_NEXT_IN_1MIN);
|
||||
|
||||
pPlayer->m_rgItems[ITEM_ANTIDOTE] += 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -281,20 +240,21 @@ class CItemAntidote : public CItem
|
|||
|
||||
LINK_ENTITY_TO_CLASS(item_antidote, CItemAntidote);
|
||||
|
||||
|
||||
class CItemSecurity : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_security.mdl");
|
||||
CItem::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
void Spawn(void)
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_security.mdl");
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_security.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
BOOL MyTouch( CBasePlayer *pPlayer )
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_security.mdl");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
pPlayer->m_rgItems[ITEM_SECURITY] += 1;
|
||||
return TRUE;
|
||||
|
@ -305,38 +265,147 @@ LINK_ENTITY_TO_CLASS(item_security, CItemSecurity);
|
|||
|
||||
class CItemLongJump : public CItem
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
void Spawn(void)
|
||||
{
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_longjump.mdl");
|
||||
CItem::Spawn( );
|
||||
CItem::Spawn();
|
||||
}
|
||||
void Precache( void )
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_longjump.mdl");
|
||||
PRECACHE_MODEL("models/w_longjump.mdl");
|
||||
}
|
||||
BOOL MyTouch( CBasePlayer *pPlayer )
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if ( pPlayer->m_fLongJump )
|
||||
{
|
||||
if (pPlayer->m_fLongJump)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ( pPlayer->pev->weapons & (1<<WEAPON_SUIT) ) )
|
||||
if (pPlayer->pev->weapons & (1 << WEAPON_SUIT))
|
||||
{
|
||||
pPlayer->m_fLongJump = TRUE;// player now has longjump module
|
||||
pPlayer->m_fLongJump = TRUE;
|
||||
g_engfuncs.pfnSetPhysicsKeyValue(pPlayer->edict(), "slj", "1");
|
||||
|
||||
g_engfuncs.pfnSetPhysicsKeyValue( pPlayer->edict(), "slj", "1" );
|
||||
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
|
||||
WRITE_STRING( STRING(pev->classname) );
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
|
||||
WRITE_STRING(STRING(pev->classname));
|
||||
MESSAGE_END();
|
||||
|
||||
EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A1" ); // Play the longjump sound UNDONE: Kelly? correct sound?
|
||||
return TRUE;
|
||||
EMIT_SOUND_SUIT(pPlayer->edict(), "!HEV_A1");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump );
|
||||
LINK_ENTITY_TO_CLASS(item_longjump, CItemLongJump);
|
||||
|
||||
class CItemKevlar : public CItem
|
||||
{
|
||||
void Spawn(void)
|
||||
{
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_kevlar.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_kevlar.mdl");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if (pPlayer->m_iKevlar == 0)
|
||||
pPlayer->m_iKevlar = 1;
|
||||
|
||||
pPlayer->pev->armorvalue = 100;
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
|
||||
WRITE_STRING(STRING(pev->classname));
|
||||
MESSAGE_END();
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev);
|
||||
WRITE_BYTE(0);
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_kevlar, CItemKevlar);
|
||||
|
||||
class CItemAssaultSuit : public CItem
|
||||
{
|
||||
void Spawn(void)
|
||||
{
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_assault.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_assault.mdl");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
pPlayer->m_iKevlar = 2;
|
||||
pPlayer->pev->armorvalue = 100;
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
|
||||
WRITE_STRING(STRING(pev->classname));
|
||||
MESSAGE_END();
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgArmorType, NULL, pPlayer->pev);
|
||||
WRITE_BYTE(1);
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_assaultsuit, CItemAssaultSuit);
|
||||
|
||||
class CItemThighPack : public CItem
|
||||
{
|
||||
void Spawn(void)
|
||||
{
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_thighpack.mdl");
|
||||
CItem::Spawn();
|
||||
}
|
||||
|
||||
void Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/w_thighpack.mdl");
|
||||
}
|
||||
|
||||
BOOL MyTouch(CBasePlayer *pPlayer)
|
||||
{
|
||||
if (pPlayer->m_iTeam != TEAM_CT)
|
||||
return FALSE;
|
||||
|
||||
if (pPlayer->m_bHasDefuser)
|
||||
return FALSE;
|
||||
|
||||
pPlayer->m_bHasDefuser = true;
|
||||
pPlayer->pev->body = 1;
|
||||
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_defuser");
|
||||
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev);
|
||||
WRITE_BYTE(STATUSICON_SHOW);
|
||||
WRITE_STRING("defuser");
|
||||
WRITE_BYTE(0);
|
||||
WRITE_BYTE(160);
|
||||
WRITE_BYTE(0);
|
||||
MESSAGE_END();
|
||||
|
||||
EMIT_SOUND(pPlayer->edict(), CHAN_VOICE, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(item_thighpack, CItemThighPack);
|
||||
|
|
21
dlls/items.h
21
dlls/items.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,15 +15,16 @@
|
|||
#ifndef ITEMS_H
|
||||
#define ITEMS_H
|
||||
|
||||
|
||||
class CItem : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
CBaseEntity* Respawn( void );
|
||||
void EXPORT ItemTouch( CBaseEntity *pOther );
|
||||
void EXPORT Materialize( void );
|
||||
virtual BOOL MyTouch( CBasePlayer *pPlayer ) { return FALSE; };
|
||||
virtual void Spawn(void);
|
||||
virtual CBaseEntity *Respawn(void);
|
||||
virtual BOOL MyTouch(CBasePlayer *pPlayer) { return FALSE; }
|
||||
|
||||
public:
|
||||
void EXPORT ItemTouch(CBaseEntity *pOther);
|
||||
void EXPORT Materialize(void);
|
||||
};
|
||||
|
||||
#endif // ITEMS_H
|
||||
#endif
|
177
dlls/lights.cpp
177
dlls/lights.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,51 +12,40 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== lights.cpp ========================================================
|
||||
|
||||
spawn and think functions for editor-placed lights
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
|
||||
|
||||
|
||||
class CLight : public CPointEntity
|
||||
{
|
||||
public:
|
||||
virtual void KeyValue( KeyValueData* pkvd );
|
||||
virtual void Spawn( void );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Spawn(void);
|
||||
void Restart(void);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
private:
|
||||
int m_iStyle;
|
||||
int m_iszPattern;
|
||||
int m_iStyle;
|
||||
int m_iszPattern;
|
||||
BOOL m_bStartOff;
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( light, CLight );
|
||||
|
||||
TYPEDESCRIPTION CLight::m_SaveData[] =
|
||||
LINK_ENTITY_TO_CLASS(light, CLight);
|
||||
|
||||
TYPEDESCRIPTION CLight::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CLight, m_iStyle, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CLight, m_iszPattern, FIELD_STRING ),
|
||||
DEFINE_FIELD(CLight, m_iStyle, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CLight, m_iszPattern, FIELD_STRING),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CLight, CPointEntity );
|
||||
IMPLEMENT_SAVERESTORE(CLight, CPointEntity);
|
||||
|
||||
|
||||
//
|
||||
// Cache user-entity-field values until spawn is called.
|
||||
//
|
||||
void CLight :: KeyValue( KeyValueData* pkvd)
|
||||
void CLight::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "style"))
|
||||
{
|
||||
|
@ -70,56 +59,72 @@ void CLight :: KeyValue( KeyValueData* pkvd)
|
|||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "pattern"))
|
||||
{
|
||||
m_iszPattern = ALLOC_STRING( pkvd->szValue );
|
||||
m_iszPattern = ALLOC_STRING(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CPointEntity::KeyValue( pkvd );
|
||||
}
|
||||
CPointEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
/*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) LIGHT_START_OFF
|
||||
Non-displayed light.
|
||||
Default light value is 300
|
||||
Default style is 0
|
||||
If targeted, it will toggle between on or off.
|
||||
*/
|
||||
|
||||
void CLight :: Spawn( void )
|
||||
void CLight::Spawn(void)
|
||||
{
|
||||
if (FStringNull(pev->targetname))
|
||||
{ // inert light
|
||||
{
|
||||
REMOVE_ENTITY(ENT(pev));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF))
|
||||
m_bStartOff = TRUE;
|
||||
else
|
||||
m_bStartOff = FALSE;
|
||||
|
||||
if (m_iStyle >= 32)
|
||||
{
|
||||
// CHANGE_METHOD(ENT(pev), em_use, light_use);
|
||||
if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF))
|
||||
LIGHT_STYLE(m_iStyle, "a");
|
||||
else if (m_iszPattern)
|
||||
LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern ));
|
||||
LIGHT_STYLE(m_iStyle, (char *)STRING(m_iszPattern));
|
||||
else
|
||||
LIGHT_STYLE(m_iStyle, "m");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void CLight::Restart(void)
|
||||
{
|
||||
if (m_iStyle >= 32)
|
||||
{
|
||||
if ( !ShouldToggle( useType, !FBitSet(pev->spawnflags, SF_LIGHT_START_OFF) ) )
|
||||
if (m_bStartOff)
|
||||
{
|
||||
SetBits(pev->spawnflags, SF_LIGHT_START_OFF);
|
||||
LIGHT_STYLE(m_iStyle, "a");
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBits(pev->spawnflags, SF_LIGHT_START_OFF);
|
||||
|
||||
if (m_iszPattern)
|
||||
LIGHT_STYLE(m_iStyle, (char *)STRING(m_iszPattern));
|
||||
else
|
||||
LIGHT_STYLE(m_iStyle, "m");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CLight::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
if (m_iStyle >= 32)
|
||||
{
|
||||
if (!ShouldToggle(useType, !FBitSet(pev->spawnflags, SF_LIGHT_START_OFF)))
|
||||
return;
|
||||
|
||||
if (FBitSet(pev->spawnflags, SF_LIGHT_START_OFF))
|
||||
{
|
||||
if (m_iszPattern)
|
||||
LIGHT_STYLE(m_iStyle, (char *)STRING( m_iszPattern ));
|
||||
LIGHT_STYLE(m_iStyle, (char *)STRING(m_iszPattern));
|
||||
else
|
||||
LIGHT_STYLE(m_iStyle, "m");
|
||||
|
||||
ClearBits(pev->spawnflags, SF_LIGHT_START_OFF);
|
||||
}
|
||||
else
|
||||
|
@ -130,28 +135,24 @@ void CLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// shut up spawn functions for new spotlights
|
||||
//
|
||||
LINK_ENTITY_TO_CLASS( light_spot, CLight );
|
||||
|
||||
LINK_ENTITY_TO_CLASS(light_spot, CLight);
|
||||
|
||||
class CEnvLight : public CLight
|
||||
{
|
||||
public:
|
||||
void KeyValue( KeyValueData* pkvd );
|
||||
void Spawn( void );
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
void Spawn(void);
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( light_environment, CEnvLight );
|
||||
LINK_ENTITY_TO_CLASS(light_environment, CEnvLight);
|
||||
|
||||
void CEnvLight::KeyValue( KeyValueData* pkvd )
|
||||
void CEnvLight::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "_light"))
|
||||
{
|
||||
int r, g, b, v, j;
|
||||
char szColor[64];
|
||||
j = sscanf( pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v );
|
||||
j = sscanf(pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v);
|
||||
|
||||
if (j == 1)
|
||||
{
|
||||
g = b = r;
|
||||
|
@ -163,37 +164,33 @@ void CEnvLight::KeyValue( KeyValueData* pkvd )
|
|||
b = b * (v / 255.0);
|
||||
}
|
||||
|
||||
// simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling
|
||||
r = pow( r / 114.0, 0.6 ) * 264;
|
||||
g = pow( g / 114.0, 0.6 ) * 264;
|
||||
b = pow( b / 114.0, 0.6 ) * 264;
|
||||
|
||||
r = (int)(powf(r / 114.0, 0.6) * 264);
|
||||
g = (int)(powf(g / 114.0, 0.6) * 264);
|
||||
b = (int)(powf(b / 114.0, 0.6) * 264);
|
||||
pkvd->fHandled = TRUE;
|
||||
sprintf( szColor, "%d", r );
|
||||
CVAR_SET_STRING( "sv_skycolor_r", szColor );
|
||||
sprintf( szColor, "%d", g );
|
||||
CVAR_SET_STRING( "sv_skycolor_g", szColor );
|
||||
sprintf( szColor, "%d", b );
|
||||
CVAR_SET_STRING( "sv_skycolor_b", szColor );
|
||||
|
||||
char szColor[64];
|
||||
sprintf(szColor, "%d", r);
|
||||
CVAR_SET_STRING("sv_skycolor_r", szColor);
|
||||
sprintf(szColor, "%d", g);
|
||||
CVAR_SET_STRING("sv_skycolor_g", szColor);
|
||||
sprintf(szColor, "%d", b);
|
||||
CVAR_SET_STRING("sv_skycolor_b", szColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLight::KeyValue( pkvd );
|
||||
}
|
||||
CLight::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
|
||||
void CEnvLight :: Spawn( void )
|
||||
void CEnvLight::Spawn(void)
|
||||
{
|
||||
char szVector[64];
|
||||
UTIL_MakeAimVectors( pev->angles );
|
||||
UTIL_MakeAimVectors(pev->angles);
|
||||
|
||||
sprintf( szVector, "%f", gpGlobals->v_forward.x );
|
||||
CVAR_SET_STRING( "sv_skyvec_x", szVector );
|
||||
sprintf( szVector, "%f", gpGlobals->v_forward.y );
|
||||
CVAR_SET_STRING( "sv_skyvec_y", szVector );
|
||||
sprintf( szVector, "%f", gpGlobals->v_forward.z );
|
||||
CVAR_SET_STRING( "sv_skyvec_z", szVector );
|
||||
|
||||
CLight::Spawn( );
|
||||
}
|
||||
sprintf(szVector, "%f", gpGlobals->v_forward.x);
|
||||
CVAR_SET_STRING("sv_skyvec_x", szVector);
|
||||
sprintf(szVector, "%f", gpGlobals->v_forward.y);
|
||||
CVAR_SET_STRING("sv_skyvec_y", szVector);
|
||||
sprintf(szVector, "%f", gpGlobals->v_forward.z);
|
||||
CVAR_SET_STRING("sv_skyvec_z", szVector);
|
||||
CLight::Spawn();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,11 +12,7 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef MAPRULES_H
|
||||
#define MAPRULES_H
|
||||
|
||||
|
||||
|
||||
#endif // MAPRULES_H
|
||||
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -17,18 +17,18 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
int event;
|
||||
char *options;
|
||||
} MonsterEvent_t;
|
||||
int event;
|
||||
char *options;
|
||||
}
|
||||
MonsterEvent_t;
|
||||
|
||||
#define EVENT_SPECIFIC 0
|
||||
#define EVENT_SCRIPTED 1000
|
||||
#define EVENT_SHARED 2000
|
||||
#define EVENT_CLIENT 5000
|
||||
#define EVENT_SPECIFIC 0
|
||||
#define EVENT_SCRIPTED 1000
|
||||
#define EVENT_SHARED 2000
|
||||
#define EVENT_CLIENT 5000
|
||||
|
||||
#define MONSTER_EVENT_BODYDROP_LIGHT 2001
|
||||
#define MONSTER_EVENT_BODYDROP_HEAVY 2002
|
||||
#define MONSTER_EVENT_BODYDROP_LIGHT 2001
|
||||
#define MONSTER_EVENT_BODYDROP_HEAVY 2002
|
||||
#define MONSTER_EVENT_SWISHSOUND 2010
|
||||
|
||||
#define MONSTER_EVENT_SWISHSOUND 2010
|
||||
|
||||
#endif // MONSTEREVENT_H
|
||||
#endif
|
186
dlls/monsters.h
186
dlls/monsters.h
|
@ -1,94 +1,94 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef MONSTERS_H
|
||||
#include "skill.h"
|
||||
#define MONSTERS_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HITGROUP_GENERIC,
|
||||
HITGROUP_HEAD,
|
||||
HITGROUP_CHEST,
|
||||
HITGROUP_STOMACH,
|
||||
HITGROUP_LEFTARM,
|
||||
HITGROUP_RIGHTARM,
|
||||
HITGROUP_LEFTLEG,
|
||||
HITGROUP_RIGHTLEG,
|
||||
HITGROUP_SHIELD,
|
||||
NUM_HITGROUPS
|
||||
}
|
||||
HitBoxGroup;
|
||||
|
||||
#define SF_MONSTER_WAIT_TILL_SEEN 1
|
||||
#define SF_MONSTER_GAG 2
|
||||
#define SF_MONSTER_HITMONSTERCLIP 4
|
||||
#define SF_MONSTER_PRISONER 16
|
||||
#define SF_MONSTER_WAIT_FOR_SCRIPT 128
|
||||
#define SF_MONSTER_PREDISASTER 256
|
||||
#define SF_MONSTER_FADECORPSE 512
|
||||
#define SF_MONSTER_FALL_TO_GROUND 0x80000000
|
||||
#define SF_MONSTER_TURRET_AUTOACTIVATE 32
|
||||
#define SF_MONSTER_TURRET_STARTINACTIVE 64
|
||||
|
||||
extern void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist, int iMoveType);
|
||||
Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1);
|
||||
Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1);
|
||||
|
||||
extern DLL_GLOBAL Vector g_vecAttackDir;
|
||||
extern DLL_GLOBAL CONSTANT float g_flMeleeRange;
|
||||
extern DLL_GLOBAL CONSTANT float g_flMediumRange;
|
||||
extern DLL_GLOBAL CONSTANT float g_flLongRange;
|
||||
|
||||
extern void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex);
|
||||
extern void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev);
|
||||
extern void ExplodeModel(const Vector &vecOrigin, float speed, int model, int count);
|
||||
|
||||
BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget);
|
||||
BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0);
|
||||
|
||||
#define R_AL -2
|
||||
#define R_FR -1
|
||||
#define R_NO 0
|
||||
#define R_DL 1
|
||||
#define R_HT 2
|
||||
#define R_NM 3
|
||||
|
||||
#define bits_MEMORY_KILLED (1<<7)
|
||||
|
||||
class CGib : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn(const char *szGibModel);
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; }
|
||||
|
||||
public:
|
||||
void EXPORT BounceGibTouch(CBaseEntity *pOther);
|
||||
void EXPORT StickyGibTouch(CBaseEntity *pOther);
|
||||
void EXPORT WaitTillLand(void);
|
||||
void LimitVelocity(void);
|
||||
|
||||
public:
|
||||
static void SpawnHeadGib(entvars_t *pevVictim);
|
||||
static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human);
|
||||
static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs);
|
||||
|
||||
public:
|
||||
int m_bloodColor;
|
||||
int m_cBloodDecals;
|
||||
int m_material;
|
||||
float m_lifeTime;
|
||||
};
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#ifndef MONSTERS_H
|
||||
#include "skill.h"
|
||||
#define MONSTERS_H
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HITGROUP_GENERIC,
|
||||
HITGROUP_HEAD,
|
||||
HITGROUP_CHEST,
|
||||
HITGROUP_STOMACH,
|
||||
HITGROUP_LEFTARM,
|
||||
HITGROUP_RIGHTARM,
|
||||
HITGROUP_LEFTLEG,
|
||||
HITGROUP_RIGHTLEG,
|
||||
HITGROUP_SHIELD,
|
||||
NUM_HITGROUPS
|
||||
}
|
||||
HitBoxGroup;
|
||||
|
||||
#define SF_MONSTER_WAIT_TILL_SEEN 1
|
||||
#define SF_MONSTER_GAG 2
|
||||
#define SF_MONSTER_HITMONSTERCLIP 4
|
||||
#define SF_MONSTER_PRISONER 16
|
||||
#define SF_MONSTER_WAIT_FOR_SCRIPT 128
|
||||
#define SF_MONSTER_PREDISASTER 256
|
||||
#define SF_MONSTER_FADECORPSE 512
|
||||
#define SF_MONSTER_FALL_TO_GROUND 0x80000000
|
||||
#define SF_MONSTER_TURRET_AUTOACTIVATE 32
|
||||
#define SF_MONSTER_TURRET_STARTINACTIVE 64
|
||||
|
||||
extern void UTIL_MoveToOrigin(edict_t *pent, const Vector &vecGoal, float flDist, int iMoveType);
|
||||
Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1);
|
||||
Vector VecCheckThrow(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1);
|
||||
|
||||
extern DLL_GLOBAL Vector g_vecAttackDir;
|
||||
extern DLL_GLOBAL CONSTANT float g_flMeleeRange;
|
||||
extern DLL_GLOBAL CONSTANT float g_flMediumRange;
|
||||
extern DLL_GLOBAL CONSTANT float g_flLongRange;
|
||||
|
||||
extern void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &vecVelocity, float rotation, int model, int soundtype, int entityIndex);
|
||||
extern void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev);
|
||||
extern void ExplodeModel(const Vector &vecOrigin, float speed, int model, int count);
|
||||
|
||||
BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget);
|
||||
BOOL FBoxVisible(entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0);
|
||||
|
||||
#define R_AL -2
|
||||
#define R_FR -1
|
||||
#define R_NO 0
|
||||
#define R_DL 1
|
||||
#define R_HT 2
|
||||
#define R_NM 3
|
||||
|
||||
#define bits_MEMORY_KILLED (1<<7)
|
||||
|
||||
class CGib : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn(const char *szGibModel);
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; }
|
||||
|
||||
public:
|
||||
void EXPORT BounceGibTouch(CBaseEntity *pOther);
|
||||
void EXPORT StickyGibTouch(CBaseEntity *pOther);
|
||||
void EXPORT WaitTillLand(void);
|
||||
void LimitVelocity(void);
|
||||
|
||||
public:
|
||||
static void SpawnHeadGib(entvars_t *pevVictim);
|
||||
static void SpawnRandomGibs(entvars_t *pevVictim, int cGibs, int human);
|
||||
static void SpawnStickyGibs(entvars_t *pevVictim, Vector vecOrigin, int cGibs);
|
||||
|
||||
public:
|
||||
int m_bloodColor;
|
||||
int m_cBloodDecals;
|
||||
int m_material;
|
||||
float m_lifeTime;
|
||||
};
|
||||
|
||||
#endif
|
303
dlls/mortar.cpp
303
dlls/mortar.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,16 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== mortar.cpp ========================================================
|
||||
|
||||
the "LaBuznik" mortar device
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "saverestore.h"
|
||||
#include "weapons.h"
|
||||
|
@ -31,44 +23,43 @@
|
|||
class CFuncMortarField : public CBaseToggle
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
int ObjectCaps(void) { return CBaseToggle::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
// Bmodels don't go across transitions
|
||||
virtual int ObjectCaps( void ) { return CBaseToggle :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
|
||||
public:
|
||||
void EXPORT FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
public:
|
||||
int m_iszXController;
|
||||
int m_iszYController;
|
||||
float m_flSpread;
|
||||
float m_flDelay;
|
||||
//float m_flDelay; //Already exists in CBaseDelay
|
||||
int m_iCount;
|
||||
int m_fControl;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( func_mortar_field, CFuncMortarField );
|
||||
LINK_ENTITY_TO_CLASS(func_mortar_field, CFuncMortarField);
|
||||
|
||||
TYPEDESCRIPTION CFuncMortarField::m_SaveData[] =
|
||||
TYPEDESCRIPTION CFuncMortarField::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CFuncMortarField, m_iszXController, FIELD_STRING ),
|
||||
DEFINE_FIELD( CFuncMortarField, m_iszYController, FIELD_STRING ),
|
||||
DEFINE_FIELD( CFuncMortarField, m_flSpread, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CFuncMortarField, m_flDelay, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CFuncMortarField, m_iCount, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CFuncMortarField, m_fControl, FIELD_INTEGER ),
|
||||
DEFINE_FIELD(CFuncMortarField, m_iszXController, FIELD_STRING),
|
||||
DEFINE_FIELD(CFuncMortarField, m_iszYController, FIELD_STRING),
|
||||
DEFINE_FIELD(CFuncMortarField, m_flSpread, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CFuncMortarField, m_flDelay, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CFuncMortarField, m_iCount, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CFuncMortarField, m_fControl, FIELD_INTEGER),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CFuncMortarField, CBaseToggle );
|
||||
IMPLEMENT_SAVERESTORE(CFuncMortarField, CBaseToggle);
|
||||
|
||||
|
||||
void CFuncMortarField :: KeyValue( KeyValueData *pkvd )
|
||||
void CFuncMortarField::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "m_iszXController"))
|
||||
{
|
||||
|
@ -97,227 +88,149 @@ void CFuncMortarField :: KeyValue( KeyValueData *pkvd )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Drop bombs from above
|
||||
void CFuncMortarField :: Spawn( void )
|
||||
void CFuncMortarField::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
SET_MODEL(ENT(pev), STRING(pev->model)); // set size and link into world
|
||||
SET_MODEL(ENT(pev), STRING(pev->model));
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
SetBits( pev->effects, EF_NODRAW );
|
||||
SetUse( FieldUse );
|
||||
SetBits(pev->effects, EF_NODRAW);
|
||||
SetUse(&CFuncMortarField::FieldUse);
|
||||
Precache();
|
||||
}
|
||||
|
||||
|
||||
void CFuncMortarField :: Precache( void )
|
||||
void CFuncMortarField::Precache(void)
|
||||
{
|
||||
PRECACHE_SOUND ("weapons/mortar.wav");
|
||||
PRECACHE_SOUND ("weapons/mortarhit.wav");
|
||||
PRECACHE_MODEL( "sprites/lgtning.spr" );
|
||||
PRECACHE_SOUND("weapons/mortar.wav");
|
||||
PRECACHE_SOUND("weapons/mortarhit.wav");
|
||||
PRECACHE_MODEL("sprites/lgtning.spr");
|
||||
}
|
||||
|
||||
|
||||
// If connected to a table, then use the table controllers, else hit where the trigger is.
|
||||
void CFuncMortarField :: FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void CFuncMortarField::FieldUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
Vector vecStart;
|
||||
|
||||
vecStart.x = RANDOM_FLOAT( pev->mins.x, pev->maxs.x );
|
||||
vecStart.y = RANDOM_FLOAT( pev->mins.y, pev->maxs.y );
|
||||
vecStart.x = RANDOM_FLOAT(pev->mins.x, pev->maxs.x);
|
||||
vecStart.y = RANDOM_FLOAT(pev->mins.y, pev->maxs.y);
|
||||
vecStart.z = pev->maxs.z;
|
||||
|
||||
switch( m_fControl )
|
||||
switch (m_fControl)
|
||||
{
|
||||
case 0: // random
|
||||
break;
|
||||
case 1: // Trigger Activator
|
||||
if (pActivator != NULL)
|
||||
case 0: break;
|
||||
case 1:
|
||||
{
|
||||
vecStart.x = pActivator->pev->origin.x;
|
||||
vecStart.y = pActivator->pev->origin.y;
|
||||
if (pActivator != NULL)
|
||||
{
|
||||
vecStart.x = pActivator->pev->origin.x;
|
||||
vecStart.y = pActivator->pev->origin.y;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2: // table
|
||||
|
||||
case 2:
|
||||
{
|
||||
CBaseEntity *pController;
|
||||
|
||||
if (!FStringNull(m_iszXController))
|
||||
{
|
||||
pController = UTIL_FindEntityByTargetname( NULL, STRING(m_iszXController));
|
||||
if (pController != NULL)
|
||||
{
|
||||
pController = UTIL_FindEntityByTargetname(NULL, STRING(m_iszXController));
|
||||
|
||||
if (pController)
|
||||
vecStart.x = pev->mins.x + pController->pev->ideal_yaw * (pev->size.x);
|
||||
}
|
||||
}
|
||||
|
||||
if (!FStringNull(m_iszYController))
|
||||
{
|
||||
pController = UTIL_FindEntityByTargetname( NULL, STRING(m_iszYController));
|
||||
if (pController != NULL)
|
||||
{
|
||||
pController = UTIL_FindEntityByTargetname(NULL, STRING(m_iszYController));
|
||||
|
||||
if (pController)
|
||||
vecStart.y = pev->mins.y + pController->pev->ideal_yaw * (pev->size.y);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int pitch = RANDOM_LONG(95,124);
|
||||
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortar.wav", 1.0, ATTN_NONE, 0, pitch);
|
||||
|
||||
int pitch = RANDOM_LONG(95, 124);
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortar.wav", VOL_NORM, ATTN_NONE, 0, pitch);
|
||||
float t = 2.5;
|
||||
|
||||
for (int i = 0; i < m_iCount; i++)
|
||||
{
|
||||
Vector vecSpot = vecStart;
|
||||
vecSpot.x += RANDOM_FLOAT( -m_flSpread, m_flSpread );
|
||||
vecSpot.y += RANDOM_FLOAT( -m_flSpread, m_flSpread );
|
||||
vecSpot.x += RANDOM_FLOAT(-m_flSpread, m_flSpread);
|
||||
vecSpot.y += RANDOM_FLOAT(-m_flSpread, m_flSpread);
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT(pev), &tr );
|
||||
|
||||
UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -1) * 4096, ignore_monsters, ENT(pev), &tr);
|
||||
edict_t *pentOwner = NULL;
|
||||
if (pActivator) pentOwner = pActivator->edict();
|
||||
|
||||
CBaseEntity *pMortar = Create("monster_mortar", tr.vecEndPos, Vector( 0, 0, 0 ), pentOwner );
|
||||
if (pActivator)
|
||||
pentOwner = pActivator->edict();
|
||||
|
||||
CBaseEntity *pMortar = Create("monster_mortar", tr.vecEndPos, Vector(0, 0, 0), pentOwner);
|
||||
pMortar->pev->nextthink = gpGlobals->time + t;
|
||||
t += RANDOM_FLOAT( 0.2, 0.5 );
|
||||
t += RANDOM_FLOAT(0.2, 0.5);
|
||||
|
||||
if (i == 0)
|
||||
CSoundEnt::InsertSound ( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 );
|
||||
if (!i)
|
||||
CSoundEnt::InsertSound(bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class CMortar : public CGrenade
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
|
||||
void EXPORT MortarExplode( void );
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
void EXPORT MortarExplode(void);
|
||||
|
||||
public:
|
||||
int m_spriteTexture;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( monster_mortar, CMortar );
|
||||
LINK_ENTITY_TO_CLASS(monster_mortar, CMortar);
|
||||
|
||||
void CMortar::Spawn( )
|
||||
void CMortar::Spawn(void)
|
||||
{
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->dmg = 200;
|
||||
|
||||
pev->dmg = 200;
|
||||
|
||||
SetThink( MortarExplode );
|
||||
SetThink(&CMortar::MortarExplode);
|
||||
pev->nextthink = 0;
|
||||
|
||||
Precache( );
|
||||
|
||||
|
||||
Precache();
|
||||
}
|
||||
|
||||
|
||||
void CMortar::Precache( )
|
||||
void CMortar::Precache(void)
|
||||
{
|
||||
m_spriteTexture = PRECACHE_MODEL( "sprites/lgtning.spr" );
|
||||
m_spriteTexture = PRECACHE_MODEL("sprites/lgtning.spr");
|
||||
}
|
||||
|
||||
void CMortar::MortarExplode( void )
|
||||
void CMortar::MortarExplode(void)
|
||||
{
|
||||
#if 1
|
||||
// mortar beam
|
||||
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
||||
WRITE_BYTE( TE_BEAMPOINTS );
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z + 1024);
|
||||
WRITE_SHORT(m_spriteTexture );
|
||||
WRITE_BYTE( 0 ); // framerate
|
||||
WRITE_BYTE( 0 ); // framerate
|
||||
WRITE_BYTE( 1 ); // life
|
||||
WRITE_BYTE( 40 ); // width
|
||||
WRITE_BYTE( 0 ); // noise
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
WRITE_BYTE( 160 ); // r, g, b
|
||||
WRITE_BYTE( 100 ); // r, g, b
|
||||
WRITE_BYTE( 128 ); // brightness
|
||||
WRITE_BYTE( 0 ); // speed
|
||||
MESSAGE_BEGIN(MSG_BROADCAST, SVC_TEMPENTITY);
|
||||
WRITE_BYTE(TE_BEAMPOINTS);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z + 1024);
|
||||
WRITE_SHORT(m_spriteTexture);
|
||||
WRITE_BYTE(0);
|
||||
WRITE_BYTE(0);
|
||||
WRITE_BYTE(1);
|
||||
WRITE_BYTE(40);
|
||||
WRITE_BYTE(0);
|
||||
WRITE_BYTE(255);
|
||||
WRITE_BYTE(160);
|
||||
WRITE_BYTE(100);
|
||||
WRITE_BYTE(128);
|
||||
WRITE_BYTE(0);
|
||||
MESSAGE_END();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// blast circle
|
||||
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
||||
WRITE_BYTE( TE_BEAMTORUS);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z + 32);
|
||||
WRITE_COORD(pev->origin.x);
|
||||
WRITE_COORD(pev->origin.y);
|
||||
WRITE_COORD(pev->origin.z + 32 + pev->dmg * 2 / .2); // reach damage radius over .3 seconds
|
||||
WRITE_SHORT(m_spriteTexture );
|
||||
WRITE_BYTE( 0 ); // startframe
|
||||
WRITE_BYTE( 0 ); // framerate
|
||||
WRITE_BYTE( 2 ); // life
|
||||
WRITE_BYTE( 12 ); // width
|
||||
WRITE_BYTE( 0 ); // noise
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
WRITE_BYTE( 160 ); // r, g, b
|
||||
WRITE_BYTE( 100 ); // r, g, b
|
||||
WRITE_BYTE( 255 ); // brightness
|
||||
WRITE_BYTE( 0 ); // speed
|
||||
MESSAGE_END();
|
||||
#endif
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine( pev->origin + Vector( 0, 0, 1024 ), pev->origin - Vector( 0, 0, 1024 ), dont_ignore_monsters, ENT(pev), &tr );
|
||||
|
||||
Explode( &tr, DMG_BLAST | DMG_MORTAR );
|
||||
UTIL_ScreenShake( tr.vecEndPos, 25.0, 150.0, 1.0, 750 );
|
||||
|
||||
#if 0
|
||||
int pitch = RANDOM_LONG(95,124);
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "weapons/mortarhit.wav", 1.0, 0.55, 0, pitch);
|
||||
|
||||
// ForceSound( SNDRADIUS_MP5, bits_SOUND_COMBAT );
|
||||
|
||||
// ExplodeModel( pev->origin, 400, g_sModelIndexShrapnel, 30 );
|
||||
|
||||
RadiusDamage ( pev, VARS(pev->owner), pev->dmg, CLASS_NONE, DMG_BLAST );
|
||||
|
||||
/*
|
||||
if ( RANDOM_FLOAT ( 0 , 1 ) < 0.5 )
|
||||
{
|
||||
UTIL_DecalTrace( pTrace, DECAL_SCORCH1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
UTIL_DecalTrace( pTrace, DECAL_SCORCH2 );
|
||||
}
|
||||
*/
|
||||
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
void CMortar::ShootTimed( EVARS *pevOwner, Vector vecStart, float time )
|
||||
{
|
||||
CMortar *pMortar = GetClassPtr( (CMortar *)NULL );
|
||||
pMortar->Spawn();
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine( vecStart, vecStart + Vector( 0, 0, -1 ) * 4096, ignore_monsters, ENT(pMortar->pev), &tr );
|
||||
|
||||
pMortar->pev->nextthink = gpGlobals->time + time;
|
||||
|
||||
UTIL_SetOrigin( pMortar->pev, tr.vecEndPos );
|
||||
}
|
||||
#endif
|
||||
UTIL_TraceLine(pev->origin + Vector(0, 0, 1024), pev->origin - Vector(0, 0, 1024), dont_ignore_monsters, ENT(pev), &tr);
|
||||
Explode(&tr, DMG_BLAST | DMG_MORTAR);
|
||||
UTIL_ScreenShake(tr.vecEndPos, 25, 150, 1, 750);
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
LIBRARY mp
|
||||
EXPORTS
|
||||
GiveFnptrsToDll @1
|
||||
SECTIONS
|
||||
.data READ WRITE
|
559
dlls/mp.dsp
559
dlls/mp.dsp
|
@ -1,559 +0,0 @@
|
|||
# Microsoft Developer Studio Project File - Name="mp" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=mp - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mp.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mp.mak" CFG="mp - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "mp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "mp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "mp - Win32 Profile" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "mp - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Releasemp"
|
||||
# PROP Intermediate_Dir ".\Releasemp"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /I "..\dlls" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\game_shared" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /YX /FD /c
|
||||
# SUBTRACT CPP /Fr
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /debug /machine:I386 /def:".\mp.def"
|
||||
# SUBTRACT LINK32 /profile
|
||||
|
||||
!ELSEIF "$(CFG)" == "mp - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\mp___Win"
|
||||
# PROP BASE Intermediate_Dir ".\mp___Win"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\debugmp"
|
||||
# PROP Intermediate_Dir ".\debugmp"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /G5 /MTd /W3 /Gm /GX /ZI /Od /I "..\dlls" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\game_shared" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /i "..\engine" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 user32.lib advapi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\mp.def" /implib:".\Debug\mp.lib"
|
||||
# SUBTRACT LINK32 /profile
|
||||
|
||||
!ELSEIF "$(CFG)" == "mp - Win32 Profile"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\mp___Win"
|
||||
# PROP BASE Intermediate_Dir ".\mp___Win"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Profilemp"
|
||||
# PROP Intermediate_Dir ".\Profilemp"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /I "..\engine" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "QUIVER" /D "VOXEL" /D "QUAKE2" /D "VALVE_DLL" /YX /c
|
||||
# SUBTRACT BASE CPP /Fr
|
||||
# ADD CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /I "..\dlls" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\game_shared" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "VALVE_DLL" /D "CLIENT_WEAPONS" /YX /FD /c
|
||||
# SUBTRACT CPP /Fr
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /def:".\mp.def"
|
||||
# SUBTRACT BASE LINK32 /profile
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /profile /debug /machine:I386 /def:".\mp.def"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "mp - Win32 Release"
|
||||
# Name "mp - Win32 Debug"
|
||||
# Name "mp - Win32 Profile"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\airtank.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\animating.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\animation.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bmodels.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\buttons.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cbase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\combat.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\crossbow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\crowbar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\doors.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\effects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\egon.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\explode.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\func_break.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\func_tank.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\game.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gamerules.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gauss.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ggrenade.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\globals.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\h_ai.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\h_battery.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\h_cycler.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\h_export.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\handgrenade.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\healthkit.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wpn_shared\hl_wpn_glock.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hornet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hornetgun.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\common\interface.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\items.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lights.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\maprules.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mortar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mp5.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mpstubb.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\multiplay_gamerules.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\pathcorner.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plane.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plats.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\player.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_debug.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_math.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_shared.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\python.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\rpg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\satchel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\shotgun.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\singleplay_gamerules.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\skill.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sound.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\soundent.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\spectator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\squeakgrenade.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\subs.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\teamplay_gamerules.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\triggers.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\tripmine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\game_shared\voice_gamemgr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\weapons.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\world.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\xen.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\activity.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\activitymap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\animation.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\basemonster.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cbase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cdll_dll.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\decals.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\doors.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\effects.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\enginecallback.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\explode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\extdll.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\func_break.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\game.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gamerules.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hornet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\items.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\maprules.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\monsterevent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\monsters.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\nodes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\plane.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\player.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_debug.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_defs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_info.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_materials.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_movevars.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\pm_shared\pm_shared.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\saverestore.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\schedule.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\scriptevent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\skill.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\soundent.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\spectator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\talkmonster.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\teamplay_gamerules.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\trains.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vector.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\weapons.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
385
dlls/mp5.cpp
385
dlls/mp5.cpp
|
@ -1,385 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "soundent.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
enum mp5_e
|
||||
{
|
||||
MP5_LONGIDLE = 0,
|
||||
MP5_IDLE1,
|
||||
MP5_LAUNCH,
|
||||
MP5_RELOAD,
|
||||
MP5_DEPLOY,
|
||||
MP5_FIRE1,
|
||||
MP5_FIRE2,
|
||||
MP5_FIRE3,
|
||||
};
|
||||
|
||||
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 );
|
||||
LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 );
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CMP5::SecondaryAmmoIndex( void )
|
||||
{
|
||||
return m_iSecondaryAmmoType;
|
||||
}
|
||||
|
||||
void CMP5::Spawn( )
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_9mmAR"); // hack to allow for old names
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_9mmAR.mdl");
|
||||
m_iId = WEAPON_MP5;
|
||||
|
||||
m_iDefaultAmmo = MP5_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CMP5::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_9mmAR.mdl");
|
||||
PRECACHE_MODEL("models/w_9mmAR.mdl");
|
||||
PRECACHE_MODEL("models/p_9mmAR.mdl");
|
||||
|
||||
m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shellTE_MODEL
|
||||
|
||||
PRECACHE_MODEL("models/grenade.mdl"); // grenade
|
||||
|
||||
PRECACHE_MODEL("models/w_9mmARclip.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
PRECACHE_SOUND("items/clipinsert1.wav");
|
||||
PRECACHE_SOUND("items/cliprelease1.wav");
|
||||
|
||||
PRECACHE_SOUND ("weapons/hks1.wav");// H to the K
|
||||
PRECACHE_SOUND ("weapons/hks2.wav");// H to the K
|
||||
PRECACHE_SOUND ("weapons/hks3.wav");// H to the K
|
||||
|
||||
PRECACHE_SOUND( "weapons/glauncher.wav" );
|
||||
PRECACHE_SOUND( "weapons/glauncher2.wav" );
|
||||
|
||||
PRECACHE_SOUND ("weapons/357_cock1.wav");
|
||||
|
||||
m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" );
|
||||
m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" );
|
||||
}
|
||||
|
||||
int CMP5::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "9mm";
|
||||
p->iMaxAmmo1 = _9MM_MAX_CARRY;
|
||||
p->pszAmmo2 = "ARgrenades";
|
||||
p->iMaxAmmo2 = M203_GRENADE_MAX_CARRY;
|
||||
p->iMaxClip = MP5_MAX_CLIP;
|
||||
p->iSlot = 2;
|
||||
p->iPosition = 0;
|
||||
p->iFlags = 0;
|
||||
p->iId = m_iId = WEAPON_MP5;
|
||||
p->iWeight = MP5_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CMP5::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CMP5::Deploy( )
|
||||
{
|
||||
return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" );
|
||||
}
|
||||
|
||||
|
||||
void CMP5::PrimaryAttack()
|
||||
{
|
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextPrimaryAttack = 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
|
||||
m_iClip--;
|
||||
|
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
Vector vecDir;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( !bIsMultiplayer() )
|
||||
#else
|
||||
if ( !g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
// optimized multiplayer. Widened to make it easier to hit a moving player
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
else
|
||||
{
|
||||
// single player spread
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;
|
||||
|
||||
if ( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CMP5::SecondaryAttack( void )
|
||||
{
|
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextPrimaryAttack = 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] == 0)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
|
||||
m_pPlayer->m_iExtraSoundTypes = bits_SOUND_DANGER;
|
||||
m_pPlayer->m_flStopExtraSoundTime = UTIL_WeaponTimeBase() + 0.2;
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]--;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
|
||||
// we don't add in player velocity anymore.
|
||||
CGrenade::ShootContact( m_pPlayer->pev,
|
||||
m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16,
|
||||
gpGlobals->v_forward * 800 );
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 );
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting.
|
||||
|
||||
if (!m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType])
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
}
|
||||
|
||||
void CMP5::Reload( void )
|
||||
{
|
||||
if ( m_pPlayer->ammo_9mm <= 0 )
|
||||
return;
|
||||
|
||||
DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 );
|
||||
}
|
||||
|
||||
|
||||
void CMP5::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
int iAnim;
|
||||
switch ( RANDOM_LONG( 0, 1 ) )
|
||||
{
|
||||
case 0:
|
||||
iAnim = MP5_LONGIDLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 1:
|
||||
iAnim = MP5_IDLE1;
|
||||
break;
|
||||
}
|
||||
|
||||
SendWeaponAnim( iAnim );
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again.
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CMP5AmmoClip : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_9mmARclip.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_9mmARclip.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
int bResult = (pOther->GiveAmmo( AMMO_MP5CLIP_GIVE, "9mm", _9MM_MAX_CARRY) != -1);
|
||||
if (bResult)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_mp5clip, CMP5AmmoClip );
|
||||
LINK_ENTITY_TO_CLASS( ammo_9mmAR, CMP5AmmoClip );
|
||||
|
||||
|
||||
|
||||
class CMP5Chainammo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_chainammo.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_chainammo.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
int bResult = (pOther->GiveAmmo( AMMO_CHAINBOX_GIVE, "9mm", _9MM_MAX_CARRY) != -1);
|
||||
if (bResult)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo );
|
||||
|
||||
|
||||
class CMP5AmmoGrenade : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_ARgrenade.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_ARgrenade.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
int bResult = (pOther->GiveAmmo( AMMO_M203BOX_GIVE, "ARgrenades", M203_GRENADE_MAX_CARRY ) != -1);
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_mp5grenades, CMP5AmmoGrenade );
|
||||
LINK_ENTITY_TO_CLASS( ammo_ARgrenades, CMP5AmmoGrenade );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
275
dlls/mpstubb.cpp
275
dlls/mpstubb.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -13,245 +13,168 @@
|
|||
*
|
||||
****/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "soundent.h"
|
||||
#include "nodes.h"
|
||||
#include "talkmonster.h"
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "soundent.h"
|
||||
#include "nodes.h"
|
||||
#include "talkmonster.h"
|
||||
float CTalkMonster::g_talkWaitTime = 0;
|
||||
|
||||
CGraph WorldGraph;
|
||||
void CGraph::InitGraph(void) {}
|
||||
int CGraph::FLoadGraph(char *szMapName) { return FALSE; }
|
||||
int CGraph::AllocNodes(void) { return FALSE; }
|
||||
int CGraph::CheckNODFile(char *szMapName) { return FALSE; }
|
||||
int CGraph::FSetGraphPointers(void) { return 0; }
|
||||
void CGraph::ShowNodeConnections(int iNode) {}
|
||||
int CGraph::FindNearestNode(const Vector &vecOrigin, int afNodeTypes) { return 0; }
|
||||
|
||||
float CTalkMonster::g_talkWaitTime = 0; // time delay until it's ok to speak: used so that two NPCs don't talk at once
|
||||
void CBaseMonster::ReportAIState(void) {}
|
||||
float CBaseMonster::ChangeYaw(int speed) { return 0; }
|
||||
void CBaseMonster::MakeIdealYaw(Vector vecTarget) {}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
|
||||
CGraph WorldGraph;
|
||||
void CGraph :: InitGraph( void ) { }
|
||||
int CGraph :: FLoadGraph ( char *szMapName ) { return FALSE; }
|
||||
int CGraph :: AllocNodes ( void ) { return FALSE; }
|
||||
int CGraph :: CheckNODFile ( char *szMapName ) { return FALSE; }
|
||||
int CGraph :: FSetGraphPointers ( void ) { return 0; }
|
||||
void CGraph :: ShowNodeConnections ( int iNode ) { }
|
||||
int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ) { return 0; }
|
||||
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
|
||||
void CBaseMonster :: ReportAIState( void ) { }
|
||||
float CBaseMonster :: ChangeYaw ( int speed ) { return 0; }
|
||||
void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { }
|
||||
|
||||
|
||||
void CBaseMonster::CorpseFallThink( void )
|
||||
void CBaseMonster::CorpseFallThink(void)
|
||||
{
|
||||
if ( pev->flags & FL_ONGROUND )
|
||||
if (pev->flags & FL_ONGROUND)
|
||||
{
|
||||
ResetThink( );
|
||||
|
||||
SetSequenceBox( );
|
||||
UTIL_SetOrigin( pev, pev->origin );// link into world.
|
||||
SetThink(NULL);
|
||||
SetSequenceBox();
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
}
|
||||
else
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
// Call after animation/pose is set up
|
||||
void CBaseMonster :: MonsterInitDead( void )
|
||||
|
||||
void CBaseMonster::MonsterInitDead(void)
|
||||
{
|
||||
InitBoneControllers();
|
||||
|
||||
pev->solid = SOLID_BBOX;
|
||||
pev->movetype = MOVETYPE_TOSS;// so he'll fall to ground
|
||||
pev->solid = SOLID_BBOX;
|
||||
pev->movetype = MOVETYPE_TOSS;
|
||||
|
||||
pev->frame = 0;
|
||||
ResetSequenceInfo( );
|
||||
ResetSequenceInfo();
|
||||
pev->framerate = 0;
|
||||
|
||||
// Copy health
|
||||
pev->max_health = pev->health;
|
||||
pev->deadflag = DEAD_DEAD;
|
||||
|
||||
UTIL_SetSize(pev, g_vecZero, g_vecZero );
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
// Setup health counters, etc.
|
||||
pev->max_health = pev->health;
|
||||
pev->deadflag = DEAD_DEAD;
|
||||
|
||||
UTIL_SetSize(pev, g_vecZero, g_vecZero);
|
||||
UTIL_SetOrigin(pev, pev->origin);
|
||||
|
||||
BecomeDead();
|
||||
SetThink( CorpseFallThink );
|
||||
SetThink(&CBaseEntity::SUB_Remove);
|
||||
pev->nextthink = gpGlobals->time + 0.5;
|
||||
}
|
||||
|
||||
|
||||
BOOL CBaseMonster :: ShouldFadeOnDeath( void )
|
||||
{
|
||||
return FALSE;
|
||||
BOOL CBaseMonster::ShouldFadeOnDeath(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CBaseMonster :: FCheckAITrigger ( void )
|
||||
{
|
||||
return FALSE;
|
||||
BOOL CBaseMonster::FCheckAITrigger(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CBaseMonster :: KeyValue( KeyValueData *pkvd )
|
||||
{
|
||||
CBaseToggle::KeyValue( pkvd );
|
||||
void CBaseMonster::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
CBaseToggle::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
int CBaseMonster::IRelationship ( CBaseEntity *pTarget )
|
||||
int CBaseMonster::IRelationship(CBaseEntity *pTarget)
|
||||
{
|
||||
static int iEnemy[14][14] =
|
||||
{ // NONE MACH PLYR HPASS HMIL AMIL APASS AMONST APREY APRED INSECT PLRALY PBWPN ABWPN
|
||||
/*NONE*/ { R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO, R_NO, R_NO },
|
||||
/*MACHINE*/ { R_NO ,R_NO ,R_DL ,R_DL ,R_NO ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_DL, R_DL, R_DL },
|
||||
/*PLAYER*/ { R_NO ,R_DL ,R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_NO, R_DL, R_DL },
|
||||
/*HUMANPASSIVE*/{ R_NO ,R_NO ,R_AL ,R_AL ,R_HT ,R_FR ,R_NO ,R_HT ,R_DL ,R_FR ,R_NO ,R_AL, R_NO, R_NO },
|
||||
/*HUMANMILITAR*/{ R_NO ,R_NO ,R_HT ,R_DL ,R_NO ,R_HT ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_HT, R_NO, R_NO },
|
||||
/*ALIENMILITAR*/{ R_NO ,R_DL ,R_HT ,R_DL ,R_HT ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_DL, R_NO, R_NO },
|
||||
/*ALIENPASSIVE*/{ R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO, R_NO, R_NO },
|
||||
/*ALIENMONSTER*/{ R_NO ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_DL, R_NO, R_NO },
|
||||
/*ALIENPREY */{ R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_NO ,R_NO ,R_NO ,R_NO ,R_FR ,R_NO ,R_DL, R_NO, R_NO },
|
||||
/*ALIENPREDATO*/{ R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_NO ,R_NO ,R_NO ,R_HT ,R_DL ,R_NO ,R_DL, R_NO, R_NO },
|
||||
/*INSECT*/ { R_FR ,R_FR ,R_FR ,R_FR ,R_FR ,R_NO ,R_FR ,R_FR ,R_FR ,R_FR ,R_NO ,R_FR, R_NO, R_NO },
|
||||
/*PLAYERALLY*/ { R_NO ,R_DL ,R_AL ,R_AL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_NO, R_NO, R_NO },
|
||||
/*PBIOWEAPON*/ { R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_DL, R_NO, R_DL },
|
||||
/*ABIOWEAPON*/ { R_NO ,R_NO ,R_DL ,R_DL ,R_DL ,R_AL ,R_NO ,R_DL ,R_DL ,R_NO ,R_NO ,R_DL, R_DL, R_NO }
|
||||
{
|
||||
{ R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_DL, R_DL },
|
||||
{ R_NO, R_DL, R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL },
|
||||
{ R_NO, R_NO, R_AL, R_AL, R_HT, R_FR, R_NO, R_HT, R_DL, R_FR, R_NO, R_AL, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_HT, R_DL, R_NO, R_HT, R_DL, R_DL, R_DL, R_DL, R_NO, R_HT, R_NO, R_NO },
|
||||
{ R_NO, R_DL, R_HT, R_DL, R_HT, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO },
|
||||
{ R_NO, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_NO, R_NO, R_DL, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO, R_FR, R_NO, R_DL, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_HT, R_DL, R_NO, R_DL, R_NO, R_NO },
|
||||
{ R_FR, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_FR, R_FR, R_FR, R_NO, R_FR, R_NO, R_NO },
|
||||
{ R_NO, R_DL, R_AL, R_AL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_NO, R_NO, R_NO },
|
||||
{ R_NO, R_NO, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_DL, R_NO, R_DL, R_NO, R_DL },
|
||||
{ R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO }
|
||||
};
|
||||
|
||||
return iEnemy[ Classify() ][ pTarget->Classify() ];
|
||||
return iEnemy[Classify()][pTarget->Classify()];
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// Look - Base class monster function to find enemies or
|
||||
// food by sight. iDistance is distance ( in units ) that the
|
||||
// monster can see.
|
||||
//
|
||||
// Sets the sight bits of the m_afConditions mask to indicate
|
||||
// which types of entities were sighted.
|
||||
// Function also sets the Looker's m_pLink
|
||||
// to the head of a link list that contains all visible ents.
|
||||
// (linked via each ent's m_pLink field)
|
||||
//
|
||||
//=========================================================
|
||||
void CBaseMonster :: Look ( int iDistance )
|
||||
void CBaseMonster::Look(int iDistance)
|
||||
{
|
||||
int iSighted = 0;
|
||||
|
||||
// DON'T let visibility information from last frame sit around!
|
||||
int iSighted = 0;
|
||||
ClearConditions(bits_COND_SEE_HATE | bits_COND_SEE_DISLIKE | bits_COND_SEE_ENEMY | bits_COND_SEE_FEAR | bits_COND_SEE_NEMESIS | bits_COND_SEE_CLIENT);
|
||||
|
||||
m_pLink = NULL;
|
||||
|
||||
CBaseEntity *pSightEnt = NULL;// the current visible entity that we're dealing with
|
||||
|
||||
CBaseEntity *pSightEnt = NULL;
|
||||
CBaseEntity *pList[100];
|
||||
Vector delta = Vector(iDistance, iDistance, iDistance);
|
||||
int count = UTIL_EntitiesInBox(pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT | FL_MONSTER);
|
||||
|
||||
Vector delta = Vector( iDistance, iDistance, iDistance );
|
||||
|
||||
// Find only monsters/clients in box, NOT limited to PVS
|
||||
int count = UTIL_EntitiesInBox( pList, 100, pev->origin - delta, pev->origin + delta, FL_CLIENT|FL_MONSTER );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
pSightEnt = pList[i];
|
||||
if ( pSightEnt != this && pSightEnt->pev->health > 0 )
|
||||
|
||||
if (pSightEnt != this && pSightEnt->pev->health > 0)
|
||||
{
|
||||
// the looker will want to consider this entity
|
||||
// don't check anything else about an entity that can't be seen, or an entity that you don't care about.
|
||||
if ( IRelationship( pSightEnt ) != R_NO && FInViewCone( pSightEnt ) && !FBitSet( pSightEnt->pev->flags, FL_NOTARGET ) && FVisible( pSightEnt ) )
|
||||
if (IRelationship(pSightEnt) != R_NO && FInViewCone(pSightEnt) && !FBitSet(pSightEnt->pev->flags, FL_NOTARGET) && FVisible(pSightEnt))
|
||||
{
|
||||
if ( pSightEnt->IsPlayer() )
|
||||
{
|
||||
// if we see a client, remember that (mostly for scripted AI)
|
||||
if (pSightEnt->IsPlayer())
|
||||
iSighted |= bits_COND_SEE_CLIENT;
|
||||
}
|
||||
|
||||
pSightEnt->m_pLink = m_pLink;
|
||||
m_pLink = pSightEnt;
|
||||
|
||||
if ( pSightEnt == m_hEnemy )
|
||||
{
|
||||
// we know this ent is visible, so if it also happens to be our enemy, store that now.
|
||||
if (pSightEnt == m_hEnemy)
|
||||
iSighted |= bits_COND_SEE_ENEMY;
|
||||
}
|
||||
|
||||
// don't add the Enemy's relationship to the conditions. We only want to worry about conditions when
|
||||
// we see monsters other than the Enemy.
|
||||
switch ( IRelationship ( pSightEnt ) )
|
||||
switch (IRelationship(pSightEnt))
|
||||
{
|
||||
case R_NM:
|
||||
iSighted |= bits_COND_SEE_NEMESIS;
|
||||
break;
|
||||
case R_HT:
|
||||
iSighted |= bits_COND_SEE_HATE;
|
||||
break;
|
||||
case R_DL:
|
||||
iSighted |= bits_COND_SEE_DISLIKE;
|
||||
break;
|
||||
case R_FR:
|
||||
iSighted |= bits_COND_SEE_FEAR;
|
||||
break;
|
||||
case R_AL:
|
||||
break;
|
||||
default:
|
||||
ALERT ( at_aiconsole, "%s can't assess %s\n", STRING(pev->classname), STRING(pSightEnt->pev->classname ) );
|
||||
break;
|
||||
case R_NM: iSighted |= bits_COND_SEE_NEMESIS; break;
|
||||
case R_HT: iSighted |= bits_COND_SEE_HATE; break;
|
||||
case R_DL: iSighted |= bits_COND_SEE_DISLIKE; break;
|
||||
case R_FR: iSighted |= bits_COND_SEE_FEAR; break;
|
||||
case R_AL: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetConditions( iSighted );
|
||||
|
||||
SetConditions(iSighted);
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// BestVisibleEnemy - this functions searches the link
|
||||
// list whose head is the caller's m_pLink field, and returns
|
||||
// a pointer to the enemy entity in that list that is nearest the
|
||||
// caller.
|
||||
//
|
||||
// !!!UNDONE - currently, this only returns the closest enemy.
|
||||
// we'll want to consider distance, relationship, attack types, back turned, etc.
|
||||
//=========================================================
|
||||
CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void )
|
||||
CBaseEntity *CBaseMonster::BestVisibleEnemy(void)
|
||||
{
|
||||
CBaseEntity *pReturn;
|
||||
CBaseEntity *pNextEnt;
|
||||
int iNearest;
|
||||
int iDist;
|
||||
int iBestRelationship;
|
||||
int iNearest = 8192;
|
||||
CBaseEntity *pNextEnt = m_pLink;
|
||||
CBaseEntity *pReturn = NULL;
|
||||
int iBestRelationship = R_NO;
|
||||
|
||||
iNearest = 8192;// so first visible entity will become the closest.
|
||||
pNextEnt = m_pLink;
|
||||
pReturn = NULL;
|
||||
iBestRelationship = R_NO;
|
||||
|
||||
while ( pNextEnt != NULL )
|
||||
while (pNextEnt)
|
||||
{
|
||||
if ( pNextEnt->IsAlive() )
|
||||
if (pNextEnt->IsAlive())
|
||||
{
|
||||
if ( IRelationship( pNextEnt) > iBestRelationship )
|
||||
if (IRelationship(pNextEnt) > iBestRelationship)
|
||||
{
|
||||
// this entity is disliked MORE than the entity that we
|
||||
// currently think is the best visible enemy. No need to do
|
||||
// a distance check, just get mad at this one for now.
|
||||
iBestRelationship = IRelationship ( pNextEnt );
|
||||
iNearest = ( pNextEnt->pev->origin - pev->origin ).Length();
|
||||
iBestRelationship = IRelationship(pNextEnt);
|
||||
iNearest = (int)((pNextEnt->pev->origin - pev->origin).Length());
|
||||
pReturn = pNextEnt;
|
||||
}
|
||||
else if ( IRelationship( pNextEnt) == iBestRelationship )
|
||||
else if (IRelationship(pNextEnt) == iBestRelationship)
|
||||
{
|
||||
// this entity is disliked just as much as the entity that
|
||||
// we currently think is the best visible enemy, so we only
|
||||
// get mad at it if it is closer.
|
||||
iDist = ( pNextEnt->pev->origin - pev->origin ).Length();
|
||||
|
||||
if ( iDist <= iNearest )
|
||||
int iDist = (int)((pNextEnt->pev->origin - pev->origin).Length());
|
||||
|
||||
if (iDist <= iNearest)
|
||||
{
|
||||
iNearest = iDist;
|
||||
iBestRelationship = IRelationship ( pNextEnt );
|
||||
iBestRelationship = IRelationship(pNextEnt);
|
||||
pReturn = pNextEnt;
|
||||
}
|
||||
}
|
||||
|
@ -261,4 +184,4 @@ CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void )
|
|||
}
|
||||
|
||||
return pReturn;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
50
dlls/nodes.h
50
dlls/nodes.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,43 +12,35 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// nodes.h
|
||||
//=========================================================
|
||||
#ifndef NODES_H
|
||||
#define NODES_H
|
||||
|
||||
#ifndef NODES_H
|
||||
#define NODES_H
|
||||
|
||||
#define bits_NODE_GROUP_REALM 1
|
||||
#define bits_NODE_GROUP_REALM 1
|
||||
|
||||
class CLink
|
||||
{
|
||||
public:
|
||||
entvars_t *m_pLinkEnt;// the entity that blocks this connection (doors, etc)
|
||||
entvars_t *m_pLinkEnt;
|
||||
};
|
||||
|
||||
|
||||
class CGraph
|
||||
{
|
||||
public:
|
||||
BOOL m_fGraphPresent;// is the graph in memory?
|
||||
BOOL m_fGraphPointersSet;// are the entity pointers for the graph all set?
|
||||
|
||||
int m_cLinks;// total number of links
|
||||
CLink *m_pLinkPool;// big list of all node connections
|
||||
|
||||
void InitGraph( void );
|
||||
int AllocNodes ( void );
|
||||
|
||||
int CheckNODFile(char *szMapName);
|
||||
int FLoadGraph(char *szMapName);
|
||||
int FSetGraphPointers(void);
|
||||
void ShowNodeConnections ( int iNode );
|
||||
int FindNearestNode ( const Vector &vecOrigin, CBaseEntity *pEntity );
|
||||
int FindNearestNode ( const Vector &vecOrigin, int afNodeTypes );
|
||||
BOOL m_fGraphPresent;
|
||||
BOOL m_fGraphPointersSet;
|
||||
int m_cLinks;
|
||||
CLink *m_pLinkPool;
|
||||
|
||||
public:
|
||||
void InitGraph(void);
|
||||
int AllocNodes(void);
|
||||
int CheckNODFile(char *szMapName);
|
||||
int FLoadGraph(char *szMapName);
|
||||
int FSetGraphPointers(void);
|
||||
void ShowNodeConnections(int iNode);
|
||||
int FindNearestNode(const Vector &vecOrigin, CBaseEntity *pEntity);
|
||||
int FindNearestNode(const Vector &vecOrigin, int afNodeTypes);
|
||||
};
|
||||
|
||||
extern CGraph WorldGraph;
|
||||
|
||||
#endif // NODES_H
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,12 +12,8 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// ========================== PATH_CORNER ===========================
|
||||
//
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "trains.h"
|
||||
#include "saverestore.h"
|
||||
|
@ -25,115 +21,57 @@
|
|||
class CPathCorner : public CPointEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( );
|
||||
void KeyValue( KeyValueData* pkvd );
|
||||
float GetDelay( void ) { return m_flWait; }
|
||||
// void Touch( CBaseEntity *pOther );
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
void Spawn(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
float GetDelay(void) { return m_flWait; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
private:
|
||||
float m_flWait;
|
||||
float m_flWait;
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( path_corner, CPathCorner );
|
||||
LINK_ENTITY_TO_CLASS(path_corner, CPathCorner);
|
||||
|
||||
// Global Savedata for Delay
|
||||
TYPEDESCRIPTION CPathCorner::m_SaveData[] =
|
||||
TYPEDESCRIPTION CPathCorner::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CPathCorner, m_flWait, FIELD_FLOAT ),
|
||||
DEFINE_FIELD(CPathCorner, m_flWait, FIELD_FLOAT),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CPathCorner, CPointEntity );
|
||||
IMPLEMENT_SAVERESTORE(CPathCorner, CPointEntity);
|
||||
|
||||
//
|
||||
// Cache user-entity-field values until spawn is called.
|
||||
//
|
||||
void CPathCorner :: KeyValue( KeyValueData *pkvd )
|
||||
void CPathCorner::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "wait"))
|
||||
{
|
||||
m_flWait = atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CPointEntity::KeyValue( pkvd );
|
||||
else
|
||||
CPointEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
|
||||
void CPathCorner :: Spawn( )
|
||||
void CPathCorner::Spawn(void)
|
||||
{
|
||||
ASSERTSZ(!FStringNull(pev->targetname), "path_corner without a targetname");
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
void CPathCorner :: Touch( CBaseEntity *pOther )
|
||||
TYPEDESCRIPTION CPathTrack::m_SaveData[] =
|
||||
{
|
||||
entvars_t* pevToucher = pOther->pev;
|
||||
|
||||
if ( FBitSet ( pevToucher->flags, FL_MONSTER ) )
|
||||
{// monsters don't navigate path corners based on touch anymore
|
||||
return;
|
||||
}
|
||||
|
||||
// If OTHER isn't explicitly looking for this path_corner, bail out
|
||||
if ( pOther->m_pGoalEnt != this )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If OTHER has an enemy, this touch is incidental, ignore
|
||||
if ( !FNullEnt(pevToucher->enemy) )
|
||||
{
|
||||
return; // fighting, not following a path
|
||||
}
|
||||
|
||||
// UNDONE: support non-zero flWait
|
||||
/*
|
||||
if (m_flWait != 0)
|
||||
ALERT(at_warning, "Non-zero path-cornder waits NYI");
|
||||
*/
|
||||
|
||||
// Find the next "stop" on the path, make it the goal of the "toucher".
|
||||
if (FStringNull(pev->target))
|
||||
{
|
||||
ALERT(at_warning, "PathCornerTouch: no next stop specified");
|
||||
}
|
||||
|
||||
pOther->m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->target) ) );
|
||||
|
||||
// If "next spot" was not found (does not exist - level design error)
|
||||
if ( !pOther->m_pGoalEnt )
|
||||
{
|
||||
ALERT(at_console, "PathCornerTouch--%s couldn't find next stop in path: %s", STRING(pev->classname), STRING(pev->target));
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn towards the next stop in the path.
|
||||
pevToucher->ideal_yaw = UTIL_VecToYaw ( pOther->m_pGoalEnt->pev->origin - pevToucher->origin );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
TYPEDESCRIPTION CPathTrack::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CPathTrack, m_length, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CPathTrack, m_pnext, FIELD_CLASSPTR ),
|
||||
DEFINE_FIELD( CPathTrack, m_paltpath, FIELD_CLASSPTR ),
|
||||
DEFINE_FIELD( CPathTrack, m_pprevious, FIELD_CLASSPTR ),
|
||||
DEFINE_FIELD( CPathTrack, m_altName, FIELD_STRING ),
|
||||
DEFINE_FIELD(CPathTrack, m_length, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CPathTrack, m_pnext, FIELD_CLASSPTR),
|
||||
DEFINE_FIELD(CPathTrack, m_paltpath, FIELD_CLASSPTR),
|
||||
DEFINE_FIELD(CPathTrack, m_pprevious, FIELD_CLASSPTR),
|
||||
DEFINE_FIELD(CPathTrack, m_altName, FIELD_STRING),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CPathTrack, CBaseEntity );
|
||||
LINK_ENTITY_TO_CLASS( path_track, CPathTrack );
|
||||
IMPLEMENT_SAVERESTORE(CPathTrack, CBaseEntity);
|
||||
LINK_ENTITY_TO_CLASS(path_track, CPathTrack);
|
||||
|
||||
//
|
||||
// Cache user-entity-field values until spawn is called.
|
||||
//
|
||||
void CPathTrack :: KeyValue( KeyValueData *pkvd )
|
||||
void CPathTrack::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "altpath"))
|
||||
{
|
||||
|
@ -141,113 +79,97 @@ void CPathTrack :: KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CPointEntity::KeyValue( pkvd );
|
||||
CPointEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void CPathTrack::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
int on;
|
||||
|
||||
// Use toggles between two paths
|
||||
if ( m_paltpath )
|
||||
if (m_paltpath)
|
||||
{
|
||||
on = !FBitSet( pev->spawnflags, SF_PATH_ALTERNATE );
|
||||
if ( ShouldToggle( useType, on ) )
|
||||
int on = !FBitSet(pev->spawnflags, SF_PATH_ALTERNATE);
|
||||
|
||||
if (ShouldToggle(useType, on))
|
||||
{
|
||||
if ( on )
|
||||
SetBits( pev->spawnflags, SF_PATH_ALTERNATE );
|
||||
if (on)
|
||||
SetBits(pev->spawnflags, SF_PATH_ALTERNATE);
|
||||
else
|
||||
ClearBits( pev->spawnflags, SF_PATH_ALTERNATE );
|
||||
ClearBits(pev->spawnflags, SF_PATH_ALTERNATE);
|
||||
}
|
||||
}
|
||||
else // Use toggles between enabled/disabled
|
||||
else
|
||||
{
|
||||
on = !FBitSet( pev->spawnflags, SF_PATH_DISABLED );
|
||||
int on = !FBitSet(pev->spawnflags, SF_PATH_DISABLED);
|
||||
|
||||
if ( ShouldToggle( useType, on ) )
|
||||
if (ShouldToggle(useType, on))
|
||||
{
|
||||
if ( on )
|
||||
SetBits( pev->spawnflags, SF_PATH_DISABLED );
|
||||
if (on)
|
||||
SetBits(pev->spawnflags, SF_PATH_DISABLED);
|
||||
else
|
||||
ClearBits( pev->spawnflags, SF_PATH_DISABLED );
|
||||
ClearBits(pev->spawnflags, SF_PATH_DISABLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPathTrack :: Link( void )
|
||||
void CPathTrack::Link(void)
|
||||
{
|
||||
edict_t *pentTarget;
|
||||
|
||||
if ( !FStringNull(pev->target) )
|
||||
if (!FStringNull(pev->target))
|
||||
{
|
||||
pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) );
|
||||
if ( !FNullEnt(pentTarget) )
|
||||
{
|
||||
m_pnext = CPathTrack::Instance( pentTarget );
|
||||
edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(pev->target));
|
||||
|
||||
if ( m_pnext ) // If no next pointer, this is the end of a path
|
||||
{
|
||||
m_pnext->SetPrevious( this );
|
||||
}
|
||||
if (!FNullEnt(pentTarget))
|
||||
{
|
||||
m_pnext = CPathTrack::Instance(pentTarget);
|
||||
|
||||
if (m_pnext)
|
||||
m_pnext->SetPrevious(this);
|
||||
}
|
||||
else
|
||||
ALERT( at_console, "Dead end link %s\n", STRING(pev->target) );
|
||||
ALERT(at_console, "Dead end link %s\n", STRING(pev->target));
|
||||
}
|
||||
|
||||
// Find "alternate" path
|
||||
if ( m_altName )
|
||||
if (m_altName)
|
||||
{
|
||||
pentTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_altName) );
|
||||
if ( !FNullEnt(pentTarget) )
|
||||
{
|
||||
m_paltpath = CPathTrack::Instance( pentTarget );
|
||||
edict_t *pentTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_altName));
|
||||
|
||||
if ( m_paltpath ) // If no next pointer, this is the end of a path
|
||||
{
|
||||
m_paltpath->SetPrevious( this );
|
||||
}
|
||||
if (!FNullEnt(pentTarget))
|
||||
{
|
||||
m_paltpath = CPathTrack::Instance(pentTarget);
|
||||
|
||||
if (m_paltpath)
|
||||
m_paltpath->SetPrevious(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPathTrack :: Spawn( void )
|
||||
void CPathTrack::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_TRIGGER;
|
||||
UTIL_SetSize(pev, Vector(-8, -8, -8), Vector(8, 8, 8));
|
||||
|
||||
m_pnext = NULL;
|
||||
m_pprevious = NULL;
|
||||
// DEBUGGING CODE
|
||||
#if PATH_SPARKLE_DEBUG
|
||||
SetThink( Sparkle );
|
||||
pev->nextthink = gpGlobals->time + 0.5;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CPathTrack::Activate( void )
|
||||
void CPathTrack::Activate(void)
|
||||
{
|
||||
if ( !FStringNull( pev->targetname ) ) // Link to next, and back-link
|
||||
if (!FStringNull(pev->targetname))
|
||||
Link();
|
||||
}
|
||||
|
||||
CPathTrack *CPathTrack :: ValidPath( CPathTrack *ppath, int testFlag )
|
||||
CPathTrack *CPathTrack::ValidPath(CPathTrack *ppath, int testFlag)
|
||||
{
|
||||
if ( !ppath )
|
||||
if (!ppath)
|
||||
return NULL;
|
||||
|
||||
if ( testFlag && FBitSet( ppath->pev->spawnflags, SF_PATH_DISABLED ) )
|
||||
if (testFlag && FBitSet(ppath->pev->spawnflags, SF_PATH_DISABLED))
|
||||
return NULL;
|
||||
|
||||
return ppath;
|
||||
}
|
||||
|
||||
|
||||
void CPathTrack :: Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist )
|
||||
void CPathTrack::Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist)
|
||||
{
|
||||
if ( pstart && pend )
|
||||
if (pstart && pend)
|
||||
{
|
||||
Vector dir = (pend->pev->origin - pstart->pev->origin);
|
||||
dir = dir.Normalize();
|
||||
|
@ -255,61 +177,56 @@ void CPathTrack :: Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin
|
|||
}
|
||||
}
|
||||
|
||||
CPathTrack *CPathTrack::GetNext( void )
|
||||
CPathTrack *CPathTrack::GetNext(void)
|
||||
{
|
||||
if ( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && !FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) )
|
||||
if (m_paltpath && FBitSet(pev->spawnflags, SF_PATH_ALTERNATE) && !FBitSet(pev->spawnflags, SF_PATH_ALTREVERSE))
|
||||
return m_paltpath;
|
||||
|
||||
|
||||
return m_pnext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CPathTrack *CPathTrack::GetPrevious( void )
|
||||
CPathTrack *CPathTrack::GetPrevious(void)
|
||||
{
|
||||
if ( m_paltpath && FBitSet( pev->spawnflags, SF_PATH_ALTERNATE ) && FBitSet( pev->spawnflags, SF_PATH_ALTREVERSE ) )
|
||||
if (m_paltpath && FBitSet(pev->spawnflags, SF_PATH_ALTERNATE) && FBitSet(pev->spawnflags, SF_PATH_ALTREVERSE))
|
||||
return m_paltpath;
|
||||
|
||||
|
||||
return m_pprevious;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CPathTrack::SetPrevious( CPathTrack *pprev )
|
||||
void CPathTrack::SetPrevious(CPathTrack *pprev)
|
||||
{
|
||||
// Only set previous if this isn't my alternate path
|
||||
if ( pprev && !FStrEq( STRING(pprev->pev->targetname), STRING(m_altName) ) )
|
||||
if (pprev && !FStrEq(STRING(pprev->pev->targetname), STRING(m_altName)))
|
||||
m_pprevious = pprev;
|
||||
}
|
||||
|
||||
|
||||
// Assumes this is ALWAYS enabled
|
||||
CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move )
|
||||
CPathTrack *CPathTrack::LookAhead(Vector *origin, float dist, int move)
|
||||
{
|
||||
CPathTrack *pcurrent;
|
||||
float originalDist = dist;
|
||||
|
||||
pcurrent = this;
|
||||
CPathTrack *pcurrent = this;
|
||||
Vector currentPos = *origin;
|
||||
|
||||
if ( dist < 0 ) // Travelling backwards through path
|
||||
if (dist < 0)
|
||||
{
|
||||
dist = -dist;
|
||||
while ( dist > 0 )
|
||||
|
||||
while (dist > 0)
|
||||
{
|
||||
Vector dir = pcurrent->pev->origin - currentPos;
|
||||
float length = dir.Length();
|
||||
if ( !length )
|
||||
|
||||
if (!length)
|
||||
{
|
||||
if ( !ValidPath(pcurrent->GetPrevious(), move) ) // If there is no previous node, or it's disabled, return now.
|
||||
if (!ValidPath(pcurrent->GetPrevious(), move))
|
||||
{
|
||||
if ( !move )
|
||||
Project( pcurrent->GetNext(), pcurrent, origin, dist );
|
||||
if (!move)
|
||||
Project(pcurrent->GetNext(), pcurrent, origin, dist);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcurrent = pcurrent->GetPrevious();
|
||||
}
|
||||
else if ( length > dist ) // enough left in this path to move
|
||||
else if (length > dist)
|
||||
{
|
||||
*origin = currentPos + (dir * (dist / length));
|
||||
return pcurrent;
|
||||
|
@ -319,34 +236,41 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move )
|
|||
dist -= length;
|
||||
currentPos = pcurrent->pev->origin;
|
||||
*origin = currentPos;
|
||||
if ( !ValidPath(pcurrent->GetPrevious(), move) ) // If there is no previous node, or it's disabled, return now.
|
||||
|
||||
if (!ValidPath(pcurrent->GetPrevious(), move))
|
||||
return NULL;
|
||||
|
||||
pcurrent = pcurrent->GetPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
*origin = currentPos;
|
||||
return pcurrent;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
while ( dist > 0 )
|
||||
while (dist > 0)
|
||||
{
|
||||
if ( !ValidPath(pcurrent->GetNext(), move) ) // If there is no next node, or it's disabled, return now.
|
||||
if (!ValidPath(pcurrent->GetNext(), move))
|
||||
{
|
||||
if ( !move )
|
||||
Project( pcurrent->GetPrevious(), pcurrent, origin, dist );
|
||||
if (!move)
|
||||
Project(pcurrent->GetPrevious(), pcurrent, origin, dist);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Vector dir = pcurrent->GetNext()->pev->origin - currentPos;
|
||||
float length = dir.Length();
|
||||
if ( !length && !ValidPath( pcurrent->GetNext()->GetNext(), move ) )
|
||||
|
||||
if (!length && !ValidPath(pcurrent->GetNext()->GetNext(), move))
|
||||
{
|
||||
if ( dist == originalDist ) // HACK -- up against a dead end
|
||||
if (dist == originalDist)
|
||||
return NULL;
|
||||
|
||||
return pcurrent;
|
||||
}
|
||||
if ( length > dist ) // enough left in this path to move
|
||||
|
||||
if (length > dist)
|
||||
{
|
||||
*origin = currentPos + (dir * (dist / length));
|
||||
return pcurrent;
|
||||
|
@ -359,70 +283,52 @@ CPathTrack *CPathTrack :: LookAhead( Vector *origin, float dist, int move )
|
|||
*origin = currentPos;
|
||||
}
|
||||
}
|
||||
|
||||
*origin = currentPos;
|
||||
}
|
||||
|
||||
return pcurrent;
|
||||
}
|
||||
|
||||
|
||||
// Assumes this is ALWAYS enabled
|
||||
CPathTrack *CPathTrack :: Nearest( Vector origin )
|
||||
CPathTrack *CPathTrack::Nearest(Vector origin)
|
||||
{
|
||||
int deadCount;
|
||||
float minDist, dist;
|
||||
Vector delta;
|
||||
CPathTrack *ppath, *pnearest;
|
||||
|
||||
|
||||
delta = origin - pev->origin;
|
||||
Vector delta = origin - pev->origin;
|
||||
delta.z = 0;
|
||||
minDist = delta.Length();
|
||||
pnearest = this;
|
||||
ppath = GetNext();
|
||||
float minDist = delta.Length();
|
||||
CPathTrack *pnearest = this;
|
||||
CPathTrack *ppath = GetNext();
|
||||
int deadCount = 0;
|
||||
|
||||
// Hey, I could use the old 2 racing pointers solution to this, but I'm lazy :)
|
||||
deadCount = 0;
|
||||
while ( ppath && ppath != this )
|
||||
while (ppath && ppath !=this)
|
||||
{
|
||||
deadCount++;
|
||||
if ( deadCount > 9999 )
|
||||
|
||||
if (deadCount > 9999)
|
||||
{
|
||||
ALERT( at_error, "Bad sequence of path_tracks from %s", STRING(pev->targetname) );
|
||||
ALERT(at_error, "Bad sequence of path_tracks from %s", STRING(pev->targetname));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
delta = origin - ppath->pev->origin;
|
||||
delta.z = 0;
|
||||
dist = delta.Length();
|
||||
if ( dist < minDist )
|
||||
float dist = delta.Length();
|
||||
|
||||
if (dist < minDist)
|
||||
{
|
||||
minDist = dist;
|
||||
pnearest = ppath;
|
||||
}
|
||||
|
||||
ppath = ppath->GetNext();
|
||||
}
|
||||
|
||||
return pnearest;
|
||||
}
|
||||
|
||||
|
||||
CPathTrack *CPathTrack::Instance( edict_t *pent )
|
||||
{
|
||||
if ( FClassnameIs( pent, "path_track" ) )
|
||||
return (CPathTrack *)GET_PRIVATE(pent);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// DEBUGGING CODE
|
||||
#if PATH_SPARKLE_DEBUG
|
||||
void CPathTrack :: Sparkle( void )
|
||||
CPathTrack *CPathTrack::Instance(edict_t *pent)
|
||||
{
|
||||
if (FClassnameIs(pent, "path_track"))
|
||||
return (CPathTrack *)GET_PRIVATE(pent);
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.2;
|
||||
if ( FBitSet( pev->spawnflags, SF_PATH_DISABLED ) )
|
||||
UTIL_ParticleEffect(pev->origin, Vector(0,0,100), 210, 10);
|
||||
else
|
||||
UTIL_ParticleEffect(pev->origin, Vector(0,0,100), 84, 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,49 +12,31 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "plane.h"
|
||||
|
||||
//=========================================================
|
||||
// Plane
|
||||
//=========================================================
|
||||
CPlane :: CPlane ( void )
|
||||
CPlane::CPlane(void)
|
||||
{
|
||||
m_fInitialized = FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// InitializePlane - Takes a normal for the plane and a
|
||||
// point on the plane and
|
||||
//=========================================================
|
||||
void CPlane :: InitializePlane ( const Vector &vecNormal, const Vector &vecPoint )
|
||||
void CPlane::InitializePlane(const Vector &vecNormal, const Vector &vecPoint)
|
||||
{
|
||||
m_vecNormal = vecNormal;
|
||||
m_flDist = DotProduct ( m_vecNormal, vecPoint );
|
||||
m_flDist = DotProduct(m_vecNormal, vecPoint);
|
||||
m_fInitialized = TRUE;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// PointInFront - determines whether the given vector is
|
||||
// in front of the plane.
|
||||
//=========================================================
|
||||
BOOL CPlane :: PointInFront ( const Vector &vecPoint )
|
||||
BOOL CPlane::PointInFront(const Vector &vecPoint)
|
||||
{
|
||||
float flFace;
|
||||
|
||||
if ( !m_fInitialized )
|
||||
{
|
||||
if (!m_fInitialized)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flFace = DotProduct ( m_vecNormal, vecPoint ) - m_flDist;
|
||||
float flFace = DotProduct(m_vecNormal, vecPoint) - m_flDist;
|
||||
|
||||
if ( flFace >= 0 )
|
||||
{
|
||||
if (flFace >= 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
34
dlls/plane.h
34
dlls/plane.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,29 +15,19 @@
|
|||
#ifndef PLANE_H
|
||||
#define PLANE_H
|
||||
|
||||
//=========================================================
|
||||
// Plane
|
||||
//=========================================================
|
||||
class CPlane
|
||||
{
|
||||
public:
|
||||
CPlane ( void );
|
||||
CPlane(void);
|
||||
|
||||
//=========================================================
|
||||
// InitializePlane - Takes a normal for the plane and a
|
||||
// point on the plane and
|
||||
//=========================================================
|
||||
void InitializePlane ( const Vector &vecNormal, const Vector &vecPoint );
|
||||
public:
|
||||
void InitializePlane(const Vector &vecNormal, const Vector &vecPoint);
|
||||
BOOL PointInFront(const Vector &vecPoint);
|
||||
|
||||
//=========================================================
|
||||
// PointInFront - determines whether the given vector is
|
||||
// in front of the plane.
|
||||
//=========================================================
|
||||
BOOL PointInFront ( const Vector &vecPoint );
|
||||
|
||||
Vector m_vecNormal;
|
||||
float m_flDist;
|
||||
BOOL m_fInitialized;
|
||||
public:
|
||||
Vector m_vecNormal;
|
||||
float m_flDist;
|
||||
BOOL m_fInitialized;
|
||||
};
|
||||
|
||||
#endif // PLANE_H
|
||||
#endif
|
2220
dlls/plats.cpp
2220
dlls/plats.cpp
File diff suppressed because it is too large
Load Diff
9428
dlls/player.cpp
9428
dlls/player.cpp
File diff suppressed because it is too large
Load Diff
1278
dlls/player.h
1278
dlls/player.h
File diff suppressed because it is too large
Load Diff
320
dlls/python.cpp
320
dlls/python.cpp
|
@ -1,320 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "weapons.h"
|
||||
#include "monsters.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
enum python_e {
|
||||
PYTHON_IDLE1 = 0,
|
||||
PYTHON_FIDGET,
|
||||
PYTHON_FIRE1,
|
||||
PYTHON_RELOAD,
|
||||
PYTHON_HOLSTER,
|
||||
PYTHON_DRAW,
|
||||
PYTHON_IDLE2,
|
||||
PYTHON_IDLE3
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_python, CPython );
|
||||
LINK_ENTITY_TO_CLASS( weapon_357, CPython );
|
||||
|
||||
int CPython::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "357";
|
||||
p->iMaxAmmo1 = _357_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = PYTHON_MAX_CLIP;
|
||||
p->iFlags = 0;
|
||||
p->iSlot = 1;
|
||||
p->iPosition = 1;
|
||||
p->iId = m_iId = WEAPON_PYTHON;
|
||||
p->iWeight = PYTHON_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CPython::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CPython::Spawn( )
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_357"); // hack to allow for old names
|
||||
Precache( );
|
||||
m_iId = WEAPON_PYTHON;
|
||||
SET_MODEL(ENT(pev), "models/w_357.mdl");
|
||||
|
||||
m_iDefaultAmmo = PYTHON_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CPython::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_357.mdl");
|
||||
PRECACHE_MODEL("models/w_357.mdl");
|
||||
PRECACHE_MODEL("models/p_357.mdl");
|
||||
|
||||
PRECACHE_MODEL("models/w_357ammobox.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
PRECACHE_SOUND ("weapons/357_reload1.wav");
|
||||
PRECACHE_SOUND ("weapons/357_cock1.wav");
|
||||
PRECACHE_SOUND ("weapons/357_shot1.wav");
|
||||
PRECACHE_SOUND ("weapons/357_shot2.wav");
|
||||
|
||||
m_usFirePython = PRECACHE_EVENT( 1, "events/python.sc" );
|
||||
}
|
||||
|
||||
BOOL CPython::Deploy( )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
// enable laser sight geometry.
|
||||
pev->body = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->body = 0;
|
||||
}
|
||||
|
||||
return DefaultDeploy( "models/v_357.mdl", "models/p_357.mdl", PYTHON_DRAW, "python", UseDecrement(), pev->body );
|
||||
}
|
||||
|
||||
|
||||
void CPython::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_fInReload = FALSE;// cancel any reload in progress.
|
||||
|
||||
if ( m_fInZoom )
|
||||
{
|
||||
SecondaryAttack();
|
||||
}
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
SendWeaponAnim( PYTHON_HOLSTER );
|
||||
}
|
||||
|
||||
void CPython::SecondaryAttack( void )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
if ( !bIsMultiplayer() )
|
||||
#else
|
||||
if ( !g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pPlayer->pev->fov != 0 )
|
||||
{
|
||||
m_fInZoom = FALSE;
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
}
|
||||
else if ( m_pPlayer->pev->fov != 40 )
|
||||
{
|
||||
m_fInZoom = TRUE;
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40;
|
||||
}
|
||||
|
||||
m_flNextSecondaryAttack = 0.5;
|
||||
}
|
||||
|
||||
void CPython::PrimaryAttack()
|
||||
{
|
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextPrimaryAttack = 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (!m_fFireOnEmpty)
|
||||
Reload( );
|
||||
else
|
||||
{
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM);
|
||||
m_flNextPrimaryAttack = 0.15;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
|
||||
m_iClip--;
|
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
Vector vecDir;
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usFirePython, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flNextPrimaryAttack = 0.75;
|
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
|
||||
void CPython::Reload( void )
|
||||
{
|
||||
if ( m_pPlayer->ammo_357 <= 0 )
|
||||
return;
|
||||
|
||||
if ( m_pPlayer->pev->fov != 0 )
|
||||
{
|
||||
m_fInZoom = FALSE;
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
||||
}
|
||||
|
||||
int bUseScope = FALSE;
|
||||
#ifdef CLIENT_DLL
|
||||
bUseScope = bIsMultiplayer();
|
||||
#else
|
||||
bUseScope = g_pGameRules->IsMultiplayer();
|
||||
#endif
|
||||
|
||||
if (DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ))
|
||||
{
|
||||
m_flSoundDelay = 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPython::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
// ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay );
|
||||
if (m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() )
|
||||
{
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT(0.8, 0.9), ATTN_NORM);
|
||||
m_flSoundDelay = 0;
|
||||
}
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
if (flRand <= 0.5)
|
||||
{
|
||||
iAnim = PYTHON_IDLE1;
|
||||
m_flTimeWeaponIdle = (70.0/30.0);
|
||||
}
|
||||
else if (flRand <= 0.7)
|
||||
{
|
||||
iAnim = PYTHON_IDLE2;
|
||||
m_flTimeWeaponIdle = (60.0/30.0);
|
||||
}
|
||||
else if (flRand <= 0.9)
|
||||
{
|
||||
iAnim = PYTHON_IDLE3;
|
||||
m_flTimeWeaponIdle = (88.0/30.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = PYTHON_FIDGET;
|
||||
m_flTimeWeaponIdle = (170.0/30.0);
|
||||
}
|
||||
|
||||
int bUseScope = FALSE;
|
||||
#ifdef CLIENT_DLL
|
||||
bUseScope = bIsMultiplayer();
|
||||
#else
|
||||
bUseScope = g_pGameRules->IsMultiplayer();
|
||||
#endif
|
||||
|
||||
SendWeaponAnim( iAnim, UseDecrement() ? 1 : 0, bUseScope );
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CPythonAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_357ammobox.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_357ammobox.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_357BOX_GIVE, "357", _357_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_357, CPythonAmmo );
|
||||
|
||||
|
||||
#endif
|
617
dlls/rpg.cpp
617
dlls/rpg.cpp
|
@ -1,617 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
|
||||
|
||||
enum rpg_e {
|
||||
RPG_IDLE = 0,
|
||||
RPG_FIDGET,
|
||||
RPG_RELOAD, // to reload
|
||||
RPG_FIRE2, // to empty
|
||||
RPG_HOLSTER1, // loaded
|
||||
RPG_DRAW1, // loaded
|
||||
RPG_HOLSTER2, // unloaded
|
||||
RPG_DRAW_UL, // unloaded
|
||||
RPG_IDLE_UL, // unloaded idle
|
||||
RPG_FIDGET_UL, // unloaded fidget
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_rpg, CRpg );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
LINK_ENTITY_TO_CLASS( laser_spot, CLaserSpot );
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
CLaserSpot *CLaserSpot::CreateSpot( void )
|
||||
{
|
||||
CLaserSpot *pSpot = GetClassPtr( (CLaserSpot *)NULL );
|
||||
pSpot->Spawn();
|
||||
|
||||
pSpot->pev->classname = MAKE_STRING("laser_spot");
|
||||
|
||||
return pSpot;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CLaserSpot::Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
pev->movetype = MOVETYPE_NONE;
|
||||
pev->solid = SOLID_NOT;
|
||||
|
||||
pev->rendermode = kRenderGlow;
|
||||
pev->renderfx = kRenderFxNoDissipation;
|
||||
pev->renderamt = 255;
|
||||
|
||||
SET_MODEL(ENT(pev), "sprites/laserdot.spr");
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
};
|
||||
|
||||
//=========================================================
|
||||
// Suspend- make the laser sight invisible.
|
||||
//=========================================================
|
||||
void CLaserSpot::Suspend( float flSuspendTime )
|
||||
{
|
||||
pev->effects |= EF_NODRAW;
|
||||
|
||||
SetThink( Revive );
|
||||
pev->nextthink = gpGlobals->time + flSuspendTime;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Revive - bring a suspended laser sight back.
|
||||
//=========================================================
|
||||
void CLaserSpot::Revive( void )
|
||||
{
|
||||
pev->effects &= ~EF_NODRAW;
|
||||
|
||||
ResetThink( );
|
||||
}
|
||||
|
||||
void CLaserSpot::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("sprites/laserdot.spr");
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( rpg_rocket, CRpgRocket );
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
CRpgRocket *CRpgRocket::CreateRpgRocket( Vector vecOrigin, Vector vecAngles, CBaseEntity *pOwner, CRpg *pLauncher )
|
||||
{
|
||||
CRpgRocket *pRocket = GetClassPtr( (CRpgRocket *)NULL );
|
||||
|
||||
UTIL_SetOrigin( pRocket->pev, vecOrigin );
|
||||
pRocket->pev->angles = vecAngles;
|
||||
pRocket->Spawn();
|
||||
pRocket->SetTouch( CRpgRocket::RocketTouch );
|
||||
pRocket->m_pLauncher = pLauncher;// remember what RPG fired me.
|
||||
pRocket->m_pLauncher->m_cActiveRockets++;// register this missile as active for the launcher
|
||||
pRocket->pev->owner = pOwner->edict();
|
||||
|
||||
return pRocket;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CRpgRocket :: Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
// motor
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/rpgrocket.mdl");
|
||||
UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
pev->classname = MAKE_STRING("rpg_rocket");
|
||||
|
||||
SetThink( IgniteThink );
|
||||
SetTouch( ExplodeTouch );
|
||||
|
||||
pev->angles.x -= 30;
|
||||
UTIL_MakeVectors( pev->angles );
|
||||
pev->angles.x = -(pev->angles.x + 30);
|
||||
|
||||
pev->velocity = gpGlobals->v_forward * 250;
|
||||
pev->gravity = 0.5;
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.4;
|
||||
|
||||
pev->dmg = gSkillData.plrDmgRPG;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CRpgRocket :: RocketTouch ( CBaseEntity *pOther )
|
||||
{
|
||||
if ( m_pLauncher )
|
||||
{
|
||||
// my launcher is still around, tell it I'm dead.
|
||||
m_pLauncher->m_cActiveRockets--;
|
||||
}
|
||||
|
||||
STOP_SOUND( edict(), CHAN_VOICE, "weapons/rocket1.wav" );
|
||||
ExplodeTouch( pOther );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CRpgRocket :: Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/rpgrocket.mdl");
|
||||
m_iTrail = PRECACHE_MODEL("sprites/smoke.spr");
|
||||
PRECACHE_SOUND ("weapons/rocket1.wav");
|
||||
}
|
||||
|
||||
|
||||
void CRpgRocket :: IgniteThink( void )
|
||||
{
|
||||
// pev->movetype = MOVETYPE_TOSS;
|
||||
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->effects |= EF_LIGHT;
|
||||
|
||||
// make rocket sound
|
||||
EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav", 1, 0.5 );
|
||||
|
||||
// rocket trail
|
||||
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
||||
|
||||
WRITE_BYTE( TE_BEAMFOLLOW );
|
||||
WRITE_SHORT(entindex()); // entity
|
||||
WRITE_SHORT(m_iTrail ); // model
|
||||
WRITE_BYTE( 40 ); // life
|
||||
WRITE_BYTE( 5 ); // width
|
||||
WRITE_BYTE( 224 ); // r, g, b
|
||||
WRITE_BYTE( 224 ); // r, g, b
|
||||
WRITE_BYTE( 255 ); // r, g, b
|
||||
WRITE_BYTE( 255 ); // brightness
|
||||
|
||||
MESSAGE_END(); // move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)
|
||||
|
||||
m_flIgniteTime = gpGlobals->time;
|
||||
|
||||
// set to follow laser spot
|
||||
SetThink( FollowThink );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
|
||||
void CRpgRocket :: FollowThink( void )
|
||||
{
|
||||
CBaseEntity *pOther = NULL;
|
||||
Vector vecTarget;
|
||||
Vector vecDir;
|
||||
float flDist, flMax, flDot;
|
||||
TraceResult tr;
|
||||
|
||||
UTIL_MakeAimVectors( pev->angles );
|
||||
|
||||
vecTarget = gpGlobals->v_forward;
|
||||
flMax = 4096;
|
||||
|
||||
// Examine all entities within a reasonable radius
|
||||
while ((pOther = UTIL_FindEntityByClassname( pOther, "laser_spot" )) != NULL)
|
||||
{
|
||||
UTIL_TraceLine ( pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr );
|
||||
// ALERT( at_console, "%f\n", tr.flFraction );
|
||||
if (tr.flFraction >= 0.90)
|
||||
{
|
||||
vecDir = pOther->pev->origin - pev->origin;
|
||||
flDist = vecDir.Length( );
|
||||
vecDir = vecDir.Normalize( );
|
||||
flDot = DotProduct( gpGlobals->v_forward, vecDir );
|
||||
if ((flDot > 0) && (flDist * (1 - flDot) < flMax))
|
||||
{
|
||||
flMax = flDist * (1 - flDot);
|
||||
vecTarget = vecDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pev->angles = UTIL_VecToAngles( vecTarget );
|
||||
|
||||
// this acceleration and turning math is totally wrong, but it seems to respond well so don't change it.
|
||||
float flSpeed = pev->velocity.Length();
|
||||
if (gpGlobals->time - m_flIgniteTime < 1.0)
|
||||
{
|
||||
pev->velocity = pev->velocity * 0.2 + vecTarget * (flSpeed * 0.8 + 400);
|
||||
if (pev->waterlevel == 3)
|
||||
{
|
||||
// go slow underwater
|
||||
if (pev->velocity.Length() > 300)
|
||||
{
|
||||
pev->velocity = pev->velocity.Normalize() * 300;
|
||||
}
|
||||
UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pev->velocity.Length() > 2000)
|
||||
{
|
||||
pev->velocity = pev->velocity.Normalize() * 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pev->effects & EF_LIGHT)
|
||||
{
|
||||
pev->effects = 0;
|
||||
STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/rocket1.wav" );
|
||||
}
|
||||
pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798;
|
||||
if (pev->waterlevel == 0 && pev->velocity.Length() < 1500)
|
||||
{
|
||||
Detonate( );
|
||||
}
|
||||
}
|
||||
// ALERT( at_console, "%.0f\n", flSpeed );
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void CRpg::Reload( void )
|
||||
{
|
||||
int iResult;
|
||||
|
||||
if ( m_iClip == 1 )
|
||||
{
|
||||
// don't bother with any of this if don't need to reload.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pPlayer->ammo_rockets <= 0 )
|
||||
return;
|
||||
|
||||
// because the RPG waits to autoreload when no missiles are active while the LTD is on, the
|
||||
// weapons code is constantly calling into this function, but is often denied because
|
||||
// a) missiles are in flight, but the LTD is on
|
||||
// or
|
||||
// b) player is totally out of ammo and has nothing to switch to, and should be allowed to
|
||||
// shine the designator around
|
||||
//
|
||||
// Set the next attack time into the future so that WeaponIdle will get called more often
|
||||
// than reload, allowing the RPG LTD to be updated
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
if ( m_cActiveRockets && m_fSpotActive )
|
||||
{
|
||||
// no reloading when there are active missiles tracking the designator.
|
||||
// ward off future autoreload attempts by setting next attack time into the future for a bit.
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if ( m_pSpot && m_fSpotActive )
|
||||
{
|
||||
m_pSpot->Suspend( 2.1 );
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( m_iClip == 0 )
|
||||
iResult = DefaultReload( RPG_MAX_CLIP, RPG_RELOAD, 2 );
|
||||
|
||||
if ( iResult )
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
|
||||
}
|
||||
|
||||
void CRpg::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_RPG;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/w_rpg.mdl");
|
||||
m_fSpotActive = 1;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
// more default ammo in multiplay.
|
||||
m_iDefaultAmmo = RPG_DEFAULT_GIVE * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iDefaultAmmo = RPG_DEFAULT_GIVE;
|
||||
}
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CRpg::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_rpg.mdl");
|
||||
PRECACHE_MODEL("models/v_rpg.mdl");
|
||||
PRECACHE_MODEL("models/p_rpg.mdl");
|
||||
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
UTIL_PrecacheOther( "laser_spot" );
|
||||
UTIL_PrecacheOther( "rpg_rocket" );
|
||||
|
||||
PRECACHE_SOUND("weapons/rocketfire1.wav");
|
||||
PRECACHE_SOUND("weapons/glauncher.wav"); // alternative fire sound
|
||||
|
||||
m_usRpg = PRECACHE_EVENT ( 1, "events/rpg.sc" );
|
||||
}
|
||||
|
||||
|
||||
int CRpg::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "rockets";
|
||||
p->iMaxAmmo1 = ROCKET_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = RPG_MAX_CLIP;
|
||||
p->iSlot = 3;
|
||||
p->iPosition = 0;
|
||||
p->iId = m_iId = WEAPON_RPG;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = RPG_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRpg::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CRpg::Deploy( )
|
||||
{
|
||||
if ( m_iClip == 0 )
|
||||
{
|
||||
return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW_UL, "rpg" );
|
||||
}
|
||||
|
||||
return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW1, "rpg" );
|
||||
}
|
||||
|
||||
|
||||
BOOL CRpg::CanHolster( void )
|
||||
{
|
||||
if ( m_fSpotActive && m_cActiveRockets )
|
||||
{
|
||||
// can't put away while guiding a missile.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CRpg::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_fInReload = FALSE;// cancel any reload in progress.
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
SendWeaponAnim( RPG_HOLSTER1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if (m_pSpot)
|
||||
{
|
||||
m_pSpot->Killed( NULL, GIB_NEVER );
|
||||
m_pSpot = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CRpg::PrimaryAttack()
|
||||
{
|
||||
if ( m_iClip )
|
||||
{
|
||||
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8;
|
||||
|
||||
CRpgRocket *pRocket = CRpgRocket::CreateRpgRocket( vecSrc, m_pPlayer->pev->v_angle, m_pPlayer, this );
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );// RpgRocket::Create stomps on globals, so remake.
|
||||
pRocket->pev->velocity = pRocket->pev->velocity + gpGlobals->v_forward * DotProduct( m_pPlayer->pev->velocity, gpGlobals->v_forward );
|
||||
#endif
|
||||
|
||||
// firing RPG no longer turns on the designator. ALT fire is a toggle switch for the LTD.
|
||||
// Ken signed up for this as a global change (sjb)
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usRpg );
|
||||
|
||||
m_iClip--;
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayEmptySound( );
|
||||
}
|
||||
UpdateSpot( );
|
||||
}
|
||||
|
||||
|
||||
void CRpg::SecondaryAttack()
|
||||
{
|
||||
m_fSpotActive = ! m_fSpotActive;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if (!m_fSpotActive && m_pSpot)
|
||||
{
|
||||
m_pSpot->Killed( NULL, GIB_NORMAL );
|
||||
m_pSpot = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
|
||||
void CRpg::WeaponIdle( void )
|
||||
{
|
||||
UpdateSpot( );
|
||||
|
||||
ResetEmptySound( );
|
||||
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
|
||||
{
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.75 || m_fSpotActive)
|
||||
{
|
||||
if ( m_iClip == 0 )
|
||||
iAnim = RPG_IDLE_UL;
|
||||
else
|
||||
iAnim = RPG_IDLE;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 15.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_iClip == 0 )
|
||||
iAnim = RPG_FIDGET_UL;
|
||||
else
|
||||
iAnim = RPG_FIDGET;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
|
||||
}
|
||||
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CRpg::UpdateSpot( void )
|
||||
{
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
if (m_fSpotActive)
|
||||
{
|
||||
if (!m_pSpot)
|
||||
{
|
||||
m_pSpot = CLaserSpot::CreateSpot();
|
||||
}
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );;
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine ( vecSrc, vecSrc + vecAiming * 8192, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr );
|
||||
|
||||
UTIL_SetOrigin( m_pSpot->pev, tr.vecEndPos );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
class CRpgAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_rpgammo.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_rpgammo.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
int iGive;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
// hand out more ammo per rocket in multiplayer.
|
||||
iGive = AMMO_RPGCLIP_GIVE * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iGive = AMMO_RPGCLIP_GIVE;
|
||||
}
|
||||
|
||||
if (pOther->GiveAmmo( iGive, "rockets", ROCKET_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_rpgclip, CRpgAmmo );
|
||||
|
||||
#endif
|
494
dlls/satchel.cpp
494
dlls/satchel.cpp
|
@ -1,494 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
enum satchel_e {
|
||||
SATCHEL_IDLE1 = 0,
|
||||
SATCHEL_FIDGET1,
|
||||
SATCHEL_DRAW,
|
||||
SATCHEL_DROP
|
||||
};
|
||||
|
||||
enum satchel_radio_e {
|
||||
SATCHEL_RADIO_IDLE1 = 0,
|
||||
SATCHEL_RADIO_FIDGET1,
|
||||
SATCHEL_RADIO_DRAW,
|
||||
SATCHEL_RADIO_FIRE,
|
||||
SATCHEL_RADIO_HOLSTER
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CSatchelCharge : public CGrenade
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void BounceSound( void );
|
||||
|
||||
void EXPORT SatchelSlide( CBaseEntity *pOther );
|
||||
void EXPORT SatchelThink( void );
|
||||
|
||||
public:
|
||||
void Deactivate( void );
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge );
|
||||
|
||||
//=========================================================
|
||||
// Deactivate - do whatever it is we do to an orphaned
|
||||
// satchel when we don't want it in the world anymore.
|
||||
//=========================================================
|
||||
void CSatchelCharge::Deactivate( void )
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
UTIL_Remove( this );
|
||||
}
|
||||
|
||||
|
||||
void CSatchelCharge :: Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
// motor
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/w_satchel.mdl");
|
||||
//UTIL_SetSize(pev, Vector( -16, -16, -4), Vector(16, 16, 32)); // Old box -- size of headcrab monsters/players get blocked by this
|
||||
UTIL_SetSize(pev, Vector( -4, -4, -4), Vector(4, 4, 4)); // Uses point-sized, and can be stepped over
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
SetTouch( SatchelSlide );
|
||||
SetUse( DetonateUse );
|
||||
SetThink( SatchelThink );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
pev->gravity = 0.5;
|
||||
pev->friction = 0.8;
|
||||
|
||||
pev->dmg = gSkillData.plrDmgSatchel;
|
||||
// ResetSequenceInfo( );
|
||||
pev->sequence = 1;
|
||||
}
|
||||
|
||||
|
||||
void CSatchelCharge::SatchelSlide( CBaseEntity *pOther )
|
||||
{
|
||||
entvars_t *pevOther = pOther->pev;
|
||||
|
||||
// don't hit the guy that launched this grenade
|
||||
if ( pOther->edict() == pev->owner )
|
||||
return;
|
||||
|
||||
// pev->avelocity = Vector (300, 300, 300);
|
||||
pev->gravity = 1;// normal gravity now
|
||||
|
||||
// HACKHACK - On ground isn't always set, so look for ground underneath
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,10), ignore_monsters, edict(), &tr );
|
||||
|
||||
if ( tr.flFraction < 1.0 )
|
||||
{
|
||||
// add a bit of static friction
|
||||
pev->velocity = pev->velocity * 0.95;
|
||||
pev->avelocity = pev->avelocity * 0.9;
|
||||
// play sliding sound, volume based on velocity
|
||||
}
|
||||
if ( !(pev->flags & FL_ONGROUND) && pev->velocity.Length2D() > 10 )
|
||||
{
|
||||
BounceSound();
|
||||
}
|
||||
StudioFrameAdvance( );
|
||||
}
|
||||
|
||||
|
||||
void CSatchelCharge :: SatchelThink( void )
|
||||
{
|
||||
StudioFrameAdvance( );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
if (!IsInWorld())
|
||||
{
|
||||
UTIL_Remove( this );
|
||||
return;
|
||||
}
|
||||
|
||||
if (pev->waterlevel == 3)
|
||||
{
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->velocity = pev->velocity * 0.8;
|
||||
pev->avelocity = pev->avelocity * 0.9;
|
||||
pev->velocity.z += 8;
|
||||
}
|
||||
else if (pev->waterlevel == 0)
|
||||
{
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pev->velocity.z -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void CSatchelCharge :: Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/grenade.mdl");
|
||||
PRECACHE_SOUND("weapons/g_bounce1.wav");
|
||||
PRECACHE_SOUND("weapons/g_bounce2.wav");
|
||||
PRECACHE_SOUND("weapons/g_bounce3.wav");
|
||||
}
|
||||
|
||||
void CSatchelCharge :: BounceSound( void )
|
||||
{
|
||||
switch ( RANDOM_LONG( 0, 2 ) )
|
||||
{
|
||||
case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM); break;
|
||||
case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM); break;
|
||||
case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel );
|
||||
|
||||
|
||||
//=========================================================
|
||||
// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal
|
||||
//=========================================================
|
||||
int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal )
|
||||
{
|
||||
CSatchel *pSatchel;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
pSatchel = (CSatchel *)pOriginal;
|
||||
|
||||
if ( pSatchel->m_chargeReady != 0 )
|
||||
{
|
||||
// player has some satchels deployed. Refuse to add more.
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return CBasePlayerWeapon::AddDuplicate ( pOriginal );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CSatchel::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
int bResult = CBasePlayerItem::AddToPlayer( pPlayer );
|
||||
|
||||
pPlayer->pev->weapons |= (1<<m_iId);
|
||||
m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it.
|
||||
|
||||
if ( bResult )
|
||||
{
|
||||
return AddWeapon( );
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CSatchel::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_SATCHEL;
|
||||
SET_MODEL(ENT(pev), "models/w_satchel.mdl");
|
||||
|
||||
m_iDefaultAmmo = SATCHEL_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CSatchel::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_satchel.mdl");
|
||||
PRECACHE_MODEL("models/v_satchel_radio.mdl");
|
||||
PRECACHE_MODEL("models/w_satchel.mdl");
|
||||
PRECACHE_MODEL("models/p_satchel.mdl");
|
||||
PRECACHE_MODEL("models/p_satchel_radio.mdl");
|
||||
|
||||
UTIL_PrecacheOther( "monster_satchel" );
|
||||
}
|
||||
|
||||
|
||||
int CSatchel::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "Satchel Charge";
|
||||
p->iMaxAmmo1 = SATCHEL_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 4;
|
||||
p->iPosition = 1;
|
||||
p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
|
||||
p->iId = m_iId = WEAPON_SATCHEL;
|
||||
p->iWeight = SATCHEL_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CSatchel::IsUseable( void )
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] > 0 )
|
||||
{
|
||||
// player is carrying some satchels
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( m_chargeReady != 0 )
|
||||
{
|
||||
// player isn't carrying any satchels, but has some out
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CSatchel::CanDeploy( void )
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] > 0 )
|
||||
{
|
||||
// player is carrying some satchels
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( m_chargeReady != 0 )
|
||||
{
|
||||
// player isn't carrying any satchels, but has some out
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CSatchel::Deploy( )
|
||||
{
|
||||
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
|
||||
if ( m_chargeReady )
|
||||
return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" );
|
||||
else
|
||||
return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" );
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CSatchel::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
if ( m_chargeReady )
|
||||
{
|
||||
SendWeaponAnim( SATCHEL_RADIO_HOLSTER );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendWeaponAnim( SATCHEL_DROP );
|
||||
}
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM);
|
||||
|
||||
if ( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady )
|
||||
{
|
||||
m_pPlayer->pev->weapons &= ~(1<<WEAPON_SATCHEL);
|
||||
SetThink( DestroyItem );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSatchel::PrimaryAttack()
|
||||
{
|
||||
switch (m_chargeReady)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Throw( );
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
SendWeaponAnim( SATCHEL_RADIO_FIRE );
|
||||
|
||||
edict_t *pPlayer = m_pPlayer->edict( );
|
||||
|
||||
CBaseEntity *pSatchel = NULL;
|
||||
|
||||
while ((pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 )) != NULL)
|
||||
{
|
||||
if (FClassnameIs( pSatchel->pev, "monster_satchel"))
|
||||
{
|
||||
if (pSatchel->pev->owner == pPlayer)
|
||||
{
|
||||
pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 );
|
||||
m_chargeReady = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_chargeReady = 2;
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
// we're reloading, don't allow fire
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSatchel::SecondaryAttack( void )
|
||||
{
|
||||
if ( m_chargeReady != 2 )
|
||||
{
|
||||
Throw( );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSatchel::Throw( void )
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
||||
{
|
||||
Vector vecSrc = m_pPlayer->pev->origin;
|
||||
|
||||
Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0), m_pPlayer->edict() );
|
||||
pSatchel->pev->velocity = vecThrow;
|
||||
pSatchel->pev->avelocity.y = 400;
|
||||
|
||||
m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_satchel_radio.mdl");
|
||||
m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_satchel_radio.mdl");
|
||||
#else
|
||||
LoadVModel ( "models/v_satchel_radio.mdl", m_pPlayer );
|
||||
#endif
|
||||
|
||||
SendWeaponAnim( SATCHEL_RADIO_DRAW );
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
m_chargeReady = 1;
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSatchel::WeaponIdle( void )
|
||||
{
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
switch( m_chargeReady )
|
||||
{
|
||||
case 0:
|
||||
SendWeaponAnim( SATCHEL_FIDGET1 );
|
||||
// use tripmine animations
|
||||
strcpy( m_pPlayer->m_szAnimExtention, "trip" );
|
||||
break;
|
||||
case 1:
|
||||
SendWeaponAnim( SATCHEL_RADIO_FIDGET1 );
|
||||
// use hivehand animations
|
||||
strcpy( m_pPlayer->m_szAnimExtention, "hive" );
|
||||
break;
|
||||
case 2:
|
||||
if ( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
||||
{
|
||||
m_chargeReady = 0;
|
||||
RetireWeapon();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_satchel.mdl");
|
||||
m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_satchel.mdl");
|
||||
#else
|
||||
LoadVModel ( "models/v_satchel.mdl", m_pPlayer );
|
||||
#endif
|
||||
|
||||
SendWeaponAnim( SATCHEL_DRAW );
|
||||
|
||||
// use tripmine animations
|
||||
strcpy( m_pPlayer->m_szAnimExtention, "trip" );
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_chargeReady = 0;
|
||||
break;
|
||||
}
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DeactivateSatchels - removes all satchels owned by
|
||||
// the provided player. Should only be used upon death.
|
||||
//
|
||||
// Made this global on purpose.
|
||||
//=========================================================
|
||||
void DeactivateSatchels( CBasePlayer *pOwner )
|
||||
{
|
||||
edict_t *pFind;
|
||||
|
||||
pFind = FIND_ENTITY_BY_CLASSNAME( NULL, "monster_satchel" );
|
||||
|
||||
while ( !FNullEnt( pFind ) )
|
||||
{
|
||||
CBaseEntity *pEnt = CBaseEntity::Instance( pFind );
|
||||
CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt;
|
||||
|
||||
if ( pSatchel )
|
||||
{
|
||||
if ( pSatchel->pev->owner == pOwner->edict() )
|
||||
{
|
||||
pSatchel->Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
pFind = FIND_ENTITY_BY_CLASSNAME( pFind, "monster_satchel" );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,7 +12,6 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// Implementation in UTIL.CPP
|
||||
#ifndef SAVERESTORE_H
|
||||
#define SAVERESTORE_H
|
||||
|
||||
|
@ -21,156 +20,154 @@ class CBaseEntity;
|
|||
class CSaveRestoreBuffer
|
||||
{
|
||||
public:
|
||||
CSaveRestoreBuffer( void );
|
||||
CSaveRestoreBuffer( SAVERESTOREDATA *pdata );
|
||||
virtual ~CSaveRestoreBuffer( void );
|
||||
CSaveRestoreBuffer(void);
|
||||
CSaveRestoreBuffer(SAVERESTOREDATA *pdata);
|
||||
virtual ~CSaveRestoreBuffer(void);
|
||||
|
||||
int EntityIndex( entvars_t *pevLookup );
|
||||
int EntityIndex( edict_t *pentLookup );
|
||||
int EntityIndex( EOFFSET eoLookup );
|
||||
int EntityIndex( CBaseEntity *pEntity );
|
||||
|
||||
int EntityFlags( int entityIndex, int flags ) { return EntityFlagsSet( entityIndex, 0 ); }
|
||||
int EntityFlagsSet( int entityIndex, int flags );
|
||||
|
||||
edict_t *EntityFromIndex( int entityIndex );
|
||||
|
||||
unsigned short TokenHash( const char *pszToken );
|
||||
public:
|
||||
int EntityIndex(entvars_t *pevLookup);
|
||||
int EntityIndex(edict_t *pentLookup);
|
||||
int EntityIndex(EOFFSET eoLookup);
|
||||
int EntityIndex(CBaseEntity *pEntity);
|
||||
int EntityFlags(int entityIndex, int flags) { return EntityFlagsSet(entityIndex, 0); }
|
||||
int EntityFlagsSet(int entityIndex, int flags);
|
||||
edict_t *EntityFromIndex(int entityIndex);
|
||||
unsigned short TokenHash(const char *pszToken);
|
||||
|
||||
protected:
|
||||
SAVERESTOREDATA *m_pdata;
|
||||
void BufferRewind( int size );
|
||||
unsigned int HashString( const char *pszToken );
|
||||
private:
|
||||
// effc++ rule 11
|
||||
void operator=(CSaveRestoreBuffer&);
|
||||
CSaveRestoreBuffer(const CSaveRestoreBuffer&);
|
||||
};
|
||||
SAVERESTOREDATA *m_pdata;
|
||||
void BufferRewind(int size);
|
||||
unsigned int HashString(const char *pszToken);
|
||||
|
||||
private:
|
||||
void operator = (CSaveRestoreBuffer &);
|
||||
CSaveRestoreBuffer(const CSaveRestoreBuffer &);
|
||||
};
|
||||
|
||||
class CSave : public CSaveRestoreBuffer
|
||||
{
|
||||
public:
|
||||
CSave( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) {};
|
||||
CSave(SAVERESTOREDATA *pdata): CSaveRestoreBuffer(pdata) {};
|
||||
|
||||
void WriteShort( const char *pname, const short *value, int count );
|
||||
void WriteInt( const char *pname, const int *value, int count ); // Save an int
|
||||
void WriteFloat( const char *pname, const float *value, int count ); // Save a float
|
||||
void WriteTime( const char *pname, const float *value, int count ); // Save a float (timevalue)
|
||||
void WriteData( const char *pname, int size, const char *pdata ); // Save a binary data block
|
||||
void WriteString( const char *pname, const char *pstring ); // Save a null-terminated string
|
||||
void WriteString( const char *pname, const int *stringId, int count ); // Save a null-terminated string (engine string)
|
||||
void WriteVector( const char *pname, const Vector &value ); // Save a vector
|
||||
void WriteVector( const char *pname, const float *value, int count ); // Save a vector
|
||||
void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary
|
||||
void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors
|
||||
void WriteFunction( const char *pname, const int *value, int count ); // Save a function pointer
|
||||
int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t)
|
||||
int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount );
|
||||
public:
|
||||
void WriteShort(const char *pname, const short *value, int count);
|
||||
void WriteInt(const char *pname, const int *value, int count);
|
||||
void WriteFloat(const char *pname, const float *value, int count);
|
||||
void WriteTime(const char *pname, const float *value, int count);
|
||||
void WriteData(const char *pname, int size, const char *pdata);
|
||||
void WriteString(const char *pname, const char *pstring);
|
||||
void WriteString(const char *pname, const int *stringId, int count);
|
||||
void WriteVector(const char *pname, const Vector &value);
|
||||
void WriteVector(const char *pname, const float *value, int count);
|
||||
void WritePositionVector(const char *pname, const Vector &value);
|
||||
void WritePositionVector(const char *pname, const float *value, int count);
|
||||
void WriteFunction(const char *pname, const int *value, int count);
|
||||
int WriteEntVars(const char *pname, entvars_t *pev);
|
||||
int WriteFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
||||
|
||||
private:
|
||||
int DataEmpty( const char *pdata, int size );
|
||||
void BufferField( const char *pname, int size, const char *pdata );
|
||||
void BufferString( char *pdata, int len );
|
||||
void BufferData( const char *pdata, int size );
|
||||
void BufferHeader( const char *pname, int size );
|
||||
int DataEmpty(const char *pdata, int size);
|
||||
void BufferField(const char *pname, int size, const char *pdata);
|
||||
void BufferString(char *pdata, int len);
|
||||
void BufferData(const char *pdata, int size);
|
||||
void BufferHeader(const char *pname, int size);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
unsigned short size;
|
||||
unsigned short token;
|
||||
char *pData;
|
||||
} HEADER;
|
||||
unsigned short size;
|
||||
unsigned short token;
|
||||
char *pData;
|
||||
}
|
||||
HEADER;
|
||||
|
||||
class CRestore : public CSaveRestoreBuffer
|
||||
{
|
||||
public:
|
||||
CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ), m_global(0), m_precache(TRUE) { }
|
||||
int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t
|
||||
int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount );
|
||||
int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData );
|
||||
int ReadInt( void );
|
||||
short ReadShort( void );
|
||||
int ReadNamedInt( const char *pName );
|
||||
char *ReadNamedString( const char *pName );
|
||||
int Empty( void ) { return (m_pdata == NULL) || ((m_pdata->pCurrentData-m_pdata->pBaseData)>=m_pdata->bufferSize); }
|
||||
inline void SetGlobalMode( int global ) { m_global = global; }
|
||||
void PrecacheMode( BOOL mode ) { m_precache = mode; }
|
||||
CRestore(SAVERESTOREDATA *pdata): CSaveRestoreBuffer(pdata), m_global(0), m_precache(TRUE) {}
|
||||
|
||||
public:
|
||||
int ReadEntVars(const char *pname, entvars_t *pev);
|
||||
int ReadFields(const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount);
|
||||
int ReadField(void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData);
|
||||
int ReadInt(void);
|
||||
short ReadShort(void);
|
||||
int ReadNamedInt(const char *pName);
|
||||
char *ReadNamedString(const char *pName);
|
||||
int Empty(void) { return (!m_pdata) || ((m_pdata->pCurrentData - m_pdata->pBaseData) >= m_pdata->bufferSize); }
|
||||
inline void SetGlobalMode(int global) { m_global = global; }
|
||||
void PrecacheMode(BOOL mode){ m_precache = mode; }
|
||||
|
||||
private:
|
||||
char *BufferPointer( void );
|
||||
void BufferReadBytes( char *pOutput, int size );
|
||||
void BufferSkipBytes( int bytes );
|
||||
int BufferSkipZString( void );
|
||||
int BufferCheckZString( const char *string );
|
||||
char *BufferPointer(void);
|
||||
void BufferReadBytes(char *pOutput, int size);
|
||||
void BufferSkipBytes(int bytes);
|
||||
int BufferSkipZString(void);
|
||||
int BufferCheckZString(const char *string);
|
||||
void BufferReadHeader(HEADER *pheader);
|
||||
|
||||
void BufferReadHeader( HEADER *pheader );
|
||||
|
||||
int m_global; // Restoring a global entity?
|
||||
BOOL m_precache;
|
||||
private:
|
||||
int m_global;
|
||||
BOOL m_precache;
|
||||
};
|
||||
|
||||
#define MAX_ENTITYARRAY 64
|
||||
|
||||
//#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
|
||||
|
||||
#define IMPLEMENT_SAVERESTORE(derivedClass,baseClass) \
|
||||
int derivedClass::Save( CSave &save )\
|
||||
{\
|
||||
if ( !baseClass::Save(save) )\
|
||||
return 0;\
|
||||
return save.WriteFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\
|
||||
}\
|
||||
int derivedClass::Restore( CRestore &restore )\
|
||||
{\
|
||||
if ( !baseClass::Restore(restore) )\
|
||||
return 0;\
|
||||
return restore.ReadFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\
|
||||
}
|
||||
|
||||
int derivedClass::Save(CSave &save)\
|
||||
{\
|
||||
if (!baseClass::Save(save))\
|
||||
return 0;\
|
||||
return save.WriteFields(#derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData));\
|
||||
}\
|
||||
int derivedClass::Restore(CRestore &restore)\
|
||||
{\
|
||||
if (!baseClass::Restore(restore))\
|
||||
return 0;\
|
||||
return restore.ReadFields(#derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData));\
|
||||
}
|
||||
|
||||
typedef enum { GLOBAL_OFF = 0, GLOBAL_ON = 1, GLOBAL_DEAD = 2 } GLOBALESTATE;
|
||||
|
||||
typedef struct globalentity_s globalentity_t;
|
||||
|
||||
struct globalentity_s
|
||||
{
|
||||
char name[64];
|
||||
char levelName[32];
|
||||
GLOBALESTATE state;
|
||||
globalentity_t *pNext;
|
||||
char name[64];
|
||||
char levelName[32];
|
||||
GLOBALESTATE state;
|
||||
globalentity_t *pNext;
|
||||
};
|
||||
|
||||
class CGlobalState
|
||||
{
|
||||
public:
|
||||
CGlobalState();
|
||||
void Reset( void );
|
||||
void ClearStates( void );
|
||||
void EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state );
|
||||
void EntitySetState( string_t globalname, GLOBALESTATE state );
|
||||
void EntityUpdate( string_t globalname, string_t mapname );
|
||||
const globalentity_t *EntityFromTable( string_t globalname );
|
||||
GLOBALESTATE EntityGetState( string_t globalname );
|
||||
int EntityInTable( string_t globalname ) { return (Find( globalname ) != NULL) ? 1 : 0; }
|
||||
int Save( CSave &save );
|
||||
int Restore( CRestore &restore );
|
||||
CGlobalState(void);
|
||||
|
||||
public:
|
||||
void Reset(void);
|
||||
void ClearStates(void);
|
||||
void EntityAdd(string_t globalname, string_t mapName, GLOBALESTATE state);
|
||||
void EntitySetState(string_t globalname, GLOBALESTATE state);
|
||||
void EntityUpdate(string_t globalname, string_t mapname);
|
||||
const globalentity_t *EntityFromTable(string_t globalname);
|
||||
GLOBALESTATE EntityGetState(string_t globalname);
|
||||
int EntityInTable(string_t globalname) { return (Find(globalname) != NULL) ? 1 : 0; }
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
void DumpGlobals(void);
|
||||
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
//#ifdef _DEBUG
|
||||
void DumpGlobals( void );
|
||||
//#endif
|
||||
private:
|
||||
globalentity_t *Find(string_t globalname);
|
||||
globalentity_t *m_pList;
|
||||
int m_listCount;
|
||||
|
||||
private:
|
||||
globalentity_t *Find( string_t globalname );
|
||||
globalentity_t *m_pList;
|
||||
int m_listCount;
|
||||
// effc++ rule 11
|
||||
void operator=(CGlobalState&);
|
||||
CGlobalState(const CGlobalState&);
|
||||
void operator = (CGlobalState &);
|
||||
CGlobalState(const CGlobalState &);
|
||||
};
|
||||
|
||||
extern CGlobalState gGlobalState;
|
||||
|
||||
#endif //SAVERESTORE_H
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,20 +12,16 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// Scheduling
|
||||
//=========================================================
|
||||
#ifndef SCHEDULE_H
|
||||
#define SCHEDULE_H
|
||||
#ifndef SCHEDULE_H
|
||||
#define SCHEDULE_H
|
||||
|
||||
#define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate
|
||||
#define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of
|
||||
#define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike
|
||||
#define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view.
|
||||
#define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little
|
||||
#define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot
|
||||
#define bits_COND_SEE_CLIENT ( 1 << 21) // see a client
|
||||
#define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis
|
||||
#define bits_COND_SEE_HATE (1<<1)
|
||||
#define bits_COND_SEE_FEAR (1<<2)
|
||||
#define bits_COND_SEE_DISLIKE (1<<3)
|
||||
#define bits_COND_SEE_ENEMY (1<<4)
|
||||
#define bits_COND_LIGHT_DAMAGE (1<<8)
|
||||
#define bits_COND_HEAVY_DAMAGE (1<<9)
|
||||
#define bits_COND_SEE_CLIENT (1<<21)
|
||||
#define bits_COND_SEE_NEMESIS (1<<22)
|
||||
|
||||
|
||||
#endif // SCHEDULE_H
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,15 +15,16 @@
|
|||
#ifndef SCRIPTEVENT_H
|
||||
#define SCRIPTEVENT_H
|
||||
|
||||
#define SCRIPT_EVENT_DEAD 1000 // character is now dead
|
||||
#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt
|
||||
#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt
|
||||
#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires
|
||||
#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY)
|
||||
#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence
|
||||
#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor)
|
||||
#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes
|
||||
#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE)
|
||||
#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time
|
||||
#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences)
|
||||
#endif //SCRIPTEVENT_H
|
||||
#define SCRIPT_EVENT_DEAD 1000
|
||||
#define SCRIPT_EVENT_NOINTERRUPT 1001
|
||||
#define SCRIPT_EVENT_CANINTERRUPT 1002
|
||||
#define SCRIPT_EVENT_FIREEVENT 1003
|
||||
#define SCRIPT_EVENT_SOUND 1004
|
||||
#define SCRIPT_EVENT_SENTENCE 1005
|
||||
#define SCRIPT_EVENT_INAIR 1006
|
||||
#define SCRIPT_EVENT_ENDANIMATION 1007
|
||||
#define SCRIPT_EVENT_SOUND_VOICE 1008
|
||||
#define SCRIPT_EVENT_SENTENCE_RND1 1009
|
||||
#define SCRIPT_EVENT_NOT_DEAD 1010
|
||||
|
||||
#endif
|
401
dlls/shotgun.cpp
401
dlls/shotgun.cpp
|
@ -1,401 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
// special deathmatch shotgun spreads
|
||||
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
|
||||
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
|
||||
|
||||
enum shotgun_e {
|
||||
SHOTGUN_IDLE = 0,
|
||||
SHOTGUN_FIRE,
|
||||
SHOTGUN_FIRE2,
|
||||
SHOTGUN_RELOAD,
|
||||
SHOTGUN_PUMP,
|
||||
SHOTGUN_START_RELOAD,
|
||||
SHOTGUN_DRAW,
|
||||
SHOTGUN_HOLSTER,
|
||||
SHOTGUN_IDLE4,
|
||||
SHOTGUN_IDLE_DEEP
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun );
|
||||
|
||||
void CShotgun::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_SHOTGUN;
|
||||
SET_MODEL(ENT(pev), "models/w_shotgun.mdl");
|
||||
|
||||
m_iDefaultAmmo = SHOTGUN_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall
|
||||
}
|
||||
|
||||
|
||||
void CShotgun::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_shotgun.mdl");
|
||||
PRECACHE_MODEL("models/w_shotgun.mdl");
|
||||
PRECACHE_MODEL("models/p_shotgun.mdl");
|
||||
|
||||
m_iShell = PRECACHE_MODEL ("models/shotgunshell.mdl");// shotgun shell
|
||||
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
|
||||
PRECACHE_SOUND ("weapons/dbarrel1.wav");//shotgun
|
||||
PRECACHE_SOUND ("weapons/sbarrel1.wav");//shotgun
|
||||
|
||||
PRECACHE_SOUND ("weapons/reload1.wav"); // shotgun reload
|
||||
PRECACHE_SOUND ("weapons/reload3.wav"); // shotgun reload
|
||||
|
||||
// PRECACHE_SOUND ("weapons/sshell1.wav"); // shotgun reload - played on client
|
||||
// PRECACHE_SOUND ("weapons/sshell3.wav"); // shotgun reload - played on client
|
||||
|
||||
PRECACHE_SOUND ("weapons/357_cock1.wav"); // gun empty sound
|
||||
PRECACHE_SOUND ("weapons/scock1.wav"); // cock gun
|
||||
|
||||
m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" );
|
||||
m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" );
|
||||
}
|
||||
|
||||
int CShotgun::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
WRITE_BYTE( m_iId );
|
||||
MESSAGE_END();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
int CShotgun::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "buckshot";
|
||||
p->iMaxAmmo1 = BUCKSHOT_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = SHOTGUN_MAX_CLIP;
|
||||
p->iSlot = 2;
|
||||
p->iPosition = 1;
|
||||
p->iFlags = 0;
|
||||
p->iId = m_iId = WEAPON_SHOTGUN;
|
||||
p->iWeight = SHOTGUN_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CShotgun::Deploy( )
|
||||
{
|
||||
return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" );
|
||||
}
|
||||
|
||||
void CShotgun::PrimaryAttack()
|
||||
{
|
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
Reload( );
|
||||
if (m_iClip == 0)
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
|
||||
m_iClip--;
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
|
||||
Vector vecDir;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
else
|
||||
{
|
||||
// regular old, untouched spread.
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 6, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
|
||||
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
if (m_iClip != 0)
|
||||
m_flPumpTime = gpGlobals->time + 0.5;
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
|
||||
if (m_iClip != 0)
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
|
||||
else
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
|
||||
m_fInSpecialReload = 0;
|
||||
}
|
||||
|
||||
|
||||
void CShotgun::SecondaryAttack( void )
|
||||
{
|
||||
// don't fire underwater
|
||||
if (m_pPlayer->pev->waterlevel == 3)
|
||||
{
|
||||
PlayEmptySound( );
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_iClip <= 1)
|
||||
{
|
||||
Reload( );
|
||||
PlayEmptySound( );
|
||||
return;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
|
||||
m_iClip -= 2;
|
||||
|
||||
|
||||
int flags;
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
|
||||
Vector vecDir;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( bIsMultiplayer() )
|
||||
#else
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
#endif
|
||||
{
|
||||
// tuned for deathmatch
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 8, vecSrc, vecAiming, VECTOR_CONE_DM_DOUBLESHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
else
|
||||
{
|
||||
// untouched default single player
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
}
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
if (m_iClip != 0)
|
||||
m_flPumpTime = gpGlobals->time + 0.95;
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5;
|
||||
if (m_iClip != 0)
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0;
|
||||
else
|
||||
m_flTimeWeaponIdle = 1.5;
|
||||
|
||||
m_fInSpecialReload = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CShotgun::Reload( void )
|
||||
{
|
||||
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP)
|
||||
return;
|
||||
|
||||
// don't reload until recoil is done
|
||||
if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
// check to see if we're ready to reload
|
||||
if (m_fInSpecialReload == 0)
|
||||
{
|
||||
SendWeaponAnim( SHOTGUN_START_RELOAD );
|
||||
m_fInSpecialReload = 1;
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
|
||||
return;
|
||||
}
|
||||
else if (m_fInSpecialReload == 1)
|
||||
{
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
// was waiting for gun to move to side
|
||||
m_fInSpecialReload = 2;
|
||||
|
||||
if (RANDOM_LONG(0,1))
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG(0,0x1f));
|
||||
else
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG(0,0x1f));
|
||||
|
||||
SendWeaponAnim( SHOTGUN_RELOAD );
|
||||
|
||||
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add them to the clip
|
||||
m_iClip += 1;
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 1;
|
||||
m_fInSpecialReload = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CShotgun::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||||
|
||||
if ( m_flPumpTime && m_flPumpTime < gpGlobals->time )
|
||||
{
|
||||
// play pumping sound
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG(0,0x1f));
|
||||
m_flPumpTime = 0;
|
||||
}
|
||||
|
||||
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
|
||||
{
|
||||
if (m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
|
||||
{
|
||||
Reload( );
|
||||
}
|
||||
else if (m_fInSpecialReload != 0)
|
||||
{
|
||||
if (m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
|
||||
{
|
||||
Reload( );
|
||||
}
|
||||
else
|
||||
{
|
||||
// reload debounce has timed out
|
||||
SendWeaponAnim( SHOTGUN_PUMP );
|
||||
|
||||
// play cocking sound
|
||||
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG(0,0x1f));
|
||||
m_fInSpecialReload = 0;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.8)
|
||||
{
|
||||
iAnim = SHOTGUN_IDLE_DEEP;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (60.0/12.0);// * RANDOM_LONG(2, 5);
|
||||
}
|
||||
else if (flRand <= 0.95)
|
||||
{
|
||||
iAnim = SHOTGUN_IDLE;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (20.0/9.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = SHOTGUN_IDLE4;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (20.0/9.0);
|
||||
}
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CShotgunAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_shotbox.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_shotbox.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "buckshot", BUCKSHOT_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_buckshot, CShotgunAmmo );
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,317 +12,241 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// teamplay_gamerules.cpp
|
||||
//
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "gamerules.h"
|
||||
#include "skill.h"
|
||||
#include "items.h"
|
||||
|
||||
extern DLL_GLOBAL CGameRules *g_pGameRules;
|
||||
extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
extern int gmsgDeathMsg; // client dll messages
|
||||
extern int gmsgScoreInfo;
|
||||
extern int gmsgMOTD;
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "gamerules.h"
|
||||
#include "skill.h"
|
||||
#include "items.h"
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
CHalfLifeRules::CHalfLifeRules( void )
|
||||
CHalfLifeRules::CHalfLifeRules(void)
|
||||
{
|
||||
RefreshSkillData();
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules::Think ( void )
|
||||
void CHalfLifeRules::Think(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::IsMultiplayer( void )
|
||||
BOOL CHalfLifeRules::IsMultiplayer(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::IsDeathmatch ( void )
|
||||
BOOL CHalfLifeRules::IsDeathmatch(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::IsCoOp( void )
|
||||
BOOL CHalfLifeRules::IsCoOp(void)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon )
|
||||
BOOL CHalfLifeRules::FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
||||
{
|
||||
if ( !pPlayer->m_pActiveItem )
|
||||
{
|
||||
// player doesn't have an active item!
|
||||
if (!pPlayer->m_pActiveItem)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( !pPlayer->m_pActiveItem->CanHolster() )
|
||||
{
|
||||
if (!pPlayer->m_pActiveItem->CanHolster())
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules :: GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon )
|
||||
BOOL CHalfLifeRules::GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules :: ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
|
||||
BOOL CHalfLifeRules::ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CHalfLifeRules :: InitHUD( CBasePlayer *pl )
|
||||
void CHalfLifeRules::InitHUD(CBasePlayer *pl)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules :: ClientDisconnected( edict_t *pClient )
|
||||
void CHalfLifeRules::ClientDisconnected(edict_t *pClient)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CHalfLifeRules::FlPlayerFallDamage( CBasePlayer *pPlayer )
|
||||
float CHalfLifeRules::FlPlayerFallDamage(CBasePlayer *pPlayer)
|
||||
{
|
||||
// subtract off the speed at which a player is allowed to fall without being hurt,
|
||||
// so damage will be based on speed beyond that, not the entire fall
|
||||
pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED;
|
||||
return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules :: PlayerSpawn( CBasePlayer *pPlayer )
|
||||
void CHalfLifeRules::PlayerSpawn(CBasePlayer *pPlayer)
|
||||
{
|
||||
pPlayer->pev->weapons |= (1 << WEAPON_MAC10);
|
||||
|
||||
pPlayer->GiveNamedItem("weapon_knife");
|
||||
pPlayer->GiveNamedItem("weapon_usp");
|
||||
pPlayer->GiveNamedItem("weapon_mp5navy");
|
||||
pPlayer->GiveNamedItem("weapon_hegrenade");
|
||||
|
||||
pPlayer->GiveAmmo(60, "9mm", _9MM_MAX_CARRY);
|
||||
pPlayer->GiveAmmo(24, "45acp", _45ACP_MAX_CARRY);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules :: AllowAutoTargetCrosshair( void )
|
||||
BOOL CHalfLifeRules::AllowAutoTargetCrosshair(void)
|
||||
{
|
||||
return ( g_iSkillLevel == SKILL_EASY );
|
||||
return g_iSkillLevel == SKILL_EASY;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules :: PlayerThink( CBasePlayer *pPlayer )
|
||||
void CHalfLifeRules::PlayerThink(CBasePlayer *pPlayer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules :: FPlayerCanRespawn( CBasePlayer *pPlayer )
|
||||
BOOL CHalfLifeRules::FPlayerCanRespawn(CBasePlayer *pPlayer)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CHalfLifeRules :: FlPlayerSpawnTime( CBasePlayer *pPlayer )
|
||||
float CHalfLifeRules::FlPlayerSpawnTime(CBasePlayer *pPlayer)
|
||||
{
|
||||
return gpGlobals->time;//now!
|
||||
return gpGlobals->time;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// IPointsForKill - how many points awarded to anyone
|
||||
// that kills this player?
|
||||
//=========================================================
|
||||
int CHalfLifeRules :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled )
|
||||
int CHalfLifeRules::IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// PlayerKilled - someone/something killed this player
|
||||
//=========================================================
|
||||
void CHalfLifeRules :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
|
||||
void CHalfLifeRules::PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Deathnotice
|
||||
//=========================================================
|
||||
void CHalfLifeRules::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
|
||||
void CHalfLifeRules::DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// PlayerGotWeapon - player has grabbed a weapon that was
|
||||
// sitting in the world
|
||||
//=========================================================
|
||||
void CHalfLifeRules :: PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon )
|
||||
void CHalfLifeRules::PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FlWeaponRespawnTime - what is the time in the future
|
||||
// at which this weapon may spawn?
|
||||
//=========================================================
|
||||
float CHalfLifeRules :: FlWeaponRespawnTime( CBasePlayerItem *pWeapon )
|
||||
float CHalfLifeRules::FlWeaponRespawnTime(CBasePlayerItem *pWeapon)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FlWeaponRespawnTime - Returns 0 if the weapon can respawn
|
||||
// now, otherwise it returns the time at which it can try
|
||||
// to spawn again.
|
||||
//=========================================================
|
||||
float CHalfLifeRules :: FlWeaponTryRespawn( CBasePlayerItem *pWeapon )
|
||||
float CHalfLifeRules::FlWeaponTryRespawn(CBasePlayerItem *pWeapon)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// VecWeaponRespawnSpot - where should this weapon spawn?
|
||||
// Some game variations may choose to randomize spawn locations
|
||||
//=========================================================
|
||||
Vector CHalfLifeRules :: VecWeaponRespawnSpot( CBasePlayerItem *pWeapon )
|
||||
Vector CHalfLifeRules::VecWeaponRespawnSpot(CBasePlayerItem *pWeapon)
|
||||
{
|
||||
return pWeapon->pev->origin;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// WeaponShouldRespawn - any conditions inhibiting the
|
||||
// respawning of this weapon?
|
||||
//=========================================================
|
||||
int CHalfLifeRules :: WeaponShouldRespawn( CBasePlayerItem *pWeapon )
|
||||
int CHalfLifeRules::WeaponShouldRespawn(CBasePlayerItem *pWeapon)
|
||||
{
|
||||
return GR_WEAPON_RESPAWN_NO;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::CanHaveItem( CBasePlayer *pPlayer, CItem *pItem )
|
||||
BOOL CHalfLifeRules::CanHaveItem(CBasePlayer *pPlayer, CItem *pItem)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules::PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem )
|
||||
void CHalfLifeRules::PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeRules::ItemShouldRespawn( CItem *pItem )
|
||||
int CHalfLifeRules::ItemShouldRespawn(CItem *pItem)
|
||||
{
|
||||
return GR_ITEM_RESPAWN_NO;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// At what time in the future may this Item respawn?
|
||||
//=========================================================
|
||||
float CHalfLifeRules::FlItemRespawnTime( CItem *pItem )
|
||||
float CHalfLifeRules::FlItemRespawnTime(CItem *pItem)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Where should this item respawn?
|
||||
// Some game variations may choose to randomize spawn locations
|
||||
//=========================================================
|
||||
Vector CHalfLifeRules::VecItemRespawnSpot( CItem *pItem )
|
||||
Vector CHalfLifeRules::VecItemRespawnSpot(CItem *pItem)
|
||||
{
|
||||
return pItem->pev->origin;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules::IsAllowedToSpawn( CBaseEntity *pEntity )
|
||||
BOOL CHalfLifeRules::IsAllowedToSpawn(CBaseEntity *pEntity)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeRules::PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount )
|
||||
void CHalfLifeRules::PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeRules::AmmoShouldRespawn( CBasePlayerAmmo *pAmmo )
|
||||
int CHalfLifeRules::AmmoShouldRespawn(CBasePlayerAmmo *pAmmo)
|
||||
{
|
||||
return GR_AMMO_RESPAWN_NO;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CHalfLifeRules::FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo )
|
||||
float CHalfLifeRules::FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
Vector CHalfLifeRules::VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo )
|
||||
Vector CHalfLifeRules::VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo)
|
||||
{
|
||||
return pAmmo->pev->origin;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
float CHalfLifeRules::FlHealthChargerRechargeTime( void )
|
||||
float CHalfLifeRules::FlHealthChargerRechargeTime(void)
|
||||
{
|
||||
return 0;// don't recharge
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeRules::DeadPlayerWeapons( CBasePlayer *pPlayer )
|
||||
int CHalfLifeRules::DeadPlayerWeapons(CBasePlayer *pPlayer)
|
||||
{
|
||||
return GR_PLR_DROP_GUN_NO;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeRules::DeadPlayerAmmo( CBasePlayer *pPlayer )
|
||||
int CHalfLifeRules::DeadPlayerAmmo(CBasePlayer *pPlayer)
|
||||
{
|
||||
return GR_PLR_DROP_AMMO_NO;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeRules::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget )
|
||||
int CHalfLifeRules::PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget)
|
||||
{
|
||||
// why would a single player in half life need this?
|
||||
return GR_NOTTEAMMATE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeRules :: FAllowMonsters( void )
|
||||
BOOL CHalfLifeRules::FAllowMonsters(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
edict_t *CHalfLifeRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer)
|
||||
{
|
||||
CBaseEntity *pSpawnSpot = UTIL_FindEntityByClassname(NULL, "info_player_start");
|
||||
|
||||
if (!pSpawnSpot)
|
||||
{
|
||||
ALERT(at_error, "PutClientInServer: no info_player_start on level");
|
||||
return INDEXENT(0);
|
||||
}
|
||||
|
||||
edict_t *pentSpawnSpot = ENT(pSpawnSpot->pev);
|
||||
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1);
|
||||
pPlayer->pev->v_angle = g_vecZero;
|
||||
pPlayer->pev->velocity = g_vecZero;
|
||||
pPlayer->pev->angles = VARS(pentSpawnSpot)->angles;
|
||||
pPlayer->pev->punchangle = g_vecZero;
|
||||
pPlayer->pev->fixangle = TRUE;
|
||||
return pentSpawnSpot;
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,36 +12,20 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// skill.cpp - code for skill level concerns
|
||||
//=========================================================
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "skill.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "skill.h"
|
||||
|
||||
skilldata_t gSkillData;
|
||||
skilldata_t gSkillData;
|
||||
|
||||
|
||||
//=========================================================
|
||||
// take the name of a cvar, tack a digit for the skill level
|
||||
// on, and return the value.of that Cvar
|
||||
//=========================================================
|
||||
float GetSkillCvar( char *pName )
|
||||
float GetSkillCvar(char *pName)
|
||||
{
|
||||
int iCount;
|
||||
float flValue;
|
||||
char szBuffer[ 64 ];
|
||||
|
||||
iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel );
|
||||
char szBuffer[64];
|
||||
int iCount = sprintf(szBuffer, "%s%d",pName, gSkillData.iSkillLevel);
|
||||
float flValue = CVAR_GET_FLOAT(szBuffer);
|
||||
|
||||
flValue = CVAR_GET_FLOAT ( szBuffer );
|
||||
|
||||
if ( flValue <= 0 )
|
||||
{
|
||||
ALERT ( at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n", szBuffer );
|
||||
}
|
||||
if (flValue <= 0)
|
||||
ALERT(at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n", szBuffer);
|
||||
|
||||
return flValue;
|
||||
}
|
||||
|
||||
}
|
66
dlls/skill.h
66
dlls/skill.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,86 +12,59 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// skill.h - skill level concerns
|
||||
//=========================================================
|
||||
|
||||
struct skilldata_t
|
||||
{
|
||||
|
||||
int iSkillLevel; // game skill level
|
||||
|
||||
// Monster Health & Damage
|
||||
float agruntHealth;
|
||||
int iSkillLevel;
|
||||
float agruntHealth;
|
||||
float agruntDmgPunch;
|
||||
|
||||
float apacheHealth;
|
||||
|
||||
float barneyHealth;
|
||||
|
||||
float bigmommaHealthFactor; // Multiply each node's health by this
|
||||
float bigmommaDmgSlash; // melee attack damage
|
||||
float bigmommaDmgBlast; // mortar attack damage
|
||||
float bigmommaRadiusBlast; // mortar attack radius
|
||||
|
||||
float bigmommaHealthFactor;
|
||||
float bigmommaDmgSlash;
|
||||
float bigmommaDmgBlast;
|
||||
float bigmommaRadiusBlast;
|
||||
float bullsquidHealth;
|
||||
float bullsquidDmgBite;
|
||||
float bullsquidDmgWhip;
|
||||
float bullsquidDmgSpit;
|
||||
|
||||
float gargantuaHealth;
|
||||
float gargantuaDmgSlash;
|
||||
float gargantuaDmgFire;
|
||||
float gargantuaDmgStomp;
|
||||
|
||||
float hassassinHealth;
|
||||
|
||||
float headcrabHealth;
|
||||
float headcrabDmgBite;
|
||||
|
||||
float hgruntHealth;
|
||||
float hgruntDmgKick;
|
||||
float hgruntShotgunPellets;
|
||||
float hgruntGrenadeSpeed;
|
||||
|
||||
float houndeyeHealth;
|
||||
float houndeyeDmgBlast;
|
||||
|
||||
float slaveHealth;
|
||||
float slaveDmgClaw;
|
||||
float slaveDmgClawrake;
|
||||
float slaveDmgZap;
|
||||
|
||||
float ichthyosaurHealth;
|
||||
float ichthyosaurDmgShake;
|
||||
|
||||
float leechHealth;
|
||||
float leechDmgBite;
|
||||
|
||||
float controllerHealth;
|
||||
float controllerDmgZap;
|
||||
float controllerSpeedBall;
|
||||
float controllerDmgBall;
|
||||
|
||||
float nihilanthHealth;
|
||||
float nihilanthZap;
|
||||
|
||||
float scientistHealth;
|
||||
|
||||
float snarkHealth;
|
||||
float snarkDmgBite;
|
||||
float snarkDmgPop;
|
||||
|
||||
float zombieHealth;
|
||||
float zombieDmgOneSlash;
|
||||
float zombieDmgBothSlash;
|
||||
|
||||
float turretHealth;
|
||||
float miniturretHealth;
|
||||
float sentryHealth;
|
||||
|
||||
|
||||
// Player Weapons
|
||||
float plrDmgCrowbar;
|
||||
float plrDmg9MM;
|
||||
float plrDmg357;
|
||||
|
@ -108,28 +81,20 @@ struct skilldata_t
|
|||
float plrDmgHandGrenade;
|
||||
float plrDmgSatchel;
|
||||
float plrDmgTripmine;
|
||||
|
||||
// weapons shared by monsters
|
||||
float monDmg9MM;
|
||||
float monDmgMP5;
|
||||
float monDmg12MM;
|
||||
float monDmgHornet;
|
||||
|
||||
// health/suit charge
|
||||
float suitchargerCapacity;
|
||||
float batteryCapacity;
|
||||
float healthchargerCapacity;
|
||||
float healthkitCapacity;
|
||||
float scientistHeal;
|
||||
|
||||
// monster damage adj
|
||||
float monHead;
|
||||
float monChest;
|
||||
float monStomach;
|
||||
float monLeg;
|
||||
float monArm;
|
||||
|
||||
// player damage adj
|
||||
float plrHead;
|
||||
float plrChest;
|
||||
float plrStomach;
|
||||
|
@ -137,11 +102,10 @@ struct skilldata_t
|
|||
float plrArm;
|
||||
};
|
||||
|
||||
extern DLL_GLOBAL skilldata_t gSkillData;
|
||||
float GetSkillCvar( char *pName );
|
||||
extern DLL_GLOBAL skilldata_t gSkillData;
|
||||
float GetSkillCvar(char *pName);
|
||||
extern DLL_GLOBAL int g_iSkillLevel;
|
||||
|
||||
extern DLL_GLOBAL int g_iSkillLevel;
|
||||
|
||||
#define SKILL_EASY 1
|
||||
#define SKILL_MEDIUM 2
|
||||
#define SKILL_HARD 3
|
||||
#define SKILL_EASY 1
|
||||
#define SKILL_MEDIUM 2
|
||||
#define SKILL_HARD 3
|
1722
dlls/sound.cpp
1722
dlls/sound.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,368 +12,243 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "soundent.h"
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "soundent.h"
|
||||
|
||||
LINK_ENTITY_TO_CLASS( soundent, CSoundEnt );
|
||||
LINK_ENTITY_TO_CLASS(soundent, CSoundEnt);
|
||||
|
||||
CSoundEnt *pSoundEnt;
|
||||
|
||||
//=========================================================
|
||||
// CSound - Clear - zeros all fields for a sound
|
||||
//=========================================================
|
||||
void CSound :: Clear ( void )
|
||||
void CSound::Clear(void)
|
||||
{
|
||||
m_vecOrigin = g_vecZero;
|
||||
m_iType = 0;
|
||||
m_iVolume = 0;
|
||||
m_flExpireTime = 0;
|
||||
m_iNext = SOUNDLIST_EMPTY;
|
||||
m_iNextAudible = 0;
|
||||
m_vecOrigin = g_vecZero;
|
||||
m_iType = 0;
|
||||
m_iVolume = 0;
|
||||
m_flExpireTime = 0;
|
||||
m_iNext = SOUNDLIST_EMPTY;
|
||||
m_iNextAudible = 0;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Reset - clears the volume, origin, and type for a sound,
|
||||
// but doesn't expire or unlink it.
|
||||
//=========================================================
|
||||
void CSound :: Reset ( void )
|
||||
void CSound::Reset(void)
|
||||
{
|
||||
m_vecOrigin = g_vecZero;
|
||||
m_iType = 0;
|
||||
m_iVolume = 0;
|
||||
m_iNext = SOUNDLIST_EMPTY;
|
||||
m_vecOrigin = g_vecZero;
|
||||
m_iType = 0;
|
||||
m_iVolume = 0;
|
||||
m_iNext = SOUNDLIST_EMPTY;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FIsSound - returns TRUE if the sound is an Audible sound
|
||||
//=========================================================
|
||||
BOOL CSound :: FIsSound ( void )
|
||||
BOOL CSound::FIsSound(void)
|
||||
{
|
||||
if ( m_iType & ( bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER ) )
|
||||
{
|
||||
if (m_iType & (bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FIsScent - returns TRUE if the sound is actually a scent
|
||||
//=========================================================
|
||||
BOOL CSound :: FIsScent ( void )
|
||||
BOOL CSound::FIsScent(void)
|
||||
{
|
||||
if ( m_iType & ( bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE ) )
|
||||
{
|
||||
if (m_iType & (bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Spawn
|
||||
//=========================================================
|
||||
void CSoundEnt :: Spawn( void )
|
||||
void CSoundEnt::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
Initialize();
|
||||
|
||||
pev->nextthink = gpGlobals->time + 1;
|
||||
pev->nextthink = gpGlobals->time + 1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Think - at interval, the entire active sound list is checked
|
||||
// for sounds that have ExpireTimes less than or equal
|
||||
// to the current world time, and these sounds are deallocated.
|
||||
//=========================================================
|
||||
void CSoundEnt :: Think ( void )
|
||||
void CSoundEnt::Think(void)
|
||||
{
|
||||
int iSound;
|
||||
int iPreviousSound;
|
||||
pev->nextthink = gpGlobals->time + 0.3;
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.3;// how often to check the sound list.
|
||||
int iPreviousSound = SOUNDLIST_EMPTY;
|
||||
int iSound = m_iActiveSound;
|
||||
|
||||
iPreviousSound = SOUNDLIST_EMPTY;
|
||||
iSound = m_iActiveSound;
|
||||
|
||||
while ( iSound != SOUNDLIST_EMPTY )
|
||||
while (iSound != SOUNDLIST_EMPTY)
|
||||
{
|
||||
if ( m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE )
|
||||
if (m_SoundPool[iSound].m_flExpireTime <= gpGlobals->time && m_SoundPool[iSound].m_flExpireTime != SOUND_NEVER_EXPIRE)
|
||||
{
|
||||
int iNext = m_SoundPool[ iSound ].m_iNext;
|
||||
|
||||
// move this sound back into the free list
|
||||
FreeSound( iSound, iPreviousSound );
|
||||
|
||||
int iNext = m_SoundPool[iSound].m_iNext;
|
||||
FreeSound(iSound, iPreviousSound);
|
||||
iSound = iNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
iPreviousSound = iSound;
|
||||
iSound = m_SoundPool[ iSound ].m_iNext;
|
||||
iSound = m_SoundPool[iSound].m_iNext;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_fShowReport )
|
||||
if (m_fShowReport)
|
||||
{
|
||||
ALERT ( at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList( SOUNDLISTTYPE_ACTIVE ),ISoundsInList( SOUNDLISTTYPE_FREE ), ISoundsInList( SOUNDLISTTYPE_ACTIVE ) - m_cLastActiveSounds );
|
||||
m_cLastActiveSounds = ISoundsInList ( SOUNDLISTTYPE_ACTIVE );
|
||||
ALERT(at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList(SOUNDLISTTYPE_ACTIVE), ISoundsInList(SOUNDLISTTYPE_FREE), ISoundsInList(SOUNDLISTTYPE_ACTIVE) - m_cLastActiveSounds);
|
||||
m_cLastActiveSounds = ISoundsInList(SOUNDLISTTYPE_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
void CSoundEnt::Precache(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Precache - dummy function
|
||||
//=========================================================
|
||||
void CSoundEnt :: Precache ( void )
|
||||
void CSoundEnt::FreeSound(int iSound, int iPrevious)
|
||||
{
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FreeSound - clears the passed active sound and moves it
|
||||
// to the top of the free list. TAKE CARE to only call this
|
||||
// function for sounds in the Active list!!
|
||||
//=========================================================
|
||||
void CSoundEnt :: FreeSound ( int iSound, int iPrevious )
|
||||
{
|
||||
if ( !pSoundEnt )
|
||||
{
|
||||
// no sound ent!
|
||||
if (!pSoundEnt)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( iPrevious != SOUNDLIST_EMPTY )
|
||||
{
|
||||
// iSound is not the head of the active list, so
|
||||
// must fix the index for the Previous sound
|
||||
// pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = m_SoundPool[ iSound ].m_iNext;
|
||||
pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = pSoundEnt->m_SoundPool[ iSound ].m_iNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the sound we're freeing IS the head of the active list.
|
||||
pSoundEnt->m_iActiveSound = pSoundEnt->m_SoundPool [ iSound ].m_iNext;
|
||||
}
|
||||
if (iPrevious != SOUNDLIST_EMPTY)
|
||||
pSoundEnt->m_SoundPool[iPrevious].m_iNext = pSoundEnt->m_SoundPool[iSound].m_iNext;
|
||||
else
|
||||
pSoundEnt->m_iActiveSound = pSoundEnt->m_SoundPool [iSound].m_iNext;
|
||||
|
||||
// make iSound the head of the Free list.
|
||||
pSoundEnt->m_SoundPool[ iSound ].m_iNext = pSoundEnt->m_iFreeSound;
|
||||
pSoundEnt->m_SoundPool[iSound].m_iNext = pSoundEnt->m_iFreeSound;
|
||||
pSoundEnt->m_iFreeSound = iSound;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// IAllocSound - moves a sound from the Free list to the
|
||||
// Active list returns the index of the alloc'd sound
|
||||
//=========================================================
|
||||
int CSoundEnt :: IAllocSound( void )
|
||||
int CSoundEnt::IAllocSound(void)
|
||||
{
|
||||
int iNewSound;
|
||||
|
||||
if ( m_iFreeSound == SOUNDLIST_EMPTY )
|
||||
if (m_iFreeSound == SOUNDLIST_EMPTY)
|
||||
{
|
||||
// no free sound!
|
||||
ALERT ( at_console, "Free Sound List is full!\n" );
|
||||
ALERT(at_console, "Free Sound List is full!\n");
|
||||
return SOUNDLIST_EMPTY;
|
||||
}
|
||||
|
||||
// there is at least one sound available, so move it to the
|
||||
// Active sound list, and return its SoundPool index.
|
||||
|
||||
iNewSound = m_iFreeSound;// copy the index of the next free sound
|
||||
|
||||
m_iFreeSound = m_SoundPool[ m_iFreeSound ].m_iNext;// move the index down into the free list.
|
||||
|
||||
m_SoundPool[ iNewSound ].m_iNext = m_iActiveSound;// point the new sound at the top of the active list.
|
||||
|
||||
m_iActiveSound = iNewSound;// now make the new sound the top of the active list. You're done.
|
||||
|
||||
int iNewSound = m_iFreeSound;
|
||||
m_iFreeSound = m_SoundPool[m_iFreeSound].m_iNext;
|
||||
m_SoundPool[iNewSound].m_iNext = m_iActiveSound;
|
||||
m_iActiveSound = iNewSound;
|
||||
return iNewSound;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// InsertSound - Allocates a free sound and fills it with
|
||||
// sound info.
|
||||
//=========================================================
|
||||
void CSoundEnt :: InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration )
|
||||
void CSoundEnt::InsertSound(int iType, const Vector &vecOrigin, int iVolume, float flDuration)
|
||||
{
|
||||
int iThisSound;
|
||||
if (!pSoundEnt)
|
||||
return;
|
||||
|
||||
if ( !pSoundEnt )
|
||||
int iThisSound = pSoundEnt->IAllocSound();
|
||||
|
||||
if (iThisSound == SOUNDLIST_EMPTY)
|
||||
{
|
||||
// no sound ent!
|
||||
ALERT(at_console, "Could not AllocSound() for InsertSound() (DLL)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
iThisSound = pSoundEnt->IAllocSound();
|
||||
|
||||
if ( iThisSound == SOUNDLIST_EMPTY )
|
||||
{
|
||||
ALERT ( at_console, "Could not AllocSound() for InsertSound() (DLL)\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
pSoundEnt->m_SoundPool[ iThisSound ].m_vecOrigin = vecOrigin;
|
||||
pSoundEnt->m_SoundPool[ iThisSound ].m_iType = iType;
|
||||
pSoundEnt->m_SoundPool[ iThisSound ].m_iVolume = iVolume;
|
||||
pSoundEnt->m_SoundPool[ iThisSound ].m_flExpireTime = gpGlobals->time + flDuration;
|
||||
pSoundEnt->m_SoundPool[iThisSound].m_vecOrigin = vecOrigin;
|
||||
pSoundEnt->m_SoundPool[iThisSound].m_iType = iType;
|
||||
pSoundEnt->m_SoundPool[iThisSound].m_iVolume = iVolume;
|
||||
pSoundEnt->m_SoundPool[iThisSound].m_flExpireTime = gpGlobals->time + flDuration;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Initialize - clears all sounds and moves them into the
|
||||
// free sound list.
|
||||
//=========================================================
|
||||
void CSoundEnt :: Initialize ( void )
|
||||
void CSoundEnt::Initialize(void)
|
||||
{
|
||||
int i;
|
||||
int iSound;
|
||||
|
||||
m_cLastActiveSounds;
|
||||
int i = 0;
|
||||
m_cLastActiveSounds = 0;
|
||||
m_iFreeSound = 0;
|
||||
m_iActiveSound = SOUNDLIST_EMPTY;
|
||||
|
||||
for ( i = 0 ; i < MAX_WORLD_SOUNDS ; i++ )
|
||||
{// clear all sounds, and link them into the free sound list.
|
||||
m_SoundPool[ i ].Clear();
|
||||
m_SoundPool[ i ].m_iNext = i + 1;
|
||||
for (; i < MAX_WORLD_SOUNDS ; i++)
|
||||
{
|
||||
m_SoundPool[i].Clear();
|
||||
m_SoundPool[i].m_iNext = i + 1;
|
||||
}
|
||||
|
||||
m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY;// terminate the list here.
|
||||
m_SoundPool[i - 1].m_iNext = SOUNDLIST_EMPTY;
|
||||
|
||||
|
||||
// now reserve enough sounds for each client
|
||||
for ( i = 0 ; i < gpGlobals->maxClients ; i++ )
|
||||
for (i = 0; i < gpGlobals->maxClients; i++)
|
||||
{
|
||||
iSound = pSoundEnt->IAllocSound();
|
||||
int iSound = pSoundEnt->IAllocSound();
|
||||
|
||||
if ( iSound == SOUNDLIST_EMPTY )
|
||||
if (iSound == SOUNDLIST_EMPTY)
|
||||
{
|
||||
ALERT ( at_console, "Could not AllocSound() for Client Reserve! (DLL)\n" );
|
||||
ALERT(at_console, "Could not AllocSound() for Client Reserve! (DLL)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
pSoundEnt->m_SoundPool[ iSound ].m_flExpireTime = SOUND_NEVER_EXPIRE;
|
||||
pSoundEnt->m_SoundPool[iSound].m_flExpireTime = SOUND_NEVER_EXPIRE;
|
||||
}
|
||||
|
||||
if ( CVAR_GET_FLOAT("displaysoundlist") == 1 )
|
||||
{
|
||||
if (CVAR_GET_FLOAT("displaysoundlist") == 1)
|
||||
m_fShowReport = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fShowReport = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// ISoundsInList - returns the number of sounds in the desired
|
||||
// sound list.
|
||||
//=========================================================
|
||||
int CSoundEnt :: ISoundsInList ( int iListType )
|
||||
int CSoundEnt::ISoundsInList(int iListType)
|
||||
{
|
||||
int i;
|
||||
int iThisSound;
|
||||
int iThisSound = 0;
|
||||
|
||||
if ( iListType == SOUNDLISTTYPE_FREE )
|
||||
{
|
||||
if (iListType == SOUNDLISTTYPE_FREE)
|
||||
iThisSound = m_iFreeSound;
|
||||
}
|
||||
else if ( iListType == SOUNDLISTTYPE_ACTIVE )
|
||||
{
|
||||
else if (iListType == SOUNDLISTTYPE_ACTIVE)
|
||||
iThisSound = m_iActiveSound;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALERT ( at_console, "Unknown Sound List Type!\n" );
|
||||
}
|
||||
ALERT(at_console, "Unknown Sound List Type!\n");
|
||||
|
||||
if ( iThisSound == SOUNDLIST_EMPTY )
|
||||
{
|
||||
if (iThisSound == SOUNDLIST_EMPTY)
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
int i = 0;
|
||||
|
||||
while ( iThisSound != SOUNDLIST_EMPTY )
|
||||
while (iThisSound != SOUNDLIST_EMPTY)
|
||||
{
|
||||
i++;
|
||||
|
||||
iThisSound = m_SoundPool[ iThisSound ].m_iNext;
|
||||
iThisSound = m_SoundPool[iThisSound].m_iNext;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// ActiveList - returns the head of the active sound list
|
||||
//=========================================================
|
||||
int CSoundEnt :: ActiveList ( void )
|
||||
int CSoundEnt::ActiveList(void)
|
||||
{
|
||||
if ( !pSoundEnt )
|
||||
{
|
||||
if (!pSoundEnt)
|
||||
return SOUNDLIST_EMPTY;
|
||||
}
|
||||
|
||||
return pSoundEnt->m_iActiveSound;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// FreeList - returns the head of the free sound list
|
||||
//=========================================================
|
||||
int CSoundEnt :: FreeList ( void )
|
||||
int CSoundEnt::FreeList(void)
|
||||
{
|
||||
if ( !pSoundEnt )
|
||||
{
|
||||
if (!pSoundEnt)
|
||||
return SOUNDLIST_EMPTY;
|
||||
}
|
||||
|
||||
return pSoundEnt->m_iFreeSound;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// SoundPointerForIndex - returns a pointer to the instance
|
||||
// of CSound at index's position in the sound pool.
|
||||
//=========================================================
|
||||
CSound* CSoundEnt :: SoundPointerForIndex( int iIndex )
|
||||
CSound *CSoundEnt::SoundPointerForIndex(int iIndex)
|
||||
{
|
||||
if ( !pSoundEnt )
|
||||
if (!pSoundEnt)
|
||||
return NULL;
|
||||
|
||||
if (iIndex > (MAX_WORLD_SOUNDS - 1))
|
||||
{
|
||||
ALERT(at_console, "SoundPointerForIndex() - Index too large!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( iIndex > ( MAX_WORLD_SOUNDS - 1 ) )
|
||||
if (iIndex < 0)
|
||||
{
|
||||
ALERT ( at_console, "SoundPointerForIndex() - Index too large!\n" );
|
||||
ALERT(at_console, "SoundPointerForIndex() - Index < 0!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( iIndex < 0 )
|
||||
{
|
||||
ALERT ( at_console, "SoundPointerForIndex() - Index < 0!\n" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &pSoundEnt->m_SoundPool[ iIndex ];
|
||||
return &pSoundEnt->m_SoundPool[iIndex];
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Clients are numbered from 1 to MAXCLIENTS, but the client
|
||||
// reserved sounds in the soundlist are from 0 to MAXCLIENTS - 1,
|
||||
// so this function ensures that a client gets the proper index
|
||||
// to his reserved sound in the soundlist.
|
||||
//=========================================================
|
||||
int CSoundEnt :: ClientSoundIndex ( edict_t *pClient )
|
||||
int CSoundEnt::ClientSoundIndex(edict_t *pClient)
|
||||
{
|
||||
int iReturn = ENTINDEX( pClient ) - 1;
|
||||
int iReturn = ENTINDEX(pClient) - 1;
|
||||
|
||||
#ifdef _DEBUG
|
||||
if ( iReturn < 0 || iReturn > gpGlobals->maxClients )
|
||||
{
|
||||
ALERT ( at_console, "** ClientSoundIndex returning a bogus value! **\n" );
|
||||
}
|
||||
#endif // _DEBUG
|
||||
if (iReturn < 0 || iReturn > gpGlobals->maxClients)
|
||||
ALERT(at_console, "** ClientSoundIndex returning a bogus value! **\n");
|
||||
#endif
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
}
|
110
dlls/soundent.h
110
dlls/soundent.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,84 +12,74 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// Soundent.h - the entity that spawns when the world
|
||||
// spawns, and handles the world's active and free sound
|
||||
// lists.
|
||||
//=========================================================
|
||||
|
||||
#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time.
|
||||
#define MAX_WORLD_SOUNDS 64
|
||||
|
||||
#define bits_SOUND_NONE 0
|
||||
#define bits_SOUND_COMBAT ( 1 << 0 )// gunshots, explosions
|
||||
#define bits_SOUND_WORLD ( 1 << 1 )// door opening/closing, glass breaking
|
||||
#define bits_SOUND_PLAYER ( 1 << 2 )// all noises generated by player. walking, shooting, falling, splashing
|
||||
#define bits_SOUND_CARCASS ( 1 << 3 )// dead body
|
||||
#define bits_SOUND_MEAT ( 1 << 4 )// gib or pork chop
|
||||
#define bits_SOUND_DANGER ( 1 << 5 )// pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate
|
||||
#define bits_SOUND_GARBAGE ( 1 << 6 )// trash cans, banana peels, old fast food bags.
|
||||
#define bits_SOUND_NONE 0
|
||||
#define bits_SOUND_COMBAT (1<<0)
|
||||
#define bits_SOUND_WORLD (1<<1)
|
||||
#define bits_SOUND_PLAYER (1<< 2)
|
||||
#define bits_SOUND_CARCASS (1<< 3)
|
||||
#define bits_SOUND_MEAT (1<< 4)
|
||||
#define bits_SOUND_DANGER (1<< 5)
|
||||
#define bits_SOUND_GARBAGE (1<< 6)
|
||||
|
||||
#define bits_ALL_SOUNDS 0xFFFFFFFF
|
||||
|
||||
#define SOUNDLIST_EMPTY -1
|
||||
|
||||
#define SOUNDLISTTYPE_FREE 1// identifiers passed to functions that can operate on either list, to indicate which list to operate on.
|
||||
#define SOUNDLISTTYPE_FREE 1
|
||||
#define SOUNDLISTTYPE_ACTIVE 2
|
||||
|
||||
#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire.
|
||||
#define SOUND_NEVER_EXPIRE -1
|
||||
|
||||
//=========================================================
|
||||
// CSound - an instance of a sound in the world.
|
||||
//=========================================================
|
||||
class CSound
|
||||
{
|
||||
public:
|
||||
void Clear(void);
|
||||
void Reset(void);
|
||||
|
||||
void Clear ( void );
|
||||
void Reset ( void );
|
||||
public:
|
||||
Vector m_vecOrigin;
|
||||
int m_iType;
|
||||
int m_iVolume;
|
||||
float m_flExpireTime;
|
||||
int m_iNext;
|
||||
int m_iNextAudible;
|
||||
|
||||
Vector m_vecOrigin; // sound's location in space
|
||||
int m_iType; // what type of sound this is
|
||||
int m_iVolume; // how loud the sound is
|
||||
float m_flExpireTime; // when the sound should be purged from the list
|
||||
int m_iNext; // index of next sound in this list ( Active or Free )
|
||||
int m_iNextAudible; // temporary link that monsters use to build a list of audible sounds
|
||||
|
||||
BOOL FIsSound( void );
|
||||
BOOL FIsScent( void );
|
||||
public:
|
||||
BOOL FIsSound(void);
|
||||
BOOL FIsScent(void);
|
||||
};
|
||||
|
||||
//=========================================================
|
||||
// CSoundEnt - a single instance of this entity spawns when
|
||||
// the world spawns. The SoundEnt's job is to update the
|
||||
// world's Free and Active sound lists.
|
||||
//=========================================================
|
||||
class CSoundEnt : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Precache(void);
|
||||
void Spawn(void);
|
||||
void Think(void);
|
||||
void Initialize(void);
|
||||
int ObjectCaps(void) { return FCAP_DONT_SAVE; }
|
||||
|
||||
void Precache ( void );
|
||||
void Spawn( void );
|
||||
void Think( void );
|
||||
void Initialize ( void );
|
||||
|
||||
static void InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration );
|
||||
static void FreeSound ( int iSound, int iPrevious );
|
||||
static int ActiveList( void );// return the head of the active list
|
||||
static int FreeList( void );// return the head of the free list
|
||||
static CSound* SoundPointerForIndex( int iIndex );// return a pointer for this index in the sound list
|
||||
static int ClientSoundIndex ( edict_t *pClient );
|
||||
public:
|
||||
static void InsertSound(int iType, const Vector &vecOrigin, int iVolume, float flDuration);
|
||||
static void FreeSound(int iSound, int iPrevious);
|
||||
static int ActiveList(void);
|
||||
static int FreeList(void);
|
||||
static CSound *SoundPointerForIndex(int iIndex);
|
||||
static int ClientSoundIndex(edict_t *pClient);
|
||||
|
||||
BOOL IsEmpty( void ) { return m_iActiveSound == SOUNDLIST_EMPTY; }
|
||||
int ISoundsInList ( int iListType );
|
||||
int IAllocSound ( void );
|
||||
virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; }
|
||||
|
||||
int m_iFreeSound; // index of the first sound in the free sound list
|
||||
int m_iActiveSound; // indes of the first sound in the active sound list
|
||||
int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work)
|
||||
BOOL m_fShowReport; // if true, dump information about free/active sounds.
|
||||
public:
|
||||
BOOL IsEmpty(void) { return m_iActiveSound == SOUNDLIST_EMPTY; }
|
||||
int ISoundsInList(int iListType);
|
||||
int IAllocSound(void);
|
||||
|
||||
public:
|
||||
int m_iFreeSound;
|
||||
int m_iActiveSound;
|
||||
int m_cLastActiveSounds;
|
||||
BOOL m_fShowReport;
|
||||
|
||||
private:
|
||||
CSound m_SoundPool[ MAX_WORLD_SOUNDS ];
|
||||
};
|
||||
CSound m_SoundPool[MAX_WORLD_SOUNDS];
|
||||
};
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,138 +12,85 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// CBaseSpectator
|
||||
|
||||
// YWB: UNDONE
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "spectator.h"
|
||||
|
||||
// Spectator functions
|
||||
//
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "spectator.h"
|
||||
|
||||
/*
|
||||
===========
|
||||
SpectatorConnect
|
||||
|
||||
called when a spectator connects to a server
|
||||
============
|
||||
*/
|
||||
void CBaseSpectator::SpectatorConnect(void)
|
||||
{
|
||||
pev->flags = FL_SPECTATOR;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NOCLIP;
|
||||
|
||||
m_pGoalEnt = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
SpectatorDisconnect
|
||||
|
||||
called when a spectator disconnects from a server
|
||||
============
|
||||
*/
|
||||
void CBaseSpectator::SpectatorDisconnect(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SpectatorImpulseCommand
|
||||
|
||||
Called by SpectatorThink if the spectator entered an impulse
|
||||
================
|
||||
*/
|
||||
void CBaseSpectator::SpectatorImpulseCommand(void)
|
||||
{
|
||||
static edict_t *pGoal = NULL;
|
||||
edict_t *pPreviousGoal;
|
||||
edict_t *pCurrentGoal;
|
||||
BOOL bFound;
|
||||
|
||||
switch (pev->impulse)
|
||||
{
|
||||
case 1:
|
||||
// teleport the spectator to the next spawn point
|
||||
// note that if the spectator is tracking, this doesn't do
|
||||
// much
|
||||
pPreviousGoal = pGoal;
|
||||
pCurrentGoal = pGoal;
|
||||
// Start at the current goal, skip the world, and stop if we looped
|
||||
// back around
|
||||
|
||||
bFound = FALSE;
|
||||
while (1)
|
||||
case 1:
|
||||
{
|
||||
pCurrentGoal = FIND_ENTITY_BY_CLASSNAME(pCurrentGoal, "info_player_deathmatch");
|
||||
// Looped around, failure
|
||||
if (pCurrentGoal == pPreviousGoal)
|
||||
static edict_t *pGoal = NULL;
|
||||
edict_t *pPreviousGoal = pGoal;
|
||||
edict_t *pCurrentGoal = pGoal;
|
||||
BOOL bFound = FALSE;
|
||||
|
||||
while (1)
|
||||
{
|
||||
ALERT(at_console, "Could not find a spawn spot.\n");
|
||||
break;
|
||||
pCurrentGoal = FIND_ENTITY_BY_CLASSNAME(pCurrentGoal, "info_player_deathmatch");
|
||||
|
||||
if (pCurrentGoal == pPreviousGoal)
|
||||
{
|
||||
ALERT(at_console, "Could not find a spawn spot.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!FNullEnt(pCurrentGoal))
|
||||
{
|
||||
bFound = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Found a non-world entity, set success, otherwise, look for the next one.
|
||||
if (!FNullEnt(pCurrentGoal))
|
||||
{
|
||||
bFound = TRUE;
|
||||
|
||||
if (!bFound)
|
||||
break;
|
||||
}
|
||||
|
||||
pGoal = pCurrentGoal;
|
||||
UTIL_SetOrigin(pev, pGoal->v.origin);
|
||||
pev->angles = pGoal->v.angles;
|
||||
pev->fixangle = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bFound) // Didn't find a good spot.
|
||||
break;
|
||||
|
||||
pGoal = pCurrentGoal;
|
||||
UTIL_SetOrigin( pev, pGoal->v.origin );
|
||||
pev->angles = pGoal->v.angles;
|
||||
pev->fixangle = FALSE;
|
||||
break;
|
||||
default:
|
||||
ALERT(at_console, "Unknown spectator impulse\n");
|
||||
break;
|
||||
default: ALERT(at_console, "Unknown spectator impulse\n"); break;
|
||||
}
|
||||
|
||||
pev->impulse = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SpectatorThink
|
||||
|
||||
Called every frame after physics are run
|
||||
================
|
||||
*/
|
||||
void CBaseSpectator::SpectatorThink(void)
|
||||
void CBaseSpectator::SpectatorThink(void)
|
||||
{
|
||||
if (!(pev->flags & FL_SPECTATOR))
|
||||
{
|
||||
pev->flags = FL_SPECTATOR;
|
||||
}
|
||||
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NOCLIP;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NOCLIP;
|
||||
|
||||
if (pev->impulse)
|
||||
SpectatorImpulseCommand();
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
Spawn
|
||||
|
||||
Called when spectator is initialized:
|
||||
UNDONE: Is this actually being called because spectators are not allocated in normal fashion?
|
||||
============
|
||||
*/
|
||||
void CBaseSpectator::Spawn()
|
||||
void CBaseSpectator::Spawn(void)
|
||||
{
|
||||
pev->flags = FL_SPECTATOR;
|
||||
pev->solid = SOLID_NOT;
|
||||
pev->movetype = MOVETYPE_NOCLIP;
|
||||
|
||||
m_pGoalEnt = NULL;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,16 +12,15 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
// Spectator.h
|
||||
|
||||
class CBaseSpectator : public CBaseEntity
|
||||
class CBaseSpectator : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn();
|
||||
void Spawn(void);
|
||||
void SpectatorConnect(void);
|
||||
void SpectatorDisconnect(void);
|
||||
void SpectatorThink(void);
|
||||
|
||||
private:
|
||||
void SpectatorImpulseCommand(void);
|
||||
};
|
||||
};
|
|
@ -1,601 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "soundent.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
enum w_squeak_e {
|
||||
WSQUEAK_IDLE1 = 0,
|
||||
WSQUEAK_FIDGET,
|
||||
WSQUEAK_JUMP,
|
||||
WSQUEAK_RUN,
|
||||
};
|
||||
|
||||
enum squeak_e {
|
||||
SQUEAK_IDLE1 = 0,
|
||||
SQUEAK_FIDGETFIT,
|
||||
SQUEAK_FIDGETNIP,
|
||||
SQUEAK_DOWN,
|
||||
SQUEAK_UP,
|
||||
SQUEAK_THROW
|
||||
};
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
class CSqueakGrenade : public CGrenade
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
int Classify( void );
|
||||
void EXPORT SuperBounceTouch( CBaseEntity *pOther );
|
||||
void EXPORT HuntThink( void );
|
||||
int BloodColor( void ) { return BLOOD_COLOR_YELLOW; }
|
||||
void Killed( entvars_t *pevAttacker, int iGib );
|
||||
void GibMonster( void );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
static float m_flNextBounceSoundTime;
|
||||
|
||||
// CBaseEntity *m_pTarget;
|
||||
float m_flDie;
|
||||
Vector m_vecTarget;
|
||||
float m_flNextHunt;
|
||||
float m_flNextHit;
|
||||
Vector m_posPrev;
|
||||
EHANDLE m_hOwner;
|
||||
int m_iMyClass;
|
||||
};
|
||||
|
||||
float CSqueakGrenade::m_flNextBounceSoundTime = 0;
|
||||
|
||||
LINK_ENTITY_TO_CLASS( monster_snark, CSqueakGrenade );
|
||||
TYPEDESCRIPTION CSqueakGrenade::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CSqueakGrenade, m_flDie, FIELD_TIME ),
|
||||
DEFINE_FIELD( CSqueakGrenade, m_vecTarget, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( CSqueakGrenade, m_flNextHunt, FIELD_TIME ),
|
||||
DEFINE_FIELD( CSqueakGrenade, m_flNextHit, FIELD_TIME ),
|
||||
DEFINE_FIELD( CSqueakGrenade, m_posPrev, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CSqueakGrenade, m_hOwner, FIELD_EHANDLE ),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CSqueakGrenade, CGrenade );
|
||||
|
||||
#define SQUEEK_DETONATE_DELAY 15.0
|
||||
|
||||
int CSqueakGrenade :: Classify ( void )
|
||||
{
|
||||
if (m_iMyClass != 0)
|
||||
return m_iMyClass; // protect against recursion
|
||||
|
||||
if (m_hEnemy != NULL)
|
||||
{
|
||||
m_iMyClass = CLASS_INSECT; // no one cares about it
|
||||
switch( m_hEnemy->Classify( ) )
|
||||
{
|
||||
case CLASS_PLAYER:
|
||||
case CLASS_HUMAN_PASSIVE:
|
||||
case CLASS_HUMAN_MILITARY:
|
||||
m_iMyClass = 0;
|
||||
return CLASS_ALIEN_MILITARY; // barney's get mad, grunts get mad at it
|
||||
}
|
||||
m_iMyClass = 0;
|
||||
}
|
||||
|
||||
return CLASS_ALIEN_BIOWEAPON;
|
||||
}
|
||||
|
||||
void CSqueakGrenade :: Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
// motor
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
pev->solid = SOLID_BBOX;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/w_squeak.mdl");
|
||||
UTIL_SetSize(pev, Vector( -4, -4, 0), Vector(4, 4, 8));
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
SetTouch( SuperBounceTouch );
|
||||
SetThink( HuntThink );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
m_flNextHunt = gpGlobals->time + 1E6;
|
||||
|
||||
pev->flags |= FL_MONSTER;
|
||||
pev->takedamage = DAMAGE_AIM;
|
||||
pev->health = gSkillData.snarkHealth;
|
||||
pev->gravity = 0.5;
|
||||
pev->friction = 0.5;
|
||||
|
||||
pev->dmg = gSkillData.snarkDmgPop;
|
||||
|
||||
m_flDie = gpGlobals->time + SQUEEK_DETONATE_DELAY;
|
||||
|
||||
m_flFieldOfView = 0; // 180 degrees
|
||||
|
||||
if ( pev->owner )
|
||||
m_hOwner = Instance( pev->owner );
|
||||
|
||||
m_flNextBounceSoundTime = gpGlobals->time;// reset each time a snark is spawned.
|
||||
|
||||
pev->sequence = WSQUEAK_RUN;
|
||||
ResetSequenceInfo( );
|
||||
}
|
||||
|
||||
void CSqueakGrenade::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_squeak.mdl");
|
||||
PRECACHE_SOUND("squeek/sqk_blast1.wav");
|
||||
PRECACHE_SOUND("common/bodysplat.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_die1.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_hunt1.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_hunt2.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_hunt3.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_deploy1.wav");
|
||||
}
|
||||
|
||||
|
||||
void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib )
|
||||
{
|
||||
pev->model = iStringNull;// make invisible
|
||||
SetThink( SUB_Remove );
|
||||
ResetTouch( );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
// since squeak grenades never leave a body behind, clear out their takedamage now.
|
||||
// Squeaks do a bit of radius damage when they pop, and that radius damage will
|
||||
// continue to call this function unless we acknowledge the Squeak's death now. (sjb)
|
||||
pev->takedamage = DAMAGE_NO;
|
||||
|
||||
// play squeek blast
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM);
|
||||
|
||||
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 );
|
||||
|
||||
UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 );
|
||||
|
||||
if (m_hOwner != NULL)
|
||||
RadiusDamage ( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST );
|
||||
else
|
||||
RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST );
|
||||
|
||||
// reset owner so death message happens
|
||||
if (m_hOwner != NULL)
|
||||
pev->owner = m_hOwner->edict();
|
||||
|
||||
CBaseMonster :: Killed( pevAttacker, GIB_ALWAYS );
|
||||
}
|
||||
|
||||
void CSqueakGrenade :: GibMonster( void )
|
||||
{
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/bodysplat.wav", 0.75, ATTN_NORM, 0, 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSqueakGrenade::HuntThink( void )
|
||||
{
|
||||
// ALERT( at_console, "think\n" );
|
||||
|
||||
if (!IsInWorld())
|
||||
{
|
||||
ResetTouch( );
|
||||
UTIL_Remove( this );
|
||||
return;
|
||||
}
|
||||
|
||||
StudioFrameAdvance( );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
// explode when ready
|
||||
if (gpGlobals->time >= m_flDie)
|
||||
{
|
||||
g_vecAttackDir = pev->velocity.Normalize( );
|
||||
pev->health = -1;
|
||||
Killed( pev, 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
// float
|
||||
if (pev->waterlevel != 0)
|
||||
{
|
||||
if (pev->movetype == MOVETYPE_BOUNCE)
|
||||
{
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
}
|
||||
pev->velocity = pev->velocity * 0.9;
|
||||
pev->velocity.z += 8.0;
|
||||
}
|
||||
else if (pev->movetype = MOVETYPE_FLY)
|
||||
{
|
||||
pev->movetype = MOVETYPE_BOUNCE;
|
||||
}
|
||||
|
||||
// return if not time to hunt
|
||||
if (m_flNextHunt > gpGlobals->time)
|
||||
return;
|
||||
|
||||
m_flNextHunt = gpGlobals->time + 2.0;
|
||||
|
||||
CBaseEntity *pOther = NULL;
|
||||
Vector vecDir;
|
||||
TraceResult tr;
|
||||
|
||||
Vector vecFlat = pev->velocity;
|
||||
vecFlat.z = 0;
|
||||
vecFlat = vecFlat.Normalize( );
|
||||
|
||||
UTIL_MakeVectors( pev->angles );
|
||||
|
||||
if (m_hEnemy == NULL || !m_hEnemy->IsAlive())
|
||||
{
|
||||
// find target, bounce a bit towards it.
|
||||
Look( 512 );
|
||||
m_hEnemy = BestVisibleEnemy( );
|
||||
}
|
||||
|
||||
// squeek if it's about time blow up
|
||||
if ((m_flDie - gpGlobals->time <= 0.5) && (m_flDie - gpGlobals->time >= 0.3))
|
||||
{
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + RANDOM_LONG(0,0x3F));
|
||||
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 );
|
||||
}
|
||||
|
||||
// higher pitch as squeeker gets closer to detonation time
|
||||
float flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY);
|
||||
if (flpitch < 80)
|
||||
flpitch = 80;
|
||||
|
||||
if (m_hEnemy != NULL)
|
||||
{
|
||||
if (FVisible( m_hEnemy ))
|
||||
{
|
||||
vecDir = m_hEnemy->EyePosition() - pev->origin;
|
||||
m_vecTarget = vecDir.Normalize( );
|
||||
}
|
||||
|
||||
float flVel = pev->velocity.Length();
|
||||
float flAdj = 50.0 / (flVel + 10.0);
|
||||
|
||||
if (flAdj > 1.2)
|
||||
flAdj = 1.2;
|
||||
|
||||
// ALERT( at_console, "think : enemy\n");
|
||||
|
||||
// ALERT( at_console, "%.0f %.2f %.2f %.2f\n", flVel, m_vecTarget.x, m_vecTarget.y, m_vecTarget.z );
|
||||
|
||||
pev->velocity = pev->velocity * flAdj + m_vecTarget * 300;
|
||||
}
|
||||
|
||||
if (pev->flags & FL_ONGROUND)
|
||||
{
|
||||
pev->avelocity = Vector( 0, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pev->avelocity == Vector( 0, 0, 0))
|
||||
{
|
||||
pev->avelocity.x = RANDOM_FLOAT( -100, 100 );
|
||||
pev->avelocity.z = RANDOM_FLOAT( -100, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
if ((pev->origin - m_posPrev).Length() < 1.0)
|
||||
{
|
||||
pev->velocity.x = RANDOM_FLOAT( -100, 100 );
|
||||
pev->velocity.y = RANDOM_FLOAT( -100, 100 );
|
||||
}
|
||||
m_posPrev = pev->origin;
|
||||
|
||||
pev->angles = UTIL_VecToAngles( pev->velocity );
|
||||
pev->angles.z = 0;
|
||||
pev->angles.x = 0;
|
||||
}
|
||||
|
||||
|
||||
void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther )
|
||||
{
|
||||
float flpitch;
|
||||
|
||||
TraceResult tr = UTIL_GetGlobalTrace( );
|
||||
|
||||
// don't hit the guy that launched this grenade
|
||||
if ( pev->owner && pOther->edict() == pev->owner )
|
||||
return;
|
||||
|
||||
// at least until we've bounced once
|
||||
pev->owner = NULL;
|
||||
|
||||
pev->angles.x = 0;
|
||||
pev->angles.z = 0;
|
||||
|
||||
// avoid bouncing too much
|
||||
if (m_flNextHit > gpGlobals->time)
|
||||
return;
|
||||
|
||||
// higher pitch as squeeker gets closer to detonation time
|
||||
flpitch = 155.0 - 60.0 * ((m_flDie - gpGlobals->time) / SQUEEK_DETONATE_DELAY);
|
||||
|
||||
if ( pOther->pev->takedamage && m_flNextAttack < gpGlobals->time )
|
||||
{
|
||||
// attack!
|
||||
|
||||
// make sure it's me who has touched them
|
||||
if (tr.pHit == pOther->edict())
|
||||
{
|
||||
// and it's not another squeakgrenade
|
||||
if (tr.pHit->v.modelindex != pev->modelindex)
|
||||
{
|
||||
// ALERT( at_console, "hit enemy\n");
|
||||
ClearMultiDamage( );
|
||||
pOther->TraceAttack(pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH );
|
||||
if (m_hOwner != NULL)
|
||||
ApplyMultiDamage( pev, m_hOwner->pev );
|
||||
else
|
||||
ApplyMultiDamage( pev, pev );
|
||||
|
||||
pev->dmg += gSkillData.snarkDmgPop; // add more explosion damage
|
||||
// m_flDie += 2.0; // add more life
|
||||
|
||||
// make bite sound
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "squeek/sqk_deploy1.wav", 1.0, ATTN_NORM, 0, (int)flpitch);
|
||||
m_flNextAttack = gpGlobals->time + 0.5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ALERT( at_console, "been hit\n");
|
||||
}
|
||||
}
|
||||
|
||||
m_flNextHit = gpGlobals->time + 0.1;
|
||||
m_flNextHunt = gpGlobals->time;
|
||||
|
||||
if ( g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
// in multiplayer, we limit how often snarks can make their bounce sounds to prevent overflows.
|
||||
if ( gpGlobals->time < m_flNextBounceSoundTime )
|
||||
{
|
||||
// too soon!
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(pev->flags & FL_ONGROUND))
|
||||
{
|
||||
// play bounce sound
|
||||
float flRndSound = RANDOM_FLOAT ( 0 , 1 );
|
||||
|
||||
if ( flRndSound <= 0.33 )
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt1.wav", 1, ATTN_NORM, 0, (int)flpitch);
|
||||
else if (flRndSound <= 0.66)
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, (int)flpitch);
|
||||
else
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, (int)flpitch);
|
||||
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 256, 0.25 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// skittering sound
|
||||
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 100, 0.1 );
|
||||
}
|
||||
|
||||
m_flNextBounceSoundTime = gpGlobals->time + 0.5;// half second.
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_snark, CSqueak );
|
||||
|
||||
|
||||
void CSqueak::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_SNARK;
|
||||
SET_MODEL(ENT(pev), "models/w_sqknest.mdl");
|
||||
|
||||
FallInit();//get ready to fall down.
|
||||
|
||||
m_iDefaultAmmo = SNARK_DEFAULT_GIVE;
|
||||
|
||||
pev->sequence = 1;
|
||||
pev->animtime = gpGlobals->time;
|
||||
pev->framerate = 1.0;
|
||||
}
|
||||
|
||||
|
||||
void CSqueak::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/w_sqknest.mdl");
|
||||
PRECACHE_MODEL("models/v_squeak.mdl");
|
||||
PRECACHE_MODEL("models/p_squeak.mdl");
|
||||
PRECACHE_SOUND("squeek/sqk_hunt2.wav");
|
||||
PRECACHE_SOUND("squeek/sqk_hunt3.wav");
|
||||
UTIL_PrecacheOther("monster_snark");
|
||||
|
||||
m_usSnarkFire = PRECACHE_EVENT ( 1, "events/snarkfire.sc" );
|
||||
}
|
||||
|
||||
|
||||
int CSqueak::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "Snarks";
|
||||
p->iMaxAmmo1 = SNARK_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 4;
|
||||
p->iPosition = 3;
|
||||
p->iId = m_iId = WEAPON_SNARK;
|
||||
p->iWeight = SNARK_WEIGHT;
|
||||
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CSqueak::Deploy( )
|
||||
{
|
||||
// play hunt sound
|
||||
float flRndSound = RANDOM_FLOAT ( 0 , 1 );
|
||||
|
||||
if ( flRndSound <= 0.5 )
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 100);
|
||||
else
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 100);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
|
||||
return DefaultDeploy( "models/v_squeak.mdl", "models/p_squeak.mdl", SQUEAK_UP, "squeak" );
|
||||
}
|
||||
|
||||
|
||||
void CSqueak::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
if ( !m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
|
||||
{
|
||||
m_pPlayer->pev->weapons &= ~(1<<WEAPON_SNARK);
|
||||
SetThink( DestroyItem );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
SendWeaponAnim( SQUEAK_DOWN );
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM);
|
||||
}
|
||||
|
||||
|
||||
void CSqueak::PrimaryAttack()
|
||||
{
|
||||
if ( m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] )
|
||||
{
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
|
||||
TraceResult tr;
|
||||
Vector trace_origin;
|
||||
|
||||
// HACK HACK: Ugly hacks to handle change in origin based on new physics code for players
|
||||
// Move origin up if crouched and start trace a bit outside of body ( 20 units instead of 16 )
|
||||
trace_origin = m_pPlayer->pev->origin;
|
||||
if ( m_pPlayer->pev->flags & FL_DUCKING )
|
||||
{
|
||||
trace_origin = trace_origin - ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
|
||||
}
|
||||
|
||||
// find place to toss monster
|
||||
UTIL_TraceLine( trace_origin + gpGlobals->v_forward * 20, trace_origin + gpGlobals->v_forward * 64, dont_ignore_monsters, NULL, &tr );
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSnarkFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 );
|
||||
|
||||
if ( tr.fAllSolid == 0 && tr.fStartSolid == 0 && tr.flFraction > 0.25 )
|
||||
{
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
CBaseEntity *pSqueak = CBaseEntity::Create( "monster_snark", tr.vecEndPos, m_pPlayer->pev->v_angle, m_pPlayer->edict() );
|
||||
pSqueak->pev->velocity = gpGlobals->v_forward * 200 + m_pPlayer->pev->velocity;
|
||||
#endif
|
||||
|
||||
// play hunt sound
|
||||
float flRndSound = RANDOM_FLOAT ( 0 , 1 );
|
||||
|
||||
if ( flRndSound <= 0.5 )
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt2.wav", 1, ATTN_NORM, 0, 105);
|
||||
else
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "squeek/sqk_hunt3.wav", 1, ATTN_NORM, 0, 105);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
|
||||
m_fJustThrown = 1;
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSqueak::SecondaryAttack( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSqueak::WeaponIdle( void )
|
||||
{
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
if (m_fJustThrown)
|
||||
{
|
||||
m_fJustThrown = 0;
|
||||
|
||||
if ( !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] )
|
||||
{
|
||||
RetireWeapon();
|
||||
return;
|
||||
}
|
||||
|
||||
SendWeaponAnim( SQUEAK_UP );
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
return;
|
||||
}
|
||||
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.75)
|
||||
{
|
||||
iAnim = SQUEAK_IDLE1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 30.0 / 16 * (2);
|
||||
}
|
||||
else if (flRand <= 0.875)
|
||||
{
|
||||
iAnim = SQUEAK_FIDGETFIT;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 16.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = SQUEAK_FIDGETNIP;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 16.0;
|
||||
}
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
|
||||
#endif
|
433
dlls/subs.cpp
433
dlls/subs.cpp
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,65 +12,50 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
/*
|
||||
|
||||
===== subs.cpp ========================================================
|
||||
|
||||
frequently used global functions
|
||||
|
||||
*/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "saverestore.h"
|
||||
#include "nodes.h"
|
||||
#include "doors.h"
|
||||
|
||||
extern CGraph WorldGraph;
|
||||
|
||||
extern BOOL FEntIsVisible(entvars_t* pev, entvars_t* pevTarget);
|
||||
|
||||
extern BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget);
|
||||
extern DLL_GLOBAL int g_iSkillLevel;
|
||||
|
||||
|
||||
// Landmark class
|
||||
void CPointEntity :: Spawn( void )
|
||||
void CPointEntity::Spawn(void)
|
||||
{
|
||||
pev->solid = SOLID_NOT;
|
||||
// UTIL_SetSize(pev, g_vecZero, g_vecZero);
|
||||
}
|
||||
|
||||
|
||||
class CNullEntity : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Spawn(void);
|
||||
};
|
||||
|
||||
|
||||
// Null Entity, remove on startup
|
||||
void CNullEntity :: Spawn( void )
|
||||
void CNullEntity::Spawn(void)
|
||||
{
|
||||
REMOVE_ENTITY(ENT(pev));
|
||||
}
|
||||
LINK_ENTITY_TO_CLASS(info_null,CNullEntity);
|
||||
|
||||
LINK_ENTITY_TO_CLASS(info_null, CNullEntity);
|
||||
|
||||
class CBaseDMStart : public CPointEntity
|
||||
{
|
||||
public:
|
||||
void KeyValue( KeyValueData *pkvd );
|
||||
BOOL IsTriggered( CBaseEntity *pEntity );
|
||||
|
||||
private:
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
BOOL IsTriggered(CBaseEntity *pEntity);
|
||||
};
|
||||
|
||||
// These are the new entry points to entities.
|
||||
LINK_ENTITY_TO_CLASS(info_player_deathmatch,CBaseDMStart);
|
||||
LINK_ENTITY_TO_CLASS(info_player_start,CPointEntity);
|
||||
LINK_ENTITY_TO_CLASS(info_landmark,CPointEntity);
|
||||
LINK_ENTITY_TO_CLASS(info_vip_start, CBaseDMStart);
|
||||
LINK_ENTITY_TO_CLASS(info_player_deathmatch, CBaseDMStart);
|
||||
LINK_ENTITY_TO_CLASS(info_player_start, CPointEntity);
|
||||
LINK_ENTITY_TO_CLASS(info_landmark, CPointEntity);
|
||||
LINK_ENTITY_TO_CLASS(info_hostage_rescue, CPointEntity);
|
||||
LINK_ENTITY_TO_CLASS(info_bomb_target, CPointEntity);
|
||||
|
||||
void CBaseDMStart::KeyValue( KeyValueData *pkvd )
|
||||
void CBaseDMStart::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "master"))
|
||||
{
|
||||
|
@ -78,73 +63,60 @@ void CBaseDMStart::KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CPointEntity::KeyValue( pkvd );
|
||||
CPointEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
BOOL CBaseDMStart::IsTriggered( CBaseEntity *pEntity )
|
||||
BOOL CBaseDMStart::IsTriggered(CBaseEntity *pEntity)
|
||||
{
|
||||
BOOL master = UTIL_IsMasterTriggered( pev->netname, pEntity );
|
||||
|
||||
return master;
|
||||
return UTIL_IsMasterTriggered(pev->netname, pEntity);
|
||||
}
|
||||
|
||||
// This updates global tables that need to know about entities being removed
|
||||
void CBaseEntity::UpdateOnRemove( void )
|
||||
void CBaseEntity::UpdateOnRemove(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if ( FBitSet( pev->flags, FL_GRAPHED ) )
|
||||
if (FBitSet(pev->flags, FL_GRAPHED))
|
||||
{
|
||||
// this entity was a LinkEnt in the world node graph, so we must remove it from
|
||||
// the graph since we are removing it from the world.
|
||||
for ( i = 0 ; i < WorldGraph.m_cLinks ; i++ )
|
||||
for (int i = 0; i < WorldGraph.m_cLinks; i++)
|
||||
{
|
||||
if ( WorldGraph.m_pLinkPool [ i ].m_pLinkEnt == pev )
|
||||
{
|
||||
// if this link has a link ent which is the same ent that is removing itself, remove it!
|
||||
WorldGraph.m_pLinkPool [ i ].m_pLinkEnt = NULL;
|
||||
}
|
||||
if (WorldGraph.m_pLinkPool[i].m_pLinkEnt == pev)
|
||||
WorldGraph.m_pLinkPool[i].m_pLinkEnt = NULL;
|
||||
}
|
||||
}
|
||||
if ( pev->globalname )
|
||||
gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD );
|
||||
|
||||
if (pev->globalname)
|
||||
gGlobalState.EntitySetState(pev->globalname, GLOBAL_DEAD);
|
||||
}
|
||||
|
||||
// Convenient way to delay removing oneself
|
||||
void CBaseEntity :: SUB_Remove( void )
|
||||
void CBaseEntity::SUB_Remove(void)
|
||||
{
|
||||
UpdateOnRemove();
|
||||
|
||||
if (pev->health > 0)
|
||||
{
|
||||
// this situation can screw up monsters who can't tell their entity pointers are invalid.
|
||||
pev->health = 0;
|
||||
ALERT( at_aiconsole, "SUB_Remove called on entity with health > 0\n");
|
||||
ALERT(at_aiconsole, "SUB_Remove called on entity with health > 0\n");
|
||||
}
|
||||
|
||||
REMOVE_ENTITY(ENT(pev));
|
||||
}
|
||||
|
||||
|
||||
// Convenient way to explicitly do nothing (passed to functions that require a method)
|
||||
void CBaseEntity :: SUB_DoNothing( void )
|
||||
void CBaseEntity::SUB_DoNothing(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Global Savedata for Delay
|
||||
TYPEDESCRIPTION CBaseDelay::m_SaveData[] =
|
||||
TYPEDESCRIPTION CBaseDelay::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CBaseDelay, m_flDelay, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseDelay, m_iszKillTarget, FIELD_STRING ),
|
||||
DEFINE_FIELD(CBaseDelay, m_flDelay, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseDelay, m_iszKillTarget, FIELD_STRING),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CBaseDelay, CBaseEntity );
|
||||
IMPLEMENT_SAVERESTORE(CBaseDelay, CBaseEntity);
|
||||
|
||||
void CBaseDelay :: KeyValue( KeyValueData *pkvd )
|
||||
void CBaseDelay::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "delay"))
|
||||
{
|
||||
m_flDelay = atof( pkvd->szValue );
|
||||
m_flDelay = atof(pkvd->szValue);
|
||||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else if (FStrEq(pkvd->szKeyName, "killtarget"))
|
||||
|
@ -153,149 +125,91 @@ void CBaseDelay :: KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CBaseEntity::KeyValue( pkvd );
|
||||
}
|
||||
CBaseEntity::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============================
|
||||
SUB_UseTargets
|
||||
|
||||
If self.delay is set, a DelayedUse entity will be created that will actually
|
||||
do the SUB_UseTargets after that many seconds have passed.
|
||||
|
||||
Removes all entities with a targetname that match self.killtarget,
|
||||
and removes them, so some events can remove other triggers.
|
||||
|
||||
Search for (string)targetname in all entities that
|
||||
match (string)self.target and call their .use function (if they have one)
|
||||
|
||||
==============================
|
||||
*/
|
||||
void CBaseEntity :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value )
|
||||
void CBaseEntity::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value)
|
||||
{
|
||||
//
|
||||
// fire targets
|
||||
//
|
||||
if (!FStringNull(pev->target))
|
||||
{
|
||||
FireTargets( STRING(pev->target), pActivator, this, useType, value );
|
||||
}
|
||||
FireTargets(STRING(pev->target), pActivator, this, useType, value);
|
||||
}
|
||||
|
||||
|
||||
void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
||||
void FireTargets(const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
|
||||
{
|
||||
edict_t *pentTarget = NULL;
|
||||
if ( !targetName )
|
||||
|
||||
if (!targetName)
|
||||
return;
|
||||
|
||||
ALERT( at_aiconsole, "Firing: (%s)\n", targetName );
|
||||
ALERT(at_aiconsole, "Firing: (%s)\n", targetName);
|
||||
|
||||
for (;;)
|
||||
while (1)
|
||||
{
|
||||
pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, targetName);
|
||||
|
||||
if (FNullEnt(pentTarget))
|
||||
break;
|
||||
|
||||
CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget );
|
||||
if ( pTarget && !(pTarget->pev->flags & FL_KILLME) ) // Don't use dying ents
|
||||
CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget);
|
||||
|
||||
if (pTarget && !(pTarget->pev->flags & FL_KILLME))
|
||||
{
|
||||
ALERT( at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName );
|
||||
pTarget->Use( pActivator, pCaller, useType, value );
|
||||
ALERT(at_aiconsole, "Found: %s, firing (%s)\n", STRING(pTarget->pev->classname), targetName);
|
||||
pTarget->Use(pActivator, pCaller, useType, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LINK_ENTITY_TO_CLASS( DelayedUse, CBaseDelay );
|
||||
LINK_ENTITY_TO_CLASS(DelayedUse, CBaseDelay);
|
||||
|
||||
|
||||
void CBaseDelay :: SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value )
|
||||
void CBaseDelay::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value)
|
||||
{
|
||||
//
|
||||
// exit immediatly if we don't have a target or kill target
|
||||
//
|
||||
if (FStringNull(pev->target) && !m_iszKillTarget)
|
||||
return;
|
||||
|
||||
//
|
||||
// check for a delay
|
||||
//
|
||||
if (m_flDelay != 0)
|
||||
{
|
||||
// create a temp object to fire at a later time
|
||||
CBaseDelay *pTemp = GetClassPtr( (CBaseDelay *)NULL);
|
||||
CBaseDelay *pTemp = GetClassPtr((CBaseDelay *)NULL);
|
||||
|
||||
if (pTemp->pev->classname)
|
||||
RemoveEntityHashValue(pTemp->pev, STRING(pTemp->pev->classname), CLASSNAME);
|
||||
|
||||
pTemp->pev->classname = MAKE_STRING("DelayedUse");
|
||||
AddEntityHashValue(pTemp->pev, STRING(pTemp->pev->classname), CLASSNAME);
|
||||
|
||||
pTemp->pev->nextthink = gpGlobals->time + m_flDelay;
|
||||
|
||||
pTemp->SetThink( DelayThink );
|
||||
|
||||
// Save the useType
|
||||
pTemp->SetThink(&CBaseDelay::DelayThink);
|
||||
pTemp->pev->button = (int)useType;
|
||||
pTemp->m_iszKillTarget = m_iszKillTarget;
|
||||
pTemp->m_flDelay = 0; // prevent "recursion"
|
||||
pTemp->m_flDelay = 0;
|
||||
pTemp->pev->target = pev->target;
|
||||
|
||||
// HACKHACK
|
||||
// This wasn't in the release build of Half-Life. We should have moved m_hActivator into this class
|
||||
// but changing member variable hierarchy would break save/restore without some ugly code.
|
||||
// This code is not as ugly as that code
|
||||
if ( pActivator && pActivator->IsPlayer() ) // If a player activates, then save it
|
||||
{
|
||||
if (pActivator && pActivator->IsPlayer())
|
||||
pTemp->pev->owner = pActivator->edict();
|
||||
}
|
||||
else
|
||||
{
|
||||
pTemp->pev->owner = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// kill the killtargets
|
||||
//
|
||||
|
||||
if ( m_iszKillTarget )
|
||||
if (m_iszKillTarget)
|
||||
{
|
||||
edict_t *pentKillTarget = NULL;
|
||||
ALERT(at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget));
|
||||
edict_t *pentKillTarget = FIND_ENTITY_BY_TARGETNAME(NULL, STRING(m_iszKillTarget));
|
||||
|
||||
ALERT( at_aiconsole, "KillTarget: %s\n", STRING(m_iszKillTarget) );
|
||||
pentKillTarget = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_iszKillTarget) );
|
||||
while ( !FNullEnt(pentKillTarget) )
|
||||
while (!FNullEnt(pentKillTarget))
|
||||
{
|
||||
UTIL_Remove( CBaseEntity::Instance(pentKillTarget) );
|
||||
|
||||
ALERT( at_aiconsole, "killing %s\n", STRING( pentKillTarget->v.classname ) );
|
||||
pentKillTarget = FIND_ENTITY_BY_TARGETNAME( pentKillTarget, STRING(m_iszKillTarget) );
|
||||
UTIL_Remove(CBaseEntity::Instance(pentKillTarget));
|
||||
ALERT(at_aiconsole, "killing %s\n", STRING(pentKillTarget->v.classname));
|
||||
pentKillTarget = FIND_ENTITY_BY_TARGETNAME(pentKillTarget, STRING(m_iszKillTarget));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// fire targets
|
||||
//
|
||||
|
||||
if (!FStringNull(pev->target))
|
||||
{
|
||||
FireTargets( STRING(pev->target), pActivator, this, useType, value );
|
||||
}
|
||||
FireTargets(STRING(pev->target), pActivator, this, useType, value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void CBaseDelay :: SUB_UseTargetsEntMethod( void )
|
||||
{
|
||||
SUB_UseTargets(pev);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
QuakeEd only writes a single float for angles (bad idea), so up and down are
|
||||
just constant angles.
|
||||
*/
|
||||
void SetMovedir( entvars_t *pev )
|
||||
void SetMovedir(entvars_t *pev)
|
||||
{
|
||||
if (pev->angles == Vector(0, -1, 0))
|
||||
{
|
||||
|
@ -310,54 +224,47 @@ void SetMovedir( entvars_t *pev )
|
|||
UTIL_MakeVectors(pev->angles);
|
||||
pev->movedir = gpGlobals->v_forward;
|
||||
}
|
||||
|
||||
|
||||
pev->angles = g_vecZero;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CBaseDelay::DelayThink( void )
|
||||
void CBaseDelay::DelayThink(void)
|
||||
{
|
||||
CBaseEntity *pActivator = NULL;
|
||||
|
||||
if ( pev->owner != NULL ) // A player activated this on delay
|
||||
{
|
||||
pActivator = CBaseEntity::Instance( pev->owner );
|
||||
}
|
||||
// The use type is cached (and stashed) in pev->button
|
||||
SUB_UseTargets( pActivator, (USE_TYPE)pev->button, 0 );
|
||||
if (pev->owner)
|
||||
pActivator = CBaseEntity::Instance(pev->owner);
|
||||
|
||||
SUB_UseTargets(pActivator, (USE_TYPE)pev->button, 0);
|
||||
REMOVE_ENTITY(ENT(pev));
|
||||
}
|
||||
|
||||
|
||||
// Global Savedata for Toggle
|
||||
TYPEDESCRIPTION CBaseToggle::m_SaveData[] =
|
||||
TYPEDESCRIPTION CBaseToggle::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CBaseToggle, m_toggle_state, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flActivateFinished, FIELD_TIME ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flMoveDistance, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flWait, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flLip, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flTWidth, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flTLength, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_vecPosition1, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CBaseToggle, m_vecPosition2, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CBaseToggle, m_vecAngle1, FIELD_VECTOR ), // UNDONE: Position could go through transition, but also angle?
|
||||
DEFINE_FIELD( CBaseToggle, m_vecAngle2, FIELD_VECTOR ), // UNDONE: Position could go through transition, but also angle?
|
||||
DEFINE_FIELD( CBaseToggle, m_cTriggersLeft, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( CBaseToggle, m_flHeight, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CBaseToggle, m_hActivator, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( CBaseToggle, m_pfnCallWhenMoveDone, FIELD_FUNCTION ),
|
||||
DEFINE_FIELD( CBaseToggle, m_vecFinalDest, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CBaseToggle, m_vecFinalAngle, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( CBaseToggle, m_sMaster, FIELD_STRING),
|
||||
DEFINE_FIELD( CBaseToggle, m_bitsDamageInflict, FIELD_INTEGER ), // damage type inflicted
|
||||
DEFINE_FIELD(CBaseToggle, m_toggle_state, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CBaseToggle, m_flActivateFinished, FIELD_TIME),
|
||||
DEFINE_FIELD(CBaseToggle, m_flMoveDistance, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_flWait, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_flLip, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_flTWidth, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_flTLength, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecPosition1, FIELD_POSITION_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecPosition2, FIELD_POSITION_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecAngle1, FIELD_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecAngle2, FIELD_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_cTriggersLeft, FIELD_INTEGER),
|
||||
DEFINE_FIELD(CBaseToggle, m_flHeight, FIELD_FLOAT),
|
||||
DEFINE_FIELD(CBaseToggle, m_hActivator, FIELD_EHANDLE),
|
||||
DEFINE_FIELD(CBaseToggle, m_pfnCallWhenMoveDone, FIELD_FUNCTION),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecFinalDest, FIELD_POSITION_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_vecFinalAngle, FIELD_VECTOR),
|
||||
DEFINE_FIELD(CBaseToggle, m_sMaster, FIELD_STRING),
|
||||
DEFINE_FIELD(CBaseToggle, m_bitsDamageInflict, FIELD_INTEGER),
|
||||
};
|
||||
IMPLEMENT_SAVERESTORE( CBaseToggle, CBaseAnimating );
|
||||
|
||||
IMPLEMENT_SAVERESTORE(CBaseToggle, CBaseAnimating);
|
||||
|
||||
void CBaseToggle::KeyValue( KeyValueData *pkvd )
|
||||
void CBaseToggle::KeyValue(KeyValueData *pkvd)
|
||||
{
|
||||
if (FStrEq(pkvd->szKeyName, "lip"))
|
||||
{
|
||||
|
@ -380,61 +287,37 @@ void CBaseToggle::KeyValue( KeyValueData *pkvd )
|
|||
pkvd->fHandled = TRUE;
|
||||
}
|
||||
else
|
||||
CBaseDelay::KeyValue( pkvd );
|
||||
CBaseDelay::KeyValue(pkvd);
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
LinearMove
|
||||
|
||||
calculate pev->velocity and pev->nextthink to reach vecDest from
|
||||
pev->origin traveling at flSpeed
|
||||
===============
|
||||
*/
|
||||
void CBaseToggle :: LinearMove( Vector vecDest, float flSpeed )
|
||||
void CBaseToggle::LinearMove(Vector vecDest, float flSpeed)
|
||||
{
|
||||
ASSERTSZ(flSpeed != 0, "LinearMove: no speed is defined!");
|
||||
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "LinearMove: no post-move function defined");
|
||||
|
||||
m_vecFinalDest = vecDest;
|
||||
|
||||
// Already there?
|
||||
if (vecDest == pev->origin)
|
||||
{
|
||||
LinearMoveDone();
|
||||
return;
|
||||
}
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
|
||||
Vector vecDestDelta = vecDest - pev->origin;
|
||||
|
||||
// divide vector length by speed to get time to reach dest
|
||||
float flTravelTime = vecDestDelta.Length() / flSpeed;
|
||||
|
||||
// set nextthink to trigger a call to LinearMoveDone when dest is reached
|
||||
pev->nextthink = pev->ltime + flTravelTime;
|
||||
SetThink( LinearMoveDone );
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
SetThink(&CBaseToggle::LinearMoveDone);
|
||||
pev->velocity = vecDestDelta / flTravelTime;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
After moving, set origin to exact final destination, call "move done" function
|
||||
============
|
||||
*/
|
||||
void CBaseToggle :: LinearMoveDone( void )
|
||||
void CBaseToggle::LinearMoveDone(void)
|
||||
{
|
||||
UTIL_SetOrigin(pev, m_vecFinalDest);
|
||||
pev->velocity = g_vecZero;
|
||||
pev->nextthink = -1;
|
||||
if ( m_pfnCallWhenMoveDone )
|
||||
|
||||
if (m_pfnCallWhenMoveDone)
|
||||
(this->*m_pfnCallWhenMoveDone)();
|
||||
}
|
||||
|
||||
BOOL CBaseToggle :: IsLockedByMaster( void )
|
||||
BOOL CBaseToggle::IsLockedByMaster(void)
|
||||
{
|
||||
if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
|
||||
return TRUE;
|
||||
|
@ -442,118 +325,78 @@ BOOL CBaseToggle :: IsLockedByMaster( void )
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
AngularMove
|
||||
|
||||
calculate pev->velocity and pev->nextthink to reach vecDest from
|
||||
pev->origin traveling at flSpeed
|
||||
Just like LinearMove, but rotational.
|
||||
===============
|
||||
*/
|
||||
void CBaseToggle :: AngularMove( Vector vecDestAngle, float flSpeed )
|
||||
void CBaseToggle::AngularMove(Vector vecDestAngle, float flSpeed)
|
||||
{
|
||||
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
|
||||
// ASSERTSZ(m_pfnCallWhenMoveDone != NULL, "AngularMove: no post-move function defined");
|
||||
|
||||
m_vecFinalAngle = vecDestAngle;
|
||||
|
||||
// Already there?
|
||||
if (vecDestAngle == pev->angles)
|
||||
{
|
||||
AngularMoveDone();
|
||||
return;
|
||||
}
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
|
||||
Vector vecDestDelta = vecDestAngle - pev->angles;
|
||||
|
||||
// divide by speed to get time to reach dest
|
||||
float flTravelTime = vecDestDelta.Length() / flSpeed;
|
||||
|
||||
// set nextthink to trigger a call to AngularMoveDone when dest is reached
|
||||
pev->nextthink = pev->ltime + flTravelTime;
|
||||
SetThink( AngularMoveDone );
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
SetThink(&CBaseToggle::AngularMoveDone);
|
||||
pev->avelocity = vecDestDelta / flTravelTime;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
After rotating, set angle to exact final angle, call "move done" function
|
||||
============
|
||||
*/
|
||||
void CBaseToggle :: AngularMoveDone( void )
|
||||
void CBaseToggle::AngularMoveDone(void)
|
||||
{
|
||||
pev->angles = m_vecFinalAngle;
|
||||
pev->avelocity = g_vecZero;
|
||||
pev->nextthink = -1;
|
||||
if ( m_pfnCallWhenMoveDone )
|
||||
|
||||
if (m_pfnCallWhenMoveDone)
|
||||
(this->*m_pfnCallWhenMoveDone)();
|
||||
}
|
||||
|
||||
|
||||
float CBaseToggle :: AxisValue( int flags, const Vector &angles )
|
||||
float CBaseToggle::AxisValue(int flags, const Vector &angles)
|
||||
{
|
||||
if ( FBitSet(flags, SF_DOOR_ROTATE_Z) )
|
||||
if (FBitSet(flags, SF_DOOR_ROTATE_Z))
|
||||
return angles.z;
|
||||
if ( FBitSet(flags, SF_DOOR_ROTATE_X) )
|
||||
|
||||
if (FBitSet(flags, SF_DOOR_ROTATE_X))
|
||||
return angles.x;
|
||||
|
||||
return angles.y;
|
||||
}
|
||||
|
||||
|
||||
void CBaseToggle :: AxisDir( entvars_t *pev )
|
||||
void CBaseToggle::AxisDir(entvars_t *pev)
|
||||
{
|
||||
if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z) )
|
||||
pev->movedir = Vector ( 0, 0, 1 ); // around z-axis
|
||||
else if ( FBitSet(pev->spawnflags, SF_DOOR_ROTATE_X) )
|
||||
pev->movedir = Vector ( 1, 0, 0 ); // around x-axis
|
||||
if (FBitSet(pev->spawnflags, SF_DOOR_ROTATE_Z))
|
||||
pev->movedir = Vector(0, 0, 1);
|
||||
else if (FBitSet(pev->spawnflags, SF_DOOR_ROTATE_X))
|
||||
pev->movedir = Vector(1, 0, 0);
|
||||
else
|
||||
pev->movedir = Vector ( 0, 1, 0 ); // around y-axis
|
||||
pev->movedir = Vector(0, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
float CBaseToggle :: AxisDelta( int flags, const Vector &angle1, const Vector &angle2 )
|
||||
float CBaseToggle::AxisDelta(int flags, const Vector &angle1, const Vector &angle2)
|
||||
{
|
||||
if ( FBitSet (flags, SF_DOOR_ROTATE_Z) )
|
||||
if (FBitSet(flags, SF_DOOR_ROTATE_Z))
|
||||
return angle1.z - angle2.z;
|
||||
|
||||
if ( FBitSet (flags, SF_DOOR_ROTATE_X) )
|
||||
|
||||
if (FBitSet(flags, SF_DOOR_ROTATE_X))
|
||||
return angle1.x - angle2.x;
|
||||
|
||||
return angle1.y - angle2.y;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
FEntIsVisible
|
||||
|
||||
returns TRUE if the passed entity is visible to caller, even if not infront ()
|
||||
=============
|
||||
*/
|
||||
BOOL
|
||||
FEntIsVisible(
|
||||
entvars_t* pev,
|
||||
entvars_t* pevTarget)
|
||||
{
|
||||
BOOL FEntIsVisible(entvars_t *pev, entvars_t *pevTarget)
|
||||
{
|
||||
Vector vecSpot1 = pev->origin + pev->view_ofs;
|
||||
Vector vecSpot2 = pevTarget->origin + pevTarget->view_ofs;
|
||||
TraceResult tr;
|
||||
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine(vecSpot1, vecSpot2, ignore_monsters, ENT(pev), &tr);
|
||||
|
||||
|
||||
if (tr.fInOpen && tr.fInWater)
|
||||
return FALSE; // sight line crossed contents
|
||||
return FALSE;
|
||||
|
||||
if (tr.flFraction == 1)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,7 +12,6 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef TALKMONSTER_H
|
||||
#define TALKMONSTER_H
|
||||
|
||||
|
@ -20,7 +19,6 @@ class CTalkMonster : public CBaseMonster
|
|||
{
|
||||
public:
|
||||
static float g_talkWaitTime;
|
||||
|
||||
};
|
||||
|
||||
#endif //TALKMONSTER_H
|
||||
#endif
|
|
@ -1,630 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// teamplay_gamerules.cpp
|
||||
//
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
#include "gamerules.h"
|
||||
#include "teamplay_gamerules.h"
|
||||
#include "game.h"
|
||||
|
||||
static char team_names[MAX_TEAMS][MAX_TEAMNAME_LENGTH];
|
||||
static int team_scores[MAX_TEAMS];
|
||||
static int num_teams = 0;
|
||||
|
||||
extern DLL_GLOBAL BOOL g_fGameOver;
|
||||
|
||||
CHalfLifeTeamplay :: CHalfLifeTeamplay()
|
||||
{
|
||||
m_DisableDeathMessages = FALSE;
|
||||
m_DisableDeathPenalty = FALSE;
|
||||
|
||||
memset( team_names, 0, sizeof(team_names) );
|
||||
memset( team_scores, 0, sizeof(team_scores) );
|
||||
num_teams = 0;
|
||||
|
||||
// Copy over the team from the server config
|
||||
m_szTeamList[0] = 0;
|
||||
|
||||
// Cache this because the team code doesn't want to deal with changing this in the middle of a game
|
||||
strncpy( m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH );
|
||||
|
||||
edict_t *pWorld = INDEXENT(0);
|
||||
if ( pWorld && pWorld->v.team )
|
||||
{
|
||||
if ( teamoverride.value )
|
||||
{
|
||||
const char *pTeamList = STRING(pWorld->v.team);
|
||||
if ( pTeamList && strlen(pTeamList) )
|
||||
{
|
||||
strncpy( m_szTeamList, pTeamList, TEAMPLAY_TEAMLISTLENGTH );
|
||||
}
|
||||
}
|
||||
}
|
||||
// Has the server set teams
|
||||
if ( strlen( m_szTeamList ) )
|
||||
m_teamLimit = TRUE;
|
||||
else
|
||||
m_teamLimit = FALSE;
|
||||
|
||||
RecountTeams();
|
||||
}
|
||||
|
||||
extern cvar_t timeleft, fragsleft;
|
||||
|
||||
#include "voice_gamemgr.h"
|
||||
extern CVoiceGameMgr g_VoiceGameMgr;
|
||||
|
||||
void CHalfLifeTeamplay :: Think ( void )
|
||||
{
|
||||
///// Check game rules /////
|
||||
static int last_frags;
|
||||
static int last_time;
|
||||
|
||||
int frags_remaining = 0;
|
||||
int time_remaining = 0;
|
||||
|
||||
g_VoiceGameMgr.Update(gpGlobals->frametime);
|
||||
|
||||
if ( g_fGameOver ) // someone else quit the game already
|
||||
{
|
||||
CHalfLifeMultiplay::Think();
|
||||
return;
|
||||
}
|
||||
|
||||
float flTimeLimit = CVAR_GET_FLOAT("mp_timelimit") * 60;
|
||||
|
||||
time_remaining = (int)(flTimeLimit ? ( flTimeLimit - gpGlobals->time ) : 0);
|
||||
|
||||
if ( flTimeLimit != 0 && gpGlobals->time >= flTimeLimit )
|
||||
{
|
||||
GoToIntermission();
|
||||
return;
|
||||
}
|
||||
|
||||
float flFragLimit = fraglimit.value;
|
||||
if ( flFragLimit )
|
||||
{
|
||||
int bestfrags = 9999;
|
||||
int remain;
|
||||
|
||||
// check if any team is over the frag limit
|
||||
for ( int i = 0; i < num_teams; i++ )
|
||||
{
|
||||
if ( team_scores[i] >= flFragLimit )
|
||||
{
|
||||
GoToIntermission();
|
||||
return;
|
||||
}
|
||||
|
||||
remain = flFragLimit - team_scores[i];
|
||||
if ( remain < bestfrags )
|
||||
{
|
||||
bestfrags = remain;
|
||||
}
|
||||
}
|
||||
frags_remaining = bestfrags;
|
||||
}
|
||||
|
||||
// Updates when frags change
|
||||
if ( frags_remaining != last_frags )
|
||||
{
|
||||
g_engfuncs.pfnCvar_DirectSet( &fragsleft, UTIL_VarArgs( "%i", frags_remaining ) );
|
||||
}
|
||||
|
||||
// Updates once per second
|
||||
if ( timeleft.value != last_time )
|
||||
{
|
||||
g_engfuncs.pfnCvar_DirectSet( &timeleft, UTIL_VarArgs( "%i", time_remaining ) );
|
||||
}
|
||||
|
||||
last_frags = frags_remaining;
|
||||
last_time = time_remaining;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// ClientCommand
|
||||
// the user has typed a command which is unrecognized by everything else;
|
||||
// this check to see if the gamerules knows anything about the command
|
||||
//=========================================================
|
||||
BOOL CHalfLifeTeamplay :: ClientCommand( CBasePlayer *pPlayer, const char *pcmd )
|
||||
{
|
||||
if(g_VoiceGameMgr.ClientCommand(pPlayer, pcmd))
|
||||
return TRUE;
|
||||
|
||||
if ( FStrEq( pcmd, "menuselect" ) )
|
||||
{
|
||||
if ( CMD_ARGC() < 2 )
|
||||
return TRUE;
|
||||
|
||||
int slot = atoi( CMD_ARGV(1) );
|
||||
|
||||
// select the item from the current menu
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern int gmsgGameMode;
|
||||
extern int gmsgSayText;
|
||||
extern int gmsgTeamInfo;
|
||||
extern int gmsgTeamNames;
|
||||
extern int gmsgScoreInfo;
|
||||
|
||||
void CHalfLifeTeamplay :: UpdateGameMode( CBasePlayer *pPlayer )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() );
|
||||
WRITE_BYTE( 1 ); // game mode teamplay
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
|
||||
const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer )
|
||||
{
|
||||
// copy out the team name from the model
|
||||
char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" );
|
||||
strncpy( pPlayer->m_szTeamName, mdls, TEAM_NAME_LENGTH );
|
||||
|
||||
RecountTeams();
|
||||
|
||||
// update the current player of the team he is joining
|
||||
if ( pPlayer->m_szTeamName[0] == '\0' || !IsValidTeam( pPlayer->m_szTeamName ) || defaultteam.value )
|
||||
{
|
||||
const char *pTeamName = NULL;
|
||||
|
||||
if ( defaultteam.value )
|
||||
{
|
||||
pTeamName = team_names[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
pTeamName = TeamWithFewestPlayers();
|
||||
}
|
||||
strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH );
|
||||
}
|
||||
|
||||
return pPlayer->m_szTeamName;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// InitHUD
|
||||
//=========================================================
|
||||
void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer )
|
||||
{
|
||||
int i;
|
||||
|
||||
SetDefaultPlayerTeam( pPlayer );
|
||||
CHalfLifeMultiplay::InitHUD( pPlayer );
|
||||
|
||||
// Send down the team names
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgTeamNames, NULL, pPlayer->edict() );
|
||||
WRITE_BYTE( num_teams );
|
||||
for ( i = 0; i < num_teams; i++ )
|
||||
{
|
||||
WRITE_STRING( team_names[ i ] );
|
||||
}
|
||||
MESSAGE_END();
|
||||
|
||||
RecountTeams();
|
||||
|
||||
char *mdls = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model" );
|
||||
// update the current player of the team he is joining
|
||||
char text[1024];
|
||||
if ( !strcmp( mdls, pPlayer->m_szTeamName ) )
|
||||
{
|
||||
sprintf( text, "* you are on team \'%s\'\n", pPlayer->m_szTeamName );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( text, "* assigned to team %s\n", pPlayer->m_szTeamName );
|
||||
}
|
||||
|
||||
ChangePlayerTeam( pPlayer, pPlayer->m_szTeamName, FALSE, FALSE );
|
||||
UTIL_SayText( text, pPlayer );
|
||||
int clientIndex = pPlayer->entindex();
|
||||
RecountTeams();
|
||||
// update this player with all the other players team info
|
||||
// loop through all active players and send their team info to the new client
|
||||
for ( i = 1; i <= gpGlobals->maxClients; i++ )
|
||||
{
|
||||
CBaseEntity *plr = UTIL_PlayerByIndex( i );
|
||||
if ( plr && IsValidTeam( plr->TeamID() ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgTeamInfo, NULL, pPlayer->edict() );
|
||||
WRITE_BYTE( plr->entindex() );
|
||||
WRITE_STRING( plr->TeamID() );
|
||||
MESSAGE_END();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
|
||||
{
|
||||
int damageFlags = DMG_GENERIC;
|
||||
int clientIndex = pPlayer->entindex();
|
||||
|
||||
if ( !bGib )
|
||||
{
|
||||
damageFlags |= DMG_NEVERGIB;
|
||||
}
|
||||
else
|
||||
{
|
||||
damageFlags |= DMG_ALWAYSGIB;
|
||||
}
|
||||
|
||||
if ( bKill )
|
||||
{
|
||||
// kill the player, remove a death, and let them start on the new team
|
||||
m_DisableDeathMessages = TRUE;
|
||||
m_DisableDeathPenalty = TRUE;
|
||||
|
||||
entvars_t *pevWorld = VARS( INDEXENT(0) );
|
||||
pPlayer->TakeDamage( pevWorld, pevWorld, 900, damageFlags );
|
||||
|
||||
m_DisableDeathMessages = FALSE;
|
||||
m_DisableDeathPenalty = FALSE;
|
||||
}
|
||||
|
||||
// copy out the team name from the model
|
||||
strncpy( pPlayer->m_szTeamName, pTeamName, TEAM_NAME_LENGTH );
|
||||
|
||||
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
|
||||
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );
|
||||
|
||||
// notify everyone's HUD of the team change
|
||||
MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo );
|
||||
WRITE_BYTE( clientIndex );
|
||||
WRITE_STRING( pPlayer->m_szTeamName );
|
||||
MESSAGE_END();
|
||||
|
||||
MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo );
|
||||
WRITE_BYTE( clientIndex );
|
||||
WRITE_SHORT( pPlayer->pev->frags );
|
||||
WRITE_SHORT( pPlayer->m_iDeaths );
|
||||
WRITE_SHORT( 0 );
|
||||
WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 );
|
||||
MESSAGE_END();
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// ClientUserInfoChanged
|
||||
//=========================================================
|
||||
void CHalfLifeTeamplay::ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer )
|
||||
{
|
||||
char text[1024];
|
||||
|
||||
// prevent skin/color/model changes
|
||||
char *mdls = g_engfuncs.pfnInfoKeyValue( infobuffer, "model" );
|
||||
|
||||
if ( !stricmp( mdls, pPlayer->m_szTeamName ) )
|
||||
return;
|
||||
|
||||
if ( defaultteam.value )
|
||||
{
|
||||
int clientIndex = pPlayer->entindex();
|
||||
|
||||
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
|
||||
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "team", pPlayer->m_szTeamName );
|
||||
sprintf( text, "* Not allowed to change teams in this game!\n" );
|
||||
UTIL_SayText( text, pPlayer );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defaultteam.value || !IsValidTeam( mdls ) )
|
||||
{
|
||||
int clientIndex = pPlayer->entindex();
|
||||
|
||||
g_engfuncs.pfnSetClientKeyValue( clientIndex, g_engfuncs.pfnGetInfoKeyBuffer( pPlayer->edict() ), "model", pPlayer->m_szTeamName );
|
||||
sprintf( text, "* Can't change team to \'%s\'\n", mdls );
|
||||
UTIL_SayText( text, pPlayer );
|
||||
sprintf( text, "* Server limits teams to \'%s\'\n", m_szTeamList );
|
||||
UTIL_SayText( text, pPlayer );
|
||||
return;
|
||||
}
|
||||
// notify everyone of the team change
|
||||
sprintf( text, "* %s has changed to team \'%s\'\n", STRING(pPlayer->pev->netname), mdls );
|
||||
UTIL_SayTextAll( text, pPlayer );
|
||||
|
||||
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" joined team \"%s\"\n",
|
||||
STRING(pPlayer->pev->netname),
|
||||
GETPLAYERUSERID( pPlayer->edict() ),
|
||||
GETPLAYERAUTHID( pPlayer->edict() ),
|
||||
pPlayer->m_szTeamName,
|
||||
mdls );
|
||||
|
||||
ChangePlayerTeam( pPlayer, mdls, TRUE, TRUE );
|
||||
// recound stuff
|
||||
RecountTeams( TRUE );
|
||||
}
|
||||
|
||||
extern int gmsgDeathMsg;
|
||||
|
||||
//=========================================================
|
||||
// Deathnotice.
|
||||
//=========================================================
|
||||
void CHalfLifeTeamplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor )
|
||||
{
|
||||
if ( m_DisableDeathMessages )
|
||||
return;
|
||||
|
||||
if ( pVictim && pKiller && pKiller->flags & FL_CLIENT )
|
||||
{
|
||||
CBasePlayer *pk = (CBasePlayer*) CBaseEntity::Instance( pKiller );
|
||||
|
||||
if ( pk )
|
||||
{
|
||||
if ( (pk != pVictim) && (PlayerRelationship( pVictim, pk ) == GR_TEAMMATE) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ALL, gmsgDeathMsg );
|
||||
WRITE_BYTE( ENTINDEX(ENT(pKiller)) ); // the killer
|
||||
WRITE_BYTE( ENTINDEX(pVictim->edict()) ); // the victim
|
||||
WRITE_STRING( "teammate" ); // flag this as a teammate kill
|
||||
MESSAGE_END();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CHalfLifeMultiplay::DeathNotice( pVictim, pKiller, pevInflictor );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeTeamplay :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
|
||||
{
|
||||
if ( !m_DisableDeathPenalty )
|
||||
{
|
||||
CHalfLifeMultiplay::PlayerKilled( pVictim, pKiller, pInflictor );
|
||||
RecountTeams();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// IsTeamplay
|
||||
//=========================================================
|
||||
BOOL CHalfLifeTeamplay::IsTeamplay( void )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CHalfLifeTeamplay::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker )
|
||||
{
|
||||
if ( pAttacker && PlayerRelationship( pPlayer, pAttacker ) == GR_TEAMMATE )
|
||||
{
|
||||
// my teammate hit me.
|
||||
if ( (friendlyfire.value == 0) && (pAttacker != pPlayer) )
|
||||
{
|
||||
// friendly fire is off, and this hit came from someone other than myself, then don't get hurt
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return CHalfLifeMultiplay::FPlayerCanTakeDamage( pPlayer, pAttacker );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeTeamplay::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget )
|
||||
{
|
||||
// half life multiplay has a simple concept of Player Relationships.
|
||||
// you are either on another player's team, or you are not.
|
||||
if ( !pPlayer || !pTarget || !pTarget->IsPlayer() )
|
||||
return GR_NOTTEAMMATE;
|
||||
|
||||
if ( (*GetTeamID(pPlayer) != '\0') && (*GetTeamID(pTarget) != '\0') && !stricmp( GetTeamID(pPlayer), GetTeamID(pTarget) ) )
|
||||
{
|
||||
return GR_TEAMMATE;
|
||||
}
|
||||
|
||||
return GR_NOTTEAMMATE;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
BOOL CHalfLifeTeamplay::ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target )
|
||||
{
|
||||
// always autoaim, unless target is a teammate
|
||||
CBaseEntity *pTgt = CBaseEntity::Instance( target );
|
||||
if ( pTgt && pTgt->IsPlayer() )
|
||||
{
|
||||
if ( PlayerRelationship( pPlayer, pTgt ) == GR_TEAMMATE )
|
||||
return FALSE; // don't autoaim at teammates
|
||||
}
|
||||
|
||||
return CHalfLifeMultiplay::ShouldAutoAim( pPlayer, target );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
int CHalfLifeTeamplay::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled )
|
||||
{
|
||||
if ( !pKilled )
|
||||
return 0;
|
||||
|
||||
if ( !pAttacker )
|
||||
return 1;
|
||||
|
||||
if ( pAttacker != pKilled && PlayerRelationship( pAttacker, pKilled ) == GR_TEAMMATE )
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
const char *CHalfLifeTeamplay::GetTeamID( CBaseEntity *pEntity )
|
||||
{
|
||||
if ( pEntity == NULL || pEntity->pev == NULL )
|
||||
return "";
|
||||
|
||||
// return their team name
|
||||
return pEntity->TeamID();
|
||||
}
|
||||
|
||||
|
||||
int CHalfLifeTeamplay::GetTeamIndex( const char *pTeamName )
|
||||
{
|
||||
if ( pTeamName && *pTeamName != 0 )
|
||||
{
|
||||
// try to find existing team
|
||||
for ( int tm = 0; tm < num_teams; tm++ )
|
||||
{
|
||||
if ( !stricmp( team_names[tm], pTeamName ) )
|
||||
return tm;
|
||||
}
|
||||
}
|
||||
|
||||
return -1; // No match
|
||||
}
|
||||
|
||||
|
||||
const char *CHalfLifeTeamplay::GetIndexedTeamName( int teamIndex )
|
||||
{
|
||||
if ( teamIndex < 0 || teamIndex >= num_teams )
|
||||
return "";
|
||||
|
||||
return team_names[ teamIndex ];
|
||||
}
|
||||
|
||||
|
||||
BOOL CHalfLifeTeamplay::IsValidTeam( const char *pTeamName )
|
||||
{
|
||||
if ( !m_teamLimit ) // Any team is valid if the teamlist isn't set
|
||||
return TRUE;
|
||||
|
||||
return ( GetTeamIndex( pTeamName ) != -1 ) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
const char *CHalfLifeTeamplay::TeamWithFewestPlayers( void )
|
||||
{
|
||||
int i;
|
||||
int minPlayers = MAX_TEAMS;
|
||||
int teamCount[ MAX_TEAMS ];
|
||||
char *pTeamName = NULL;
|
||||
|
||||
memset( teamCount, 0, MAX_TEAMS * sizeof(int) );
|
||||
|
||||
// loop through all clients, count number of players on each team
|
||||
for ( i = 1; i <= gpGlobals->maxClients; i++ )
|
||||
{
|
||||
CBaseEntity *plr = UTIL_PlayerByIndex( i );
|
||||
|
||||
if ( plr )
|
||||
{
|
||||
int team = GetTeamIndex( plr->TeamID() );
|
||||
if ( team >= 0 )
|
||||
teamCount[team] ++;
|
||||
}
|
||||
}
|
||||
|
||||
// Find team with least players
|
||||
for ( i = 0; i < num_teams; i++ )
|
||||
{
|
||||
if ( teamCount[i] < minPlayers )
|
||||
{
|
||||
minPlayers = teamCount[i];
|
||||
pTeamName = team_names[i];
|
||||
}
|
||||
}
|
||||
|
||||
return pTeamName;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
//=========================================================
|
||||
void CHalfLifeTeamplay::RecountTeams( bool bResendInfo )
|
||||
{
|
||||
char *pName;
|
||||
char teamlist[TEAMPLAY_TEAMLISTLENGTH];
|
||||
|
||||
// loop through all teams, recounting everything
|
||||
num_teams = 0;
|
||||
|
||||
// Copy all of the teams from the teamlist
|
||||
// make a copy because strtok is destructive
|
||||
strcpy( teamlist, m_szTeamList );
|
||||
pName = teamlist;
|
||||
pName = strtok( pName, ";" );
|
||||
while ( pName != NULL && *pName )
|
||||
{
|
||||
if ( GetTeamIndex( pName ) < 0 )
|
||||
{
|
||||
strcpy( team_names[num_teams], pName );
|
||||
num_teams++;
|
||||
}
|
||||
pName = strtok( NULL, ";" );
|
||||
}
|
||||
|
||||
if ( num_teams < 2 )
|
||||
{
|
||||
num_teams = 0;
|
||||
m_teamLimit = FALSE;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
memset( team_scores, 0, sizeof(team_scores) );
|
||||
|
||||
// loop through all clients
|
||||
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
|
||||
{
|
||||
CBaseEntity *plr = UTIL_PlayerByIndex( i );
|
||||
|
||||
if ( plr )
|
||||
{
|
||||
const char *pTeamName = plr->TeamID();
|
||||
// try add to existing team
|
||||
int tm = GetTeamIndex( pTeamName );
|
||||
|
||||
if ( tm < 0 ) // no team match found
|
||||
{
|
||||
if ( !m_teamLimit )
|
||||
{
|
||||
// add to new team
|
||||
tm = num_teams;
|
||||
num_teams++;
|
||||
team_scores[tm] = 0;
|
||||
strncpy( team_names[tm], pTeamName, MAX_TEAMNAME_LENGTH );
|
||||
}
|
||||
}
|
||||
|
||||
if ( tm >= 0 )
|
||||
{
|
||||
team_scores[tm] += plr->pev->frags;
|
||||
}
|
||||
|
||||
if ( bResendInfo ) //Someone's info changed, let's send the team info again.
|
||||
{
|
||||
if ( plr && IsValidTeam( plr->TeamID() ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo, NULL );
|
||||
WRITE_BYTE( plr->entindex() );
|
||||
WRITE_STRING( plr->TeamID() );
|
||||
MESSAGE_END();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// teamplay_gamerules.h
|
||||
//
|
||||
|
||||
#define MAX_TEAMNAME_LENGTH 16
|
||||
#define MAX_TEAMS 32
|
||||
|
||||
#define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH
|
||||
|
||||
class CHalfLifeTeamplay : public CHalfLifeMultiplay
|
||||
{
|
||||
public:
|
||||
CHalfLifeTeamplay();
|
||||
|
||||
virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd );
|
||||
virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer );
|
||||
virtual BOOL IsTeamplay( void );
|
||||
virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker );
|
||||
virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
|
||||
virtual const char *GetTeamID( CBaseEntity *pEntity );
|
||||
virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target );
|
||||
virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled );
|
||||
virtual void InitHUD( CBasePlayer *pl );
|
||||
virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor );
|
||||
virtual const char *GetGameDescription( void ) { return "HL Teamplay"; } // this is the game name that gets seen in the server browser
|
||||
virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode
|
||||
virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor );
|
||||
virtual void Think ( void );
|
||||
virtual int GetTeamIndex( const char *pTeamName );
|
||||
virtual const char *GetIndexedTeamName( int teamIndex );
|
||||
virtual BOOL IsValidTeam( const char *pTeamName );
|
||||
const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer );
|
||||
virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib );
|
||||
|
||||
private:
|
||||
void RecountTeams( bool bResendInfo = FALSE );
|
||||
const char *TeamWithFewestPlayers( void );
|
||||
|
||||
BOOL m_DisableDeathMessages;
|
||||
BOOL m_DisableDeathPenalty;
|
||||
BOOL m_teamLimit; // This means the server set only some teams as valid
|
||||
char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH];
|
||||
};
|
169
dlls/trains.h
169
dlls/trains.h
|
@ -1,9 +1,9 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -15,113 +15,106 @@
|
|||
#ifndef TRAINS_H
|
||||
#define TRAINS_H
|
||||
|
||||
// Tracktrain spawn flags
|
||||
#define SF_TRACKTRAIN_NOPITCH 0x0001
|
||||
#define SF_TRACKTRAIN_NOCONTROL 0x0002
|
||||
#define SF_TRACKTRAIN_FORWARDONLY 0x0004
|
||||
#define SF_TRACKTRAIN_PASSABLE 0x0008
|
||||
#define SF_TRACKTRAIN_NOPITCH 0x0001
|
||||
#define SF_TRACKTRAIN_NOCONTROL 0x0002
|
||||
#define SF_TRACKTRAIN_FORWARDONLY 0x0004
|
||||
#define SF_TRACKTRAIN_PASSABLE 0x0008
|
||||
|
||||
// Spawnflag for CPathTrack
|
||||
#define SF_PATH_DISABLED 0x00000001
|
||||
#define SF_PATH_FIREONCE 0x00000002
|
||||
#define SF_PATH_ALTREVERSE 0x00000004
|
||||
#define SF_PATH_DISABLE_TRAIN 0x00000008
|
||||
#define SF_PATH_ALTERNATE 0x00008000
|
||||
#define SF_PATH_DISABLED 0x00000001
|
||||
#define SF_PATH_FIREONCE 0x00000002
|
||||
#define SF_PATH_ALTREVERSE 0x00000004
|
||||
#define SF_PATH_DISABLE_TRAIN 0x00000008
|
||||
#define SF_PATH_ALTERNATE 0x00008000
|
||||
|
||||
// Spawnflags of CPathCorner
|
||||
#define SF_CORNER_WAITFORTRIG 0x001
|
||||
#define SF_CORNER_TELEPORT 0x002
|
||||
#define SF_CORNER_FIREONCE 0x004
|
||||
#define SF_CORNER_WAITFORTRIG 0x001
|
||||
#define SF_CORNER_TELEPORT 0x002
|
||||
#define SF_CORNER_FIREONCE 0x004
|
||||
|
||||
//#define PATH_SPARKLE_DEBUG 1 // This makes a particle effect around path_track entities for debugging
|
||||
class CPathTrack : public CPointEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Activate( void );
|
||||
void KeyValue( KeyValueData* pkvd);
|
||||
|
||||
void SetPrevious( CPathTrack *pprevious );
|
||||
void Link( void );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void Spawn(void);
|
||||
void Activate(void);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
void SetPrevious(CPathTrack *pprevious);
|
||||
void Link(void);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
CPathTrack *ValidPath(CPathTrack *ppath, int testFlag);
|
||||
void Project(CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist);
|
||||
|
||||
CPathTrack *ValidPath( CPathTrack *ppath, int testFlag ); // Returns ppath if enabled, NULL otherwise
|
||||
void Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist );
|
||||
public:
|
||||
static CPathTrack *Instance(edict_t *pent);
|
||||
|
||||
static CPathTrack *Instance( edict_t *pent );
|
||||
public:
|
||||
CPathTrack *LookAhead(Vector *origin, float dist, int move);
|
||||
CPathTrack *Nearest(Vector origin);
|
||||
CPathTrack *GetNext(void);
|
||||
CPathTrack *GetPrevious(void);
|
||||
|
||||
CPathTrack *LookAhead( Vector *origin, float dist, int move );
|
||||
CPathTrack *Nearest( Vector origin );
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
CPathTrack *GetNext( void );
|
||||
CPathTrack *GetPrevious( void );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
#if PATH_SPARKLE_DEBUG
|
||||
void EXPORT Sparkle(void);
|
||||
#endif
|
||||
|
||||
float m_length;
|
||||
string_t m_altName;
|
||||
CPathTrack *m_pnext;
|
||||
CPathTrack *m_pprevious;
|
||||
CPathTrack *m_paltpath;
|
||||
public:
|
||||
float m_length;
|
||||
string_t m_altName;
|
||||
CPathTrack *m_pnext;
|
||||
CPathTrack *m_pprevious;
|
||||
CPathTrack *m_paltpath;
|
||||
};
|
||||
|
||||
|
||||
class CFuncTrackTrain : public CBaseEntity
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void Spawn(void);
|
||||
void Restart(void);
|
||||
void Precache(void);
|
||||
void Blocked(CBaseEntity *pOther);
|
||||
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
|
||||
void KeyValue(KeyValueData *pkvd);
|
||||
int Save(CSave &save);
|
||||
int Restore(CRestore &restore);
|
||||
int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; }
|
||||
void OverrideReset(void);
|
||||
|
||||
void Blocked( CBaseEntity *pOther );
|
||||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
||||
void KeyValue( KeyValueData* pkvd );
|
||||
public:
|
||||
void EXPORT Next(void);
|
||||
void EXPORT Find(void);
|
||||
void EXPORT NearestPath(void);
|
||||
void EXPORT DeadEnd(void);
|
||||
|
||||
void EXPORT Next( void );
|
||||
void EXPORT Find( void );
|
||||
void EXPORT NearestPath( void );
|
||||
void EXPORT DeadEnd( void );
|
||||
public:
|
||||
void NextThink(float thinkTime, BOOL alwaysThink);
|
||||
void SetTrack(CPathTrack *track) { m_ppath = track->Nearest(pev->origin); }
|
||||
void SetControls(entvars_t *pevControls);
|
||||
BOOL OnControls(entvars_t *pev);
|
||||
void StopSound(void);
|
||||
void UpdateSound(void);
|
||||
|
||||
void NextThink( float thinkTime, BOOL alwaysThink );
|
||||
public:
|
||||
static CFuncTrackTrain *Instance(edict_t *pent);
|
||||
|
||||
void SetTrack( CPathTrack *track ) { m_ppath = track->Nearest(pev->origin); }
|
||||
void SetControls( entvars_t *pevControls );
|
||||
BOOL OnControls( entvars_t *pev );
|
||||
public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
void StopSound ( void );
|
||||
void UpdateSound ( void );
|
||||
|
||||
static CFuncTrackTrain *Instance( edict_t *pent );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; }
|
||||
|
||||
virtual void OverrideReset( void );
|
||||
|
||||
CPathTrack *m_ppath;
|
||||
float m_length;
|
||||
float m_height;
|
||||
float m_speed;
|
||||
float m_dir;
|
||||
float m_startSpeed;
|
||||
Vector m_controlMins;
|
||||
Vector m_controlMaxs;
|
||||
int m_soundPlaying;
|
||||
int m_sounds;
|
||||
float m_flVolume;
|
||||
float m_flBank;
|
||||
float m_oldSpeed;
|
||||
public:
|
||||
CPathTrack *m_ppath;
|
||||
float m_length;
|
||||
float m_height;
|
||||
float m_speed;
|
||||
float m_dir;
|
||||
float m_startSpeed;
|
||||
Vector m_controlMins;
|
||||
Vector m_controlMaxs;
|
||||
int m_soundPlaying;
|
||||
int m_sounds;
|
||||
float m_flVolume;
|
||||
float m_flBank;
|
||||
float m_oldSpeed;
|
||||
|
||||
private:
|
||||
unsigned short m_usAdjustPitch;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
2691
dlls/triggers.cpp
2691
dlls/triggers.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,526 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "effects.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
#define TRIPMINE_PRIMARY_VOLUME 450
|
||||
|
||||
|
||||
|
||||
enum tripmine_e {
|
||||
TRIPMINE_IDLE1 = 0,
|
||||
TRIPMINE_IDLE2,
|
||||
TRIPMINE_ARM1,
|
||||
TRIPMINE_ARM2,
|
||||
TRIPMINE_FIDGET,
|
||||
TRIPMINE_HOLSTER,
|
||||
TRIPMINE_DRAW,
|
||||
TRIPMINE_WORLD,
|
||||
TRIPMINE_GROUND,
|
||||
};
|
||||
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
class CTripmineGrenade : public CGrenade
|
||||
{
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
|
||||
void EXPORT WarningThink( void );
|
||||
void EXPORT PowerupThink( void );
|
||||
void EXPORT BeamBreakThink( void );
|
||||
void EXPORT DelayDeathThink( void );
|
||||
void Killed( entvars_t *pevAttacker, int iGib );
|
||||
|
||||
void MakeBeam( void );
|
||||
void KillBeam( void );
|
||||
|
||||
float m_flPowerUp;
|
||||
Vector m_vecDir;
|
||||
Vector m_vecEnd;
|
||||
float m_flBeamLength;
|
||||
|
||||
EHANDLE m_hOwner;
|
||||
CBeam *m_pBeam;
|
||||
Vector m_posOwner;
|
||||
Vector m_angleOwner;
|
||||
edict_t *m_pRealOwner;// tracelines don't hit PEV->OWNER, which means a player couldn't detonate his own trip mine, so we store the owner here.
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( monster_tripmine, CTripmineGrenade );
|
||||
|
||||
TYPEDESCRIPTION CTripmineGrenade::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CTripmineGrenade, m_flPowerUp, FIELD_TIME ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_vecDir, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_vecEnd, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_flBeamLength, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_hOwner, FIELD_EHANDLE ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_pBeam, FIELD_CLASSPTR ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_posOwner, FIELD_POSITION_VECTOR ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_angleOwner, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( CTripmineGrenade, m_pRealOwner, FIELD_EDICT ),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE(CTripmineGrenade,CGrenade);
|
||||
|
||||
|
||||
void CTripmineGrenade :: Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
// motor
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->solid = SOLID_NOT;
|
||||
|
||||
SET_MODEL(ENT(pev), "models/v_tripmine.mdl");
|
||||
pev->frame = 0;
|
||||
pev->body = 3;
|
||||
pev->sequence = TRIPMINE_WORLD;
|
||||
ResetSequenceInfo( );
|
||||
pev->framerate = 0;
|
||||
|
||||
UTIL_SetSize(pev, Vector( -8, -8, -8), Vector(8, 8, 8));
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
if (pev->spawnflags & 1)
|
||||
{
|
||||
// power up quickly
|
||||
m_flPowerUp = gpGlobals->time + 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// power up in 2.5 seconds
|
||||
m_flPowerUp = gpGlobals->time + 2.5;
|
||||
}
|
||||
|
||||
SetThink( PowerupThink );
|
||||
pev->nextthink = gpGlobals->time + 0.2;
|
||||
|
||||
pev->takedamage = DAMAGE_YES;
|
||||
pev->dmg = gSkillData.plrDmgTripmine;
|
||||
pev->health = 1; // don't let die normally
|
||||
|
||||
if (pev->owner != NULL)
|
||||
{
|
||||
// play deploy sound
|
||||
EMIT_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM );
|
||||
EMIT_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav", 0.2, ATTN_NORM ); // chargeup
|
||||
|
||||
m_pRealOwner = pev->owner;// see CTripmineGrenade for why.
|
||||
}
|
||||
|
||||
UTIL_MakeAimVectors( pev->angles );
|
||||
|
||||
m_vecDir = gpGlobals->v_forward;
|
||||
m_vecEnd = pev->origin + m_vecDir * 2048;
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_tripmine.mdl");
|
||||
PRECACHE_SOUND("weapons/mine_deploy.wav");
|
||||
PRECACHE_SOUND("weapons/mine_activate.wav");
|
||||
PRECACHE_SOUND("weapons/mine_charge.wav");
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: WarningThink( void )
|
||||
{
|
||||
// play warning sound
|
||||
// EMIT_SOUND( ENT(pev), CHAN_VOICE, "buttons/Blip2.wav", 1.0, ATTN_NORM );
|
||||
|
||||
// set to power up
|
||||
SetThink( PowerupThink );
|
||||
pev->nextthink = gpGlobals->time + 1.0;
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: PowerupThink( void )
|
||||
{
|
||||
TraceResult tr;
|
||||
|
||||
if (m_hOwner == NULL)
|
||||
{
|
||||
// find an owner
|
||||
edict_t *oldowner = pev->owner;
|
||||
pev->owner = NULL;
|
||||
UTIL_TraceLine( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 32, dont_ignore_monsters, ENT( pev ), &tr );
|
||||
if (tr.fStartSolid || (oldowner && tr.pHit == oldowner))
|
||||
{
|
||||
pev->owner = oldowner;
|
||||
m_flPowerUp += 0.1;
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
return;
|
||||
}
|
||||
if (tr.flFraction < 1.0)
|
||||
{
|
||||
pev->owner = tr.pHit;
|
||||
m_hOwner = CBaseEntity::Instance( pev->owner );
|
||||
m_posOwner = m_hOwner->pev->origin;
|
||||
m_angleOwner = m_hOwner->pev->angles;
|
||||
}
|
||||
else
|
||||
{
|
||||
STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav" );
|
||||
STOP_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav" );
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
ALERT( at_console, "WARNING:Tripmine at %.0f, %.0f, %.0f removed\n", pev->origin.x, pev->origin.y, pev->origin.z );
|
||||
KillBeam();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (m_posOwner != m_hOwner->pev->origin || m_angleOwner != m_hOwner->pev->angles)
|
||||
{
|
||||
// disable
|
||||
STOP_SOUND( ENT(pev), CHAN_VOICE, "weapons/mine_deploy.wav" );
|
||||
STOP_SOUND( ENT(pev), CHAN_BODY, "weapons/mine_charge.wav" );
|
||||
CBaseEntity *pMine = Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles );
|
||||
pMine->pev->spawnflags |= SF_NORESPAWN;
|
||||
|
||||
SetThink( SUB_Remove );
|
||||
KillBeam();
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
return;
|
||||
}
|
||||
// ALERT( at_console, "%d %.0f %.0f %0.f\n", pev->owner, m_pOwner->pev->origin.x, m_pOwner->pev->origin.y, m_pOwner->pev->origin.z );
|
||||
|
||||
if (gpGlobals->time > m_flPowerUp)
|
||||
{
|
||||
// make solid
|
||||
pev->solid = SOLID_BBOX;
|
||||
UTIL_SetOrigin( pev, pev->origin );
|
||||
|
||||
MakeBeam( );
|
||||
|
||||
// play enabled sound
|
||||
EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 );
|
||||
}
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: KillBeam( void )
|
||||
{
|
||||
if ( m_pBeam )
|
||||
{
|
||||
UTIL_Remove( m_pBeam );
|
||||
m_pBeam = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: MakeBeam( void )
|
||||
{
|
||||
TraceResult tr;
|
||||
|
||||
// ALERT( at_console, "serverflags %f\n", gpGlobals->serverflags );
|
||||
|
||||
UTIL_TraceLine( pev->origin, m_vecEnd, dont_ignore_monsters, ENT( pev ), &tr );
|
||||
|
||||
m_flBeamLength = tr.flFraction;
|
||||
|
||||
// set to follow laser spot
|
||||
SetThink( BeamBreakThink );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
|
||||
Vector vecTmpEnd = pev->origin + m_vecDir * 2048 * m_flBeamLength;
|
||||
|
||||
m_pBeam = CBeam::BeamCreate( g_pModelNameLaser, 10 );
|
||||
m_pBeam->PointEntInit( vecTmpEnd, entindex() );
|
||||
m_pBeam->SetColor( 0, 214, 198 );
|
||||
m_pBeam->SetScrollRate( 255 );
|
||||
m_pBeam->SetBrightness( 64 );
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade :: BeamBreakThink( void )
|
||||
{
|
||||
BOOL bBlowup = 0;
|
||||
|
||||
TraceResult tr;
|
||||
|
||||
// HACKHACK Set simple box using this really nice global!
|
||||
gpGlobals->trace_flags = FTRACE_SIMPLEBOX;
|
||||
UTIL_TraceLine( pev->origin, m_vecEnd, dont_ignore_monsters, ENT( pev ), &tr );
|
||||
|
||||
// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );
|
||||
|
||||
// respawn detect.
|
||||
if ( !m_pBeam )
|
||||
{
|
||||
MakeBeam( );
|
||||
if ( tr.pHit )
|
||||
m_hOwner = CBaseEntity::Instance( tr.pHit ); // reset owner too
|
||||
}
|
||||
|
||||
if (fabs( m_flBeamLength - tr.flFraction ) > 0.001)
|
||||
{
|
||||
bBlowup = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_hOwner == NULL)
|
||||
bBlowup = 1;
|
||||
else if (m_posOwner != m_hOwner->pev->origin)
|
||||
bBlowup = 1;
|
||||
else if (m_angleOwner != m_hOwner->pev->angles)
|
||||
bBlowup = 1;
|
||||
}
|
||||
|
||||
if (bBlowup)
|
||||
{
|
||||
// a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill
|
||||
// so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant
|
||||
// that a player couldn't trigger his own tripmine. Now that the mine is exploding, it's safe the restore the owner so the
|
||||
// CGrenade code knows who the explosive really belongs to.
|
||||
pev->owner = m_pRealOwner;
|
||||
pev->health = 0;
|
||||
Killed( VARS( pev->owner ), GIB_NORMAL );
|
||||
return;
|
||||
}
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
int CTripmineGrenade :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
||||
{
|
||||
if (gpGlobals->time < m_flPowerUp && flDamage < pev->health)
|
||||
{
|
||||
// disable
|
||||
// Create( "weapon_tripmine", pev->origin + m_vecDir * 24, pev->angles );
|
||||
SetThink( SUB_Remove );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
KillBeam();
|
||||
return FALSE;
|
||||
}
|
||||
return CGrenade::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
||||
}
|
||||
|
||||
void CTripmineGrenade::Killed( entvars_t *pevAttacker, int iGib )
|
||||
{
|
||||
pev->takedamage = DAMAGE_NO;
|
||||
|
||||
if ( pevAttacker && ( pevAttacker->flags & FL_CLIENT ) )
|
||||
{
|
||||
// some client has destroyed this mine, he'll get credit for any kills
|
||||
pev->owner = ENT( pevAttacker );
|
||||
}
|
||||
|
||||
SetThink( DelayDeathThink );
|
||||
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1, 0.3 );
|
||||
|
||||
EMIT_SOUND( ENT(pev), CHAN_BODY, "common/null.wav", 0.5, ATTN_NORM ); // shut off chargeup
|
||||
}
|
||||
|
||||
|
||||
void CTripmineGrenade::DelayDeathThink( void )
|
||||
{
|
||||
KillBeam();
|
||||
TraceResult tr;
|
||||
UTIL_TraceLine ( pev->origin + m_vecDir * 8, pev->origin - m_vecDir * 64, dont_ignore_monsters, ENT(pev), & tr);
|
||||
|
||||
Explode( &tr, DMG_BLAST );
|
||||
}
|
||||
#endif
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_tripmine, CTripmine );
|
||||
|
||||
void CTripmine::Spawn( )
|
||||
{
|
||||
Precache( );
|
||||
m_iId = WEAPON_TRIPMINE;
|
||||
SET_MODEL(ENT(pev), "models/v_tripmine.mdl");
|
||||
pev->frame = 0;
|
||||
pev->body = 3;
|
||||
pev->sequence = TRIPMINE_GROUND;
|
||||
// ResetSequenceInfo( );
|
||||
pev->framerate = 0;
|
||||
|
||||
FallInit();// get ready to fall down
|
||||
|
||||
m_iDefaultAmmo = TRIPMINE_DEFAULT_GIVE;
|
||||
|
||||
#ifdef CLIENT_DLL
|
||||
if ( !bIsMultiplayer() )
|
||||
#else
|
||||
if ( !g_pGameRules->IsDeathmatch() )
|
||||
#endif
|
||||
{
|
||||
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 28) );
|
||||
}
|
||||
}
|
||||
|
||||
void CTripmine::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/v_tripmine.mdl");
|
||||
PRECACHE_MODEL ("models/p_tripmine.mdl");
|
||||
UTIL_PrecacheOther( "monster_tripmine" );
|
||||
|
||||
m_usTripFire = PRECACHE_EVENT( 1, "events/tripfire.sc" );
|
||||
}
|
||||
|
||||
int CTripmine::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "Trip Mine";
|
||||
p->iMaxAmmo1 = TRIPMINE_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = WEAPON_NOCLIP;
|
||||
p->iSlot = 4;
|
||||
p->iPosition = 2;
|
||||
p->iId = m_iId = WEAPON_TRIPMINE;
|
||||
p->iWeight = TRIPMINE_WEIGHT;
|
||||
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CTripmine::Deploy( )
|
||||
{
|
||||
//pev->body = 0;
|
||||
return DefaultDeploy( "models/v_tripmine.mdl", "models/p_tripmine.mdl", TRIPMINE_DRAW, "trip" );
|
||||
}
|
||||
|
||||
|
||||
void CTripmine::Holster( int skiplocal /* = 0 */ )
|
||||
{
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
||||
|
||||
if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType])
|
||||
{
|
||||
// out of mines
|
||||
m_pPlayer->pev->weapons &= ~(1<<WEAPON_TRIPMINE);
|
||||
SetThink( DestroyItem );
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
||||
SendWeaponAnim( TRIPMINE_HOLSTER );
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM);
|
||||
}
|
||||
|
||||
void CTripmine::PrimaryAttack( void )
|
||||
{
|
||||
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
return;
|
||||
|
||||
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
|
||||
TraceResult tr;
|
||||
|
||||
UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usTripFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 );
|
||||
|
||||
if (tr.flFraction < 1.0)
|
||||
{
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
|
||||
if ( pEntity && !(pEntity->pev->flags & FL_CONVEYOR) )
|
||||
{
|
||||
Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );
|
||||
|
||||
CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() );
|
||||
|
||||
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
|
||||
{
|
||||
// no more mines!
|
||||
RetireWeapon();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// ALERT( at_console, "no deploy\n" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
void CTripmine::WeaponIdle( void )
|
||||
{
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 )
|
||||
{
|
||||
SendWeaponAnim( TRIPMINE_DRAW );
|
||||
}
|
||||
else
|
||||
{
|
||||
RetireWeapon();
|
||||
return;
|
||||
}
|
||||
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||||
if (flRand <= 0.25)
|
||||
{
|
||||
iAnim = TRIPMINE_IDLE1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0;
|
||||
}
|
||||
else if (flRand <= 0.75)
|
||||
{
|
||||
iAnim = TRIPMINE_IDLE2;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 30.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = TRIPMINE_FIDGET;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 100.0 / 30.0;
|
||||
}
|
||||
|
||||
SendWeaponAnim( iAnim );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
2860
dlls/util.cpp
2860
dlls/util.cpp
File diff suppressed because it is too large
Load Diff
630
dlls/util.h
630
dlls/util.h
|
@ -1,9 +1,12 @@
|
|||
#ifndef util_h__
|
||||
#define util_h__
|
||||
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
|
@ -12,9 +15,7 @@
|
|||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
//
|
||||
// Misc utility code
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#ifndef ACTIVITY_H
|
||||
#include "activity.h"
|
||||
|
@ -23,149 +24,123 @@
|
|||
#ifndef ENGINECALLBACK_H
|
||||
#include "enginecallback.h"
|
||||
#endif
|
||||
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file
|
||||
|
||||
extern globalvars_t *gpGlobals;
|
||||
#include <tier1/UtlVector.h>
|
||||
|
||||
// Use this instead of ALLOC_STRING on constant strings
|
||||
#define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset)
|
||||
#define MAKE_STRING(str) ((int)str - (int)STRING(0))
|
||||
inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent);
|
||||
extern globalvars_t *gpGlobals;
|
||||
|
||||
inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName)
|
||||
#define STRING(offset) reinterpret_cast<const char *>(gpGlobals->pStringBase + (uintp)offset)
|
||||
#define MAKE_STRING(str) (reinterpret_cast<uintp>(str) - reinterpret_cast<uintp>(STRING(0)))
|
||||
|
||||
inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING(entStart, "classname", pszName);
|
||||
}
|
||||
}
|
||||
|
||||
inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName)
|
||||
inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING(entStart, "targetname", pszName);
|
||||
}
|
||||
}
|
||||
|
||||
// for doing a reverse lookup. Say you have a door, and want to find its button.
|
||||
inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName)
|
||||
inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName)
|
||||
{
|
||||
return FIND_ENTITY_BY_STRING(entStart, "target", pszName);
|
||||
}
|
||||
}
|
||||
|
||||
// Keeps clutter down a bit, when writing key-value pairs
|
||||
#define WRITEKEY_INT(pf, szKeyName, iKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%d\"\n", szKeyName, iKeyValue)
|
||||
#define WRITEKEY_FLOAT(pf, szKeyName, flKeyValue) \
|
||||
ENGINE_FPRINTF(pf, "\"%s\" \"%f\"\n", szKeyName, flKeyValue)
|
||||
#define WRITEKEY_STRING(pf, szKeyName, szKeyValue) \
|
||||
ENGINE_FPRINTF(pf, "\"%s\" \"%s\"\n", szKeyName, szKeyValue)
|
||||
#define WRITEKEY_VECTOR(pf, szKeyName, flX, flY, flZ) \
|
||||
ENGINE_FPRINTF(pf, "\"%s\" \"%f %f %f\"\n", szKeyName, flX, flY, flZ)
|
||||
#define WRITEKEY_FLOAT(pf, szKeyName, flKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%f\"\n", szKeyName, flKeyValue)
|
||||
#define WRITEKEY_STRING(pf, szKeyName, szKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%s\"\n", szKeyName, szKeyValue)
|
||||
#define WRITEKEY_VECTOR(pf, szKeyName, flX, flY, flZ) ENGINE_FPRINTF(pf, "\"%s\" \"%f %f %f\"\n", szKeyName, flX, flY, flZ)
|
||||
|
||||
// Keeps clutter down a bit, when using a float as a bit-vector
|
||||
#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
|
||||
#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
|
||||
|
||||
// Makes these more explicit, and easier to find
|
||||
#define FILE_GLOBAL static
|
||||
#define DLL_GLOBAL
|
||||
|
||||
// Until we figure out why "const" gives the compiler problems, we'll just have to use
|
||||
// this bogus "empty" define to mark things as constant.
|
||||
#define CONSTANT
|
||||
|
||||
// More explicit than "int"
|
||||
typedef int EOFFSET;
|
||||
|
||||
// In case it's not alread defined
|
||||
typedef int BOOL;
|
||||
|
||||
// In case this ever changes
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
// Keeps clutter down a bit, when declaring external entity/global method prototypes
|
||||
#define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName( void )
|
||||
#define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void)
|
||||
#define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName(void)
|
||||
#define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void)
|
||||
|
||||
// This is the glue that hooks .MAP entity class names to our CPP classes
|
||||
// The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress()
|
||||
// The function is used to intialize / allocate the object for the entity
|
||||
#ifdef _WIN32
|
||||
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \
|
||||
extern "C" _declspec( dllexport ) void mapClassName( entvars_t *pev ); \
|
||||
void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); }
|
||||
#define LINK_ENTITY_TO_CLASS(mapClassName, DLLClassName) \
|
||||
extern "C" _declspec(dllexport) void mapClassName(entvars_t *pev); \
|
||||
void mapClassName(entvars_t *pev) { GetClassPtr((DLLClassName *)pev); }
|
||||
#else
|
||||
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" void mapClassName( entvars_t *pev ); void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); }
|
||||
#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) extern "C" void mapClassName(entvars_t *pev); void mapClassName(entvars_t *pev) { GetClassPtr((DLLClassName *)pev); }
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Conversion among the three types of "entity", including identity-conversions.
|
||||
//
|
||||
#ifdef DEBUG
|
||||
extern edict_t *DBG_EntOfVars(const entvars_t *pev);
|
||||
inline edict_t *ENT(const entvars_t *pev) { return DBG_EntOfVars(pev); }
|
||||
inline edict_t *ENT(const entvars_t *pev) { return DBG_EntOfVars(pev); }
|
||||
#else
|
||||
inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; }
|
||||
inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; }
|
||||
#endif
|
||||
inline edict_t *ENT(edict_t *pent) { return pent; }
|
||||
inline edict_t *ENT(EOFFSET eoffset) { return (*g_engfuncs.pfnPEntityOfEntOffset)(eoffset); }
|
||||
inline EOFFSET OFFSET(EOFFSET eoffset) { return eoffset; }
|
||||
inline EOFFSET OFFSET(const edict_t *pent)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if ( !pent )
|
||||
ALERT( at_error, "Bad ent in OFFSET()\n" );
|
||||
inline edict_t *ENT(edict_t *pent) { return pent; }
|
||||
inline edict_t *ENT(EOFFSET eoffset) { return (*g_engfuncs.pfnPEntityOfEntOffset)(eoffset); }
|
||||
inline EOFFSET OFFSET(EOFFSET eoffset) { return eoffset; }
|
||||
inline EOFFSET OFFSET(const edict_t *pent)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (!pent)
|
||||
ALERT(at_error, "Bad ent in OFFSET()\n");
|
||||
#endif
|
||||
return (*g_engfuncs.pfnEntOffsetOfPEntity)(pent);
|
||||
return (*g_engfuncs.pfnEntOffsetOfPEntity)(pent);
|
||||
}
|
||||
inline EOFFSET OFFSET(entvars_t *pev)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if ( !pev )
|
||||
ALERT( at_error, "Bad pev in OFFSET()\n" );
|
||||
#endif
|
||||
return OFFSET(ENT(pev));
|
||||
}
|
||||
inline entvars_t *VARS(entvars_t *pev) { return pev; }
|
||||
|
||||
inline entvars_t *VARS(edict_t *pent)
|
||||
{
|
||||
if ( !pent )
|
||||
inline EOFFSET OFFSET(entvars_t *pev)
|
||||
{
|
||||
#if _DEBUG
|
||||
if (!pev)
|
||||
ALERT(at_error, "Bad pev in OFFSET()\n");
|
||||
#endif
|
||||
return OFFSET(ENT(pev));
|
||||
}
|
||||
inline entvars_t *VARS(entvars_t *pev) { return pev; }
|
||||
|
||||
inline entvars_t *VARS(edict_t *pent)
|
||||
{
|
||||
if (!pent)
|
||||
return NULL;
|
||||
|
||||
return &pent->v;
|
||||
return &pent->v;
|
||||
}
|
||||
|
||||
inline entvars_t* VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); }
|
||||
inline int ENTINDEX(edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); }
|
||||
inline edict_t* INDEXENT( int iEdictNum ) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); }
|
||||
inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ) {
|
||||
(*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ENT(ent));
|
||||
}
|
||||
inline entvars_t *VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); }
|
||||
inline int ENTINDEX(edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); }
|
||||
inline edict_t *INDEXENT(int iEdictNum) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); }
|
||||
|
||||
inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent) { (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ENT(ent)); }
|
||||
|
||||
// Testing the three types of "entity" for nullity
|
||||
#define eoNullEntity 0
|
||||
inline BOOL FNullEnt(EOFFSET eoffset) { return eoffset == 0; }
|
||||
inline BOOL FNullEnt(const edict_t* pent) { return pent == NULL || FNullEnt(OFFSET(pent)); }
|
||||
inline BOOL FNullEnt(entvars_t* pev) { return pev == NULL || FNullEnt(OFFSET(pev)); }
|
||||
inline BOOL FNullEnt(EOFFSET eoffset) { return eoffset == 0; }
|
||||
inline BOOL FNullEnt(const edict_t *pent) { return pent == NULL || FNullEnt(OFFSET(pent)); }
|
||||
inline BOOL FNullEnt(entvars_t *pev) { return pev == NULL || FNullEnt(OFFSET(pev)); }
|
||||
|
||||
// Testing strings for nullity
|
||||
#define iStringNull 0
|
||||
inline BOOL FStringNull(int iString) { return iString == iStringNull; }
|
||||
inline BOOL FStringNull(int iString) { return iString == iStringNull; }
|
||||
|
||||
#define cchMapNameMost 32
|
||||
|
||||
// Dot products for view cone checking
|
||||
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
|
||||
#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks
|
||||
#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks
|
||||
#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks
|
||||
#define VIEW_FIELD_FULL (float)-1
|
||||
#define VIEW_FIELD_WIDE (float)-0.7
|
||||
#define VIEW_FIELD_NARROW (float)0.7
|
||||
#define VIEW_FIELD_ULTRA_NARROW (float)0.9
|
||||
|
||||
// All monsters need this data
|
||||
#define DONT_BLEED -1
|
||||
#define BLOOD_COLOR_RED (BYTE)247
|
||||
#define BLOOD_COLOR_YELLOW (BYTE)195
|
||||
#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW
|
||||
#define DONT_BLEED -1
|
||||
#define BLOOD_COLOR_RED (BYTE)247
|
||||
#define BLOOD_COLOR_YELLOW (BYTE)195
|
||||
#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW
|
||||
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
|
||||
MONSTERSTATE_NONE = 0,
|
||||
MONSTERSTATE_IDLE,
|
||||
MONSTERSTATE_COMBAT,
|
||||
|
@ -175,292 +150,241 @@ typedef enum
|
|||
MONSTERSTATE_SCRIPT,
|
||||
MONSTERSTATE_PLAYDEAD,
|
||||
MONSTERSTATE_DEAD
|
||||
}
|
||||
MONSTERSTATE;
|
||||
|
||||
} MONSTERSTATE;
|
||||
|
||||
|
||||
|
||||
// Things that toggle (buttons/triggers/doors) need this
|
||||
typedef enum
|
||||
{
|
||||
{
|
||||
TS_AT_TOP,
|
||||
TS_AT_BOTTOM,
|
||||
TS_GOING_UP,
|
||||
TS_GOING_DOWN
|
||||
} TOGGLE_STATE;
|
||||
}
|
||||
TOGGLE_STATE;
|
||||
|
||||
// Misc useful
|
||||
inline BOOL FStrEq(const char*sz1, const char*sz2)
|
||||
{ return (strcmp(sz1, sz2) == 0); }
|
||||
inline BOOL FClassnameIs(edict_t* pent, const char* szClassname)
|
||||
{ return FStrEq(STRING(VARS(pent)->classname), szClassname); }
|
||||
inline BOOL FClassnameIs(entvars_t* pev, const char* szClassname)
|
||||
{ return FStrEq(STRING(pev->classname), szClassname); }
|
||||
inline BOOL FStrEq(const char *sz1, const char *sz2) { return (!strcmp(sz1, sz2)); }
|
||||
inline BOOL FClassnameIs(edict_t *pent, const char *szClassname) { return FStrEq(STRING(VARS(pent)->classname), szClassname); }
|
||||
inline BOOL FClassnameIs(entvars_t *pev, const char *szClassname) { return FStrEq(STRING(pev->classname), szClassname); }
|
||||
|
||||
class CBaseEntity;
|
||||
|
||||
// Misc. Prototypes
|
||||
extern void UTIL_SetSize (entvars_t* pev, const Vector &vecMin, const Vector &vecMax);
|
||||
extern float UTIL_VecToYaw (const Vector &vec);
|
||||
extern Vector UTIL_VecToAngles (const Vector &vec);
|
||||
extern float UTIL_AngleMod (float a);
|
||||
extern float UTIL_AngleDiff ( float destAngle, float srcAngle );
|
||||
extern void UTIL_SetSize(entvars_t *pev, const Vector &vecMin, const Vector &vecMax);
|
||||
extern float UTIL_VecToYaw(const Vector &vec);
|
||||
extern Vector UTIL_VecToAngles(const Vector &vec);
|
||||
extern float UTIL_AngleMod(float a);
|
||||
extern float UTIL_AngleDiff(float destAngle, float srcAngle);
|
||||
|
||||
extern CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius);
|
||||
extern CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue );
|
||||
extern CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName );
|
||||
extern CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName );
|
||||
extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, float flRadius );
|
||||
extern CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius);
|
||||
extern CBaseEntity *UTIL_FindEntityByString_Old(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
|
||||
extern CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
|
||||
extern CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName);
|
||||
extern CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName);
|
||||
extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, float flRadius);
|
||||
extern CBaseEntity *UTIL_PlayerByIndex(int playerIndex);
|
||||
|
||||
// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected
|
||||
// otherwise returns NULL
|
||||
// Index is 1 based
|
||||
extern CBaseEntity *UTIL_PlayerByIndex( int playerIndex );
|
||||
#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent)
|
||||
|
||||
#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent)
|
||||
extern void UTIL_MakeVectors (const Vector &vecAngles);
|
||||
extern void UTIL_MakeVectors(const Vector &vecAngles);
|
||||
extern int UTIL_MonstersInSphere(CBaseEntity **pList, int listMax, const Vector ¢er, float radius);
|
||||
extern int UTIL_EntitiesInBox(CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask);
|
||||
inline void UTIL_MakeVectorsPrivate(const Vector &vecAngles, float *p_vForward, float *p_vRight, float *p_vUp) { g_engfuncs.pfnAngleVectors(vecAngles, p_vForward, p_vRight, p_vUp); }
|
||||
extern void UTIL_MakeAimVectors(const Vector &vecAngles);
|
||||
extern void UTIL_MakeInvVectors(const Vector &vec, globalvars_t *pgv);
|
||||
|
||||
// Pass in an array of pointers and an array size, it fills the array and returns the number inserted
|
||||
extern int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢er, float radius );
|
||||
extern int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask );
|
||||
extern void UTIL_SetOrigin(entvars_t *pev, const Vector &vecOrigin);
|
||||
extern void UTIL_EmitAmbientSound(edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch);
|
||||
extern void UTIL_ParticleEffect(const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount);
|
||||
extern void UTIL_ScreenShake(const Vector ¢er, float amplitude, float frequency, float duration, float radius);
|
||||
extern void UTIL_ScreenShakeAll(const Vector ¢er, float amplitude, float frequency, float duration);
|
||||
extern void UTIL_ShowMessageArgs(const char *pString, CBaseEntity *pPlayer, CUtlVector<char *> *args, bool isHint);
|
||||
extern void UTIL_ShowMessage(const char *pString, CBaseEntity *pPlayer);
|
||||
extern void UTIL_ShowMessageAll(const char *pString);
|
||||
extern void UTIL_ScreenFadeAll(const Vector &color, float fadeTime, float holdTime, int alpha, int flags);
|
||||
extern void UTIL_ScreenFade(CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags);
|
||||
|
||||
inline void UTIL_MakeVectorsPrivate( const Vector &vecAngles, float *p_vForward, float *p_vRight, float *p_vUp )
|
||||
typedef enum { ignore_monsters = 1, dont_ignore_monsters = 0, missile = 2 } IGNORE_MONSTERS;
|
||||
typedef enum { ignore_glass = 1, dont_ignore_glass = 0 } IGNORE_GLASS;
|
||||
extern void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr);
|
||||
extern void UTIL_TraceLine(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr);
|
||||
typedef enum { point_hull = 0, human_hull = 1, large_hull = 2, head_hull = 3 } HULL_TYPE;
|
||||
extern void UTIL_TraceHull(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr);
|
||||
extern TraceResult UTIL_GetGlobalTrace(void);
|
||||
extern void UTIL_TraceModel(const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr);
|
||||
extern Vector UTIL_GetAimVector(edict_t *pent, float flSpeed);
|
||||
extern int UTIL_PointContents(const Vector &vec);
|
||||
|
||||
extern int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator);
|
||||
extern void UTIL_BloodStream(const Vector &origin, const Vector &direction, int color, int amount);
|
||||
extern void UTIL_BloodDrips(const Vector &origin, const Vector &direction, int color, int amount);
|
||||
extern Vector UTIL_RandomBloodVector(void);
|
||||
extern BOOL UTIL_ShouldShowBlood(int bloodColor);
|
||||
extern void UTIL_BloodDecalTrace(TraceResult *pTrace, int bloodColor);
|
||||
extern void UTIL_DecalTrace(TraceResult *pTrace, int decalNumber);
|
||||
extern void UTIL_PlayerDecalTrace(TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom);
|
||||
extern void UTIL_GunshotDecalTrace(TraceResult *pTrace, int decalNumber);
|
||||
extern void UTIL_Sparks(const Vector &position);
|
||||
extern void UTIL_Ricochet(const Vector &position, float scale);
|
||||
extern void UTIL_StringToVector(float *pVector, const char *pString);
|
||||
extern void UTIL_StringToIntArray(int *pVector, int count, const char *pString);
|
||||
extern Vector UTIL_ClampVectorToBox(const Vector &input, const Vector &clampSize);
|
||||
extern float UTIL_Approach(float target, float value, float speed);
|
||||
extern float UTIL_ApproachAngle(float target, float value, float speed);
|
||||
extern float UTIL_AngleDistance(float next, float cur);
|
||||
extern char *UTIL_VarArgs(char *format, ...);
|
||||
extern void UTIL_Remove(CBaseEntity *pEntity);
|
||||
extern BOOL UTIL_IsValidEntity(edict_t *pent);
|
||||
extern BOOL UTIL_TeamsMatch(const char *pTeamName1, const char *pTeamName2);
|
||||
extern float UTIL_SplineFraction(float value, float scale);
|
||||
extern float UTIL_WaterLevel(const Vector &position, float minz, float maxz);
|
||||
extern void UTIL_Bubbles(Vector mins, Vector maxs, int count);
|
||||
extern void UTIL_BubbleTrail(Vector from, Vector to, int count);
|
||||
extern void UTIL_PrecacheOther(const char *szClassname);
|
||||
extern void UTIL_ClientPrintAll(int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL);
|
||||
|
||||
inline void UTIL_CenterPrintAll(const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL)
|
||||
{
|
||||
g_engfuncs.pfnAngleVectors( vecAngles, p_vForward, p_vRight, p_vUp );
|
||||
}
|
||||
|
||||
extern void UTIL_MakeAimVectors ( const Vector &vecAngles ); // like MakeVectors, but assumes pitch isn't inverted
|
||||
extern void UTIL_MakeInvVectors ( const Vector &vec, globalvars_t *pgv );
|
||||
|
||||
extern void UTIL_SetOrigin ( entvars_t* pev, const Vector &vecOrigin );
|
||||
extern void UTIL_EmitAmbientSound ( edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch );
|
||||
extern void UTIL_ParticleEffect ( const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount );
|
||||
extern void UTIL_ScreenShake ( const Vector ¢er, float amplitude, float frequency, float duration, float radius );
|
||||
extern void UTIL_ScreenShakeAll ( const Vector ¢er, float amplitude, float frequency, float duration );
|
||||
extern void UTIL_ShowMessage ( const char *pString, CBaseEntity *pPlayer );
|
||||
extern void UTIL_ShowMessageAll ( const char *pString );
|
||||
extern void UTIL_ScreenFadeAll ( const Vector &color, float fadeTime, float holdTime, int alpha, int flags );
|
||||
extern void UTIL_ScreenFade ( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags );
|
||||
|
||||
typedef enum { ignore_monsters=1, dont_ignore_monsters=0, missile=2 } IGNORE_MONSTERS;
|
||||
typedef enum { ignore_glass=1, dont_ignore_glass=0 } IGNORE_GLASS;
|
||||
extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr);
|
||||
extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr);
|
||||
enum { point_hull=0, human_hull=1, large_hull=2, head_hull=3 };
|
||||
extern void UTIL_TraceHull (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr);
|
||||
extern TraceResult UTIL_GetGlobalTrace (void);
|
||||
extern void UTIL_TraceModel (const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr);
|
||||
extern Vector UTIL_GetAimVector (edict_t* pent, float flSpeed);
|
||||
extern int UTIL_PointContents (const Vector &vec);
|
||||
|
||||
extern int UTIL_IsMasterTriggered (string_t sMaster, CBaseEntity *pActivator);
|
||||
extern void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, int amount );
|
||||
extern void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount );
|
||||
extern Vector UTIL_RandomBloodVector( void );
|
||||
extern BOOL UTIL_ShouldShowBlood( int bloodColor );
|
||||
extern void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor );
|
||||
extern void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber );
|
||||
extern void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom );
|
||||
extern void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber );
|
||||
extern void UTIL_Sparks( const Vector &position );
|
||||
extern void UTIL_Ricochet( const Vector &position, float scale );
|
||||
extern void UTIL_StringToVector( float *pVector, const char *pString );
|
||||
extern void UTIL_StringToIntArray( int *pVector, int count, const char *pString );
|
||||
extern Vector UTIL_ClampVectorToBox( const Vector &input, const Vector &clampSize );
|
||||
extern float UTIL_Approach( float target, float value, float speed );
|
||||
extern float UTIL_ApproachAngle( float target, float value, float speed );
|
||||
extern float UTIL_AngleDistance( float next, float cur );
|
||||
|
||||
extern char *UTIL_VarArgs( char *format, ... );
|
||||
extern void UTIL_Remove( CBaseEntity *pEntity );
|
||||
extern BOOL UTIL_IsValidEntity( edict_t *pent );
|
||||
extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 );
|
||||
|
||||
// Use for ease-in, ease-out style interpolation (accel/decel)
|
||||
extern float UTIL_SplineFraction( float value, float scale );
|
||||
|
||||
// Search for water transition along a vertical line
|
||||
extern float UTIL_WaterLevel( const Vector &position, float minz, float maxz );
|
||||
extern void UTIL_Bubbles( Vector mins, Vector maxs, int count );
|
||||
extern void UTIL_BubbleTrail( Vector from, Vector to, int count );
|
||||
|
||||
// allows precacheing of other entities
|
||||
extern void UTIL_PrecacheOther( const char *szClassname );
|
||||
|
||||
// prints a message to each client
|
||||
extern void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL );
|
||||
inline void UTIL_CenterPrintAll( const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL )
|
||||
{
|
||||
UTIL_ClientPrintAll( HUD_PRINTCENTER, msg_name, param1, param2, param3, param4 );
|
||||
UTIL_ClientPrintAll(HUD_PRINTCENTER, msg_name, param1, param2, param3, param4);
|
||||
}
|
||||
|
||||
class CBasePlayerItem;
|
||||
class CBasePlayer;
|
||||
extern BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon );
|
||||
|
||||
// prints messages through the HUD
|
||||
extern void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL );
|
||||
|
||||
// prints a message to the HUD say (chat)
|
||||
extern void UTIL_SayText( const char *pText, CBaseEntity *pEntity );
|
||||
extern void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity );
|
||||
|
||||
extern BOOL UTIL_GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon);
|
||||
extern void ClientPrint(entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL);
|
||||
extern void UTIL_SayText(const char *pText, CBaseEntity *pEntity);
|
||||
extern void UTIL_SayTextAll(const char *pText, CBaseEntity *pEntity);
|
||||
|
||||
typedef struct hudtextparms_s
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
int effect;
|
||||
byte r1, g1, b1, a1;
|
||||
byte r2, g2, b2, a2;
|
||||
float fadeinTime;
|
||||
float fadeoutTime;
|
||||
float holdTime;
|
||||
float fxTime;
|
||||
int channel;
|
||||
} hudtextparms_t;
|
||||
float x;
|
||||
float y;
|
||||
int effect;
|
||||
byte r1, g1, b1, a1;
|
||||
byte r2, g2, b2, a2;
|
||||
float fadeinTime;
|
||||
float fadeoutTime;
|
||||
float holdTime;
|
||||
float fxTime;
|
||||
int channel;
|
||||
}
|
||||
hudtextparms_t;
|
||||
|
||||
// prints as transparent 'title' to the HUD
|
||||
extern void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage );
|
||||
extern void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage );
|
||||
extern void UTIL_HudMessageAll(const hudtextparms_t &textparms, const char *pMessage);
|
||||
extern void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage);
|
||||
|
||||
// for handy use with ClientPrint params
|
||||
extern char *UTIL_dtos1( int d );
|
||||
extern char *UTIL_dtos2( int d );
|
||||
extern char *UTIL_dtos3( int d );
|
||||
extern char *UTIL_dtos4( int d );
|
||||
extern char *UTIL_dtos1(int d);
|
||||
extern char *UTIL_dtos2(int d);
|
||||
extern char *UTIL_dtos3(int d);
|
||||
extern char *UTIL_dtos4(int d);
|
||||
extern void UTIL_LogPrintf(char *fmt, ...);
|
||||
extern float UTIL_DotPoints(const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir);
|
||||
extern void UTIL_StripToken(const char *pKey, char *pDest);
|
||||
extern char UTIL_TextureHit(TraceResult *ptrHit, Vector vecSrc, Vector vecEnd);
|
||||
extern bool UTIL_IsGame(const char *gameName);
|
||||
extern float UTIL_GetPlayerGaitYaw(int playerIndex);
|
||||
extern int UTIL_HumansInGame(bool ignoreSpectators);
|
||||
|
||||
// Writes message to console with timestamp and FragLog header.
|
||||
extern void UTIL_LogPrintf( char *fmt, ... );
|
||||
extern void SetMovedir(entvars_t *pev);
|
||||
extern Vector VecBModelOrigin(entvars_t *pevBModel);
|
||||
extern int BuildChangeList(LEVELLIST *pLevelList, int maxList);
|
||||
|
||||
// Sorta like FInViewCone, but for nonmonsters.
|
||||
extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir );
|
||||
|
||||
extern void UTIL_StripToken( const char *pKey, char *pDest );// for redundant keynames
|
||||
|
||||
// Misc functions
|
||||
extern void SetMovedir(entvars_t* pev);
|
||||
extern Vector VecBModelOrigin( entvars_t* pevBModel );
|
||||
extern int BuildChangeList( LEVELLIST *pLevelList, int maxList );
|
||||
|
||||
//
|
||||
// How did I ever live without ASSERT?
|
||||
//
|
||||
#ifdef DEBUG
|
||||
void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage);
|
||||
#define ASSERT(f) DBG_AssertFunction(f, #f, __FILE__, __LINE__, NULL)
|
||||
#ifdef DEBUG
|
||||
void DBG_AssertFunction(BOOL fExpr, const char *szExpr, const char *szFile, int szLine, const char *szMessage);
|
||||
#define ASSERT(f) DBG_AssertFunction(f, #f, __FILE__, __LINE__, NULL)
|
||||
#define ASSERTSZ(f, sz) DBG_AssertFunction(f, #f, __FILE__, __LINE__, sz)
|
||||
#else // !DEBUG
|
||||
#else
|
||||
#define ASSERT(f)
|
||||
#define ASSERTSZ(f, sz)
|
||||
#endif // !DEBUG
|
||||
|
||||
#endif
|
||||
|
||||
extern DLL_GLOBAL const Vector g_vecZero;
|
||||
|
||||
//
|
||||
// Constants that were used only by QC (maybe not used at all now)
|
||||
//
|
||||
// Un-comment only as needed
|
||||
//
|
||||
#define LANGUAGE_ENGLISH 0
|
||||
#define LANGUAGE_GERMAN 1
|
||||
#define LANGUAGE_FRENCH 2
|
||||
#define LANGUAGE_BRITISH 3
|
||||
#define LANGUAGE_ENGLISH 0
|
||||
#define LANGUAGE_GERMAN 1
|
||||
#define LANGUAGE_FRENCH 2
|
||||
#define LANGUAGE_BRITISH 3
|
||||
|
||||
extern DLL_GLOBAL int g_Language;
|
||||
extern DLL_GLOBAL int g_Language;
|
||||
|
||||
#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation
|
||||
#define AMBIENT_SOUND_EVERYWHERE 1
|
||||
#define AMBIENT_SOUND_SMALLRADIUS 2
|
||||
#define AMBIENT_SOUND_MEDIUMRADIUS 4
|
||||
#define AMBIENT_SOUND_LARGERADIUS 8
|
||||
#define AMBIENT_SOUND_START_SILENT 16
|
||||
#define AMBIENT_SOUND_NOT_LOOPING 32
|
||||
#define AMBIENT_SOUND_STATIC 0
|
||||
#define AMBIENT_SOUND_EVERYWHERE 1
|
||||
#define AMBIENT_SOUND_SMALLRADIUS 2
|
||||
#define AMBIENT_SOUND_MEDIUMRADIUS 4
|
||||
#define AMBIENT_SOUND_LARGERADIUS 8
|
||||
#define AMBIENT_SOUND_START_SILENT 16
|
||||
#define AMBIENT_SOUND_NOT_LOOPING 32
|
||||
|
||||
#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements
|
||||
#define SPEAKER_START_SILENT 1
|
||||
|
||||
#define SND_SPAWNING (1<<8) // duplicated in protocol.h we're spawing, used in some cases for ambients
|
||||
#define SND_STOP (1<<5) // duplicated in protocol.h stop sound
|
||||
#define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol
|
||||
#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch
|
||||
#define SND_SPAWNING (1<<8)
|
||||
#define SND_STOP (1<<5)
|
||||
#define SND_CHANGE_VOL (1<<6)
|
||||
#define SND_CHANGE_PITCH (1<<7)
|
||||
|
||||
#define LFO_SQUARE 1
|
||||
#define LFO_TRIANGLE 2
|
||||
#define LFO_RANDOM 3
|
||||
#define LFO_SQUARE 1
|
||||
#define LFO_TRIANGLE 2
|
||||
#define LFO_RANDOM 3
|
||||
|
||||
// func_rotating
|
||||
#define SF_BRUSH_ROTATE_Y_AXIS 0
|
||||
#define SF_BRUSH_ROTATE_INSTANT 1
|
||||
#define SF_BRUSH_ROTATE_BACKWARDS 2
|
||||
#define SF_BRUSH_ROTATE_Z_AXIS 4
|
||||
#define SF_BRUSH_ROTATE_X_AXIS 8
|
||||
#define SF_PENDULUM_AUTO_RETURN 16
|
||||
#define SF_PENDULUM_PASSABLE 32
|
||||
#define SF_BRUSH_ROTATE_Y_AXIS 0
|
||||
#define SF_BRUSH_ROTATE_INSTANT 1
|
||||
#define SF_BRUSH_ROTATE_BACKWARDS 2
|
||||
#define SF_BRUSH_ROTATE_Z_AXIS 4
|
||||
#define SF_BRUSH_ROTATE_X_AXIS 8
|
||||
#define SF_PENDULUM_AUTO_RETURN 16
|
||||
#define SF_PENDULUM_PASSABLE 32
|
||||
|
||||
|
||||
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
|
||||
#define SF_BRUSH_ROTATE_SMALLRADIUS 128
|
||||
#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256
|
||||
#define SF_BRUSH_ROTATE_LARGERADIUS 512
|
||||
|
||||
#define PUSH_BLOCK_ONLY_X 1
|
||||
#define PUSH_BLOCK_ONLY_Y 2
|
||||
#define PUSH_BLOCK_ONLY_X 1
|
||||
#define PUSH_BLOCK_ONLY_Y 2
|
||||
|
||||
#define VEC_HULL_MIN Vector(-16, -16, -36)
|
||||
#define VEC_HULL_MAX Vector( 16, 16, 36)
|
||||
#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 )
|
||||
#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 )
|
||||
#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 )
|
||||
#define VEC_HULL_MIN Vector(-16, -16, -36)
|
||||
#define VEC_HULL_MAX Vector(16, 16, 36)
|
||||
#define VEC_HUMAN_HULL_MIN Vector(-16, -16, 0)
|
||||
#define VEC_HUMAN_HULL_MAX Vector(16, 16, 72)
|
||||
#define VEC_HUMAN_HULL_DUCK Vector(16, 16, 36)
|
||||
|
||||
#define VEC_VIEW Vector( 0, 0, 28 )
|
||||
#define VEC_VIEW Vector(0, 0, 17)
|
||||
|
||||
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 )
|
||||
#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18)
|
||||
#define VEC_DUCK_VIEW Vector( 0, 0, 12 )
|
||||
#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18)
|
||||
#define VEC_DUCK_HULL_MAX Vector(16, 16, 32)
|
||||
#define VEC_DUCK_VIEW Vector(0, 0, 12)
|
||||
|
||||
#define SVC_TEMPENTITY 23
|
||||
#define SVC_INTERMISSION 30
|
||||
#define SVC_CDTRACK 32
|
||||
#define SVC_WEAPONANIM 35
|
||||
#define SVC_ROOMTYPE 37
|
||||
#define SVC_DIRECTOR 51
|
||||
#define SVC_TEMPENTITY 23
|
||||
#define SVC_INTERMISSION 30
|
||||
#define SVC_CDTRACK 32
|
||||
#define SVC_WEAPONANIM 35
|
||||
#define SVC_ROOMTYPE 37
|
||||
#define SVC_DIRECTOR 51
|
||||
|
||||
#define SF_TRIGGER_ALLOWMONSTERS 1
|
||||
#define SF_TRIGGER_NOCLIENTS 2
|
||||
#define SF_TRIGGER_PUSHABLES 4
|
||||
|
||||
#define SF_BREAK_TRIGGER_ONLY 1
|
||||
#define SF_BREAK_TOUCH 2
|
||||
#define SF_BREAK_PRESSURE 4
|
||||
#define SF_BREAK_CROWBAR 256
|
||||
|
||||
// triggers
|
||||
#define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger
|
||||
#define SF_TRIGGER_NOCLIENTS 2// players not allowed to fire this trigger
|
||||
#define SF_TRIGGER_PUSHABLES 4// only pushables can fire this trigger
|
||||
#define SF_PUSH_BREAKABLE 128
|
||||
|
||||
// func breakable
|
||||
#define SF_BREAK_TRIGGER_ONLY 1// may only be broken by trigger
|
||||
#define SF_BREAK_TOUCH 2// can be 'crashed through' by running player (plate glass)
|
||||
#define SF_BREAK_PRESSURE 4// can be broken by a player standing on it
|
||||
#define SF_BREAK_CROWBAR 256// instant break if hit with crowbar
|
||||
#define SF_LIGHT_START_OFF 1
|
||||
|
||||
// func_pushable (it's also func_breakable, so don't collide with those flags)
|
||||
#define SF_PUSH_BREAKABLE 128
|
||||
#define SPAWNFLAG_NOMESSAGE 1
|
||||
#define SPAWNFLAG_NOTOUCH 1
|
||||
#define SPAWNFLAG_DROIDONLY 4
|
||||
|
||||
#define SF_LIGHT_START_OFF 1
|
||||
#define SPAWNFLAG_USEONLY 1
|
||||
|
||||
#define SPAWNFLAG_NOMESSAGE 1
|
||||
#define SPAWNFLAG_NOTOUCH 1
|
||||
#define SPAWNFLAG_DROIDONLY 4
|
||||
#define TELE_PLAYER_ONLY 1
|
||||
#define TELE_SILENT 2
|
||||
|
||||
#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons)
|
||||
#define SF_TRIG_PUSH_ONCE 1
|
||||
|
||||
#define TELE_PLAYER_ONLY 1
|
||||
#define TELE_SILENT 2
|
||||
|
||||
#define SF_TRIG_PUSH_ONCE 1
|
||||
|
||||
|
||||
// Sound Utilities
|
||||
|
||||
// sentence groups
|
||||
#define CBSENTENCENAME_MAX 16
|
||||
#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match
|
||||
// CVOXFILESENTENCEMAX in engine\sound.h!!!
|
||||
#define CVOXFILESENTENCEMAX 1536
|
||||
|
||||
extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX];
|
||||
extern int gcallsentences;
|
||||
|
@ -469,7 +393,7 @@ int USENTENCEG_Pick(int isentenceg, char *szfound);
|
|||
int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int freset);
|
||||
void USENTENCEG_InitLRU(unsigned char *plru, int count);
|
||||
|
||||
void SENTENCEG_Init();
|
||||
void SENTENCEG_Init(void);
|
||||
void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick);
|
||||
int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch);
|
||||
int SENTENCEG_PlayRndSz(edict_t *entity, const char *szrootname, float volume, float attenuation, int flags, int pitch);
|
||||
|
@ -477,19 +401,11 @@ int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szrootname, float vo
|
|||
int SENTENCEG_GetIndex(const char *szrootname);
|
||||
int SENTENCEG_Lookup(const char *sample, char *sentencenum);
|
||||
|
||||
void TEXTURETYPE_Init();
|
||||
void TEXTURETYPE_Init(void);
|
||||
char TEXTURETYPE_Find(char *name);
|
||||
float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType);
|
||||
|
||||
// NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100
|
||||
// is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100
|
||||
// down to 1 is a lower pitch. 150 to 70 is the realistic range.
|
||||
// EMIT_SOUND_DYN with pitch != 100 should be used sparingly, as it's not quite as
|
||||
// fast as EMIT_SOUND (the pitchshift mixer is not native coded).
|
||||
|
||||
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation,
|
||||
int flags, int pitch);
|
||||
float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType);
|
||||
|
||||
void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch);
|
||||
|
||||
inline void EMIT_SOUND(edict_t *entity, int channel, const char *sample, float volume, float attenuation)
|
||||
{
|
||||
|
@ -505,19 +421,19 @@ void EMIT_SOUND_SUIT(edict_t *entity, const char *sample);
|
|||
void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg);
|
||||
void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname);
|
||||
|
||||
#define PRECACHE_SOUND_ARRAY( a ) \
|
||||
{ for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); }
|
||||
#define PRECACHE_SOUND_ARRAY(a) \
|
||||
{ for (int i = 0; i < (int)(ARRAYSIZE(a)); i++) PRECACHE_SOUND((char *) a [i]); }
|
||||
|
||||
#define EMIT_SOUND_ARRAY_DYN( chan, array ) \
|
||||
EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) );
|
||||
#define EMIT_SOUND_ARRAY_DYN(chan, array) \
|
||||
EMIT_SOUND_DYN(ENT(pev), chan, array[RANDOM_LONG(0,A RRAYSIZE(array) - 1)], 1, ATTN_NORM, 0, RANDOM_LONG(95, 105));
|
||||
|
||||
#define RANDOM_SOUND_ARRAY( array ) (array) [ RANDOM_LONG(0,ARRAYSIZE( (array) )-1) ]
|
||||
#define RANDOM_SOUND_ARRAY(array) (array)[RANDOM_LONG(0, ARRAYSIZE((array)) - 1)]
|
||||
|
||||
#define PLAYBACK_EVENT( flags, who, index ) PLAYBACK_EVENT_FULL( flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 );
|
||||
#define PLAYBACK_EVENT_DELAY( flags, who, index, delay ) PLAYBACK_EVENT_FULL( flags, who, index, delay, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 );
|
||||
#define PLAYBACK_EVENT(flags, who, index) PLAYBACK_EVENT_FULL(flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0);
|
||||
#define PLAYBACK_EVENT_DELAY(flags, who, index, delay) PLAYBACK_EVENT_FULL(flags, who, index, delay, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0);
|
||||
|
||||
#define GROUP_OP_AND 0
|
||||
#define GROUP_OP_NAND 1
|
||||
#define GROUP_OP_AND 0
|
||||
#define GROUP_OP_NAND 1
|
||||
|
||||
extern int g_groupmask;
|
||||
extern int g_groupop;
|
||||
|
@ -525,18 +441,18 @@ extern int g_groupop;
|
|||
class UTIL_GroupTrace
|
||||
{
|
||||
public:
|
||||
UTIL_GroupTrace( int groupmask, int op );
|
||||
~UTIL_GroupTrace( void );
|
||||
UTIL_GroupTrace(int groupmask, int op);
|
||||
~UTIL_GroupTrace(void);
|
||||
|
||||
private:
|
||||
int m_oldgroupmask, m_oldgroupop;
|
||||
};
|
||||
|
||||
void UTIL_SetGroupTrace( int groupmask, int op );
|
||||
void UTIL_UnsetGroupTrace( void );
|
||||
void UTIL_SetGroupTrace(int groupmask, int op);
|
||||
void UTIL_UnsetGroupTrace(void);
|
||||
|
||||
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
|
||||
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
|
||||
int UTIL_SharedRandomLong(unsigned int seed, int low, int high);
|
||||
float UTIL_SharedRandomFloat(unsigned int seed, float low, float high);
|
||||
|
||||
float UTIL_WeaponTimeBase( void );
|
||||
char UTIL_TextureHit(TraceResult *ptrHit, Vector vecSrc, Vector vecEnd);
|
||||
float UTIL_WeaponTimeBase(void);
|
||||
#endif // util_h__
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* Use, distribution, and modification ofthissource code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
|
@ -24,21 +24,20 @@ class Vector2D
|
|||
public:
|
||||
inline Vector2D(void): x(0.0), y(0.0) { }
|
||||
inline Vector2D(float X, float Y): x(0.0), y(0.0) { x = X; y = Y; }
|
||||
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); }
|
||||
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); }
|
||||
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); }
|
||||
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); }
|
||||
inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y);}
|
||||
inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y);}
|
||||
inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl);}
|
||||
inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl);}
|
||||
|
||||
inline float Length(void) const { return sqrt(x*x + y*y ); }
|
||||
inline float Length(void) const { return sqrt(x*x + y*y); }
|
||||
|
||||
inline Vector2D Normalize ( void ) const
|
||||
inline Vector2D Normalize (void) const
|
||||
{
|
||||
// Vector2D vec2;
|
||||
|
||||
float flLen = Length();
|
||||
if ( flLen == 0 )
|
||||
if (flLen == 0)
|
||||
{
|
||||
return Vector2D( 0, 0 );
|
||||
return Vector2D( 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,31 +49,31 @@ public:
|
|||
vec_t x, y;
|
||||
};
|
||||
|
||||
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); }
|
||||
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y); }
|
||||
inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
|
||||
|
||||
//=========================================================
|
||||
// 3D Vector
|
||||
//=========================================================
|
||||
class Vector // same data-layout as engine's vec3_t,
|
||||
{ // which is a vec_t[3]
|
||||
class Vector // same data-layout as engine's vec3_t,
|
||||
{ // which is a vec_t[3]
|
||||
public:
|
||||
// Construction/destruction
|
||||
inline Vector(void): x(0.0), y(0.0), z(0.0) { }
|
||||
inline Vector(float X, float Y, float Z): x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; }
|
||||
//inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
//inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; }
|
||||
inline Vector(const Vector& v): x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; }
|
||||
inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
|
||||
inline Vector(float X, float Y, float Z): x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; }
|
||||
//inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z;}
|
||||
//inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z;}
|
||||
inline Vector(const Vector& v): x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; }
|
||||
inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2];}
|
||||
|
||||
// Operators
|
||||
inline Vector operator-(void) const { return Vector(-x,-y,-z); }
|
||||
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; }
|
||||
inline int operator!=(const Vector& v) const { return !(*this==v); }
|
||||
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); }
|
||||
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); }
|
||||
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
|
||||
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
|
||||
inline Vector operator-(void) const { return Vector(-x,-y,-z); }
|
||||
inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z;}
|
||||
inline int operator!=(const Vector& v) const { return !(*this==v); }
|
||||
inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z);}
|
||||
inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z);}
|
||||
inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); }
|
||||
inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); }
|
||||
|
||||
// Methods
|
||||
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; }
|
||||
|
@ -89,7 +88,7 @@ public:
|
|||
return Vector(x * flLen, y * flLen, z * flLen);
|
||||
}
|
||||
|
||||
inline Vector2D Make2D ( void ) const
|
||||
inline Vector2D Make2D (void) const
|
||||
{
|
||||
Vector2D Vec2;
|
||||
|
||||
|
@ -105,8 +104,7 @@ public:
|
|||
};
|
||||
inline Vector operator*(float fl, const Vector& v) { return v * fl; }
|
||||
inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); }
|
||||
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); }
|
||||
|
||||
inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector(a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x); }
|
||||
|
||||
|
||||
#endif
|
||||
|
|
2182
dlls/weapons.cpp
2182
dlls/weapons.cpp
File diff suppressed because it is too large
Load Diff
3476
dlls/weapons.h
3476
dlls/weapons.h
File diff suppressed because it is too large
Load Diff
756
dlls/world.cpp
756
dlls/world.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,274 +0,0 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "weapons.h"
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
|
||||
enum glock_e {
|
||||
GLOCK_IDLE1 = 0,
|
||||
GLOCK_IDLE2,
|
||||
GLOCK_IDLE3,
|
||||
GLOCK_SHOOT,
|
||||
GLOCK_SHOOT_EMPTY,
|
||||
GLOCK_RELOAD,
|
||||
GLOCK_RELOAD_NOT_EMPTY,
|
||||
GLOCK_DRAW,
|
||||
GLOCK_HOLSTER,
|
||||
GLOCK_ADD_SILENCER
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( weapon_glock, CGlock );
|
||||
LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock );
|
||||
|
||||
|
||||
void CGlock::Spawn( )
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_9mmhandgun"); // hack to allow for old names
|
||||
Precache( );
|
||||
m_iId = WEAPON_GLOCK;
|
||||
SET_MODEL(ENT(pev), "models/w_9mmhandgun.mdl");
|
||||
|
||||
m_iDefaultAmmo = GLOCK_DEFAULT_GIVE;
|
||||
|
||||
FallInit();// get ready to fall down.
|
||||
}
|
||||
|
||||
|
||||
void CGlock::Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL("models/v_9mmhandgun.mdl");
|
||||
PRECACHE_MODEL("models/w_9mmhandgun.mdl");
|
||||
PRECACHE_MODEL("models/p_9mmhandgun.mdl");
|
||||
|
||||
m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shell
|
||||
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
PRECACHE_SOUND("items/9mmclip2.wav");
|
||||
|
||||
PRECACHE_SOUND ("weapons/pl_gun1.wav");//silenced handgun
|
||||
PRECACHE_SOUND ("weapons/pl_gun2.wav");//silenced handgun
|
||||
PRECACHE_SOUND ("weapons/pl_gun3.wav");//handgun
|
||||
|
||||
m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" );
|
||||
m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" );
|
||||
}
|
||||
|
||||
int CGlock::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "9mm";
|
||||
p->iMaxAmmo1 = _9MM_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = GLOCK_MAX_CLIP;
|
||||
p->iSlot = 1;
|
||||
p->iPosition = 0;
|
||||
p->iFlags = 0;
|
||||
p->iId = m_iId = WEAPON_GLOCK;
|
||||
p->iWeight = GLOCK_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CGlock::Deploy( )
|
||||
{
|
||||
// pev->body = 1;
|
||||
return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 );
|
||||
}
|
||||
|
||||
void CGlock::SecondaryAttack( void )
|
||||
{
|
||||
GlockFire( 0.1, 0.2, FALSE );
|
||||
}
|
||||
|
||||
void CGlock::PrimaryAttack( void )
|
||||
{
|
||||
GlockFire( 0.01, 0.3, TRUE );
|
||||
}
|
||||
|
||||
void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim )
|
||||
{
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
|
||||
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
||||
|
||||
int flags;
|
||||
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
// silenced
|
||||
if (pev->body == 1)
|
||||
{
|
||||
m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
|
||||
}
|
||||
else
|
||||
{
|
||||
// non-silenced
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
}
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
||||
Vector vecAiming;
|
||||
|
||||
if ( fUseAutoAim )
|
||||
{
|
||||
vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
}
|
||||
else
|
||||
{
|
||||
vecAiming = gpGlobals->v_forward;
|
||||
}
|
||||
|
||||
Vector vecDir;
|
||||
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
|
||||
|
||||
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
|
||||
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
// HEV suit - indicate out of ammo condition
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
|
||||
|
||||
void CGlock::Reload( void )
|
||||
{
|
||||
if ( m_pPlayer->ammo_9mm <= 0 )
|
||||
return;
|
||||
|
||||
int iResult;
|
||||
|
||||
if (m_iClip == 0)
|
||||
iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 );
|
||||
else
|
||||
iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 );
|
||||
|
||||
if (iResult)
|
||||
{
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CGlock::WeaponIdle( void )
|
||||
{
|
||||
ResetEmptySound( );
|
||||
|
||||
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
||||
|
||||
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
||||
return;
|
||||
|
||||
// only idle if the slid isn't back
|
||||
if (m_iClip != 0)
|
||||
{
|
||||
int iAnim;
|
||||
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );
|
||||
|
||||
if (flRand <= 0.3 + 0 * 0.75)
|
||||
{
|
||||
iAnim = GLOCK_IDLE3;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16;
|
||||
}
|
||||
else if (flRand <= 0.6 + 0 * 0.875)
|
||||
{
|
||||
iAnim = GLOCK_IDLE1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iAnim = GLOCK_IDLE2;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
|
||||
}
|
||||
SendWeaponAnim( iAnim, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CGlockAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_9mmclip.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
}
|
||||
void Precache( void )
|
||||
{
|
||||
PRECACHE_MODEL ("models/w_9mmclip.mdl");
|
||||
PRECACHE_SOUND("items/9mmclip1.wav");
|
||||
}
|
||||
BOOL AddAmmo( CBaseEntity *pOther )
|
||||
{
|
||||
if (pOther->GiveAmmo( AMMO_GLOCKCLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo );
|
||||
LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,180 +1,179 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum ak47_e
|
||||
{
|
||||
AK47_IDLE1,
|
||||
AK47_RELOAD,
|
||||
AK47_DRAW,
|
||||
AK47_SHOOT1,
|
||||
AK47_SHOOT2,
|
||||
AK47_SHOOT3
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_ak47, CAK47);
|
||||
|
||||
void CAK47::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_ak47");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AK47;
|
||||
SET_MODEL(ENT(pev), "models/w_ak47.mdl");
|
||||
|
||||
m_iDefaultAmmo = AK47_DEFAULT_GIVE;
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAK47::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_ak47.mdl");
|
||||
PRECACHE_MODEL("models/w_ak47.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/ak47-1.wav");
|
||||
PRECACHE_SOUND("weapons/ak47-2.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_clipout.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_boltpull.wav");
|
||||
|
||||
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
|
||||
m_usFireAK47 = PRECACHE_EVENT(1, "events/ak47.sc");
|
||||
}
|
||||
|
||||
int CAK47::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "762Nato";
|
||||
p->iMaxAmmo1 = _762NATO_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AK47_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 1;
|
||||
p->iId = m_iId = WEAPON_AK47;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AK47_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAK47::Deploy(void)
|
||||
{
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
iShellOn = 1;
|
||||
|
||||
return DefaultDeploy("models/v_ak47.mdl", "models/p_ak47.mdl", AK47_DRAW, "ak47", UseDecrement() != FALSE);
|
||||
}
|
||||
|
||||
void CAK47::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AK47Fire(0.04 + (0.4) * m_flAccuracy, 0.0955, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AK47Fire(0.04 + (0.07) * m_flAccuracy, 0.0955, FALSE);
|
||||
else
|
||||
AK47Fire((0.0275), 0.0955, FALSE);
|
||||
}
|
||||
|
||||
void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
m_bDelayFire = true;
|
||||
m_iShotsFired++;
|
||||
m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.35;
|
||||
|
||||
if (m_flAccuracy > 1.25)
|
||||
m_flAccuracy = 1.25;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, flSpread, 8192, 2, BULLET_PLAYER_762MM, 36, 0.98, m_pPlayer->pev, FALSE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireAK47, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.y * 100), FALSE, FALSE);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9;
|
||||
|
||||
if (m_pPlayer->pev->velocity.Length2D() > 0)
|
||||
KickBack(1.5, 0.45, 0.225, 0.05, 6.5, 2.5, 7);
|
||||
else if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
KickBack(2.0, 1.0, 0.5, 0.35, 9.0, 6.0, 5);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
KickBack(0.9, 0.35, 0.15, 0.025, 5.5, 1.5, 9);
|
||||
else
|
||||
KickBack(1.0, 0.375, 0.175, 0.0375, 5.75, 1.75, 8);
|
||||
}
|
||||
|
||||
void CAK47::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_762nato <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AK47_MAX_CLIP, AK47_RELOAD, 2.45))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
m_bDelayFire = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CAK47::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20;
|
||||
SendWeaponAnim(AK47_IDLE1, UseDecrement() != FALSE);
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum ak47_e
|
||||
{
|
||||
AK47_IDLE1,
|
||||
AK47_RELOAD,
|
||||
AK47_DRAW,
|
||||
AK47_SHOOT1,
|
||||
AK47_SHOOT2,
|
||||
AK47_SHOOT3
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_ak47, CAK47);
|
||||
|
||||
void CAK47::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_ak47");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AK47;
|
||||
SET_MODEL(ENT(pev), "models/w_ak47.mdl");
|
||||
|
||||
m_iDefaultAmmo = AK47_DEFAULT_GIVE;
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAK47::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_ak47.mdl");
|
||||
PRECACHE_MODEL("models/w_ak47.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/ak47-1.wav");
|
||||
PRECACHE_SOUND("weapons/ak47-2.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_clipout.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/ak47_boltpull.wav");
|
||||
|
||||
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
|
||||
m_usFireAK47 = PRECACHE_EVENT(1, "events/ak47.sc");
|
||||
}
|
||||
|
||||
int CAK47::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "762Nato";
|
||||
p->iMaxAmmo1 = _762NATO_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AK47_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 1;
|
||||
p->iId = m_iId = WEAPON_AK47;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AK47_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAK47::Deploy(void)
|
||||
{
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
iShellOn = 1;
|
||||
|
||||
return DefaultDeploy("models/v_ak47.mdl", "models/p_ak47.mdl", AK47_DRAW, "ak47", UseDecrement() != FALSE);
|
||||
}
|
||||
|
||||
void CAK47::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AK47Fire(0.04 + (0.4) * m_flAccuracy, 0.0955, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AK47Fire(0.04 + (0.07) * m_flAccuracy, 0.0955, FALSE);
|
||||
else
|
||||
AK47Fire((0.0275), 0.0955, FALSE);
|
||||
}
|
||||
|
||||
void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
m_bDelayFire = true;
|
||||
m_iShotsFired++;
|
||||
m_flAccuracy = ((float)(m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200.0) + 0.35;
|
||||
|
||||
if (m_flAccuracy > 1.25)
|
||||
m_flAccuracy = 1.25;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, flSpread, 8192, 2, BULLET_PLAYER_762MM, 36, 0.98, m_pPlayer->pev, FALSE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireAK47, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.y * 100), FALSE, FALSE);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9;
|
||||
|
||||
if (m_pPlayer->pev->velocity.Length2D() > 0)
|
||||
KickBack(1.5, 0.45, 0.225, 0.05, 6.5, 2.5, 7);
|
||||
else if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
KickBack(2.0, 1.0, 0.5, 0.35, 9.0, 6.0, 5);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
KickBack(0.9, 0.35, 0.15, 0.025, 5.5, 1.5, 9);
|
||||
else
|
||||
KickBack(1.0, 0.375, 0.175, 0.0375, 5.75, 1.75, 8);
|
||||
}
|
||||
|
||||
void CAK47::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_762nato <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AK47_MAX_CLIP, AK47_RELOAD, 2.45))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
m_bDelayFire = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CAK47::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20;
|
||||
SendWeaponAnim(AK47_IDLE1, UseDecrement() != FALSE);
|
||||
}
|
|
@ -1,197 +1,196 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum aug_e
|
||||
{
|
||||
AUG_IDLE1,
|
||||
AUG_RELOAD,
|
||||
AUG_DRAW,
|
||||
AUG_SHOOT1,
|
||||
AUG_SHOOT2,
|
||||
AUG_SHOOT3
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_aug, CAUG);
|
||||
|
||||
void CAUG::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_aug");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AUG;
|
||||
SET_MODEL(ENT(pev), "models/w_aug.mdl");
|
||||
|
||||
m_iDefaultAmmo = AUG_DEFAULT_GIVE;
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAUG::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_aug.mdl");
|
||||
PRECACHE_MODEL("models/w_aug.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/aug-1.wav");
|
||||
PRECACHE_SOUND("weapons/aug_clipout.wav");
|
||||
PRECACHE_SOUND("weapons/aug_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/aug_boltpull.wav");
|
||||
PRECACHE_SOUND("weapons/aug_boltslap.wav");
|
||||
PRECACHE_SOUND("weapons/aug_forearm.wav");
|
||||
|
||||
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
|
||||
m_usFireAug = PRECACHE_EVENT(1, "events/aug.sc");
|
||||
}
|
||||
|
||||
int CAUG::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "556Nato";
|
||||
p->iMaxAmmo1 = _556NATO_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AUG_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 14;
|
||||
p->iId = m_iId = WEAPON_AUG;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AUG_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAUG::Deploy(void)
|
||||
{
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
iShellOn = 1;
|
||||
|
||||
return DefaultDeploy("models/v_aug.mdl", "models/p_aug.mdl", AUG_DRAW, "carbine", UseDecrement() != FALSE);
|
||||
}
|
||||
|
||||
void CAUG::SecondaryAttack(void)
|
||||
{
|
||||
if (m_pPlayer->m_iFOV != 90)
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 90;
|
||||
else
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 55;
|
||||
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
}
|
||||
|
||||
void CAUG::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AUGFire(0.035 + (0.4) * m_flAccuracy, 0.0825, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AUGFire(0.035 + (0.07) * m_flAccuracy, 0.0825, FALSE);
|
||||
else if (m_pPlayer->pev->fov == 90)
|
||||
AUGFire((0.02) * m_flAccuracy, 0.0825, FALSE);
|
||||
else
|
||||
AUGFire((0.02) * m_flAccuracy, 0.135, FALSE);
|
||||
}
|
||||
|
||||
void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
m_bDelayFire = true;
|
||||
m_iShotsFired++;
|
||||
m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 215) + 0.3;
|
||||
|
||||
if (m_flAccuracy > 1)
|
||||
m_flAccuracy = 1;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, flSpread, 8192, 2, BULLET_PLAYER_556MM, 32, 0.96, m_pPlayer->pev, FALSE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireAug, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.y * 100), FALSE, FALSE);
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9;
|
||||
|
||||
if (m_pPlayer->pev->velocity.Length2D() > 0)
|
||||
KickBack(1.0, 0.45, 0.275, 0.05, 4.0, 2.5, 7);
|
||||
else if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
KickBack(1.25, 0.45, 0.22, 0.18, 5.5, 4.0, 5);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
KickBack(0.575, 0.325, 0.2, 0.011, 3.25, 2.0, 8);
|
||||
else
|
||||
KickBack(0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8);
|
||||
}
|
||||
|
||||
void CAUG::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_556nato <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AUG_MAX_CLIP, AUG_RELOAD, 3.3))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
|
||||
if (m_pPlayer->m_iFOV != 90)
|
||||
SecondaryAttack();
|
||||
|
||||
m_flAccuracy = 0;
|
||||
m_iShotsFired = 0;
|
||||
m_bDelayFire = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CAUG::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20;
|
||||
SendWeaponAnim(AUG_IDLE1, UseDecrement() != FALSE);
|
||||
}
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum aug_e
|
||||
{
|
||||
AUG_IDLE1,
|
||||
AUG_RELOAD,
|
||||
AUG_DRAW,
|
||||
AUG_SHOOT1,
|
||||
AUG_SHOOT2,
|
||||
AUG_SHOOT3
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_aug, CAUG);
|
||||
|
||||
void CAUG::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_aug");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AUG;
|
||||
SET_MODEL(ENT(pev), "models/w_aug.mdl");
|
||||
|
||||
m_iDefaultAmmo = AUG_DEFAULT_GIVE;
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAUG::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_aug.mdl");
|
||||
PRECACHE_MODEL("models/w_aug.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/aug-1.wav");
|
||||
PRECACHE_SOUND("weapons/aug_clipout.wav");
|
||||
PRECACHE_SOUND("weapons/aug_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/aug_boltpull.wav");
|
||||
PRECACHE_SOUND("weapons/aug_boltslap.wav");
|
||||
PRECACHE_SOUND("weapons/aug_forearm.wav");
|
||||
|
||||
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
|
||||
m_usFireAug = PRECACHE_EVENT(1, "events/aug.sc");
|
||||
}
|
||||
|
||||
int CAUG::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "556Nato";
|
||||
p->iMaxAmmo1 = _556NATO_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AUG_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 14;
|
||||
p->iId = m_iId = WEAPON_AUG;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AUG_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAUG::Deploy(void)
|
||||
{
|
||||
m_flAccuracy = 0.2;
|
||||
m_iShotsFired = 0;
|
||||
iShellOn = 1;
|
||||
|
||||
return DefaultDeploy("models/v_aug.mdl", "models/p_aug.mdl", AUG_DRAW, "carbine", UseDecrement() != FALSE);
|
||||
}
|
||||
|
||||
void CAUG::SecondaryAttack(void)
|
||||
{
|
||||
if (m_pPlayer->m_iFOV != 90)
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 90;
|
||||
else
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 55;
|
||||
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
}
|
||||
|
||||
void CAUG::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AUGFire(0.035 + (0.4) * m_flAccuracy, 0.0825, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AUGFire(0.035 + (0.07) * m_flAccuracy, 0.0825, FALSE);
|
||||
else if (m_pPlayer->pev->fov == 90)
|
||||
AUGFire((0.02) * m_flAccuracy, 0.0825, FALSE);
|
||||
else
|
||||
AUGFire((0.02) * m_flAccuracy, 0.135, FALSE);
|
||||
}
|
||||
|
||||
void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
m_bDelayFire = true;
|
||||
m_iShotsFired++;
|
||||
m_flAccuracy = ((float)(m_iShotsFired * m_iShotsFired * m_iShotsFired) / 215.0) + 0.3;
|
||||
|
||||
if (m_flAccuracy > 1)
|
||||
m_flAccuracy = 1;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, flSpread, 8192, 2, BULLET_PLAYER_556MM, 32, 0.96, m_pPlayer->pev, FALSE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireAug, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.y * 100), FALSE, FALSE);
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.9;
|
||||
|
||||
if (m_pPlayer->pev->velocity.Length2D() > 0)
|
||||
KickBack(1.0, 0.45, 0.275, 0.05, 4.0, 2.5, 7);
|
||||
else if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
KickBack(1.25, 0.45, 0.22, 0.18, 5.5, 4.0, 5);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
KickBack(0.575, 0.325, 0.2, 0.011, 3.25, 2.0, 8);
|
||||
else
|
||||
KickBack(0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8);
|
||||
}
|
||||
|
||||
void CAUG::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_556nato <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AUG_MAX_CLIP, AUG_RELOAD, 3.3))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
|
||||
if (m_pPlayer->m_iFOV != 90)
|
||||
SecondaryAttack();
|
||||
|
||||
m_flAccuracy = 0;
|
||||
m_iShotsFired = 0;
|
||||
m_bDelayFire = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CAUG::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20;
|
||||
SendWeaponAnim(AUG_IDLE1, UseDecrement() != FALSE);
|
||||
}
|
|
@ -1,210 +1,209 @@
|
|||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum awp_e
|
||||
{
|
||||
AWP_IDLE,
|
||||
AWP_SHOOT1,
|
||||
AWP_SHOOT2,
|
||||
AWP_SHOOT3,
|
||||
AWP_RELOAD,
|
||||
AWP_DRAW
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_awp, CAWP);
|
||||
|
||||
void CAWP::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_awp");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AWP;
|
||||
SET_MODEL(ENT(pev), "models/w_awp.mdl");
|
||||
|
||||
m_iDefaultAmmo = AWP_DEFAULT_GIVE;
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAWP::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_awp.mdl");
|
||||
PRECACHE_MODEL("models/w_awp.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/awp1.wav");
|
||||
PRECACHE_SOUND("weapons/boltpull1.wav");
|
||||
PRECACHE_SOUND("weapons/boltup.wav");
|
||||
PRECACHE_SOUND("weapons/boltdown.wav");
|
||||
PRECACHE_SOUND("weapons/zoom.wav");
|
||||
PRECACHE_SOUND("weapons/awp_deploy.wav");
|
||||
PRECACHE_SOUND("weapons/awp_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/awp_clipout.wav");
|
||||
|
||||
m_iShellId = m_iShell = PRECACHE_MODEL("models/rshell_big.mdl");
|
||||
m_usFireAWP = PRECACHE_EVENT(1, "events/awp.sc");
|
||||
}
|
||||
|
||||
int CAWP::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "338Magnum";
|
||||
p->iMaxAmmo1 = _338MAGNUM_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AWP_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 2;
|
||||
p->iId = m_iId = WEAPON_AWP;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AWP_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAWP::Deploy(void)
|
||||
{
|
||||
if (DefaultDeploy("models/v_awp.mdl", "models/p_awp.mdl", AWP_DRAW, "rifle", UseDecrement() != FALSE))
|
||||
{
|
||||
m_flNextPrimaryAttack = m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.45;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CAWP::SecondaryAttack(void)
|
||||
{
|
||||
switch (m_pPlayer->m_iFOV)
|
||||
{
|
||||
case 90: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 40; break;
|
||||
case 40: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 10; break;
|
||||
default: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break;
|
||||
}
|
||||
|
||||
m_pPlayer->ResetMaxSpeed();
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/zoom.wav", 0.2, 2.4);
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
}
|
||||
|
||||
void CAWP::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AWPFire(0.85, 1.45, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AWPFire(0.25, 1.45, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 10)
|
||||
AWPFire(0.1, 1.45, FALSE);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
AWPFire(0.0, 1.45, FALSE);
|
||||
else
|
||||
AWPFire(0.001, 1.45, FALSE);
|
||||
}
|
||||
|
||||
void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
if (m_pPlayer->pev->fov != 90)
|
||||
{
|
||||
m_pPlayer->m_bResumeZoom = true;
|
||||
m_pPlayer->m_iLastZoom = m_pPlayer->m_iFOV;
|
||||
m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90;
|
||||
}
|
||||
else
|
||||
flCycleTime += 0.08;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
|
||||
m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.55;
|
||||
m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
|
||||
Vector vecDir = FireBullets3(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, flSpread, 8192, 3, BULLET_PLAYER_338MAG, 115, 0.99, m_pPlayer->pev, TRUE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, ENT(m_pPlayer->pev), m_usFireAWP, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.x * 100), FALSE, FALSE);
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2;
|
||||
m_pPlayer->pev->punchangle.x -= 2;
|
||||
}
|
||||
|
||||
void CAWP::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_338mag <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AWP_MAX_CLIP, AWP_RELOAD, 2.5))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
|
||||
if (m_pPlayer->pev->fov != 90)
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 10;
|
||||
SecondaryAttack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAWP::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
if (m_iClip)
|
||||
{
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60;
|
||||
SendWeaponAnim(AWP_IDLE, UseDecrement() != FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
float CAWP::GetMaxSpeed(void)
|
||||
{
|
||||
if (m_pPlayer->m_iFOV == 90)
|
||||
return 210;
|
||||
|
||||
return 150;
|
||||
/***
|
||||
*
|
||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||||
*
|
||||
* This product contains software technology licensed from Id
|
||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Use, distribution, and modification of this source code and/or resulting
|
||||
* object code is restricted to non-commercial enhancements to products from
|
||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
||||
* without written permission from Valve LLC.
|
||||
*
|
||||
****/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "cbase.h"
|
||||
#include "player.h"
|
||||
#include "weapons.h"
|
||||
|
||||
enum awp_e
|
||||
{
|
||||
AWP_IDLE,
|
||||
AWP_SHOOT1,
|
||||
AWP_SHOOT2,
|
||||
AWP_SHOOT3,
|
||||
AWP_RELOAD,
|
||||
AWP_DRAW
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_awp, CAWP);
|
||||
|
||||
void CAWP::Spawn(void)
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_awp");
|
||||
|
||||
Precache();
|
||||
m_iId = WEAPON_AWP;
|
||||
SET_MODEL(ENT(pev), "models/w_awp.mdl");
|
||||
|
||||
m_iDefaultAmmo = AWP_DEFAULT_GIVE;
|
||||
FallInit();
|
||||
}
|
||||
|
||||
void CAWP::Precache(void)
|
||||
{
|
||||
PRECACHE_MODEL("models/v_awp.mdl");
|
||||
PRECACHE_MODEL("models/w_awp.mdl");
|
||||
|
||||
PRECACHE_SOUND("weapons/awp1.wav");
|
||||
PRECACHE_SOUND("weapons/boltpull1.wav");
|
||||
PRECACHE_SOUND("weapons/boltup.wav");
|
||||
PRECACHE_SOUND("weapons/boltdown.wav");
|
||||
PRECACHE_SOUND("weapons/zoom.wav");
|
||||
PRECACHE_SOUND("weapons/awp_deploy.wav");
|
||||
PRECACHE_SOUND("weapons/awp_clipin.wav");
|
||||
PRECACHE_SOUND("weapons/awp_clipout.wav");
|
||||
|
||||
m_iShellId = m_iShell = PRECACHE_MODEL("models/rshell_big.mdl");
|
||||
m_usFireAWP = PRECACHE_EVENT(1, "events/awp.sc");
|
||||
}
|
||||
|
||||
int CAWP::GetItemInfo(ItemInfo *p)
|
||||
{
|
||||
p->pszName = STRING(pev->classname);
|
||||
p->pszAmmo1 = "338Magnum";
|
||||
p->iMaxAmmo1 = _338MAGNUM_MAX_CARRY;
|
||||
p->pszAmmo2 = NULL;
|
||||
p->iMaxAmmo2 = -1;
|
||||
p->iMaxClip = AWP_MAX_CLIP;
|
||||
p->iSlot = 0;
|
||||
p->iPosition = 2;
|
||||
p->iId = m_iId = WEAPON_AWP;
|
||||
p->iFlags = 0;
|
||||
p->iWeight = AWP_WEIGHT;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL CAWP::Deploy(void)
|
||||
{
|
||||
if (DefaultDeploy("models/v_awp.mdl", "models/p_awp.mdl", AWP_DRAW, "rifle", UseDecrement() != FALSE))
|
||||
{
|
||||
m_flNextPrimaryAttack = m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.45;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CAWP::SecondaryAttack(void)
|
||||
{
|
||||
switch (m_pPlayer->m_iFOV)
|
||||
{
|
||||
case 90: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 40; break;
|
||||
case 40: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 10; break;
|
||||
default: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break;
|
||||
}
|
||||
|
||||
m_pPlayer->ResetMaxSpeed();
|
||||
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/zoom.wav", 0.2, 2.4);
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
||||
}
|
||||
|
||||
void CAWP::PrimaryAttack(void)
|
||||
{
|
||||
if (!FBitSet(m_pPlayer->pev->flags, FL_ONGROUND))
|
||||
AWPFire(0.85, 1.45, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
||||
AWPFire(0.25, 1.45, FALSE);
|
||||
else if (m_pPlayer->pev->velocity.Length2D() > 10)
|
||||
AWPFire(0.1, 1.45, FALSE);
|
||||
else if (FBitSet(m_pPlayer->pev->flags, FL_DUCKING))
|
||||
AWPFire(0.0, 1.45, FALSE);
|
||||
else
|
||||
AWPFire(0.001, 1.45, FALSE);
|
||||
}
|
||||
|
||||
void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
||||
{
|
||||
if (m_pPlayer->pev->fov != 90)
|
||||
{
|
||||
m_pPlayer->m_bResumeZoom = true;
|
||||
m_pPlayer->m_iLastZoom = m_pPlayer->m_iFOV;
|
||||
m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90;
|
||||
}
|
||||
else
|
||||
flCycleTime += 0.08;
|
||||
|
||||
if (m_iClip <= 0)
|
||||
{
|
||||
if (m_fFireOnEmpty)
|
||||
{
|
||||
PlayEmptySound();
|
||||
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_iClip--;
|
||||
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
|
||||
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
||||
|
||||
m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.55;
|
||||
m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME;
|
||||
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
||||
|
||||
Vector vecDir = FireBullets3(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, flSpread, 8192, 3, BULLET_PLAYER_338MAG, 115, 0.99, m_pPlayer->pev, TRUE, m_pPlayer->random_seed);
|
||||
|
||||
int flags;
|
||||
#ifdef CLIENT_WEAPONS
|
||||
flags = FEV_NOTHOST;
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
|
||||
PLAYBACK_EVENT_FULL(flags, ENT(m_pPlayer->pev), m_usFireAWP, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.x * 100), FALSE, FALSE);
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;
|
||||
|
||||
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
||||
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2;
|
||||
m_pPlayer->pev->punchangle.x -= 2;
|
||||
}
|
||||
|
||||
void CAWP::Reload(void)
|
||||
{
|
||||
if (m_pPlayer->ammo_338mag <= 0)
|
||||
return;
|
||||
|
||||
if (DefaultReload(AWP_MAX_CLIP, AWP_RELOAD, 2.5))
|
||||
{
|
||||
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
||||
|
||||
if (m_pPlayer->pev->fov != 90)
|
||||
{
|
||||
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 10;
|
||||
SecondaryAttack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAWP::WeaponIdle(void)
|
||||
{
|
||||
ResetEmptySound();
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
if (m_iClip)
|
||||
{
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60;
|
||||
SendWeaponAnim(AWP_IDLE, UseDecrement() != FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
float CAWP::GetMaxSpeed(void)
|
||||
{
|
||||
if (m_pPlayer->m_iFOV == 90)
|
||||
return 210;
|
||||
|
||||
return 150;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue