1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

Need help creating a ZoneInfo subclass!!

Discussion in 'Programming' started by zhark, Jan 10, 2002.

  1. zhark

    zhark New Member

    Joined:
    Jan 10, 2002
    Messages:
    2
    Likes Received:
    0
    :(
    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
     
  2. Shiit

    Shiit Shiit

    Joined:
    Dec 19, 2000
    Messages:
    168
    Likes Received:
    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.
     
  3. Brood_of_Evil

    Brood_of_Evil Selene's martyr

    Joined:
    Nov 3, 2001
    Messages:
    147
    Likes Received:
    0
    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 :)
     
  4. zhark

    zhark New Member

    Joined:
    Jan 10, 2002
    Messages:
    2
    Likes Received:
    0
    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
     

Share This Page