Monster Handler Code by El Furriando
This code is the original code written by El Furriando. I have posted this with El Furriando's permission. Looking at this will help you understand the full game source better.
*WANDERING NPC DS*
*USES TIMERS 400-500*
*BEGIN LOOP*
(This little tidbit instantly triggers 100 timers after the dream loads, its a glitch with the DS parser that we
are using to our advantage)
*Init timers*
(0:0) When everything is starting up,
(5:50) set countdown timer 400 to go off in 1 seconds.
(5:300) set variable %npc_loop to the value 400.
(0:49) When any countdown timer goes off,
(5:327) set variable %timer to the number of the countdown timer that just went off.
(5:301) copy the value of variable %timer into variable %wut_npc.
(5:304) take variable %wut_npc and subtract 399 from it.
(5:300) set variable %trig_npc to the value 0.
*NPC INIT*
*USE ANY TRIGGER HERE TO RESTART THE NPCS*
(0:31) When someone says {Reset},
(5:300) set variable %wanderers to the value 100. How many wanderers
*We are going to use a dummy player to track the stats of all npcs*
(5:631) forget all PhoenixSpeak info about the player named {N}.
(5:5) change item 1398 to item 0.
*CLEAR NPCS*
(5:5) change item 305 to item 0.
(5:5) change item 306 to item 0.
(5:5) change item 307 to item 0.
(5:5) change item 308 to item 0.
(5:5) change item 309 to item 0.
(5:5) change item 310 to item 0.
*In wanderer tuple, add in the shape variations for the npc*
*Variation number in () followed by the item number, and then a ( if its at the end of the string*
(5:250) set message ~wanderer_tuple to { (1)305(2)306(3)307(4)308(5)309(6)310( }.
*set %wanderer_diversity to the number of entries in ~wanderer_tuple*
(5:300) set variable %wanderer_diversity to the value 6.
*Spawn wanderers*
(0:49) When any countdown timer goes off,
(1:201) and variable %wanderers is more than 0,
(5:312) set variable %wanderer_type to the total of rolling 1 dice with %wanderer_diversity sides plus 0.
(5:251) copy message ~wanderer_tuple onto message ~temp.
(5:283) set variable %temp to the total number of characters before {(%wanderer_type)} appears in message ~temp (or zero if not found).
(5:274) chop off the beginning of message ~temp, removing the first %temp characters of it.
(5:278) remove the first 1 copies of {(%wanderer_type)} from message ~temp.
(5:282) set variable %wanderer_item to the first number in ~temp.
(3:502) at a random spot somewhere in the Dream,
(4:1) only where the floor is 500,
*(3:512) at a random spot somewhere in the Dream where the floor is 500,
(4:8) only where there are no items,
(5:4) place item 1398.
(4:0) clear all filtering,
(5:532) set variable %npc_loc to the X,Y position of a random spot where the item is 1398 somewhere in the Dream.
(5:41) place item %wanderer_item at (%npc_loc).
*MEMORIZE WANDERER POS*
(5:601) memorize that the PhoenixSpeak info {%wanderers x} about the player named {N} will now be %npc_loc.x
(5:601) memorize that the PhoenixSpeak info {%wanderers y} about the player named {N} will now be %npc_loc.y
*MEMORIZE WANDERER HP, SET TO 10 FOR NOW*
(5:601) memorize that the PhoenixSpeak info {%wanderers h} about the player named {N} will now be 10
*MEMORIZE WANDERER ACTION POINTS, SET TO 10 FOR NOW*
(5:601) memorize that the PhoenixSpeak info {%wanderers a} about the player named {N} will now be 10
*MEMORIZE WANDERER CLASS, SET TO 1 FOR NOW*
*CLASS IS STORED AS A NUMBER TO CONSERVE PS SPACE, BUT YOU COULD USE THAT VALUE TO COMPARE IT TO A STRING*
(5:601) memorize that the PhoenixSpeak info {%wanderers c} about the player named {N} will now be 1
*MEMORIZE WANDERER ARMOUR, SET TO 1 FOR NOW(Used D for defence, A is already being used for action points)*
(5:601) memorize that the PhoenixSpeak info {%wanderers d} about the player named {N} will now be 1
*MEMORIZE WANDERER TURN, SET TO 30 FOR NOW(repleneshes AP every 30 seconds)*
(5:601) memorize that the PhoenixSpeak info {%wanderers t} about the player named {N} will now be 30
*Memorize wanderer inverted coordinate(for referencing)
(5:601) memorize that the PhoenixSpeak info {%npc_loc.x %npc_loc.y} about the player named {N} will now be %wanderers.
*subtract 1 from spawn
(5:304) take variable %wanderers and subtract 1 from it.
(5:204) emitloud message {NPC loc is %npc_loc.x %npc_loc.y} to everyone on the map.
*Process wanderer's AI*
*Get current npc*
(0:49) When any countdown timer goes off,
(1:201) and variable %wut_npc is more than 0,
(1:202) and variable %wut_npc is less than 101,
(1:615) and the PhoenixSpeak info {%wut_npc x} about the player named {N} exists,
(5:300) set variable %trig_npc to the value 1.
(5:611) remember the PhoenixSpeak info {%wut_npc x} about the player named {N}, and put it in variable %npc.x
(5:611) remember the PhoenixSpeak info {%wut_npc y} about the player named {N}, and put it in variable %npc.y
(5:611) remember the PhoenixSpeak info {%wut_npc t} about the player named {N}, and put it in variable %npc_turn
(5:611) remember the PhoenixSpeak info {%wut_npc a} about the player named {N}, and put it in variable %npc_ap
(5:301) copy the value of variable %npc into variable %npc_NE
(5:301) copy the value of variable %npc into variable %npc_SE
(5:301) copy the value of variable %npc into variable %npc_SW
(5:301) copy the value of variable %npc into variable %npc_NW
(5:352) move the position in variable %npc_NE northeast (up and right) 1 step(s).
(5:353) move the position in variable %npc_SE southeast (down and right) 1 step(s).
(5:354) move the position in variable %npc_SW southwest (down and left) 1 step(s).
(5:355) move the position in variable %npc_NW northwest (up and left) 1 step(s).
(5:312) set variable %NPC_dir to the total of rolling 1 dice with 4 sides plus 0.
(5:312) set variable %NPC_move to the total of rolling 1 dice with 3 sides plus 0.
*MOVE NE
(0:49) When any countdown timer goes off,
(1:200) and variable %NPC_dir is equal to 1,
(5:301) copy the value of variable %npc_NE into variable %new_pos.
*MOVE SE
(0:49) When any countdown timer goes off,
(1:200) and variable %NPC_dir is equal to 2,
(5:301) copy the value of variable %npc_SE into variable %new_pos.
*MOVE SW
(0:49) When any countdown timer goes off,
(1:200) and variable %NPC_dir is equal to 3,
(5:301) copy the value of variable %npc_SW into variable %new_pos.
*MOVE NW
(0:49) When any countdown timer goes off,
(1:200) and variable %NPC_dir is equal to 4,
(5:301) copy the value of variable %npc_NW into variable %new_pos.
(0:49) When any countdown timer goes off,
(1:615) and the PhoenixSpeak info {%wut_npc x} about the player named {N} exists,
*make sure an NPC is being triggered
(1:200) and variable %trig_npc is equal to 1,
*make sure the 33% chance was triggered
(1:200) and variable %NPC_move is equal to 1,
*Check action points*
(1:201) and variable %npc_ap is more than 0,
*Check to make sure npc isn't adjacent to a player*
(1:1101) and there's no one at (%npc_NE),
(1:1101) and there's no one at (%npc_SE),
(1:1101) and there's no one at (%npc_SW),
(1:1101) and there's no one at (%npc_NW),
*check the new location to make sure its clear*
(1:1011) and position (%new_pos) is floor 500,
(1:1013) and position (%new_pos) is item 0,
*get old sprite*
(5:381) set variable %npcitem to the item type at (%npc).
*clear old sprite*
(5:41) place item 0 at (%npc).
*place new object*
(5:41) place item %npcitem at (%new_pos).
*subtract action point*
(5:304) take variable %npc_ap and subtract 1 from it.
*commit changes to memory*
(5:601) memorize that the PhoenixSpeak info {%wut_npc x} about the player named {N} will now be %new_pos.x
(5:601) memorize that the PhoenixSpeak info {%wut_npc y} about the player named {N} will now be %new_pos.y
(5:601) memorize that the PhoenixSpeak info {%wut_npc a} about the player named {N} will now be %npc_ap.
(5:635) forget the PhoenixSpeak info {%npc.x %npc.y} about the player named {N}.
(5:601) memorize that the PhoenixSpeak info {%new_pos.x %new_pos.y} about the player named {N} will now be %wut_npc.
*Subtract 1 from turn*
(0:49) When any countdown timer goes off,
(1:615) and the PhoenixSpeak info {%wut_npc x} about the player named {N} exists,
*make sure an NPC is being triggered
(1:200) and variable %trig_npc is equal to 1,
(1:201) and variable %npc_turn is more than 0,
(5:304) take variable %npc_turn and subtract 1 from it.
(5:601) memorize that the PhoenixSpeak info {%wut_npc t} about the player named {N} will now be %npc_turn.
*reset turns to 30 if at 0*
(0:49) When any countdown timer goes off,
(1:615) and the PhoenixSpeak info {%wut_npc x} about the player named {N} exists,
*make sure an NPC is being triggered
(1:200) and variable %trig_npc is equal to 1,
(1:200) and variable %npc_turn is equal to 0,
(5:601) memorize that the PhoenixSpeak info {%wut_npc t} about the player named {N} will now be 30.
(5:601) memorize that the PhoenixSpeak info {%wut_npc a} about the player named {N} will now be 10.
-----------------------------------------------------------------------------------------------------------
*Game Clock reset Code*
*Add to loop*
(0:49) When any countdown timer goes off,
(1:201) and variable %timer is more than 399,
(1:202) and variable %timer is less than 500,
(1:202) and variable %npc_loop is less than 500,
(5:302) take variable %npc_loop and add 1 to it.
(5:50) set countdown timer %npc_loop to go off in 1 seconds.
(0:49) When any countdown timer goes off,
(1:201) and variable %timer is more than 399,
(1:202) and variable %timer is less than 500,
(5:50) set countdown timer %timer to go off in 1 seconds.
-----------------------------------------------------------------------------------------------------------------------
********************************************************************************************************************************
*basic F3 for testing and attacking*
*****************************************************************************************************************************
---------------------------------------------------------------------------------------------------------
*Depending on the direction the player is facing grab the position directly in front of them.*
--------------------------------------------------------------------------------------------------------
(0:16) When someone uses any item,
(5:350) set variable %temp to the X,Y position the triggering player (moved from/is standing at).
(0:16) When someone uses any item,
(1:13) and they are facing northeast (up and right),
(5:352) move the position in variable %temp northeast (up and right) 1 step(s).
(0:16) When someone uses any item,
(1:14) and they are facing southeast (down and right),
(5:353) move the position in variable %temp southeast (down and right) 1 step(s).
(0:16) When someone uses any item,
(1:15) and they are facing southwest (down and left),
(5:354) move the position in variable %temp southwest (down and left) 1 step(s).
(0:16) When someone uses any item,
(1:16) and they are facing northwest (up and left),
(5:355) move the position in variable %temp northwest (up and left) 1 step(s).
---------------------------------------------------------------------------------------------------------------------
*check to see if there is anything in the position in front of the player
*if there is information about that position and put it into a reference variable
*using the reference variable access the rest of the data Health(max),Sub Health,Action Points,Class,Defense, and turn
*perform the the attack check and commit that check to the database
*Then emit the information about the monster to the one who attacked it.
---------------------------------------------------------------------------------------------------------------------
(0:16) When someone uses any item,
(1:615) and the PhoenixSpeak info {%temp.x %temp.y} about the player named {N} exists,
(5:611) remember the PhoenixSpeak info {%temp.x %temp.y} about the player named {N}, and put it in variable %temp1.
(5:611) remember the PhoenixSpeak info {%temp1 h} about the player named {N}, and put it in variable %emit_health.
(5:611) remember the PhoenixSpeak info {%temp1 h} about the player named {N}, and put it in variable %emit_sub_health.
(5:611) remember the PhoenixSpeak info {%temp1 a} about the player named {N}, and put it in variable %emit_ap.
(5:611) remember the PhoenixSpeak info {%temp1 c} about the player named {N}, and put it in variable %emit_class.
(5:611) remember the PhoenixSpeak info {%temp1 d} about the player named {N}, and put it in variable %emit_defense.
(5:611) remember the PhoenixSpeak info {%temp1 t} about the player named {N}, and put it in variable %emit_turn.
(5:304) take variable %emit_sub_health and subtract 1 from it.
(5:601) memorize that the PhoenixSpeak info {%temp1 h} about the player named {N} will now be %emit_sub_health.
(5:200) emit message {My ID is %temp1} to the triggering player.
(5:200) emit message {My HP was %emit_health, but its now %emit_sub_health} to the triggering player.
(5:200) emit message {I have %emit_ap action points.} to the triggering player.
(5:200) emit message {My class number is %emit_class} to the triggering player.
(5:200) emit message {My defense is %emit_defense} to the triggering player.
(5:200) emit message {I am on turn %emit_turn} to the triggering player.
Comments
Post a Comment