A random sentence for a random mind.

Simple newbie exercise: mutator increase all weapon firing rates (UT2k3)

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

Moderators: Semfry, ividyon

User avatar TheIronKnuckle
Gilded Claw Gilded Claw
Posts: 1967
Joined: 12 Nov 2007, 07:21
Location: Riding my bicycle from the highest hill in Sydney to these forums

Subject: Simple newbie exercise: mutator increase all weapon firing rates (UT2k3)

Post Posted: 26 Aug 2013, 04:23

I want to port the superberserk mutator that shipped with ut2k4 to ut2k3. It sounds like it should be a simple exercise, just doubling all the weapon firing rates.
I've basically copied the code from the ut2k4 version and used referential transparency to remove all the obfuscatory Object Oriented bullshit (ie, whenever there is a function/method call to another class, i just inline the function call and pray that it doesn't touch anything that was set to private. Surprisingly it compiles, lucky me).

I've inserted log messages at strategic locations throughout the code. Currently the only ones that show up in the log are the postbeginplay "hello world" one, and the "i'mouttaurloop" one. The "yoyoyoyo", "Il hombre!" and "dawg!" messages never get hit, which indicates that the foreach loop is never entered.

NOTE: This is ALL the code. It's not much :)

Code: Select all

class SuperBerserk extends Mutator;
 
function PostBeginPlay()
{
  Super.PostBeginPlay(); // Run the super class function (Mutator.PostBeginPlay).
  Log("Hello World");    // Write our log message
 
}


auto state startup
{
   function tick(float deltatime)
   {
      local Weapon W;
//      local Ammunition A;
log("imouttaurloop");
//      Level.GRI.WeaponBerserk = 3;
      ForEach DynamicActors(class'Weapon', W)
                {
         Log("YOYOYOYO");
         //W.CheckSuperBerserk();
             if (W.FireMode[0] != None)
                       {
            Log("Il hombre!");
               //W.FireMode[0].StartSuperBerserk();
                         W.Firemode[0].FireRate = W.Firemode[0].default.FireRate * 0.75;
                         W.Firemode[0].FireAnimRate = W.Firemode[0].default.FireAnimRate/0.75;
                         W.Firemode[0].ReloadAnimRate = W.Firemode[0].default.ReloadAnimRate/0.75;
                       }
             if (W.FireMode[1] != None)
                       {
            Log("dawg!");
          //W.FireMode[1].StartSuperBerserk();
          W.Firemode[1].FireRate = W.Firemode[1].default.FireRate * 0.75;
                         W.Firemode[1].FireAnimRate = W.Firemode[1].default.FireAnimRate/0.75;
                         W.Firemode[1].ReloadAnimRate = W.Firemode[1].default.ReloadAnimRate/0.75;
                       }
                }
//      ForEach DynamicActors(class'Ammunition', A)
//         A.AddAmmo(1);
      GotoState('BegunPlay');
   }
}

function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{

   return true;
}

state BegunPlay
{
   ignores tick;
}


defaultproperties
{
  FriendlyName="Super Berserk"
  Description="Increases all weapon fire rates (Currently only successfully Logs 'Hello World'. :P)"
}


This code is the result of half an hour of mucking around. I've got 9 years coding experience in various other languages so feel free to use big words. I'm still a unrealscript n00b though, I have never mustered the ability to "be arsed" and properly learn the framework provided by ut2k4/ut2k3/unreal/UT. Now's a good time to start
ImageIgnorance is knowing anything
And only idiots know everything

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

Subject: Re: Simple newbie exercise: mutator increase all weapon firing rates (UT2k3)

Post Posted: 26 Aug 2013, 13:58

Erp, thought you were making this for UT99, not UT2k3. Question: why... why do you even want to play UT2k3?

The problem is that you're assuming, like a rational person, that FireRate does what you want. It doesn't. 99% of UT's weapons set up their fire rate based on animation rate, which is... exceedingly stupid, but what can you do. You have to increase the animrate for every PlayFiring and PlayAltFiring function in order to do what you want, which isn't possible with just a mutator. You have to replace the weapons with new weapon classes. Naturally, this means you can't make it affect all weapons globally, only the ones you directly replace.
Image

User avatar ividyon
Administrator Administrator
Posts: 2354
Joined: 12 Nov 2007, 14:43
Location: Germany
Contact:

Subject: Re: Simple newbie exercise: mutator increase all weapon firing rates (UT2k3)

Post Posted: 26 Aug 2013, 21:36

You should check out other existing 2k3 mutators and see how they handle code performed at map launch. Hello World is called in PostBeginPlay which is pretty much a sure-way execution, but if the other log bits don't get called, that means there is an issue with the "auto state startup" and "function tick" bits. Are you sure "auto state startup" is the way to go? Hell, couldn't you just put all that code in PostBeginPlay? Investigate existing muts and copy paste some stuff together. (That's how I do my coding!)
UnrealSP.org webmaster & administrator

User avatar TheIronKnuckle
Gilded Claw Gilded Claw
Posts: 1967
Joined: 12 Nov 2007, 07:21
Location: Riding my bicycle from the highest hill in Sydney to these forums

Subject: Re: Simple newbie exercise: mutator increase all weapon firing rates (UT2k3)

Post Posted: 27 Aug 2013, 01:20

@waff: haha I understand the confusion. I find UT2003 to be better balanced for deathmatch and capture the flag. Also my favourite UT2kX maps along with some choice mutators and gametypes were never ported from ut2003 to ut2004. Another big thing that is a massive dealbreaker on ut2004 for me is that the vehicles got boring within 6 months of me buying the game, and after that I just wanted to play ctf-face over and over again. The only thing is, the headshot hitbox on most models for 2k4 is fucked. You shoot em in the head, blood comes out, but it's not a headshot. Very frustrating when coming from the seemingly "anything above the waist" headshot hitbox from ut99. This isn't the case with UT2003.
Overall I find 2k3 to be less frustrating and more enjoyable. There's probably some mutators by greatemerald or delacroix that make ut2004 behave like that but I haven't been bothered to investigate.

@sana, yeh. That's how I got to this point. Opened up the 2k4 source code and just shuffled things over to ut2003. I have no idea what the state keyword does (let alone auto state :p should be fun to look up in future) and will try moving it all over to post-begin-play.
ImageIgnorance is knowing anything
And only idiots know everything


Who is online

Users browsing this forum: No registered users and 45 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited