rendered paste body// missles.cpp : Defines the entry point for the DLL application.
//
#include "bzfsAPI.h"
#define POSITION_NUM 3
float positions[POSITION_NUM][3] = {{-1,0,0},{0,0,0},{1,0,0}};
// Comment this out to have to positions be fired from in order:
#define RANDOM_POSITION
int current_position = 0;
BZ_GET_PLUGIN_VERSION
class MissleSilo : public bz_EventHandler
{
public:
virtual void process ( bz_EventData *eventData );
};
MissleSilo misslesilo;
BZF_PLUGIN_CALL int bz_Load ( const char* /*commandLine*/ )
{
bz_debugMessage(4,"missles plugin loaded");
bz_registerEvent(bz_ePlayerDieEvent, &misslesilo);
return 0;
}
BZF_PLUGIN_CALL int bz_Unload ( void )
{
bz_debugMessage(4,"missles plugin unloaded");
bz_removeEvent(bz_ePlayerDieEvent, &misslesilo);
return 0;
}
void MissleSilo::process ( bz_EventData *eventData )
{
switch (eventData->eventType)
{
default:
break;
case bz_ePlayerDieEvent:
{
bz_PlayerDieEventData *data = (bz_PlayerDieEventData*)eventData;
#ifdef RANDOM_POSITION
// Random position:
current_position = (int)((float) (POSITION_NUM) * rand() / (float)RAND_MAX);
#else
// Cycling position:
if (current_position++ >= POSITION_NUM) current_position = 0;
#endif
bz_debugMessagef(1, "Fired position %d", current_position);
float *pos = positions[current_position];
float direction = 6.28 * rand() / (float)RAND_MAX;
bz_fireWorldGM(data->killerID,(float)bz_getBZDBDouble("_reloadTime")*3,pos,1.4,direction,0.0f);
}
break;
}
}