|
Hyper.nl Unreal Services The forum of Hyper.nl Unreal Services and the semi-offical resource for Winged Unicorn's Unreal mods
|
View previous topic :: View next topic |
Author |
Message |
Cheese
Joined: 30 Mar 2006 Posts: 79 Location: ...YES
|
Posted: Wed Apr 26, 2006 4:19 am Post subject: Please, help a newbie make a Gametype 'Mutator' |
|
|
Alright. This here, what i'm about to say, is the code from something i'm working on.
(The bold sums it all up)
Which is, basically to replace the normal weapons in normal co-op with ones from Uber2.
The problem is, it just won't work.
Please, help out a newbie here.
Here's the code:
Code: |
//=============================================================================
// UberCoop.UberCoopGame.
//
//Some code taken from Upak's TerranWeaponMatch
//and slightly edited by me. And then added into the
//normal Co-op game code.
//=============================================================================
class UberCoopGame expands CoopGame;
var() config bool bNoFriendlyFire;
var bool bSpecialFallDamage;
function PostBeginPlay()
{
Super.PostBeginPlay();
bClassicDeathMessages = True;
UberWeaponSetup();
}
function UberWeaponSetup()
{
local EightBall EBall;
local Stinger S;
local FlakCannon FlakC;
local MiniGun MiniG;
local Rifle R;
local AutoMag AutoM;
local ASMD A;
local RazorJack RJ;
local GESBiorifle GES;
local DispersionPistol DP;
// local WeaponPowerup WP;
// local RifleAmmo RA;
// local FlakBox FBox;
// local StingerAmmo SA;
// local ASMDAmmo ASA;
// local Sludge BGA;
// local RocketCan RCan;
// Log( "Destroying ASMD Ammo." );
// ForEach AllActors( class'ASMDAmmo', ASA )
// {
// ASA.Destroy();
// }
// Log( "Destroying BioGel Ammo." );
// ForEach AllActors( class'Sludge', BGA )
// {
// BGA.Destroy();
// }
// Log( "Destroying Stinger Ammo." );
// ForEach AllActors( class'StingerAmmo', SA )
// {
// SA.Destroy();
// }
// Log( "Destroying Weapon Powerups." );
// ForEach AllActors( class'WeaponPowerup', WP )
// {
// WP.Destroy();
// }
Log( "Replacing DispersionPistols." );
ForEach AllActors( class'DispersionPistol', DP )
{
Spawn( class'Uber2.fastDPistol1',,, DP.Location, DP.Rotation);
DP.Destroy();
}
Log( "Replacing Eightballs." );
ForEach AllActors( class'EightBall', EBall )
{
Spawn( class'Uber2.uberball',,, EBall.Location, EBall.Rotation);
EBall.Destroy();
}
// Log( "Replacing Eightball ammo." );
// ForEach AllActors( class'RocketCan', RCan )
// {
// Spawn( class'RLAmmo',,, RCan.Location, RCan.Rotation );
// }
// Log( "Replacing FlakCAnnon ammo with GrenadeLauncher ammo." );
// ForEach AllActors( class'FlakBox', FBox )
// {
// Spawn( class'GLAmmo',,, FBox.Location, FBox.Rotation );
// }
Log( "Replacing BioGel Guns." );
ForEach AllActors( class'GESBiorifle', GES )
{
Spawn( class'Uber2.Energy1',,, R.Location, R.Rotation);
R.Destroy();
}
Log( "Replacing Rifles." );
ForEach AllActors( class'Rifle', R )
{
Spawn( class'Uber2.FlakRifle',,, R.Location, R.Rotation);
R.Destroy();
}
// Log( "Replacing all Rifle Ammo with CAR Rifle Ammo clips." );
// ForEach AllActors( class'RifleAmmo', RA )
// {
// Spawn( class'CARifleClip',,, RA.Location, RA.Rotation );
// RA.Destroy();
// }
Log( "Replacing FlakCannons" );
ForEach AllActors( class'FlakCannon', FlakC )
{
Spawn( class'Uber2.UberFlak1',,, FlakC.Location, FlakC.Rotation );
FlakC.Destroy();
}
Log( "Replacing Stingers." );
ForEach AllActors( class'Stinger', S )
{
Spawn( class'Uber2.Faststinger1',,,S.Location, S.Rotation);
S.Destroy();
}
Log( "Replacing Razorjacks." );
ForEach AllActors( class'Razorjack', RJ )
{
Spawn( class'Uber2.RazorStinger',,, R.Location, R.Rotation);
R.Destroy();
}
Log( "Replacing Miniguns." );
ForEach AllActors( class'MiniGun', MiniG )
{
Spawn( class'Uber2.UberMinigun',,, R.Location, R.Rotation);
R.Destroy();
}
Log( "Replacing AutoMags" );
ForEach AllActors( class'AutoMag', AutoM )
{
Spawn( class'Uber2.Fastautomag1',,, R.Location, R.Rotation);
R.Destroy();
}
Log( "Replacing ASMDs" );
ForEach AllActors( class'ASMD', A )
{
Spawn( class'Uber2.AmpedASMD',,, R.Location, R.Rotation);
R.Destroy();
}
}
function bool IsRelevant(actor Other)
{
// hide all playerpawns
if ( Other.IsA('PlayerPawn') && !Other.IsA('Spectator') )
{
Other.SetCollision(false,false,false);
Other.bHidden = true;
}
return Super.IsRelevant(Other);
}
function float PlaySpawnEffect(inventory Inv)
{
Playsound(sound'RespawnSound');
if ( !bCoopWeaponMode || !Inv.IsA('Weapon') )
{
spawn( class 'ReSpawn',,, Inv.Location );
return 0.3;
}
return 0.0;
}
event playerpawn Login
(
string Portal,
string Options,
out string Error,
class<playerpawn> SpawnClass
)
{
local PlayerPawn NewPlayer;
local string InName, InPassword;
local pawn aPawn;
NewPlayer = Super.Login(Portal, Options, Error, SpawnClass);
if ( NewPlayer != None )
{
if ( !NewPlayer.IsA('Spectator') )
{
NewPlayer.bHidden = false;
NewPlayer.SetCollision(true,true,true);
}
log("Logging in to "$Level.Title);
if ( Level.Title ~= "The Source Antechamber" )
{
bSpecialFallDamage = true;
log("reduce fall damage");
}
}
return NewPlayer;
}
function NavigationPoint FindPlayerStart( byte Team, optional string incomingName )
{
local PlayerStart Dest, Candidate[8], Best;
local float Score[8], BestScore, NextDist;
local pawn OtherPlayer;
local int i, num;
local Teleporter Tel;
num = 0;
//choose candidates
foreach AllActors( class 'PlayerStart', Dest )
{
if ( (Dest.bSinglePlayerStart || Dest.bCoopStart) && !Dest.Region.Zone.bWaterZone )
{
if (num<4)
Candidate[num] = Dest;
else if (Rand(num) < 4)
Candidate[Rand(4)] = Dest;
num++;
}
}
if (num>4) num = 4;
else if (num == 0)
return None;
//assess candidates
for (i=0;i<num;i++)
Score[i] = 4000 * FRand(); //randomize
foreach AllActors( class 'Pawn', OtherPlayer )
{
if (OtherPlayer.bIsPlayer)
{
for (i=0;i<num;i++)
{
NextDist = VSize(OtherPlayer.Location - Candidate[i].Location);
Score[i] += NextDist;
if (NextDist < OtherPlayer.CollisionRadius + OtherPlayer.CollisionHeight)
Score[i] -= 1000000.0;
}
}
}
BestScore = Score[0];
Best = Candidate[0];
for (i=1;i<num;i++)
{
if (Score[i] > BestScore)
{
BestScore = Score[i];
Best = Candidate[i];
}
}
return Best;
}
function int ReduceDamage(int Damage, name DamageType, pawn injured, pawn instigatedBy)
{
if ( bNoFriendlyFire && (instigatedBy != None)
&& instigatedBy.bIsPlayer && injured.bIsPlayer && (instigatedBy != injured) )
return 0;
if ( (DamageType == 'Fell') && bSpecialFallDamage )
return Min(Damage, 5);
return Super.ReduceDamage(Damage, DamageType, injured, instigatedBy);
}
function bool ShouldRespawn(Actor Other)
{
if ( Other.IsA('Weapon') && !Weapon(Other).bHeldItem && (Weapon(Other).ReSpawnTime != 0) )
{
Inventory(Other).ReSpawnTime = 1.0;
return true;
}
return false;
}
function SendPlayer( PlayerPawn aPlayer, string URL )
{
// hack to skip end game in coop play
if ( left(URL,6) ~= "endgame")
{
Level.ServerTravel( "Vortex2", false);
return;
}
Level.ServerTravel( URL, true );
}
function PlayTeleportEffect( actor Incoming, bool bOut, bool bSound)
{
}
function Killed(pawn killer, pawn Other, name damageType)
{
super.Killed(killer, Other, damageType);
if ( (Killer != None) && (Other.bIsPlayer || Other.IsA('Nali')) )
killer.PlayerReplicationInfo.Score -= 2;
}
function AddDefaultInventory( pawn PlayerPawn )
{
local Translator newTranslator;
if ( Level.DefaultGameType != class'VRikersGame' )
Super.AddDefaultInventory(PlayerPawn);
// Spawn translator.
if( PlayerPawn.IsA('Spectator') || PlayerPawn.FindInventoryType(class'Translator') != None )
return;
newTranslator = Spawn(class'Translator',,, Location);
if( newTranslator != None )
{
newTranslator.bHeldItem = true;
newTranslator.GiveTo( PlayerPawn );
PlayerPawn.SelectedItem = newTranslator;
newTranslator.PickupFunction(PlayerPawn);
}
}
|
Pretty much normal co-op code merged with the
TerranWeaponMatch code from Upak (that replaces the weapons).
And, in case this helps:
Code: |
C:\UnrealGold\System\Unreal.exe nyleve?game=UberCoop.UberCoopGame?difficulty=3 -server
|
^^My shortcut thing to start up the server (using this gametype)
And a couple log pictures to prove that it loaded.
I belive the script logs are from the 'log' command :p
And the 'accesed none' ... maybe cause a certain gun wasnt in the level?
http://img141.imageshack.us/my.php?image=serverthang5sf.jpg
http://img134.imageshack.us/my.php?image=serverthang27ao.jpg
(I blurred out IPs, computer information, and whatnot. just in case any hackers come visit.)
But, thanks if you can help, which will probably be yes and it will probably just be some dum mistake like a 'syntax error' :p
btw i've never really scripted before, besides one VERY simple item (uber 2 health regenerator) so please, cut me some slack :p _________________
|
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
Posted: Wed Apr 26, 2006 2:39 pm Post subject: |
|
|
u dont need to make a new gametype, make an new mutator
here is the replacer from SRwep2:
Code: | var(SRweps2Mutator) class<inventory> OldAmmo[32],NewAmmo[32],OldWep[20],NewWep[20],OldPick[10],NewPick[10];
function PostBeginPlay()
{
local int ToSpawn;
local weapon OW;
local Pickup OP;
local ScriptedPawn SP;
local Decoration DN;
local health OH;
local ammo OA;
local inventory OI;
local int i,j;
local inventory allOW[128];
local ScriptedPawn AllP[64];
local Decoration AllDeco[64];
Super.PostBeginPlay();
foreach allactors(class'ammo',OA)
{
for(i=0;i<32;i++)
{
if(OA.class==OldAmmo[i])
{
if(NewAmmo[i]!=None)
{
spawn(NewAmmo[i],,,OA.location);
OA.Destroy();
}
}
}
}
foreach allactors(class'weapon',OW)
{
for(i=0;i<20;i++)
{
if(OW.class==OldWep[i])
{
if(NewWep[i]!=None)
{
spawn(NewWep[i],,,OW.location);
OW.Destroy();
}
}
}
}
foreach allactors(class'Pickup',OP)
{
for(i=0;i<10;i++)
{
if(OP.class==OldPick[i])
{
if(NewPick[i]!=None)
{
spawn(NewPick[i],,,OP.location);
OP.Destroy();
}
}
}
}
}
|
u may use it if ya want. i think the var names say all but if u have questions jsut say ;)
so make a new mutator, example: Uber2.replacer
C:\UnrealGold\System\Unreal.exe nyleve?mutator=Uber2.replacer?difficulty=3 -server
and ur done ;)
but this CAN make an problem when items are "inside" decorations that get spawned once you shoot them.
to ways to fix that:
1. Forloop trough all deco's finding the "insides".
2. run the above script on tick event.
SR
EDIT: this script does all what yours do if i see it.
if you also what that mine script logs all then u will only need to add 3 lines _________________ Before asking, try the Unreal wiki here.
------------------------------
New UT3 Community site. |
|
Back to top |
|
|
[B@D]Thug
Joined: 07 Oct 2005 Posts: 315
|
Posted: Wed Apr 26, 2006 9:36 pm Post subject: |
|
|
SoulReaver wrote: | u dont need to make a new gametype, make an new mutator
here is the replacer from SRwep2:
Code: | var(SRweps2Mutator) class<inventory> OldAmmo[32],NewAmmo[32],OldWep[20],NewWep[20],OldPick[10],NewPick[10];
function PostBeginPlay()
{
local int ToSpawn;
local weapon OW;
local Pickup OP;
local ScriptedPawn SP;
local Decoration DN;
local health OH;
local ammo OA;
local inventory OI;
local int i,j;
local inventory allOW[128];
local ScriptedPawn AllP[64];
local Decoration AllDeco[64];
Super.PostBeginPlay();
foreach allactors(class'ammo',OA)
{
for(i=0;i<32;i++)
{
if(OA.class==OldAmmo[i])
{
if(NewAmmo[i]!=None)
{
spawn(NewAmmo[i],,,OA.location);
OA.Destroy();
}
}
}
}
foreach allactors(class'weapon',OW)
{
for(i=0;i<20;i++)
{
if(OW.class==OldWep[i])
{
if(NewWep[i]!=None)
{
spawn(NewWep[i],,,OW.location);
OW.Destroy();
}
}
}
}
foreach allactors(class'Pickup',OP)
{
for(i=0;i<10;i++)
{
if(OP.class==OldPick[i])
{
if(NewPick[i]!=None)
{
spawn(NewPick[i],,,OP.location);
OP.Destroy();
}
}
}
}
}
|
u may use it if ya want. i think the var names say all but if u have questions jsut say ;)
so make a new mutator, example: Uber2.replacer
C:\UnrealGold\System\Unreal.exe nyleve?mutator=Uber2.replacer?difficulty=3 -server
and ur done ;)
but this CAN make an problem when items are "inside" decorations that get spawned once you shoot them.
to ways to fix that:
1. Forloop trough all deco's finding the "insides".
2. run the above script on tick event.
SR
EDIT: this script does all what yours do if i see it.
if you also what that mine script logs all then u will only need to add 3 lines |
You may have just taught me something soul... Thankyou. _________________ Improvements along the way friends and foes.
WebSite:www.freewebs.com/agressivetoys |
|
Back to top |
|
|
Zombie
Joined: 27 Jan 2004 Posts: 295
|
Posted: Wed Apr 26, 2006 11:14 pm Post subject: |
|
|
SoulReaver is right in that you don't need to make a new GameType in order to replace things. Make a replace mutator by subclassing the Mutator class. In doing things that way you can still run a different GameType. Plus, it is faster and more optimal if replacing was done in Mutator.CheckReplacement() too because actors are passed to that function when they spawn. Running ForEach iterators to find everything is much slower and it only works one time (at level start) unless you perform the checks on a constant Timer().
Code: | function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
if (Other.Class == Class'OriginalInvClassOne')
{
ReplaceWith(Other, "SomeInvPackage.SomeInvClassOne");
return False; // Tells the actor in that pass to destroy.
}
else if (Other.Class == Class'OriginalInvClassTwo')
{
ReplaceWith(Other, "SomeInvPackage.SomeInvClassTwo");
return False; // Tells the actor in that pass to destroy.
}
// Etc..Etc..
return True; // Always True outside of any inner expressions at end.
} |
-Zombie _________________ GameType: JCoopZ1 - Build137 (11/30/12)
Mutator: DZMapM - 2.34 (12/15/11) |
|
Back to top |
|
|
Cheese
Joined: 30 Mar 2006 Posts: 79 Location: ...YES
|
Posted: Fri Apr 28, 2006 1:55 am Post subject: |
|
|
Alright, thanks much!
But, I have a couple more questions.
1: How can you make them be edited in a .ini (example, DZMap uses an .ini
to change settings and whatnot)
2: I made it, I guess.. One problem, enemies like samain drop the weapon and
don't use it, and when you grab it, it respawns (after being dropped by an enemy) How can I fix that? _________________
|
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
|
Back to top |
|
|
Cheese
Joined: 30 Mar 2006 Posts: 79 Location: ...YES
|
Posted: Fri Apr 28, 2006 8:38 pm Post subject: |
|
|
I mean, how to make some settings appear in the DefaultSettings
Like that,
And how to make the settings editable in a .ini file or a .int file.
And you know how some enemies carry weapons?
They immediately drop the weapon and can't attack you.
And the weapon respawns (like a normal one placed in the level)
After the enemies drop it.
Example: Samain (an enemy) uses the flak cannon, okay?
Once the mutator is used, she drops it, and can't shoot (she has no gun)
When you go to pick up the gun, it acts like a summoned gun
or one placed in the level, it respawns.
EDIT: Alright I made one that's working so far, but it only replaces health
and fruit.
btw, i'm using zombie's code, but only because it's less typing, and quite a bit
less confusing. :p besides, they're basically the same thing :p _________________
|
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
|
Back to top |
|
|
Cheese
Joined: 30 Mar 2006 Posts: 79 Location: ...YES
|
Posted: Sat Apr 29, 2006 8:47 pm Post subject: |
|
|
Sorry SR, it's not that I don't like your code, it's just that zombie's was less
confusing to read :p
But anyways, I found out how to put things in the advanced options
(I was coming here to post that :p) Sorry again, SR..
But I think there is something you can help me in:
How to put something in the advanced options to a .int:
Code: |
//=============================================================================
// UberMut.
//=============================================================================
class UberMut expands Mutator;
var() string Gun1,
Gun2,
Gun3,
Gun4,
Gun5,
Gun6,
Gun7,
Gun8,
Gun9,
Gun0;
function Postbeginplay()
{
Log( "UberMut Beta mutator is loading.." );
}
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
if (Other.Class == Class'DispersionPistol')
{
ReplaceWith(Other, Gun1);
return False;
}
else if (Other.Class == Class'Automag')
{
ReplaceWith(Other, Gun2);
return False;
}
else if (Other.Class == Class'Stinger')
{
ReplaceWith(Other, Gun3);
return False;
}
else if (Other.Class == Class'ASMD')
{
ReplaceWith(Other, Gun4);
return False;
}
else if (Other.Class == Class'Eightball')
{
ReplaceWith(Other, Gun5);
return False;
}
else if (Other.Class == Class'FlakCannon')
{
ReplaceWith(Other, Gun6);
return False;
}
else if (Other.Class == Class'RazorJack')
{
ReplaceWith(Other, Gun7);
return False;
}
else if (Other.Class == Class'GESBioRifle')
{
ReplaceWith(Other, Gun8);
return False;
}
else if (Other.Class == Class'Rifle')
{
ReplaceWith(Other, Gun9);
return False;
}
else if (Other.Class == Class'Minigun')
{
ReplaceWith(Other, Gun0);
return False;
}
return True;
}
|
The Gun1-0's are in the DefaultProperties now..
(You put the class you want to replace in the DefaultProperties
ex. in Gun1|UnrealI.Flakcannon etc)
Can you tell me what I need to have in the .int or .ini
to edit these? _________________
|
|
Back to top |
|
|
Zombie
Joined: 27 Jan 2004 Posts: 295
|
Posted: Sun Apr 30, 2006 12:50 am Post subject: |
|
|
You're doing good so far. Now if you want to optimize your mutator some more so that less 'if' statments are processed per pass then you can nest it all inside one if statement.
Code: | function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
if (Other.IsA('Inventory')) // If 'Other' is a Inventory...
{
// All of your current uscript here.
}
return True;
} |
For your gun variables you can use an array of those instead. You'd do so like this:
var() string Gun[ArraySize];
When you use them in your uscript you'd need to include the index.
Gun[#]
To make your mutator class use its own INI and configurable variables:
class UberMut expands Mutator(UberMut);
var() config string Gun[ArraySize];
-Zombie _________________ GameType: JCoopZ1 - Build137 (11/30/12)
Mutator: DZMapM - 2.34 (12/15/11) |
|
Back to top |
|
|
Cheese
Joined: 30 Mar 2006 Posts: 79 Location: ...YES
|
Posted: Fri May 05, 2006 11:15 pm Post subject: |
|
|
Alright, sounds confusing.
Okay, I'll try to figure this out/do this.
About the .ini... I'll look at saber.u to figure it out :p _________________
|
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
Posted: Sat May 06, 2006 10:38 am Post subject: |
|
|
cant u use a switch to make it faster and better::
Code: | function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
switch (Other.Class)
{
case Class'DispersionPistol':
ReplaceWith(Other, Gun1);
break;
case Class'Automag':
ReplaceWith(Other, Gun2);
break;
case Class'Stinger':
ReplaceWith(Other, Gun3);
break;
case Class'ASMD':
ReplaceWith(Other, Gun4);
break;
case Class'Eightball':
ReplaceWith(Other, Gun5);
break;
case Class'FlakCannon':
ReplaceWith(Other, Gun6);
break;
case Class'RazorJack':
ReplaceWith(Other, Gun7);
break;
case Class'GESBioRifle':
ReplaceWith(Other, Gun8);
break;
case Class'Rifle':
ReplaceWith(Other, Gun9);
break;
case Class'Minigun':
ReplaceWith(Other, Gun0);
break;
default return True;
}
return false;
} |
_________________ Before asking, try the Unreal wiki here.
------------------------------
New UT3 Community site. |
|
Back to top |
|
|
Zombie
Joined: 27 Jan 2004 Posts: 295
|
Posted: Sat May 06, 2006 12:35 pm Post subject: |
|
|
Using case statements is a better practice when the condition will be for several of a type. Just don't use them with a string condition because it's incompatible with 224.
-Zombie _________________ GameType: JCoopZ1 - Build137 (11/30/12)
Mutator: DZMapM - 2.34 (12/15/11) |
|
Back to top |
|
|
SoulReaver
Joined: 15 May 2004 Posts: 162
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|