Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
NPC Stat Display
by ZzFenix

This is a long, confusing script. To get it to work, you should make graphics for the numbers 0 through 9 and put NPCs 0 - 6 on the map to represent the digits of your HP (NPCs 0-3) and MP (NPCs 4-6). The script, when called, will change those NPCs' pictures to the pictures of the numbers that correspond to those digits.
Makes sense? Good.


include, plotscr.hsd

define script (500,start,none)
define script (autonumber,assign,none)
define script (autonumber,check,none)

global variable (50,hp)
global variable (51,ones)	#Placeholder for ones in HP
global variable (52,tens)	#Placeholder for tens in HP
global variable (53,huns)	#etc...
global variable (54,thos)
global variable (55,mp)
global variable (56,mpone)	#Placeholder for ones in MP
global variable (57,mpten)	#etc..
global variable (58,mphun)

#########################################################

script,start,begin
 set variable (hp,getherostat(0,hp,currentstat))	#Checks to see how much HP hero has
 set variable (mp,getherostat(0,mp,currentstat))	#Same, but with MP
 assign
 check
end

#########################################################
#Assigning Values for variables ones, tens, huns, thos
#########################################################

script,assign,begin
 if (hp >= 1000),then(
  set variable (thos,hp/1000)
)
 
 if (hp >= 100),then(
  if (hp >= 1000),then(
   set variable (huns,(hp--((hp/1000)*1000))/100)
)
 
  if (hp << 1000),then (
   set variable (huns,hp/100)
))
 
 if (hp >= 10),then(
  if (hp >= 100),then(
   if (hp >= 1000),then(
    set variable (tens,(hp--((thos*1000)+(huns*100)))/10)
)
  if (hp << 1000),then(
   set variable (tens,(hp--(huns*100))/10)
))
  if (hp << 100),then(
   set variable (tens,hp/10)
))

 if (hp >= 1),then(
  if (hp >= 10),then(
   if (hp >= 100),then(
    if (hp >= 1000),then(
     set variable (ones,hp--((thos*1000)+(huns*100)+(tens*10)))
)
    if (hp << 1000),then(
     set variable (ones,hp--((huns*100)+(tens*10)))
)))
    if (hp << 100),then(
     set variable (ones,hp--(tens*10))
)
  if (hp << 10),then(
   set variable (ones,hp))
)

#########################################################
#Same as above, but with MP
#########################################################

 if (mp >= 100),then(
   set variable (mphun,mp/100)
)

 if (mp >= 10),then(
  if (mp >= 100),then(
   set variable (mpten,(mp--(mphun*100))/10)
))
  if (mp << 100),then(
   set variable (mpten,mp/10)
)
 if (mp >=1),then(
  if (mp >= 10),then(
   if (mp >= 100),then(
    set variable (mpone,mp--((mphun*100)+(mpten*10)))
)))
 if (mp << 100),then(
  set variable (mpone,mp--(mpten*10))
)
 if (mp << 10),then(
  set variable (mpone,mp)
)
end

#########################################################
#	Making the numbers appear as NPCs
#	Walkabout 10 would be blank. Walkabout 0 would look
#	like 0, 1 would look like 1, etc..
#	If your number walkabouts have different id numbers,
#	then look at the number id for "0" then put + id after
#	the variables. For example, if walkabout 17 was 0,
#	then I'd put "alter npc (3,0,ones+17)", and the same
#	for the rest.
#########################################################

script,check,begin
 Alter NPC ( 3, 0, ones)	#HP ones, add "+id" here to make it fit your game
 Alter NPC ( 2, 0, tens)	#HP tens, ditto
 Alter NPC ( 1, 0, huns)	#HP hundreds, ditto
 Alter NPC ( 0, 0, thos)	#HP thousands, ditto
 if (hp << 1000), then
  (Alter NPC ( 0, 0, 10))	################################################
 if (hp << 100), then		#Note: NPC 0 is thousands for HP, 1 is hundreds,
  (Alter NPC ( 1, 0, 10))	#2 is tens, 3 is ones! NPC 4 is hundreds for MP,
 if (hp << 10), then		#etc. etc.
  (Alter NPC ( 2, 0, 10))	################################################
 if (hp << 1), then
  (Alter NPC ( 3, 0, 0))

 Alter NPC ( 6, 0, mpone)	#MP ones, add "+id" here to make it fit your game
 Alter NPC ( 5, 0, mpten)	#MP tens, ditto
 Alter NPC ( 4, 0, mphun)	#MP hundreds, ditto
 if (mp << 100), then
  (Alter NPC ( 4, 0, 0))
 if (mp << 10), then
  (Alter NPC ( 5, 0, 0))
 if (mp << 1), then
  (Alter NPC ( 6, 0, 10))
end


Site layout (c)2000 Jennifer Raby. Used by permission.