AD商业广告自由选择
AD商业广告自由选择

GOD引擎 NPC加永久点txt文本保存代码写法

正文概述 开源人   2024-11-04 23:31:56  
procedure TNormNpc.ActionOfADDSHUXING(PlayObject: TPlayObject; ActionInfo: pTActionInfo);
var
  I, nVal: Integer;
  cMethod: Char;
  sFileDir, sFilePatchName, tStr, sVal,sWhere, sParam, sValue: string;
  nStatusVal: Int64;
  BaseObject: TBaseObject;
  LoadstrList: TStringList;
begin
  try
    sParam := GetParamStrValue(PlayObject, ActionInfo.sParam1);
    sValue := GetParamStrValue(PlayObject, ActionInfo.sParam3);

    if (StrToInt(sParam) >= MAX_STATUS_ATTR) or (StrToInt(sParam) < 0) or (StrToInt(sValue) < 0) then begin
      ScriptError(PlayObject, '', ActionInfo);
      Exit;
    end;

    BaseObject := PlayObject;
    if ActionInfo.sOpHName = 'H' then begin
      if PlayObject.m_MyHero = nil then
        Exit;
      BaseObject := PlayObject.m_MyHero;
    end;

    sFileDir := g_Config.sEnvirDir + 'ADDShuXing\';
    if not DirectoryExists(sFileDir) then
      CreateDir(sFileDir);
    sFilePatchName := sFileDir + PlayObject.m_sCharName + '.txt';

    cMethod := ActionInfo.sParam2[1];
    case cMethod of
      '=':
        begin
           //PlayObject.m_BonusAbil

           if FileExists(sFilePatchName) then begin
              LoadstrList := TStringList.Create;
              LoadstrList.LoadFromFile(sFilePatchName);
              if LoadstrList.Count > 0 then
              begin
                for I := 0 to LoadstrList.Count - 1 do
                begin
                  tStr := LoadstrList.Strings[I];
                  sVal := GetValidStr3(tStr, sWhere, ['=', #9]);
                  if sWhere = sParam then
                  begin
                    LoadstrList.Strings[I] := sParam + '=' + sValue;
                    LoadstrList.SaveToFile(sFilePatchName);
                  end;
                end;
              end
              else
              begin
                LoadstrList.Strings[0] := sParam + '=' + sValue;
                LoadstrList.SaveToFile(sFilePatchName);
              end;
           end;
        end;
      '-':
        begin
           if FileExists(sFilePatchName) then begin
              LoadstrList := TStringList.Create;
              LoadstrList.LoadFromFile(sFilePatchName);
              if LoadstrList.Count > 0 then
              begin
                for I := 0 to LoadstrList.Count - 1 do
                begin
                  tStr := LoadstrList.Strings[I];
                  sVal := GetValidStr3(tStr, sWhere, ['=', #9]);
                  if sWhere = sParam then
                  begin
                    nVal := strtoint(sVal) - strtoint(sValue);
                    LoadstrList.Strings[I] := sParam + '=' + IntToStr(nVal);
                    LoadstrList.SaveToFile(sFilePatchName);
                  end;
                end;
              end
              else
              begin
                nVal := -StrToInt(sParam);
                LoadstrList.Strings[0] := sParam + '=' + IntToStr(nVal);
                LoadstrList.SaveToFile(sFilePatchName);
              end;
           end;
        end;
      '+':
        begin
           if FileExists(sFilePatchName) then begin
              LoadstrList := TStringList.Create;
              LoadstrList.LoadFromFile(sFilePatchName);
              if LoadstrList.Count > 0 then
              begin
                for I := 0 to LoadstrList.Count - 1 do
                begin
                  tStr := LoadstrList.Strings[I];
                  sVal := GetValidStr3(tStr, sWhere, ['=', #9]);
                  if sWhere = sParam then
                  begin
                    nVal := strtoint(sVal) + strtoint(sValue);
                    LoadstrList.Strings[I] := sWhere + '=' + IntToStr(nVal);
                    LoadstrList.SaveToFile(sFilePatchName);
                  end;
                end;
              end
              else
              begin
                LoadstrList.Strings[0] := sParam + '=' + sValue;
                LoadstrList.SaveToFile(sFilePatchName);
              end;
           end;
        end;
    end;

    PlayObject.RecalcAbilitys();
    PlayObject.SendAbilitys();
  except
    MainOutMessage('{异常} TNormNpc.ActionOfCHANGEHUMABILITY: [' + IntToStr(ActionInfo.nLine) + ']: ' + ActionInfo.sLine);
  end;
end;

 


声明:本文系互联网搜索而收集整理,不以盈利性为目的,文字、图文资料源于互联网且共享于互联网。
如有侵权,请联系 yao4fvip#qq.com (#改@) 删除。