comparison Actor.cpp @ 319:5a66be213cff

Actor::Die
author Nomad
date Wed, 20 Feb 2013 02:53:37 +0200
parents 6d584c95dcf8
children 15decc249a94
comparison
equal deleted inserted replaced
317:e41fe9cf3613 319:5a66be213cff
2176 memcpy(&v20, v14, sizeof(v20)); 2176 memcpy(&v20, v14, sizeof(v20));
2177 v13 = 0; 2177 v13 = 0;
2178 } 2178 }
2179 v15 = pSpriteFrameTable->pSpriteSFrames; 2179 v15 = pSpriteFrameTable->pSpriteSFrames;
2180 v3->uYawAngle = LOWORD(v12->uYawAngle); 2180 v3->uYawAngle = LOWORD(v12->uYawAngle);
2181 v16 = v15[v3->pSpriteIDs[2]].uAnimLength; 2181 v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength;
2182 v17 = v24; 2182 v17 = v24;
2183 v3->uCurrentActionLength = 8 * v16; 2183 v3->uCurrentActionLength = 8 * v16;
2184 v3->uCurrentActionTime = v13; 2184 v3->uCurrentActionTime = v13;
2185 v3->uAIState = AttackingMelee; 2185 v3->uAIState = AttackingMelee;
2186 Actor::PlaySound(v17, 0); 2186 Actor::PlaySound(v17, 0);
2573 memcpy(&v18, v11, sizeof(v18)); 2573 memcpy(&v18, v11, sizeof(v18));
2574 v10 = 0; 2574 v10 = 0;
2575 } 2575 }
2576 v12 = pSpriteFrameTable->pSpriteSFrames; 2576 v12 = pSpriteFrameTable->pSpriteSFrames;
2577 v3->uYawAngle = LOWORD(v9->uYawAngle); 2577 v3->uYawAngle = LOWORD(v9->uYawAngle);
2578 v13 = v12[v3->pSpriteIDs[3]].uAnimLength; 2578 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
2579 v14 = v22; 2579 v14 = v22;
2580 v3->uCurrentActionLength = 8 * v13; 2580 v3->uCurrentActionLength = 8 * v13;
2581 v3->uCurrentActionTime = v10; 2581 v3->uCurrentActionTime = v10;
2582 v3->uAIState = AttackingRanged4; 2582 v3->uAIState = AttackingRanged4;
2583 Actor::PlaySound(v14, 0); 2583 Actor::PlaySound(v14, 0);
2685 memcpy(&v18, v11, sizeof(v18)); 2685 memcpy(&v18, v11, sizeof(v18));
2686 v10 = 0; 2686 v10 = 0;
2687 } 2687 }
2688 v12 = pSpriteFrameTable->pSpriteSFrames; 2688 v12 = pSpriteFrameTable->pSpriteSFrames;
2689 v3->uYawAngle = LOWORD(v9->uYawAngle); 2689 v3->uYawAngle = LOWORD(v9->uYawAngle);
2690 v13 = v12[v3->pSpriteIDs[3]].uAnimLength; 2690 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
2691 v14 = v22; 2691 v14 = v22;
2692 v3->uCurrentActionLength = 8 * v13; 2692 v3->uCurrentActionLength = 8 * v13;
2693 v3->uCurrentActionTime = v10; 2693 v3->uCurrentActionTime = v10;
2694 v3->uAIState = AttackingRanged3; 2694 v3->uAIState = AttackingRanged3;
2695 Actor::PlaySound(v14, 0); 2695 Actor::PlaySound(v14, 0);
2796 memcpy(&v17, v11, sizeof(v17)); 2796 memcpy(&v17, v11, sizeof(v17));
2797 v10 = 0; 2797 v10 = 0;
2798 } 2798 }
2799 v12 = pSpriteFrameTable->pSpriteSFrames; 2799 v12 = pSpriteFrameTable->pSpriteSFrames;
2800 v3->uYawAngle = LOWORD(v9->uYawAngle); 2800 v3->uYawAngle = LOWORD(v9->uYawAngle);
2801 v13 = v12[v3->pSpriteIDs[3]].uAnimLength; 2801 v13 = v12[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
2802 v14 = v21; 2802 v14 = v21;
2803 v3->uCurrentActionLength = 8 * v13; 2803 v3->uCurrentActionLength = 8 * v13;
2804 v3->uCurrentActionTime = v10; 2804 v3->uCurrentActionTime = v10;
2805 v3->uAIState = AttackingRanged2; 2805 v3->uAIState = AttackingRanged2;
2806 Actor::PlaySound(v14, 0); 2806 Actor::PlaySound(v14, 0);
2900 memcpy(&v18, v12, sizeof(v18)); 2900 memcpy(&v18, v12, sizeof(v18));
2901 v11 = 0; 2901 v11 = 0;
2902 } 2902 }
2903 v13 = pSpriteFrameTable->pSpriteSFrames; 2903 v13 = pSpriteFrameTable->pSpriteSFrames;
2904 v3->uYawAngle = LOWORD(v10->uYawAngle); 2904 v3->uYawAngle = LOWORD(v10->uYawAngle);
2905 v14 = v13[v3->pSpriteIDs[3]].uAnimLength; 2905 v14 = v13[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength;
2906 v15 = v21; 2906 v15 = v21;
2907 v3->uCurrentActionLength = 8 * v14; 2907 v3->uCurrentActionLength = 8 * v14;
2908 v3->uCurrentActionTime = v11; 2908 v3->uCurrentActionTime = v11;
2909 v3->uAIState = AttackingRanged1; 2909 v3->uAIState = AttackingRanged1;
2910 Actor::PlaySound(v15, 0); 2910 Actor::PlaySound(v15, 0);
3109 && result != 2 ) 3109 && result != 2 )
3110 { 3110 {
3111 memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10)); 3111 memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10));
3112 v6 = pSpriteFrameTable->pSpriteSFrames; 3112 v6 = pSpriteFrameTable->pSpriteSFrames;
3113 v4->uYawAngle = LOWORD(v10.uYawAngle); 3113 v4->uYawAngle = LOWORD(v10.uYawAngle);
3114 v7 = v6[v4->pSpriteIDs[4]].uAnimLength; 3114 v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength;
3115 v8 = v11; 3115 v8 = v11;
3116 v4->uCurrentActionTime = 0; 3116 v4->uCurrentActionTime = 0;
3117 v4->uAIState = Stunned; 3117 v4->uAIState = Stunned;
3118 v4->uCurrentActionLength = 8 * v7; 3118 v4->uCurrentActionLength = 8 * v7;
3119 Actor::PlaySound(v8, 2u); 3119 Actor::PlaySound(v8, 2u);
3151 v3 = v15; 3151 v3 = v15;
3152 v4 = &v12; 3152 v4 = &v12;
3153 } 3153 }
3154 v6 = pSpriteFrameTable->pSpriteSFrames; 3154 v6 = pSpriteFrameTable->pSpriteSFrames;
3155 v5->uYawAngle = LOWORD(v4->uYawAngle); 3155 v5->uYawAngle = LOWORD(v4->uYawAngle);
3156 v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[7]].uAnimLength; 3156 v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[ANIM_Bored]].uAnimLength;
3157 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); 3157 v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y);
3158 LOWORD(v8) = v5->uYawAngle; 3158 LOWORD(v8) = v5->uYawAngle;
3159 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; 3159 v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7;
3160 if ( BYTE1(v9) & 7 ) 3160 if ( BYTE1(v9) & 7 )
3161 { 3161 {
3182 SpriteFrame *v2; // edx@1 3182 SpriteFrame *v2; // edx@1
3183 int v3; // eax@1 3183 int v3; // eax@1
3184 3184
3185 pActor = &pActors[uActorID]; 3185 pActor = &pActors[uActorID];
3186 v2 = pSpriteFrameTable->pSpriteSFrames; 3186 v2 = pSpriteFrameTable->pSpriteSFrames;
3187 v3 = pActor->pSpriteIDs[5]; 3187 v3 = pActor->pSpriteIDs[ANIM_Dying];
3188 pActor->uCurrentActionTime = 0; 3188 pActor->uCurrentActionTime = 0;
3189 pActor->uAIState = Resurrected; 3189 pActor->uAIState = Resurrected;
3190 pActor->uCurrentActionAnimation = ANIM_Dying; 3190 pActor->uCurrentActionAnimation = ANIM_Dying;
3191 pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength; 3191 pActor->uCurrentActionLength = 8 * v2[v3].uAnimLength;
3192 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); 3192 pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP);
3194 return pActor->UpdateAnimation(); 3194 return pActor->UpdateAnimation();
3195 } 3195 }
3196 3196
3197 3197
3198 //----- (00402D6E) -------------------------------------------------------- 3198 //----- (00402D6E) --------------------------------------------------------
3199 void __fastcall Actor::Die(unsigned int uActorID) 3199 void Actor::Die(unsigned int uActorID)
3200 { 3200 {
3201 Actor *v1; // esi@1 3201 auto actor = &pActors[uActorID];
3202 SpriteFrame *v2; // ecx@1 3202
3203 int v3; // eax@1 3203 actor->uCurrentActionTime = 0;
3204 int v4; // ecx@1 3204 actor->uAIState = Dying;
3205 char *v5; // eax@1 3205 actor->uCurrentActionAnimation = ANIM_Dying;
3206 SpellBuff *v6; // edi@5 3206 actor->sCurrentHP = 0;
3207 signed int v7; // ebx@5 3207 actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Dying]].uAnimLength;
3208 MONSTER_TYPE v8; // eax@7 3208 actor->pActorBuffs[6].Reset();
3209 int v9; // eax@23 3209 actor->pActorBuffs[5].Reset();
3210 ItemGen _this; // [sp+8h] [bp-28h]@7 3210 Actor::PlaySound(uActorID, 1);
3211 unsigned int v11; // [sp+2Ch] [bp-4h]@1 3211 actor->UpdateAnimation();
3212 3212
3213 v1 = &pActors[uActorID]; 3213 for (uint i = 0; i < 5; ++i)
3214 v11 = uActorID; 3214 if (pParty->field_750[i] == actor->pMonsterInfo.uID)
3215 v2 = pSpriteFrameTable->pSpriteSFrames; 3215 pParty->field_75A[i] = true;
3216 v3 = 60 * v1->pSpriteIDs[5]; 3216
3217 v1->uCurrentActionTime = 0; 3217 for (uint i = 0; i < 22; ++i)
3218 v1->uAIState = Dying; 3218 actor->pActorBuffs[i].Reset();
3219 v1->uCurrentActionAnimation = ANIM_Dying; 3219
3220 LOWORD(v3) = *(__int16 *)((char *)&v2->uAnimLength + v3); 3220 ItemGen drop;
3221 v1->sCurrentHP = 0; 3221 switch (actor->pMonsterInfo.uID)
3222 v1->uCurrentActionLength = 8 * v3; 3222 {
3223 v1->pActorBuffs[6].Reset(); 3223 case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3:
3224 v1->pActorBuffs[5].Reset(); 3224 drop.uItemID = ITEM_HARPY_FEATHER;
3225 Actor::PlaySound(v11, 1u); 3225 break;
3226 v1->UpdateAnimation(); 3226
3227 v4 = v1->pMonsterInfo.uID; 3227 case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3:
3228 v5 = (char *)pParty->field_75A; 3228 drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
3229 do 3229 break;
3230 { 3230
3231 if ( v4 == *((short *)v5 - 5) ) 3231 case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3:
3232 *(short *)v5 = 1; 3232 drop.uItemID = ITEM_TROLL_BLOOD;
3233 v5 += 2; 3233 break;
3234 } 3234
3235 while ( (signed int)v5 < (signed int)&pParty->field_764 ); 3235 case MONSTER_DEVIL_1: case MONSTER_DEVIL_2: case MONSTER_DEVIL_3:
3236 v6 = v1->pActorBuffs; 3236 drop.uItemID = ITEM_DEVIL_ICHOR;
3237 v7 = 22; 3237 break;
3238 do 3238
3239 { 3239 case MONSTER_DRAGON_1: case MONSTER_DRAGON_2: case MONSTER_DRAGON_3:
3240 v6->Reset(); 3240 drop.uItemID = ITEM_DRAGON_EYE;
3241 ++v6; 3241 }
3242 --v7; 3242
3243 } 3243 if (rand() % 100 < 20)
3244 while ( v7 ); 3244 {
3245 _this.Reset(); 3245 sub_42F7EB_DropItemAt(pItemsTable->pItems[drop.uItemID].uSpriteID,
3246 v8 = (MONSTER_TYPE)v1->pMonsterInfo.uID; 3246 actor->vPosition.x,
3247 if ( v8 > MONSTER_HARPY_3 ) 3247 actor->vPosition.y,
3248 { 3248 actor->vPosition.z + 16,
3249 if ( v8 < MONSTER_OOZE_1 ) 3249 rand() % 200 + 200,
3250 {
3251 if ( !_this.uItemID )
3252 {
3253 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3254 Actor::Explode(v11);
3255 return;
3256 }
3257 if ( rand() % 100 < 20 )
3258 {
3259 v9 = rand();
3260 sub_42F7EB_DropItemAt(
3261 pItemsTable->pItems[_this.uItemID].uSpriteID,
3262 v1->vPosition.x,
3263 v1->vPosition.y,
3264 v1->vPosition.z + 16,
3265 v9 % 200 + 200,
3266 1,
3267 1,
3268 0,
3269 &_this);
3270 }
3271 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3272 Actor::Explode(v11);
3273 return;
3274 }
3275 if ( v8 <= MONSTER_OOZE_3 )
3276 {
3277 _this.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
3278 if ( !_this.uItemID )
3279 {
3280 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3281 Actor::Explode(v11);
3282 return;
3283 }
3284 if ( rand() % 100 < 20 )
3285 {
3286 v9 = rand();
3287 sub_42F7EB_DropItemAt(
3288 pItemsTable->pItems[_this.uItemID].uSpriteID,
3289 v1->vPosition.x,
3290 v1->vPosition.y,
3291 v1->vPosition.z + 16,
3292 v9 % 200 + 200,
3293 1,
3294 1,
3295 0,
3296 &_this);
3297 }
3298 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3299 Actor::Explode(v11);
3300 return;
3301 }
3302 if ( v8 <= MONSTER_PEASANT_GOBLIN_MALE_3_3 || v8 > MONSTER_TROLL_3 )
3303 {
3304 if ( !_this.uItemID )
3305 {
3306 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3307 Actor::Explode(v11);
3308 return;
3309 }
3310 if ( rand() % 100 < 20 )
3311 {
3312 v9 = rand();
3313 sub_42F7EB_DropItemAt(
3314 pItemsTable->pItems[_this.uItemID].uSpriteID,
3315 v1->vPosition.x,
3316 v1->vPosition.y,
3317 v1->vPosition.z + 16,
3318 v9 % 200 + 200,
3319 1,
3320 1,
3321 0,
3322 &_this);
3323 }
3324 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3325 Actor::Explode(v11);
3326 return;
3327 }
3328 _this.uItemID = ITEM_TROLL_BLOOD;
3329 }
3330 else
3331 {
3332 if ( v8 >= MONSTER_HARPY_1 )
3333 {
3334 _this.uItemID = ITEM_HARPY_FEATHER;
3335 }
3336 else
3337 {
3338 if ( v8 < MONSTER_DEVIL_1 )
3339 {
3340 if ( !_this.uItemID )
3341 {
3342 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3343 Actor::Explode(v11);
3344 return;
3345 }
3346 if ( rand() % 100 < 20 )
3347 {
3348 v9 = rand();
3349 sub_42F7EB_DropItemAt(
3350 pItemsTable->pItems[_this.uItemID].uSpriteID,
3351 v1->vPosition.x,
3352 v1->vPosition.y,
3353 v1->vPosition.z + 16,
3354 v9 % 200 + 200,
3355 1,
3356 1,
3357 0,
3358 &_this);
3359 }
3360 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3361 Actor::Explode(v11);
3362 return;
3363 }
3364 if ( v8 > MONSTER_DEVIL_3 )
3365 {
3366 if ( v8 <= MONSTER_DRAGON_3 )
3367 {
3368 _this.uItemID = ITEM_DRAGON_EYE;
3369 if ( rand() % 100 < 20 )
3370 {
3371 v9 = rand();
3372 sub_42F7EB_DropItemAt(
3373 pItemsTable->pItems[_this.uItemID].uSpriteID,
3374 v1->vPosition.x,
3375 v1->vPosition.y,
3376 v1->vPosition.z + 16,
3377 v9 % 200 + 200,
3378 1,
3379 1,
3380 0,
3381 &_this);
3382 }
3383 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3384 Actor::Explode(v11);
3385 return;
3386 }
3387 if ( !_this.uItemID )
3388 {
3389 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3390 Actor::Explode(v11);
3391 return;
3392 }
3393 if ( rand() % 100 < 20 )
3394 {
3395 v9 = rand();
3396 sub_42F7EB_DropItemAt(
3397 pItemsTable->pItems[_this.uItemID].uSpriteID,
3398 v1->vPosition.x,
3399 v1->vPosition.y,
3400 v1->vPosition.z + 16,
3401 v9 % 200 + 200,
3402 1,
3403 1,
3404 0,
3405 &_this);
3406 }
3407 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE )
3408 Actor::Explode(v11);
3409 return;
3410 }
3411 _this.uItemID = ITEM_DEVIL_ICHOR;
3412 }
3413 }
3414 if ( rand() % 100 < 20 )
3415 {
3416 v9 = rand();
3417 sub_42F7EB_DropItemAt(
3418 pItemsTable->pItems[_this.uItemID].uSpriteID,
3419 v1->vPosition.x,
3420 v1->vPosition.y,
3421 v1->vPosition.z + 16,
3422 v9 % 200 + 200,
3423 1, 3250 1,
3424 1, 3251 1,
3425 0, 3252 0,
3426 &_this); 3253 &drop);
3427 } 3254 }
3428 if ( v1->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE ) 3255
3429 Actor::Explode(v11); 3256 if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE)
3257 Actor::Explode(uActorID);
3430 } 3258 }
3431 3259
3432 //----- (00402CED) -------------------------------------------------------- 3260 //----- (00402CED) --------------------------------------------------------
3433 void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) 3261 void __fastcall Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID)
3434 { 3262 {
4127 LABEL_10: 3955 LABEL_10:
4128 result |= 0x200000u; 3956 result |= 0x200000u;
4129 this->uAttributes = result; 3957 this->uAttributes = result;
4130 break; 3958 break;
4131 case Dead: 3959 case Dead:
4132 result = 60 * this->pSpriteIDs[6]; 3960 result = 60 * this->pSpriteIDs[ANIM_Dead];
4133 if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 ) 3961 if ( *(__int16 *)((char *)pSpriteFrameTable->pSpriteSFrames->pHwSpriteIDs + result) <= 0 )
4134 this->uAIState = Removed; 3962 this->uAIState = Removed;
4135 else 3963 else
4136 this->uCurrentActionAnimation = ANIM_Dead; 3964 this->uCurrentActionAnimation = ANIM_Dead;
4137 break; 3965 break;