MCPcopy Create free account
hub / github.com/diasurgical/devilution / ArmorDur

Function ArmorDur

Source/player.cpp:2935–2983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2933}
2934
2935void ArmorDur(int pnum)
2936{
2937 int a;
2938 ItemStruct *pi;
2939 PlayerStruct *p;
2940
2941 if (pnum != myplr) {
2942 return;
2943 }
2944
2945 if ((DWORD)pnum >= MAX_PLRS) {
2946 app_fatal("ArmorDur: illegal player %d", pnum);
2947 }
2948
2949 p = &plr[pnum];
2950 if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
2951 return;
2952 }
2953
2954 a = random_(8, 3);
2955 if (p->InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype == ITYPE_NONE) {
2956 a = 1;
2957 }
2958 if (p->InvBody[INVLOC_CHEST]._itype == ITYPE_NONE && p->InvBody[INVLOC_HEAD]._itype != ITYPE_NONE) {
2959 a = 0;
2960 }
2961
2962 if (a != 0) {
2963 pi = &p->InvBody[INVLOC_CHEST];
2964 } else {
2965 pi = &p->InvBody[INVLOC_HEAD];
2966 }
2967 if (pi->_iDurability == DUR_INDESTRUCTIBLE) {
2968 return;
2969 }
2970
2971 pi->_iDurability--;
2972 if (pi->_iDurability != 0) {
2973 return;
2974 }
2975
2976 if (a != 0) {
2977 NetSendCmdDelItem(TRUE, INVLOC_CHEST);
2978 } else {
2979 NetSendCmdDelItem(TRUE, INVLOC_HEAD);
2980 }
2981 pi->_itype = ITYPE_NONE;
2982 CalcPlrInv(pnum, TRUE);
2983}
2984
2985BOOL PM_DoDeath(int pnum)
2986{

Callers 1

PM_DoGotHitFunction · 0.85

Calls 4

app_fatalFunction · 0.85
random_Function · 0.85
NetSendCmdDelItemFunction · 0.85
CalcPlrInvFunction · 0.85

Tested by

no test coverage detected