📄 antagon.cpp
字号:
// (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
#include "stdafx.h"
#include "antagon.h"
#include "girl.h"
#include "stdio.h"
char antagonist::NumAttackers = 0;
char antagonist::NumObjects = 0;
antagonist::antagonist(sextype gender) : qentry()
{
personal tmp;
if (gender == FEMALE)
{
tmp.load(gallist());
m_dude = new girl(&tmp);
}
else
{
tmp.load(guylist());
m_dude = new dude(&tmp);
}
common();
}
antagonist::antagonist(CString& str, sextype gender) : qentry()
{
personal tmp;
if (gender == FEMALE)
{
tmp.load(str);
m_dude = new girl(&tmp);
}
else
{
tmp.load(str);
m_dude = new dude(&tmp);
}
common();
}
antagonist::~antagonist()
{
delete controller;
delete m_dude;
NumObjects--;
}
void antagonist::common()
{
if (NumObjects == 0)
NumAttackers = 0;
NumObjects++;
controller = new control(m_dude);
m_type = ANTAGONIST;
short dir = random(TC_PI2);
view ctmp;
ctmp.setx(tcsin(dir, (float) VIEWRANGE/7));
ctmp.setz(tccos(dir, (float) VIEWRANGE/7));
m_dude->setto(ctmp);
sethesitation(0);
motionless = FALSE;
AddedMyself = FALSE;
}
void antagonist::righthandhold(baseobject *b)
{
m_dude->righthandhold(b);
}
void antagonist::lefthandhold(baseobject *b)
{
m_dude->lefthandhold(b);
}
void antagonist::shirtcolor(COLORREF c)
{
m_dude->shirtcolor(c);
}
void antagonist::pantscolor(COLORREF c)
{
m_dude->pantscolor(c);
}
void antagonist::draw()
{
m_dude->draw();
controller->issuecommands();
if (!motionless)
{
direction where;
where = gowhere();
if (isinfront(where))
{
if (!walking)
controller->stopeverything();
startwalking();
walking = TRUE;
}
else
{
if (walking)
controller->stopeverything();
startturning(where);
walking = FALSE;
}
}
else
{
m_hesitatecnt--;
}
if (m_dude->isdead() && motionless != TRUE)
{
motionless = TRUE;
m_hesitation = -1;
m_hesitatecnt = 40;
controller->falldown();
}
}
char antagonist::isinfront(direction& d)
{
direction tmp;
tmp = m_dude->location().ydirection();
tmp = tmp-d;
return (char)(tmp < (direction) TC_PI_4 ||
tmp > (direction) -TC_PI_4);
}
void antagonist::startwalking()
{
float dist;
dist = m_dude->location().distanceto(Game->LevelPtr()->usercontrol->location());
if (AddedMyself == TRUE)
{
NumAttackers--;
AddedMyself = FALSE;
}
if (NumAttackers > 1 && dist > (VIEWRANGE*.1))
controller->stopeverything();
else if (NumAttackers == 0 && dist > (VIEWRANGE*.2))
controller->runfoward();
else if (NumAttackers == 0 && dist > (VIEWRANGE*.04))
controller->stepfoward();
else if (dist < (VIEWRANGE*.01) || (NumAttackers > 1 && dist < (VIEWRANGE*.1)))
controller->stepbackward();
else
{
controller->stopeverything();
if (++m_hesitatecnt > m_hesitation)
{
m_hesitatecnt = 0;
if (random(10) != 3)
controller->selectpunch(random(100),m_dude->normalpunch());
else
controller->selectpunch(random(100),m_dude->personalpunch());
}
else if (m_hesitatecnt > (m_hesitation / 3))
{
controller->block();
if (AddedMyself == FALSE)
{
NumAttackers++;
AddedMyself = TRUE;
}
}
}
}
void antagonist::startturning(direction& d)
{
if (m_dude->location().ydirection() > d)
controller->turnright();
else
controller->turnleft();
}
direction antagonist::gowhere()
{
return m_dude->location().ydirectionto(Game->LevelPtr()->usercontrol->location());
}
view& antagonist::location()
{
return m_dude->location();
}
CString& antagonist::dudelist(LPCTSTR file)
{
return picklist((float)random(100)/100.0f, (CString)file);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -