diff Events.cpp @ 501:6fa3ff8ef729

SubtractVariables
author Ritor1
date Fri, 01 Mar 2013 17:37:47 +0600
parents 4bd56919f075
children dd5124185551
line wrap: on
line diff
--- a/Events.cpp	Thu Feb 28 10:36:37 2013 +0600
+++ b/Events.cpp	Fri Mar 01 17:37:47 2013 +0600
@@ -204,7 +204,7 @@
 	int v60; // eax@126
 	int v61; // edx@133
 	int v62; // eax@139
-	void *v63; // ebp@145
+	int v63; // ebp@145
 	signed int v64; // edi@146
 	unsigned int v65; // edx@148
 	Player *v66; // ecx@148
@@ -221,8 +221,8 @@
 	signed int v77; // ebp@186
 	int v78; // edx@186
 	Player *v79; // esi@187
-	signed int v80; // ebp@200
-	int v81; // edx@200
+	//signed int v80; // ebp@200
+	//int v81; // edx@200
 	Player *v82; // esi@201
 	int v83; // eax@212
 	int v84; // ebp@220
@@ -266,7 +266,7 @@
 	int curr_seq_num; // [sp+10h] [bp-498h]@4
 	//char *v123; // [sp+14h] [bp-494h]@0
 	signed int v124; // [sp+18h] [bp-490h]@7
-	signed int v125; // [sp+1Ch] [bp-48Ch]@155
+	//signed int v125; // [sp+1Ch] [bp-48Ch]@155
 	int v126; // [sp+1Ch] [bp-48Ch]@262
 	int player_choose; // [sp+20h] [bp-488h]@4
 	int v128; // [sp+24h] [bp-484h]@21
@@ -821,7 +821,7 @@
 				//v6 = v123;
 				//v7 = "";
 				break;
-			case EVENT_Compare://_evt->_e_type == 14 cmp in Global.evt event 6
+			case EVENT_Compare:
 				pValue = EVT_DWORD(_evt->v7);
 				if ( player_choose <= 3 )
 					{
@@ -882,12 +882,12 @@
 				 v4 = v124;
 				 break;
 			case EVENT_Substract:
-				v63 = (void *)(_evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8));
-				if ( _evt->v5 + ((uint)_evt->v6 << 8) == VAR_PlayerItemInHands )
+				pValue = EVT_DWORD(_evt->v7);
+				if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands )
+				{
+					v64 = 0;
+					if ( pParty->pPickedItem.uItemID == pValue )
 					{
-					v64 = 0;
-					if ( (void *)pParty->pPickedItem.uItemID == v63 )
-						{
 						pMouse->RemoveHoldingItem();
 						++curr_seq_num;
 						v4 = v124;
@@ -895,14 +895,14 @@
 						//v6 = v123;
 						//v7 = "";
 						break;
-						}
+					}
 					v65 = 0;
 					v66 = pPlayers[uActiveCharacter];
 					v67 = (int)v66->pInventoryIndices;
 					do
+					{
+						if ( (int)&v66->pInventoryItems[v67] == pValue )
 						{
-						if ( *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v67 + 5] == v63 )
-							{
 							v66->RemoveItemAtInventoryIndex(v65);
 							++curr_seq_num;
 							v4 = v124;
@@ -910,17 +910,17 @@
 							//v6 = v123;
 							//v7 = "";
 							break;
-							}
+						}
 						++v65;
 						v67 += 4;
-						}
-						while ( (signed int)v65 < 126 );
+					}
+					while ( (signed int)v65 < 126 );
 						v68 = 0;
 						v69 = (int)&v66->pEquipment;
 						do
+						{
+							if ( *(int *)v69 && (int)&v66->pInventoryItems[v69] == pValue )
 							{
-							if ( *(int *)v69 && *(void **)&v66->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v69 + 5] == v63 )
-								{
 								*(&v66->pEquipment.uOffHand + v68) = 0;
 								++curr_seq_num;
 								v4 = v124;
@@ -928,105 +928,143 @@
 								//v6 = v123;
 								//v7 = "";
 								break;
-								}
+							}
 							++v68;
 							v69 += 4;
-							}
-							while ( v68 < 16 );
-							v125 = (signed int)&pPlayers[1];
+						}
+						while ( v68 < 16 );
+							pPlayer = pPlayers[1];
 							while ( 1 )
+							{
+								v70 = pPlayer;
+								if ( !v64 )
 								{
-								v70 = *(Player **)v125;
-								if ( !v64 )
-									{
 									v71 = 0;
 									v72 = (int)v70->pInventoryIndices;
 									do
+									{
+										if ( (int)&v70->pInventoryItems[v72] == pValue )
 										{
-										if ( *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v72 + 5] == v63 )
-											{
 											v70->RemoveItemAtInventoryIndex(v71);
 											goto LABEL_169;
-											}
+										}
 										++v71;
 										v72 += 4;
-										}
-										while ( (signed int)v71 < 126 );
+									}
+									while ( (signed int)v71 < 126 );
 										v73 = 0;
 										v74 = (int)&v70->pEquipment;
-										while ( !*(int *)v74
-											|| *(void **)&v70->spellbook.pDarkSpellbook.bIsSpellAvailable[36 * *(int *)v74 + 5] != v63 )
-											{
+										while ( !*(int *)v74 || (int)&v70->pInventoryItems[v74] != pValue )
+										{
 											++v73;
 											v74 += 4;
 											if ( v73 >= 16 )
 												goto LABEL_170;
-											}
+										}
 										*(&v70->pEquipment.uOffHand + v73) = 0;
 LABEL_169:
 										v64 = 1;
-									}
+								}
 LABEL_170:
