Aegis Support Board: Healing Area NPC - Aegis Support Board

Jump to content

ASB News! ASB 5.0 Beta V2 has now been released!. See here for more Info.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Healing Area NPC (help needed)

#1 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 10 November 2006 - 02:39 PM

Im trying to make an alternative for a healing npc, in the form of a hidden warp (under a fountain) that will heal players over time. I've been able to get it somewhat working, but its nowhere near functional yet. I know its still a regular portal, easier testing that way.
What it does atm is it does heal me, it fills the hp/sp bar at a speed when I aproach. However both values seem to hit a max somehow. As soon as I get below that hp/sp it heals be back to it again.

I tested with a character with 3936 HP and 253 SP. I get healed to 3837 HP and 154 SP max. When I increase vit or sp the ammount healed increases together with the max HP/SP.

Eventually Id like the script to heal a bit more slowly then it does now, but Id like to get it working first. Also seeing its in a constant loop would it create much load? Oh and I tried with just hpheal and spheal without the if, it didnt help.


Quote

warp "prontera" "healing" 25 160 5 5
OnTouch:
while(1)
if v[VAR_HP] < v[VAR_MAXHP]
hpheal 1
endif
if v[VAR_SP] < v[VAR_MAXSP]
spheal 1
endif
endwhile
return

This post has been edited by .chronoz.: 10 November 2006 - 02:44 PM

0

#2 User is offline   980542 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 106
  • Joined: 21-December 05

Posted 10 November 2006 - 08:43 PM

Didnt test but maybe this works...
I didnt check the case sensitive of the commands i added, you must check it before trying to load.

Also, my experience with OnTouch is that it only works for the first guy to activate it and keeps working with him untill he leaves the area, wich means that this way of yours probably just heal 1 person at time.

But as I said, I didnt test it. Anyway, great idea of yours ;)


warp "prontera" "healing" 25 160 5 5
OnInit:
strlocalvar 0 "heal_pause"
SetLocalVar "heal_pause" 1
return

OnTouch:
while(1)
if ((v[VAR_HP] < v[VAR_MAXHP]) & (lv["heal_pause"] == 1))
hpheal 1
endif
if ((v[VAR_SP] < v[VAR_MAXSP]) & (lv["heal_pause"] == 1))
spheal 1
endif
setlocalvar "heal_pause" 0
cmdothernpc "healing timer" "on"
endwhile
return

OnCommand: "heal"
setlocalvar "heal_pause" 1
return


npc "prontera" "healing timer" HIDDEN_NPC 1 1 1 1 1

OnCommand: "on"
InitTimer
return

OnTimer: 1000
cmdothernpc "healing" "heal"
return

This post has been edited by 980542: 10 November 2006 - 10:36 PM

0

#3 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 10 November 2006 - 10:30 PM

Once I change setlocalvar to SetLocalVar the script will run, but as soon as I step on the thing the zone will give me an error the localvar doesnt exist :S
0

#4 User is offline   980542 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 106
  • Joined: 21-December 05

Posted 10 November 2006 - 10:35 PM

Sorry man, local vars *have* to be declared inside OnInit:


Should work now that i re-edited. check case sensitivity again if you want to copy this.
0

#5 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 10 November 2006 - 11:48 PM

AFAIK non-warping warp-type NPCs only work for the first characted that stepped on them (this also applies to OnTouch: trigger of visible NPCS). If you want the healing to be done for everybody, you need to heal them and move them aside to make room for others. Or you can make a number of 1x1 "healing warps" so that each character gets its own.
Once we had some warps that didn't warp Novices for some reason. A single Novice stepping on that warp closed the warp for everybody until he left the area.

Aaaand I would go along these lines:

npc "prontera" "heal_timer" HIDDEN_NPC 1 1 0 0 0
OnInit:
InitTimer
return

OnCommand: "restart"
InitTimer
return

OnTimer: 1000
cmdothernpc "heal_place1" "heal"
...
... put as many "heal places" as you want here
...
cmdothernpc "heal_timer" "restart"
stoptimer
return


warp "prontera" "heal_place1" x y 0 0
OnInit:
disablenpc "heal_place1"
return

OnCommand: "heal"
enablenpc "heal_place1"
cmdothernpc "heal_place1" "stop"
return

OnCommand: "stop"
disablenpc "heal_place1"
return

OnTouch:
hpheal 1
spheal 1
return

This post has been edited by Kasuha: 11 November 2006 - 12:01 AM

0

#6 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 10 November 2006 - 11:51 PM

What about a hidden NPC type, instead of warp? And I tried the script, it will only work if I keep moving outside and inside the area, but it still doesnt want to go to the max hp, seems like it has to do with the hpheal 1 thing..
0

#7 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 11 November 2006 - 12:08 AM

I haven't tested the script, sorry if it doesn't work.
I used warp type because it seems to be the only way to allow characters to step directly on it. Both hiddenwarp and HIDDEN_NPC protect its central points like there's something standing on it.
If it doesn't work, then adding 'moveto "prontera" v[VAR_CURRX] v[VAR_CURRY]' statement after the healing might help to refresh the state of the warp, but it will also produce some strange and perhaps undesirable effects.

This post has been edited by Kasuha: 11 November 2006 - 12:10 AM

0

#8 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 11 November 2006 - 12:17 AM

I just tried the script you posted, it shows me a constantly hidding/unhiding portal, it doesnt heal me when Im standing on it tho.. I probably would need to step onto it on just the right time or something
0

#9 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 11 November 2006 - 12:21 AM

If you need to reach maximum HP/SP in steps by 1 per cent, I think you need to use something like this:

