Skip to content

Commit

Permalink
Merge pull request #492 from mekolat/puppet-checks
Browse files Browse the repository at this point in the history
Puppet checks
  • Loading branch information
mekolat committed May 2, 2016
2 parents 2f97a15 + 3ad45c5 commit f892486
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 24 deletions.
21 changes: 10 additions & 11 deletions world/map/npc/001-2/wizards.txt
Expand Up @@ -11,16 +11,15 @@
close;

OnInit:
void
puppet("001-2", 104, 19, "Desert Mana Seed#_M", 166),
puppet("001-2", 99, 22, "Wizard#1", 355),
puppet("001-2", 92, 24, "Wizard#2", 356),
puppet("001-2", 92, 30, "Wizard#3", 357),
puppet("001-2", 99, 32, "Wizard#4", 358),
puppet("001-2", 110, 22, "Wizard#5", 359),
puppet("001-2", 117, 24, "Wizard#6", 360),
puppet("001-2", 117, 30, "Wizard#7", 361),
puppet("001-2", 110, 32, "Wizard#8", 362),
puppet("001-2", 104, 27, "Arch-Wizard#9", 354);
if (puppet("001-2", 104, 19, "Desert Mana Seed#_M", 166) < 1) mapexit;
if (puppet("001-2", 99, 22, "Wizard#1", 355) < 1) mapexit;
if (puppet("001-2", 92, 24, "Wizard#2", 356) < 1) mapexit;
if (puppet("001-2", 92, 30, "Wizard#3", 357) < 1) mapexit;
if (puppet("001-2", 99, 32, "Wizard#4", 358) < 1) mapexit;
if (puppet("001-2", 110, 22, "Wizard#5", 359) < 1) mapexit;
if (puppet("001-2", 117, 24, "Wizard#6", 360) < 1) mapexit;
if (puppet("001-2", 117, 30, "Wizard#7", 361) < 1) mapexit;
if (puppet("001-2", 110, 32, "Wizard#8", 362) < 1) mapexit;
if (puppet("001-2", 104, 27, "Arch-Wizard#9", 354) < 1) mapexit;
end;
}
8 changes: 6 additions & 2 deletions world/map/npc/008-1/annualeaster.txt
Expand Up @@ -129,10 +129,14 @@ OnSpawn:
set .@y, .loc[(.@e-1)+.loc[1]];
set .eID, .eID + 1; // give the egg an id
set .@name$, "#--Ee"+chr(3)+.eID;
void puppet(strnpcinfo(3), .@x, .@y, .@name$, 375); // spawn the egg
initnpctimer .@name$; // init puppeteer check timer
if (.eID == 2147483647)
set .eID, 0; // start over if id = 0x7FFFFFFF
if (puppet(strnpcinfo(3), .@x, .@y, .@name$, 375) < 1) goto L_RetrySpawn; // spawn the egg
initnpctimer .@name$; // init puppeteer check timer
end;

L_RetrySpawn:
addnpctimer 0, strnpcinfo(0) + "::OnSpawn"; // schedule a spawn
end;

S_Spawn:
Expand Down
2 changes: 1 addition & 1 deletion world/map/npc/029-2/alchemy.txt
Expand Up @@ -74,7 +74,7 @@ S_Spawn:
if (.spawned >= .@s)
goto S_Return;
set .@n$, "#_Al-lab"+chr(3)+.spawned;
void puppet(.m$[.spawned], .x1[.spawned], .y1[.spawned], .@n$, 400); // TODO: make a npc like npc 400 but with hoverCursor="action" => looks better for things like crafting
if (puppet(.m$[.spawned], .x1[.spawned], .y1[.spawned], .@n$, 400) < 1) mapexit; // TODO: make a npc like npc 400 but with hoverCursor="action" => looks better for things like crafting
set .spawned, .spawned + 1;
if (.spawned < .@s)
goto S_Spawn;
Expand Down
7 changes: 4 additions & 3 deletions world/map/npc/055-1/pumpkins.txt
Expand Up @@ -83,6 +83,8 @@ OnReallyDestroy:
S_MakeNode:
set .nID, .nID + 1; // give the node an id
set .@name$, "#_Pkin" + chr(3) + .nID;
if (.nID == 2147483647)
set .nID, 0; // start over if id = 0x7FFFFFFF
goto S_FindXY;

S_FindXY:
Expand All @@ -94,13 +96,13 @@ S_FindXY:

