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

Expert challenge


Dawntide
 Share

Recommended Posts

Hey,

I got a challenge for all the good coders in this community.

I tried it, but i'm a noob and fucked up my files, luckily i create a backup after nearly every small change :D

I want to create a "grappling hook".

You throw/shoot the projectile and it pulls/warps you to the place where the projectile hits, whether it is a tile or a npc/player.

that's it.
Link to comment
Share on other sites

Haha, very sneaky way of asking it. :P
Anyway, like Abhi2011 said its not that hard, if you have Wabbits projectile system it can be easily implemented, just add a warp that warps you 1 tile away from the thing your grappling hook is attached to, in front of the ClearProjectile's.
Link to comment
Share on other sites

@Lumiere:

> Even if someone accept this challenge doesn't mean it would have to give the modified engine or the system to him

I actually just sended him the code.

@Joyce:

> Hardly an expert challenge, just cast a loop call from current position into the direction you're facing, and teleport to the first blocked tile you can -1.

Thats exactly what I thought, this is the code I came up with:
```
' check if left map
    If x > Map.MaxX Or y > Map.MaxY Or x < 0 Or y < 0 Then
        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

    ' check if we hit a block
    If Map.Tile(x, y).Type = TILE_TYPE_BLOCKED Then
        If getplayerequipment(Index, Weapon) = 7 Then
            Select Case TempPlayer(Index).ProjecTile(PlayerProjectile).Direction
                Case DIR_DOWN
                    Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y - 1)
                Case DIR_UP
                    Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y + 1)
                Case DIR_RIGHT
                    Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x - 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
                Case DIR_LEFT
                    Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x + 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
            End Select
        End If

        ClearProjectile Index, PlayerProjectile
        Exit Sub
    End If

    ' check for player hit
    For i = 1 To Player_HighIndex
        If x = GetPlayerX(i) And y = GetPlayerY(i) Then
            ' they're hit, remove it
            If Not x = Player(MyIndex).x Or Not y = GetPlayerY(MyIndex) Then
                If getplayerequipment(Index, Weapon) = 7 Then
                    Select Case TempPlayer(Index).ProjecTile(PlayerProjectile).Direction
                        Case DIR_DOWN
                            Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y - 1)
                        Case DIR_UP
                            Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y + 1)
                        Case DIR_RIGHT
                            Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x - 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
                        Case DIR_LEFT
                            Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x + 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
                    End Select
                End If

                ClearProjectile Index, PlayerProjectile
                Exit Sub
            End If
        End If
    Next

    ' check for npc hit
    For i = 1 To MAX_MAP_NPCS
        If x = MapNpc(i).x And y = MapNpc(i).y Then
            If getplayerequipment(Index, Weapon) = 7 Then
                Select Case TempPlayer(Index).ProjecTile(PlayerProjectile).Direction
                    Case DIR_DOWN
                        Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y - 1)
                    Case DIR_UP
                        Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x, TempPlayer(Index).ProjecTile(PlayerProjectile).y + 1)
                    Case DIR_RIGHT
                        Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x - 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
                    Case DIR_LEFT
                        Call playerwarp(Index, GetPlayerMap(Index), TempPlayer(Index).ProjecTile(PlayerProjectile).x + 1, TempPlayer(Index).ProjecTile(PlayerProjectile).y)
                End Select
            End If

            ' they're hit, remove it
            ClearProjectile Index, PlayerProjectile
            Exit Sub
        End If
    Next
```
Not sure if it works, I just typed it real quick in Notepad.
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...