hungry noob requesting help

  • 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.

Defx666

New Member
Jan 1, 2006
19
0
0
Well, how can i call my function?
does an event happen when the player reaches 100 adrenaline?
im feelin kinda lost
one more thing i copied the beginning of the code from the regen mutator
Code:
event PreBeginPlay()
{
        SetTimer(1.0,true);
}
why is event? and why didnt it call Super.PreBeginPlay?
wouldnt this break the chain?
 
Last edited:

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
Ok so now i understand, you want the adrenaline to constantly decrease so the player has to get a lot of kills before it activates this SeedMode thing, correct ?

Right lets go through this :), an event does the same things in Uscript as the function keyword, however marking a function as an event means that it will build in references to C++ code that can be exported as well. You could have simply put:

Code:
Function PreBeginPlay()

This would make no difference to you as you arent using any C++ code.

I dont entirely understand what you mean by 'why didnt it call super.PreBeginPlay()', but i will have a go and try to explain anyway. If you are using a function that has been used in the code you are extending off(in your case mutator, info, actor and object (in order)) you can use code that has been previously written in this function. The super.-FunctionName-; will essentially write into your function any previous code that was made in previous classes for that function. You dont have to worry about this though because you dnt need this code.
It basically means you dont have to write in code you have already made in previous classes.

You must call your function from another function, as far as i know there is no other way... This is the part i was most confused at when i started, i didnt know any of the function names so didnt have anywhere to call my own functions from. Heres a small list of usefull functions that the engine calls and you can use:

Code:
Touch(Actor Other) //This is called whenever another actor touches your own actor, however your current mutator doesnt have any sort of collision on it (obviously) so this isnt usefull for your current project, but you may find it usefull at a later date :).

PreBeginPlay() //This is called right before your actor enteres play, this could be at the start of the level in the case of your mutator or every time it spawns as in the case of a player.

PostBeginPlay() //This is nearly identical to PreBeginPlay() except that it is called immediatly after an actor enteres play.

Tick(float DeltaTime) //This is called every frame (or tick), however be carefull when using this function and try not to write iterative functions (loops, For commands etc...) in it as it will severly reduce FPS if you do.

There are a lot more as well, i cant possibly list them all, but generally if it seems logical that the engine would have a function be called for instance when an actor takes damage or dies, then there will probably be a function that you can use.


Right back to your mutator, you need to know when your controllers are at 100 adrenaline, you have 2 ways to do this, you can either write the code into your existing Timer function or you can use tick. You could probably get away with going through the controller list in tick since there can only be a maximum of 32 (except in invasion). However for simplicity we will write it into Timer.

Code:
function Timer()
{
        local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
                If(C.Adrenaline == C.AdrenalineMax)
                {
                         SeedMode();
                }

                if (C.Pawn != None && C.Adrenaline < C.AdrenalineMax )
                {
                         C.Adrenaline = Min( C.Adrenaline-AdrenalineDecrease, C.AdrenalineMax );
                }
        }
}

Try that, it shoud call SeedMode now...
 

Defx666

New Member
Jan 1, 2006
19
0
0
Right, Seedmode is being called now
But i have some new questions =)
Code:
function SeedMode()
{
        local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
              if (C.Pawn != None && C.Adrenaline ==100)
              {
                      PlayerController(C).ClientMessage("Seed Mode activated");
                      C.Pawn.Health = 199;
                      C.Pawn.GroundSpeed = 700;
                      C.Adrenaline = 0;
              }
        }
}
as you can see i added some functionality to seedmode but i had some problems

1 - Whats the difference between Pawn and xPawn, xPawn has some cool vars but i cant seem to access them
2 - how can i set a time duration for seed mode?

and thats it (for now)
btw you (all, especially rich_zap) have been a great help
Thank You
 
Last edited:

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
This is what the wiki has to say about xpawn as im not sure myself:

The Wiki said:
This is the actual pawn class used in UT2003 and UT2004. The "x" does not stand for anything, just indicates this is Digital Extreme's implementation, rather than from Epic's basic engine classes.

The best way i could see to set a time duration is to use states, this will require a fair amount of redesigning in your code. Another way would be to include a timing variable. As timer is called every 1 second, if you include the variable there and then increment it whenever timer is called, you should be able to keep track of how many seconds seedmode has been used, then reset it when you stop running seedmode (if that happens).
 

Defx666

New Member
Jan 1, 2006
19
0
0
I think redesigning my code would be a good idea
its too lame
btw, i finished high school last year, i was wondering, does any of you know some university in the US (or Canada) that offers scholarship for foreign students? Im interested in something computer related, like computer science or even something more game related
anyway, its just a thought
 

Defx666

New Member
Jan 1, 2006
19
0
0
Well, i redesigned my code, but as expected I have some doubts
I seem to be addicted to this
Code:
local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
is there some other way of checking if some player reached 100 adrenaline since i cant define locals in states?

here is the complete code



Code:
//-----------------------------------------------------------
//       Seed mode mutator
//-----------------------------------------------------------
class MutSEEDmode extends Mutator;

var int AdrenalineDecrease;