S_ReallySpawn:
set .@p, puppet(.m$[.i], .@x, .@y, .@name$, 32767); // spawn the node (but not on map, because 32767)
if (.@p < 1) goto S_MakeNode; // silently retry
disablenpc .@name$; // make sure it can't be clicked by guessing the being id
set .i, .i, .@p; // tell the puppet what object contains it
set .death_t, rand(.death_t/2, .death_t), .@p; // tell the puppet when to die
set .@timer, if_then_else(.done_initial[.i], rand(.appear_t/2, .appear_t), 0); // timer depends on if first spawn or if respawned after death
addnpctimer .@timer, .@name$+"::OnAppear"; // we spawn the node instantly but it only appears after the timer
if (.nID == 2147483647)
set .nID, 0; // start over if id = 0x7FFFFFFF
set .nodes[.i], .nodes[.i] + 1;
return;

S_IterateObjects:
Expand All @@ -112,7 +114,6 @@ S_IterateObjects:
if (.nodes[.i] >= .max_nodes[.i])
goto S_NextObject;

set .nodes[.i], .nodes[.i] + 1;
callsub S_MakeNode;
if (.nodes[.i] < if_then_else(.done_initial[.i], .min_nodes[.i], .max_nodes[.i]))
goto S_IterateObjects;
Expand Down
2 changes: 1 addition & 1 deletion world/map/npc/commands/numa.txt
Expand Up @@ -90,7 +90,7 @@ L_Close:
OnInit:
registercmd chr(ATCMD_SYMBOL) + "numa", strnpcinfo(0);
registercmd chr(ATCMD_SYMBOL) + "superdebug", strnpcinfo(0);
void puppet("017-9", 30, 28, "Numa", 393);
if (puppet("017-9", 30, 28, "Numa", 393) < 1) mapexit;
end;
}

Expand Down
1 change: 1 addition & 0 deletions world/map/npc/magic/level1-summon-maggots.txt
Expand Up @@ -18,6 +18,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, ((sqrt(@spellpower)+(@spellpower/15))/5)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, (@spellpower*50)+10000, .@puppet;
Expand Down
1 change: 1 addition & 0 deletions world/map/npc/magic/level2-arrow-hail.txt
Expand Up @@ -32,6 +32,7 @@ OnCast:
callfunc "magic_exp";
misceffect FX_MAGIC_BLACK, strcharinfo(0);
set @spell_npc, puppet(getmap(), POS_X, POS_Y, @new_npc_name$, 127); // clone npc => get puppet id
if (@spell_npc < 1) end;
set .max_hit, (@spellpower / 8), @spell_npc; // set .max_hit in the puppet
set .caster, getcharid(3), @spell_npc; // tell the puppet who controls it
set .damage, 125, @spell_npc;
Expand Down
1 change: 1 addition & 0 deletions world/map/npc/magic/level2-rain.txt
Expand Up @@ -29,6 +29,7 @@ OnCast:
callfunc "magic_exp";
misceffect FX_MAGIC_GREEN, strcharinfo(0);
set @spell_npc, puppet(getmap(), POS_X, POS_Y, @new_npc_name$, 127); // clone npc => get puppet id
if (@spell_npc < 1) end;
set .caster, getcharid(3), @spell_npc; // tell the puppet who controls it
set .radius, @krad, @spell_npc; // this is also used by ingrav, don't rename
set .initial_x, POS_X, @spell_npc;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-fluffies.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 39) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -19,6 +19,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/170)+1+(@spellpower/430), .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*350, .@puppet;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-mouboo.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 35) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -19,6 +19,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/270)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*100, .@puppet;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-pinkie.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 35) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -19,6 +19,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/120)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*150, .@puppet;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-snakes.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 40) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -20,6 +20,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/300)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*80, .@puppet;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-spiky-mushroom.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 33) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -19,6 +19,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/120)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*400, .@puppet;
Expand Down
3 changes: 2 additions & 1 deletion world/map/npc/magic/level2-summon-wickedmushroom.txt
Expand Up @@ -3,7 +3,7 @@
end;

OnCast:
if(call("magic_checks")) end;
if(call("magic_checks")) end;
if (Sp < 35) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (getskilllv(.school) < .level) end;
Expand All @@ -20,6 +20,7 @@ OnCast:
callfunc "magic_exp";
set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID;
set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127);
if (.@puppet < 1) end;
set .count, (@spellpower/250)+1, .@puppet;
set .master, BL_ID, .@puppet;
set .lifetime, @spellpower*80, .@puppet;
Expand Down

0 comments on commit f892486

Please sign in to comment.