-								v125 += 4;
-								if ( v125 > (signed int)&pPlayers[4] )
-									{
+								pPlayer += 4;
+								if ( pPlayer > pPlayers[4] )
+								{
 									++curr_seq_num;
 									v4 = v124;
 									
 									//v6 = v123;
 									//v7 = "";
 									break;
-									}
 								}
+							}
 					}
 				v75 = player_choose;
-				if ( player_choose != 5 )
+				if ( player_choose <= 3 )
+				{
+					pPlayer = &pParty->pPlayers[v75];
+					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					++curr_seq_num;
+					//v4 = v124;
+					break;
+				}
+				else if ( player_choose == 4 ) //active
+				{
+					if ( uActiveCharacter )
 					{
+						pPlayer = pPlayers[uActiveCharacter];
+						pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+						++curr_seq_num;
+						v4 = v124;
+						break;
+					}
+				}
+				else 	if ( player_choose == 5 )//all
+				{
+					v130=0;
+					for(int i=0; i<4; ++i)
+					{
+						if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
+						{
+							++curr_seq_num;
+							break;
+						}
+					}
+					++v130;
+					break;
+				}
+				else if ( player_choose == 6 ) //random
+				{
+					v75 = rand() % 4;
+					pPlayer = &pParty->pPlayers[v75];
+					pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
+					++curr_seq_num;
+					v4 = v124;
+					break;
+				}
+/*				if ( player_choose != 5 )
+				{
 					if ( player_choose < 0 )
 						goto LABEL_183;
-					if ( player_choose > 3 )
+					//if ( player_choose > 3 )
+					//{
+						if ( player_choose != 4 )
 						{
-						if ( player_choose != 4 )
-							{
 							if ( player_choose == 6 )
 								goto LABEL_180;
 LABEL_183:
-							((Player *)v6)->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
+							((Player *)v6)->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
 							++curr_seq_num;
 							v4 = v124;
 							
 							//v6 = v123;
 							//v7 = "";
 							break;
-							}
+						}
 						if ( uActiveCharacter )
-							{
+						{
 							v6 = pPlayers[uActiveCharacter];
 							goto LABEL_182;
-							}
+						}
 LABEL_180:
 						v75 = rand() % 4;
 						
-						}
+					//}
 					v6 = &pParty->pPlayers[v75];
 LABEL_182:
 					//v123 = v6;
 					goto LABEL_183;
-					}
-				v76 = pParty->pPlayers;
-				v130 = 4;
-				do
+				}
+				v130=0;
+				for(int i=0; i<4; ++i)
+				{
+					if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) )
 					{
-					v76->SubtractVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v63);
-					++v76;
+						++curr_seq_num;
+						break;
 					}
-					while ( (signed int)v76 < (signed int)pParty->pHirelings );
-					++curr_seq_num;
-					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
-					break;
+				}
+				++v130;
+				break;*/
 			case EVENT_Set:
 				v77 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
 				v78 = player_choose;
@@ -1078,8 +1116,8 @@
 					//v7 = "";
 					break;
 			case EVENT_Add:
-				v80 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8);
-				v81 = player_choose;
+				pValue = EVT_DWORD(_evt->v7);
+				//v81 = player_choose;
 				if ( player_choose != 5 )
 					{
 					if ( player_choose < 0 )
@@ -1091,7 +1129,7 @@
 							if ( player_choose == 6 )
 								goto LABEL_208;
 LABEL_211:
-							((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80);
+							((Player *)v6)->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), pValue);
 							goto LABEL_212;
 							}
 						if ( uActiveCharacter )
@@ -1100,31 +1138,23 @@
 							goto LABEL_210;
 							}
 LABEL_208:
-						v81 = rand() % 4;
+						player_choose = rand() % 4;
 						
 						}
-					v6 = &pParty->pPlayers[v81];
+					v6 = &pParty->pPlayers[player_choose];
 LABEL_210:
 					//v123 = v6;
 					goto LABEL_211;
 					}
-				v82 = pParty->pPlayers;
-				v130 = 4;
-				do
-					{
-					v82->AddVariable((enum VariableType)(_evt->v5 + ((uint)_evt->v6 << 8)), v80);
-					++v82;
-					}
-					while ( (signed int)v82 < (signed int)pParty->pHirelings );
+				v130 = 0;
+				for(int i=1; i<5; ++i)
+					pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
 LABEL_212:
-					v83 = _evt->v5 + ((uint)_evt->v6 << 8);
+					v83 = EVT_WORD(_evt->v5);
 					if ( v83 == 21 || v83 == 22 || v83 == 23 || v83 == 24 )
 						viewparams->bRedrawGameUI = 1;
 					++curr_seq_num;
 					v4 = v124;
-					
-					//v6 = v123;
-					//v7 = "";
 					break;
 			case EVENT_InputString:
 				if ( !start_event_seq_number )