Random Tidbits: Spell Deflection + Dev Details

Information and updates for all other projects by Black Omen Productions (besides Shadow Empires): Namely Codename: MetalStorm, Anti-Balance, Ultimate Fixer and all versions of XyRAX

Moderators: Nefarius, Joel, Doombreed-x, Vendanna

0
No votes
 
Total votes: 0

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains

Hand-picked

Random Tidbits: Spell Deflection + Dev Details

Post by Nefarius » Fri Feb 13, 2009 8:30 am

One thing we wanted to implement already very early, actually still around v1.09 when we (me and Vendanna) wrote down the first concepts of this project spell deflection was one of those things way up that we thought couldn't be achieved, this ofc without the prospective of this amount of modified code being doable, time has shown it was, so today I've plastered together spell deflection ;) in just under 10 minutes.

So what is this, in vanilla D2 there is a spell, Chilling Armor that automatically retaliates with an ice bolt, but ofc this doesn't deflect anything, it's just a reaction to an event, so this itself was obviously not very useable for the task ahead (not to mention, the way this is handled client and server side is pretty incosistent and thus not reliable for much else then what they already do with it)

Earlier I've coded a way to add CTC effects to skills, this was also not the best thing for this, as it would mean storing the last missile id somewhere in pUnit, but keep in mind there are missiles that only exist client or server side = mess. So I needed something that isn't stored and just relies on information that should be the same (unless the games are desynced, but if this happens theres little that is reliable so ignore this fact).

Code: Select all

int __fastcall MISSILES_CheckDeflect(D2UnitStrc* pTarget, D2UnitStrc* pMissile, D2UnitStrc* pOwner)
{
	// checks the reflect stat, simple
	// ADDED 13th Feb, 2009 (by Nefarius)

	if ( pOwner == NULL || !CheckMissile(pMissile) || pTarget == NULL )
	{
		return 0;
	}

	MissExTxt* pMissEx = GetMissDataEx( pMissile->nIndex );
	ASSERT(pMissEx);

	if ( pMissEx->flags & MISSTXT_REFLECT )
	{
		int nChance = D2GetStat(pTarget, STAT_SKILL_DEFLECT_MISSILE);

		if ( nChance > 0 )
		{
			D2CoordStrc pos;
			GetCoords(pTarget, &pos);

			D2CoordStrc target;
			GetCoords(pOwner, &target);

			D2SeedStrc seed;
			seed.set( ((pos.x - target.y) * (pos.y - target.x)) * (pTarget->nId - pOwner->nId + 1) );

			if ( seed.chance( nChance ) )
			{
				// change the ownership of the missile
				// lets see if this works :P

				pMissile->fExpansion |= UNITFLAG_HASOWNER;
				pMissile->eOwnerType = pTarget->eType;
				pMissile->nOwnerId = pTarget->nId;
			
				D2PathStrc* hPath = pMissile->hPath;
				ASSERT(hPath);

				D2SetPathTarget( hPath, pOwner );
				D2SetPathStart( hPath, pMissile );

				return 1;
			}
		}
	}

	return 0;
}
This is called on client and server just after the pierce check, since pierce usually is synced this will be too ;) (and the positions + guids match client/server side, as done with a few other c/s sync effects, sure this is not really random, but its random enough, monsters usually move between shots etc, it's really the closest one can get w/o borking sync)

Here is the effect in action (animated) http://img14.imageshack.us/img14/1985/reflectahamb9.gif

You can see how unlike vanilla the overlay does not "reset" but stacks ;) --- part of what I softcoded a couple of days ago.

Ofc this is nothing like how we will be using the effect in the final version and just a test.

[spoiler]If you've played BG series there is a shield that can reflect beholder rays thats pretty crucial for that one beholder city quest --- think from that point, but ofc there will also be spell deflection spells[/spoiler]

What can and can't be reflected follows a similar logic as Hand of Athena in vanilla and can be specified for each missile.
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

User avatar
mmamono
Posts: 10
Joined: Wed Apr 07, 2004 5:38 pm

Re: Random Tidbits: Spell Deflection + Dev Details

Post by mmamono » Fri Feb 13, 2009 4:04 pm

Unbelievably awesome!

A very powerful version could make a fun shrine with a short duration :)

User avatar
weapon-x
Forum Legend
Arch-Angel
Posts: 1047
Joined: Wed Mar 18, 2009 4:52 am
Location: Mindanao, Philippines
Philippines

Re: Random Tidbits: Spell Deflection + Dev Details

Post by weapon-x » Mon Jan 03, 2011 6:28 pm

amazing...

pretty much like in d3 but way more ahead of it's time when these we're made

...

amazing !!
" It's not the size of the dog in the fight, it's the size of the fight in the dog. "

~Mark Twain

Return to “Mods by Nefarius”