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

Spell Casting NPC's


DarkSpine
 Share

Recommended Posts

Ok, so i tried to add a script to make npc's cast spells, BUT i don't know where to put this

> Dim Hp
> Dim Dmg
> Dim MapNum
> Dim X
> Dim Y
>
> Hp = GetPlayerHp(index)
> Dmg = 0
> MapNum = GetPlayerMap(index)
> X = GetPlayerX(index)
> Y = GetPlayerY(index)
>
> Call playermsg(index, "You were hit by an opponent's spell.", 12)
> Dmg = Hp - 1000
> Call SpellAnim(1,MapNum,X,Y)
> Call SetPlayerHp(index, Dmg)
> Call SendHP(index)       
>        
>
> End Select

Link to the script:  [http://www.touchofdeathforums.com/smf/index.php?topic=24989.0](http://www.touchofdeathforums.com/smf/index.php?topic=24989.0)
It did not say in the script.
Can anyone help me?

-Spine
Link to comment
Share on other sites

lol dude , i would try and put this in a scripted NPC, or try the on attacknpc sub.

[EDIT]

i read the thread you linked to and i found that you need to make your own timers…

in your main.txt find

```
'||||||||||||||||||||||||||||
Sub TMRTEST(index, script)
'||||||||||||||||||||||||||||

```
change it to this

```
'||||||||||||||||||||||||||||
Sub TMRTEST(index, script)
'||||||||||||||||||||||||||||

Dim Hp
  Dim Dmg
  Dim MapNum
  Dim X
  Dim Y

  Hp = GetPlayerHp(index)
  Dmg = 0
  MapNum = GetPlayerMap(index)
  X = GetPlayerX(index)
  Y = GetPlayerY(index)

  Select Case script

      Case 0
        Call playermsg(index, "You were hit by an opponent's spell.", 12)
        Dmg = Hp - 20
        Call SpellAnim(1,MapNum,X,Y)
        Call SetPlayerHp(index, Dmg)
        Call SendHP(index)       

      Case Else
        Call playermsg(index, "No timer found, please contact an admin to resolve this issue.", 12)
        Call Removetimer("tmrtest " &index & "," & script)

  End Select
End Sub

```

then place this in a scripted tile.

```
  Call SetTimer("tmrTest " & index & ",0", 5000)

```
the link you provided was pretty self explainitory, and

@Sy|exus:

> If I told you where to put it could I use it?

its not his, so i am pretty sure you dont have to ask permission from him, you might from the creator though
If I told you where to put it could I use it?
Link to comment
Share on other sites

Well…
Your trigger is  Call SetTimer("tmrTest " & index & ",0", 5000)
You can change the 5000 to any duration you would like, _in miliseconds_.  It is set to 5 seconds right now.

The tutorial says to use a scripted tile for when you enter a map.  The tile would trigger a timer which would start the NPC casting the spell.  Then, in the OnNPCDeath sub you add a Call RemoveTimer to stop the NPC from casting.  The flaw with this is that only the first NPC on the map will cast.

Alternatively, put it in Sub PlayerHit with a check for the NPC number to begin the casting when an NPC hits you.

_Do not_ put it in scripted NPCs because then you can not attack them, and they will not directly attack you.

The part of the code you posted goes into Sub tmrTest under Case 0.  Everyone seems to use this sub for timers, which is frustrating since it assumes the script's user also happened to be using the exact same sub for their timers.  You will have to add in the sub, and the title of a sub is case-sensitive is a timer is to be used. 

@Warconn: The original Main.txt does not include a Sub tmrTest.  This sub was made by Baron to keep timers organized, and **is absolutely not a required sub to use timers**.  He probably won't be able to find that sub in his main.txt because it might not be in his main.txt.  I'm going to assume you're using Baron's main.txt.  Don't forget that it's different.
Link to comment
Share on other sites

@Zeno:

> Well…
> Your trigger is   Call SetTimer("tmrTest " & index & ",0", 5000)
> You can change the 5000 to any duration you would like, _in miliseconds_.  It is set to 5 seconds right now.
>
> The tutorial says to use a scripted tile for when you enter a map.  The tile would trigger a timer which would start the NPC casting the spell.  Then, in the OnNPCDeath sub you add a Call RemoveTimer to stop the NPC from casting.  The flaw with this is that only the first NPC on the map will cast.
>
> Alternatively, put it in Sub PlayerHit with a check for the NPC number to begin the casting when an NPC hits you.
>
> _Do not_ put it in scripted NPCs because then you can not attack them, and they will not directly attack you.
>
> The part of the code you posted goes into Sub tmrTest under Case 0.  Everyone seems to use this sub for timers, which is frustrating since it assumes the script's user also happened to be using the exact same sub for their timers.  You will have to add in the sub, and the title of a sub is case-sensitive is a timer is to be used. 
>
> @Warconn: The original Main.txt does not include a Sub tmrTest.  This sub was made by Baron to keep timers organized, and **is absolutely not a required sub to use timers**.  He probably won't be able to find that sub in his main.txt because it might not be in his main.txt.  I'm going to assume you're using Baron's main.txt.  Don't forget that it's different.

ahh ok, no im not using Barons, i just picked it up from a post i saw probably his though. I like to script my stuff more in source then SS because it relieves lagg on the server
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...