Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12698
Modified Files:
basechar.cpp pythonscript.cpp
Log Message:
Fixes
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.169
retrieving revision 1.170
diff -C2 -d -r1.169 -r1.170
*** basechar.cpp 27 Oct 2004 14:06:51 -0000 1.169
--- basechar.cpp 27 Oct 2004 14:37:25 -0000 1.170
***************
*** 2270,2273 ****
--- 2270,2289 ----
}
+
+ P_CHAR sourceChar = dynamic_cast<P_CHAR>(source);
+
+ if (sourceChar && sourceChar->canHandleEvent(EVENT_DODAMAGE)) {
+ PyObject* args = Py_BuildValue( "NiiN", sourceChar->getPyObject(), type, amount, getPyObject() );
+ PyObject* result = callEvent(EVENT_DODAMAGE, args);
+
+ if (result) {
+ if (PyInt_Check(result))
+ amount = PyInt_AsLong(result);
+ Py_DECREF(result);
+ }
+
+ Py_DECREF(args);
+ }
+
//
// First of all, call onDamage with the damage-type, amount and source
***************
*** 2277,2282 ****
{
PyObject* args = 0;
! if ( dynamic_cast<P_CHAR>( source ) != 0 )
! args = Py_BuildValue( "O&iiO&", PyGetCharObject, this, ( unsigned int ) type, amount, PyGetCharObject, source );
else if ( dynamic_cast<P_ITEM>( source ) )
args = Py_BuildValue( "O&iiO&", PyGetCharObject, this, ( unsigned int ) type, amount, PyGetItemObject, source );
--- 2293,2298 ----
{
PyObject* args = 0;
! if ( sourceChar )
! args = Py_BuildValue( "O&iiO&", PyGetCharObject, this, ( unsigned int ) type, amount, PyGetCharObject, sourceChar );
else if ( dynamic_cast<P_ITEM>( source ) )
args = Py_BuildValue( "O&iiO&", PyGetCharObject, this, ( unsigned int ) type, amount, PyGetItemObject, source );
***************
*** 2297,2315 ****
}
- if (source && source->isChar() && source->canHandleEvent(EVENT_DODAMAGE)) {
- P_CHAR sourceChar = static_cast<P_CHAR>(source);
-
- PyObject* args = Py_BuildValue( "NiiN", sourceChar->getPyObject(), type, amount, getPyObject() );
- PyObject* result = callEvent(EVENT_DAMAGE, args);
-
- if (result) {
- if (PyInt_Check(result))
- amount = PyInt_AsLong(result);
- Py_DECREF(result);
- }
-
- Py_DECREF(args);
- }
-
// The damage has been resisted or scripts have taken care of the damage otherwise
// Invulnerable Targets don't take any damage at all
--- 2313,2316 ----
Index: pythonscript.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/pythonscript.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** pythonscript.cpp 27 Oct 2004 14:06:52 -0000 1.56
--- pythonscript.cpp 27 Oct 2004 14:37:25 -0000 1.57
***************
*** 570,573 ****
--- 570,574 ----
/*
+ \event onDoDamage
\param char The character dealing the damage.
\param type The damage type.
|