Beispiel #1
0
void LoadNPCList()
{
  int i = 0;
  int j = 0;
  int k = 0;
  FILE *file;
  char *c;
  char buf[512];
  file = fopen("system/npclist.def","r");
  if(file == NULL)
  {
    fprintf(stderr,"Unable to open npc file\n");
    return;
  }
  memset(&NPCList,0,sizeof(NPCList));
  i = 0;
  j = 0;
  k = 0;
  NumNPCS = 0;
  while(fscanf(file, "%s", buf) != EOF)
  {
    if(strcmp(buf,"#") ==0)
    {
      fgets(buf, sizeof(buf), file);
      continue;/*ignore the rest of the line.*/
    }
    if(strcmp(buf,"</NPC>") ==0)
    {
      i++;
      NumNPCS++;
      if(i >= MAXNPCS)
      {
        fprintf(stderr,"maximum number of NPCS loaded from file!\n");
        return;
      }
      continue;
    }
    if(strcmp(buf,"<NPC>") ==0)
    {
      fgetc(file);  /*clear the space before the word*/
      fgets(NPCList[i].name, 80, file);
      c = strchr(NPCList[i].name, '\n');
      if(c != NULL) *c = '\0';    /*replace trailing return with terminating character*/
        continue;
    }
    if(strcmp(buf,"<monster>") ==0)
    {
      fgetc(file);  /*clear the space before the word*/
      fgets(NPCList[i].monster, 80, file);
      c = strchr(NPCList[i].monster, '\n');
      if(c != NULL) *c = '\0';    /*replace trailing return with terminating character*/
        continue;
    }
    if(strcmp(buf,"<questlist>") ==0)
    {
      LoadQuest(file,i);
      continue;
    }
    if(strcmp(buf,"<shoplist>") ==0)
    {
      LoadShop(file,i);
      continue;
    }
    if(strcmp(buf,"<dialoglist>") ==0)
    {
      LoadDialog(file,i);
      continue;
    }
  }
  fclose(file);
}
Beispiel #2
0
void __fastcall LoadGame(bool firstflag)
{
	int v1; // esi
	int v2; // edi
	int v5; // ebx
	int v6; // eax
	int v7; // eax
	int v8; // ecx
	bool v9; // sf
	unsigned char v10; // of
	int *v11; // esi
	int *v12; // esi
	int i; // esi
	int *v14; // esi
	int *v15; // esi
	int j; // esi
	int *v17; // esi
	int *v18; // esi
	int k; // esi
	int l; // esi
	signed int v21; // esi
	int m; // esi
	int v23; // esi
	int *v24; // esi
	int *v25; // esi
	int n; // esi
	int *v27; // esi
	char *v29; // edi
	char *v30; // edi
	char *v31; // edi
	char *v32; // edi
	int (*v33)[112]; // ebx
	_DWORD *v34; // edi
	char *v35; // edi
	char *v36; // edi
	char *v37; // edi
	char *v38; // edi
	signed int v39; // ebx
	bool *v40; // edi
	char *v41; // edi
	int v42; // esi
	char dst[260]; // [esp+0h] [ebp-120h]
	int len; // [esp+104h] [ebp-1Ch]
	int v46; // [esp+108h] [ebp-18h]
	int v47; // [esp+10Ch] [ebp-14h]
	void *ptr; // [esp+110h] [ebp-10h]
	int v49; // [esp+114h] [ebp-Ch]
	int from_save; // [esp+118h] [ebp-8h]
	int quest_num; // [esp+11Ch] [ebp-4h]

	FreeGameMem();
	pfile_remove_temp_files();
	pfile_get_game_name(dst);
	ptr = pfile_read(dst, &len);
	tbuff = ptr;
	if ( ILoad_2() != 'RETL' )
		TermMsg("Invalid save file");
	setlevel = OLoad();
	setlvlnum = ILoad();
	currlevel = ILoad();
	leveltype = ILoad();
	v1 = ILoad();
	v2 = ILoad();
	invflag = OLoad();
	chrflag = OLoad();
	v5 = ILoad();
	v47 = ILoad();
	v49 = ILoad();
	v6 = ILoad();
	quest_num = 0;
	v46 = v6;
	do
	{
		*(int *)((char *)glSeedTbl + quest_num) = ILoad_2();
		v7 = ILoad();
		v8 = quest_num;
		quest_num += 4;
		v10 = __OFSUB__(quest_num, 68);
		v9 = quest_num - 68 < 0;
		*(int *)((char *)gnLevelTypeTbl + v8) = v7;
	}
	while ( v9 ^ v10 );
	LoadPlayer(myplr);
	quest_num = 0;
	do
		LoadQuest(quest_num++);
	while ( quest_num < 16 );
	quest_num = 0;
	do
		LoadPortal(quest_num++);
	while ( quest_num < 4 );
	LoadGameLevel(firstflag, 4);
	SyncInitPlr(myplr);
	SyncPlrAnim(myplr);
	ViewX = v1;
	numitems = v47;
	nummissiles = v49;
	ViewY = v2;
	nummonsters = v5;
	nobjects = v46;
	v11 = monstkills;
	do
	{
		*v11 = ILoad_2();
		++v11;
	}
	while ( (signed int)v11 < (signed int)&monstkills[200] );
	if ( leveltype )
	{
		v12 = monstactive;
		do
		{
			*v12 = ILoad();
			++v12;
		}
		while ( (signed int)v12 < (signed int)&monstactive[200] );
		for ( i = 0; i < nummonsters; ++i )
			LoadMonster(monstactive[i]);
		v14 = missileactive;
		do
		{
			*v14 = BLoad();
			++v14;
		}
		while ( (signed int)v14 < (signed int)&missileactive[125] );
		v15 = missileavail;
		do
		{
			*v15 = BLoad();
			++v15;
		}
		while ( (signed int)v15 < (signed int)&missileavail[125] );
		for ( j = 0; j < nummissiles; ++j )
			LoadMissile(missileactive[j]);
		v17 = objectactive;
		do
		{
			*v17 = BLoad();
			++v17;
		}
		while ( (signed int)v17 < (signed int)&objectactive[127] );
		v18 = objectavail;
		do
		{
			*v18 = BLoad();
			++v18;
		}
		while ( (signed int)v18 < (signed int)&objectavail[127] );
		for ( k = 0; k < nobjects; ++k )
			LoadObject(objectactive[k]);
		for ( l = 0; l < nobjects; ++l )
			SyncObjectAnim(objectactive[l]);
		numlights = ILoad();
		v21 = 0;
		do
			lightactive[v21++] = BLoad();
		while ( v21 < 32 );
		for ( m = 0; m < numlights; ++m )
			LoadLighting((unsigned char)lightactive[m]);
		visionid = ILoad();
		v23 = 0;
		numvision = ILoad();
		if ( numvision > 0 )
		{
			do
				LoadVision(v23++);
			while ( v23 < numvision );
		}
	}
	v24 = itemactive;
	do
	{
		*v24 = BLoad();
		++v24;
	}
	while ( (signed int)v24 < (signed int)&itemactive[127] );
	v25 = itemavail;
	do
	{
		*v25 = BLoad();
		++v25;
	}
	while ( (signed int)v25 < (signed int)&itemavail[127] );
	for ( n = 0; n < numitems; ++n )
		LoadItem(itemactive[n]);
	v27 = UniqueItemFlag;
	do
	{
		*v27 = OLoad();
		++v27;
	}
	while ( (signed int)v27 < (signed int)&UniqueItemFlag[128] );
	quest_num = 0;
	do
	{
		from_save = 112;
		v29 = (char *)dTransVal + quest_num;
		do
		{
			*v29 = BLoad();
			v29 += 112;
			--from_save;
		}
		while ( from_save );
		++quest_num;
	}
	while ( quest_num < 112 );
	quest_num = 0;
	do
	{
		from_save = 112;
		v30 = (char *)dFlags + quest_num;
		do
		{
			*v30 = BLoad();
			v30 += 112;
			--from_save;
		}
		while ( from_save );
		++quest_num;
	}
	while ( quest_num < 112 );
	quest_num = 0;
	do
	{
		from_save = 112;
		v31 = (char *)dPlayer + quest_num;
		do
		{
			*v31 = BLoad();
			v31 += 112;
			--from_save;
		}
		while ( from_save );
		++quest_num;
	}
	while ( quest_num < 112 );
	quest_num = 0;
	do
	{
		from_save = 112;
		v32 = (char *)dItem + quest_num;
		do
		{
			*v32 = BLoad();
			v32 += 112;
			--from_save;
		}
		while ( from_save );
		++quest_num;
	}
	while ( quest_num < 112 );
	if ( leveltype )
	{
		v33 = dMonster;
		do
		{
			v34 = (unsigned int *)v33;
			from_save = 112;
			do
			{
				*v34 = ILoad();
				v34 += 112;
				--from_save;
			}
			while ( from_save );
			v33 = (int (*)[112])((char *)v33 + 4);
		}
		while ( (signed int)v33 < (signed int)dMonster[1] );
		quest_num = 0;
		do
		{
			from_save = 112;
			v35 = (char *)dDead + quest_num;
			do
			{
				*v35 = BLoad();
				v35 += 112;
				--from_save;
			}
			while ( from_save );
			++quest_num;
		}
		while ( quest_num < 112 );
		quest_num = 0;
		do
		{
			from_save = 112;
			v36 = (char *)dObject + quest_num;
			do
			{
				*v36 = BLoad();
				v36 += 112;
				--from_save;
			}
			while ( from_save );
			++quest_num;
		}
		while ( quest_num < 112 );
		quest_num = 0;
		do
		{
			from_save = 112;
			v37 = (char *)dTransVal + quest_num;
			do
			{
				*v37 = BLoad();
				v37 += 112;
				--from_save;
			}
			while ( from_save );
			++quest_num;
		}
		while ( quest_num < 112 );
		quest_num = 0;
		do
		{
			from_save = 112;
			v38 = (char *)dTransVal2 + quest_num;
			do
			{
				*v38 = BLoad();
				v38 += 112;
				--from_save;
			}
			while ( from_save );
			++quest_num;
		}
		while ( quest_num < 112 );
		v39 = 0;
		do
		{
			v40 = (bool *)automapview + v39;
			from_save = 40;
			do
			{
				*v40 = OLoad();
				v40 += 40;
				--from_save;
			}
			while ( from_save );
			++v39;
		}
		while ( v39 < 40 );
		quest_num = 0;
		do
		{
			from_save = 112;
			v41 = (char *)dMissile + quest_num;
			do
			{
				*v41 = BLoad();
				v41 += 112;
				--from_save;
			}
			while ( from_save );
			++quest_num;
		}
		while ( quest_num < 112 );
	}
	numpremium = ILoad();
	premiumlevel = ILoad();
	v42 = 0;
	do
		LoadPremium(v42++);
	while ( v42 < 6 );
	automapflag = OLoad();
	AutoMapScale = ILoad();
	mem_free_dbg(ptr);
	AutomapZoomReset();
	ResyncQuests();
	if ( leveltype )
		ProcessLightList();
	RedoPlayerVision();
	ProcessVisionList();
	missiles_process_charge();
	ResetPal();
	SetCursor(CURSOR_HAND);
	gbProcessPlayers = 1;
}
void pawsNpcDialogWindow::HandleMessage(MsgEntry* me)
{
    if(me->GetType() == MSGTYPE_DIALOG_MENU)
    {
        psDialogMenuMessage mesg(me);

        Debug2(LOG_QUESTS, 0,"Got psDialogMenuMessage: %s\n", mesg.xml.GetDataSafe());
        responseList->Clear();

        SelfPopulateXML(mesg.xml);

        if(useBubbles)
        {
            speechBubble->Hide(); // hide previous npc say response
            LoadQuest(mesg.xml);
            AdjustForPromptWindow(); // should be done before DisplayQuestBubbles
            DisplayQuestBubbles(displayIndex);
            gotNewMenu = true;
        }
        else
        {
            AdjustForPromptWindow();
        }

        Show();
    }
    else if(me->GetType() == MSGTYPE_CHAT)
    {
        psChatMessage chatMsg(me);
        Debug2(LOG_QUESTS, 0,"Got Chat message from NPC: %s\n", (const char*)chatMsg.sText);

        GEMClientActor* actor = dynamic_cast<GEMClientActor*>(psengine->GetCelClient()->FindObject(chatMsg.actor));
        if(!actor)
            return;

        // handle the basic action types, in the future we could play an animation as well
        csString inText ;
        switch(chatMsg.iChatType)
        {
            case CHAT_NPC_ME:
            {
                inText.Format("(%s %s)", (const char*)chatMsg.sPerson, ((const char*)chatMsg.sText));
                break;
            }

            case CHAT_NPC_MY:
            {
                inText.Format("(%s's %s)", (const char*)chatMsg.sPerson, ((const char*)chatMsg.sText));
                break;
            }

            case CHAT_NPC_NARRATE:
            {
                inText.Format("(%s)", (const char*)chatMsg.sText);
                break;
            }
            default:
                inText = chatMsg.sText;
        }
        NpcSays(inText, actor);

        //checks if the NPC Dialogue is displayed, in this case don't show the normal overhead bubble
        if(IsVisible())
            return;
    }
    else if(me->GetType() == MSGTYPE_REMOVE_OBJECT)
    {
        psRemoveObject mesg(me);
        //if the current target is being removed hide this window
        if(IsVisible() && targetEID.IsValid() && mesg.objectEID.IsValid() && mesg.objectEID == targetEID)
        {
            Hide();
            //In these cases something might have gone wrong with the camera
            //eg: the character is being teleported. So we need to have it reset
            //correctly.
            psengine->GetPSCamera()->ResetCameraPositioning();
        }
    }
}