[FIXED] Creatures can be summoned inside walls

Here we stuff all the bugs we've managed to squash/squish/squelch.
Post Reply
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Creatures can be summoned inside walls

Post by Xuri »

If standing on the west side of a wall, summoning a creature/elemental/daemon will make that summoned creature appear inside the wall east of the character, allowing it to walk out of the wall on the other side.

Basically a bug that allows people to attack other people through walls by summoning a creature and sending it through to the other side :P

Image
UOX3 needs to check the spawn location if it's a valid location for NPCs to move on, and pick a new one on a different side on the character if not.
Last edited by Xuri on Sun Jan 18, 2009 7:25 pm, edited 2 times in total.
-= Ho Eyo He Hum =-
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Don't have a working UO client install, but try this:

To magic.cpp, add this near the top (before the spells)

Code: Select all

bool blockingSurround( SI16 srcX, SI16 srcY, SI08 srcZ, UI08 worldNumber, SI08 radius, SI16 &outX, SI16 &outY )
{
	for( int x = -radius; x <= radius; ++x )
	{
		for( int y = -radius; y <radius>ValidSpawnLocation( srcX + x, srcY + y, srcZ, worldNumber );
			if( foundSpot )
			{
				outX = srcX + x;
				outY = srcY + y;
				return true;
			}
		}
	}
	return false;
}
Now you'll want to change splSummonAir, splSummonDaemon, splSummonEarth, splSummonFire, splSummonWater and splRandom to this (note, you're only changing a couple of lines):

After the GetSkill check, add this:

Code: Select all

	SI16 outX = -1, outY = -1;
	bool foundSpot = blockingSurround( caster->GetX(), caster->GetY(), caster->GetZ(), caster->WorldNumber(), 1, outX, outY );
We want to change the SummonMonster call to a if checked one, so it should now look like:

Code: Select all

	if( foundSpot )
		Magic->SummonMonster( sock, caster, 2, outX, outY, caster->GetZ() );
	else if( sock != NULL )
		sock->sysmessage( "You cannot summon a creature here" );
	return true;
Replacing the *2* in the SummonMonster() call with whatever is currently there.

If you want to do that, you'll need to pass in the direction to blockingSurround, and fiddle that piece of logic.

It looks like it should work (it'll only put a creature there if it can validly spawn there ... hmmm, late note, WON'T work for over water). And would be somewhat better than what is already there (blind assumption of caster's location + 1,1).

Edit: OK, that's a tad bizarre, the code didn't cut and paste properly. Should be updated now.

Edit 2: Still no joy ... something's screwing it up, because the form's accepting it properly, just displaying it incorrectly.
Last edited by Maarc on Sun Jul 09, 2006 11:14 am, edited 2 times in total.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Alternatively you can do a ValidSpawnLocation() on the target XY in SummonMonster() and just have it summon on the character if no or invalid target.

Not sure how OSI handled summoning (if it was infront of the caster or on the caster).
Scott
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Just tested the Summon Creature spell on the official shards, and at least in the current implementation they seem to be summoned to a random valid tile immediately next to the caster.
-= Ho Eyo He Hum =-
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Ok then, sounds like Maarcs code would be the best solution.

Note that we will still want to add the ValidSpawnLocation() check for the targeted summons (EV and BS, namely). As there is a chance the client would allow them to target an area that they shouldn't be able to summon a creature on.
Scott
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

After summoning about 40 elementals in the same spot as in my original post in this thread, and not having any of the elementals spawn in the wall - this seems to be fixed.
-= Ho Eyo He Hum =-
dracuskaos
UOX3 Neophyte
Posts: 35
Joined: Sat Oct 25, 2008 3:54 am
Has thanked: 0
Been thanked: 0

Post by dracuskaos »

hypothetically speaking aren't the floor tiles supposed to actually represent 4 feet? If it doesn't break the server why not just remove the plus one and spawn the critter on the same tile as the player?

Or is this were I get a foam brick thrown at me?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Nah, that's one solution - though this bug seems to have been fixed already. Unless you've ran into it yourself?
-= Ho Eyo He Hum =-
Post Reply