summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-08-17 23:37:46 -0300
committerJesusaves <cpntb1@ymail.com>2024-08-17 23:37:46 -0300
commit4871f91c277df6bd1149285bb8dc1b8333248fcf (patch)
tree4d1e5762214904101558f3fa1ff8c419a00f4e76
parent6378a5411e6432232ce40b58bd32e1480ba73a25 (diff)
downloadserverdata-4871f91c277df6bd1149285bb8dc1b8333248fcf.tar.gz
serverdata-4871f91c277df6bd1149285bb8dc1b8333248fcf.tar.bz2
serverdata-4871f91c277df6bd1149285bb8dc1b8333248fcf.tar.xz
serverdata-4871f91c277df6bd1149285bb8dc1b8333248fcf.zip
This is the experimental and untested code for the use-case of the new commands.
The skill cannot be obtained. It's untested, and it could break server. (Need to check of duplicate removal of a running NPC crashes server or not).
-rw-r--r--db/re/skill_db.conf32
-rw-r--r--db/re/skill_tree.conf1
-rw-r--r--npc/config/duplicates.txt33
-rw-r--r--npc/config/traps.txt31
-rw-r--r--npc/functions/hub.txt3
-rw-r--r--npc/magic/traps.txt56
-rw-r--r--npc/scripts.conf2
7 files changed, 157 insertions, 1 deletions
diff --git a/db/re/skill_db.conf b/db/re/skill_db.conf
index 9328a4d40..aa91ce1b6 100644
--- a/db/re/skill_db.conf
+++ b/db/re/skill_db.conf
@@ -40499,6 +40499,38 @@ skill_db: (
Quest: true
}
},
+{
+ Id: 20080
+ Name: "TMW2_TRAPS"
+ Description: "Trap Setter"
+ MaxLevel: 10
+ SkillType: {
+ Self: true
+ }
+ SkillInfo: {
+ Quest: true
+ }
+ CoolDown: {
+ Lv1: 120000
+ Lv2: 115000
+ Lv3: 110000
+ Lv4: 105000
+ Lv5: 100000
+ Lv6: 95000
+ Lv7: 90000
+ Lv8: 85000
+ Lv9: 80000
+ Lv10: 75000
+ }
+ CastTime: 100
+ FixedCastTime: 100
+ Requirements: {
+ SPCost: 100
+ Items: {
+ IronOre: 1
+ }
+ }
+},
diff --git a/db/re/skill_tree.conf b/db/re/skill_tree.conf
index 6ecdff753..009931be4 100644
--- a/db/re/skill_tree.conf
+++ b/db/re/skill_tree.conf
@@ -83,6 +83,7 @@ Human: {
///////////////// Magic v3 (Custom/Trickmaster)
TMW2_MANABOMB: 0
+ TMW2_TRAPS: 0
///////////////// Magic v3 (Custom/Scholarship)
TMW2_FIRSTAID: 0
diff --git a/npc/config/duplicates.txt b/npc/config/duplicates.txt
new file mode 100644
index 000000000..cdf24ed61
--- /dev/null
+++ b/npc/config/duplicates.txt
@@ -0,0 +1,33 @@
+// TMW2 script
+// Author: Jesusalva <admin@tmw2.org>
+// Manages duplicates
+
+- script #dupemaster 32767,{
+ end;
+
+OnInterIfInitOnce:
+ // (dupe_name$, expire_tick)
+ $@_DUPES = htnew();
+ end;
+
+OnInit:
+ initnpctimer;
+ end;
+
+// Cleans every 15s
+OnTimer15000:
+ .@t = gettimetick(2);
+
+ .@iter = htiterator($@_DUPES);
+ for (.@key$ = htinextkey(.@iter); hticheck(.@iter); .@key$ = htinextkey(.@iter)) {
+ // Check if the NPC expired, remove from hash table if so
+ if (htget($@_DUPES, .@key$, INT_MAX) <= .@t) {
+ npc_duplicate_remove(.@key$);
+ htput($@_DUPES, .@key$, 0);
+ }
+ }
+ htidelete(.@iter);
+
+ initnpctimer;
+ end;
+}
diff --git a/npc/config/traps.txt b/npc/config/traps.txt
index 1bb9d35e7..9f71edf27 100644
--- a/npc/config/traps.txt
+++ b/npc/config/traps.txt
@@ -69,7 +69,7 @@ function script IronTrap {
.@gid=(playerattached() ? playerattached() : mobattached());
// Just to be sure
- if (.@gid)
+ if (.@gid > 0)
harm(.@gid, .@dmg, HARM_MISC);
else
Exception("IronTrap \""+.@n$+"\" called without GID!", RB_DEBUGMES);
@@ -111,3 +111,32 @@ function script WorldHeartTrap {
return;
}
+
+// SkillTrap( {damage=100}, {delay=2s}, {npcname=auto} )
+function script SkillTrap {
+ .@dmg=getarg(0, 100);
+ .@delay=getarg(1, 2);
+ .@n$=getarg(2, strnpcinfo(0));
+
+ // Fire!!
+ awake(.@n$);
+ setnpcdisplay .@n$, NPC_TRAP_TRIGGERED;
+
+ // Skill traps does not distinguish between players or monsters
+ // (and does not work on homunculus, mercenaries, etc.)
+ sc_start SC_STUN, .@delay, 0;
+ .@gid=(playerattached() ? playerattached() : mobattached());
+
+ // Just to be sure
+ if (.@gid > 0)
+ harm(.@gid, .@dmg, HARM_MISC);
+ else
+ Exception("SkillTrap \""+.@n$+"\" called without GID!", RB_DEBUGMES);
+
+ // A minor special effect and we're done.
+ specialeffect 11;
+ sleep(800);
+ setnpcdisplay .@n$, NPC_TRAP_ONLINE;
+ return;
+}
+
diff --git a/npc/functions/hub.txt b/npc/functions/hub.txt
index 33831941c..fc15384af 100644
--- a/npc/functions/hub.txt
+++ b/npc/functions/hub.txt
@@ -609,6 +609,9 @@ function script HUB_SkillInvoke {
SK_spregen();
GetManaExp(GD_DEVELOPMENT, 10);
break;
+ case TMW2_TRAPS:
+ SK_Traps();
+ break;
// Weapon Overload attack
case TMW2_OVERLOAD:
.@PW=200+(@skillLv > 3 ? @skillLv : 0)+(@skillLv > 7 ? @skillLv*2 : 0);
diff --git a/npc/magic/traps.txt b/npc/magic/traps.txt
new file mode 100644
index 000000000..65da75e69
--- /dev/null
+++ b/npc/magic/traps.txt
@@ -0,0 +1,56 @@
+// TMW2 script
+// Author: Jesusalva <admin@tmw2.org>
+//
+// Magic Script: TMW2_TRAPS
+//
+// Deploy a trap behind you.
+
+function script SK_Traps {
+ .@lv = getskilllv(TMW2_TRAPS);
+ .@ab = abizit() * 2;
+ // TODO: Determine duration, power, stun time; use abizit too
+ // More abizit: Longer duration and stun time
+ // Higher level: Longer duration and power
+ .@length=40 + (.@lv+.@ab)*4; // Max duration: 120 seconds
+ .@power =.@lv * 100;
+ .@stun =.@ab * 6 / 5; // Up to 12s of stun time (2,4,7,9,12 seconds)
+ .@n$ = sprintf("sk#_%06d_%06d_%01d_%05d", getcharid(0), .@power, .@stun, htsize($@_DUPES));
+ getmapxy(.@m$, .@x, .@y, 0);
+
+ npc_duplicate("sk#trap", .@n$, .@m$, .@x, .@y);
+ htput($@_DUPES, .@n$, gettimetick(2) + .@length);
+
+ // Get a few mana experience points (this is NOT used by Mana Stone)
+ GetManaExp(TMW2_TRAPS, rand2(1,.@lv));
+ return;
+}
+
+// Copy from 026-7/config, and htput($@_DUPES, "new_npc_name", expiration_tick)
+// Syntax: sk#_CharID_dmg_stun_{uuid}
+// 3 + 6 + (up to 6) + 1 = 15 out of 22 chars (5 for UUID)
+// So UUID
+// We'll also need another trap function
+boss,0,0,0 script sk#trap NPC_TRAP,0,0,{
+ end;
+
+OnTouch:
+ .@id=getcharid(0);
+ // FALLTHROUGH
+OnTouchNPC:
+ explode(.@parts$, strnpcinfo(0), "_");
+ .@gid=atoi(.@parts$[1]);
+ .@dmg=atoi(.@parts$[2]);
+ .@stn=atoi(.@parts$[3]);
+ // Do not harm the trap setter/caster
+ if (.@id == .@gid)
+ end;
+ // Actual trap function
+ SkillTrap(.@dmg, .@stn);
+ end;
+
+OnInit:
+ // A small animation of the trap arming itself...
+ sleep(500);
+ setnpcdisplay strnpcinfo(0), NPC_TRAP_ONLINE;
+ end;
+}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index e61b5db50..5732cccf9 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -35,6 +35,7 @@
"npc/commands/event.txt",
// config script
+"npc/config/duplicates.txt",
"npc/config/hairstyle_config.txt",
"npc/config/location.txt",
"npc/config/traps.txt",
@@ -143,6 +144,7 @@
"npc/magic/revive.txt",
"npc/magic/study.txt",
"npc/magic/transmigration.txt",
+"npc/magic/traps.txt",
"npc/magic/scrolls.txt",
"npc/magic/magic_blackbox.txt",