// Don't call Actor PreBeginPlay() for Mutator
event PreBeginPlay()
{
        SetTimer(1.0,true);
}

auto state Idle
{
    function Timer()
    {
            local Controller C;

            for (C = Level.ControllerList; C != None; C = C.NextController)
            {
                    If(C.Adrenaline == C.AdrenalineMax)
                    {
                          Gotostate('Start');
                    }

                    //if (C.Pawn != None && C.Adrenaline <= C.AdrenalineMax )
                    //{
                    //         C.Adrenaline = Min( C.Adrenaline-AdrenalineDecrease, C.AdrenalineMax );
                    //}
            }
    }
}

state Start
{
        local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
              if (C.Pawn != None && C.Adrenaline == 100)
              {
                      PlayerController(C).ClientMessage("Seed Mode activated");
                      C.Pawn.Health = 199;
                      C.Pawn.GroundSpeed = 700;
                      Gotostate('Running')
              }
        }
}

state Runnning
{
        local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
            if (C.Pawn != None && C.Adrenaline > 0)
            {
                    C.Adrenaline -= -1;
                    Sleep(1.0);
                    Gotostate('Running')
            }
            else
            {
                    Gotostate('End')
            }
        }
}

state End
{

local Controller C;

        for (C = Level.ControllerList; C != None; C = C.NextController)
        {
             PlayerController(C).ClientMessage("Seed Mode deactivated");
                      C.Pawn.Health = 100;
                      C.Pawn.GroundSpeed = 450;
                      Gotostate('Idle')
        }
}



defaultproperties
{
       AdrenalineDecrease=1
       IconMaterialName="MutatorArt.nosym"
       ConfigMenuClassName=""
       GroupName="SEED"
       FriendlyName="SEED mode"
       Description="Seed mode is activated upon reaching 100 adrenaline."
}
 

Defx666

New Member
Jan 1, 2006
19
0
0
rich_zap said:
No theres no problem with what youve done there, i cant think of another way to access all of the controllers...

but do i have to do it every state?
i get an error when i try to compile, something about declaring locals in the state
ill post the exact message as soon as i get home
Edit:
Error: F:\UT2004\MutSEEDmode\Classes\MutSEEDmode.uc(16) : Error, 'State' is not allowed here
 
Last edited:

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
41
New Zealand
www.digitalconfectioners.com
That's because you have used state's incorrectly. The best way to think of states is well .. mmm, let's say you have a person. His normal breathing pattern is fine, so in his 'normal' state he breathes fine. If he becomes sick, his state changes to 'sick' and his breathing function becomes laboured.

No you do not have to put the ControllerList iteration in every state. Just have a look at how some other classes in UT2004 use states.
 

Defx666

New Member
Jan 1, 2006
19
0
0
[SAS]Solid Snake said:
No you do not have to put the ControllerList iteration in every state. Just have a look at how some other classes in UT2004 use states.
Could you please post a state code that you think is good?
 

rich_zap

New Member
Jul 18, 2004
133
0
0
Dissapearing into the fog !
Heres a simple actor that uses states, courtesy of Tuco, Ludocraft:

Code:
//-----------------------------------------------------------
// TPActor.
//-----------------------------------------------------------
class TPActor extends Actor;

var float SizeDiff;
var int Health;


// Try to spawn a new TPActor near.
function SpawnNewOne()
{
    local TPActor TP;
    local int i;
    local vector Loc;

    for(i=0;i<10;i++)
    {
        Loc = Location + (VRand() * 250);
        Loc.Z = Location.Z;
        TP = Spawn(class'TPActor',,,Loc);
        if(TP != none)
            break;
    }
}

// If takes more than 25 points of damage, spawn explosion and destroy
function TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType)
{
    Health -= Damage;
    if(Health <= 0)
    {
        spawn(class'RocketExplosion');
        Destroy();
    }
}

// State code
// ****************************************
auto state Idling
{
    function Touch(actor Other)
    {
        if(Pawn(Other) != none && PlayerController(Pawn(Other).Controller) != none)
        {
            PlayerController(Pawn(Other).Controller).ClientMessage("touched me");
            PlaySound(sound'WeaponSounds.BExplosion5',SLOT_Misc,1,,1024);
            SpawnNewOne();
            Gotostate('Waiting');
        }
    }
}

state Waiting
{
    function EndState()
    {
        SetDrawScale(default.DrawScale);
    }

    function Tick(float DeltaTime)
    {
        if(DrawScale > 1.5 && SizeDiff > 0)
            SizeDiff = -0.05;
        else if(DrawScale < 0.5 && SizeDiff < 0)
            SizeDiff = 0.05;

        SetDrawScale(DrawScale+SizeDiff);
    }

begin:
    Sleep(6);
    Gotostate('Idling');
}



DefaultProperties
{
    bCollideActors=true
    bProjTarget=true

    bStasis=false
    bStatic=false
    bHidden=false

    DrawType=DT_Sprite
    RemoteRole=ROLE_None

    bUseCylinderCollision=true
    CollisionHeight=50.0
    CollisionRadius=50.0

    SizeDiff=0.05
    Health=25
}