if (weapons[j].getType() != staff)
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
- Person::players[i]->weaponactive = 0;
- weapons[j].owner = Person::players[i]->id;
- if (Person::players[i]->num_weapons > 0)
- Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
- Person::players[i]->num_weapons++;
- Person::players[i]->weaponids[0] = j;
+ Person::players[i]->takeWeapon(j);
}
}
} else if ((Person::players[i]->isIdle() ||
if (weapons[k].getType() != staff)
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
- Person::players[i]->weaponactive = 0;
- weapons[k].owner = Person::players[i]->id;
- if (Person::players[i]->num_weapons > 0)
- Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
- Person::players[i]->num_weapons++;
- Person::players[i]->weaponids[0] = k;
+ Person::players[i]->takeWeapon(k);
}
}
}
if (fleshstuck)
emit_sound_at(fleshstabremovesound, Person::players[i]->coords, 128.);
- Person::players[i]->weaponactive = 0;
if (weapons[k].owner != -1) {
if (Person::players[i]->victim->num_weapons == 1)
Person::players[i]->victim->num_weapons = 0;
Person::players[i]->victim->jointVel(rightshoulder) += relative * 6;
Person::players[i]->victim->jointVel(leftshoulder) += relative * 6;
}
- weapons[k].owner = i;
- if (Person::players[i]->num_weapons > 0) {
- Person::players[i]->weaponids[Person::players[i]->num_weapons] = Person::players[i]->weaponids[0];
- }
- Person::players[i]->num_weapons++;
- Person::players[i]->weaponids[0] = k;
+ Person::players[i]->takeWeapon(k);
}
}
}
emit_sound_at(knifedrawsound, coords, 128.);
}
- weaponactive = 0;
- weapons[i].owner = id;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[0];
- }
- num_weapons++;
- weaponids[0] = i;
+ takeWeapon(i);
}
}
}
emit_sound_at(knifedrawsound, coords, 128.);
}
}
- weaponactive = 0;
if (weapons[i].owner != -1) {
-
victim = Person::players[weapons[i].owner];
if (victim->num_weapons == 1)
victim->num_weapons = 0;
victim->jointVel(rightshoulder) += relative * 6;
victim->jointVel(leftshoulder) += relative * 6;
}
- weapons[i].owner = id;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[0];
- }
- num_weapons++;
- weaponids[0] = i;
+ takeWeapon(i);
}
}
}
if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && animation[animTarget].label[frameCurrent] == 5) {
if (victim->weaponactive != -1 && victim->num_weapons > 0) {
if (weapons[victim->weaponids[victim->weaponactive]].owner == int(victim->id)) {
- weapons[victim->weaponids[victim->weaponactive]].owner = id;
- weaponactive = 0;
- if (num_weapons > 0) {
- weaponids[num_weapons] = weaponids[victim->weaponactive];
- }
- num_weapons++;
- weaponids[0] = victim->weaponids[victim->weaponactive];
+ takeWeapon(victim->weaponids[victim->weaponactive]);
victim->num_weapons--;
if (victim->num_weapons > 0) {
victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
return firstintersecting;
}
+void Person::takeWeapon(int weaponId)
+{
+ weaponactive = 0;
+ weapons[weaponId].owner = id;
+ if (num_weapons > 0) {
+ weaponids[num_weapons] = weaponids[0];
+ }
+ num_weapons++;
+ weaponids[0] = weaponId;
+}
+
void setAnimation(int);
void DoAnimations();
void RagDoll(bool checkcollision);
+
+ void takeWeapon (int weaponId);
};
const int maxplayers = 10;
(Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {
emit_sound_at(knifedrawsound, Person::players[j]->coords, 128.);
- Person::players[j]->weaponactive = 0;
Person::players[j]->animTarget = removeknifeanim;
Person::players[j]->frameTarget = 1;
Person::players[j]->target = 1;
- owner = Person::players[j]->id;
- if (Person::players[j]->num_weapons > 0) {
- Person::players[j]->weaponids[Person::players[j]->num_weapons] = Person::players[j]->weaponids[0];
- }
- Person::players[j]->num_weapons++;
- Person::players[j]->weaponids[0] = i;
+ Person::players[j]->takeWeapon(i);
Person::players[j]->aitype = attacktypecutoff;
} else {