Could be asleep, typing random messages instead.

UScript: Chat, Questions, Discussion

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: ividyon, Semfry, zYnthetic

User avatar Core
Skaarj Assassin Skaarj Assassin
Posts: 106
Joined: 15 Mar 2010, 17:16
Location: ../System/
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 11 May 2012, 20:21

Use a mutator's PreventDeath() function instead, and call the game's killed() function (if the score matters) and the playerpawn's RestartPlayer() function and/or whatever you want from there.

User avatar Jet v4.3.5
Skaarj Elder Skaarj Elder
Posts: 1247
Joined: 24 Dec 2007, 17:40
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 31 May 2012, 03:22

This is a thread for UScript, and I'm a beginner at said language, so I thought I'd post a concept actor that I'd like to put together, and get a crash course in UScript in the process.

The current concept I've commented into the code of my currently blank class speaks for itself, but in short, this actor should, on a basic level, allow the player to look at an object directly in front of them, get an indication that it is a usable object, press their "InventoryActivate" key (mine is Enter) without actually activating their currently-selected inventory item, following which an event will be set off of whatever purpose or scale the mapper may so designate.

The code:

Code: Select all

//=============================================================================
// UsableTrigger.
//=============================================================================
class UsableTrigger expands Trigger;

//   If the player is facing the trigger on all axis, the trigger is usable. This may also disable InventoryActivate functionality, making that key synonymous with a "use" key when presented with a Usable Trigger.

//Note: This should ONLY be the case if the player is viewing the trigger, not if the player is standing on the trigger.



//   Should a HUD effect of some sort be used? If so, make the following optional:

//   1) Four/Two-corner Hilight - Four corner textures or one duplicated and rotated corner texture used to encompass the usable object. The effect will be the same between Movers and Items, but the method behind this may be different.
//   2) Object Tinting - Overlay should be simulated with a certain texture applied, prefferable one of a solid color. Likely impossible for Movers.
//   3) Square Outline - Similar to No. 1 above, but possible more complex. Current concept consists of one corner texture and one or two edge textures to create the entire box.
//   4) Freeform Outline Effect - Possibly repeat effect in No. 2 above, but reverse mesh normals in some way? Increase fatness and set to an solid outline color texture.

//Notes: (A) There should be a field or two in properties to allow the mapper to specify what object is being "used" so that a trigger may be placed at the object, and the visual effects will be produced around the designated object. This may also allow for multiple objects, such as keypads, switches, or buttons, to all activate the same thing via one trigger. Also, possibly place effects around designated brush actor?
//       (B) Can all visual effects be made independent of a new HUD system, and simply be drawn based on code in the trigger or an Effect class of some sort?
Image
ModDb Portfolio
"Bear," she cried. "I love you. Pull my head off."

User avatar Buff Skeleton
>:E >:E
Posts: 4149
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 01 Jun 2012, 14:42

Pretty ambitious-sounding concept for a new UScripter, but seems doable, although I wouldn't know how. Have you considered just opening up a book on programming and learning the basics in a language, then applying that knowledge to UScript? UScript is very similar to C++ I believe so that might be a good starting point. Once you learn the programming basics, adapting just requires learning the changes in syntax.

The most important thing I've learned about UScript is, honestly, how to teach myself what things do by looking up parent functions, documentation (Unreal Wiki), etc.
Image

User avatar ebd
Trustee Member Trustee Member
Posts: 429
Joined: 05 Apr 2008, 19:08
Contact:

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 01 Jun 2012, 20:30

For your proposed highlighting, Determining the 3d location of the actor's corners should be easy if you use the collision height/radius of the actor. Translating this to a 2d location will be difficult unless there is a function to do this. Even if there is not you could calculate the position yourself. In this method a square outline isn't really more difficult than a corner outline.
Jet v4.3.5 wrote:The current concept I've commented into the code of my currently blank class speaks for itself, but in short, this actor should, on a basic level, allow the player to look at an object directly in front of them, get an indication that it is a usable object, press their "InventoryActivate" key (mine is Enter) without actually activating their currently-selected inventory item, following which an event will be set off of whatever purpose or scale the mapper may so designate.
I'm pretty sure this will take a custom player class to handle the inventory key.
Jet v4.3.5 wrote:Can all visual effects be made independent of a new HUD system, and simply be drawn based on code in the trigger or an Effect class of some sort?
If you wanted to use the renderOverlays() function in the PlayerPawn you could avoid a new HUD system. You'd also have the choice of rendering the outlines before the weapons if you desired.
Waffnuffly wrote:UScript is very similar to C++ I believe so that might be a good starting point. Once you learn the programming basics, adapting just requires learning the changes in syntax.
I've read this elsewhere though I've always felt it was more similar to Java since it avoided many of the weird constructs that plague c++, and like Java its standard library is sometimes very poorly implemented.

