void CScriptFile::FoundNewItemL(const TDesC& aText, TLex& arInput, TInt& arCurrentItemStart, CScriptSection& aSection, CScriptSectionItem*& arCurrentItem) { TPtrC token = arInput.MarkedToken(); ParseAndSetItemValueL(aText, arInput, arCurrentItemStart, arCurrentItem); arInput.SkipSpaceAndMark(); arCurrentItemStart = arInput.Offset(); TPtrC itemEnd(KScriptItemEnd); const TInt length = token.Length() - itemEnd.Length(); arCurrentItem = &aSection.ReplaceItemL(token.Left(length), KNullDesC); }
void checkFieldEffects( UI32 currenttime, P_CHAR pc, char timecheck ) { VALIDATEPC(pc); if ( (timecheck && !(nextfieldeffecttime<=currenttime)) ) //changed by Luxor return; #ifdef SPAR_NEW_WR_SYSTEM pItemVectorIt itemIt( pc->nearbyItems->begin() ), itemEnd( pc->nearbyItems->end() ); for( ; itemIt != itemEnd; ++itemIt ) { P_ITEM pi= (*itemIt); #else NxwItemWrapper si; si.fillItemsNearXYZ( pc->getPosition(), 2, false ); for( si.rewind(); !si.isEmpty(); si++ ) { P_ITEM pi=si.getItem(); #endif if(ISVALIDPI(pi) ) { if ( pi->getPosition().x == pc->getPosition().x && pi->getPosition().y == pc->getPosition().y ) //Luxor: added new field damage handling switch( pi->getId() ) { case 0x3996: case 0x398C: //Fire Field if (!pc->resistsFire()) tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, (UI08)(pi->morex/100.0), DAMAGE_FIRE, 0, 0,1); return; case 0x3915: case 0x3920: //Poison Field if ((pi->morex<997)) { tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 2, DAMAGE_POISON, 0, 0,2); pc->applyPoison(POISON_WEAK); } else { tempfx::add(pc, pc, tempfx::FIELD_DAMAGE, 3, DAMAGE_POISON, 0, 0,2); // gm mages can cast greater poison field, LB pc->applyPoison(POISON_NORMAL); } return; case 0x3979: case 0x3967: //Para Field if (chance(50)) { tempfx::add(pc, pc, tempfx::SPELL_PARALYZE, 0, 0, 0, 0,3); pc->playSFX( 0x0204 ); } return; } } } } void checktimers() // Check shutdown timers { overflow = (lclock > uiCurrentTime); if (endtime) { if ( endtime <= uiCurrentTime ) keeprun=false; } lclock = uiCurrentTime; }
void CScriptFile::ParseScriptSectionsL(const TDesC& aScript, TInt aInsertIndex) { iLastSection = NULL; CScriptSection* section = NULL; CScriptSectionItem* currentItem = NULL; TInt currentItemStart = 0; CScriptSection* sectionAll = NULL; RArray<TInt> sectionIndexArray; CleanupClosePushL(sectionIndexArray); TInt indexIncrement = 0; HBufC* scriptContents = ReadFileLC(aScript); TLex input(*scriptContents); while (!input.Eos()) { input.SkipSpaceAndMark(); input.SkipCharacters(); if ( input.TokenLength() == 0 ) // if valid potential token { break; } TPtrC token = input.MarkedToken(); if (token.CompareF(_L("endscript")) == 0) { break; } else if (token.FindF(KScriptSectionStart) == 0 && token.Length() > 2) { ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem); TInt mid = 1; TInt len = token.Length() - 2; if (sectionAll) section = CScriptSection::NewLC(token.Mid(mid, len), *sectionAll); else section = CScriptSection::NewLC(token.Mid(mid, len)); if (!sectionAll && section->SectionName().CompareF(_L("All")) == 0) sectionAll = section; // We have a Scripts section, store its index as we need to track where // it occured so that the scripts can be added in the same location // after the current file has parsed if (section->SectionName().CompareF(KScriptsSection) == 0) { if(aInsertIndex==KErrNotFound) { // Not an embedded script, simple store its index TInt currectSectionsCount = iSections->Count(); sectionIndexArray.Append(currectSectionsCount); } else { // An embedded script, calculate the index it should be inserted at TInt currectSectionsCount = indexIncrement+aInsertIndex; sectionIndexArray.Append(currectSectionsCount); } } // Check if the section needs to be inserted at a particular location if(aInsertIndex==KErrNotFound) iSections->AppendL(section); else iSections->InsertL(aInsertIndex + indexIncrement++, section); CleanupStack::Pop(section); } else if (section) { TPtrC itemEnd(KScriptItemEnd); if (itemEnd.Length() < token.Length() && token.Right(itemEnd.Length()).CompareF(itemEnd) == 0) { FoundNewItemL(*scriptContents, input, currentItemStart, *section, currentItem); } } } ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem); CleanupStack::PopAndDestroy(scriptContents); // We have been tracking where the script sections have been inserted so we // want to load the sections from the embedded script file and insert them // at the same point. This must be done in reverse order so that the index // values of script sections before the current one is maintained. TInt scriptSectionsCount = sectionIndexArray.Count(); for( TInt ii=scriptSectionsCount-1; ii>=0; --ii) { TInt indexOfScriptSection = sectionIndexArray[ii]; ParseEmbeddedScriptsL(*(iSections->At(indexOfScriptSection)), indexOfScriptSection); } CleanupStack::PopAndDestroy(§ionIndexArray); }