Page 1 of 1

UnrealScript: DrunkFx Zone?

PostPosted: Fri Aug 06, 10 4:44 pm
by WeeCrab
I would like to create a zone that, upon entering, gives a player the DrunkFx screen texture, and upon leaving, removes the screen texture.

I'm not a modder but usually I can copy and paste and change properties to get what I want for simple things but this is a little more difficult. First I assumed, I'd make a new zone class that expands ZoneInfo (like waterzone does), put only the ActorEntered and ActorLeaving functions in the new zone class (like Super.ActorEntered() ) and then add the hud effects I copied from DX player:

for entering:
root.hud.SetBackground(Texture'DrunkFX');
root.hud.SetBackgroundSmoothing(True);
root.hud.SetBackgroundStretching(True);
root.hud.SetBackgroundStyle(DSTY_Modulated);
for leaving:
root.hud.SetBackground(None);
root.hud.SetBackgroundStyle(DSTY_Normal);
DesiredFOV = Default.DesiredFOV;

Problem is it doesn't seem to work (gives errors) because A) the ActorEntered and ActorLeaving aren't functions, they are "events" so the Super() thing doesn't work I guess and B) I'm assuming because I'm mixing variables from a Player and those of a Zone.. I don't know. Is this possible without a new player class?

Note that I don't want the zone to hurt the player or make the player go 'argh' or anything, just have the DrunkFx texture over the screen as long as he is in that zone, just like how as long as you are in a "WaterZone," your screen is blue.

PostPosted: Fri Aug 06, 10 5:53 pm
by ~DJ~
I'd just suggest setting player's poison-timer and make the player has druggy effect by seeing how it is added..

At this, I am sure it's like (Actor Other) so writing DeusExPlayer(Other).<boolname> might help rather than localing.

Sorry, this isn't that helpful, but yeah.. find out how a player is poisoned without those HUD-Codes.

PostPosted: Fri Aug 06, 10 5:58 pm
by Dae
What about this?

Code: Select all
class DrunkFxZone extends ZoneInfo;

event ActorEntered( actor Other )
{
   Super.ActorEntered(Other);

   if (Other.isA('DeusExPlayer'))
   {
      DeusExPlayer(Other).drugEffectTimer += 10.0;
   }
}

defaultproperties
{
}

PostPosted: Fri Aug 06, 10 6:40 pm
by WeeCrab
That looks a lot cleaner, although one thing I need different and that one thing is giving an error:

I don't want to put the player in drugged mode, I only want the texture overlay on the screen if that makes sense (so I should be able to put any texture in there too and it would overlay on the screen).

So I used yours and tried this:

Code: Select all
class ScreenZone extends ZoneInfo;

event ActorEntered( actor Other )
{
   Super.ActorEntered(Other);

   if (Other.isA('DeusExPlayer'))
   {
      DeusExRootWindow.hud.SetBackground(Texture'DrunkFX');
   }
}


Ucc makes says: Error 'DeusExRootWindow' bad command or expression, so I copy exactly the way they did it in DeusExPlayer for defining DeusExRootWindow into "root" or something, which is this part:

local DeusExRootWindow root;

root = DeusExRootWindow(rootWindow);

So if I insert that into the code it is now:

Code: Select all
class ScreenZone extends ZoneInfo;

event ActorEntered( actor Other )
{
   Super.ActorEntered(Other);

   local DeusExRootWindow root;

   root = DeusExRootWindow(rootWindow);
   if (Other.isA('DeusExPlayer'))
   {
      root.hud.SetBackground(Texture'DrunkFX');
   }
}


But that doesn't work either, it says Local is not allowed here I assume because it's an Event and not a function?

Edit: Actually, figured out it was just the order making that error (local not allowed) but moving that above the Super line gets me "bad expression in '=' " on the line "root = DeusExRootWindow(rootWindow);" .. I don't understand these errors :(

PostPosted: Fri Aug 06, 10 7:00 pm
by Dae
WeeCrab wrote:Local is not allowed here

You should define local variables in the beginning of a function. That is not a beginning and event is not a function.

But the problem is different. Suppose there are several DeusExPlayers playing on your map. Each one has his own DeusExRootWindow, but you need a specific DeusExRootWindow — the one which belongs to the player, who entered your zone.

I believe the code should be something like this:
Code: Select all
class DrunkFxZone extends ZoneInfo;

