Difference between revisions of "Talk:Pain state"

From DoomWiki.org

m (punctuation)
(RNG results: Hexen)
Line 564: Line 564:
  
 
It appears that this logic carries over exactly to Heretic.  See {{c|P_DamageMobj()}} in {{c|P_INTER.C}}, {{c|rndtable[]}} and {{c|P_Random()}} in {{c|M_MISC.C}}.    [[User:Ryan W|Ryan W]] ([[User talk:Ryan W|talk]]) 19:24, 11 March 2016 (CST)
 
It appears that this logic carries over exactly to Heretic.  See {{c|P_DamageMobj()}} in {{c|P_INTER.C}}, {{c|rndtable[]}} and {{c|P_Random()}} in {{c|M_MISC.C}}.    [[User:Ryan W|Ryan W]] ([[User talk:Ryan W|talk]]) 19:24, 11 March 2016 (CST)
 +
 +
For Hexen, it differs: the array of numbers ({{c|M_MISC.C}} lines 139-156) now includes ''one'' occurrence of each number 0-255.  Therefore the prior approach of dividing pain chance values by 256 actually gives correct percentages.  Other statements look unchanged: the conditional test is line 2056 of {{c|P_INTER.C}}, and {{c|P_Random()}} is line 1251 of {{c|H2DEF.H}} (except it's now a {{c|#define}} instead of a function, which I think only matters at a low level, below such things as actor behavior).    [[User:Ryan W|Ryan W]] ([[User talk:Ryan W|talk]]) 20:47, 11 March 2016 (CST)

Revision as of 21:47, 11 March 2016

This article needs information on pain threshold. See Quasar's note here.

100% pain chance

According to Dehacked (and the respective actor's entries here on the wiki), the player and Romero's head all have 255 pain chance. This is translated to 100%. But something is wrong. As I understand, pain chance is out of 256, which would mean that 255 pain chance would translate to 99.61%, not 100%. However, if we assume that pain chance is actually out of 255, then that throws off every other pain chance calculation. Examples:

  • Arachnotron: 128 pain chance
    • (128*100)/256=50% (agrees with wiki)
    • (128*100)/255=50.20% (doesn't agree with wiki)
  • Mancubus: 80 pain chance
    • (80*100)/256=31.25% (agrees with wiki)
    • (80*100)/255=31.37% (doesn't agree with wiki)

I could go on, but you get the idea. If pain chance is really out of 256 and not 255, then the real pain% for the player and Romero's head is (255*100)/256=99.61%. --Reaper with no name 04:33, 31 December 2008 (UTC)

Very sensible.  According to the article, this is where an actor does or does not enter its pain state (from P_DamageMobj):
   if ( (P_Random () < target->info->painchance)
        && !(target->flags&MF_SKULLFLY) )
   {
       target->flags |= MF_JUSTHIT;        // fight back!
       
       P_SetMobjState (target, target->info->painstate);
   }
Therefore, AFAICT, what "255" really means is "what fraction of the entries in m_random.c are below 255?".  The answer is 255/256 ≈ 99.61%.  For "80" it would be 79/256 ≈ 30.86%.    Ryan W 20:18, 8 January 2009 (UTC)

Explanation

Pain chance is an 8-bit variable. That's 256 possibilities, from 0 to 255. 255 = 100%. --162.123.17.80 16:33, 9 January 2009 (UTC)Jared

I thought about that, but according to Dehacked, the Lost Soul has 256 pain chance. That's what makes me think it's unlikely, unless Dehacked messed it up somehow. But if pain chance is out of 255, then there's going to have be a lot of recalculation for all the monster's pain %'s. --Reaper with no name 17:05, 12 January 2009 (UTC)
"A lot"?  Surely the wiki doesn't use these numbers anywhere besides the data tables in the monster articles.  I'll be glad to redo those myself if we can agree on what the mistake is.  :>   Our tables seem to have been added originally by User:CyRaptor who I assume is long gone.  However, in the source code, you can read the pain chance numbers (used in the excerpt above) from info.c.  Romero's head indeed has 255, which means that your analysis is testable: for example, one could make a custom PWAD + demo in which Romero's head is hit by a pistol shot and doesn't react.    Ryan W 00:16, 13 January 2009 (UTC)

If we look at m_random.c, There is also no number higher than 255 in the table. The header also states:

// // M_Random // Returns a 0-255 number //

RNG results

Following on to the first section of this talk page, here is the correct conversion:

Pain chance value Pain state percentage
0 0.00%
1 0.78%
2 0.78%
3 1.56%
4 1.95%
5 2.34%
6 2.34%
7 2.34%
8 2.73%
9 3.13%
10 3.13%
11 3.13%
12 3.52%
13 3.52%
14 3.52%
15 3.91%
16 4.30%
17 4.69%
18 5.47%
19 5.47%
20 5.47%
21 6.25%
22 6.64%
23 7.03%
24 7.03%
25 7.42%
26 8.20%
27 8.59%
28 8.98%
29 9.77%
30 9.77%
31 9.77%
32 10.16%
33 10.16%
34 10.55%
35 10.55%
36 10.55%
37 11.33%
38 12.11%
39 12.11%
40 12.89%
41 12.89%
42 13.28%
43 14.06%
44 14.45%
45 14.45%
46 14.84%
47 15.63%
48 16.02%
49 16.41%
50 16.80%
51 17.58%
52 17.58%
53 18.75%
54 19.14%
55 19.53%
56 19.53%
57 19.92%
58 19.92%
59 20.31%
60 20.70%
61 21.48%
62 21.88%
63 22.27%
64 23.05%
65 23.05%
66 23.05%
67 23.83%
68 23.83%
69 24.22%
70 24.61%
71 26.17%
72 26.56%
73 26.56%
74 26.95%
75 27.34%
76 28.13%
77 28.52%
78 29.69%
79 30.08%
80 30.86%
81 31.64%
82 32.42%
83 32.81%
84 32.81%
85 33.59%
86 33.98%
87 34.38%
88 34.77%
89 34.77%
90 35.16%
91 35.55%
92 35.94%
93 36.33%
94 37.11%
95 37.50%
96 38.28%
97 38.67%
98 38.67%
99 39.84%
100 39.84%
101 39.84%
102 40.23%
103 40.23%
104 40.63%
105 41.02%
106 41.02%
107 41.80%
108 42.58%
109 42.97%
110 44.14%
111 44.53%
112 44.92%
113 45.31%
114 46.48%
115 46.88%
116 46.88%
117 46.88%
118 46.88%
119 47.27%
120 47.27%
121 48.44%
122 48.44%
123 48.83%
124 49.61%
125 49.61%
126 50.00%
127 50.00%
128 50.00%
129 50.78%
130 51.17%
131 51.17%
132 51.17%
133 51.17%
134 51.17%
135 51.17%
136 51.95%
137 52.73%
138 52.73%
139 53.91%
140 54.30%
141 55.47%
142 55.86%
143 55.86%
144 56.64%
145 56.64%
146 58.59%
147 59.38%
148 59.38%
149 59.38%
150 60.16%
151 60.16%
152 60.16%
153 60.55%
154 60.55%
155 60.94%
156 60.94%
157 61.72%
158 61.72%
159 61.72%
160 62.11%
161 62.11%
162 63.28%
163 63.28%
164 64.84%
165 65.23%
166 65.63%
167 66.80%
168 66.80%
169 67.58%
170 67.58%
171 67.97%
172 68.36%
173 68.36%
174 68.75%
175 68.75%
176 69.92%
177 70.31%
178 70.31%
179 70.70%
180 70.70%
181 70.70%
182 71.48%
183 72.27%
184 72.27%
185 73.05%
186 73.05%
187 73.44%
188 73.83%
189 74.22%
190 74.22%
191 75.00%
192 75.00%
193 75.00%
194 75.39%
195 75.78%
196 76.17%
197 76.95%
198 78.52%
199 79.30%
200 79.30%
201 79.69%
202 79.69%
203 80.47%
204 80.86%
205 80.86%
206 81.25%
207 81.64%
208 81.64%
209 81.64%
210 81.64%
211 81.64%
212 82.42%
213 83.59%
214 83.59%
215 83.59%
216 83.59%
217 83.98%
218 83.98%
219 83.98%
220 84.38%
221 84.77%
222 85.16%
223 85.94%
224 86.33%
225 87.50%
226 87.89%
227 88.67%
228 89.06%
229 89.06%
230 89.45%
231 89.45%
232 89.84%
233 90.23%
234 90.23%
235 90.23%
236 90.63%
237 91.02%
238 91.41%
239 91.41%
240 92.58%
241 92.58%
242 93.36%
243 94.53%
244 94.53%
245 94.92%
246 94.92%
247 95.31%
248 95.70%
249 96.09%
250 97.27%
251 97.66%
252 98.05%
253 98.44%
254 98.83%
255 99.61%
256 100.00%

I believe this is already fixed in a few monster articles.  I will check the others sooner or later, unless someone else does it first of course.  :>     Ryan W 23:55, 20 March 2014 (UTC)

It appears that this logic carries over exactly to Heretic.  See P_DamageMobj() in P_INTER.C, rndtable[] and P_Random() in M_MISC.C.    Ryan W (talk) 19:24, 11 March 2016 (CST)

For Hexen, it differs: the array of numbers (M_MISC.C lines 139-156) now includes one occurrence of each number 0-255.  Therefore the prior approach of dividing pain chance values by 256 actually gives correct percentages.  Other statements look unchanged: the conditional test is line 2056 of P_INTER.C, and P_Random() is line 1251 of H2DEF.H (except it's now a #define instead of a function, which I think only matters at a low level, below such things as actor behavior).    Ryan W (talk) 20:47, 11 March 2016 (CST)