Pcube (Duh!)
Banned Banned
Posts: 2
Joined: 04 Jun 2012, 01:30

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 04 Jun 2012, 01:43

ebd wrote:For your proposed highlighting, Determining the 3d location of the actor's corners should be easy if you use the collision height/radius of the actor. Translating this to a 2d location will be difficult unless there is a function to do this.


Correct. It would require 3D to 2D projection math. You can look up the WorldToScreen function on unrealwiki if you don't feel like breaking out a linear algebra book. :) (http://wiki.beyondunreal.com/Legacy:Map ... ldToScreen)

Jet v4.3.5 wrote:The current concept I've commented into the code of my currently blank class speaks for itself, but in short, this actor should, on a basic level, allow the player to look at an object directly in front of them, get an indication that it is a usable object, press their "InventoryActivate" key (mine is Enter) without actually activating their currently-selected inventory item, following which an event will be set off of whatever purpose or scale the mapper may so designate.
I'm pretty sure this will take a custom player class to handle the inventory key.


Wait! One of the biggest blunders possible would be to make a new player class. This would make the content in question largely incompatible with existing gametypes. I have actually solved this problem before with a "grabbable trigger" but I have not tested it in many years. Here is the code:

Code: Select all

class grabtrigger expands Book;

var vector initial;

function postbeginplay()
{
   super.postbeginplay();
   Disable('TakeDamage');
   initial = location;
}

simulated function tick(float deltatime)
{
   setlocation(initial);
   setphysics(phys_none);
}

function touch(actor other)
{
   super.touch(other);
   playerpawn(other).clientmessage("hi");
}

event basechange()
{
local playerpawn p;
local actor a;

Super.BaseChange();


   if (base.IsA('playerpawn'))
   {
      Log("got grabbed");
      Playerpawn(base).carrieddecoration = none;
      SetBase(none);
      SetPhysics(Phys_None);
      SetLocation(initial);
      
      foreach allactors(class'actor',a,Event)
      {
         a.Trigger(P,P);
      }
      
      P = none;
   }
}


It seems that I used a book class (because you can grab decorations with mass < 25 iirc). Examine the code in PlayerPawn.uc where the grab function takes place and perhaps you can tailor a better solution based on grabbing objects. This solution is pretty hacky, but will work...


Can all visual effects be made independent of a new HUD system, and simply be drawn based on code in the trigger or an Effect class of some sort?
If you wanted to use the renderOverlays() function in the PlayerPawn you could avoid a new HUD system. You'd also have the choice of rendering the outlines before the weapons if you desired.


Very difficult in stock Unreal. Your options if you want to get more screen effects are to spawn your HUD and set the playerpawn's HUD = your new HUD. Your new HUD would pass through all calls that it receives to the old HUD, effectively "chaining" the HUDs... This is a legendary workaround, but I have seen it work with good results. I can dig up some code if you wish.

As much as I do not like to mar together content & gametypes, many gametypes do provide more direct methods of adding this functionality if desired. For compatibility purposes though I would not tie maps to a specific gametype unless absolutely necessary...

Waffnuffly wrote:UScript is very similar to C++ I believe so that might be a good starting point. Once you learn the programming basics, adapting just requires learning the changes in syntax.
I've read this elsewhere though I've always felt it was more similar to Java since it avoided many of the weird constructs that plague c++, and like Java its standard library is sometimes very poorly implemented.


I heard the same analogy between UScript & C++. Not sure where it started, but from experience I can say that UScript is far closer to Java (in terms of the language & virtual machine) than C++ by a long shot. This is probably for the best as it enhances ease of deployment and does not burden the programmer with memory management details. It makes sense for a game language, but arguments can be made both ways.

