Some questions about inventory items (pickups)

Discussions about Coding and Scripting
nogardilaref
Masterful
Posts: 577
Joined: Tue Jun 20, 2017 1:00 pm
Personal rank: ⚋⚊⚌☰⚞⌖⚟☰⚌⚊⚋

Re: Some questions about inventory items (pickups)

Post by nogardilaref »

nullbyte wrote: You mentioned that if the client is asked to spawn a class it does not have, it might fall back to the parent class. Does this mean if I made my ShrinkVial extend a default class like HealthVial, it might spawn a visible HealthVial on the client?
Yes, that's what I meant, but I am not sure though, as I don't remember what exactly is the behavior of this engine on that.
It's either that, your it doesn't spawn at all leaving a null reference (None).

It's best if someone else is able to confirm that for you, or you can test it yourself through client logs to check what kind of reference you get in the end.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Some questions about inventory items (pickups)

Post by sektor2111 »

Eheh, I'm gonna point you (due to my love for A.I. as a base) to some actor which has 2 components from 2 different packages - so a default sample would be explanatory. Take a look at WayBeacon class - of course has no RemoteRole but that's a pity, else that thing is visible only by Owner but this can be changed as well...
User avatar
PrinceOfFunky
Godlike
Posts: 1200
Joined: Mon Aug 31, 2015 10:31 pm

Re: Some questions about inventory items (pickups)

Post by PrinceOfFunky »

There's a formula to calculate the exact collision sizes depending on the DrawScale of the mesh, I wrote it in the CommandSystem mutator:

Code: Select all

/*
 * Calculate the right collision cylinder sizes of an actor.
 * <Has side effects>
 */
static function calculateCollisions(Actor actor, int oldDrawScale, out float CollisionR, out float CollisionH)
{
	local float collisionRPerNewDrawScale;
	local float collisionHPerNewDrawScale;
	local float collisionRPerOldDrawScale;
	local float collisionHPerOldDrawScale;
	local float collisionRPerDrawScaleLeftover;
	local float collisionHPerDrawScaleLeftover;
		
	collisionRPerNewDrawScale = (actor.DrawScale * 100) / actor.CollisionRadius;
	collisionRPerOldDrawScale = (oldDrawScale * 100) / actor.CollisionRadius;
	collisionRPerDrawScaleLeftover = collisionRPerOldDrawScale / collisionRPerNewDrawScale;
	
	collisionHPerNewDrawScale = (actor.DrawScale * 100) / actor.CollisionHeight;
	collisionHPerOldDrawScale = (oldDrawScale * 100) / actor.CollisionHeight;
	collisionHPerDrawScaleLeftover = collisionHPerOldDrawScale / collisionHPerNewDrawScale;
	
	CollisionR = actor.CollisionRadius / collisionRPerDrawScaleLeftover;
	CollisionH = actor.CollisionHeight / collisionHPerDrawScaleLeftover;
}

Code: Select all

/*
 * Resize the actor DrawScale basing on the given Percentage and call 'calculateCollisions()' from within 'CommandSystem' to calculate its
 * new collision sizes.
 */
static function Resize( Actor actor, int Percentage )
{
	local float TotalScore, ObtainedScore;
	local float OldDrawScale;
	local float NewCollisionRadius, NewCollisionHeight;
	
	TotalScore = 1.0;
	ObtainedScore = (Percentage * TotalScore) / 100;
	
	OldDrawScale = actor.DrawScale;
	actor.DrawScale = ObtainedScore;
	
	class'CommandSystem'.static.calculateCollisions(actor, OldDrawScale, NewCollisionRadius, NewCollisionHeight);
	actor.setCollisionSize(NewCollisionRadius, NewCollisionHeight);
}
Feel free to use them if you want .o.
"Your stuff is known to be buggy and unfinished/not properly tested"
nullbyte
Novice
Posts: 27
Joined: Sat Sep 03, 2016 3:40 am

Re: Some questions about inventory items (pickups)

Post by nullbyte »

Brilliant, thank you.

Any ideas about how to scale the player's hand-held weapon (in third-person view) when the player's drawscale changes?
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Some questions about inventory items (pickups)

