Difference between revisions of "Source:NetHack 1.3d/wield.c"
Jump to navigation
Jump to search
m (Automated source code upload) |
Kernigh bot (talk | contribs) m (NetHack 1.3d/wield.c moved to Source:NetHack 1.3d/wield.c: Robot: moved page) |
(No difference)
|
Latest revision as of 00:40, 4 March 2008
Below is the full text to wield.c from the source code of NetHack 1.3d. To link to a particular line, write [[NetHack 1.3d/wield.c#line123]], for example.
Warning! This is the source code from an old release. For the latest release, see Source code
Screenshots and source code from Hack are used under the CWI license.
1. /* SCCS Id: @(#)wield.c 1.3 87/07/14 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* wield.c - version 1.0.3 */ 4. 5. #include "hack.h" 6. extern struct obj zeroobj; 7. extern char *hcolor(); 8. #ifdef KAA 9. extern boolean unweapon; 10. #endif 11. 12. setuwep(obj) register struct obj *obj; { 13. setworn(obj, W_WEP); 14. } 15. 16. dowield() 17. { 18. register struct obj *wep; 19. register int res = 0; 20. 21. multi = 0; 22. #ifdef KAA 23. if (cantwield(u.usym)) { 24. pline("Don't be ridiculous!"); 25. return(0); 26. } 27. #endif 28. if(!(wep = getobj("#-)", "wield"))) /* nothing */; 29. else if(uwep == wep) 30. pline("You are already wielding that!"); 31. else if(welded(uwep)) 32. pline("The %s welded to your hand!", 33. aobjnam(uwep, "are")); 34. else if(wep == &zeroobj) { 35. if(uwep == 0){ 36. pline("You are already empty handed."); 37. } else { 38. setuwep((struct obj *) 0); 39. res++; 40. pline("You are empty handed."); 41. } 42. /* Prevent wielding a cockatrice in pack when not wearing gloves KAA*/ 43. } else if (!uarmg && wep->otyp == DEAD_COCKATRICE) { 44. pline("You wield the dead cockatrice in your bare hands."); 45. pline("You turn to stone ..."); 46. killer="dead cockatrice"; 47. done("died"); 48. } else if(uarms && wep->otyp == TWO_HANDED_SWORD) 49. pline("You cannot wield a two-handed sword and wear a shield."); 50. else if(wep->owornmask & (W_ARMOR | W_RING)) 51. pline("You cannot wield that!"); 52. else { 53. setuwep(wep); 54. res++; 55. if(welded(uwep)) 56. pline("The %s %s to your hand!", 57. aobjnam(uwep, "weld"), 58. (uwep->quan == 1) ? "itself" : "themselves"); /* a3 */ 59. else prinv(uwep); 60. } 61. #ifdef KAA 62. if(res && uwep) 63. unweapon = (uwep->otyp >= BOW || uwep->otyp <= BOOMERANG) ? 64. TRUE : FALSE; 65. #endif 66. return(res); 67. } 68. 69. corrode_weapon(){ 70. if(!uwep || uwep->olet != WEAPON_SYM) return; /* %% */ 71. if(uwep->rustfree) 72. pline("Your %s not affected.", aobjnam(uwep, "are")); 73. else { 74. pline("Your %s!", aobjnam(uwep, "corrode")); 75. uwep->spe--; 76. } 77. } 78. 79. chwepon(otmp,amount) 80. register struct obj *otmp; 81. register amount; 82. { 83. register char *color = (amount < 0) ? "black" : "green"; 84. register char *time; 85. 86. if(Hallucination) color=hcolor(); 87. if(!uwep || uwep->olet != WEAPON_SYM) { 88. strange_feeling(otmp, 89. (amount > 0) ? "Your hands twitch." 90. : "Your hands itch."); 91. return(0); 92. } 93. 94. if(uwep->otyp == WORM_TOOTH && amount > 0) { 95. uwep->otyp = CRYSKNIFE; 96. pline("Your weapon seems sharper now."); 97. uwep->cursed = 0; 98. return(1); 99. } 100. 101. if(uwep->otyp == CRYSKNIFE && amount < 0) { 102. uwep->otyp = WORM_TOOTH; 103. pline("Your weapon looks duller now."); 104. return(1); 105. } 106. 107. /* there is a (soft) upper limit to uwep->spe */ 108. if(amount > 0 && uwep->spe > 5 && rn2(3)) { 109. pline("Your %s violently %s for a while and then evaporate%s.", 110. aobjnam(uwep,"glow"),Hallucination ? hcolor() : "green", 111. plur(uwep->quan)); 112. 113. while(uwep) /* let all of them disappear */ 114. /* note: uwep->quan = 1 is nogood if unpaid */ 115. useup(uwep); 116. return(1); 117. } 118. if(!rn2(6)) amount *= 2; 119. time = (amount*amount == 1) ? "moment" : "while"; 120. pline("Your %s %s for a %s.", 121. aobjnam(uwep, "glow"), color, time); 122. uwep->spe += amount; 123. if(amount > 0) uwep->cursed = 0; 124. return(1); 125. } 126. 127. int 128. welded(obj) register struct obj *obj; { 129. return(obj == uwep && obj->cursed && 130. (obj->olet == WEAPON_SYM || obj->otyp == HEAVY_IRON_BALL || 131. obj->otyp == CAN_OPENER || obj->otyp == PICK_AXE)); 132. }