Need help creating a ZoneInfo subclass!!

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

zhark

New Member
Jan 10, 2002
2
0
0
48
Colom
Visit site
:(
Hi everybody
so far, this is my first post, with my first real problem. I'm really newbie to UnrealScript

What I want to acomplish is a triggable ZoneInfo subclass. I mean: a ZoneInfo that can be activated/deactivated by a trigger, something like PressureZone but modifiyin gravity, so if you activate the trigger, the ZoneInfo gravity affects the player

This is one of my attemps, it doesnt work at all

/-------------------------------------------------------------
class TriggableZone expands ZoneInfo;
var() bool bZoneEnabled; //Zone is activated or not

function Trigger( actor Other, pawn EventInstigator )
{

if( bZoneEnabled )
{
//If already activated, deactivate!
bZoneEnabled = false;
return;
}
else
{
//Activate the Zone
bZoneEnabled = true;
if (DamagePerSec != 0)
bPainZone = true;
}
}


// When an actor enters this zone.
event ActorEntered( actor Other )
{
if( !bZoneEnabled )
{
//This is what I added (Zhark)
//If the zone is not enabled (trigger-activated), it won't affect anybody
return;
}
else
{
//Proceed as normal ZoneInfo :)
Super.ActorEntered(Other);
}
}


I know this is a lame question, with a very bad coding. :(
I really don't know enough of UnrealScript, any suggestion, tip, help will be very appreciated.

Thanks
 

Shiit

Shiit
Dec 19, 2000
168
0
0
A much easier solution would be to just change the bGravityZone bool. This is what it'd look like:

function Trigger( actor Other, pawn EventInstigator )
{
Super.Trigger(Other, EventInstigator);
bGravityZone=!bGravityZone; // Toggles special gravity on/off
}

Um... I don't quite know whether you should toggle it in the Trigger function, or turn it on in there and turn it off in the Untrigger function.
 

Brood_of_Evil

Selene's martyr
Nov 3, 2001
147
0
0
45
Look outside your window!
Visit site
Do this:

Add a variable to the new class like this:
Code:
var (GravityTrigger) vector NewGravity;

And add this code:
Code:
function Trigger( actor Other, pawn EventInstigator ) 
{ 
     ZoneGravity = NewGravity;
}

function UnTrigger( actor Other, pawn EventInstigator ) 
{
     ZoneGravity = Default.ZoneGravity;
}

That way you can set the new gravity in the editor in defaultproperties without having to compile the whole class again.
I used untrigger, but if you want to toggle it you can write:
Code:
function Trigger( actor Other, pawn EventInstigator ) 
{
     if(bToggle)
     {
          //Toggle it
          bToggle = False;
          ZoneGravity = Default.ZoneGravity;
     }
     else
     {
          //Toggle it
          bToggle = True;
          ZoneGravity = NewGravity;
     }
}
Either way works fine :)
 

zhark

New Member
Jan 10, 2002
2
0
0
48
Colom
Visit site
Hey buds thanks a lot!

:D

Look you made my smilie change

I'm gonna try the new code right now...
Without your help I could've been needed weeks to figure it out ('cause I first have to learn UnrealScript)

As soon as I finish my level, I'll let you know!

See ya