[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src unit_types.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src unit_types.cpp |
Date: |
Thu, 17 Mar 2005 17:49:22 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/03/17 22:49:22
Modified files:
src : unit_types.cpp
Log message:
made it possible to have multiple defensive animations, one of which is
selected at random
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit_types.cpp.diff?tr1=1.88&tr2=1.89&r1=text&r2=text
Patches:
Index: wesnoth/src/unit_types.cpp
diff -u wesnoth/src/unit_types.cpp:1.88 wesnoth/src/unit_types.cpp:1.89
--- wesnoth/src/unit_types.cpp:1.88 Fri Mar 11 02:40:00 2005
+++ wesnoth/src/unit_types.cpp Thu Mar 17 22:49:22 2005
@@ -1,4 +1,4 @@
-/* $Id: unit_types.cpp,v 1.88 2005/03/11 02:40:00 Sirp Exp $ */
+/* $Id: unit_types.cpp,v 1.89 2005/03/17 22:49:22 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1039,14 +1039,26 @@
}
const unit_animation* unit_type::defend_animation(bool hits,
attack_type::RANGE range) const
-{
+{
+ //select one of the matching animations at random
+ const unit_animation* res = NULL;
+ std::vector<const unit_animation*> options;
for(std::vector<defensive_animation>::const_iterator i =
defensive_animations_.begin(); i != defensive_animations_.end(); ++i) {
- if(i->matches(hits,range)) {
- return &i->animation;
+ if(i->matches(hits,range)) {
+ if(res != NULL) {
+ options.push_back(res);
+ }
+
+ res = &i->animation;
}
+ }
+
+ if(options.empty()) {
+ return res;
+ } else {
+ options.push_back(res);
+ return options[rand()%options.size()];
}
-
- return NULL;
}
const unit_animation* unit_type::teleport_animation( ) const
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src unit_types.cpp,
David White <=