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

New Trigger Types


balliztik1
 Share

Recommended Posts

In Eclipse, there are several triggers you can use for scripts: tiles, timers, scripted NPCs, etc. Adding more triggers to the main.txt can be a great way to expand the possibilities of Eclipse. With just the addition of a few lines of code in the source, you can add hundreds of new scripting possibilities.

(All additions are in the server-side source code.)

**Sub OnNpcHitPlayer**
In _modGameLogic_, find procedure _NPCAttackPlayer_. In it, look for this line:

```
Name = Trim(Npc(MapNpc(MapNum, MapNpcNum).num).Name)
```
Right underneath that, paste this:

```
MyScript.ExecuteStatement "Scripts\main.txt", "OnNpcHitPlayer " & Victim & "," & MapNpcNum & "," & Damage
```
Now, add this sub to your main.txt:

```
Sub OnNPCHitPlayer(index, mapnpcnum, damage)
Call BattleMsg(index, "You were hit by a " & GetMapNPCName(GetPlayerMap(index), mapnpcnum) & " for " & damage & " damage.", 4, 0)
End Sub
```
Now, whenever an NPC hits a player, a script can be called.

**Sub OnPlayerHitNPC**
In _modGameLogic_, find procedure _AttackNpc_. In it, look for these lines:

```
    MapNum = GetPlayerMap(Attacker)
    NpcNum = MapNpc(MapNum, MapNpcNum).num
    Name = Trim(Npc(NpcNum).Name)
```
Right underneath that, paste this:

```
MyScript.ExecuteStatement "Scripts\main.txt", "OnPlayerHitNPC " & Attacker & "," & MapNpcNum & "," & Damage
```
Now, add this sub to your main.txt:

```
Sub OnPlayerHitNPC(index, mapnpcnum, damage)
Call BattleMsg(index, "You hit a " & GetMapNPCName(GetPlayerMap(index), mapnpcnum) & " for " & damage & " damage.", 4, 0)
End Sub
```
Now, whenever a player hits an NPC, a script can be called.

**Sub OnNpcDeath** (Already in EE)
In _modGameLogic_, find procedure _AttackNpc_. In it, look for this line:

```
If Damage >= MapNpc(MapNum, MapNpcNum).HP Then
```
Right underneath that, paste this:

```
MyScript.ExecuteStatement "Scripts\main.txt", "OnNPCDeath " & Attacker & "," & MapNpcNum
```
Now, add this sub to your main.txt:

```
Sub OnNpcDeath(index, mapnpcnum)
Call BattleMsg(index, "You killed a " & GetMapNPCName(GetPlayerMap(index), mapnpcnum) & ".", 4, 0)
End Sub
```
Now, whenever a player kills an NPC, a script can be called.

**Sub OnPlayerHitPlayer**
In _modGameLogic_, find procedure _AttackPlayer_. In it, look for this line:

```
    Call SendDataToMapBut(Attacker, GetPlayerMap(Attacker), "ATTACK" & SEP_CHAR & Attacker & SEP_CHAR & END_CHAR)
```
Right underneath that, paste this:

```
MyScript.ExecuteStatement "Scripts\Main.txt", "OnPlayerHitPlayer " & Attacker & "," & Victim & "," & Damage
```
Now, add this sub to your main.txt:

```
Sub OnPlayerHitPlayer(attacker, victim, damage)
Call BattleMsg(attacker, "You hit " & GetPlayerName(victim) & " for " & damage & " damage.", 4, 0)
Call BattleMsg(victim, GetPlayerName(attacker) & " hit you for " & damage & " damage.", 4, 0)
End Sub
```
Now, whenever a player hits another player, a script can be called.

_**Sub OnPlayerPKPlayer**_ (Already in EE)
In _modGameLogic_, find procedure _AttackPlayer_. In it, look for this line:

```
    If Damage >= GetPlayerHP(Victim) Then
```
Right underneath that, paste this:

```
    MyScript.ExecuteStatement "Scripts\Main.txt", "OnPlayerPKPlayer " & Attacker & "," & Victim
```
Now, add this sub to your main.txt:

```
Sub OnPlayerPKPlayer(attacker, victim)
Call BattleMsg(attacker, "You killed " & GetPlayerName(victim) & ".", 4, 0)
Call BattleMsg(victim, GetPlayerName(attacker) & " killed you.", 4, 0)
End Sub
```
Now, whenever a player kills another player (outside of an arena), a script can be called.

**Sub OnPlayerPKPlayerArena** (Already in EE)
In _modGameLogic_, find procedure _AttackPlayer_. In it, look for these lines:

```
ElseIf map(GetPlayerMap(Attacker)).Tile(GetPlayerX(Attacker), GetPlayerY(Attacker)).Type = TILE_TYPE_ARENA And map(GetPlayerMap(Victim)).Tile(GetPlayerX(Victim), GetPlayerY(Victim)).Type = TILE_TYPE_ARENA Then
    If Damage >= GetPlayerHP(Victim) Then
```
Right underneath that, paste this:

```
        MyScript.ExecuteStatement "Scripts\Main.txt", "OnPlayerPKPlayerArena " & Attacker & "," & Victim
```
Now, add this sub to your main.txt:

```
Sub OnPlayerPKPlayerArena(attacker, victim)
Call BattleMsg(attacker, "You killed " & GetPlayerName(victim) & ".", 4, 0)
Call BattleMsg(victim, GetPlayerName(attacker) & " killed you.", 4, 0)
End Sub
```
Now, whenever a player kills another player on an arene tile, a script can be called.

**Sub OnEquip** and **Sub OnUnEquip**
In _modServerTCP_, find procedure _HandleData_. In it, look for this line:

```
' Find out what kind of item it is
```
Underneath that, find these lines:

```
                        Call SetPlayerArmorSlot(index, InvNum)
                    Else
                        Call SetPlayerArmorSlot(index, 0)
                    End If
```
Change those to these:

```
                        MyScript.ExecuteStatement "Scripts\Main.txt", "OnEquip " & index & "," & GetPlayerInvItemNum(index, InvNum) & "," & InvNum
                    Else
                        MyScript.ExecuteStatement "Scripts\Main.txt", "OnUnEquip " & index & "," & GetPlayerInvItemNum(index, InvNum) & "," & InvNum
                    End If
```
There are six instances where you have to change them. There's one each for weapons, helmets, armor, shields, rings, and necklaces.

In the main.txt, add these subs:

```
Sub OnEquip(index, itemnum, slot)
Select Case itemnum
Case 0
Call PlayerMsg(index, "Houston, we have a problem.", 15)
Case Else
Call PlayerMsg(index, "You just equipped a " & GetItemName(itemnum) & " from item slot " & slot, 15)
Call Equip(index, 0, slot)
End Select
End Sub

Sub OnUnequip(index, itemnum, slot)
Select Case itemnum
Case 0
Call PlayerMsg(index, "Houston, we have a problem.", 15)
Case Else
Call PlayerMsg(index, "You just unequipped a " & GetItemName(itemnum) & " out of item slot " & slot, 15)
Call Unequip(index, 0, slot)
End Select
End Sub
```

There you have it. New script triggers. Keep in mind, that to function properly, some of these additions need commands from my clsCommands, found [here](http://www.freemmorpgmaker.com/smf/index.php/topic,16163.0.html).
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...