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

What's wrong with this script?


ryono
 Share

Recommended Posts

hey guys, I can't seem to figure out what's wrong with this script. maybe you can figure it out. It is supposed to be a combo system. or the begining of one.

put this at bottom of main.txt:
```
sub attackanimation(index, animation)
dim map
dim playerx
dim playery
dim dir

map = getplayermap(index)
playerx = getplayerx(index)
playery = getplayery(index)
dir = getplayerdir(index)

if dir = 0 then
call spellanim(animation, map, playerx, playery - 1)
elseif dir = 1 then
call spellanim(animation, map, playerx, playery + 1)
elseif dir = 2 then
call spellanim(animation, map, playerx - 1, playery)
else
call spellanim(animation, map, playerx + 1, playery)
end if
end sub

'COMBO SYSTEM!!!!!!!!!!!!
sub damagecommand(index, high, low, hitrate, critrate, hitanimation, missanimation, critanimation, hitsound, misssound, critsound)
dim str
dim dmg
dim playerdef
dim npcdef
dim critdmg
dim hitchance
dim critchance
dim target
dim npcnum
dim playerx
dim playery
dim npcx
dim npcy
dim dir
dim targettype

str = getplayerstr(index) * 2

if low < 0 then
low = 0
end if

if hitrate < 0 then
hitrate = 0
end if
if hitrate > 100 then
hitrate = 100
end if

critdmg = high / 4

if critrate > 100 then
critrate = 100
end if
if critrate < 0 then
critrate = 0
end if

critchance = rand(0, 100)
npcnum = getplayertargetnpc(index)
npcdef = getnpcdefense(npcnum)

if int(getplayertarget(index)) > 0 then
target = getplayertarget(index)
targettype = 1
if hitchance <= hitrate then
playerdef = getplayerdef(target)
dmg = (rand(low, high) + (str * 2)) - (playerdef * 5)
else
dmg = 0
end if
else
target = getplayertargetnpc(index)
targettype = 0
if hitchance <= hitrate then
dmg = (rand(low, high) + (str * 2)) - (npcdef * 5)
else
dmg = 0
end if
end if

playerx = getplayerx(index)
playery = getplayery(index)
npcx = getnpcx(getplayermap(index), npcnum)
npcy = getnpcy(getplayermap(index), npcnum)
dir = getplayerdir(index)

if dir = 0 then
if playerx = npcx then
if playery = npcy + 1 then
if critchance <= critrate then
call putvar("Damage.ini", "DAMAGE", getplayername(index), "2")
dmg = high + rand(0, critdmg)
else
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
end if
if targettype = 1 then
call damageplayer(index, target, dmg)
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
else
call damagenpc(index, target, dmg)
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
end if
end if
end if
elseif dir = 1 then
if playerx = npcx then
if playery = npcy - 1 then
if critchance <= critrate then
call putvar("Damage.ini", "DAMAGE", getplayername(index), "2")
dmg = high + rand(0, critdmg)
else
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
end if
if targettype = 1 then
call damageplayer(index, target, dmg)
else
call damagenpc(index, target, dmg)
end if
end if
end if
elseif dir = 2 then
if playerx = npcx + 1 then
if playery = npcy then
if critchance <= critrate then
call putvar("Damage.ini", "DAMAGE", getplayername(index), "2")
dmg = high + rand(0, critdmg)
else
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
end if
if targettype = 1 then
call damageplayer(index, target, dmg)
else
call damagenpc(index, target, dmg)
end if
end if
end if
else
if playerx = npcx - 1 then
if playery = npcy then
if critchance <= critrate then
call putvar("Damage.ini", "DAMAGE", getplayername(index), "2")
dmg = high + rand(0, critdmg)
else
call putvar("Damage.ini", "DAMAGE", getplayername(index), "1")
end if
if targettype = 1 then
call damageplayer(index, target, dmg)
else
call damagenpc(index, target, dmg)
end if
end if
end if
end if

if dmg = 0 then
call putvar("Damage.ini", "DAMAGE", getplayername(index), "0")
end if

if getvar("Damage.ini", "DAMAGE", getplayername(index)) = "2" then
call attackanimation(index, critanimation)
call playsound(index, critsound)
elseif getvar("Damage.ini", "DAMAGE", getplayername(index)) = "1" then
call attackanimation(index, hitanimation)
call playsound(index, hitsound)
else
call attackanimation(index, missanimation)
call playsound(index, misssound)
end if

call putvar("Damage.ini", "DAMAGE", getplayername(index), "0")
end sub

sub nexthit(index)
call removetimer("nexthit " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "0")
end sub

sub hitdelay1(index)
call removetimer("hitdelay1 " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "1")
call settimer("nexthit " & index, 3000)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
end sub

sub hitdelay2(index)
call removetimer("hitdelay2 " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "2")
call settimer("nexthit " & index, 3000)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
end sub

sub hitdelay3(index)
call removetimer("hitdelay3 " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "3")
call settimer("nexthit " & index, 3000)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
end sub

sub hitdelay4(index)
call removetimer("hitdelay4 " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "4")
call settimer("nexthit " & index, 3000)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
end sub

sub hitdelay5(index)
call removetimer("hitdelay5 " & index)
call putvar("HitNumber.ini", "HIT", getplayername(index), "1")
call settimer("nexthit " & index, 3000)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
end sub
```
put this in OnNewCharCreate sub:
```
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "1")
call putvar("HitNumber.ini", "HIT", getplayername(index), "0")
```
replace HotScript sub with this:
```
' Executes when a hotkey is pressed client-side.
Sub HotScript(Index, KeyID)
Select Case KeyID
' Executes when any player presses the PageUp key.
Case 1
if getvar("HitNumber.ini", "CAN ATTACK", getplayername(index)) = "1" then
if getvar("HitNumber.ini", "HIT", getplayername(index)) = "0" then
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay1 " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "1" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay2 " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "2" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay3 " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "3" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay4 " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
else
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay5 " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
end if
end if
' Executes when any player presses the Delete key.
Case 2

' Executes when players press the End key.
Case 3
call advancedattack(index, 800, 600, 76, 8, 2, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
' Executes when players press the PageDown key.
Case 4
if getvar("HitNumber.ini", "CAN ATTACK", getplayername(index)) = "1" then
if getvar("HitNumber.ini", "HIT", getplayername(index)) = "0" then
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "1" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "2" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
elseif getvar("HitNumber.ini", "HIT", getplayername(index)) = "3" then
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
else
call removetimer("nexthit " & index)
call damagecommand(index, 800, 600, 100, 10, 1, 2, 3, "sword.wav", "miss.wav", "SwordCritical.wav")
call settimer("hitdelay " & index, 500)
call putvar("HitNumber.ini", "CAN ATTACK", getplayername(index), "0")
end if
end if
End Select
End Sub
```
and I think thats it. The error I get it a subscript out of range on line 37 when I press page up. and when I press page down, I get it on line 36\. so I don't know. well, ty in advance everyone.
Link to comment
Share on other sites

I remade all my .inis and made a new character, and it worked for 2 attacks but then I got like 5 thousand errors. and it was like cant show modal form when theres is no modal form. what ever modal means lol. any ideas?

oh and btw, the script wont work unless you make a new character. well, it's not supposed to work unless you make one.

edit: ok now I have type mismatch "attackdelay" hmmmm…
Link to comment
Share on other sites

notice all your directional checks? throw em all away and for example change this sub:

```
sub attackanimation(index, animation)
  dim map
  dim playerx
  dim playery
  dim dir

  map = getplayermap(index)
  playerx = getplayerx(index)
  playery = getplayery(index)
  dir = getplayerdir(index)

  if dir = 0 then
      call spellanim(animation, map, playerx, playery - 1)
  elseif dir = 1 then
      call spellanim(animation, map, playerx, playery + 1)
  elseif dir = 2 then
      call spellanim(animation, map, playerx - 1, playery)
  else
      call spellanim(animation, map, playerx + 1, playery)
  end if
end sub

```
to this:

```
sub attackanimation(index, animation)
Call SpellAnim(Animation, GetPlayerMap(index), GetPlayerDirX(index), GetPlayerDirY(index))
end sub

```
see how much of a difference that makes? XD
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...