event ActorEntered( actor Other )
{
   Super.ActorEntered(Other);

   if (Other.isA('DeusExPlayer'))
   {
      DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackground(WetTexture'DrunkFX');
   }
}

defaultproperties
{
}

PostPosted: Fri Aug 06, 10 7:19 pm
by WeeCrab
edit: oops, I saw the post too soon, am testing the new one now

Hmmm, it works, sorta, it seems that something is trying to override it though :(

If I descend into the zone, I see the drunkFx texture 'flash' once and go away. As I bob in and out of the zone (its bWaterZone true, no ViewFog though), I see the texture keep flashing on and off. If I enable Fly, and fly down into the zone, the texture stays over my view until I type Walk again. Any ideas?

Thank you by the way.

Blah. I thought it might be overridden by the fact that it's a waterzone but that doesn't seem to make a difference

PostPosted: Fri Aug 06, 10 9:23 pm
by Dae
I dunno 8-[

There are also those commands in the drug effect code of DeusExPlayer, perhaps try adding them as well (below SetBackground... call):

Code: Select all
DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundSmoothing(True);
DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStretching(True);
DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStyle(DSTY_Modulated);


Are you testing this in singleplayer?

PostPosted: Fri Aug 06, 10 9:33 pm
by WeeCrab
Yeah, single player. I will try in multiplayer and then I'll try adding those other commands too, very strange

PostPosted: Fri Aug 06, 10 9:40 pm
by Dae
WeeCrab wrote:Yeah, single player. I will try in multiplayer and then I'll try adding those other commands too, very strange

Na, if something like this doesn't work in singleplayer it's unlikely to work in multiplayer.

PostPosted: Fri Aug 06, 10 9:43 pm
by WeeCrab
edit:

It seems that because of the way it works - only flashes once and then resets - it needs to be a function that constantly applies the settings, in the DXPlayer poison, it does this I think by:

if (drugEffectTimer > 0)
{

but how can I do that for this? it needs to be...

While DeusExPlayer is inside this zone
..change the texture.

:S

Been looking for a "similar" code to copy from ZoneInfo and DeusExPlayer and can't find anything but will keep looking. REALLY thought there would be something like that for pain zones in ZoneInfo - assumed there'd be a code like - "While player is in this zone, damage him" but meh :(

PostPosted: Fri Aug 06, 10 10:51 pm
by ~DJ~
This is causing the problem:

On that DrugEffects function:

Code: Select all
   
   else
   {
      if ((root != None) && (root.hud != None))
      {
         if (root.hud.background != None)
         {
            root.hud.SetBackground(None);
            root.hud.SetBackgroundStyle(DSTY_Normal);
            DesiredFOV = Default.DesiredFOV;
         }
      }
   }


You see, it clearly says that if root exists, and if root HAS a background which you set, set it to nothing.

But-- It isn't because of the deltaTime, it's on it's own function.. the real thing which is causing it is on PlayerWalking state; an event called PlayerTick (which is continuous) has this code:

Code: Select all
state PlayerWalking
{
   event PlayerTick(float deltaTime)
   {
        RefreshSystems(deltaTime);
        DrugEffects(deltaTime);
        Bleed(deltaTime);
        HighlightCenterObject();

        Stuff..
   }
}



That, my friend, is a call to DrugEffects() on a float.

So.. this explains when you fly why it would not 'flash' and stay there, because you're not on state PlayerWalking.

So anyway, you'll have to create a new player.. and.. yes.. People.. have tried to do this before, and they had to make a whole new gametype.

PostPosted: Fri Aug 06, 10 11:03 pm
by WeeCrab
Hmmmmmm well crap.

Wait. That means, the ONLY time you can have a hud background texture is when drugTimer > 0 right?

So going back to Dae's original drugTimer idea, could that be used?

Upon entering the zone, give the dxplayer an insane amount of drugTimer, AND change the texture to something else
Upon exiting the zone, take away the drugTimer?

the only thing I'm concerned about there is a medkit healing the effect. I think it would..... unless while in the zone, the effect is constantly applied?

Would that work?

I just don't know how to say:

"While a DXPlayer is in this zone, constantly apply this effect"

PostPosted: Sat Aug 07, 10 12:11 am
by ~DJ~
Try..

Code: Select all
class DrunkFxZone extends ZoneInfo;

var int OldHealth;
var float HealthPlus;

event ActorEntered( actor Other )
{

    Super.ActorEntered(Other);

    if(Other.isA('DeusExPlayer'))
    {
        DeusExPlayer(Other).drugEffectTimer += 99999999999;
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackground(WetTexture'DrunkFX');
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundSmoothing(True);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStretching(True);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStyle(DSTY_Modulated);
        OldHealth = DeusExPlayer(Other).Health;
        DeusExPlayer(Other).Health += HealthPlus;
    }
}

event ActorLeaving( actor Other )
{
    Super.ActorLeaving(Other);

    if(Other.isA('DeusExPlayer'))
    {
        DeusExPlayer(Other).drugEffectTimer = 0;
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackground(None);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundSmoothing(False);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStretching(False);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStyle(DSTY_Normal);
        DeusExPlayer(Other).Health = OldHealth;
        DeusExPlayer(Other).DesiredFOV = DeusExPlayer(Other).Default.DesiredFOV;
    }
}

function Tick(float deltaTime)
{
    Super.Tick(deltaTime);

    HealthPlus += deltaTime;
}

defaultproperties
{
}


Worked for me, although the heal might not work.. but we don't seem to get any damage either.

PostPosted: Sat Aug 07, 10 12:21 am
by WeeCrab
I'll try now, although yes - I think the drugEffectTimer doesnt actually cause any damage since the player is not really poisoned - I think that is only "poisonTimer"

Ii'll try it out now




edit:

You know, guys, DJ and Dae, if you ever leave I am not sure who I'm gonna ask for DX1 coding help/tuts anymore. I usually come back to DX every once in a while and work on something. I'll never get bored of making something new in UnrealEd, and it's really nice of you guys to share your knowledge.

It works, there is only one problem which is the screen texture likes to stay up even when bobbing above the water level. Easily dismissed/fixed by mapping another thin waterzone above the muddy zone. :)

Thanks again. I'll update here on the progress (of the map)

PostPosted: Sat Aug 07, 10 12:27 am
by ~DJ~
Indeed.. there is no 'TakeDamage' in DrugEffects, only in UpdatePoison function.

Remove that bit of health code if needed.. it works on INTERNET too.

EDIT: Aaaaand, the only problem now is that there will be multiple textures, The DrugFX, normally.. and the texture you're going to select for your zone.

PostPosted: Sat Aug 07, 10 12:40 am
by WeeCrab
Got scared for a sec, but thankfully what happens is it looks like their drugtimer is applied first (by default giving the drunkfx), but then we apply our own texture instantly afterward, and it doesn't know that it should be changing back to drunkfx, so it doesn't :) It keeps the texture you define with your code :)

Just tried with Tear_Gas_A just to test it. Although maybe I should test in MP as well

PostPosted: Sat Aug 07, 10 12:41 am
by ~DJ~
Well.. I've already tried in MP.. it works.

Sadly, there will be two textures, as I've said before. And the fact that it'll rotate.. weirdly.. and change FOV.

I was wondering, is this like a new waterzone where you were willing to put a new texture so it looks kewl in water?

PostPosted: Sat Aug 07, 10 1:36 am
by WeeCrab
Hmmm.. it's working fine for me with just 1 texture but I will test again with dedicated if I can get dedicated to host with the Deus Exe fix. I decided to go completely opaque, maybe that's why it's working fine?

And yes - sort of. I want to make muddy, swampy water, and as you would not want to jump in that water in real life, I wanted to try and transfer that feeling to an in-game DX swamp. If the water surface is completely opaque black/brown, but you can see crystal clear underwater, that kind of ruins it right? :P And hopefully with some other little additions, players can be afraid to enter the swamp water, and stick to land as much as they can.

PostPosted: Sat Aug 07, 10 10:01 am
by Dae
~DJ~ wrote:OldHealth = DeusExPlayer(Other).Health;

What if a player receives damage while being in zone? :P

PostPosted: Sat Aug 07, 10 10:07 am
by Alex
Dae wrote:
~DJ~ wrote:OldHealth = DeusExPlayer(Other).Health;

What if a player receives damage while being in zone? :P

What if two people are in the same zone... player A gets player B's health?

PostPosted: Sat Aug 07, 10 12:58 pm
by WeeCrab
The health thing I actually commented out because drugeffectTimer doesn't hurt them anyways :)

I did have another idea which can be added to this (with the existing code, just have to test it)

Alright.. use a completely opaque texture for when they are submerged. This is already done.
When they exit the zone however, apply a texture that looks like "muddy spots" still over your eyes, but seems to be washing/dripping off and has masked spots where you are still able to see about 60% of the screen, and set the drugeffectTimer to "4 seconds".

So hopefully the effect would be that you can't see anything underwater, and when you get out, the mud has 1 transition texture before it goes away instead of just disappearing. :)

Will test and see how it looks. A little afraid it won't be too pretty because of how ugly it is when the player is coming out of being poisoned (the screen is very twitchy and not very smooth)

PostPosted: Sat Aug 07, 10 1:21 pm
by ~DJ~
Dae wrote:What if a player receives damage while being in zone? :P


Errr, well.. I dint thought about it.. :o

Besides, I am no expert in zones :cry:

Alex wrote:What if two people are in the same zone... player A gets player B's health?


Hmm? I'm not quite sure if it would do that.. but it does look like it'll do it. ARGH!

I suck at healing players (too)!


Also, good luck WeeCrab :$

PostPosted: Sat Aug 07, 10 4:21 pm
by WeeCrab
Well, don't need to worry about the healing part, however, I just tested and although replacing the drunkfx texture with another texture works fine in SP, in MP, it seems that clients get the old DrunkFx tex

I may have to stick with that unless you guys know of a way around that.

It's pretty cool though in singleplayer. I made an additional hidden 32 unit high mud zone above the normal mud zone. Made two different classes of the zones. In the deep zone, your screen is completely covered. In the shallow zone, your screen is 2/3 covered (kind of a "mud beginning to slide off" effect, but it's static). When you LEAVE the shallow zone, instead of removing the textures, it applies a third "1/3 covered in mud" texture and sets the timer to 5 seconds, so it's like if you escape the 'quicksand', the mud stays on the bottom of your screen in splotches for 5 seconds, like it's still on your eyes and has to wear off.

