Heal Party

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
LordGarth
Apprentice
Posts: 41
Joined: Thu Jan 27, 2011 6:21 pm

Heal Party

Post by LordGarth »

Is there a heal party method that can be put onto a staff and just a spell.

Thx,

LordGarth
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Heal Party

Post by Sophia »

Not included, but it shouldn't be a whole lot of trouble to create what you want using method_heal as a reference.
LordGarth
Apprentice
Posts: 41
Joined: Thu Jan 27, 2011 6:21 pm

Re: Heal Party

Post by LordGarth »

I was looking at that method but I dont know exactly what must be changed or added.

LordGarth
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Heal Party

Post by Sophia »

It depends on how you want the party healing to work.

If you just want to heal all the party members instead of just one, it's probably enough to add another loop and iterate over all four party positions.
Right now, the healing loop is repeated 30 times. Where the new loop goes and how you break out of it etc. depends on whether you want there to be 30 "healing steps" for each party member, or if the 30 steps should be divided among all of them, or whatever.
LordGarth
Apprentice
Posts: 41
Joined: Thu Jan 27, 2011 6:21 pm

Re: Heal Party

Post by LordGarth »

I guess whatever it does now for each party member
LordGarth
Apprentice
Posts: 41
Joined: Thu Jan 27, 2011 6:21 pm

Re: Heal Party

Post by LordGarth »

Another thing

Do you have any idea why DSB would not like some sound files. The code is correct but it does not like the file for some reason. So I delete the file, keep the same code, download the new file and call it the same thing and it works.

I have a sound file called howling1 and it would not play it and then I download a new howl sound. Named it howling1 and DSB played it.

?

LordGarth
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Heal Party

Post by Gambit37 »

Lord Garth, don't ask unrelated questions in the same thread. You already started a thread about music and sounds, please use that one to continue asking questions about sounds.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Heal Party

Post by Sophia »

Well, to be fair, that one got kind of derailed with a discussion about modifying DSB's base code and distributing said modifications.
But anyway, it doesn't like some files because FMOD (the sound library DSB uses) can't load them. They're usually weirdly formatted or something-- it chokes on some OGG files, too. Sorry but there isn't really anything I can do.
Mon Ful Ir
Adept
Posts: 221
Joined: Sat Jan 07, 2006 1:54 am
Location: Britain

Re: Heal Party

Post by Mon Ful Ir »

I haven't tested this, just written it out in the text window. Would this work?

Code: Select all

function method_heal_party
     for foo = 1 to 4
     method_heal(name, foo, who, what)	
     next foo
return
end
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Heal Party

Post by Sophia »

No, it won't.
Party positions go from 0 to 3, and you'd need to make sure that who was properly generated based on the ppos.

However, it has a larger conceptual problem. method_heal burns mana from its invoker and heals its invoker. So, this function would burn mana from all four party members to heal all four party members. On the upside, it will give experience to everyone. In other words, method_heal is doing a lot more than just healing, so it's not quite so simple.
Mon Ful Ir
Adept
Posts: 221
Joined: Sat Jan 07, 2006 1:54 am
Location: Britain

Re: Heal Party

Post by Mon Ful Ir »

Yup: that's a substantial conceptual problem. :)

I suppose I'd have to try copy/pasting method_heal and tweaking it. The original function used who, but if I change some of those to foo, then I get:-

Code: Select all

function method_heal_party(name, ppos, who, what)	
	local m = lookup_method_info(name, what)
	if (not m) then return end
	
	att_idle(ppos, m.idleness)
	burn_stamina(who, m.stamina_used)

for foo = 0 to 3
	local hp = dsb_get_bar(foo, HEALTH)
	local needed_hp = dsb_get_maxbar(foo, HEALTH) - hp
	if (needed_hp > 0) then
		local mana = dsb_get_bar(who, MANA)
		if (mana > 0) then
			local healinc = (determine_xp_level(who, m.xp_class, m.xp_sub) + 1) * 10
			if (healinc > 100) then healinc = 100 end
			for i=0,29 do
				hp = hp + healinc
				needed_hp = needed_hp - healinc
				mana = mana - m.mana_used
				if (needed_hp < healinc) then healinc = needed_hp end
				xp_up(who, m.xp_class, m.xp_sub, m.xp_get)
				if (mana <= 0 or needed_hp <= 0) then break end 
			end			
			if (mana < 0) then dsb_set_bar(who, MANA, 0)
			else dsb_set_bar(who, MANA, mana) end			
			dsb_set_bar(foo, HEALTH, hp)
		else
			return
		end
	else
		return
	end
next foo
		
	if (m.charge) then 
		use_charge(what, m.charge)
	end
end	
Again, it's untested code, I'm just wondering if I'm going about it right.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Heal Party

Post by Sophia »

That's pretty close to what I'd do.

I should point out that you're iterating over party positions, but you have to convert that to actual character id numbers.
Some code like this will suffice:

Code: Select all

for fppos=0,3 do
   local foo = dsb_ppos_char(fppos)
   if (valid_and_alive(foo)) then
      -- code goes here
The only thing wrong there is that it heals party members in sequence, so if the healer runs out of mana after healing the first two, the second two get no healing at all. It might work better to move the loop over party positions 0 to 3 inside of the 0 to 29 loop. That would require more restructuring, of course-- which is the main reason I haven't bothered to write out the function. ;)
(Not that it's terribly hard, I'm just lazy)
User avatar
ian_scho
High Lord
Posts: 2806
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

Re: Heal Party

Post by ian_scho »

I got this coders joke! :o *

Code: Select all

dsb_set_bar(foo, HEALTH, hp)
Post Reply