View Single Post
Old 17.07.2006, 21:56   #1
Aikeleer
Архивный участник
 
Join Date: Jun 2005
Posts: 374
Default [Share] C4 Attacked handler (warrior-class) decompiled

Just a little thing for the other AI-coders out there. Creating a C4-AI decoder isn't that hard. This is old work, not entirely fixed. The pieces of the puzzle are there, you just gotta put them down the right way.

Also there are a few new functions in (CanAttack i.e). You can just comment those out or create a workaround if you don't have the C4 L2NPC.
Code:
 EventHandler ATTACKED(attacker, damage, f0, myself) {
    if ((attacker.is_pc != 0)  ||  IsInCategory(11, attacker.npc_class_id)) {
      f0 = 0;
      if (SetHateGroup >= 0) {
        if (IsInCategory(SetHateGroup, attacker.occupation)) {
          f0 = (f0+SetHateGroupRatio);
        }
      }
      if (attacker.occupation == SetHateOccupation) {
        f0 = (f0+SetHateOccupationRatio);
      }
      if (SetHateRace == attacker.race) {
        f0 = (f0+SetHateRaceRatio);
      }
      f0 = (((1.000000*damage)/(myself.sm.level+7))+((f0/100)*((1.000000*damage)/(myself.sm.level+7))));
      AddAttackDesire(attacker, 1, (f0*100));
    }
    if (IsNullCreature(myself.top_desire_target) == 0) {
      GetPathfindFailCount(myself);
      if ((myself > 10)  &&  (attacker == myself.top_desire_target)  &&  (FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp))) {
        InstantTeleportInMyTerritory(myself.sm, FloatToInt(attacker.x), FloatToInt(attacker.y), FloatToInt(attacker.z));
      }
      if ((DistFromMe(myself.top_desire_target) > 40)) {
        if (CanAttack(myself.top_desire_target) == 1) {
          if ((attacker.is_pc != 0)  ||  IsInCategory(11, attacker.npc_class_id)) {
            f0 = 0;
            if (SetHateGroup >= 0) {
              if (IsInCategory(SetHateGroup, attacker.occupation)) {
                f0 = (f0+SetHateGroupRatio);
              }
            }
            if (attacker.occupation == SetHateOccupation) {
              f0 = (f0+SetHateOccupationRatio);
            }
            if (SetHateRace == attacker.race) {
              f0 = (f0+SetHateRaceRatio);
            }
            f0 = (((1.000000*damage)/(myself.sm.level+7))+((f0/100)*((1.000000*damage)/(myself.sm.level+7))));
            AddAttackDesire(attacker, 1, (f0*100));
          }
        }
        else {
          RemoveAttackDesire(myself.top_desire_target);
          if ((attacker.is_pc != 0)  ||  IsInCategory(11, attacker.npc_class_id)) {
            f0 = 0;
            if (SetHateGroup >= 0) {
              if (IsInCategory(SetHateGroup, attacker.occupation)) {
                f0 = (f0+SetHateGroupRatio);
              }
            }
            if (attacker.occupation == SetHateOccupation) {
              f0 = (f0+SetHateOccupationRatio);
            }
            if (SetHateRace == attacker.race) {
              f0 = (f0+SetHateRaceRatio);
            }
            f0 = (((1.000000*damage)/(myself.sm.level+7))+((f0/100)*((1.000000*damage)/(myself.sm.level+7))));
            AddAttackDesire(attacker, 1, (f0*100));
          }
        }
      }
    }
    super;
  }
Aikeleer is offline