Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  Lua Method: object:Kill()  (Read 1614 times)

0 Members and 0 Guests are viewing this topic.

smacky

« on: 25, June 2009, 02:30:53 »
object:Kill() already existed, but had a number of problems.

These are fixed and the best news is it can now be used to kill players! So prepare for much bloodshed!

But on that point, note that Kill() does exactly that and no more -- it does not attack the object or cause it damage. It simply makes it dead.

When a player is killed, he will die properly, losing stats and exp and going back to his savebed. Optionally you can name the killer, like this:
Code: [Select]
player:Kill(killer)

killer can be a string or a GameObject. If a GameObject, its name will be extracted.

ATM killer is (I think only) used to write the cause of death on the gravestone. If you don't specify a killer, "bad luck" is the default.

When a monster is killed, he will drop a corpse and give exp according to the usual rules.

Unfortunately the 'usual rules' are a bit inflexible for this sort of thing so whether and to whom exp is given depends on any non-scripted combat, as does any bounty dropped.

If he has no aggro history (ie, no-one has hit him), he'll drop an empty corpse belonging to no-one and no-one will get any exp.

You can specify a killer for mobs but (currently) this does nothing.

Previously the two main arguments were reversed on Kill() for some reason. So it was killer:Kill(victim). I guess that makes some sense like that, but the problems are (a) this order is unlike every other core method (eg, victim:Remove() and victim:Destruct()) and (b) as killer is optional and victim mandatory, the old order makes no sense.

There also used to be a third required arg, an integer cryptically known as how. This was completely unused. It did nothing so is removed.

grommit

« Reply #1 on: 16, July 2009, 15:52:58 »
Lippy is moaning the change to parameter order apparently broke one of his scripts - you usually post to unofficial forums where you find a possible conflict (e.g. lights, pedestals), but apparently not in this case.

smacky

« Reply #2 on: 16, July 2009, 16:27:54 »
No, in this case I simply fixed the script for him:
Quote from: Mapserv r1265
Log:
Correct calls to obj:Kill().


Modified:
   trunk/maps-B5/planes/demon_plane/palace_damned/potd_armoured_demon.lua
   trunk/maps-B5/unofficial/cleopatra/PetMoving.lua
   trunk/maps-B5/unofficial/cleopatra/petshop_test/PetMoving.lua
Modified: trunk/maps-B5/planes/demon_plane/palace_damned/potd_armoured_demon.lua
===================================================================
--- trunk/maps-B5/planes/demon_plane/palace_damned/potd_armoured_demon.lua   2009-06-21 19:33:41 UTC (rev 1264)
+++ trunk/maps-B5/planes/demon_plane/palace_damned/potd_armoured_demon.lua   2009-06-24 23:58:07 UTC (rev 1265)
@@ -54,7 +54,7 @@
     if killer_obj ~= nil then
         me:Say(me.name.." "..killer_obj.message, 1)
         -- Kill the mob
-        ac:Kill(me, 0)
+        me:Kill(ac)
     end
 end

So does this not work (it should)? Or has he used an old revision of the script for the remodelling for some reason? And why is he not posting? ;)

Lippy

« Reply #3 on: 16, July 2009, 16:55:20 »
Hmm, I used the beta 6 version, since I'm aiming to unify the beta 5 and beta 6 branches of the Shattered Planes (formerly the Demon Plane) once the remodelling is finished. All that needs to be different for the beta 6 version is the addition of the portal to the new Demon Plane (they are new maps so /unofficial is probably a better place for them until they are ready), and for the portal to the Shattered Planes to point to shattered_planes instead of demon_plane. This is because no parallel work is happening on the beta 6 branch and won't be until beta 5 is released. I figured I could use the renamed Shattered Planes since it will need to be done eventually, and it shouldn't cause any problems if it's renamed for beta 5 instead of beta 6.

Anyway, I figured out the problem fairly quickly, as the server told me what was up when it didn't work. I at first assumed the second parameter was no longer needed, resulting in my untimely death. I got it right second time round, so no worries. :P
Current Project: Dynamic Widget Client (M1)

grommit

« Reply #4 on: 16, July 2009, 21:24:30 »
I think that's hilarious, actually. I think we should randomise the code so that sometimes it kills the mob and sometimes the player :D

Tags:
 

Related Topics

  Subject / Started by Replies Last post
11 Replies
3942 Views
Last post 19, December 2008, 11:47:13
by smacky
0 Replies
1055 Views
Last post 20, December 2008, 16:58:09
by smacky
5 Replies
1481 Views
Last post 10, April 2009, 21:36:07
by grommit
11 Replies
2433 Views
Last post 30, June 2009, 13:44:00
by smacky
0 Replies
11189 Views
Last post 30, September 2013, 18:43:54
by smacky