Replies: 7 (Who?), Viewed: 274 times.
Lab Assistant
Original Poster
#1 Old 18th Nov 2020 at 7:23 PM
Default Killing the loser of the Spar
Okay, my present project is to add a Duel to Death interaction to my Swordfighting Mod. I got almost everything figured out... Besides how to actually kill the loser of the spar match. I think that the code that governs the end of the match is this:

private void PostMatchCeremony()
				int wins = 0;
				int losses = 0;
				Sim sim = null;
				Sim sim2 = null;
				MartialArts losersMartialArts = null;
				MartialArts winnersMartialArts = null;
					switch (mCurrentSparState)
						case MartialArts.SparState.ActorWinsMatch:
						case MartialArts.SparState.TargetCancelledMatch:
							sim = Actor;
							sim2 = Target;
							wins = mRoundsActorWon;
							losses = mCurrentRound - mRoundsActorWon;
							winnersMartialArts = mActorsMartialArtsSkill;
							losersMartialArts = mTargetsMartialArtsSkill;
						case MartialArts.SparState.TargetWinsMatch:
						case MartialArts.SparState.ActorCancelledMatch:
							sim = Target;
							sim2 = Actor;
							wins = mCurrentRound - mRoundsActorWon;
							losses = mRoundsActorWon;
							winnersMartialArts = mTargetsMartialArtsSkill;
							losersMartialArts = mActorsMartialArtsSkill;
					EventTracker.SendEvent(new MartialArts.SparEvent(sim, sim2, true, mSparMatchType == MartialArts.SparMatchType.Tournament));
					EventTracker.SendEvent(new MartialArts.SparEvent(sim2, sim, false, mSparMatchType == MartialArts.SparMatchType.Tournament));
					if (sim != null && sim2 != null)
						UpdateStatistics(losersMartialArts, winnersMartialArts);
						NotifyMatchResult(sim, sim2, wins, losses);

What should I add to kill the losing sim, after the match ends? Just to be clear, the ghost that I want to produce after the death is an starvation one.
Lab Assistant
#2 Old 19th Nov 2020 at 1:40 AM
I think what you want is "sim2.Kill(DeathType.Starve)" - I've been working on a mod that needs to kill sims sometimes too (sounds bad to write out), so I'd be interested to know how it goes for you!
#3 Old 21st Nov 2020 at 1:35 PM
Hey my mod also has a kill ability for Vampires. Check it out. It's the Attack Sim interaction. The animation in my mod was made by @Druyddark it syncs up perfectly with the dying animation. If your animation also syncs up it would look great.

If you like my mods. Consider supporting me on Patreon

Follow me on
#4 Old Yesterday at 4:01 PM
Does sim.Kill(DeathType.BlahBlah) actually trigger the Grim Reaper, or is it just an instant death?

(Gee, I'm working on a mod with a chance of death too. We sim-murderers should form a club. ;-) )

Echo Weaver's Simblr:
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy:
Lab Assistant
#5 Old Yesterday at 5:14 PM
It does! Sim.Kill is the highest-level death-related function I've found, so it checks whether the sim is allowed to die (that's the part I want to modify), handles a bunch of stuff that needs to be handled when a sim dies (like triggering reactions from other sims, ending scuba dives, checking the sim out of their hotel etc) and also creates an Urnstone.KillSim instance. And Urnstone.KillSim also does a bunch of extra death-handling stuff (sending events, triggering tutorials, triggering more reactions from other sims, so much stuff) and then creates a service request to summon the Grim Reaper. I hadn't realized the Grim Reaper was a service sim and the soul reaping was a service situation, but it is!
#6 Old Yesterday at 8:50 PM
LOL! I think I knew Grim was a service sim, but mostly because I've seen them when searching for service sims with MasterController .

It is SO AWESOME that triggering such a complex series of actions is that simple!

What constitutes a sim that is not allowed to die?

My mod is a stray cat mod intended for use with the Warrior Cats Challenge my kid is playing. It looks like an awesome challenge even if you aren't passionate about the books, but pets are so limited that half of the challenge mechanics involve cats doing things in the game that can be traded for a human sim to do something for them.

One of the first things I want to do is short-circuit the Social Worker such that cats can actually die of starvation, drown, etc. and add a way to die of wounds from fights.

I'm hoping that cats count as sims who can die arbitrarily. One can assign arbitrary ghost shaders to them using MasterController, so I hope that also can be coded smoothly. Being restricted to Good Pet and Bad Pet is lame.

Echo Weaver's Simblr:
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy:
Lab Assistant
#7 Old Today at 5:58 AM
Originally Posted by echoweaver
What constitutes a sim that is not allowed to die?

Oh man I dug so deep into this a couple weeks ago

Imaginary friends, "NPCAnimals" (I'm guessing that's deer and racoons and such, maybe also strays?), pregnant sims, some service sims, sims on the world lot (probably because the Grim Reaper service situation doesn't work if there's not a lot for it to happen on), and inactive sims not on the same lot as an active sim are all excluded by the CanBeKilled check that happens before the part of Kill that does any work can run.

So animals aren't all screened out there, but there's also another layer of protection for types of sims the game doesn't let die in Motive.MotiveDistress, which is the method that calls sim.Kill to make sims starve, drown, die of freezing, die of dehydration, or die of thirst. And also makes them pee themselves, but not pass out, weirdly enough? I don't know where energy distress gets handled. For pets, MotiveDistress just does nothing if the motive that's in distress is hunger; so it's possible to stop the social worker from taking them by setting the hunger(or social, or temperature) threshold that triggers the social worker to an impossible value, but MotiveDistress will still never be able to make them starve. And it looks like this means pets also can't die by drowning or freezing, since those deaths occur when the hunger bar is empty?

But! I think it's possible to get around the invulnerability by replacing some buffs and maybe using a custom version of the sim.Kill method. I've written a lot of the code I think I need for this and just not tried it yet since I'm missing animations, so I don't know if it'll actually work; I don't want to derail this thread, but it seems like the same strategy should work for what you're trying to do too if it works at all, though.
#8 Old Today at 6:54 AM
Woo. I am in awe of your geekery.

I'm assuming that I'll have to catch the pets before the social worker is called, and if I can push out the call to social worker until later that normal, all the better. Pets CAN die of old age, so I'd assume that Grim's Kill method could be called for them, but I'll run tests before going much further. The mod doesn't center around death, but the risk sure would make things more interesting.

To be clear, I'm not talking about a mod for inactive stray cats, which I think are service sims. I just mean playing an active household of cats as strays.

Do you have a thread where you're discussing your death-delving?

Echo Weaver's Simblr:
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy:
Back to top