A random sentence for a random mind.

UScript: Chat, Questions, Discussion

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 22 Mar 2012, 23:19

Nelsona wrote:Switched here at Waffnuffly suggestion from EXU thread related to coding-modding.

I saw other technology to enhance monsters in EXU2 more exactly nightmare mutator meant to bring some difficulty (I guess :D). Another default ideea for games with monsters like MH has a function to increase pawn's power and other things (called SetPawnDifficulty right in controller and called later in BaseMutator in AlwaysKeep targeting 2 things: presence of certain monsters missing and keep the power of monsters). Except speed, hearing, combat style, I didn't saw anywhere something like Monster.Skill called. Anyway this kind of code I think is stressfull for game since AlwaysKeep is powerfull and is checking even 500 monsters at once as I can notice from codes. I want to do another kind of MH breaking all default codes, I want to deliver a better speed, even giving up using that so called Lives configuration because is useless (in my opinion). You had a different way to deal with monsters (you called a SpawnNotify subclass). Is faster or better ? I want to try that style. That original MH function was also defined to check that so called skilled monster versus non-skilled using a shadow non-replicated, existing only in server or local games, LOL. Your function for boosting monsters have another kind of functionality. How is acting ? I just want to test it removing that original high loaded and using yours ideea. Of course I have other questions related to shadow decal, can slow down worse the server or not ? Maybe you can suggest some tricks that need to be tested.


SpawnNotify is a thing that UT has which lets you modify any actor as it is generated rather than once at the start of the map, which is handy. It only does it once per spawn of an item I believe. You can certainly use it on pawns. There might be a better way, though.

The shadow decals are generated by Oldskool (I'm assuming you're working within Oldskool here) and caused us all kinds of headache in EXU2, so we disabled them entirely for performance reasons. You might want to do the same if you're concerned about it. For some reason, olpawnshadow was generating asstons of Accessed Nones in tick() in server.log! Crazy stuff, and naturally not something you want filling up your server log.
Image

Nelsona
Skaarj Scout Skaarj Scout
Posts: 12
Joined: 22 May 2011, 14:23

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 23 Mar 2012, 17:59

Thanks for informations related to SpawnNotify. Now I need to ask AFCore for some improvements at Shadow decal - called in client, not server. Shrimp defined a decal based on tick but default PlayerShadow is based on timer not tick. Anyway some ecoop codes are done with more explanations fixing a lot of accessed nones...

Thanks again. I admit, for the moment I'm OFF-LINE but I want to be ready when I'll be back ON-LINE with other stuff. I finished my deal with Skaarj and weaponry, but I want to deal with any monster weapon-holder as well and this I want to be faster than timer (I attacked them in timer - maybe is not the best ideea) but worked.

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 13 Apr 2012, 20:22

General quick question: what is the optimal order for the following checks?

Code: Select all

class CanisterCollisionProxy expands EXUProxyProjectiles;   // this arms a Shit Canister when it enters a waterzone

function ProcessTouch (Actor Other, vector HitLocation)
{
   if(bdeleteme || owner==none || owner.bdeleteme || !owner.isa('projectile') || !validtouch(other))
      return;

   projectile(owner).explode(location,vect(0,0,0));
   destroy();
}

function bool validtouch(actor other)
{
   if( other==none || other==instigator || other==owner || !other.isa('Pawn') )
      return false;

   if(!other.bprojtarget || pawn(other).getstatename()=='dying' || pawn(other).health<=0)
      return false;

   if( !fasttrace(location, Other.Location) )   // Splash damage can't hit the target; don't explode
      return false;

   if(level.game.bteamgame && pawn(other).playerreplicationinfo!=none && instigator.playerreplicationinfo!=none && pawn(other).playerreplicationinfo.team == instigator.playerreplicationinfo.team)
      return false;

   return true;
}



First: in ProcessTouch, will the initial if statement stop processing as soon as one of the statements is confirmed, or will it check all the other statements too? If it continues to check even after hitting one true condition, would splitting them onto their own lines with return statements be a good idea? I assume that the statement will return immediately when it hits something, though, right?

Secondly: in ValidTouch, what is the best order for checks there? Would it be faster to have fasttrace at the very top, or is it fine where it is? I imagine it might slow things down if it's constantly tracing to invalid actors every time. If fasttrace is the slowest check there, would it be better as the LAST check?
Image

