CAnimation have now derivated classes, and don't use union anymore.
This commit is contained in:
parent
187c304ca8
commit
f1e72f243d
45 changed files with 3008 additions and 1125 deletions
|
@ -62,7 +62,26 @@ source_group(action FILES ${action_SRCS})
|
|||
|
||||
set(animation_SRCS
|
||||
src/animation/animation.cpp
|
||||
src/animation/animation_attack.cpp
|
||||
src/animation/animation_die.cpp
|
||||
src/animation/animation_exactframe.cpp
|
||||
src/animation/animation_frame.cpp
|
||||
src/animation/animation_goto.cpp
|
||||
src/animation/animation_ifvar.cpp
|
||||
src/animation/animation_label.cpp
|
||||
src/animation/animation_move.cpp
|
||||
src/animation/animation_randomgoto.cpp
|
||||
src/animation/animation_randomrotate.cpp
|
||||
src/animation/animation_randomsound.cpp
|
||||
src/animation/animation_randomwait.cpp
|
||||
src/animation/animation_rotate.cpp
|
||||
src/animation/animation_setplayervar.cpp
|
||||
src/animation/animation_setvar.cpp
|
||||
src/animation/animation_sound.cpp
|
||||
src/animation/animation_spawnmissile.cpp
|
||||
src/animation/animation_spawnunit.cpp
|
||||
src/animation/animation_unbreakable.cpp
|
||||
src/animation/animation_wait.cpp
|
||||
)
|
||||
source_group(animation FILES ${animation_SRCS})
|
||||
|
||||
|
@ -376,7 +395,26 @@ set(stratagus_action_HDRS
|
|||
)
|
||||
|
||||
set(stratagus_animation_HDRS
|
||||
src/include/animation/animation_attack.h
|
||||
src/include/animation/animation_die.h
|
||||
src/include/animation/animation_exactframe.h
|
||||
src/include/animation/animation_frame.h
|
||||
src/include/animation/animation_goto.h
|
||||
src/include/animation/animation_ifvar.h
|
||||
src/include/animation/animation_label.h
|
||||
src/include/animation/animation_move.h
|
||||
src/include/animation/animation_randomgoto.h
|
||||
src/include/animation/animation_randomrotate.h
|
||||
src/include/animation/animation_randomsound.h
|
||||
src/include/animation/animation_randomwait.h
|
||||
src/include/animation/animation_rotate.h
|
||||
src/include/animation/animation_setplayervar.h
|
||||
src/include/animation/animation_setvar.h
|
||||
src/include/animation/animation_sound.h
|
||||
src/include/animation/animation_spawnmissile.h
|
||||
src/include/animation/animation_spawnunit.h
|
||||
src/include/animation/animation_unbreakable.h
|
||||
src/include/animation/animation_wait.h
|
||||
)
|
||||
|
||||
set(stratagus_generic_HDRS
|
||||
|
|
File diff suppressed because it is too large
Load diff
54
src/animation/animation_attack.cpp
Normal file
54
src/animation/animation_attack.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_attack.cpp - The animation . */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_attack.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Attack::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
unit.CurrentOrder()->OnAnimationAttack(unit);
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ void CAnimation_Attack::Init(const char* s)
|
||||
{
|
||||
}
|
||||
|
||||
//@}
|
|
@ -40,19 +40,24 @@
|
|||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
void AnimationDie_Action(CUnit &unit)
|
||||
/* virtual */ void CAnimation_Die::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim->Type == AnimationDie);
|
||||
Assert(unit.Anim.Anim == this);
|
||||
if (unit.Anim.Unbreakable) {
|
||||
fprintf(stderr, "Can't call \"die\" action in unbreakable section\n");
|
||||
Exit(1);
|
||||
}
|
||||
if (unit.Anim.Anim->D.Die.DeathType[0] != '\0') {
|
||||
unit.DamagedType = ExtraDeathIndex(unit.Anim.Anim->D.Die.DeathType);
|
||||
if (this->DeathType.empty() == false) {
|
||||
unit.DamagedType = ExtraDeathIndex(this->DeathType.c_str());
|
||||
}
|
||||
throw AnimationDie_Exception();
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Die::Init(const char* s)
|
||||
{
|
||||
this->DeathType = s;
|
||||
}
|
||||
|
||||
void AnimationDie_OnCatch(CUnit& unit)
|
||||
{
|
||||
unit.State = 0;
|
||||
|
|
59
src/animation/animation_exactframe.cpp
Normal file
59
src/animation/animation_exactframe.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_exactframe.cpp - The animation . */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_exactframe.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_ExactFrame::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
unit.Frame = ParseAnimInt(&unit);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_ExactFrame::Init(const char* s)
|
||||
{
|
||||
this->frame = s;
|
||||
}
|
||||
|
||||
int CAnimation_ExactFrame::ParseAnimInt(const CUnit *unit) const
|
||||
{
|
||||
return ::ParseAnimInt(unit, this->frame.c_str());
|
||||
}
|
||||
|
||||
//@}
|
60
src/animation/animation_frame.cpp
Normal file
60
src/animation/animation_frame.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_frame.cpp - The animation Frame. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_frame.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Frame::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
unit.Frame = ParseAnimInt(&unit);
|
||||
UnitUpdateHeading(unit);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Frame::Init(const char* s)
|
||||
{
|
||||
this->frame = s;
|
||||
}
|
||||
|
||||
int CAnimation_Frame::ParseAnimInt(const CUnit *unit) const
|
||||
{
|
||||
return ::ParseAnimInt(unit, this->frame.c_str());
|
||||
}
|
||||
|
||||
//@}
|
55
src/animation/animation_goto.cpp
Normal file
55
src/animation/animation_goto.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_goto.cpp - The animation Goto. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_goto.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Goto::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
unit.Anim.Anim = this->gotoLabel;
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Goto::Init(const char* s)
|
||||
{
|
||||
FindLabelLater(&this->gotoLabel, s);
|
||||
}
|
||||
|
||||
//@}
|
131
src/animation/animation_ifvar.cpp
Normal file
131
src/animation/animation_ifvar.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_ifvar.cpp - The animation IfVar. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_ifvar.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
//IfVar compare types
|
||||
#define IF_GREATER_EQUAL 1
|
||||
#define IF_GREATER 2
|
||||
#define IF_LESS_EQUAL 3
|
||||
#define IF_LESS 4
|
||||
#define IF_EQUAL 5
|
||||
#define IF_NOT_EQUAL 6
|
||||
|
||||
/* virtual */ void CAnimation_IfVar::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
const int lop = ParseAnimInt(&unit, this->leftVar.c_str());
|
||||
const int rop = ParseAnimInt(&unit, this->rightVar.c_str());
|
||||
bool go = false;
|
||||
|
||||
switch (this->type) {
|
||||
case IF_GREATER_EQUAL:
|
||||
go = (lop >= rop);
|
||||
break;
|
||||
case IF_GREATER:
|
||||
go = (lop > rop);
|
||||
break;
|
||||
case IF_LESS_EQUAL:
|
||||
go = (lop <= rop);
|
||||
break;
|
||||
case IF_LESS:
|
||||
go = (lop < rop);
|
||||
break;
|
||||
case IF_EQUAL:
|
||||
go = (lop == rop);
|
||||
break;
|
||||
case IF_NOT_EQUAL:
|
||||
go = (lop != rop);
|
||||
break;
|
||||
}
|
||||
if (go) {
|
||||
unit.Anim.Anim = this->gotoLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_IfVar::Init(const char* s)
|
||||
{
|
||||
char *op2 = const_cast<char*>(s);
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->leftVar = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->rightVar = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
if (!strcmp(op2,">=")) {
|
||||
this->type = 1;
|
||||
} else if (!strcmp(op2,">")) {
|
||||
this->type = 2;
|
||||
} else if (!strcmp(op2,"<=")) {
|
||||
this->type = 3;
|
||||
} else if (!strcmp(op2,"<")) {
|
||||
this->type = 4;
|
||||
} else if (!strcmp(op2,"==")) {
|
||||
this->type = 5;
|
||||
} else if (!strcmp(op2,"!=")) {
|
||||
this->type = 6;
|
||||
} else {
|
||||
this->type = atoi(op2);
|
||||
}
|
||||
op2 = next;
|
||||
while (*op2 == ' ') {
|
||||
++op2;
|
||||
}
|
||||
FindLabelLater(&this->gotoLabel, op2);
|
||||
}
|
||||
|
||||
//@}
|
52
src/animation/animation_label.cpp
Normal file
52
src/animation/animation_label.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_label.cpp - The animation Label. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_label.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Label::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Label::Init(const char* s)
|
||||
{
|
||||
}
|
||||
|
||||
//@}
|
56
src/animation/animation_move.cpp
Normal file
56
src/animation/animation_move.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_move.cpp - The animation Move. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_move.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Move::Action(CUnit& unit, int &move, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
Assert(!move);
|
||||
|
||||
move = ParseAnimInt(&unit, this->moveStr.c_str());
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Move::Init(const char* s)
|
||||
{
|
||||
this->moveStr = s;
|
||||
}
|
||||
|
||||
//@}
|
68
src/animation/animation_randomgoto.cpp
Normal file
68
src/animation/animation_randomgoto.cpp
Normal file
|
@ -0,0 +1,68 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomgoto.cpp - The animation RandomGoto. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_randomgoto.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_RandomGoto::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
if (SyncRand() % 100 < ParseAnimInt(&unit, this->randomStr.c_str())) {
|
||||
unit.Anim.Anim = this->gotoLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_RandomGoto::Init(const char* s)
|
||||
{
|
||||
char *op2 = const_cast<char*>(s);
|
||||
char *label = strchr(op2, ' ');
|
||||
|
||||
if (!label) {
|
||||
// LuaError(l, "Missing random-goto label");
|
||||
} else {
|
||||
while (*label == ' ') {
|
||||
*label++ = '\0';
|
||||
}
|
||||
}
|
||||
this->randomStr = op2;
|
||||
FindLabelLater(&this->gotoLabel, label);
|
||||
}
|
||||
|
||||
//@}
|
60
src/animation/animation_randomrotate.cpp
Normal file
60
src/animation/animation_randomrotate.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomrotate.cpp - The animation RandomRotate. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_randomrotate.h"
|
||||
|
||||
#include "animation/animation_rotate.h"
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_RandomRotate::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
if ((SyncRand() >> 8) & 1) {
|
||||
UnitRotate(unit, -ParseAnimInt(&unit, this->rotateStr.c_str()));
|
||||
} else {
|
||||
UnitRotate(unit, ParseAnimInt(&unit, this->rotateStr.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_RandomRotate::Init(const char* s)
|
||||
{
|
||||
this->rotateStr = s;
|
||||
}
|
||||
|
||||
//@}
|
82
src/animation/animation_randomsound.cpp
Normal file
82
src/animation/animation_randomsound.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomsound.cpp - The animation RandomSound. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_randomsound.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "map.h"
|
||||
#include "sound.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_RandomSound::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
if (unit.IsVisible(*ThisPlayer) || ReplayRevealMap) {
|
||||
const size_t index = SyncRand() % this->sounds.size();
|
||||
PlayUnitSound(unit, this->sounds[index].Sound);
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_RandomSound::Init(const char* s)
|
||||
{
|
||||
// FIXME : Bad const cast.
|
||||
char *op2 = const_cast<char*>(s);
|
||||
int count = 0;
|
||||
|
||||
while (op2 && *op2) {
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
++count;
|
||||
this->sounds.push_back(SoundConfig(op2));
|
||||
op2 = next;
|
||||
}
|
||||
}
|
||||
|
||||
void CAnimation_RandomSound::MapSound()
|
||||
{
|
||||
for (size_t i = 0; i != this->sounds.size(); ++i) {
|
||||
this->sounds[i].Sound = SoundForName(this->sounds[i].Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@}
|
71
src/animation/animation_randomwait.cpp
Normal file
71
src/animation/animation_randomwait.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomwait.cpp - The animation RandomWait. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_RandomWait.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_RandomWait::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
const int arg1 = ParseAnimInt(&unit, this->minWait.c_str());
|
||||
const int arg2 = ParseAnimInt(&unit, this->maxWait.c_str());
|
||||
|
||||
unit.Anim.Wait = arg1 + SyncRand() % (arg2 - arg1 + 1);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_RandomWait::Init(const char* s)
|
||||
{
|
||||
char* op2 = const_cast<char*>(s);
|
||||
char *next = strchr(op2, ' ');
|
||||
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->minWait = new_strdup(op2);
|
||||
op2 = next;
|
||||
while (*op2 == ' ') {
|
||||
++op2;
|
||||
}
|
||||
this->maxWait = new_strdup(op2);
|
||||
}
|
||||
|
||||
//@}
|
79
src/animation/animation_rotate.cpp
Normal file
79
src/animation/animation_rotate.cpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_rotate.cpp - The animation Rotate. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_rotate.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/**
|
||||
** Rotate a unit
|
||||
**
|
||||
** @param unit Unit to rotate
|
||||
** @param rotate Number of frames to rotate (>0 clockwise, <0 counterclockwise)
|
||||
*/
|
||||
void UnitRotate(CUnit &unit, int rotate)
|
||||
{
|
||||
unit.Direction += rotate * 256 / unit.Type->NumDirections;
|
||||
UnitUpdateHeading(unit);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Rotate::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
if (!strcmp(this->rotateStr.c_str(), "target") && unit.CurrentOrder()->HasGoal()) {
|
||||
COrder &order = *unit.CurrentOrder();
|
||||
const CUnit &target = *order.GetGoal();
|
||||
if (target.Destroyed) {
|
||||
order.ClearGoal();
|
||||
return;
|
||||
}
|
||||
const Vec2i pos = target.tilePos + target.Type->GetHalfTileSize() - unit.tilePos;
|
||||
UnitHeadingFromDeltaXY(unit, pos);
|
||||
} else {
|
||||
UnitRotate(unit, ParseAnimInt(&unit, this->rotateStr.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Rotate::Init(const char* s)
|
||||
{
|
||||
this->rotateStr = s;
|
||||
}
|
||||
|
||||
//@}
|
264
src/animation/animation_setplayervar.cpp
Normal file
264
src/animation/animation_setplayervar.cpp
Normal file
|
@ -0,0 +1,264 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_setplayervar.cpp - The animation SetPlayerVar. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_setplayervar.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
//Modify types
|
||||
#define MOD_ADD 1
|
||||
#define MOD_SUB 2
|
||||
#define MOD_MUL 3
|
||||
#define MOD_DIV 4
|
||||
#define MOD_MOD 5
|
||||
|
||||
/**
|
||||
** Gets the player data.
|
||||
**
|
||||
** @param player Player number.
|
||||
** @param prop Player's property.
|
||||
** @param arg Additional argument (for resource and unit).
|
||||
**
|
||||
** @return Returning value (only integer).
|
||||
*/
|
||||
int GetPlayerData(int player, const char *prop, const char *arg)
|
||||
{
|
||||
if (!strcmp(prop, "RaceName")) {
|
||||
return Players[player].Race;
|
||||
} else if (!strcmp(prop, "Resources")) {
|
||||
const std::string resource(arg);
|
||||
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
if (resource == DefaultResourceNames[i]) {
|
||||
return Players[player].Resources[i];
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Invalid resource \"%s\"", resource.c_str());
|
||||
Exit(1);
|
||||
} else if (!strcmp(prop, "MaxResources")) {
|
||||
const std::string resource(arg);
|
||||
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
if (resource == DefaultResourceNames[i]) {
|
||||
return Players[player].MaxResources[i];
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Invalid resource \"%s\"", resource.c_str());
|
||||
Exit(1);
|
||||
} else if (!strcmp(prop, "UnitTypesCount")) {
|
||||
const std::string unit(arg);
|
||||
CUnitType *type = UnitTypeByIdent(unit);
|
||||
return Players[player].UnitTypesCount[type->Slot];
|
||||
} else if (!strcmp(prop, "AiEnabled")) {
|
||||
return Players[player].AiEnabled;
|
||||
} else if (!strcmp(prop, "TotalNumUnits")) {
|
||||
return Players[player].GetUnitCount();
|
||||
} else if (!strcmp(prop, "NumBuildings")) {
|
||||
return Players[player].NumBuildings;
|
||||
} else if (!strcmp(prop, "Supply")) {
|
||||
return Players[player].Supply;
|
||||
} else if (!strcmp(prop, "Demand")) {
|
||||
return Players[player].Demand;
|
||||
} else if (!strcmp(prop, "UnitLimit")) {
|
||||
return Players[player].UnitLimit;
|
||||
} else if (!strcmp(prop, "BuildingLimit")) {
|
||||
return Players[player].BuildingLimit;
|
||||
} else if (!strcmp(prop, "TotalUnitLimit")) {
|
||||
return Players[player].TotalUnitLimit;
|
||||
} else if (!strcmp(prop, "Score")) {
|
||||
return Players[player].Score;
|
||||
} else if (!strcmp(prop, "TotalUnits")) {
|
||||
return Players[player].TotalUnits;
|
||||
} else if (!strcmp(prop, "TotalBuildings")) {
|
||||
return Players[player].TotalBuildings;
|
||||
} else if (!strcmp(prop, "TotalResources")) {
|
||||
const std::string resource(arg);
|
||||
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
if (resource == DefaultResourceNames[i]) {
|
||||
return Players[player].TotalResources[i];
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Invalid resource \"%s\"", resource.c_str());
|
||||
Exit(1);
|
||||
} else if (!strcmp(prop, "TotalRazings")) {
|
||||
return Players[player].TotalRazings;
|
||||
} else if (!strcmp(prop, "TotalKills")) {
|
||||
return Players[player].TotalKills;
|
||||
} else {
|
||||
fprintf(stderr, "Invalid field: %s" _C_ prop);
|
||||
Exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Sets the player data.
|
||||
*/
|
||||
static void SetPlayerData(int player, const char *prop, const char *arg, int value)
|
||||
{
|
||||
if (!strcmp(prop, "RaceName")) {
|
||||
Players[player].Race = value;
|
||||
} else if (!strcmp(prop, "Resources")) {
|
||||
const std::string res(arg);
|
||||
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
if (res == DefaultResourceNames[i]) {
|
||||
Players[player].SetResource(i,value);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Invalid resource \"%s\"" _C_ res.c_str());
|
||||
Exit(1);
|
||||
} else if (!strcmp(prop, "UnitLimit")) {
|
||||
Players[player].UnitLimit = value;
|
||||
} else if (!strcmp(prop, "BuildingLimit")) {
|
||||
Players[player].BuildingLimit = value;
|
||||
} else if (!strcmp(prop, "TotalUnitLimit")) {
|
||||
Players[player].TotalUnitLimit = value;
|
||||
} else if (!strcmp(prop, "Score")) {
|
||||
Players[player].Score = value;
|
||||
} else if (!strcmp(prop, "TotalUnits")) {
|
||||
Players[player].TotalUnits = value;
|
||||
} else if (!strcmp(prop, "TotalBuildings")) {
|
||||
Players[player].TotalBuildings = value;
|
||||
} else if (!strcmp(prop, "TotalResources")) {
|
||||
const std::string res(arg);
|
||||
|
||||
for (int i = 0; i < MaxCosts; ++i) {
|
||||
if (res == DefaultResourceNames[i]) {
|
||||
Players[player].TotalResources[i] = value;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "Invalid resource \"%s\"" _C_ res.c_str());
|
||||
Exit(1);
|
||||
} else if (!strcmp(prop, "TotalRazings")) {
|
||||
Players[player].TotalRazings = value;
|
||||
} else if (!strcmp(prop, "TotalKills")) {
|
||||
Players[player].TotalKills = value;
|
||||
} else {
|
||||
fprintf(stderr, "Invalid field: %s" _C_ prop);
|
||||
Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ void CAnimation_SetPlayerVar::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
const char *var = this->varStr.c_str();
|
||||
const char *arg = this->argStr.c_str();
|
||||
int playerId = ParseAnimInt(&unit, this->playerStr.c_str());
|
||||
int rop = ParseAnimInt(&unit, this->valueStr.c_str());
|
||||
int data = GetPlayerData(playerId, var, arg);
|
||||
|
||||
switch (this->mod) {
|
||||
case MOD_ADD:
|
||||
data += rop;
|
||||
break;
|
||||
case MOD_SUB:
|
||||
data -= rop;
|
||||
break;
|
||||
case MOD_MUL:
|
||||
data *= rop;
|
||||
break;
|
||||
case MOD_DIV:
|
||||
if (!rop) {
|
||||
fprintf(stderr, "Division by zero in AnimationSetPlayerVar\n");
|
||||
Exit(1);
|
||||
}
|
||||
data /= rop;
|
||||
break;
|
||||
case MOD_MOD:
|
||||
if (!rop) {
|
||||
fprintf(stderr, "Division by zero in AnimationSetPlayerVar\n");
|
||||
Exit(1);
|
||||
}
|
||||
data %= rop;
|
||||
break;
|
||||
default:
|
||||
data = rop;
|
||||
}
|
||||
rop = data;
|
||||
SetPlayerData(playerId, var, arg, rop);
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_SetPlayerVar::Init(const char* s)
|
||||
{
|
||||
char *op2 = const_cast<char*>(s);
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->playerStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->varStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->mod = atoi(op2);
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->valueStr = op2;
|
||||
op2 = next;
|
||||
while (*op2 == ' ') {
|
||||
++op2;
|
||||
}
|
||||
this->argStr = op2;
|
||||
}
|
||||
|
||||
//@}
|
173
src/animation/animation_setvar.cpp
Normal file
173
src/animation/animation_setvar.cpp
Normal file
|
@ -0,0 +1,173 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_setvar.cpp - The animation SetVar. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_setvar.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
//Modify types
|
||||
#define MOD_ADD 1
|
||||
#define MOD_SUB 2
|
||||
#define MOD_MUL 3
|
||||
#define MOD_DIV 4
|
||||
#define MOD_MOD 5
|
||||
|
||||
|
||||
/* virtual */ void CAnimation_SetVar::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
char arg1[128];
|
||||
CUnit *goal = &unit;
|
||||
|
||||
strcpy(arg1, this->varStr.c_str());
|
||||
const int rop = ParseAnimInt(&unit, this->valueStr.c_str());
|
||||
|
||||
char *next = strchr(arg1, '.');
|
||||
if (next == NULL) {
|
||||
fprintf(stderr, "Need also specify the variable '%s' tag \n" _C_ arg1);
|
||||
Exit(1);
|
||||
} else {
|
||||
*next ='\0';
|
||||
}
|
||||
const int index = UnitTypeVar.VariableNameLookup[arg1];// User variables
|
||||
if (index == -1) {
|
||||
fprintf(stderr, "Bad variable name '%s'\n" _C_ arg1);
|
||||
Exit(1);
|
||||
}
|
||||
if (this->unitSlotStr.empty() == false) {
|
||||
switch (this->unitSlotStr[0]) {
|
||||
case 'l': // last created unit
|
||||
goal = Units[NumUnits - 1];
|
||||
break;
|
||||
case 't': // target unit
|
||||
goal = unit.CurrentOrder()->GetGoal();
|
||||
break;
|
||||
case 's': // unit self (no use)
|
||||
goal = &unit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!goal) {
|
||||
return;
|
||||
}
|
||||
int value = 0;
|
||||
if (!strcmp(next + 1, "Value")) {
|
||||
value = goal->Variable[index].Value;
|
||||
} else if (!strcmp(next + 1, "Max")) {
|
||||
value = goal->Variable[index].Max;
|
||||
} else if (!strcmp(next + 1,"Increase")) {
|
||||
value = goal->Variable[index].Increase;
|
||||
} else if (!strcmp(next + 1, "Enable")) {
|
||||
value = goal->Variable[index].Enable;
|
||||
}
|
||||
switch (this->mod) {
|
||||
case MOD_ADD:
|
||||
value += rop;
|
||||
break;
|
||||
case MOD_SUB:
|
||||
value -= rop;
|
||||
break;
|
||||
case MOD_MUL:
|
||||
value *= rop;
|
||||
break;
|
||||
case MOD_DIV:
|
||||
if (!rop) {
|
||||
fprintf(stderr, "Division by zero in AnimationSetVar\n");
|
||||
Exit(1);
|
||||
}
|
||||
value /= rop;
|
||||
break;
|
||||
case MOD_MOD:
|
||||
if (!rop) {
|
||||
fprintf(stderr, "Division by zero in AnimationSetVar\n");
|
||||
Exit(1);
|
||||
}
|
||||
value %= rop;
|
||||
break;
|
||||
default:
|
||||
value = rop;
|
||||
}
|
||||
if (!strcmp(next + 1, "Value")) {
|
||||
goal->Variable[index].Value = value;
|
||||
} else if (!strcmp(next + 1, "Max")) {
|
||||
goal->Variable[index].Max = value;
|
||||
} else if (!strcmp(next + 1, "Increase")) {
|
||||
goal->Variable[index].Increase = value;
|
||||
} else if (!strcmp(next + 1, "Enable")) {
|
||||
goal->Variable[index].Enable = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_SetVar::Init(const char* s)
|
||||
{
|
||||
char *op2 = const_cast<char*>(s);
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->varStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->mod = atoi(op2);
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->valueStr = op2;
|
||||
if (next) {
|
||||
op2 = next;
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
this->unitSlotStr = op2;
|
||||
}
|
||||
}
|
||||
|
||||
//@}
|
63
src/animation/animation_sound.cpp
Normal file
63
src/animation/animation_sound.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_sound.cpp - The animation Sound. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_sound.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "map.h"
|
||||
#include "sound.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Sound::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
if (unit.IsVisible(*ThisPlayer) || ReplayRevealMap) {
|
||||
PlayUnitSound(unit, this->sound.Sound);
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Sound::Init(const char* s)
|
||||
{
|
||||
this->sound.Name = s;
|
||||
}
|
||||
|
||||
void CAnimation_Sound::MapSound()
|
||||
{
|
||||
this->sound.Sound = SoundForName(this->sound.Name);
|
||||
}
|
||||
|
||||
//@}
|
214
src/animation/animation_spawnmissile.cpp
Normal file
214
src/animation/animation_spawnmissile.cpp
Normal file
|
@ -0,0 +1,214 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_spawnmissile.cpp - The animation SpawnMissile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_spawnmissile.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "animation.h"
|
||||
#include "map.h"
|
||||
#include "missile.h"
|
||||
#include "unit.h"
|
||||
|
||||
//SpawnMissile flags
|
||||
#define ANIM_SM_DAMAGE 1
|
||||
#define ANIM_SM_TOTARGET 2
|
||||
#define ANIM_SM_PIXEL 4
|
||||
#define ANIM_SM_RELTARGET 8
|
||||
#define ANIM_SM_RANGED 16
|
||||
|
||||
/**
|
||||
** Parse flags list in animation frame.
|
||||
**
|
||||
** @param unit Unit of the animation.
|
||||
** @param parseflag Flag list to parse.
|
||||
**
|
||||
** @return The parsed value.
|
||||
*/
|
||||
static int ParseAnimFlags(CUnit &unit, const char *parseflag)
|
||||
{
|
||||
char s[100];
|
||||
int flags = 0;
|
||||
|
||||
strcpy(s, parseflag);
|
||||
char* cur = s;
|
||||
char* next = s;
|
||||
while (next){
|
||||
next = strchr(cur, '.');
|
||||
if (next){
|
||||
*next = '\0';
|
||||
++next;
|
||||
}
|
||||
if (unit.Anim.Anim->Type == AnimationSpawnMissile) {
|
||||
if (!strcmp(cur, "damage")) {
|
||||
flags |= ANIM_SM_DAMAGE;
|
||||
} else if (!strcmp(cur, "totarget")) {
|
||||
flags |= ANIM_SM_TOTARGET;
|
||||
} else if (!strcmp(cur, "pixel")) {
|
||||
flags |= ANIM_SM_PIXEL;
|
||||
} else if (!strcmp(cur, "reltarget")) {
|
||||
flags |= ANIM_SM_RELTARGET;
|
||||
} else if (!strcmp(cur, "ranged")) {
|
||||
flags |= ANIM_SM_RANGED;
|
||||
}
|
||||
}
|
||||
cur = next;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ void CAnimation_SpawnMissile::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
const int startx = ParseAnimInt(&unit, this->startX.c_str());
|
||||
const int starty = ParseAnimInt(&unit, this->startY.c_str());
|
||||
const int destx = ParseAnimInt(&unit, this->destX.c_str());
|
||||
const int desty = ParseAnimInt(&unit, this->destY.c_str());
|
||||
const int flags = ParseAnimFlags(unit, this->flags.c_str());
|
||||
CUnit *goal;
|
||||
PixelPos start;
|
||||
PixelPos dest;
|
||||
|
||||
if ((flags & ANIM_SM_RELTARGET)) {
|
||||
goal = unit.CurrentOrder()->GetGoal();
|
||||
} else {
|
||||
goal = &unit;
|
||||
}
|
||||
if (!goal || goal->Destroyed || goal->Removed) {
|
||||
return;
|
||||
}
|
||||
if ((flags & ANIM_SM_PIXEL)) {
|
||||
start.x = goal->tilePos.x * PixelTileSize.x + goal->IX + startx;
|
||||
start.y = goal->tilePos.y * PixelTileSize.y + goal->IY + starty;
|
||||
} else {
|
||||
start.x = (goal->tilePos.x + startx) * PixelTileSize.x + PixelTileSize.x / 2;
|
||||
start.y = (goal->tilePos.y + starty) * PixelTileSize.y + PixelTileSize.y / 2;
|
||||
}
|
||||
if ((flags & ANIM_SM_TOTARGET)) {
|
||||
CUnit *target = goal->CurrentOrder()->GetGoal();
|
||||
Assert(goal->CurrentAction() == UnitActionAttack);
|
||||
if (!target || target->Destroyed || target->Removed) {
|
||||
return;
|
||||
}
|
||||
if (flags & ANIM_SM_PIXEL) {
|
||||
dest.x = target->tilePos.x * PixelTileSize.x + target->IX + destx;
|
||||
dest.y = target->tilePos.y * PixelTileSize.y + target->IY + desty;
|
||||
} else {
|
||||
dest.x = (target->tilePos.x + destx) * PixelTileSize.x + target->Type->TileWidth * PixelTileSize.x / 2;
|
||||
dest.y = (target->tilePos.y + desty) * PixelTileSize.y + target->Type->TileHeight * PixelTileSize.y / 2;
|
||||
}
|
||||
} else {
|
||||
if ((flags & ANIM_SM_PIXEL)) {
|
||||
dest.x = goal->tilePos.x * PixelTileSize.x + goal->IX + destx;
|
||||
dest.y = goal->tilePos.y * PixelTileSize.y + goal->IY + desty;
|
||||
} else {
|
||||
dest.x = (goal->tilePos.x + destx) * PixelTileSize.x + goal->Type->TileWidth * PixelTileSize.x / 2;
|
||||
dest.y = (goal->tilePos.y + desty) * PixelTileSize.y + goal->Type->TileHeight * PixelTileSize.y / 2;
|
||||
}
|
||||
}
|
||||
const int dist = goal->MapDistanceTo(dest.x, dest.y);
|
||||
if ((flags & ANIM_SM_RANGED) && !(flags & ANIM_SM_PIXEL)
|
||||
&& dist > goal->Stats->Variables[ATTACKRANGE_INDEX].Max
|
||||
&& dist < goal->Type->MinAttackRange) {
|
||||
} else {
|
||||
Missile *missile = MakeMissile(*MissileTypeByIdent(this->missile.c_str()), start, dest);
|
||||
if (flags & ANIM_SM_DAMAGE) {
|
||||
missile->SourceUnit = &unit;
|
||||
unit.RefsIncrease();
|
||||
}
|
||||
if (flags & ANIM_SM_TOTARGET) {
|
||||
missile->TargetUnit = goal->CurrentOrder()->GetGoal();
|
||||
goal->CurrentOrder()->GetGoal()->RefsIncrease();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_SpawnMissile::Init(const char* s)
|
||||
{
|
||||
// FIXME : Bad const_cast
|
||||
char* op2 = const_cast<char*>(s);
|
||||
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->missile = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
this->startX = op2;
|
||||
}
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
this->startY = op2;
|
||||
}
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
this->destX = op2;
|
||||
}
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
this->destY = op2;
|
||||
}
|
||||
op2 = next;
|
||||
if (next) {
|
||||
while (*op2 == ' ') {
|
||||
++op2;
|
||||
}
|
||||
this->flags = op2;
|
||||
}
|
||||
}
|
||||
|
||||
//@}
|
171
src/animation/animation_spawnunit.cpp
Normal file
171
src/animation/animation_spawnunit.cpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_spawnunit.cpp - The animation SpawnUnit. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_spawnunit.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "map.h"
|
||||
#include "unit.h"
|
||||
|
||||
/**
|
||||
** Find the nearest position at which unit can be placed.
|
||||
**
|
||||
** @param type Type of the dropped unit.
|
||||
** @param goalPos Goal map tile position.
|
||||
** @param resPos Holds the nearest point.
|
||||
** @param heading preferense side to drop out of.
|
||||
*/
|
||||
static void FindNearestDrop(const CUnitType &type, const Vec2i &goalPos, Vec2i &resPos, int heading)
|
||||
{
|
||||
int addx = 0;
|
||||
int addy = 0;
|
||||
Vec2i pos = goalPos;
|
||||
|
||||
if (heading < LookingNE || heading > LookingNW) {
|
||||
goto starts;
|
||||
} else if (heading < LookingSE) {
|
||||
goto startw;
|
||||
} else if (heading < LookingSW) {
|
||||
goto startn;
|
||||
} else {
|
||||
goto starte;
|
||||
}
|
||||
|
||||
// FIXME: don't search outside of the map
|
||||
for (;;) {
|
||||
startw:
|
||||
for (int i = addy; i--; ++pos.y) {
|
||||
if (UnitTypeCanBeAt(type, pos)) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
++addx;
|
||||
starts:
|
||||
for (int i = addx; i--; ++pos.x) {
|
||||
if (UnitTypeCanBeAt(type, pos)) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
++addy;
|
||||
starte:
|
||||
for (int i = addy; i--; --pos.y) {
|
||||
if (UnitTypeCanBeAt(type, pos)) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
++addx;
|
||||
startn:
|
||||
for (int i = addx; i--; --pos.x) {
|
||||
if (UnitTypeCanBeAt(type, pos)) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
++addy;
|
||||
}
|
||||
|
||||
found:
|
||||
resPos = pos;
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_SpawnUnit::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
|
||||
const int offX = ParseAnimInt(&unit, this->offXStr.c_str());
|
||||
const int offY = ParseAnimInt(&unit, this->offYStr.c_str());
|
||||
const int range = ParseAnimInt(&unit, this->rangeStr.c_str());
|
||||
const int playerId = ParseAnimInt(&unit, this->playerStr.c_str());
|
||||
CPlayer &player = Players[playerId];
|
||||
const Vec2i pos = { unit.tilePos.x + offX, unit.tilePos.y + offY};
|
||||
CUnitType *type = UnitTypeByIdent(this->unitStr.c_str());
|
||||
Vec2i resPos;
|
||||
DebugPrint("Creating a %s\n" _C_ type->Name.c_str());
|
||||
FindNearestDrop(*type, pos, resPos, LookingW);
|
||||
if (MapDistance(pos, resPos) <= range) {
|
||||
CUnit *target = MakeUnit(*type, &player);
|
||||
if (target != NoUnitP) {
|
||||
target->tilePos = resPos;
|
||||
target->Place(resPos);
|
||||
//DropOutOnSide(*target, LookingW, NULL);
|
||||
} else {
|
||||
DebugPrint("Unable to allocate Unit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_SpawnUnit::Init(const char* s)
|
||||
{
|
||||
char* op2 = const_cast<char*>(s);
|
||||
char *next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->unitStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->offXStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->offYStr = op2;
|
||||
op2 = next;
|
||||
next = strchr(op2, ' ');
|
||||
if (next) {
|
||||
while (*next == ' ') {
|
||||
*next++ = '\0';
|
||||
}
|
||||
}
|
||||
this->rangeStr = op2;
|
||||
op2 = next;
|
||||
while (*op2 == ' ') {
|
||||
++op2;
|
||||
}
|
||||
this->playerStr = op2;
|
||||
}
|
||||
|
||||
//@}
|
62
src/animation/animation_unbreakable.cpp
Normal file
62
src/animation/animation_unbreakable.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_unbreakable.cpp - The animation Unbreakable. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_unbreakable.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Unbreakable::Action(CUnit& unit, int &/*move*/, int /*scale*/) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
Assert(unit.Anim.Unbreakable ^ this->state);
|
||||
|
||||
unit.Anim.Unbreakable = this->state;
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Unbreakable::Init(const char* s)
|
||||
{
|
||||
if (!strcmp(s, "begin")) {
|
||||
this->state = 1;
|
||||
} else if (!strcmp(s, "end")) {
|
||||
this->state = 0;
|
||||
} else {
|
||||
// LuaError(l, "Unbreakable must be 'begin' or 'end'. Found: %s" _C_ op2);
|
||||
}
|
||||
}
|
||||
|
||||
//@}
|
63
src/animation/animation_wait.cpp
Normal file
63
src/animation/animation_wait.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_wait.cpp - The animation Wait. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
//@{
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Includes
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#include "stratagus.h"
|
||||
|
||||
#include "animation/animation_wait.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* virtual */ void CAnimation_Wait::Action(CUnit& unit, int &/*move*/, int scale) const
|
||||
{
|
||||
Assert(unit.Anim.Anim == this);
|
||||
unit.Anim.Wait = ParseAnimInt(&unit, this->wait.c_str()) << scale >> 8;
|
||||
if (unit.Variable[SLOW_INDEX].Value) { // unit is slowed down
|
||||
unit.Anim.Wait <<= 1;
|
||||
}
|
||||
if (unit.Variable[HASTE_INDEX].Value && unit.Anim.Wait > 1) { // unit is accelerated
|
||||
unit.Anim.Wait >>= 1;
|
||||
}
|
||||
if (unit.Anim.Wait <= 0) {
|
||||
unit.Anim.Wait = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void CAnimation_Wait::Init(const char* s)
|
||||
{
|
||||
this->wait = s;
|
||||
}
|
||||
|
||||
//@}
|
|
@ -35,8 +35,7 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "sound.h"
|
||||
|
||||
#include "upgrade_structs.h" // MaxCost
|
||||
#define ANIMATIONS_DEATHTYPES 40
|
||||
|
||||
class CFile;
|
||||
|
@ -78,151 +77,14 @@ enum AnimationType {
|
|||
|
||||
class CAnimation {
|
||||
public:
|
||||
CAnimation(AnimationType type) : Type(type), Next(NULL) {
|
||||
memset(&D, 0, sizeof(D));
|
||||
}
|
||||
CAnimation(AnimationType type) : Type(type), Next(NULL) {}
|
||||
|
||||
~CAnimation() {
|
||||
if (Type == AnimationFrame || Type == AnimationExactFrame)
|
||||
delete[] D.Frame.Frame;
|
||||
else if (Type == AnimationWait)
|
||||
delete[] D.Wait.Wait;
|
||||
else if (Type == AnimationRandomWait) {
|
||||
delete[] D.RandomWait.MinWait;
|
||||
delete[] D.RandomWait.MaxWait;
|
||||
}
|
||||
else if (Type == AnimationRotate || Type == AnimationRandomRotate)
|
||||
delete[] D.Rotate.Rotate;
|
||||
else if (Type == AnimationMove)
|
||||
delete[] D.Move.Move;
|
||||
else if (Type == AnimationSound)
|
||||
delete[] D.Sound.Name;
|
||||
else if (Type == AnimationSpawnMissile)
|
||||
{
|
||||
delete[] D.SpawnMissile.Missile;
|
||||
delete[] D.SpawnMissile.StartX;
|
||||
delete[] D.SpawnMissile.StartY;
|
||||
delete[] D.SpawnMissile.DestX;
|
||||
delete[] D.SpawnMissile.DestY;
|
||||
delete[] D.SpawnMissile.Flags;
|
||||
}
|
||||
else if (Type == AnimationSpawnUnit)
|
||||
{
|
||||
delete[] D.SpawnUnit.Unit;
|
||||
delete[] D.SpawnUnit.OffX;
|
||||
delete[] D.SpawnUnit.OffY;
|
||||
delete[] D.SpawnUnit.Range;
|
||||
delete[] D.SpawnUnit.Player;
|
||||
}
|
||||
else if (Type == AnimationIfVar)
|
||||
{
|
||||
delete[] D.IfVar.LeftVar;
|
||||
delete[] D.IfVar.RightVar;
|
||||
}
|
||||
else if (Type == AnimationSetVar)
|
||||
{
|
||||
delete[] D.SetVar.Var;
|
||||
delete[] D.SetVar.Value;
|
||||
delete[] D.SetVar.UnitSlot;
|
||||
}
|
||||
else if (Type == AnimationSetPlayerVar)
|
||||
{
|
||||
delete[] D.SetPlayerVar.Player;
|
||||
delete[] D.SetPlayerVar.Var;
|
||||
delete[] D.SetPlayerVar.Arg;
|
||||
delete[] D.SetPlayerVar.Value;
|
||||
}
|
||||
else if (Type == AnimationDie)
|
||||
{
|
||||
delete[] D.Die.DeathType;
|
||||
}
|
||||
else if (Type == AnimationRandomSound) {
|
||||
for (unsigned int i = 0; i < D.RandomSound.NumSounds; ++i) {
|
||||
delete[] D.RandomSound.Name[i];
|
||||
}
|
||||
delete[] D.RandomSound.Name;
|
||||
delete[] D.RandomSound.Sound;
|
||||
}
|
||||
}
|
||||
virtual ~CAnimation() {}
|
||||
|
||||
|
||||
static void Action(CUnit &unit, int &move, int scale);
|
||||
virtual void Action(CUnit &unit, int &move, int scale) const = 0;
|
||||
virtual void Init(const char* s) {}
|
||||
|
||||
const AnimationType Type;
|
||||
union {
|
||||
struct {
|
||||
const char *Frame;
|
||||
} Frame;
|
||||
struct {
|
||||
const char *Wait;
|
||||
} Wait;
|
||||
struct {
|
||||
const char *MinWait;
|
||||
const char *MaxWait;
|
||||
} RandomWait;
|
||||
struct {
|
||||
const char *Name;
|
||||
CSound *Sound;
|
||||
} Sound;
|
||||
struct {
|
||||
const char **Name;
|
||||
CSound **Sound;
|
||||
unsigned int NumSounds;
|
||||
} RandomSound;
|
||||
struct {
|
||||
const char *Rotate;
|
||||
} Rotate;
|
||||
struct {
|
||||
const char *Move;
|
||||
} Move;
|
||||
struct {
|
||||
int Begin;
|
||||
} Unbreakable;
|
||||
struct {
|
||||
CAnimation *Goto;
|
||||
} Goto;
|
||||
struct {
|
||||
const char *Random;
|
||||
CAnimation *Goto;
|
||||
} RandomGoto;
|
||||
struct {
|
||||
const char *Missile;
|
||||
const char *StartX;
|
||||
const char *StartY;
|
||||
const char *DestX;
|
||||
const char *DestY;
|
||||
const char *Flags;
|
||||
} SpawnMissile;
|
||||
struct {
|
||||
const char *Unit;
|
||||
const char *OffX;
|
||||
const char *OffY;
|
||||
const char *Range;
|
||||
const char *Player;
|
||||
} SpawnUnit;
|
||||
struct {
|
||||
const char *LeftVar;
|
||||
const char *RightVar;
|
||||
int Type;
|
||||
CAnimation *Goto;
|
||||
} IfVar;
|
||||
struct {
|
||||
int Mod;
|
||||
const char *Var;
|
||||
const char *Value;
|
||||
const char *UnitSlot;
|
||||
} SetVar;
|
||||
struct {
|
||||
int Mod;
|
||||
const char *Player;
|
||||
const char *Var;
|
||||
const char *Arg;
|
||||
const char *Value;
|
||||
} SetPlayerVar;
|
||||
struct {
|
||||
const char *DeathType;
|
||||
} Die;
|
||||
} D;
|
||||
CAnimation *Next;
|
||||
};
|
||||
|
||||
|
@ -289,6 +151,9 @@ extern int UnitShowAnimationScaled(CUnit &unit, const CAnimation *anim, int scal
|
|||
extern int UnitShowAnimation(CUnit &unit, const CAnimation *anim);
|
||||
|
||||
|
||||
extern int ParseAnimInt(const CUnit *unit, const char *parseint);
|
||||
|
||||
extern void FindLabelLater(CAnimation **anim, const std::string &name);
|
||||
//@}
|
||||
|
||||
#endif // !__ANIMATIONS_H__
|
||||
|
|
50
src/include/animation/animation_attack.h
Normal file
50
src/include/animation/animation_attack.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_attack.h - The animation headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_ATTACK_H
|
||||
#define ANIMATION_ATTACK_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Attack : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Attack() : CAnimation(AnimationAttack) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_ATTACK_H
|
|
@ -32,19 +32,28 @@
|
|||
|
||||
//@{
|
||||
|
||||
class CUnit;
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Die : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Die() : CAnimation(AnimationDie) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string DeathType;
|
||||
};
|
||||
|
||||
|
||||
class AnimationDie_Exception
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
extern void AnimationDie_Action(CUnit &unit);
|
||||
extern void AnimationDie_OnCatch(CUnit& unit);
|
||||
|
||||
|
||||
//@}
|
||||
|
||||
#endif // !__ANIMATION_DIE_H__
|
||||
|
|
54
src/include/animation/animation_exactframe.h
Normal file
54
src/include/animation/animation_exactframe.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_exactframe.h - The animation headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_EXACTFRAME_H
|
||||
#define ANIMATION_EXACTFRAME_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_ExactFrame : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_ExactFrame() : CAnimation(AnimationExactFrame) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
int ParseAnimInt(const CUnit *unit) const;
|
||||
|
||||
private:
|
||||
std::string frame;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_EXACTFRAME_H
|
53
src/include/animation/animation_frame.h
Normal file
53
src/include/animation/animation_frame.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_frame.h - The animation Frame headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_FRAME_H
|
||||
#define ANIMATION_FRAME_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Frame : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Frame() : CAnimation(AnimationFrame) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
int ParseAnimInt(const CUnit *unit) const;
|
||||
private:
|
||||
std::string frame;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_FRAME_H
|
52
src/include/animation/animation_goto.h
Normal file
52
src/include/animation/animation_goto.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_goto.h - The animation Goto headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_GOTO_H
|
||||
#define ANIMATION_GOTO_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Goto : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Goto() : CAnimation(AnimationGoto), gotoLabel(NULL) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
CAnimation *gotoLabel;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_GOTO_H
|
55
src/include/animation/animation_ifvar.h
Normal file
55
src/include/animation/animation_ifvar.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_ifvar.h - The animation IfVar headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_IFVAR_H
|
||||
#define ANIMATION_IFVAR_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_IfVar : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_IfVar() : CAnimation(AnimationIfVar) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string leftVar;
|
||||
std::string rightVar;
|
||||
int type;
|
||||
CAnimation *gotoLabel;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_IFVAR_H
|
52
src/include/animation/animation_label.h
Normal file
52
src/include/animation/animation_label.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_label.h - The animation Label headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_LABEL_H
|
||||
#define ANIMATION_LABEL_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Label : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Label() : CAnimation(AnimationLabel) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
// std::string ;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_LABEL_H
|
52
src/include/animation/animation_move.h
Normal file
52
src/include/animation/animation_move.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_move.h - The animation Move headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_MOVE_H
|
||||
#define ANIMATION_MOVE_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Move : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Move() : CAnimation(AnimationMove) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string moveStr;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_MOVE_H
|
53
src/include/animation/animation_randomgoto.h
Normal file
53
src/include/animation/animation_randomgoto.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomgoto.h - The animation RandomGoto headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_RANDOMGOTO_H
|
||||
#define ANIMATION_RANDOMGOTO_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_RandomGoto : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_RandomGoto() : CAnimation(AnimationRandomGoto), gotoLabel(NULL) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string randomStr;
|
||||
CAnimation *gotoLabel;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_RANDOMGOTO_H
|
52
src/include/animation/animation_randomrotate.h
Normal file
52
src/include/animation/animation_randomrotate.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomrotate.h - The animation RandomRotate headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_RANDOMROTATE_H
|
||||
#define ANIMATION_RANDOMROTATE_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_RandomRotate : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_RandomRotate() : CAnimation(AnimationRandomRotate) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string rotateStr;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_RANDOMROTATE_H
|
55
src/include/animation/animation_randomsound.h
Normal file
55
src/include/animation/animation_randomsound.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_RandomSound.h - The animation RandomSound headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_RANDOMSOUND_H
|
||||
#define ANIMATION_RANDOMSOUND_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "animation.h"
|
||||
#include "unitsound.h"
|
||||
|
||||
class CAnimation_RandomSound : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_RandomSound() : CAnimation(AnimationRandomSound) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
void MapSound();
|
||||
private:
|
||||
std::vector<SoundConfig> sounds;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_RANDOMSOUND_H
|
53
src/include/animation/animation_randomwait.h
Normal file
53
src/include/animation/animation_randomwait.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_randomwait.h - The animation RandomWait headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_RANDOMWAIT_H
|
||||
#define ANIMATION_RANDOMWAIT_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_RandomWait : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_RandomWait() : CAnimation(AnimationRandomWait) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string minWait;
|
||||
std::string maxWait;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_RANDOMWAIT_H
|
54
src/include/animation/animation_rotate.h
Normal file
54
src/include/animation/animation_rotate.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_rotate.h - The animation Rotate headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_ROTATE_H
|
||||
#define ANIMATION_ROTATE_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Rotate : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Rotate() : CAnimation(AnimationRotate) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string rotateStr;
|
||||
};
|
||||
|
||||
extern void UnitRotate(CUnit &unit, int rotate);
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_ROTATE_H
|
58
src/include/animation/animation_setplayervar.h
Normal file
58
src/include/animation/animation_setplayervar.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_setplayervar.h - The animation SetPlayerVar headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_SETPLAYERVAR_H
|
||||
#define ANIMATION_SETPLAYERVAR_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_SetPlayerVar : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_SetPlayerVar() : CAnimation(AnimationSetPlayerVar) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
int mod;
|
||||
std::string playerStr;
|
||||
std::string varStr;
|
||||
std::string argStr;
|
||||
std::string valueStr;
|
||||
};
|
||||
|
||||
extern int GetPlayerData(int player, const char *prop, const char *arg);
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_SETPLAYERVAR_H
|
55
src/include/animation/animation_setvar.h
Normal file
55
src/include/animation/animation_setvar.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_setvar.h - The animation SetVar headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_SETVAR_H
|
||||
#define ANIMATION_SETVAR_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_SetVar : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_SetVar() : CAnimation(AnimationSetVar) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
int mod;
|
||||
std::string varStr;
|
||||
std::string valueStr;
|
||||
std::string unitSlotStr;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_SETVAR_H
|
55
src/include/animation/animation_sound.h
Normal file
55
src/include/animation/animation_sound.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_sound.h - The animation Sound headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_SOUND_H
|
||||
#define ANIMATION_SOUND_H
|
||||
|
||||
//@{
|
||||
|
||||
#include "animation.h"
|
||||
#include "unitsound.h"
|
||||
|
||||
|
||||
class CAnimation_Sound : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Sound() : CAnimation(AnimationSound) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
void MapSound();
|
||||
|
||||
private:
|
||||
SoundConfig sound;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_SOUND_H
|
57
src/include/animation/animation_spawnmissile.h
Normal file
57
src/include/animation/animation_spawnmissile.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_spawnmissile.h - The animation SpawnMissile headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_SPAWNMISSILE_H
|
||||
#define ANIMATION_SPAWNMISSILE_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_SpawnMissile : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_SpawnMissile() : CAnimation(AnimationSpawnMissile) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string missile;
|
||||
std::string startX;
|
||||
std::string startY;
|
||||
std::string destX;
|
||||
std::string destY;
|
||||
std::string flags;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_SPAWNMISSILE_H
|
56
src/include/animation/animation_spawnunit.h
Normal file
56
src/include/animation/animation_spawnunit.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_spawnunit.h - The animation SpawnUnit headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_SPAWNUNIT_H
|
||||
#define ANIMATION_SPAWNUNIT_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_SpawnUnit : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_SpawnUnit() : CAnimation(AnimationSpawnUnit) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string unitStr;
|
||||
std::string offXStr;
|
||||
std::string offYStr;
|
||||
std::string rangeStr;
|
||||
std::string playerStr;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_SPAWNUNIT_H
|
52
src/include/animation/animation_unbreakable.h
Normal file
52
src/include/animation/animation_unbreakable.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_unbreakable.h - The animation Unbreakable headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_UNBREAKABLE_H
|
||||
#define ANIMATION_UNBREAKABLE_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Unbreakable : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Unbreakable() : CAnimation(AnimationUnbreakable), state(0) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
int state;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_UNBREAKABLE_H
|
52
src/include/animation/animation_wait.h
Normal file
52
src/include/animation/animation_wait.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// _________ __ __
|
||||
// / _____// |_____________ _/ |______ ____ __ __ ______
|
||||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
|
||||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
|
||||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
|
||||
// \/ \/ \//_____/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// Stratagus - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name animation_wait.h - The animation Wait headerfile. */
|
||||
//
|
||||
// (c) Copyright 2012 by Joris Dauphin
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; only version 2 of the License.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
// 02111-1307, USA.
|
||||
//
|
||||
|
||||
#ifndef ANIMATION_WAIT_H
|
||||
#define ANIMATION_WAIT_H
|
||||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include "animation.h"
|
||||
|
||||
class CAnimation_Wait : public CAnimation
|
||||
{
|
||||
public:
|
||||
CAnimation_Wait() : CAnimation(AnimationWait) {}
|
||||
|
||||
virtual void Action(CUnit& unit, int &move, int scale) const;
|
||||
virtual void Init(const char* s);
|
||||
|
||||
private:
|
||||
std::string wait;
|
||||
};
|
||||
|
||||
//@}
|
||||
|
||||
#endif // ANIMATION_WAIT_H
|
|
@ -40,15 +40,17 @@
|
|||
#include "stratagus.h"
|
||||
|
||||
#include "unitsound.h"
|
||||
#include "video.h"
|
||||
#include "sound.h"
|
||||
#include "unittype.h"
|
||||
#include "animation.h"
|
||||
|
||||
#include "animation/animation_randomsound.h"
|
||||
#include "animation/animation_sound.h"
|
||||
#include "map.h"
|
||||
#include "player.h"
|
||||
#include "unit.h"
|
||||
#include "sound.h"
|
||||
#include "sound_server.h"
|
||||
#include "tileset.h"
|
||||
#include "map.h"
|
||||
#include "unit.h"
|
||||
#include "unittype.h"
|
||||
#include "video.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Declarations
|
||||
|
@ -69,6 +71,19 @@ void LoadUnitSounds()
|
|||
{
|
||||
}
|
||||
|
||||
static void MapAnimSound(CAnimation &anim)
|
||||
{
|
||||
if (anim.Type == AnimationSound) {
|
||||
CAnimation_Sound &anim_sound = *static_cast<CAnimation_Sound*>(&anim);
|
||||
|
||||
anim_sound.MapSound();
|
||||
} else if (anim.Type == AnimationRandomSound) {
|
||||
CAnimation_RandomSound &anim_rsound = *static_cast<CAnimation_RandomSound*>(&anim);
|
||||
|
||||
anim_rsound.MapSound();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Map animation sounds
|
||||
*/
|
||||
|
@ -77,21 +92,9 @@ static void MapAnimSounds2(CAnimation *anim)
|
|||
if (anim == NULL) {
|
||||
return ;
|
||||
}
|
||||
if (anim->Type == AnimationSound) {
|
||||
anim->D.Sound.Sound = SoundForName(anim->D.Sound.Name);
|
||||
} else if (anim->Type == AnimationRandomSound) {
|
||||
for (unsigned int i = 0; i < anim->D.RandomSound.NumSounds; ++i) {
|
||||
anim->D.RandomSound.Sound[i] = SoundForName(anim->D.RandomSound.Name[i]);
|
||||
}
|
||||
}
|
||||
MapAnimSound(*anim);
|
||||
for (CAnimation *it = anim->Next; it != anim; it = it->Next) {
|
||||
if (it->Type == AnimationSound) {
|
||||
it->D.Sound.Sound = SoundForName(it->D.Sound.Name);
|
||||
} else if (it->Type == AnimationRandomSound) {
|
||||
for (unsigned int i = 0; i < it->D.RandomSound.NumSounds; ++i) {
|
||||
it->D.RandomSound.Sound[i] = SoundForName(it->D.RandomSound.Name[i]);
|
||||
}
|
||||
}
|
||||
MapAnimSound(*it);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,14 +43,18 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "unittype.h"
|
||||
|
||||
#include "animation.h"
|
||||
#include "animation/animation_exactframe.h"
|
||||
#include "animation/animation_frame.h"
|
||||
|
||||
#include "video.h"
|
||||
#include "tileset.h"
|
||||
#include "map.h"
|
||||
#include "sound.h"
|
||||
#include "unitsound.h"
|
||||
#include "construct.h"
|
||||
#include "unittype.h"
|
||||
#include "animation.h"
|
||||
#include "player.h"
|
||||
#include "missile.h"
|
||||
#include "script.h"
|
||||
|
@ -476,10 +480,13 @@ static int GetStillFrame(CUnitType *type)
|
|||
|
||||
while (anim) {
|
||||
if (anim->Type == AnimationFrame) {
|
||||
CAnimation_Frame& a_frame = *static_cast<CAnimation_Frame*>(anim);
|
||||
// Use the frame facing down
|
||||
return ParseAnimInt(NoUnitP, anim->D.Frame.Frame) + type->NumDirections / 2;
|
||||
return a_frame.ParseAnimInt(NoUnitP) + type->NumDirections / 2;
|
||||
} else if (anim->Type == AnimationExactFrame) {
|
||||
return ParseAnimInt(NoUnitP, anim->D.Frame.Frame);
|
||||
CAnimation_ExactFrame& a_frame = *static_cast<CAnimation_ExactFrame*>(anim);
|
||||
|
||||
return a_frame.ParseAnimInt(NoUnitP);
|
||||
}
|
||||
anim = anim->Next;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue