Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Linear Spells Script Working 100% on all engines. (Fixed by abhi2011)


aeronx
 Share

Recommended Posts

Hello everybody! Looking on other forums, I found this script, working pretty neat, so i thought i share it.

Note: Tested on skywyre engine, works fine Perfect! (Fixed by: **[abhi2011](http://www.eclipseorigins.com/user-35814.html)** )

~~ Client Side~~

Search for:

```
Public Const SPELL_TYPE_WARP As Byte = 4
```
After it add:

```
Public Const SPELL_TYPE_LINEAR As Byte = 5 ' or your next spell_type number
```
Open FrmEditor_Spell, click on cmbType and blow this:

```
Spell(EditorIndex).Type = cmbType.ListIndex
```
Add this:

```

If cmbType.text = "Linear" Then

scrlRange.Value = 0
chkAOE.Value = 1
End If

```
Click cmbType properties and add Linear to the list

Client side done.

~~Server Side~~

At Sub Public Sub CastSpell search for:

```
Dim x As Long
Dim y As Long

```
Under it add:

```
Dim Linear, Calculate As Long
```
At the same sub look for:

```
Case 2 ' targetted
```
On the End Select above Case 2, above it add:

```

Case SPELL_TYPE_LINEAR

DidCast = True
Linear = 1
Do While Linear < Spell(spellnum).AoE

Select Case GetPlayerDir(index)

                        Case DIR_UP

                        Calculate = GetPlayerY(index) - Linear
                        If Calculate <= 0 Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - Linear).Type = TILE_TYPE_BLOCKED Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        SendAnimation GetPlayerMap(index), Spell(SpellNum).SpellAnim, GetPlayerX(index), GetPlayerY(index) - Linear
                        IsUseLinear index, SpellNum, Vital, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) - Linear

                        Case DIR_DOWN
                        Calculate = GetPlayerY(index) + Linear
                        If Calculate <= 0 Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + Linear).Type = TILE_TYPE_BLOCKED Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        SendAnimation GetPlayerMap(index), Spell(SpellNum).SpellAnim, GetPlayerX(index), GetPlayerY(index) + Linear
                        IsUseLinear index, SpellNum, Vital, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) + Linear

                        Case DIR_LEFT
                        Calculate = GetPlayerX(index) - Linear
                        If Calculate <= 0 Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - Linear, GetPlayerY(index)).Type = TILE_TYPE_BLOCKED Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        SendAnimation GetPlayerMap(index), Spell(SpellNum).SpellAnim, GetPlayerX(index) - Linear, GetPlayerY(index)
                        IsUseLinear index, SpellNum, Vital, GetPlayerMap(index), GetPlayerX(index) - Linear, GetPlayerY(index)

                        Case DIR_RIGHT
                        Calculate = GetPlayerX(index) + Linear
                        If Calculate <= 0 Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + Linear, GetPlayerY(index)).Type = TILE_TYPE_BLOCKED Then
                        DidCast = True
                        GoTo theEnd
                        End If
                        SendAnimation GetPlayerMap(index), Spell(SpellNum).SpellAnim, GetPlayerX(index) + Linear, GetPlayerY(index)
                        IsUseLinear index, SpellNum, Vital, GetPlayerMap(index), GetPlayerX(index) + Linear, GetPlayerY(index)

End Select
Linear = Linear + 1
Loop

```
At the end of CastSpell sub find:
```
If DidCast then
```
Above it, add:
```
theEnd:
```

After whole Public Sub StunNPC add:
```
Function IsUseLinear(ByVal index As Integer, ByVal spellnum As Integer, ByVal Vital As Long, ByVal Mapa As Integer, ByVal x As Byte, ByVal y As Byte)

Dim i As Long

'Loop Global Npc
For i = 1 To MAX_MAP_NPCS
If MapNpc(Mapa).NPC(i).Num > 0 And MapNpc(Mapa).NPC(i).x = x And MapNpc(Mapa).NPC(i).y = y And MapNpc(Mapa).NPC(i).Vital(HP) > 0 Then PlayerAttackNpc index, i, Vital, spellnum
Next

'Loop Global Player
For i = 1 To Player_HighIndex
If GetPlayerMap(i) = Mapa And GetPlayerX(i) = x And GetPlayerY(i) = y Then PlayerAttackPlayer index, i, Vital, spellnum
Next
End Function

```
After:

```
Public Const SPELL_TYPE_WARP As Byte = 4
```
Add:

```
Public Const SPELL_TYPE_LINEAR As Byte = 5 'or whatever number you need
```
Aaand you are done!

You just now need to create a new spell, set the animation, vital and range (from AOE range) and you have it.

Thanks! I wish it helps somebody.
Link to comment
Share on other sites

Try changing this:

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - Linear).Type = TILE_TYPE_BLOCKED Then Exit Sub

to this:

If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - Linear).Type = TILE_TYPE_BLOCKED Then
DidCast = False
ExitSub
End if

No idea if it will work or not. Got smashed last night so I can't think too well without it hurting lol.
Link to comment
Share on other sites

If you were to look at the end of the method you'll see the 'If DidCast = true then' part. This is where MP reduced. Basically, we want to jump to that point in code. Use a Code label along with a GoTo statement.

```
If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - Linear).Type = TILE_TYPE_BLOCKED Then
didcast = true
goto theEnd
endif

```That's what your problem line should be.

Above```
If DidCast Then
```add a "theEnd: " line. This img should help if you didn't understand -> http://imgur.com/5PzfX9x

EDIT:
This line of code```
If Calculate <= 0 Then Exit Sub
```has the same problem. It calls Exit Sub from within a loop. Meaning, any damage done in a previous iteration will be handled but since the method is exited, mana won't be deducted. Exit sub should be called in only those instances where nothing has been done for a logical deduction to take place. (for eg. when no target has been selected, it'd be wrong to deduct mana without any damage happening)
Link to comment
Share on other sites

Thanks all for your help.

I've tried something like this, but now if you face a blocked tile from 3 tiles, but it has range 4\. The spell wont cast, even if there is a NPC on the way.
I've been trying some diferent ways but i havent been successfull.

This is what i have now. (Doesnt work right)

```

Case DIR_UP

                       Calculate = GetPlayerY(index) - Linear
                       If Calculate <= 0 Then
                       DidCast = True
                       GoTo theEnd
                       End If
                       Exit Sub
                       If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - Linear).Type = TILE_TYPE_BLOCKED Then
                       DidCast = True
                       GoTo theEnd
                       End If
                       Exit Sub
theEnd:
                       If DidCast Then
                       SendAnimation GetPlayerMap(index), Spell(SpellNum).SpellAnim, GetPlayerX(index), GetPlayerY(index) - Linear
                       IsUseLinear index, SpellNum, Vital, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index) - Linear
                       End If

```
Link to comment
Share on other sites

Umm.. I'm not getting what you are trying to do.
The 'theEnd' and 'If DidCast …' is at the end of the function. Not within the select case/loop. You just do a goto theEnd where you want to.
Give your entire CastSpell or w/e it's called function here.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...