Post by sektor2111 »

Ahah, you think that resizing and collision were the only problems... Keep going, I'm listening.
Stepheight, baseeyeheight, eyeheight, Jump.Z, crouching collision, running speed. Tiny player is probably different in my logic. Excuse topic title, this is about Player already... Not gonna ask about Bot... and I wanna see double enforcer held...
nullbyte
Novice
Posts: 27
Joined: Sat Sep 03, 2016 3:40 am

Re: Some questions about inventory items (pickups)

Post by nullbyte »

sektor2111 wrote:Stepheight, baseeyeheight, eyeheight, Jump.Z, crouching collision, running speed.
:cry:
User avatar
SilverSound
Adept
Posts: 341
Joined: Fri Nov 06, 2015 10:12 am
Personal rank: Curious
Location: St. Cloud, Florida

Re: Some questions about inventory items (pickups)

Post by SilverSound »

Oh boy. Good luck you. "Spaghetti code Epic Mega games" has things set up weird as you will find out by this small simple endeavor.

But hey if you push through you might find a better way through it all.


Just know bots are not players and will be more nightmarish to effect with this than you can even begin to think. :ironic:



On a note for this topic:This information is amazing. Definitely note worthy.
"Woah what?! I wish I was recording that...."
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Some questions about inventory items (pickups)

Post by Barbie »

@PrinceOfFunky: by doing some simple maths you can reduce your (for me confusing) formula of your function calculateCollisions()

Code: Select all

collisionRPerNewDrawScale = (actor.DrawScale * 100) / actor.CollisionRadius;
collisionRPerOldDrawScale = (oldDrawScale * 100) / actor.CollisionRadius;
collisionRPerDrawScaleLeftover = collisionRPerOldDrawScale / collisionRPerNewDrawScale;

collisionHPerNewDrawScale = (actor.DrawScale * 100) / actor.CollisionHeight;
collisionHPerOldDrawScale = (oldDrawScale * 100) / actor.CollisionHeight;
collisionHPerDrawScaleLeftover = collisionHPerOldDrawScale / collisionHPerNewDrawScale;

CollisionR = actor.CollisionRadius / collisionRPerDrawScaleLeftover;
CollisionH = actor.CollisionHeight / collisionHPerDrawScaleLeftover;
to

Code: Select all

DrawScaleRatio = actor.DrawScale / oldDrawScale;
CollisionR = actor.CollisionRadius * DrawScaleRatio;
CollisionH = actor.CollisionHeight * DrawScaleRatio;
(PS: Your comment

Code: Select all

* <Has side effects>
is not true because that function has no side effects: it does not change anything besides the given two arguments which are expected to be changeable.)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
EvilGrins
Godlike
Posts: 9668
Joined: Thu Jun 30, 2011 8:12 pm
Personal rank: God of Fudge
Location: Palo Alto, CA
Contact:

Re: Some questions about inventory items (pickups)

Post by EvilGrins »

This may or may not help, as I don't remember how he did it.

From this · viewtopic.php?f=5&t=5031

As with any Alice In Wonderland scenario, there's things you can eat or drink that make you shrink or grow.

Haven't played the map in a REALLY long time, and even then I didn't open it up in UnrealEd, but there's a part of the map where you shrink.

Not sure if you actually shrink or get ported to a part of the map that's in giant-scale.
http://unreal-games.livejournal.com/
Image
medor wrote:Replace Skaarj with EvilGrins :mrgreen:
Smilies · viewtopic.php?f=8&t=13758
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Some questions about inventory items (pickups)

Post by papercoffee »

EvilGrins wrote:This may or may not help, as I don't remember how he did it.

From this · viewtopic.php?f=5&t=5031

As with any Alice In Wonderland scenario, there's things you can eat or drink that make you shrink or grow.

Haven't played the map in a REALLY long time, and even then I didn't open it up in UnrealEd, but there's a part of the map where you shrink.

Not sure if you actually shrink or get ported to a part of the map that's in giant-scale.
Nope ...if you get shrunk, you just teleport into another map section which is a replica of the former room but just much bigger.
So, I'm sorry to say that, but this isn't helping OP.
Post Reply