📄 actor.h
字号:
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/actor.h $
// $Revision:: 90 $
// $Author:: Jimdose $
// $Date:: 1/29/99 7:02p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/actor.h $
//
// 90 1/29/99 7:02p Jimdose
// added 2015 changes
//
// 89 11/09/98 6:23p Markd
// Added turnspeed event
//
// 88 11/08/98 7:07p Markd
// added nochatter command
//
// 87 11/08/98 6:57p Jimdose
// reordered some variables in archive and unarchive so that they match the
// order they're defined in the class
//
// 86 11/07/98 3:34p Markd
// Added nodeathfade command
//
// 85 11/06/98 8:25p Jimdose
// made visiondistance adjustable from script
//
// 84 10/27/98 9:41p Jimdose
// made gun orienting functions virtual
//
// 83 10/27/98 7:53p Jimdose
// added IfEnemyWithinEvent
//
// 82 10/27/98 1:50a Markd
// Made Chatter a virtual void function
//
// 81 10/26/98 2:19p Markd
// Added last_jump_time
//
// 80 10/25/98 11:52p Jimdose
// added EXPORT_TEMPLATE
//
// 79 10/25/98 4:43a Markd
// Added animal events
//
// 78 10/24/98 3:10p Markd
// Put in eyeoffset command
//
// 77 10/22/98 9:29p Aldie
// Added support for deathgib animations
//
// 76 10/20/98 2:37a Markd
// Added additional JumpTo methods
//
// 75 10/20/98 12:44a Markd
// Added setSize and setHealth
//
// 74 10/17/98 11:02p Markd
// Added ifcanshoot
//
// 73 10/17/98 4:59p Markd
// Added Attackmode event
//
// 72 10/16/98 7:19p Markd
// Added a bunch of new events
//
// 71 10/16/98 1:41a Jimdose
// Added goto command for actors. This helps the all too common mistake of
// typing "local.self goto label"
//
// 70 10/14/98 5:22p Markd
// Added jumpto and jumpto function
//
// 69 10/14/98 2:17a Markd
// Added in ifcanmeleeattack event
//
// 68 10/14/98 1:27a Markd
// Added HasWeapon method
//
// 67 10/13/98 9:11p Markd
// Externed Actor_AttackEntity Actor_AttackPlayer
//
// 66 10/11/98 5:01p Markd
// Added variables to keep track of drowning and lack of oxygen
//
// 65 10/11/98 12:32a Markd
// Added AirMove
//
// 64 10/10/98 7:59p Markd
// Added painthreshold and snd_pain_taunt
//
// 63 10/10/98 6:08p Markd
// Added FleeAndRemove, FindFlee, fixed max_ainode bug
//
// 62 10/10/98 1:25a Jimdose
// Did some bulletproofing against possible NULL actorthread
// Prethink kills actors with NULL threads
// added SetVariable for setting thread variables safely
// stateStack is now properly archived without destroying its contents
//
// 61 10/06/98 5:26p Markd
// Made MakeEnemy and DoAction take the force parameter
//
// 60 10/06/98 12:14p Markd
// Added ForceAction
//
// 59 10/05/98 10:33p Markd
// Added nostrafe and canstrafe
//
// 58 10/05/98 2:25a Jimdose
// Made archive functions properly handle NULL behaviors
//
// 57 10/04/98 10:26p Markd
// Added AttackFinishedEvent
//
// 56 10/03/98 7:27p Markd
// working on swimming character and redid some weapon aiming stuff
//
// 55 10/01/98 8:01p Markd
// Added melee variables
//
// 54 9/30/98 1:18p Markd
// Added actor melee variables
//
// 53 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 52 9/24/98 7:10p Jimdose
// Added MyGunAngles
//
// 51 9/22/98 5:11p Jimdose
// made the anim variables public
//
// 50 9/22/98 5:31a Jimdose
// Added attackmode
//
// 49 9/22/98 1:58a Jimdose
// Added lastmove and forwardspeed
// Regrouped functions by functionality
//
// 48 9/19/98 6:16p Jimdose
// Added AttackPlayer
//
// 47 9/18/98 10:55p Jimdose
// Added inanimate actor type
// started work on swimming monsters
// added showinfo
//
// 46 9/14/98 5:26p Jimdose
// ProcessScript now allows events to be passed in
//
// 45 8/26/98 11:13p Jimdose
// Began strafe support
//
// 44 8/24/98 6:56p Jimdose
// Added crouching pain and death animations
// Added path
// Moved hueristics for path finding to actor
//
// 43 8/19/98 3:59p Jimdose
// Added IfNearEvent and CopyStateEvent
//
// 42 8/19/98 2:30p Jimdose
// Can no longer alias "alert" to "idle" so I've added a hasalert variable
//
// 41 8/14/98 11:34p Jimdose
// added seenenemy
//
// 40 8/14/98 6:24p Jimdose
// Got rid of decelleration for steering
//
// 39 8/07/98 7:57p Markd
// Added ForwardToBehavior event
//
// 38 8/07/98 6:02p Jimdose
// Added NotifyBehavior
//
// 37 8/06/98 6:59p Jimdose
// Added IfEnemyVisible
//
// 36 8/05/98 7:19p Jimdose
// Added definestate, ignoresounds, respondtosounds, respondtoall
// Added StateInfo
//
// 35 7/29/98 6:32p Jimdose
// Added MonsterStart
//
// 34 7/26/98 11:43a Jimdose
// Added EnemyCanSeeMeFrom
//
// 33 7/26/98 3:49a Jimdose
// Modified aim based on skill
//
// 32 7/25/98 2:12a Jimdose
// Made trig a TouchFieldPtr
//
// 31 7/24/98 3:10p Jimdose
// Removed ignore enemies stuff
//
// 30 7/22/98 7:03p Aldie
// Remove useless bodies
//
// 29 7/14/98 11:49p Jimdose
// Made PopState return whether a new state was popped off the stack
//
// 28 7/08/98 12:58p Jimdose
// added min and max for crouch and stand sizes
//
// 27 7/08/98 12:56p Jimdose
// added crouchsize and standsize
//
// 26 7/07/98 11:37p Jimdose
// Replaced priority-based system with full script-based state system
//
// 25 7/06/98 1:06p Jimdose
// working on ai
//
// 24 7/06/98 1:06p Jimdose
// working on ai
//
// 23 6/30/98 6:49p Aldie
// Added Gib event
//
// 22 6/30/98 6:00p Jimdose
// Added more states and state detection code.
// Added range detection
// added health level detection
//
// 21 6/25/98 8:11p Jimdose
// Added global actor scripts
//
// 20 6/19/98 9:29p Jimdose
// Added GetGunOrientation
//
// 19 6/19/98 5:53p Jimdose
// Added InFOV
//
// 18 6/18/98 8:45p Jimdose
// Removed string based SetBehavior and PushState functions
//
// 17 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 16 6/13/98 8:22p Jimdose
// Added some enemy visibility functions for FindCover
//
// 15 6/11/98 12:44a Jimdose
// behaviors now get info from the script at startup
//
// 14 6/10/98 10:25p Jimdose
// Added priority based state system
//
// 13 6/09/98 4:24p Jimdose
// worked on ai
//
// 12 6/04/98 10:48p Jimdose
// Fixed a bunch of things that got broken just in time for E3. Paths and
// scripting actually work now.
//
// 11 6/03/98 5:44p Jimdose
// Fixed spelling of behavior. :)
//
// 10 5/27/98 5:11a Jimdose
// working on ai
//
// 9 5/25/98 6:47p Jimdose
// Made animateframe, prethink and posthink into functions built into the base
// entity class
//
// 8 5/25/98 5:31p Jimdose
// Pathnodes are no longer a subclass of Entity. This was done to save on
// edicts
//
// 7 5/25/98 1:06a Jimdose
// Added chatter
//
// 6 5/24/98 1:02a Jimdose
// Added monster hearing
//
// 5 5/23/98 6:29p Jimdose
// changed waitfordoor to a float
//
// 4 5/22/98 9:39p Jimdose
// Worked on ai
//
// 3 5/20/98 6:38p Jimdose
// working on ai
//
// 2 5/18/98 8:15p Jimdose
// Created file
//
// DESCRIPTION:
// Base class for character AI.
//
#ifndef __ACTOR_H__
#define __ACTOR_H__
#include "g_local.h"
#include "weapon.h"
#include "sentient.h"
#include "container.h"
#include "stack.h"
#include "navigate.h"
#include "behavior.h"
#include "scriptmaster.h"
#include "prioritystack.h"
extern Event EV_Actor_Start;
extern Event EV_Actor_Dead;
extern Event EV_Actor_PopAnim;
extern Event EV_Actor_LookAt;
extern Event EV_Actor_TurnTo;
extern Event EV_Actor_FinishedBehavior;
extern Event EV_Actor_NotifyBehavior;
extern Event EV_Actor_FinishedMove;
extern Event EV_Actor_FinishedAnim;
extern Event EV_Actor_WalkTo;
extern Event EV_Actor_RunTo;
extern Event EV_Actor_Anim;
extern Event EV_Actor_Attack;
extern Event EV_Actor_InPain;
extern Event EV_Actor_Gib;
extern Event EV_Actor_ForwardToBehavior;
extern Event EV_Actor_Aim;
extern Event EV_Actor_MeleeRange;
extern Event EV_Actor_MeleeDamage;
extern Event EV_Actor_AttackFinished;
extern Event EV_Actor_Attack;
extern Event EV_Actor_AttackPlayer;
typedef enum
{
RANGE_MELEE,
RANGE_NEAR,
RANGE_MID,
RANGE_FAR
} range_t;
typedef enum
{
ON_SIGHT,
ON_ATTACK
};
typedef enum
{
IGNORE,
ATTACK,
FLEE,
} reaction_t;
typedef enum
{
LIKES, // Will not fire at, even if attacked
TOLERATES, // Will attack when attacked
HATES, // Will attack on sight
WARY, // Will flee when attacked
FEARS, // Will flee on sight
NUM_DISPOSITIONS
} disposition_t;
typedef enum
{
IS_INANIMATE,
IS_MONSTER,
IS_ENEMY,
IS_CIVILIAN,
IS_FRIEND,
IS_ANIMAL,
NUM_ACTORTYPES
} actortype_t;
#define AI_CANWALK 0x00000001
#define AI_CANSWIM 0x00000002
#define AI_CANFLY 0x00000004
#define WEAK_WEIGHT 0.5
#define WEAK_HEALTH 20
#define STRONGER_WEIGHT 0.9
#define VISIBLE_WEIGHT 0.5
#define NEWENEMY_WEIGHT 0.75 // if he's a new enemy
//#define DAMAGE_WEIGHT 0.5 // If he's done a lot of damage to you
//#define WEAPON_WEIGHT 1.5 // How much the weapon influences you
class EXPORT_FROM_DLL StateInfo : public Class
{
public:
CLASS_PROTOTYPE( StateInfo );
StateInfo();
str action;
str response;
qboolean ignore;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void StateInfo::Archive
(
Archiver &arc
)
{
Class::Archive( arc );
arc.WriteString( action );
arc.WriteString( response );
arc.WriteBoolean( ignore );
}
inline EXPORT_FROM_DLL void StateInfo::Unarchive
(
Archiver &arc
)
{
Class::Unarchive( arc );
arc.ReadString( &action );
arc.ReadString( &response );
arc.ReadBoolean( &ignore );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<StateInfo *>;
#endif
class EXPORT_FROM_DLL ActorState : public Class
{
public:
CLASS_PROTOTYPE( ActorState );
str name;
str anim;
Event *animDoneEvent;
Behavior *behavior;
PathPtr path;
int thread;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -