Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
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  
Old 17.07.2006, 22:04   #2
TheOrder
Архивный участник
 
Join Date: Sep 2005
Posts: 731
Default

Aikeleer = Rules GJ with the AI Decompiling thing !!!
TheOrder is offline  
Old 17.07.2006, 23:04   #3
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default

this is the complete warrior class and some others ai. btw i haven't checked it for errors.

Code:
/***************************************************************************
*                                Change Log
*                            ------------------
*   xx.xx.2006
*   Script Decompiled by SauDecompiler build 160706.1
*
***************************************************************************/

class warrior : warrior_parameter
{
parameter:
	float	Attack_DecayRatio = 6.600000;
	float	UseSkill_DecayRatio = 660xx.xx0000;
	float	Attack_BoostValue = 3xx.xx0000;
	float	UseSkill_BoostValue = 1000xx.xx0000;

handler:
	EventHandler NO_DESIRE()
	{
		AddMoveAroundDesire(5,5);
	}

	EventHandler CREATED()
	{
		if( ShoutMsg1 > 0 )
		{
			Shout(MakeFString(ShoutMsg1,"","","","",""));
		}
		if( MoveAroundSocial > 0 || ShoutMsg2 > 0 || ShoutMsg3 > 0 )
		{
			AddTimerEx(1001,10000);
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 1001 )
		{
			if( ( myself.p_state == 1 || myself.p_state == 2 || myself.p_state == 9 ) && ( myself.sm.c_ai2 > ( myself.sm.max_hp * 0.400000 ) && myself.sm.alive != 0 ) )
			{
				if( MoveAroundSocial > 0 || MoveAroundSocial1 > 0 || MoveAroundSocial2 > 0 )
				{
					if( MoveAroundSocial2 > 0 && Rand(100) < 20 )
					{
						AddEffectActionDesire(myself.sm,3,( ( MoveAroundSocial2 * 1000 ) / 30 ),50);
					}
					else if( MoveAroundSocial1 > 0 && Rand(100) < 20 )
					{
						AddEffectActionDesire(myself.sm,2,( ( MoveAroundSocial1 * 1000 ) / 30 ),50);
					}
					else if( MoveAroundSocial > 0 && Rand(100) < 20 )
					{
						AddEffectActionDesire(myself.sm,1,( ( MoveAroundSocial * 1000 ) / 30 ),50);
					}
				}
				if( ShoutMsg2 > 0 && Rand(1000) < 17 )
				{
					Shout(MakeFString(ShoutMsg2,"","","","",""));
				}
			}
			else if( myself.p_state == 3 )
			{
				if( ShoutMsg3 > 0 && Rand(100) < 10 )
				{
					Shout(MakeFString(ShoutMsg3,"","","","",""));
				}
			}
			AddTimerEx(1001,10000);
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage,f0)
	{
		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 )
		{
			if( GetPathfindFailCount() > 10 && attacker == myself.top_desire_target && FloatToInt(myself.sm.c_ai2) != FloatToInt(myself.sm.max_hp) )
			{
				InstantTeleport(myself.sm,FloatToInt(attacker.x),FloatToInt(attacker.creature),FloatToInt(attacker.z));
			}
			if( GetAbnormalLevel(myself.sm,Skill_GetAbnormalType(307457)) >= 0 && 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.id);
					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;
	}

	EventHandler CLAN_ATTACKED(attacker,damage,f0)
	{
		if( GetLifeTime() > 7 )
		{
			if( IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( GetPathfindFailCount() > 10 && attacker == myself.top_desire_target && FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp) )
				{
					InstantTeleport(myself.sm,FloatToInt(attacker.x),FloatToInt(attacker.creature),FloatToInt(attacker.z));
				}
			}
			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 * 30 ));
			}
		}
	}

	EventHandler SEE_SPELL(speller,skill_name_id,target,f0,i0)
	{
		if( Skill_GetEffectPoint(skill_name_id) > 0 )
		{
			if( myself.p_state == 3 && myself.top_desire_target == target )
			{
				i0 = Skill_GetEffectPoint(skill_name_id);
				f0 = 0;
				if( SetHateGroup >= 0 )
				{
					if( IsInCategory(SetHateGroup,speller.occupation) )
					{
						f0 = ( f0 + SetHateGroupRatio );
					}
				}
				if( speller.occupation == SetHateOccupation )
				{
					f0 = ( f0 + SetHateOccupationRatio );
				}
				if( SetHateRace == speller.race )
				{
					f0 = ( f0 + SetHateRaceRatio );
				}
				f0 = ( ( ( 1.000000 * i0 ) / ( myself.sm.level + 7 ) ) + ( ( f0 / 100 ) * ( ( 1.000000 * i0 ) / ( myself.sm.level + 7 ) ) ) );
				AddAttackDesire(speller,1,( f0 * 150 ));
			}
		}
		if( GetPathfindFailCount() > 10 && speller == myself.top_desire_target && FloatToInt(myself.sm.hp) != FloatToInt(myself.sm.max_hp) )
		{
			InstantTeleport(myself.sm,FloatToInt(speller.x),FloatToInt(speller.y),FloatToInt(speller.z));
		}
	}

	EventHandler DESIRE_MANIPULATION(speller,desire)
	{
		MakeAttackEvent(speller,desire,0);
	}

	EventHandler MY_DYING()
	{
		if( ShoutMsg4 > 0 && Rand(100) < 30 )
		{
			Shout(MakeFString(ShoutMsg4,"","","","",""));
		}
	}

}




