summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
Diffstat (limited to 'world')
-rw-r--r--world/map/npc/magic/_procedures.txt64
-rw-r--r--world/map/npc/magic/level1-experience.txt5
-rw-r--r--world/map/npc/magic/level1-lesser-heal.txt7
-rw-r--r--world/map/npc/magic/level2-lay-on-hands.txt14
4 files changed, 52 insertions, 38 deletions
diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt
index 5d7e5c8a..c7ae2cd7 100644
--- a/world/map/npc/magic/_procedures.txt
+++ b/world/map/npc/magic/_procedures.txt
@@ -15,6 +15,9 @@ function|script|magic_register
OnLogin:
set @_M_BLOCK, 2;
+ //if (MAGIC_EXPERIENCE < 0)
+ // set MAGIC_EXPERIENCE, 0; // bug fix
+ // ^ XXX: check if negative MAGIC_EXPERIENCE is desirable
addtimer 10000, "Magic Timer::OnClear";
end;
@@ -118,10 +121,20 @@ L_Perfect:
return;
}
+function|script|bit
+{
+ //0 name
+ //1 mask
+ //2 shift
+ //3 value
+
+ return ((getarg(0) & ~(getarg(1) << getarg(2))) | ((getarg(3) & getarg(1)) << getarg(2)));
+}
+
function|script|magic_exp
{
- set @last_index, (MAGIC_EXPERIENCE & BYTE_2_MASK) >> BYTE_2_SHIFT;
- set @last_exp, (MAGIC_EXPERIENCE & (BYTE_0_MASK | BYTE_1_MASK)) >> BYTE_0_SHIFT;
+ set @last_index, (MAGIC_EXPERIENCE >> 16) & 0xFF;
+ set @last_exp, MAGIC_EXPERIENCE & 0xFFFF;
//debugmes "old spell index: " + @last_index;
//debugmes "new spell index: " + .index;
@@ -136,12 +149,11 @@ L_Gain:
// remove this line then players can cast a spell with
// no cost, then a spell with a reagents, then another
// spell with no costs and still get the exp
- set @new_exp, @last_exp + .exp_gain;
- if(@new_exp > (BYTE_0_MASK | BYTE_1_MASK)) set @new_exp, (BYTE_0_MASK | BYTE_1_MASK);
+ set @new_exp, min(0xFFFF, @last_exp + .exp_gain);
//debugmes "old magic exp: "+ @last_exp;
//debugmes "new magic exp: "+ @new_exp;
- set MAGIC_EXPERIENCE, (MAGIC_EXPERIENCE &~ (BYTE_0_MASK | BYTE_1_MASK)) | (@new_exp << BYTE_0_SHIFT);
- set MAGIC_EXPERIENCE, (MAGIC_EXPERIENCE &~ BYTE_2_MASK) | (.index << BYTE_2_SHIFT);
+ set MAGIC_EXPERIENCE, call("bit", MAGIC_EXPERIENCE, 0xFFFF, 0, @new_exp);
+ set MAGIC_EXPERIENCE, call("bit", MAGIC_EXPERIENCE, 0xFF, 16, .index);
goto L_Return;
L_Return:
@@ -168,25 +180,29 @@ L_Return:
function|script|gain_heal_xp
{
- set @last_heal_xp, ((SCRIPT_XP & SCRIPT_HEALSPELL_MASK) >> SCRIPT_HEALSPELL_SHIFT);
- if ((@target_id != BL_ID) && ((.@heal_value / .heal_xp_value_divisor) > (((10 + @last_heal_xp) + rand(@last_heal_xp + 1)) + rand(@last_heal_xp + 1))))
- goto L_Block;
- goto L_Return;
+ set .@value, getarg(0);
+ set .@gain, getarg(1);
+ set .@value_divisor, getarg(2);
+ set .@base_xp_factor, getarg(3);
-L_Block:
- set @heal_xp, (@last_heal_xp + @mexp);
- if (@heal_xp > SCRIPT_HEALSPELL_MASK)
- set @heal_xp, SCRIPT_HEALSPELL_MASK;
- set SCRIPT_XP, (SCRIPT_XP & ~(SCRIPT_HEALSPELL_MASK) | (@heal_xp << SCRIPT_HEALSPELL_SHIFT));
- goto L_Gain_Xp;
-
-L_Gain_Xp:
- set @heal_exp, .@heal_value;
- if (.@heal_value > get(HEALXP, @target_id))
- set @heal_exp, get(HEALXP, @target_id);
- getexp (.base_exp_factor * @heal_exp), 0;
- goto L_Return;
+ set .@last_heal_xp, ((MAGIC_EXPERIENCE >> 24) & 0xFF);
+
+ if ((.@value / .@value_divisor) <= (10 + .@last_heal_xp + rand(.@last_heal_xp + 1) + rand(.@last_heal_xp + 1)))
+ goto L_Return;
+
+ set .@heal_xp, min(0xFF, .@last_heal_xp + .@gain); // XXX: maybe switch to 7F
+
+ getexp (.@base_xp_factor * .@heal_xp), 0;
+
+ // FIXME: extract_heal_xp
+
+ //debugmes "old heal exp: "+ .@last_heal_xp;
+
+ set MAGIC_EXPERIENCE, call("bit", MAGIC_EXPERIENCE, 0xFF, 24, .@heal_xp);
+
+ //debugmes "new heal exp: "+ ((MAGIC_EXPERIENCE >> 24) & 0xFF);
+ return 1;
L_Return:
- return;
+ return 0;
}
diff --git a/world/map/npc/magic/level1-experience.txt b/world/map/npc/magic/level1-experience.txt
index 36ad8179..94b07ad0 100644
--- a/world/map/npc/magic/level1-experience.txt
+++ b/world/map/npc/magic/level1-experience.txt
@@ -1,5 +1,10 @@
-|script|spell-experience|32767
{
+ //debugmes MAGIC_EXPERIENCE;
+ //debugmes (MAGIC_EXPERIENCE >> 0) & 0xFFFF; // magic exp
+ //debugmes (MAGIC_EXPERIENCE >> 16) & 0xFF; // last spell index
+ //debugmes (MAGIC_EXPERIENCE >> 24) & 0xFF; // heal exp
+
if(call("magic_checks")) end;
if (Sp < 1) end;
set @_M_BLOCK, 1; // block casting, until the timer clears it
diff --git a/world/map/npc/magic/level1-lesser-heal.txt b/world/map/npc/magic/level1-lesser-heal.txt
index d195956f..37d081dc 100644
--- a/world/map/npc/magic/level1-lesser-heal.txt
+++ b/world/map/npc/magic/level1-lesser-heal.txt
@@ -17,18 +17,14 @@
callfunc "adjust_spellpower";
set Sp, Sp - 6;
misceffect FX_MAGIC_WHITE, strcharinfo(0);
- set .@heal_value, get(HEALXP, @target_id);
- set @mexp, .exp_gain;
callfunc "magic_exp";
- if (.@heal_value > 200)
- set .@heal_value, 200;
if (@args$ == "Mouboo" || @args$ == "mouboo") goto L_Mouboo;
if (@target_id != BL_ID) goto L_NotMe;
goto L_Continue;
L_NotMe:
misceffect FX_MAGIC_WHITE, @target_id;
- callfunc "gain_heal_xp";
+ void call("gain_heal_xp", min(200, (get(MaxHp, @target_id) - get(Hp, @target_id))), 1, 2, 2);
goto L_Continue;
L_Continue:
@@ -51,6 +47,5 @@ OnInit:
void call("magic_register");
set .level, 1;
set .exp_gain, 1;
- set .heal_xp_value_divisor, 2;
end;
}
diff --git a/world/map/npc/magic/level2-lay-on-hands.txt b/world/map/npc/magic/level2-lay-on-hands.txt
index 0affb210..1f9d7389 100644
--- a/world/map/npc/magic/level2-lay-on-hands.txt
+++ b/world/map/npc/magic/level2-lay-on-hands.txt
@@ -12,7 +12,7 @@
if (distance(BL_ID, @target_id) >= (((sqrt(@spellpower)*12)+@spellpower)/100)+2) end;
if (sc_check(SC_HALT_REGENERATE,@target_id)) end;
if (getequipid(equip_head, @args$) == 888) end; // magic gm top hat
- set .@needed, get(MaxHp, @target_id) - get(Hp, @target_id);
+ set @needed, get(MaxHp, @target_id) - get(Hp, @target_id);
goto L_Pay;
L_Pay:
@@ -23,14 +23,14 @@ L_Pay:
misceffect FX_MAGIC_WHITE, @args$; // on target
set .@fraction, max(80, 200 - (Vit + (@spellpower/10))); // pay at least 40%
- set .@payment, (.@needed * .@fraction) / 200;
+ set .@payment, (@needed * .@fraction) / 200;
set .@available, Hp - (MaxHp / 20);
- set .@heal_value, if_then_else(.@payment < .@available, .@needed+1-1, (.@available * 200) / .@fraction); // FIXME / XXX why the f do I need to do +1-1 ?
+ set @heal_value, if_then_else(.@payment < .@available, @needed+1-1, (.@available * 200) / .@fraction); // FIXME / XXX why the f do I need to do +1-1 ?
if (.@payment > .@available) set .@payment, .@available;
set @mexp, min(.exp_gain, .@payment/100);
- callfunc "gain_heal_xp";
+ void call("gain_heal_xp", @heal_value, 1, 1, 3);
callfunc "magic_exp";
set .@dark, getskilllv(SKILL_MAGIC_DARK) >= 2; // true if dark magic user
@@ -40,13 +40,13 @@ L_Pay:
set .@thp, get(Hp, @target_id);
if (.@thp < 1) end;
- set Hp, .@thp + .@heal_value, @target_id;
+ set Hp, .@thp + @heal_value, @target_id;
end;
L_Mouboo:
set @spell, 1;
callfunc "QuestMoubooHeal";
- set .@needed, 1000;
+ set @needed, 1000;
goto L_Pay;
OnInit:
@@ -55,7 +55,5 @@ OnInit:
void call("magic_register");
set .level, 2;
set .exp_gain, 1; // this is MAX possible exp
- set .heal_xp_value_divisor, 1;
- set .base_exp_factor, 3;
end;
}