User avatar integration
Skaarj Berserker Skaarj Berserker
Posts: 445
Joined: 01 Sep 2010, 12:37

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 05 Jun 2012, 17:53

I am not sure, if I will ever touch UnrealEd again. So I will paste some 1 year old code from me, which is useful for aiming functions of pawns and weapons, whose projectiles are affected by gravity. Basically, we have a projectile and another object both moving on parabolic paths. The target's path f2 is given, but the projectile's path (f1) can be influenced: We can decide its initial direction d (normed), though its initial speed v is steady.

f2(t) = 0.5*a2*t² + b2*t + c2
f1(t,d) = 0.5*a1*t² + b1*t + c1 + v*d*t
e.g. for the Gesbio rifle we have
a1 = 0.5*zonegravity
b1 = vect(0,0,120)
c1 = biogel's starting location
v = 800

We want, that the projectile hits the target at a certain time t, thus f1(t,d) = f2(t), which can be rearanged to:
v*d*t = 0.5*a*t² + b*t + c
with the vectors a := a2 - a1, b := b2 - b1, c := c2 - c1
Now, we can compare the lenghts of both sides with the help of the dot product:

(v*d*t) dot (v*d*t) = (0.5*a*t² + b*t + c) dot (0.5*a*t² + b*t + c)
t²*v² = 0.25*a²*t^4 + (a dot b)*t^3 + (a dot c + b²)*t² + 2*(b dot c)*t + c²