User avatar TheIronKnuckle
Gilded Claw Gilded Claw
Posts: 1967
Joined: 12 Nov 2007, 07:21
Location: Riding my bicycle from the highest hill in Sydney to these forums

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 14 Apr 2012, 02:36

I would hope that uscript has short circuiting, like any other c derived language, in which case yes the boolean expression will not be fully evaluated. if bdeleteme is true, it will return true there and then, and the other conditions will be ignored. I'm too sleepy to even read your second query XD sorry.
ImageIgnorance is knowing anything
And only idiots know everything

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 14 Apr 2012, 05:34

Unrealscript is short circuited, so yes. Check the most efficient first, least efficient later. The only changes I would make is replace !other.isa('Pawn') -> !Other.bIsPawn {way faster}, remove the Pawn() cast on pawn(other).getstatename() since GetStateName is in object

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 14 Apr 2012, 06:57

Thanks guys, I'll go around and replace all instances of Other.IsA('Pawn') with Other.bIsPawn and remove the pawn casting from GetStateName calls! Good stuff to know. I'm sure these performance tweaks don't amount to much, but when you have EXU-levels of shit going on, who knows. Can't hut!
Image

User avatar TheIronKnuckle
Gilded Claw Gilded Claw
Posts: 1967
Joined: 12 Nov 2007, 07:21
Location: Riding my bicycle from the highest hill in Sydney to these forums

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Apr 2012, 03:45

actually, they might :S it looks like reflection is going down there. reflection is evil and performance heavy in every situation. I didn't know uscript had reflection.
ImageIgnorance is knowing anything
And only idiots know everything

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Apr 2012, 09:48

IsA just loads the UClass with the name you feed into it, and goes down the Super:: variables

it probably looks something like this in psuedo code

IsA(FName N)
{
UClass *C;
//stuff to get C = (Name -> UClass)
while(Super::StaticClass() != None)//or some other arbitrary "end" of class
{
if (C == StaticClass())
return true;
C = Super::StaticClass;
}
return false;
}
basically, it's a reverse linked list lookup which is static and probably isn't very slow depending on how far down the "tree" you're looking. Pawn from SkaarjSniper is twice as far as Pawn is from Brute, since SkaarjTrooper is Pawn->ScriptedPawn->Skaarj->SkaarjTrooper->SkaarjSniper, where brute is just Pawn->ScriptedPawn->Brute

Though I don't know if Pawn(Other) is faster than Other.IsA('Pawn') for comparison purposes. I have no idea what uscript does there.

User avatar Core
Skaarj Assassin Skaarj Assassin
Posts: 106
Joined: 15 Mar 2010, 17:16
Location: ../System/
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Apr 2012, 17:54

Yes, IsA() is a couple of native instructions more effecient then a dynamic cast.

Code: Select all

//
// See if this object belongs to the specified class.
//
inline UBOOL UObject::IsA( class UClass* SomeBase ) const
{
   guardSlow(UObject::IsA);
   for( UClass* TempClass=Class; TempClass; TempClass=(UClass*)TempClass->SuperField )
      if( TempClass==SomeBase )
         return 1;
   return SomeBase==NULL;
   unguardobjSlow;
}

Code: Select all

// Dynamically cast an object type-safely.
template< class T > T* Cast( UObject* Src )
{
   return Src && Src->IsA(T::StaticClass()) ? (T*)Src : NULL;
}

As you can read from the pub sources, a dynamic cast is basically an indirect call to IsA(), and checks first if the passed reference is valid.

Unlike with IsA(), a cast is also evaluated at compile time, which makes it more safe. For example if you mistyped the classname in IsA('someclassname'), the compiler won't give a damn, whereas with explicit casting, it will abort compilation.

However, the latter also adds dependancy on the package of the class that is being evaluated against, IsA() on the other hand is package independant, but requires a valid reference to be called from (or else cause accessed nones).

So both have there uses and can be prefered to one another if their advantage is deemed more crucial.

TheIronKnuckle wrote:I didn't know uscript had reflection

What makes you think UnrealScript has?

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Apr 2012, 20:11

Core wrote:
TheIronKnuckle wrote:I didn't know uscript had reflection

What makes you think UnrealScript has?

