m4hud17 Posted September 30, 2013 Author Share Posted September 30, 2013 Hei guys, this is my first post and also my first mod :DThis mod, allow you to targetting the enemy without click the enemy. This mod was tested in EO TFF(EO 3.0).These all just edit the serverokay, there's three kind :1\. auto-target Npc when it attack you.First, in modCombat :```Sub NpcAttackPlayer```find,```TempPlayer(victim).stopRegenTimer = GetTickCount```under that, add :```If TempPlayer(victim).targetType = 0 And TempPlayer(victim).target = 0 Then TempPlayer(victim).targetType = 2 'NPC TempPlayer(victim).target = MapNpcNum SendTarget victimEnd If```2\. auto-target Npc when you use non AoE spell and don't have any target.Find :```Public Sub BufferSpell(ByVal index As Long, ByVal spellslot As Long)```Then find :```If Not target > 0 Then PlayerMsg index, "You do not have a target.", BrightRedEnd If```Change it into :```If Not target > 0 Then TempPlayer(index).targetType = TARGET_TYPE_NPC TempPlayer(index).target = FindNPCInRange(index, mapnum, Range) SendTarget index targetType = TempPlayer(index).targetType target = TempPlayer(index).target 'if it's still 0 If target = 0 Then PlayerMsg index, "No enemies nearby.", BrightRed SendClearSpellBuffer index Exit Sub End IfEnd If```3\. The last, it's auto-target when Npc targetting youfirst, in modServerLoop find```Private Sub UpdateMapLogic()```Then, under it add :```Dim index As Long```then, find :``` MapNpc(mapnum).NPC(x).targetType = 1 ' player MapNpc(mapnum).NPC(x).target = IEnd If```change it into :``` MapNpc(mapnum).NPC(x).targetType = 1 ' player MapNpc(mapnum).NPC(x).target = I For index = 1 To MAX_PLAYERS If TempPlayer(index).targetType = 0 And TempPlayer(index).target = 0 Then TempPlayer(index).targetType = 2 'npc TempPlayer(index).target = x SendTarget index End If Next indexEnd If```Finish, Sorry for my bad english :P :P :PYou can auto target when you attack, it's also work with projectilesfirst, in modCombat, CanPlayerAttackNpc find``` If Map(GetPlayerMap(attacker)).Tile(GetPlayerX(attacker) + pX, GetPlayerY(attacker) + pY).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(attacker)).Tile(GetPlayerX(attacker) + pX, GetPlayerY(attacker) + pY).Type <> TILE_TYPE_RESOURCE Then CanPlayerAttackNpc = True End If```change it to``` If Map(GetPlayerMap(attacker)).Tile(GetPlayerX(attacker) + pX, GetPlayerY(attacker) + pY).Type <> TILE_TYPE_BLOCKED And Map(GetPlayerMap(attacker)).Tile(GetPlayerX(attacker) + pX, GetPlayerY(attacker) + pY).Type <> TILE_TYPE_RESOURCE Then If TempPlayer(attacker).target = 0 Then TempPlayer(attacker).targetType = TARGET_TYPE_NPC TempPlayer(attacker).target = MapNpcNum SendTarget attacker End If CanPlayerAttackNpc = True End If```For auto targeting playerin CanPlayerAttackPlayer, above the end function add```If TempPlayer(attacker).target = 0 Then TempPlayer(attacker).targetType = TARGET_TYPE_PLAYER TempPlayer(attacker).target = victim SendTarget attackerEnd IfIf TempPlayer(victim).target = 0 Then TempPlayer(victim).targetType = TARGET_TYPE_PLAYER TempPlayer(victim).target = attacker SendTarget victimEnd If``` Link to comment Share on other sites More sharing options...
coziboy Posted September 30, 2013 Share Posted September 30, 2013 nice tutor brother :D Link to comment Share on other sites More sharing options...
m4hud17 Posted September 30, 2013 Author Share Posted September 30, 2013 Thanks :D :D :D Link to comment Share on other sites More sharing options...
Ananke Posted October 26, 2013 Share Posted October 26, 2013 i've got "FindNPCInRange' erroreo 3.0 Link to comment Share on other sites More sharing options...
m4hud17 Posted October 31, 2013 Author Share Posted October 31, 2013 Anake : what the error? Link to comment Share on other sites More sharing options...
Ananke Posted October 31, 2013 Share Posted October 31, 2013 here: Link to comment Share on other sites More sharing options...
Ananke Posted November 15, 2013 Share Posted November 15, 2013 bump Link to comment Share on other sites More sharing options...
Santini Posted November 15, 2013 Share Posted November 15, 2013 You are receiving that error because the function FindNPCInRange does not exist. What engine are you using? Link to comment Share on other sites More sharing options...
Ananke Posted November 16, 2013 Share Posted November 16, 2013 i know that now, find solution, But it's not searching NPC in spell range, but any NPC on map… Link to comment Share on other sites More sharing options...
Santini Posted November 16, 2013 Share Posted November 16, 2013 Is it meant to target only NPCs within spell range? Because from looking at the tutorial it does not look like it is. Link to comment Share on other sites More sharing options...
Ananke Posted November 16, 2013 Share Posted November 16, 2013 Ah it's auto-target when you use non AOE spell, but still, i want it to target the nearest NPC, or at last NPC in spell range.or maybe you know how to do AoE spell doesn't require auto-target?ps:Missed code (in modgamelogic):```Function FindNPCInRange(ByVal Index As Long, ByVal mapnum As Long, ByVal Range As Long)Dim x As Long, y As LongDim npcX As Long, npcY As LongDim i As Long FindNPCInRange = 0 For i = 1 To MAX_MAP_NPCS x = GetPlayerX(Index) y = GetPlayerY(Index) npcX = MapNpc(mapnum).NPC(i).x npcY = MapNpc(mapnum).NPC(i).y If isInRange(Range, x, y, npcX, npcY) Then If MapNpc(mapnum).NPC(i).Num > 0 Then If NPC(MapNpc(mapnum).NPC(i).Num).Behaviour = NPC_BEHAVIOUR_ATTACKONSIGHT Or NPC(MapNpc(mapnum).NPC(i).Num).Behaviour = NPC_BEHAVIOUR_ATTACKWHENATTACKED Then FindNPCInRange = i Exit Function End If End If End If Next iEnd Function``` Link to comment Share on other sites More sharing options...
Santini Posted November 16, 2013 Share Posted November 16, 2013 Hello,If you need help with selecting the nearest NPC, feel free to PM me and I will do my best to help you with it. As I do not want to take this thread off-topic. Link to comment Share on other sites More sharing options...
Near24 Posted November 18, 2013 Share Posted November 18, 2013 Good~! :) Link to comment Share on other sites More sharing options...
JohnPony Posted November 30, 2013 Share Posted November 30, 2013 ```Function FindNPCInRange(ByVal Index As Long, ByVal mapnum As Long, ByVal Range As Long)Dim x As Long, y As LongDim npcX As Long, npcY As LongDim i As Long FindNPCInRange = 0 x = GetPlayerX(Index) y = GetPlayerY(Index) For i = 1 To MAX_MAP_NPCS npcX = MapNpc(mapnum).NPC(i).x npcY = MapNpc(mapnum).NPC(i).y If isInRange(Range, x, y, npcX, npcY) Then If MapNpc(mapnum).NPC(i).Num > 0 Then If NPC(MapNpc(mapnum).NPC(i).Num).Behaviour = NPC_BEHAVIOUR_ATTACKONSIGHT Or NPC(MapNpc(mapnum).NPC(i).Num).Behaviour = NPC_BEHAVIOUR_ATTACKWHENATTACKED Then FindNPCInRange = i Exit Function End If End If End If Next iEnd Function```Use this instead. There's no reason to calculate the player's x/y position every iteration. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now