/***************************************************************************
*                                C4 stuff
*                            ------------------
*   -----------
*   FUNCTIONS:
*   -----------
*   IsNullCreature
*   GetPathfindFailCount
*   CanAttack
***************************************************************************/
Code:
/***************************************************************************
*                                Change Log
*                            ------------------
*   xx.xx.2006
*   Script Decompiled by SauDecompiler build 160706.1
*
***************************************************************************/

class warrior_casting_ddmagic : warrior
{
parameter:
	int	DDMagic = 1024257;

handler:
	EventHandler CREATED()
	{
		myself.i_ai1 = 0;
		myself.i_ai2 = 0;
		super;
	}

	EventHandler ATTACKED(attacker,damage,i6)
	{
		if( myself.i_ai1 == 1 )
		{
			if( myself.top_desire_target == attacker )
			{
				myself.i_ai2 = 1;
			}
		}
		else
		{
			AddTimerEx(2001,5000);
			myself.i_ai1 = 1;
		}
		if( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) )
		{
			i6 = Rand(100);
			if( DistFromMe(attacker) > 100 )
			{
				if( IsNullCreature(myself.top_desire_target) == 0 )
				{
					if( myself.top_desire_target == attacker && i6 < 33 )
					{
						if( Skill_GetConsumeMP(DDMagic) < myself.sm.c_ai3 && Skill_GetConsumeHP(DDMagic) < myself.sm.c_ai2 && Skill_InReuseDelay(DDMagic) == 0 )
						{
							AddUseSkillDesire(attacker,DDMagic,0,1,1000000);
						}
					}
				}
			}
		}
		super;
	}

	EventHandler CLAN_ATTACKED(attacker,damage,i6)
	{
		if( ( GetLifeTime() > 7 && ( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) ) ) && myself.p_state != 3 )
		{
			i6 = Rand(100);
			if( DistFromMe(attacker) > 100 && i6 < 33 )
			{
				if( Skill_GetConsumeMP(DDMagic) < myself.sm.mp && Skill_GetConsumeHP(DDMagic) < myself.sm.hp && Skill_InReuseDelay(DDMagic) == 0 )
				{
					AddUseSkillDesire(attacker,DDMagic,0,1,1000000);
				}
			}
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 2001 )
		{
			if( myself.p_state != 3 && myself.p_state != 10 )
			{
				myself.i_ai1 = 0;
				myself.i_ai2 = 0;
			}
			else if( myself.i_ai2 == 0 )
			{
				if( IsNullCreature(myself.top_desire_target) == 0 && Rand(100) < 50 )
				{
					if( GetAbnormalLevel(myself.top_desire_target,Skill_GetAbnormalType(DDMagic)) <= 0 )
					{
						if( Skill_GetConsumeMP(DDMagic) < myself.sm.c_ai3 && Skill_GetConsumeHP(DDMagic) < myself.sm.c_ai2 && Skill_InReuseDelay(DDMagic) == 0 )
						{
							AddUseSkillDesire(myself.top_desire_target,DDMagic,0,1,1000000);
						}
					}
				}
			}
			AddTimerEx(2001,5000);
			myself.i_ai2 = 0;
		}
		super;
	}

}




