Did you know? Every one of these messages is hand-typed live, just for you.

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: 06 Jun 2013, 19:19

Awwww maaaan I was so close to making this rad switch statement to replace an ugly if/else skyscraper that evaluated every single possibility only to realize that my switch was unable to check child classes. Can anyone think of a way to make this work?

Here's what I'm trying to replace:

Code: Select all

   else if( WhatDied.IsA('EXUBrute') || WhatDied.IsA('Brute') )
      Brutes++;
   else if( WhatDied.IsA('EXUGasbag') || WhatDied.IsA('Gasbag') )
      Gasbags++;
   else if( WhatDied.IsA('EXUKrall') || WhatDied.IsA('Krall') )
      Krall++;

   etc, etc etc


That shit sucks balls. Sure, the elses at least help terminate conditions earlier, but if you don't match ANY of the conditions, you have to check every single one of them and there's dozens. Every single time a pawn dies. In EXU2.

Yeah.

Here's what I tried to alleviate this problem:

Code: Select all

   switch( WhatDied.Class )
   {
      Case class'EXUBrute':
      Case class'Brute':
         log(self$": "$PlayerName$" killed a Brute");
         Brutes++;
         break;

      Case class'EXUGasbag':
      Case class'Gasbag':
         log(self$": "$PlayerName$" killed a Gasbag");
         Gasbags++;
         break;

      Case class'EXUKrall':
      Case class'Krall':
         log(self$": "$PlayerName$" killed a Krall");
         Krall++;
         break;

      etc, etc etc etc


Problem HERE is it evaluates classes LITERALLY, i.e. it doesn't check to see if a class is a child class the way IsA() does. Is there any way to use a switch statement with IsA() in the way I'm trying to, or am I stuck with if/else bullfuckery?

I also tried switch( WhatDied) and then did stuff like Case WhatDied.IsA('EXUBrute'):, but the syntax made UCC disappointed in me and it refused to cooperate. I'm guessing you can't have an uncertain statement in a switch case.
Image

User avatar ebd
Trustee Member Trustee Member
Posts: 442
Joined: 05 Apr 2008, 19:08
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 21:11

Traditionally also switch statements are used when cases are constants. I'm not surprised that unrealscript doesn't allow for what you are trying to do but it is inconvenient.

Also, traditionally both if else chains and switch statements are very fast in implementation (with switch statements being slightly faster some of the time). How it is implemented in unrealscript I have no clue, but if they at least tried a little bit in implementation an ugly pile of if else should be pretty quick even with EXU levels of stuff (as long as you aren't do too much else in there).

I guess that isn't quite the help you were looking for.

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

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 21:42

Nah, that's fine, I was just mostly wanting to see if I could make the code... prettier :p
Image

.:..:
Skaarj Warrior Skaarj Warrior
Posts: 68
Joined: 20 Dec 2007, 13:06
Location: Finland
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 23:10

Cant you use Mesh instead?

Code: Select all

   switch( WhatDied.Mesh )
   {
      case Mesh'BruteM':
         Brutes++;
         break;

      case Mesh'GasbagM':
         Gasbags++;
         break;

      case Mesh'KrallM':
         Kralls++;
         break;
   }

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

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 23:11

Theoretically that's a good solution, but not all subclasses of EXUGasbag, for example, actually use the Gasbag mesh :I

[Edit] Actually that's not strictly true... there are overlay meshes and an invisible Gasbag mesh underneath. I'll investigate this as a possible solution! Though it would definitely fail for, say, a custom Gasbag variant that was designed with a new mesh and new anims, etc.
Image

Bleeder91<NL>
Skaarj Assassin Skaarj Assassin
Posts: 147
Joined: 24 Jun 2011, 18:45

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 23:16

Set their default Tags or Events to something and use that. Can't remember which one of those gets reset when spawned but you can always use the default Tag/Event.
Or make a struct with a list of enemy types, and pick that. myeah, there are a lot of ways around it.

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

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 23:30

There's a lot I could do for EXUScriptedPawn, but I wanted to make it count the stock pawns as well (which are entirely different classes). Either way I guess the current solution isn't that bad all things considered, just a little disappointed I couldn't use a fancy switch for it :P
Image

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

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 06 Jun 2013, 23:58

Actually, I have a totally different question now I almost forgot about:

How do you override friendly fire damage scaling? If Friendly Fire is at 0% and you have a triggered map-wide destruction event that should damage anything that gets hit, regardless of whether it's a friend or foe, but you still want the instigator of that event to get credit for kills, it will scale the damage for friendlies based on Friendly Fire Scale. If you want friendlies to take 100% damage regardless of that scale, is there a way around that? MutatorTakeDamage hack or something? Or can it be done in the actor that deals the damage?
Image

User avatar Draco Nihil
Skaarj Lord Skaarj Lord
Posts: 197
Joined: 06 Jun 2012, 21:18
Location: Independence, Kansas
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2013, 00:04

I would try MutatorTakeDamage because I noticed that thing tends to get called before several important steps. (like armor absorb damage being one)

A hack way would be to set everyone's team to a random value. >.,=,.>
“I am the dragon without a name...”

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

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2013, 00:25

That won't work in coop; teams are irrelevant. Damage is based solely on a comparison of whether or not both the victim and instigator are bIsPlayer=True. That would also make ALL damage count 100% on friendlies, breaking friendly fire scale entirely.
Image

User avatar Draco Nihil
Skaarj Lord Skaarj Lord
Posts: 197
Joined: 06 Jun 2012, 21:18
Location: Independence, Kansas
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2013, 08:07

Well if you want people to die instantly there's no stopping GibbedBy(); That of course is if you want people to die instantly regardless of friendlyfire.

However to fully get 'round friendly fire, you'd have to handle TakeDamage your own via MutatorTakeDamage and quite literally act as an override to regular TakeDamage and perform all the necessary functionality.. I'm not sure how in the execution cycle MutatorTakeDamage is apart from knowing it happens after ArmorAbsorbDamage (for whatever stupid reason) so maybe just modifying damage through that might do the trick.
“I am the dragon without a name...”

User avatar makemeunreal
Banned Banned
Posts: 1296
Joined: 20 Mar 2011, 09:20
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2013, 23:33

I have got a big problem.
I can place a pickup on the map, then setup it's properties(how much health it grantes to me etc...)
but, what if I want that pickup to be dropped by a pawn?
I choose it as DropsWhenKilled, and that's all. Then, I can't modify the item.
I want to make a health pickup with the same mesh it has, but it should grant 1 health, and generate a strong, light blue light around it.
I want to modify it's DrawnScale to 0.5, but with the same collision.
I can't make these when i choose the pickup as the drops.
I tried to make a class beyond Super Health.
But I didn't find anything it's mode that can be set to these parameters.

Please help me, if you can.
"They let us go about our business here, but it is a farce. I know that they are watching us, controlling us. I believe that this once safe haven is as deadly as the surface planet below."

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: 08 Jun 2013, 04:23

I love that mesh suggestion. If you end up going with it make sure to comment why :P I'd be flipping the table if I came across that code even if it's the best way to do it
ImageIgnorance is knowing anything
And only idiots know everything

User avatar makemeunreal
Banned Banned
Posts: 1296
Joined: 20 Mar 2011, 09:20
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 08 Jun 2013, 07:40

I need that pickup very much.
But, it's a shame I can't do it.
"They let us go about our business here, but it is a farce. I know that they are watching us, controlling us. I believe that this once safe haven is as deadly as the surface planet below."

User avatar makemeunreal
Banned Banned
Posts: 1296
Joined: 20 Mar 2011, 09:20
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 08 Jun 2013, 15:14

So, they should drop these things, but with a DrawScale of 0.5. Same collision.
Image

It should boost your health, even if it is 100.So, it has to set to Superhealth. Also, +1 hp boost.

It's the code of the original pickup.

Code: Select all

//=============================================================================
// SuperHealth.
//=============================================================================
class SuperHealth extends Health;

#exec OBJ LOAD FILE=Detail.utx

#exec MESH IMPORT MESH=SuperHealthMesh ANIVFILE=Models\sheal_a.3d DATAFILE=Models\sheal_d.3d LODSTYLE=8
#exec MESH LODPARAMS MESH=SuperHealthMesh STRENGTH=0.6
#exec  MESH ORIGIN MESH=SuperHealthMesh X=0 Y=0 Z=0 ROLL=128
#exec  MESH SEQUENCE MESH=SuperHealthMesh SEQ=All    STARTFRAME=0  NUMFRAMES=1
#exec  TEXTURE IMPORT NAME=Jshealth1 FILE=Models\shealth.pcx GROUP="Skins" DETAIL=Metal
#exec OBJ LOAD FILE=Textures\WaterEffect1.utx  PACKAGE=UnrealShare.WEffect1
#exec  MESHMAP SCALE MESHMAP=SuperHealthMesh X=0.04 Y=0.04 Z=0.08
#exec  MESHMAP SETTEXTURE MESHMAP=SuperHealthMesh NUM=1 TEXTURE=Jshealth1
#exec  MESHMAP SETTEXTURE MESHMAP=SuperHealthMesh NUM=0 TEXTURE=UnrealShare.WEffect1.WaterEffect1

function PlayPickupMessage(Pawn Other)
{
   Other.ClientMessage(PickupMessage, 'Pickup');
}



I made a subclass within, and tried to modify the code, but it has nothing to do with the items properties.
"They let us go about our business here, but it is a farce. I know that they are watching us, controlling us. I believe that this once safe haven is as deadly as the surface planet below."

Previous Next

Who is online

Users browsing this forum: No registered users and 66 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited