diff mm7_3.cpp @ 1413:3881d2f94eb1

UseNPCSkill DIALOGUE_USE_NPC_ABILITY
author Nomad
date Sat, 27 Jul 2013 16:09:00 +0200
parents 182d58b2a34c
children 483b1b453986 a8b1bbac95d4
line wrap: on
line diff
--- a/mm7_3.cpp	Sat Jul 27 14:28:14 2013 +0200
+++ b/mm7_3.cpp	Sat Jul 27 16:09:00 2013 +0200
@@ -2207,8 +2207,8 @@
   int bFeatherFall; // [sp+28h] [bp-6Ch]@4
   int v105; // [sp+2Ch] [bp-68h]@24
   int bWaterWalk; // [sp+30h] [bp-64h]@1
-  bool v107; // [sp+34h] [bp-60h]@30
-  int v108; // [sp+38h] [bp-5Ch]@1
+  //bool v107; // [sp+34h] [bp-60h]@30
+  //int v108; // [sp+38h] [bp-5Ch]@1
   int v109; // [sp+3Ch] [bp-58h]@28
   int v110; // [sp+40h] [bp-54h]@180
   int v111; // [sp+44h] [bp-50h]@14
@@ -2230,7 +2230,7 @@
   BSPModel *v127; // [sp+84h] [bp-10h]@1
   int v128; // [sp+88h] [bp-Ch]@1
   int v129; // [sp+8Ch] [bp-8h]@92
-  int v130; // [sp+90h] [bp-4h]@14
+  //int v130; // [sp+90h] [bp-4h]@14
 
   v121 = pParty->uFallSpeed;
   pZ = pParty->vPosition.z;
@@ -2247,22 +2247,12 @@
   auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y);
   v114 = 0;
   v124 = 0;
-  v108 = 0;
   v102 = 0;
   v127 = 0;
   bWaterWalk = 0;
   if (!pParty->FeatherFallActive())
-      //SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0
-      //|| SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 )
   {
     bFeatherFall = 0;
-    /*v119 = &pPlayers[1];
-    while ( !(*v119)->WearsItem(536, 16) )
-    {
-      ++v119;
-      if ( (signed int)v119 > (signed int)&pPlayers[4] )
-        goto LABEL_9;
-    }*/
     for (int i = 0; i < 4; ++i)
       if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY))  // seems like flying boots
       {
@@ -2285,7 +2275,11 @@
 		pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 )
       bWaterWalk = 0;
   }
-  v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
+  int bmodel_standing_on_pid;
+  int is_on_water = false;
+  v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
+  int is_not_on_bmodel = bmodel_standing_on_pid == 0;
+
   v111 = v3;
   if ( bFeatherFall )
     pParty->uFallStartY = v3;
@@ -2316,7 +2310,7 @@
   v109 = -1;
   if ( pParty->bFlying )
     v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102);
-  v107 = v108 == 0;
+  //v107 = bmodel_standing_on_pid == 0;
   v105 = v111 + 1;
   if ( pZ <= v111 + 1 )
   {
@@ -2334,20 +2328,18 @@
       pParty->walk_sound_timer -= pEventTimer->uTimeElapsed;
     else pParty->walk_sound_timer = 0;
   }
-  if (!bUnderwater
-    && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0
-    && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) )
+  if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0)
     pParty->bFlying = false;
   if (!bJumping)
   {
-    if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) )
+    if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) )
     {
-      if (v108)
+      if (bmodel_standing_on_pid)
       {
-        if ( v108 >> 6 < pOutdoor->uNumBModels )
+        if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels )
         {
-          v7 = pOutdoor->pBModels[v108 >> 6].pFaces;
-          v6 = v108 & 0x3F;
+          v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces;
+          v6 = bmodel_standing_on_pid & 0x3F;
           /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 )
           {
             pParty->field_6F4_packedid = PID(OBJECT_BModel,v108);
@@ -2355,13 +2347,13 @@
           }*/
 		  if ( BYTE3(v7[v6].uAttributes) & 4 )
           {
-            pParty->floor_face_pid = PID(OBJECT_BModel, v108);
+            pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);
             v103 = v7[v6].sCogTriggeredID;
           }
         }
       }
     }
