Thursday, 21-Sep-2017  00:00:00
Enhanced Coop  
[ New messages · Members · Forum rules · Search · RSS ]
Page 1 of 11
Forum moderator: MrLoathsome 
Forum » Map Packs, Mods & Mutators » Mutators » The SkaarjTroopers Weapon Hack Thread (Fix for Skaarj with Weapons in UT)
The SkaarjTroopers Weapon Hack Thread
MrLoathsomeDate: Saturday, 08-Jun-2013, 11:03 AM | Message # 1
Lieutenant colonel
Group: Moderators
Messages: 150
Awards: 0
Reputation: 0
Status: Offline
Example of a crude "hack" that seems to fix the issues caused by adding Skaarj Troopers/Infantry/Gunners/Snipers or Officers into UT games.

I have refused to even consider re-writing any scriptedpawns to fix this sort of issue, if there is any chance I can fix it another way that would work
with the default pawns/game.

The code in the base UnrealI.SkaarjTrooper class is flawed.   Specifically in the auto state Startup section.   Everything regarding variable myWeapon.
All the issues regarding bIsPlayer are easily fixed, just by setting that to False right away.    The guns are trickier.

Even if the WeaponType class is set to a valid value, there are problems with getting the Troopers to successfully hold the weapon if you try it at the same
point in time as they spawn.    I have tried a LOT of ways to make this work, starting with when I was working on the BadNews mutator.   Nothing worked.

Since all the default WeaponTypes for the Trooper classes are Unreal guns, and UT's DMMutator code swaps all those out right away, that complicates things
even more.

I decided on a hack that would spawn all troopers with no weapon at all, and then assign them a weapon shortly thereafter.
The main thing that does get set when they spawn, is the class for their WeaponType variable.

Here are some snippets the current code in my development copy of the next version of the SwarmSpawn mutator.

First thing you should do, is preserve the default WeaponType values for the Trooper classes, so that the mutator or gametype code you place this
in can remain compatible with maps that are also spawning Troopers in them.  We need to save these in a global variable for the mutator:

Code
var class<Weapon> STDefWep, SGDefWep, SSDefWep, SIDefWep, SODefWep;


This bit is in PostBeginPlay, and actually saves the values:
Code
    STDefWep = class'UnrealI.SkaarjTrooper'.default.WeaponType;
       SGDefWep = class'UnrealI.SkaarjGunner'.default.WeaponType;
       SSDefWep = class'UnrealI.SkaarjSniper'.default.WeaponType;
       SIDefWep = class'UnrealI.SkaarjInfantry'.default.WeaponType;
       SODefWep = class'UnrealI.SkaarjOfficer'.default.WeaponType;


I have the mutator clearing out the WeaponType before the Troopers spawn, and then resetting the default values
like this:
Code
   class'UnrealI.SkaarjTrooper'.default.WeaponType = None;
      class'UnrealI.SkaarjGunner'.default.WeaponType = None;
      class'UnrealI.SkaarjSniper'.default.WeaponType = None;
      class'UnrealI.SkaarjInfantry'.default.WeaponType = None;
      class'UnrealI.SkaarjOfficer'.default.WeaponType = None;

.
.
.
do a bunch of checks and other stuff, spawn the pawn......
.
.
.
      class'UnrealI.SkaarjTrooper'.default.WeaponType = STDefWep;
      class'UnrealI.SkaarjGunner'.default.WeaponType = SGDefWep;
      class'UnrealI.SkaarjSniper'.default.WeaponType = SSDefWep;
      class'UnrealI.SkaarjInfantry'.default.WeaponType = SIDefWep;
      class'UnrealI.SkaarjOfficer'.default.WeaponType = SODefWep;


At this point, we have a weapon carrying SkaarjTrooper on the map, with no gun.   There are also no stray floating guns, or dropped guns etc.
The SwarmSpawn mutator however has set the desired WeaponType via an optional Set option configured in the ini file.

Next step for this crude hack, is to check for Troopers with no gun, and give them one.
Here is the bit out of the mutators Timer() function that is relevant:
Code
    foreach AllActors(class'ScriptedPawn', S)
       if (S.IsA('SkaarjTrooper'))
       {
           if (S.Weapon == None)
           {
               SkaarjWeaponHack(S);
           }
       }


S is a local ScriptedPawn variable in Timer....

Here is the Hacky function itself:
Code
function SkaarjWeaponHack(ScriptedPawn S)
{
       S.bIsPlayer = False;
       if (SkaarjTrooper(S).WeaponType == None)
       {
           SkaarjTrooper(S).WeaponType = class'Botpack.ChainSaw';
       }
       DeathMatchPlus(Level.Game).GiveWeapon(S, String(SkaarjTrooper(S).WeaponType));
       S.Weapon.bCanThrow = False;
       if (bTrooperGunDrop) S.DropWhenKilled = SkaarjTrooper(S).WeaponType;
       S.ChangedWeapon();
}


Note the bTrooperGunDrop variable above is a new config variable for the SwarmSpawner mutator.
The function ChangedWeapon(), is a default function that is in the default SkaarjTrooper source, that did almost everything it needed to, but IT NEVER GETS CALLED!!!  (I don't think...)

Also if the Trooper has an invalid or unavailable class set as WeaponType, it will get a ChainSaw.

That is about it for the moment.

The above will spawn almost any weapon for your skaarj that is set in WeaponType, as long as it is NOT one of the default UnrealI/UnrealShare weapons.

When I get the next release of SwarmSpawner done, it will include a number of example ini files for the Troopers and how to have them use 3rd party weapons.


Moo

 
Forum » Map Packs, Mods & Mutators » Mutators » The SkaarjTroopers Weapon Hack Thread (Fix for Skaarj with Weapons in UT)
Page 1 of 11
Search:

Copyright MyCorp © 2017
Powered by uCoz