That's exactly why I posted the stuff about IsA. That's really the only possible "reflection" uscript has, and it's on a extremely tiny level. It's actually possible in C++ to give a little bit more reflection, but it still, by reflections definition, not fulfill any requirements to even consider it true reflection.

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Apr 2012, 21:16

Well this discussion went over my head in a hurry.

Basically what I'm gleaning is: use <something>.bIsPawn instead of <something>.IsA('Pawn') and things will work the same way but slightly faster. Right?

I did go through and replace all instances, which was about 30-40 total, so I guess yay? Nothing broke at least!
Image

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 16 Apr 2012, 01:54

Not slightly faster, but a lot faster. it's a single comparison versus a whole ton, see Core's post with UObject::IsA

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 01 May 2012, 00:04

OK, new query here:

Is there a function or event I can use to make a pawn immediately hate all other pawns on sight?

I have a Chryssalid-like monster (the Brussalid) which is designed to hate all pawns except for its own kind. It charges them, infects them with a proxy projectile that kills the infected after 15 seconds (no matter what) and spawns a new Brussalid in their place, etc. The thing is, Brussalids ONLY attack other ScriptedPawns if they bump into them first. Is there a way to make them attack automatically? They attack players and bots just fine, of course, but not other pawns.

I also have an issue with making them break off and attack a new pawn once they have successfully infected one. They will keep smacking whatever they just infected, which isn't very productive, instead of marking it "done" and going on to something else. How would I go about doing this? Do I need to pick apart the Attacking state?

Here's what I've got going on so far (works great as far as spawning more Brussalids and killing enemies goes, though):


[spoiler]

Code: Select all

//======================================================================================================
// KILL EVERYTHING
function eAttitude AttitudeToCreature(Pawn Other)
{
   if ( Other.IsA('Brussalid') )
      return ATTITUDE_Friendly;
   else
      return ATTITUDE_Hate;
}

//============================================================================================================
function WhipDamageTarget()
{
   local BrussalidInfection B;

   if( target!=none )
   {
      if( Target.bIsPawn && bCanInfect(Target) )
      {
         B = Target.Spawn(Class'BrussalidInfection', Target);
         if(B!=none)
            B.Instigator = self;
      }
      Target = none;
   }
   PlaySound(PistolWhip, SLOT_Interact,,,, 0.75);
}

//============================================================================================================
function bool bCanInfect(actor Other)
{
   local BrussalidInfection B;

   foreach Other.ChildActors( class'BrussalidInfection', B )
   {
      if(B!=None)
         return False;
   }

   return True;
}

[/spoiler]

Would love to get this working! They have the potential to be a real nightmare in MP games :)
Image

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 01 May 2012, 04:43

Never done this, but you can try

Code: Select all

function eAttitude AttitudeToCreature(Pawn Other)
{
   if ( Other.IsA('Brussalid') || !bCanInfect(Other))
      return ATTITUDE_Friendly;
   else
      return ATTITUDE_Hate;
}


and

Code: Select all

Target = None;
Enemy = None;
if(OldEnemy == Target)
OldEnemy = None;

on whip damage target

Might work, I've never heard of a pawn that changes "allegiance" on the fly though. cool idea

User avatar Buff Skeleton
>:E >:E
Posts: 4173
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 01 May 2012, 05:10

I'll give that a go, thanks!

Any ideas about automatically having ScriptedPawns hate each other? They WILL attack pawns if they bump into them, but the pawns they bump won't fight back. If I can get the Brussalids to attack on sight, then I can probably get all other pawns to return fire on sight as well. (This would have the added bonus of allowing me to properly implement the TeamHateTag system I wanted, allowing me to designate rival pawn gangs, like Demons vs. Saints, etc.)

[Edit] The !bCanInfect thing works perfectly! This is going to make them SO much more dangerous. Oddly enough, though, when I added the other whatever = none stuff to the melee attack function, it froze the game when it first attacked a pawn. I'll just leave those off then!

[Edit2] Enemy=None freezes the game. Not sure what that's all about. Gonna try manually calling AttitudeToCreature(Target) to force it to break off its attack once it successfully infects the target.

[Edit3] Not much difference there. I may just abandon trying to make them break off their attacks since their targets will die soon anyway.
Image

Previous Next

Who is online

Users browsing this forum: No registered users and 24 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited