User Control Panel

View messages: Inbox

Folder is 2% full (19 from 1000 messages stored)

Next PM in history

Re: Code Annotation Assistance?

Sent: Thu Feb 05, 2015 1:36 am
From: Higor
To: LannFyre 

Code: Select all
Global.ActorLeaving( Other);

// Calls non-state ActorLeaving event from this class

Code: Select all
//=============================================================================
// > QUESTION: How exactly do States work?
//=============================================================================

It's a special code flow executed during the actor's native Tick (don't remember if before or after the script Tick event).
Single flow, can define variations of global functions to customize the actor's behaviour during said state.
Flow can be controlled using 'latent' functions:
- Sleep( float Time);
- Stop;
- WaitForLanding(); (pawn only)
- MoveToward, MoveTo, StrafeFacing, etc (pawn only)
- FinishAnim(); (actor playing non-looped animation only)
- Goto operator, paired with a label name (ex: Goto Begin;), this is 100% safer than GotoState from within state.
You can customize flow control using While() loops paired with Sleep(0.0); calls.
Code: Select all
WaitForEnemy:
    while ( Enemy == none )
        Sleep(0.0);
Attack:
    Attack();
    if ( Enemy == none || Enemy.bDeleteMe || Enemy.Health <= 0 )
    {
        Enemy = none;
        Goto WaitForEnemy;
    }
    Goto Attack;



Code: Select all
        event EndState()
        //
        {
                Guy = none;
                // If guy = none, the state ends
        }

EndState() is a state-only script function, it's immediately called after your GotoState() call changes the actor into a different (or none) state, executed before the next line of code, consider the current state's EndState() as an extension of your GotoState() call.
Something similar occurs with the new state's BeginState() event.
In this case, we're setting Guy=none because he's either left the zone or the lottery has finished, it's a cleanup routine and a very responsible way of coding.



Code: Select all
        selection = FRand(); //Generate float ranged [0,1)
        if (Selection >= 0.8)
        else if (Selection >= 0.7)
        else

If we check >= 0.8 before >= 0.7, then the >= 0.8 will never evaluate, it's simple logical reasoning.
There's like ten different ways of doing a random chance check with more than two results, each one requires a different reasoning.
Just take a look:
Code: Select all
if ( Selection < 0.7)
     fail
else if ( Selection < 0.8 )
    one weapon
else
   two weapons

Code: Select all
if ( FRand() < 0.7 )
     fail
else if ( FRand() < 0.33 )
   one weapon
else
   two weapons

They all do the same.
Higor
Masterful
 
Posts: 728
Joined: Sun Mar 04, 2012 12:47 pm
Previous PMNext PM

Expand view Message history:

Re: Code Annotation Assistance?

Sent: Thu Feb 05, 2015 1:36 am
by Higor

Code: Select all
Global.ActorLeaving( Other);

// Calls non-state ActorLeaving event from this class

Code: Select all
//=============================================================================
// > QUESTION: How exactly do States work?
//=============================================================================

It's a special code flow executed during the actor's native Tick (don't remember if before or after the script Tick event).
Single flow, can define variations of global functions to customize the actor's behaviour during said state.
Flow can be controlled using 'latent' functions:
- Sleep( float Time);
- Stop;
- WaitForLanding(); (pawn only)
- MoveToward, MoveTo, StrafeFacing, etc (pawn only)
- FinishAnim(); (actor playing non-looped animation only)
- Goto operator, paired with a label name (ex: Goto Begin;), this is 100% safer than GotoState from within state.
You can customize flow control using While() loops paired with Sleep(0.0); calls.
Code: Select all
WaitForEnemy:
    while ( Enemy == none )
        Sleep(0.0);
Attack:
    Attack();
    if ( Enemy == none || Enemy.bDeleteMe || Enemy.Health <= 0 )
    {
        Enemy = none;
        Goto WaitForEnemy;
    }
    Goto Attack;



Code: Select all
        event EndState()
        //
        {
                Guy = none;
                // If guy = none, the state ends
        }

EndState() is a state-only script function, it's immediately called after your GotoState() call changes the actor into a different (or none) state, executed before the next line of code, consider the current state's EndState() as an extension of your GotoState() call.
Something similar occurs with the new state's BeginState() event.
In this case, we're setting Guy=none because he's either left the zone or the lottery has finished, it's a cleanup routine and a very responsible way of coding.



Code: Select all
        selection = FRand(); //Generate float ranged [0,1)
        if (Selection >= 0.8)
        else if (Selection >= 0.7)
        else

If we check >= 0.8 before >= 0.7, then the >= 0.8 will never evaluate, it's simple logical reasoning.
There's like ten different ways of doing a random chance check with more than two results, each one requires a different reasoning.
Just take a look:
Code: Select all
if ( Selection < 0.7)
     fail
else if ( Selection < 0.8 )
    one weapon
else
   two weapons

Code: Select all
if ( FRand() < 0.7 )
     fail
else if ( FRand() < 0.33 )
   one weapon
else
   two weapons

They all do the same.

Re: Code Annotation Assistance?

Sent: Wed Feb 04, 2015 11:44 pm
by LannFyre

What about the notes I have in WeaponLottery? Are they accurate for what I have? Could you explain the parts that I have pretty much left out and replaced with "QUESTION:"?

Re: Code Annotation Assistance?

Sent: Tue Feb 03, 2015 11:18 pm
by Higor

The RPG_Camera works fine in a single player scenario, with the following correction.
Code: Select all
function MyFunction()
{
        local PlayerPawn P;

        ForEach AllActors(class'PlayerPawn', P)
        {
                Target = P;
                Target.ViewTarget = self;
        }
}


Steam:
http://steamcommunity.com/profiles/76561197995853124/

Code Annotation Assistance?

Sent: Tue Feb 03, 2015 9:13 pm
by LannFyre

I've begun writing annotations to the code of the three actors so I have a better understanding of what I'm looking at, but I am stuck at annotating the state "Lottery" in RPG_WeapongLottery. Would you be able to go over the code in RPG_WeaponLottery with me in each area so I can have the code annotated for reference? Also would you mind proofreading my notes on RPG_Camera? If you have the time, would you mind helping annotate the new LotteryPanel code? I haven't made any changes to LotteryPanel, annotating or otherwise.

> RPG_Camera:
http://pastebin.com/HrJUTZ7T

> RPG_WeaponLottery:
http://pastebin.com/QHLEweiq

> RPG_WeaponPanel:
http://pastebin.com/xcbZCeKn

P.s. Do you have a Steam account that I could add so I could get in touch with you easier?

Re: Debug level + others

Sent: Sun Feb 01, 2015 11:37 pm
by Higor

Small prototype with the following edits:

- LotteryZone now has an extra Speel(1.5) post lottery.
- Added a StaticMeshActor subclass to draw Lottery zone timer.
-- Contains a custom static mesh.
-- Texture file is 'Scripted.utx'
- Added explosion + kill to LotteryZone upon third fail.
- Replaced lottery zone actor outside of the cylinder with a normal zoneinfo, the panel only interacts with one nearby lottery zone.

Stuff that could be done:
- Replace the base texture for the Scripted texture so we can draw text in multiple colors.
- Replace the zone container with a simple cube, and make a mesh decoration for the cylinder. (Cylinder zone breaks BSP horribly)
- Get some more fonts (LadderFonts sounds nice)
- Reduce amount of zones in main map (there's no reason to separate camera and play zones), there's a 64 zone limit!

We'll keep passing the map back and forth till we get something acceptable.

Re: Debug level + others

Sent: Sun Feb 01, 2015 10:31 am
by LannFyre

I don't mean to rush you or nothing, but have you had a chance to take a look at that level?

Re: Debug level + others

Sent: Tue Jan 27, 2015 7:56 pm
by LannFyre

I hear ya, I just wanted to make sure that the file actually got to you.

Re: Debug level + others

Sent: Tue Jan 27, 2015 7:08 pm
by Higor

Will be taking a look at it tomorrow or the day after.
XC_GameEngine's got me pretty busy, enhancing UT 227 style ain't easy :lol2:

Debug level + others

Sent: Tue Jan 27, 2015 11:31 am
by LannFyre

This link includes the following:
> The map
> The RPG_Camera and RPG_WeaponLottery zone scripts if you need to import them
> The RPG_Test sound package if you need to import it
> Vanilla Unreal Tournament textures
> Firetrucks, an RPG making mod for 227i which I believe is still being used on that map
https://www.dropbox.com/s/pqusacx9l3u2h ... g.zip?dl=0

Could you also explain how I could print text onto the screen similar to how it appears from either an admin message or announcer message (ie, "5 minutes remaining" being printed in the middle of the screen)? Also how would I get text that slowly reveals on screen, like what is seen in Unreal Tournament's tutorial level messages?

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Tue Jan 27, 2015 2:31 am
by Higor

You could attach those to ZIP files here if they're not so big.
Otherwise putting it on something like Dropbox will work.

(Yeah I'll need the custom resources to run the map, my Unreal 227i is 100% vanilla).

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Mon Jan 26, 2015 7:02 pm
by LannFyre

That sounds good to me. How should/would I send you the map? Also there are UT textures on the map plus custom sounds, so would I have to send those to you as well?

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Mon Jan 26, 2015 1:54 pm
by Higor

Such code allows you to draw stuff onto a texture!
If you want, you can send me the map and I'll add a sign on a random wall (inside the zone) with the new texture and code.
I won't embed the new code though (I have 227i Editor, are you using that one?)

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Mon Jan 26, 2015 10:46 am
by LannFyre

I've been away for a bit and have just come back to coding, so sorry for this in advance.

I've been taking a look at the code for the Pulse Gun (I have no idea where to look in the case of DM-Morpheus) and I think that this is the code that you wanted me to study:

Code: Select all
simulated event RenderTexture(ScriptedTexture Tex)
{
   local Color C;
   local string Temp;
   
   Temp = String(AmmoType.AmmoAmount);

   while(Len(Temp) < 3) Temp = "0"$Temp;

   Tex.DrawTile( 30, 100, (Min(AmmoType.AmmoAmount,AmmoType.Default.AmmoAmount)*196)/AmmoType.Default.AmmoAmount, 10, 0, 0, 1, 1, Texture'AmmoCountBar', False );

   if(AmmoType.AmmoAmount < 10)
   {
      C.R = 255;
      C.G = 0;
      C.B = 0;   
   }
   else
   {
      C.R = 0;
      C.G = 0;
      C.B = 255;
   }

   Tex.DrawColoredText( 56, 14, Temp, Font'LEDFont', C );   
}


I don't entirely understand what exactly I am looking for to be honest. I do appreciate the instructions from your previous message, but I'm going to need some more explaining on the topic of scripted textures (if you have the time). In this case, I'd need you to start explaining what pretty much everything that the code block above does.

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Sat Jan 17, 2015 3:30 pm
by Higor

The game itself.
Troubleshooting with EditActor commands and test logs, quickly going in and out of UnrealEd.

Just do this on your code whenever a function or a certain part of state code is executed:
Log("Player just entered the zone");
Log("Lottery start, failcount is "$ FailCount);
Log("Player left the zone");
This kind of debugging is ideal for stuff that doesn't execute every frame (or you'd end up with 500mb log file lol).

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Sat Jan 17, 2015 11:42 am
by LannFyre

I'm going to be working on this script when I get back from work, but I have a question first: is there any program that will let me execute scripts and troublshoot them in game?

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 10:43 pm
by Higor

BeyondUnreal wiki for most of UT99 and Unreal 226 code.

But if you really want to learn to use scripted textures, grab the code for UT99's pulse gun, or DM-Morpheus (UT99).
A ScriptedTexture is a dynamic bitmap (implying no mipmaps) where the user can define what to do with it.

- It works by setting the texture's 'NotifyActor' variable to that on an actor.
- When texture is about to render, it calls the actor's RenderTexture event, where the actor's code can draw stuff on it.
- Rinse and repeat for every frame.

Can be done in two ways:

- Static approach:
Draw stuff on a wall (use one scripted texture per panel... unless you're drawing the same stuff on all of them)
Place an actor that:
--- Sets the ScriptedTexture's NotifyActor to self in 'BeginPlay()' event
--- Has a function named 'event RenderTexture( ScriptedTexture S)' to draw on it.
--- Sets the ScriptedTexture's Notifyactor to none on 'Destroyed()' event.

Dynamic approach:
Drawing stuff on your weapon for example.
Defined on the weapon's RenderOverlays( Canvas C) [or any other rendering function].
--- Right before the 'DrawActor( self)' call, set the ScriptedTexture's NotifyActor to self.
--- Call 'DrawActor( self)' (or whatever actor has a scripted texture on it).
--- Set the ScriptedTexture's NotifyActor to none.
^^ this approach lets you use the same ScriptedTexture for multiple drawcalls in a frame.

In your case, the static approach is how you must do it.
Ideally:
- I'd use the ZoneInfo actor as a controller.
- I'd create one ScriptedTexture per ZoneInfo controller.
- The ScriptedTexture should be embedded into the map, or the same package of the Zone classes (avoids possible crash)
- Define a new property on the custom Zone: 'var() ScriptedTexture MyTexture'
- Set on each zone a different ScriptedTexture of your making, now you'll get a different draw state on each texture.
- Define the 'simulated event RenderTexture(ScriptedTexture Tex)' on the Zone's code.
- Draw your stuff on the texture within RenderTexture.
You now have a nice status indicator that doesn't require a HUD mutator or a big chained set of ElevatorMovers.

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 9:11 pm
by LannFyre

Higor wrote:The status can be done displaying the text on a wall (provided the class ScriptedTexture exists in Unreal 227i) or a sign.

Have any links/tutorials I could look at in order to learn how to do this?

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 7:15 pm
by Higor

The status can be done displaying the text on a wall (provided the class ScriptedTexture exists in Unreal 227i) or a sign.
Multiplayer support is something that'd need my direct touch tho (I like making SP campaigns work with Botz and other stuff).

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 5:59 pm
by LannFyre

Higor wrote:Is the failure count recorded for each player?

Yes, as well as a success. If the player succeeds one time, then the zone needs to not activate for them when they enter.
Higor wrote:What would happen if a player leaves the zone in the middle of a countdown after accumulating one or two failures?

The failures would be recorded on the player that entered the zone, and upon leaving (if the countdown hasn't finished yet) then the zone would stop counting down and nothing would result from it. The player would have the same amount of failures on them as when they entered; if they have succeeded, then the countdown doesn't activate.
Higor wrote:Is the lottery supposed to continue after it starts, regardless of the player's position?

No, it would end as soon as the player leaves the zone. If they leave before the initial (or second, or third) countdown finishes, then no result is recorded.
Higor wrote:Is the failure count reset when a player respawns?

This is a script that will be for a single player only mod, so the zone wouldn't reset until the player leaves the "area" (level).

Also, is it possible to add an on-screen text for the countdown that would just show numbers for each countdown, then would display either "pass", "lucky" or "fail" upon the lottery either granting a weapon or failing? Could said text then be reset to begin at the first number and count down the numbers again, displaying the result of the next roll and so on and so fourth?

Re: Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 11:45 am
by Higor

What would happen if a player leaves the zone in the middle of a countdown after accumulating one or two failures?
Is the failure count recorded for each player?
Is the failure count reset when a player respawns?
Is the lottery supposed to continue after it starts, regardless of the player's position?

Zone Gibbing Playerpawn - "WeaponLottery Zone"

Sent: Fri Jan 16, 2015 11:03 am
by LannFyre

> When the next roll (and every roll after it) executes, a countdown timer plays (by seconds, so tick needs to be implemented to account for 3 seconds along with 3 countdown sound plays (like Halo 1's respawn timer in multiplayer)).
> If the player neither receives a >0.7 roll nor >0.8 roll for three rolls, a different sound is played and they explode into gibs.


I had actually forgot about this part of the script. How would make it so the countdown happens two more times on fails, and if it fails the third time the player would be gibbed?

http://pastebin.com/QHLEweiq

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Fri Jan 16, 2015 10:57 am
by LannFyre

Awesome, that seems to have made the script begin working! The countdown that begins playing kinda stutters each time the beep is played, kinda like a very shoot echo that only echos the sound once. Everything else is fine though. Thank you for helping me to get this script working!

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Thu Jan 15, 2015 7:10 pm
by Higor

It would appear the zone isn't executing state code, change in both default and all instances of said zone these properties:
- bStatic to False
- bNoDelete to True

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Thu Jan 15, 2015 5:36 pm
by LannFyre

Higor wrote:Try making the sounds come from Guy instead (PlaySound into Guy.PlaySound)


Like this? http://pastebin.com/QHLEweiq
I tried running the above script and I walked into the zone; no sound, no weapon changes.

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Thu Jan 15, 2015 5:34 pm
by LannFyre

Higor wrote:Try making the sounds come from Guy instead (PlaySound into Guy.PlaySound)


Like this? http://pastebin.com/QHLEweiq

I tried running the above script and I walked into the zone; no sound, no weapon changes.

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Thu Jan 15, 2015 5:32 pm
by LannFyre

Higor wrote:Try making the sounds come from Guy instead (PlaySound into Guy.PlaySound)


Like this? http://pastebin.com/QHLEweiq

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Thu Jan 15, 2015 3:19 pm
by Higor

Try making the sounds come from Guy instead (PlaySound into Guy.PlaySound)

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Wed Jan 14, 2015 8:36 pm
by LannFyre

The value of Guy changes to MaleThree'Autoplay.MaleThree0', but that appears to be all that happens.

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Wed Jan 14, 2015 8:25 am
by LannFyre

It'll bring up a editor dialog in the actual game!!
And the hidden properties will be available in the 'None' tab.


I can open the advanced properties window in the game through the console, but I can't click on or access any option on the window itself; my cursor always passes behind the window if I pause the game.

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Mon Jan 12, 2015 10:59 pm
by Higor

My bad, that's an XC_GameEngine command.
Use this instead:
EditActor class=RPG_WeaponLottery

It'll bring up a editor dialog in the actual game!!
And the hidden properties will be available in the 'None' tab.

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Mon Jan 12, 2015 10:28 pm
by LannFyre

Higor wrote:That one on the screenshot is a normal zoneinfo...


Here is an updated screen shot; the player spawns in the same zone as the WeaponLottery, which just uses the sprite for the normal zoneinfo. (http://i.imgur.com/u0qofEz.jpg)

Higor wrote:If i'm wrong, type "EditObject class=RPG_WeaponLottery" while playing.
(You gotta pause a lot here)

How would I do this? Copy/pasting that line into the console while playing the map caused the game to back out and crash the editor/game.


Higor wrote:Enter the zone, pause often and check the properties on said zone to find out what's happening. (Stary with checking 'guy')

Re: "WeaponLottery Zone" doesn't seem to function

Sent: Mon Jan 12, 2015 9:23 pm
by Higor

That one on the screenshot is a normal zoneinfo...

If i'm wrong, type "EditObject class=RPG_WeaponLottery" while playing.
(You gotta pause a lot here)
Enter the zone, pause often and check the properties on said zone to find out what's happening. (Stary with checking 'guy')

"WeaponLottery Zone" doesn't seem to function

Sent: Mon Jan 12, 2015 5:35 pm
by LannFyre

Subject: WeaponLottery Zone Scripting: Newb Needs Help

Hey there, I really appreciate the help you provided in the WeaponLottery thread, but I am still having a few issues with the script and I was hoping you could take a look at the post I made and could maybe help me trouble shoot this script even further. If you can assist me, any help you provide I will be sure to edit into the original post so anyone can see the information.


EDIT:
So I compiled the new script with Higor's changes (here: http://pastebin.com/BzM9VFih) but something is wrong. When I start the game (the player spawns in the zone that the zoneinfo is in, here is a screenshot of zone portals for the level: http://i.imgur.com/7iBa48p.jpg) no sound is played, and I don't think I even receive rolls. I honestly can't tell because I do not hear the countdown noise. What could be causing this?

Higor wrote:Dunno about the booleans stuff... the current code handles the zone pretty well, unless you want some other functionality?

I'm not sure what you mean here.

Higor wrote:[. . .] typecasting from Actor into PlayerPawn is necessary to set a PlayerPawn type variable using an Actor reference... and it will fail to do so if said Actor isn't a PlayerPawn (setting to none)

How exactly does typecasting work? I'm a little confused on this.

Code: Select all
event ActorEntered(Actor Other)
{
   if ( Other.IsA('PlayerPawn') && !IsInState('Lottery') ) // edit here, define PlayerPawn
   {
      Guy = PlayerPawn(Other);
      GotoState('Lottery');
   }
   Super.ActorEntered(Other); // Calls the function from this class' parent class, ZoneInfo
}

Also, how could I modify this script so the playerpawn is checked for weapons, and if they have weapons RPG_NoDamageHit plays and the lottery doesn't roll?

Top