/***************************************************************************
*                                C4 stuff
*                            ------------------
*   -----------
*   FUNCTIONS:
*   -----------
*   IsNullCreature
***************************************************************************/
Code:
/***************************************************************************
*                                Change Log
*                            ------------------
*   xx.xx.2006
*   Script Decompiled by SauDecompiler build 160706.1
*
***************************************************************************/

class warrior_casting_curse : warrior
{
parameter:
	int	DeBuff = 1033473;

handler:
	EventHandler CREATED()
	{
		myself.i_ai1 = 0;
		myself.i_ai2 = 0;
		super;
	}

	EventHandler ATTACKED(attacker,damage)
	{
		if( myself.i_ai1 == 1 )
		{
			if( myself.top_desire_target == attacker )
			{
				myself.i_ai2 = 1;
			}
		}
		else
		{
			AddTimerEx(2001,5000);
			myself.i_ai1 = 1;
		}
		if( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) )
		{
			if( IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( Rand(100) < 33 && GetAbnormalLevel(attacker,Skill_GetAbnormalType(DeBuff)) <= 0 && myself.top_desire_target == attacker )
				{
					if( Skill_GetConsumeMP(DeBuff) < myself.sm.c_ai3 && Skill_GetConsumeHP(DeBuff) < myself.sm.c_ai2 && Skill_InReuseDelay(DeBuff) == 0 )
					{
						AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
					}
				}
			}
		}
		super;
	}

	EventHandler CLAN_ATTACKED(attacker,damage)
	{
		if( GetLifeTime() > 7 && ( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) ) )
		{
			if( Rand(100) < 33 && GetAbnormalLevel(attacker,Skill_GetAbnormalType(DeBuff)) <= 0 )
			{
				if( Skill_GetConsumeMP(DeBuff) < myself.sm.mp && Skill_GetConsumeHP(DeBuff) < myself.sm.hp && Skill_InReuseDelay(DeBuff) == 0 )
				{
					AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
				}
			}
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 2001 )
		{
			if( myself.p_state != 3 && myself.p_state != 10 )
			{
				myself.i_ai1 = 0;
				myself.i_ai2 = 0;
			}
			else if( myself.i_ai2 == 0 )
			{
				if( IsNullCreature(myself.top_desire_target) == 0 && Rand(100) < 50 )
				{
					if( GetAbnormalLevel(myself.top_desire_target,Skill_GetAbnormalType(DeBuff)) <= 0 )
					{
						if( Skill_GetConsumeMP(DeBuff) < myself.sm.c_ai3 && Skill_GetConsumeHP(DeBuff) < myself.sm.c_ai2 && Skill_InReuseDelay(DeBuff) == 0 )
						{
							AddUseSkillDesire(myself.top_desire_target,DeBuff,0,1,1000000);
						}
					}
				}
			}
			AddTimerEx(2001,5000);
			myself.i_ai2 = 0;
		}
		super;
	}

}




/***************************************************************************
*                                C4 stuff
*                            ------------------
*   -----------
*   FUNCTIONS:
*   -----------
*   IsNullCreature
***************************************************************************/
Sauron is offline  
Old 17.07.2006, 23:09   #4
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default