The left side is independent from d, since d is normed (d dot d = 1). We get a quartic equation for t, which I solved with the help of complex numbers. The code is rather long, so I copied it to pastebin. In the case that b = 0 (object not moving, no linear term in the projectile's initial velocity), we have only even pows, so the quartic equation can be solved like a quadratic equation (faster).

https://www.youtube.com/watch?v=XJeoQ5Z6hbI

Code: Select all

class qGESBioRifle expands GESBioRifle;

// ############ code for solving a quartic equation #########

// returns the smallest positive solution x of e*x^4 + a*x^3 + b*x^2 + c*x + d = 0;
static function float SolveQuartic(float e, float a, float b, float c, float d)
{
   return 0;  // ####### attention: code too long to post it here ########
}

// returns the smallest positive solution x of a*x² + b*x + c = 0
static function float SolveQuadratic(float a, float b, float c)
{
   if ( a != 1 )
   {
      b /= a;
      c /= a;
   }
   a = b*b - 4*c;
   if ( a < 0 )
      return 0;
   if ( c < 0 )
      return 0.5*( -b + sqrt(a) );
   else if ( b < 0 )
      return 0.5*( -b - sqrt(a) );
   else
      return 0;
}

// #################### AIM FUNCTION ################################

function Projectile ProjectileFire(class<projectile> ProjClass, float ProjSpeed, bool bWarn)
{
   local Vector Start, X,Y,Z;
   local float qTime;
   local Pawn qOwner;
   local Actor qTarget;

   qOwner = Pawn(Owner);
   if ( Owner.Target == none && qOwner != none )
   {
      if ( qOwner.enemy != none && !qOwner.enemy.bDeleteme && qOwner.enemy != self )
         Owner.Target = qOwner.enemy;
   }
   qTarget = Owner.Target;
   if ( qTarget == none || qOwner == none )
      return Super.ProjectileFire(ProjClass,ProjSpeed, bWarn);

   GetAxes(qOwner.ViewRotation,X,Y,Z);
   Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;
   // call own function instead of owner.AdjustToss()
   AdjustedAim = SmartAim(ProjSpeed, -0.5*Region.Zone.ZoneGravity,
               qTarget.Velocity + qTarget.Base.Velocity - vect(0,0,120),
               qTarget.Location - Start, qTime); // <--------
   // PlayerPawn(qTarget).ClientMessage(qTarget.Base);
   if ( qTime <= 0 )
      return none; // target too far away or too far above
   Owner.MakeNoise(Pawn(Owner).SoundDampening);
   if ( (bWarn || FRand() < 0.4) && Pawn(Target) != None )
      Pawn(Target).WarnTarget(qOwner, ProjSpeed, Normal(qTarget.Location - Start) );
   return Spawn(ProjClass,,, Start, AdjustedAim);
}

// solves equation t*v*d = 0.5*a*t² + b*t + c, where
// d: unknown, normed (d dot d = 1) shooting direction, which will be returned as a rotator
// t: unknown scalar standing for the time
// v: scalar standing for the projetile speed
// a: vector standing for the gravity
// b: vector standing for the initial speeds, which are independent of shooting direction
// c: vector standing for the distance to your target
function rotator SmartAim(float v, vector a, vector b, vector c, optional out float t)
{
   // solution can be obtained via comparing the lenghts of both sides
   // t²*v² = 0.25*a²*t^4 + (a dot b)*t^3 + (a dot c + b²)*t² + 2*(b dot c)*t + c²
   // which is a quartic equation in t
   // if we know t, we can easily calculate d
   if ( a != vect(0,0,0) && b != vect(0,0,0) )
      t = SolveQuartic(a dot a*0.25, a dot b, a dot c + b dot b - v*v , b dot c*2., c dot c);
   else if ( a != vect(0,0,0) )
      t = sqrt( SolveQuadratic(a dot a*0.25, a dot c - v*v, c dot c) );
   else if ( b != vect(0,0,0) )
      t = SolveQuadratic(b dot b - v*v, b dot c*2., c dot c);
   else
      t = vsize(c)/v;
   return rotator(0.5*t*t*a + t*b + c);
}

The aiming function is pretty much unfinished. It should only prove, that my calculation is working. Missing things: aiming error, estimating the targets future speed with some kind of randomization, what happens, if target is jumping (estimating jumping time and do a calculation with the target's new location + horizontal speed), what happens, if the calculated hit point is outside of level geometry, and so on.
Last edited by integration on 05 Jun 2012, 19:15, edited 1 time in total.

User avatar Buff Skeleton
>:E >:E
Posts: 4149
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 05 Jun 2012, 18:08

Holy crap. This would be amazing to have for a variety of pawns and weapons in EXU that use indirect fire projectiles! It's something we've been planning to add for a long time but just haven't been able to yet.
Image

User avatar Gizzy
Skaarj Berserker Skaarj Berserker
Posts: 449
Joined: 02 Feb 2010, 12:55

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2012, 03:35

Going out on a whim hoping someone can help me here, since it's the last bug I need to fix in CSWeapons before it can be released properly.

Does anyone know how I can get MuzzleFlash on weapons to be scaled appropriately on different resolutions? I use bMuzzleFlash++; in Fire(); and AltFire(); functions to draw it and the offsets are set in the defaultproperties of each weapon (FlashS, FlashY). On 800x600 resolution, they're drawn correctly, but in my native resolution of 1920x1080 (And any other for that matter), they are slightly off :/

This is for U1 btw. I've looked through UT's TournamentWeapon class and Minigun2/SniperRifle classes and not had any luck (Or maybe because it's 5am and I cant sleep, who knows)

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 07 Jun 2012, 10:09

multipliers of Canvas.SizeX/SizeY(Or rendered in game space, instead of canvas will work 100%) of relative position to the weapon should do it... but it still won't be 1:1. You basically stumbled on the worst canvas problem ever.

User avatar Gizzy
Skaarj Berserker Skaarj Berserker
Posts: 449
Joined: 02 Feb 2010, 12:55

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 15 Jun 2012, 14:01

[]KAOS[]Casey wrote:multipliers of Canvas.SizeX/SizeY(Or rendered in game space, instead of canvas will work 100%) of relative position to the weapon should do it... but it still won't be 1:1. You basically stumbled on the worst canvas problem ever.


Thanks Casey, screw the canvas.

Little confused with how the canvas works, not used it much before but this is what it looks like now:

Code: Select all

//=============================================================================
// CSWeapons.
//=============================================================================
class CSWeapons expands Weapon
   Abstract;

other bits of code etc..

Simulated Function ClientSetMFlash( Float FlashSOffset, Float FlashYOffset )
{
   FlashS = FlashSOffset;
   FlashY = FlashYOffset;
}

simulated function PostRender( canvas Canvas )
{
   Super.PostRender(Canvas);

   if ((Canvas.SizeX == 1920) && (Canvas.SizeY == 1080))
   {
      ClientSetMFlash(Default.FlashS, Default.FlashY - 0.025);
   }
}

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 16 Jun 2012, 07:45

Gonna need the original code for 800x600

the problem here is aspect ratios

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 18 Jun 2012, 05:46

Jet v4.3.5 wrote:This is a thread for UScript, and I'm a beginner at said language, so I thought I'd post a concept actor that I'd like to put together, and get a crash course in UScript in the process.

The current concept I've commented into the code of my currently blank class speaks for itself, but in short, this actor should, on a basic level, allow the player to look at an object directly in front of them, get an indication that it is a usable object, press their "InventoryActivate" key (mine is Enter) without actually activating their currently-selected inventory item, following which an event will be set off of whatever purpose or scale the mapper may so designate.

The code:

Code: Select all

//=============================================================================
// UsableTrigger.
//=============================================================================
class UsableTrigger expands Trigger;

//   If the player is facing the trigger on all axis, the trigger is usable. This may also disable InventoryActivate functionality, making that key synonymous with a "use" key when presented with a Usable Trigger.

//Note: This should ONLY be the case if the player is viewing the trigger, not if the player is standing on the trigger.



//   Should a HUD effect of some sort be used? If so, make the following optional:

//   1) Four/Two-corner Hilight - Four corner textures or one duplicated and rotated corner texture used to encompass the usable object. The effect will be the same between Movers and Items, but the method behind this may be different.
//   2) Object Tinting - Overlay should be simulated with a certain texture applied, prefferable one of a solid color. Likely impossible for Movers.
//   3) Square Outline - Similar to No. 1 above, but possible more complex. Current concept consists of one corner texture and one or two edge textures to create the entire box.
//   4) Freeform Outline Effect - Possibly repeat effect in No. 2 above, but reverse mesh normals in some way? Increase fatness and set to an solid outline color texture.

//Notes: (A) There should be a field or two in properties to allow the mapper to specify what object is being "used" so that a trigger may be placed at the object, and the visual effects will be produced around the designated object. This may also allow for multiple objects, such as keypads, switches, or buttons, to all activate the same thing via one trigger. Also, possibly place effects around designated brush actor?
//       (B) Can all visual effects be made independent of a new HUD system, and simply be drawn based on code in the trigger or an Effect class of some sort?

1) not really understanding what you want. Some sort of highlight that only takes up part of the box in a 45 degree right angle triangle? Like this: http://etc.usf.edu/clipart/32300/32337/ ... 337_md.gif
2) Easily done in 227 with ActorRenderColor on movers and non-movers. Somewhat awkwardly done in non-227 with meshes that are larger than the normal and either opaque or transparent with a fixed color{sorry, no fancy color changing here :( }
3) Can only be done with Canvas if I understand you correctly. Say you have a sphere: you'd want the 2d box to "contain" the entire sphere?
4) I'm not sure if this is really possible. Maybe some poking around with STY_Modulated..?

