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

[All ver.] Script System.


Ariel
 Share

Recommended Posts

![](http://www.freemmorpgmaker.com/files/imagehost/pics/4112e05c11826d11dc3e3c1a63b4fcae.png)

**What is Script System**

Script System allow you to make custom Npcs, Items, Maps, ETC actions.

ex: I want to make a Npc that will warp me to a certain map if i have a certain item. This is an example of an action that can be made using Scripts.

Cool idea:

Combine this with Party Only Map, Scripted maps and NPCs and you can make a nice enjoyable Party Quest. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

**Todo**

Finish up the Item and Map. Im too lazy right now .

**Requirement**

Any Ver. of EO.

10 minutes.

Common human brain ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)

Visual basic 6.

**Guidelines**

Make a Back up.

Open the server source files.

Right click on modules > Add > Module

![](http://www.freemmorpgmaker.com/files/imagehost/pics/6a625b7e7c345a090f4b438c5647d4ad.png)

Name it: modScripts

(To name it click it and change name in Properties Window)

Paste This inside of the new mod:

```

Option Explicit

Public Sub npcScirpt(ByVal scriptnum As Long, ByVal player As Long)

Select Case scriptnum

Case 0

'do nothing

Case 1

PlayerMsg player, "Scripted NPC", Red

'do nothing

End Select

End Sub

Public Sub ItemScirpt(ByVal scriptnum As Long, ByVal player As Long)

Select Case scriptnum

Case 0

'do nothing

Case 1

PlayerMsg player, "Scripted Item", Red

'do nothing

End Select

End Sub

Public Sub MapScirpt(ByVal scriptnum As Long, ByVal player As Long)

Select Case scriptnum

Case 0

'do nothin

Case 1

PlayerMsg player, "Scripted Map", Red

End Select

End Sub

```

Open modTypes

What are "Types": Variables of different data types when combined as a single variable to hold several related informations is called a User-Defined data type. And this is the main way eclipse handle the data in game.

Find: NpcRec

Inside the type add to the bottom:

```

'Script NPC

Script As Long

```

Find: ItemRec

Inside the type add to the bottom:

```

'Script NPC

Script As Long

```

Find: MapRec

Inside the type add to the bottom:

```

'Script NPC

Script As Long

```

Do the same in modTypes that inside the Client.

This Part can be different in some EO ver.(I'm using EO3.0)

Open modCombat

Find sub CanPlayerAttackNpc

And Above:

```

If Len(Trim$(NPC(npcNum).AttackSay)) > 0 Then

```
If you cant find it, try to understand where the code is executing the npc action and past it there.

Add:

```

'Script npc

If NPC(npcNum).Script > 0 Then

npcScirpt NPC(npcNum).Script, attacker

End If

```
This lines will check if a npc have a script, and trigger it.

Find sub PlayerWarp

Add below:

```

TempPlayer(Index).GettingMap = YES

```

This:

```

If Map(mapNum).Script > 0 Then

Call MapScirpt(Map(mapNum).Script, Index)

End If

```

Find sub UseItem

Add after:

```

Select Case Item(itemNum).Type

```

This:

```

Case ITEM_TYPE_NONE

If Item(itemNum).Script > 0 Then

Call ItemScript(Item(itemNum).Script, Index)

End If

```

Server side is done. Save and debug it.

Open Client Source code.

Make sure you added the Type at the first to the client also.

Open frmEditor_NPC

Add one Scroll bar and one label.

Scroll bar name: scrlScript

Label name: lblScript

Place them wherever you want in the form, double click scrlScript and Paste that inside:

```

'Script NPC

lblScript.Caption = scrlScript.Value

NPC(EditorIndex).Script = scrlScript.Value

```
This will add the script to the npc Type.

You need to do that to the Map Properties and item editors. DONT FORGET TO CHANGE **NPC**(EDITORINDEX) TO THE TYPE YOU ARE EDITING!

Find sub NpcEditorInit

After:

```

.txtLevel.Text = NPC(EditorIndex).Level

```

Add:

```

'NPC Script

.scrlScript.Value = NPC(EditorIndex).Script

```

Find sub ItemEditorInit

above:

```
If frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_CONSUME Then
```

Add:

```

If frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_NONE Then

frmEditor_Item.scrlScript.visible = True

frmEditor_Item.lblScript.visible = True

frmEditor_Item.scrlScript.Value = .Script

End If
```

Find

```

.BossNpc = scrlBoss.Value

```

Add after:

```

.Script = scrlScript.Value

```

Find:

```

.scrlFogBlending.Value = Map.FogBlendMode

```

Add:

```
.scrlScript.Value = Map.Script
```

Save and debug.

Make a new NPC with Script choose Script 1…

When you try to talk with him(or attack) he should Tell you: "Scripted NPC"

Not telling? Start again. Still not telling? Post a replay.

**How to add a new Script**

Open modScripts

You see there "End Select"?

Above this you add "Case x"

x= the next case in the sub.

Now after you made a new case, add some method to it.

You can:

Warp-

```

Call PlayerWarp(player, 1, 1, 1)

```

Add Stat-

```

Call SetPlayerStat(player, Strength, GetPlayerStat(player, Strength) + 5)

```

Send MSG-

```

Call PlayerMsg(player, "Hello I am a Scripted NPC", Yellow)

```

You can add "If" checks and "for" loops so you can pretty much make it do anything.

Yes its that easy. Have fun!

_Please reply if you find bugs and Like if you use. ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)_
Link to comment
Share on other sites

This looks really useful, thanks for making this tutorial. ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) I'm sure it will be very helpful.

Although I haven't tried it yet. I think I might wait to hear what more experienced users think. From what I've heard scripting isn't a good thing to do because it slows down your game – which is why it wasn't included in the vanilla engine of EO.
Link to comment
Share on other sites

lol its my mistake you can edit it to be "script".

And i know it isnt actual scripting but i have no idea how else to call it.

@niffler, Im not sure you should add Items and Maps yet I added them from my head and didnt tested them yet. If you do, let me know the result.
Link to comment
Share on other sites

> Wasn't the event system created just to do this kind of stuff?
>
> Also, has been said before, this isn't scripting; it's just hardcoding more stuff.

It has a purpose really, you can't do everything with just the event system(Not to mention Events, especially parralel ones are far from efficient). This sort of stuff is neat for the more advanced users that wish to have menus pop-up or various other things.
Link to comment
Share on other sites

> Im not sure you should add Items and Maps yet I added them from my head and didnt tested them yet. If you do, let me know the result.

Yeah, I'm going to wait until this tutorial is complete before I make any changes to my source. But I'll follow this topic so that I can see when you update this ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)
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...