-    pParty->floor_face_pid = PID(OBJECT_BModel, v108);
+    pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);
   }
   _walk_speed = pParty->uWalkSpeed;
   _angle_y = pParty->sRotationY;
@@ -2547,7 +2539,7 @@
 
           v128 = v1;
         }
-        else if (partyAtHighSlope && !v108)
+        else if (partyAtHighSlope && !bmodel_standing_on_pid)
         {
           v2 += dx;
           v1 += dy;
@@ -2633,7 +2625,7 @@
       break;
 
       case PARTY_Jump:
-        if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
+        if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) )
         {
           v126 = pParty->field_24 << 6;
           bJumping = 1;
@@ -2677,7 +2669,7 @@
     }
 	else
 	{
-		if ( v130 && v121 )
+		if ( is_on_water && v121 )
 		  sub_42F960_create_object(pX, pY, v111);
 		v121 = 0;
 		pZ = v111;
@@ -2707,7 +2699,7 @@
   }
   else if (!bJumping)
   {
-    if ( !v108 )
+    if ( !bmodel_standing_on_pid )
 	{
 		// rolling down the hill
 		// how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
@@ -2801,18 +2793,18 @@
       v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ;
     }
     v122 = v40;
-    ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
-    v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &v130, &v97, 0);
-    auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &v130, &v110, 0);
+    ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
+    v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0);
+    auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0);
     v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
     v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
-    v107 = 0;
+    is_not_on_bmodel = false;
     v118 = v42;
-    if ( !v97 && !v110 && !v108 )
-      v107 = 1;
+    if ( !v97 && !v110 && !bmodel_standing_on_pid )
+      is_not_on_bmodel = true;
     v43 = 1;
     v44 = 1;
-    if ( bUnderwater || !v107 )
+    if ( bUnderwater || !is_not_on_bmodel )
 	{
 		  pX = _angle_x;
 		  if ( v43 )
@@ -2834,7 +2826,7 @@
 		  pY = _angle_y;
 		else
 		{
-			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0);
+			v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
 			if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ )
 			{
 			  v43 = 1;
@@ -2846,7 +2838,7 @@
 	}
     if ( stru_721530.field_7C >= stru_721530.field_6C )
     {
-      if ( !v107 )
+      if ( !is_not_on_bmodel )
       {
         pX = stru_721530.normal2.x;
         pY = stru_721530.normal2.y;
@@ -2877,9 +2869,8 @@
     {
       v56 = integer_sqrt(v2 * v2 + v128 * v128);
       v118 = v56;
-      v57 = stru_5C6E00->Atan2(
-              _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
-              _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
+      v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
+                               _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
       v129 = v57;
       v58 = (BSPModel *)stru_5C6E00->Cos(v57);
       v127 = v58;
@@ -2920,7 +2911,7 @@
 				v2 = 0;
 				*(float *)&v128 = 0.0;
 			}
-			if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 )
+			if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE))
 			{
 				pParty->floor_face_pid = v45;
 				v103 = v47->sCogTriggeredID;
@@ -3035,7 +3026,7 @@
 	{
 		if ( v114 && (!bJumping || v101) )
 		{
-		  if ( !v107
+		  if ( !is_not_on_bmodel
 			&& !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
 		  {
             pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0);
@@ -3052,7 +3043,7 @@
 		{
 			if ( v124 && (!bJumping || v101) )
 			{
-			  if ( v107
+			  if ( is_not_on_bmodel
 				|| BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
 			  {
 				v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
@@ -3079,14 +3070,14 @@
   v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
   v114 = WorldPosToGridCellX(pX);
   v66 = WorldPosToGridCellZ(pY) - 1;
-  v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
-  v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
+  v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1);
+  v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1;
   v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66);
   v68 = 0;
-  v69 = ((unsigned int)~v67 >> 1) & 1;
+  v69 = (~(unsigned int)v67 >> 1) & 1;
   if ( v114 == v126 && v66 == v65 && v122 && v69 )
     v68 = 1;
-  if ( !v107 )
+  if ( !is_not_on_bmodel )
     v68 = 1;
   if ( v68 )
   {