User avatar Frieza
Skaarj Warlord Skaarj Warlord
Posts: 920
Joined: 16 Nov 2007, 15:05

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 18 Jun 2012, 14:38

I think with 1 he basically just means doing what Deus Ex did

Image

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 426
Joined: 25 Sep 2008, 07:25

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 18 Jun 2012, 22:21

Yeah, that makes sense. although it's kind of a hack in DX since there's no real way to know the mesh height to box it correctly

Oh and, all of this would have to be done in canvas/HUD for cleanliness

User avatar Buff Skeleton
>:E >:E
Posts: 4149
Joined: 15 Dec 2007, 00:46

Subject: Re: UScript: Chat, Questions, Discussion

Post Posted: 09 Jul 2012, 04:14

Simple question: when Actor A touches Actor B, how do you determine -where- A touched within B's collision radius?

Basically, I've got a simple trigger that spawns a splash noise whenever a player walks into it (so I can get the water effect without making water zones just for puddles), which works fine, but I want it to spawn visible splash effects too. Thing is, if I just spawn at the sensor's location, you'll only see splashes at 3-4 locations (sometimes just one). If I spawn at other.location, it might not spawn over the water puddle at all, and will probably spawn high above it to boot. I basically want to get the splash effect to spawn approximately where the player's foot would be. The sensors' collision height values are all set to 10, and could probably even be shrunk down to 5 and still work.
Image

Previous Next

Who is online

Users browsing this forum: No registered users and 3 guests

Copyright © 2001-2020 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited