- Joined
- Oct 31, 2006
- Messages
- 20
- Reaction score
- 0
Her is some code i have been working on its for the mosters attack power but it jusat doesnt work correctly...maybe someone out the can go off of what i did and make it that much better.
// -------------- UPDATE MONSTER ATTACK AND OR MOVEMENT STOPPERS --------------
for(unsigned i=0; i<MonsterList.size(); i++) {
CMonster* thismon = MonsterList;
CWorldClient* thisclient = GetClientByID( thismon->targetid );
if (thisclient==0) continue;
float dx=thismon->pos.x - thisclient->pos.x;
float dy=thismon->pos.y - thisclient->pos.y;
clock_t etime = clock() - thismon->lastAttackTime;
if (etime > 0.9*CLOCKS_PER_SEC && abs(dx*dx+dy*dy) <= 0) {
srand((unsigned)time(0));
int hitpower;
int multiplier;
int hitpowertotal;
int lowest=0, highest=100;
int lowest3=0, highest3=1;
int range=(highest-lowest)+1;
int range3=(highest3-lowest3)+1;
for (int index=0; index<20; index++)
multiplier = lowest+int(range3*rand()/(RAND_MAX + 1.0));
hitpower = lowest+int(range*rand()/(RAND_MAX + 1.0))-((thisclient->c_dex/4)+(thisclient->c_str/2));
if (multiplier = 0)
{
int lowest2=1, highest2=2;
int range2=(highest2-lowest2)+1;
for (int index=0; index<20; index++)
hitpowertotal = hitpower*lowest2+int(range2*rand()/(RAND_MAX + 1.0))-((thisclient->c_dex/4)+(thisclient->c_str/2));
thisclient->c_currenthp -= hitpowertotal;
}
else
{
hitpowertotal = hitpower;
thisclient->c_currenthp -= hitpowertotal;;
}
BEGINPACKET( pak, 0x799 );
ADDWORD( pak, thismon->clientid );
ADDWORD( pak, thisclient->clientid );
ADDDWORD( pak, hitpower );
ADDDWORD( pak, (thisclient->c_currenthp<=0)?16:0 );
SendToVisible( &pak, thismon );
thismon->lastAttackTime = clock();
}
}
// -------------- UPDATE MONSTER ATTACK AND OR MOVEMENT STOPPERS --------------
for(unsigned i=0; i<MonsterList.size(); i++) {
CMonster* thismon = MonsterList;
CWorldClient* thisclient = GetClientByID( thismon->targetid );
if (thisclient==0) continue;
float dx=thismon->pos.x - thisclient->pos.x;
float dy=thismon->pos.y - thisclient->pos.y;
clock_t etime = clock() - thismon->lastAttackTime;
if (etime > 0.9*CLOCKS_PER_SEC && abs(dx*dx+dy*dy) <= 0) {
srand((unsigned)time(0));
int hitpower;
int multiplier;
int hitpowertotal;
int lowest=0, highest=100;
int lowest3=0, highest3=1;
int range=(highest-lowest)+1;
int range3=(highest3-lowest3)+1;
for (int index=0; index<20; index++)
multiplier = lowest+int(range3*rand()/(RAND_MAX + 1.0));
hitpower = lowest+int(range*rand()/(RAND_MAX + 1.0))-((thisclient->c_dex/4)+(thisclient->c_str/2));
if (multiplier = 0)
{
int lowest2=1, highest2=2;
int range2=(highest2-lowest2)+1;
for (int index=0; index<20; index++)
hitpowertotal = hitpower*lowest2+int(range2*rand()/(RAND_MAX + 1.0))-((thisclient->c_dex/4)+(thisclient->c_str/2));
thisclient->c_currenthp -= hitpowertotal;
}
else
{
hitpowertotal = hitpower;
thisclient->c_currenthp -= hitpowertotal;;
}
BEGINPACKET( pak, 0x799 );
ADDWORD( pak, thismon->clientid );
ADDWORD( pak, thisclient->clientid );
ADDDWORD( pak, hitpower );
ADDDWORD( pak, (thisclient->c_currenthp<=0)?16:0 );
SendToVisible( &pak, thismon );
thismon->lastAttackTime = clock();
}
}