Code:
/***************************************************************************
*                                Change Log
*                            ------------------
*   xx.xx.2006
*   Script Decompiled by SauDecompiler build 160706.1
*
***************************************************************************/

class warrior_physicalspecial : warrior
{
parameter:
	int	PhysicalSpecial = 1032193;

handler:
	EventHandler ATTACKED(attacker,damage)
	{
		if( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) )
		{
			if( IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( Rand(100) < 33 && myself.top_desire_target == attacker )
				{
					if( Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.c_ai3 && Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.c_ai2 && Skill_InReuseDelay(PhysicalSpecial) == 0 )
					{
						AddUseSkillDesire(attacker,PhysicalSpecial,0,1,1000000);
					}
				}
			}
		}
		super;
	}

	EventHandler CLAN_ATTACKED(attacker,damage)
	{
		if( ( GetLifeTime() > 7 && ( attacker.is_pc != 0 || IsInCategory(11,attacker.npc_class_id) ) ) && myself.p_state != 3 )
		{
			if( Rand(100) < 33 )
			{
				if( Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && Skill_InReuseDelay(PhysicalSpecial) == 0 )
				{
					AddUseSkillDesire(attacker,PhysicalSpecial,0,1,1000000);
				}
			}
		}
		super;
	}

}




/***************************************************************************
*                                C4 stuff
*                            ------------------
*   -----------
*   FUNCTIONS:
*   -----------
*   IsNullCreature
***************************************************************************/
Вложения из исходного сообщения (сами файлы в копии отсутствуют):
ai_boss04_antaras_208.rar — 3232 байт
Sauron is offline  
Old 18.07.2006, 08:54   #5
empathon
Архивный участник
 
Join Date: Feb 2006
Posts: 136
Default

thanks a lot! very usefull staff
btw. GetPathfindFailCount its for pathnode function?
i saw how its work on retail and im 100% sure that way where mob or player goes is in patchnode. I dont know AI as well as u, is there any function in C1 AI equal to that?
empathon is offline  
Old 18.07.2006, 09:19   #6
Aikeleer
Архивный участник
 
Join Date: Jun 2005
Posts: 374
Default

This is a function in the AI that is against perching. If the mob is stuck, and it can't get to it's waypoint (which is set in the pathnode) the failpathnodecount increases. If it reaches 10, the mob just teleports to you.
Aikeleer is offline  
Old 18.07.2006, 10:23   #7
empathon
Архивный участник
 
Join Date: Feb 2006
Posts: 136
Default

sa can i relay this function like that:
if (disttance to mob not become smaller in some period of time) then (teleport to player)
??
now i have to find out how to write it in NASC im noob in this :P
empathon is offline  
Old 18.07.2006, 10:41   #8
midnight
Архивный участник
 
Join Date: Jun 2005
Posts: 199
Default

When i load the ai class warrior : warrior_parameter , ingame monsters says farewell and npcserver crashes
midnight is offline  
Old 18.07.2006, 13:27   #9
Sauron
Архивный участник
 
Join Date: Feb 2005
Posts: 357
Default

Quote:
Originally Posted by empathon
sa can i relay this function like that:
if (disttance to mob not become smaller in some period of time) then (teleport to player)
??
now i have to find out how to write it in NASC im noob in this :P
what happen if the player runs away? you have to check, if the npc is under attack, is free of root/sleep/etc, position (x,y,z), and if you want distance.
Sauron is offline  
Old 18.07.2006, 15:37   #10
empathon
Архивный участник
 
Join Date: Feb 2006
Posts: 136
Default

yeah i didnt thought about it. thanks for a tip
and i dont understand this one
(IsNullCreature(myself.top_desire_target) == 0)
so mob can have on target not PC or what ?
empathon is offline  
Old 18.07.2006, 19:50   #11
Duna
Архивный участник
 
Join Date: Aug 2005
Posts: 14
Default

Sauron how to check in ai when mob is free of root/sleep/etc ?

Can u show me good way only ?
Duna is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 15:50.