But as I said clients get the old DrunkFx tex :(

PostPosted: Sat Aug 07, 10 6:14 pm
by ~DJ~
Hmm.. perhaps a haxy way like this one?

Code: Select all
event ActorEntered( actor Other )
{

    Super.ActorEntered(Other);

    if(Other.isA('DeusExPlayer'))
    {
        DeusExPlayer(Other).drugEffectTimer += 99999999999;
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackground(None);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackground(WetTexture'CustomTexture');
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundSmoothing(True);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStretching(True);
        DeusExRootWindow(DeusExPlayer(Other).rootWindow).hud.SetBackgroundStyle(DSTY_Modulated);
    }
}


At the above code, it makes the Root-background to none, and THEN sets it to something else. Set it to your texture name and inform me what happened.. also..

I'll somewhat request something from you:

Can you make a texture which is like Nano_SFX_A, used for the water-zone. The another zone like your mud-zone, You see a kewl-like texture when you're inside water.. wavy texture, so it has this feeling of water. And after we get out of water, we can see 'little drops of water' possibly moving towards the bottom of our screen.

THNX :$

PostPosted: Sat Aug 07, 10 8:10 pm
by WeeCrab
I suppose you could use bluewater_a for the underwater one. Actually, that would probably look pretty cool. Maybe modulated would look good on it too

For the drips one, I guess- actually I've never made a "drips" texture but don't they start as completely empty (black) texture and then the drops effect is somehow applied on?

Edit:

Just tried to make a zone with bluewater_a while underwater. Actually, it looks awesome. Problem: drugeffecttimer makes your vision sway around and zoom in :P Not something you might want in normal water. Unless there is a way around that.

PostPosted: Sun Aug 08, 10 5:11 am
by ~DJ~
Yeah.. might be a big haxy way.. too.. to fix the FOV.. but not sure about the weird movement..

EDIT: About the drops texture.. nah.. I meant like.. drops are THERE after we get out of the zone and slowly move towards the bottom (pan-down in the texture)

PostPosted: Sun Aug 08, 10 10:34 am
by Dae
WeeCrab wrote:drugeffecttimer makes your vision sway around and zoom in

Perhaps that can be removed.

Code: Select all
DeusExPlayer.fov = DeusExPlayer.Default.DesiredFOV;
DeusExPlayer.ViewRotation = 0;


(not sure if the latter line compiles, perhaps it should be defined as a vector?)

don't forget to replace DeusExPlayer with your actor

PostPosted: Sun Aug 08, 10 3:19 pm
by ~DJ~
Perhaps with this.. instead?

Code: Select all
DeusExPlayer(Other).ViewRotation = DeusExPlayer(Other).Default.ViewRotation;