uh, nevermind... sorry

View Post.chronoz., on Nov 11 2006, 08:17 AM, said:

I just tried the script you posted, it shows me a constantly hidding/unhiding portal, it doesnt heal me when Im standing on it tho.. I probably would need to step onto it on just the right time or something

It's just one tile, did you stand on the center?

This post has been edited by Kasuha: 11 November 2006 - 12:24 AM

0

#10 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 11 November 2006 - 12:22 AM

Aye, I did. Seems like the ontouch is hard to pull when its disabled/enabled I think
0

#11 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 11 November 2006 - 12:25 AM

View Post.chronoz., on Nov 11 2006, 08:22 AM, said:

Aye, I did. Seems like the ontouch is hard to pull when its disabled/enabled I think

It works nicely when enabled, the problem might be that it refuses to be triggered again by the same character if it didn't move. Well, duh.

Um, what about casting a level 1 Sanctuary?

This post has been edited by Kasuha: 11 November 2006 - 12:27 AM

0

#12 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 11 November 2006 - 01:42 AM

Quote

warp "prontera" "heal_place1" 150 150 0 0

OnInit:
InitTimer
strlocalvar 0 "heal_pause"
return

OnCommand: "restart"
InitTimer
return

OnTimer: 1000
SetLocalVar "heal_pause" 1
return

OnTimer: 1005
SetLocalVar "heal_pause" 0
stoptimer
cmdothernpc "heal_place1" "restart"
return

OnTouch:
while(1)
if (lv["heal_pause"] == 1)
hpheal 5
spheal 5
endif
endwhile
return


Well, this did the trick for the timer part. I just let it regen after 1 second, and close it 0.05 seconds after, to open after another second. However this wasnt really my questions in the end, altough this is pretty close to what I had in mind.

The problem is, hpheal seems to heal the 5% of the missing hp. Meaning it starts real fast and then slows down. Also it does never reach 100%. If this is true, itd make a lot of sense. Then the next questions would be, is there a way to let it just heal 5% of the max hp? Maybe something like read max hp, and divide it and heal that solid number of hp? That would at least make it a bit more steady, ofcourse Ill reduce delay etc some too, like 1% each second sounds nice.

Oh and thanks for the example NPCs, I wouldnt have been able to make my single-npc version with it.

This post has been edited by .chronoz.: 11 November 2006 - 01:44 AM

0

#13 User is offline   980542 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 106
  • Joined: 21-December 05

Posted 11 November 2006 - 02:09 AM

First, there should be some vars you can try and find what one is more suitable:

VAR_MAXHP
VAR_MAXHPAMOUNT
VAR_MAXHPPERCENT

i believe the last one is the best... but try all.. so im gonna use it:
If you are right about the hpheal working by lack of hp percentage... i believe this will be a good option, maybe not the best.



replace this:

Quote

OnTouch:
while(1)
if (lv["heal_pause"] == 1)
hpheal 5
spheal 5
endif
endwhile
return



by this

Quote

OnTouch:
while(1)
if ((lv["heal_pause"] == 1) & (v[VAR_MAXHPPERCENT] < 25))
hpheal 5
spheal 5

elseif ((lv["heal_pause"] == 1) & (v[VAR_MAXHPPERCENT] > 75) & (v[VAR_MAXHPPERCENT] < 95))
hpheal 95
spheal 95

elseif ((lv["heal_pause"] == 1) & (v[VAR_MAXHPPERCENT] >= 95))
hpheal 100
spheal 100


else
hpheal 50
spheal 50
endif

endwhile
return


In the end, you may recheck the amount of hp and sp got for a suitable amount....

This post has been edited by 980542: 11 November 2006 - 02:13 AM

0

#14 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 11 November 2006 - 11:45 AM

Well, I've confirmed it. The function hpheal uses the % of the missing hp, rather then the total. Some math should be able to solve it, so that itll always use 1% of the total hp.
Say we have a user of a max of 1000 HP, who has currently 350 HP.

First check for ammount to be healed:
maxhp / 100 = 10hp to be healed each time

Now check what ammount the hpheal will use to calculate:

maxhp - currenthp = 650 HP

Now we need to know how much % 10 hp is of 650:
(10/650)*100= 1,53

Time to heal rougly 1% of max hp
hpheal 1,53

Im gonna try script it, if I get it working Ill just finalize the thing so it can be 'released' for others to use.
0

#15 User is offline   .chronoz. 

  • The Wanderer
  • PipPipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-October 04

Posted 11 November 2006 - 04:56 PM

Bah, this reminds me how limited AEGIS scripts are. Its about impossible to calculate the % seeing you get numbers like 0.2 etc. When I display VAR_MAXHPPERCENT at a NPC it always gives me a 0 too?
0

#16 User is offline   980542 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 106
  • Joined: 21-December 05

Posted 11 November 2006 - 06:32 PM

As I told you, you need to test those vars, some of them (in enum.sc) doesnt really work as we would like.
Maybe its better to use another and transform it in percentage...

I found another type of npc: hiddenwarp

It is used on woe scripts, maybe you can use it to make the npc completely invisable.

here is an example of it
hiddenwarp "aldeg_cas03" "ban_warp#13" 225 269 8 8
0

#17 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 13 November 2006 - 06:38 AM

hiddenwarp blocks its central tile, unlike the warp NPC.

for the percent thing, this should do the trick:

var healpercent = 1 <-- here put the percentage of total HP you want to heal
var maxhp = v[VAR_MAXHP]
var hp = v[VAR_HP]
hpheal (maxhp * healpercent)/(maxhp - hp)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users