Results 1 to 29 of 29

Thread: Script Help?

  1. #1
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default Script Help?

    Hello all. I have a bit of code That i've been trying to get working. It's supposed to display a message after pressing the button 'c'. This first bit of code is from an interaction subclass i made.

    function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta)
    {
    Local Controller C ;
    if ((Action == IST_Press) && (Key == IK_C))
    //ViewportOwner.Actor.ReceiveLocalizedMessage(class' MSG_Artillery', 1);//ClientMessage("Key PRESSED:" @ Key);
    Howitzer.DisplayMessages(C);
    //Howitzer.SetActiveWeapon(1);

    return false;

    }

    the part with the viewportowner works. I'm trying to tell the computer that if 'c' is pressed, open up the script that resides in 'howitzer', yet it won't. here is what i WANT it to call:

    exec Function DisplayMessages(Controller C)
    {
    if (PlayerController(C) != None && Vehicle(C.Pawn) != None)
    {
    PlayerController(C).ReceiveLocalizedMessage(class' MSG_Artillery', 1);
    //LastBeepTime = Level.TimeSeconds;
    }
    }

    it doesn't work though. Does anyone know what to do? thanks for the help!

  2. #2

    Default

    That code looks wrong on many levels. For example, why declare an exec function with a parameter that could never be passed in from a key press or console command? Or why declare a local variable that is never assigned before being passed to a function call?

    Let's try figuring this out from the start. Why do you want the C key specifically? Do you want to call the function when the user presses what would be the crouch key? And what kind of vehicle would that be? One you created or some already existing vehicle?
    If you are trying to perform some action when the player presses the crouch key while driving your vehicle, I recommend doing it similar to the Manta's jump/duck feature. Onslaught.ONSHoverBike (that's the Manta's class name) calls the function CheckJumpDuck() from its Tick() event. That function evaluates the Rise variable, which stores player input for the vertical movement axis, i.e. whether the player currently presses the jump or duck key. Depending on whether the player presses any of those keys, the Manta either performs a jump or tries to duck. Have a look at that code and decide whether that might be more suited for what you want to do.
    Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives

    <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
    <TNSe> nono
    <TNSe> its always funny to find code a week later you dont even remember writing
    <Pfhoenix> what's worse is when you have a Star Wars moment
    <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
    Note that your questions via PMs will be ignored if they actually belong in the forum.

  3. #3
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Hi Wormbo, Thanks for replying. First off, I'm trying to learn how to do things with unreal script, as you can tell by the bad coding i previously started with. I've searched all over the wiki, which is somewhat frustrating because I sometimes don't find what I'm looking for, or whenever I DO find something, it requires a more advanced understanding of the language.

    I chose the C key from an ambiguous lot of keys; just a random choice, that is all. About the vehicle: i've put together the SPMA cannon on the Goliath Tank's body, which works very well. The issue is that I want to get the beast to switch projectiles when I press a button, so I can keep the Mortar-Camera Functionality. I.E.: If it launches a shell that splits, after I press a button it switches to a shell that (toasts bread, so to speak). Alot of weapons use the alt-fire as an operator to switch ammotypes, which is dandy, but not what I'm trying to achieve. Does all of this make any sense? I just got done with a hellish week of finals, and I still have two left. As if 4 wasn't enough...

  4. #4
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Try this (in your vehicle):
    Code:
    simulated function SomeFunctionToChangeAmmo()
    {
    	// write your change ammo code here...
    }
    
    exec simulated function ChangeAmmo()
    {
    	SomeFunctionToChangeAmmo();
    }
    Now, only you need is bind some button to ChangeAmmo and replication stuff.
    Last edited by VendorX; 12-10-2011 at 02:57 PM.

  5. #5
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Thanks VendorX. Right now, i'm just trying to see if i can get the localized message to work. I'm having some hard time trying to get a grip on type casting. because inside the interaction that i've made, it states that if i press the 'I' key, it'll call a script that broadcasts a message (this message is just letting me know that the script that i've made between the interaction works, and will be used for the switching of ammo types.).


    I've looked through some things, and my log file says "Warning: Switchshell Package.Switchshell (Function Artillery.Switchshell.KeyEvent:0028) Accessed None 'MYTANK'" each time I press the button that calls a script (I changed it to 'I'). I'm not sure what the issue is, but here's the script:

    Code:
    Class Switchshell extends Interaction
    		config(user);
     var float LastBeepTime;
     Var int iWeapon;
     Var ONSTankArtillery MYTANK;
     Var bool bPressed;
    Function Initialize()
    {
        Log("Interaction Initialized");
    }
    
    
    function PostBeginPlay()
    {
        Super.PostBeginPlay();
       
    }
    
    function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta)
    {
    
    	if ((Action == IST_Press) && (Key == IK_I))
    		{
    		bPressed = true;
    						MYTANK.DisplayMessage();
    		ViewportOwner.Actor.ClientMessage("Key PRESSED:" @ Key);
    		iWeapon++;
    		if (iWeapon >= 2)
    		{
    			iWeapon = 0;
    			if (iWeapon == 0)
    				{
    				
    
    				//ReceivelocalizedMessage(class'MSG_Artillery', 2);
    				//Howitzer.IWeapon = IWeapon;
    				}
    				
    		}
    		
     }
     
     if ((Action == IST_Release) && (Key == IK_I))
     {
     bPressed = false;
     }
    	return false;
    	
    }
    
    DefaultProperties
    {
    bActive=True
    }
    Last edited by 1Lt Coagulator; 12-11-2011 at 02:26 AM.

  6. #6
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    This error point to:
    Code:
    ...
    MYTANK.DisplayMessage();
    ...
    'MYTANK' is None, None don't have DisplayMessage...
    You have:
    Code:
    ...
    Var ONSTankArtillery MYTANK;
    ...
    OK, but first you need setup that var, then you can call it...
    ...and this:
    Code:
    ...
    			iWeapon = 0;
    			if (iWeapon == 0)
    
    ...
    ...is wrong. Your 'if (iWeapon == 0)' has no sense, because of 'iWeapon = 0;' just before.

    Ps: why you stick with interaction? My example is betther... You can bind whenever button you like.
    Last edited by VendorX; 12-11-2011 at 01:12 PM.

  7. #7
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Thanks again. Setting up the variable is my issue. Each time I try:

    MYTANK = ONSTankArtillery; it says "bad or missing expression in =".

    I know something else has to be added to this line, but i'm not sure what. I'm also using the interaction because I keep screwing something up whenever I try to do keybinds . It's probably really simple, but i just can't figure it out .

  8. #8

    Default

    That's because "MYTANK = ONSTankArtillery;" doesn't make sense. It'd mean "assign value of variable 'ONSTankArtillery' to variable 'MYTANK'".
    Wormbo's UT/UT2004/UT3 mods | PlanetJailbreak | Unreal Wiki | Liandri Archives

    <elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
    <TNSe> nono
    <TNSe> its always funny to find code a week later you dont even remember writing
    <Pfhoenix> what's worse is when you have a Star Wars moment
    <Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
    Note that your questions via PMs will be ignored if they actually belong in the forum.

  9. #9
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    I know it doesn't make sense, but I don't know what to do, or how to do it in this case. i'm at a roadblock.

  10. #10
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Tell me, where your Interaction 'came to life'..?

  11. #11
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    I'm not sure if I understand your question... where did it start to work? what was the idea? I found it on the wiki, and used it as a certain way to trigger my hopeful script that doesn't work...

    Anyway, i was able to fix the problem somewhat, but now nothing happens at all. Any remarks?? What i've added is in red


    EDIT: I was able to get a keybind to work! so, now my problem still lies in variables, and typecasting (i think.) here's the snippet (red):

    Code:
    class PulseShell extends Projectile;
    
    //#exec TEXTURE  IMPORT NAME=NewFlakSkin FILE=textures\jflakslugel1.bmp GROUP="Skins" DXT=5
    
    var	emitter trail;
    var actor Glow;
    var class<Emitter> ExplosionEffectClass;
    var class<Emitter> AirExplosionEffectClass;
    var bool bExploded;
    var bool bsplit;
    var Actor HomingTarget;
    
    var vector InitialDir;
    //var int Iweapon;
    Var OnsTankArtillery Tank;
    simulated function PostBeginPlay()
    {
    	local Rotator R;
    	local PlayerController PC;
    
    	if ( !PhysicsVolume.bWaterVolume && (Level.NetMode != NM_DedicatedServer) )
    	{
    		PC = Level.GetLocalPlayerController();
    		if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 6000 )
    			Trail = Spawn(class'NEWTRAILEFFECT',self);
    		Glow = Spawn(class'FlakGlow', self);
    	}
    
    	Super.PostBeginPlay();
    	R = Rotation;
    	R.Roll = 32768;
    	SetRotation(R);
    }
    
    simulated function StartTimer(float Fuse)
    {
        SetTimer(Fuse, False);
    }
    
    simulated function Timer()
    {
        local int i;
        local ONSArtilleryShellSmall SmallShell;
    	Tank = ONSTankArtillery.IWeapon;
    	
    	if (Tank.iweapon == 0){	PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    	if ( Level.NetMode != NM_DedicatedServer )
    		spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);}
    	
    
    if (Tank.iweapon == 1){	PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    	if ( Level.NetMode != NM_DedicatedServer )
    		spawn(class'PULSESHELL', self, , Location, Rotation);}
        for (i=0; i<8; i++)
        {
            SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    		if ( SmallShell != None )
    			SmallShell.Velocity = Velocity + (VRand() * 500.0);
        }
        Destroy();
    }
    
    simulated function Destroyed()
    {
    	if ( !bExploded )
    		ExplodeInAir();
    	if ( Trail != None )
    		//Trail.mRegen=False;
    		Trail.Destroy();
    	if ( glow != None )
    		Glow.Destroy();
    	Super.Destroyed();
    
    
    }
    
    
    simulated function ProcessTouch(Actor Other, Vector HitLocation)
    {
    	if (Other != Instigator && !Other.IsA('PulseShell'))
    	{
            SpawnEffects(HitLocation, -1 * Normal(Velocity) );
    		Explode(HitLocation,Normal(HitLocation-Other.Location));
    	}
    }
    
    simulated function SpawnEffects( vector HitLocation, vector HitNormal )
    {
    	local PlayerController PC;
    
    	PlaySound(sound'ONSBPSounds.Artillery.ShellFragmentExplode', SLOT_None, 2.0);
    	if ( EffectIsRelevant(Location,false) )
    	{
    		PC = Level.GetLocalPlayerController();
    		if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 3000 )
    			spawn(ExplosionEffectClass,,,HitLocation + HitNormal*16 );
    		spawn(ExplosionEffectClass,,,HitLocation + HitNormal*16 );
    		spawn(class'RocketSmokeRing',,,HitLocation + HitNormal*16, rotator(HitNormal) );
    		if ( (ExplosionDecal != None) && (Level.NetMode != NM_DedicatedServer) )
    			Spawn(ExplosionDecal,self,,HitLocation, rotator(-HitNormal));
    	}
    }
    
    simulated function Landed( vector HitNormal )
    {
    	SpawnEffects( Location, HitNormal );
    	Explode(Location,HitNormal);
    }
    
    simulated function HitWall (vector HitNormal, actor Wall)
    {
    	Landed(HitNormal);
    }
    
    simulated function Explode(vector HitLocation, vector HitNormal)
    {
    	bExploded = true;
        HurtRadius(Damage, DamageRadius, MyDamageType, MomentumTransfer, HitLocation);
    
        Destroy();
    }
    
    simulated function ExplodeInAir()
    {
    	bExploded = true;
        PlaySound(sound'ONSBPSounds.Artillery.ShellFragmentExplode', SLOT_None, 2.0);
    	if ( Level.NetMode != NM_DedicatedServer )
    		spawn(AirExplosionEffectClass);
    
        Explode(Location, Location - Instigator.Location);
        Destroy();
    }
    
    event TakeDamage(int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType)
    {
        if (Damage > 0 && (EventInstigator == None || EventInstigator.Controller == None ||
                           Instigator == None || Instigator.Controller == None ||
                           !EventInstigator.Controller.SameTeamAs(Instigator.Controller)))
            ExplodeInAir();
    }
    
    defaultproperties
    {
        StaticMesh=StaticMesh'BIG****.BIG****'
        ExplosionDecal=class'ShockAltDecal'
    	bProjTarget=True
        Speed=4000.000000
        MaxSpeed=4000.0
    	ExplosionEffectClass=class'PulseExplosion'
    	AirExplosionEffectClass=class'ONSSmallVehicleExplosionEffect'
    	Damage=250.0
    	DamageRadius=660.0
        MomentumTransfer=575000
        bNetTemporary=False
        Physics=PHYS_Falling
        bIgnoreTerminalVelocity=True
        MyDamageType=class'DamTypeArtilleryShell'
        LifeSpan=17.000000
        DrawType=DT_StaticMesh
        DrawScale=2.5
        AmbientGlow=100
        SoundRadius=100
        SoundVolume=255
        ForceType=FT_Constant
        ForceScale=5.0
        ForceRadius=60.0
        CullDistance=+10000.0
        bOrientToVelocity=True
        CollisionRadius=0
        CollisionHeight=0
        AmbientSound=sound'ONSBPSounds.Artillery.ShellAmbient'
    }

    it keeps saying that there is a bad/missing expression in "=". it's obviously the "tank =...". I want to somehow connect the tank's integer "Iweapon" to this projectile's. that way, when "Iweap = 0", it does something, and the same applies for it being 1. any remarks?? help is much appreciated.
    Last edited by 1Lt Coagulator; 12-13-2011 at 04:37 AM.

  12. #12
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Organisation... This is your problem.
    Look, the same red code...
    Code:
    simulated function Timer()
    {
    	local int i;
    	local ONSArtilleryShellSmall SmallShell;
    	local ONSTankArtillery Tank;
    
    	Tank = ONSTankArtillery(Owner);//ONSTankArtillery.IWeapon;
    	
    	if (Tank.iweapon == 0)
    	{
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);
    	}
    	
    
    	if (Tank.iweapon == 1)
    	{
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'PULSESHELL', self, , Location, Rotation);
    	}
    
    	for (i=0; i<8; i++)
    	{
    		SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    
    		if ( SmallShell != None )
    			SmallShell.Velocity = Velocity + (VRand() * 500.0);
    	}
    
    	Destroy();
    }
    On red is code that you missed.

  13. #13
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Thanks. I'm still getting an accessed none for 'tank'.

    Code:
    Warning: PulseShell ONS-Torlan.PulseShell (Function Artillery.PulseShell.Timer:001A) Accessed None 'Tank'
    I changed up some of the code this time, adding the tank.iweapon to the for (i=0; i<8, i++) part, so that if iweap=0 it does something, and if iweap=1 it spawns something else.

    Code:
    simulated function Timer()
    {
    	local int i;
    	local ONSArtilleryShellSmall SmallShell;
    	local PulseShell SmallShell2;
    	local ONSTankArtillery Tank;
    
    	Tank = ONSTankArtillery(Owner);//ONSTankArtillery.IWeapon;
    	
    	if (Tank.iweapon == 0)
    	{
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);
    	}
    	
    
    	if (Tank.iweapon == 1)
    	{
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'PULSESHELL', self, , Location, Rotation);
    	}
    
    	for (i=0; i<8; i++)
    	{
    		if (Tank.iweapon == 0)
    			{
    				SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    					if ( SmallShell != None )
    						SmallShell.Velocity = Velocity + (VRand() * 500.0);
    			}
    		else if (Tank.iweapon != 0)
    			{	
    				SmallShell2 = spawn(class'PulseShell', self, , Location, Rotation);
    					if ( SmallShell2 != None )
    						SmallShell2.Velocity = Velocity + (VRand() * 500.0);
    			}
    	}
    
    	Destroy();
    }
    i have a feeling i'm getting really close to a solution, but i still don't know what's causing me to get "accessed none"...

  14. #14
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    have a feeling i'm getting really close to a solution, but i still don't know what's causing me to get "accessed none"...
    Because Owner is None or is not a ONSTankArtillery. This was jus example how to do this...

    Think... If this is Projectile then Owner is a Weapon, in Weapon Owner is a Pawn - ONSTankArtillery.

    Place `log("***Timer.Owner"@Owner); before 'Tank = ONSTankArtillery(Owner)' and post log.

  15. #15
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    thank you for your patience !
    here's the log


    edit:

    i've fixed the accessed none issue. I used this here, and i've made a log (son1, 1.1, 2, 2.2) to show if it's working right:

    Code:
    local int i;
    	local ONSArtilleryShellSmall SmallShell;
    	local PulseShell SmallShell2;
    	local ONSTankArtilleryCannon Tank;
    
    log("***Timer.Owner"@Owner);	Tank = ONSTankArtilleryCannon(owner);//ONSTankArtillery.IWeapon;
    	
    	if (Tank.iweapon == 0)
    	{
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    log("***SON1***");
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);
    	}
    	
    
    	if (Tank.iweapon == 1)
    	{
    	log("***SON2***");
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'PULSESHELL', self, , Location, Rotation);
    	}
    
    	for (i=0; i<8; i++)
    	{
    		if (Tank.iweapon == 0)
    			{log("***SON1.1***");
    				SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    					if ( SmallShell != None )
    						SmallShell.Velocity = Velocity + (VRand() * 500.0);
    			}
    		else if ((Tank.iweapon != 0) && (Tank.Iweapon == 1))
    			{	log("***SON2.2***");
    				SmallShell2 = spawn(class'PulseShell', self, , Location, Rotation);
    					if ( SmallShell2 != None )
    						SmallShell2.Velocity = Velocity + (VRand() * 500.0);
    			}
    	}
    the log is returning this:
    Code:
    ScriptLog: ***Timer.Owner ONS-Torlan.ONSTankArtilleryCannon
    ScriptLog: ***SON1***
    ScriptLog: ***SON1.1***
    For some odd reason, this thing isn't working out. Here is the code from the EXEC function (don't hate the name):

    Code:
    exec function KillerSUCK()
    {
    if (bDriving)
    {
    		iWeapon += 1;
    		if (iWeapon >= 2)
    		{
    			iWeapon = 0;
    		}
    			if (iWeapon == 0)
    				{
    				if (PlayerController(Controller) != None)
    		PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',2);//standard bombs
    				}
    			if (iWeapon != 0)
    				{
    				log("***IWeapon"@IWeapon);	
    				log("***TANK SCRIPTED AMMO CHANGE***");
    				if (PlayerController(Controller) != None)
    		PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',1); //pulsebombs
    				}
    				
    		}
    		
    else if (!bdriving)
    	{log("Not Driving");
    	iWeapon = 0;
    	}
    }
    it is supposed to be logging son 2 and 2.2, but for some reason, the integer won't change itself permanently to 1, or something. idk whynot.
    Last edited by 1Lt Coagulator; 12-13-2011 at 10:35 PM.

  16. #16
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Code:
    exec function KillerSUCK()
    {
    	if (bDriving)
    	{
    		iWeapon ++;//+= 1; <- is the same
    
    		if (iWeapon >= 2)
    			iWeapon = 0;
    
    		if (iWeapon == 0)
    		{
    			if (PlayerController(Controller) != None)
    				PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',2);//standard bombs
    		}
    
    		else//if (iWeapon != 0) <- is already
    		{
    			log("***IWeapon"@IWeapon);	
    			log("***TANK SCRIPTED AMMO CHANGE***");
    			if (PlayerController(Controller) != None)
    				PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',1); //pulsebombs
    		}
    				
    	}
    	else// if (!bdriving) <- don't need this, bDriving is already False
    	{
    		log("Not Driving");
    		iWeapon = 0;
    	}
    }
    it is supposed to be logging son 2 and 2.2, but for some reason, the integer won't change itself permanently to 1, or something. idk whynot.
    ...it can... Look, at the end of KillerSUCK you set iWeapon = 0, then in the beginning you pushed iWeapon to += 1. Thats mean, already in first check ('if (iWeapon == 0)') iWeapon = 1.
    You can setup 'iWeapon = -1' in else at end of script... But if you not driving (bdriving = False) you can't exec function KillerSUCK (will not be called...)

    Try this:
    Code:
    exec function KillerSUCK()
    {
    	if (bDriving)
    	{
    		if (iWeapon == 0)
    		{
    			log("***iWeapon == 0");
    			if (PlayerController(Controller) != None)
    				PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',2);//standard bombs
    		}
    		else
    		{
    			log("***iWeapon != 0"@IWeapon);	
    			if (PlayerController(Controller) != None)
    				PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',1); //pulsebombs
    		}
    				
    	}
    
    	iWeapon ++;
    
    	if (iWeapon >= 2)
    		iWeapon = 0;
    }

  17. #17
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Much Appreciated. I Implemented the Code you had posted above. Here's the new Timer() script from pulseshell.uc. this is what I'm trying to get to change when iWeapon does:

    Code:
    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------
    class PulseShell extends Projectile
    config(user);
    
    //#exec TEXTURE  IMPORT NAME=NewFlakSkin FILE=textures\jflakslugel1.bmp GROUP="Skins" DXT=5
    
    var	emitter trail;
    var actor Glow;
    var class<Emitter> ExplosionEffectClass;
    var class<Emitter> AirExplosionEffectClass;
    var bool bExploded;
    var bool bsplit;
    var Actor HomingTarget;
    
    var vector InitialDir;
    var int iWeapon;
    Var OnsTankArtillery Tank;
    Var weapon ONSTankArtilleryCannon;
    Var int iWeapon;
    
    simulated function PostBeginPlay()
    {
    	local Rotator R;
    	local PlayerController PC;
    
    	if ( !PhysicsVolume.bWaterVolume && (Level.NetMode != NM_DedicatedServer) )
    	{
    		PC = Level.GetLocalPlayerController();
    		if ( (PC.ViewTarget != None) && VSize(PC.ViewTarget.Location - Location) < 6000 )
    			Trail = Spawn(class'NEWTRAILEFFECT',self);
    		Glow = Spawn(class'FlakGlow', self);
    	}
    
    	Super.PostBeginPlay();
    	R = Rotation;
    	R.Roll = 32768;
    	SetRotation(R);
    }
    
    
    
    simulated function StartTimer(float Fuse)
    {
        SetTimer(Fuse, False);
    }
    
    // NASTY ASS WORKAROUND??
    simulated function Timer()
    {
    	local int i;
    	local ONSArtilleryShellSmall SmallShell;
    	local PulseShell SmallShell2;
    	local ONSTankArtilleryCannon Tank;
    log("***Timer.Owner"@Owner);	
    Tank = ONSTankArtilleryCannon(owner);
    
    		PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    		if ( Level.NetMode != NM_DedicatedServer )
    			spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);
    for (i=0; i<8; i++)
    	{		
    		if (Tank.iWeapon == 0)
    			{
    				SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    					if ( SmallShell != None )
    						SmallShell.Velocity = Velocity + (VRand() * 500.0);
    				Log("Iweapon"@Tank.Iweapon);
    			}
    		if (Tank.iWeapon == 1)
    			{
    				Log("Iweapon"@Tank.Iweapon);
    				SmallShell2 = spawn(class'PulseShell', self, , Location, Rotation);
    					if ( SmallShell2 != None )
    						SmallShell2.Velocity = Velocity + (VRand() * 500.0);
    			}
    	}
    	Destroy();
    }
    .......
    
    defaultproperties
    {
     .........
    }
    the stuff in red is supposed to bridge the gap between pulseshell.uc and onstankartillery.uc. I did forget to put it in there. ill test it.

    and the log:
    Code:
    ScriptLog: ***iWeapon == 0
    ScriptLog: ***iWeapon != 0 1
    ScriptLog: ***Timer.Owner ONS-Torlan.ONSTankArtilleryCannon
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: ***iWeapon == 0
    ScriptLog: ***Timer.Owner ONS-Torlan.ONSTankArtilleryCannon
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: ***iWeapon != 0 1
    ScriptLog: ***Timer.Owner ONS-Torlan.ONSTankArtilleryCannon
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: ***iWeapon == 0
    ScriptLog: ***Timer.Owner ONS-Torlan.ONSTankArtilleryCannon
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    ScriptLog: Iweapon 0
    Since the Iteration of "iWeapon 0" keeps showing up, it means something isn't changing. ugh

    I'm going to see what i can do to get this to work. This is really frustrating.
    Last edited by 1Lt Coagulator; 12-14-2011 at 02:50 PM.

  18. #18
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Code:
    simulated function Timer()
    {
    	local int i;
    	local ONSArtilleryShellSmall SmallShell;
    	local PulseShell SmallShell2;
    	local ONSTankArtilleryCannon Tank;
    	
    	log("***Timer.Owner"@Owner);	
    	Tank = ONSTankArtilleryCannon(owner);
    
    	PlaySound(sound'ONSBPSounds.Artillery.ShellBrakingExplode');
    
    	if ( Level.NetMode != NM_DedicatedServer )
    		spawn(class'ONSArtilleryShellSplit', self, , Location, Rotation);
    
    	if (tank != none)
    		 iWeapon = tank.iWeapon;//tank.iWeapon = iWeapon;
    
    	if (iWeapon == 0)
    	{
    		for (i=0; i<8; i++)
    		{
    			Log("Iweapon"@Tank.Iweapon);
    			SmallShell = spawn(class'ONSArtilleryShellSmall', self, , Location, Rotation);
    			if ( SmallShell != None )
    				SmallShell.Velocity = Velocity + (VRand() * 500.0);
    		}
    
    		if (PlayerController(Controller) != None)
    			PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',3); //pulsebombs
    	}
    	else
    	{
    		for (i=0; i<8; i++)
    		{
    			Log("Iweapon"@Tank.Iweapon);
    			SmallShell2 = spawn(class'PulseShell', self, , Location, Rotation);
    			if ( SmallShell2 != None )
    				SmallShell2.Velocity = Velocity + (VRand() * 500.0);
    		}
    
    		if (PlayerController(Controller) != None)
    			PlayerController(Controller).ReceiveLocalizedMessage(class'MSG_Artillery',4); //pulsebombs
    	}					
    	Destroy();
    }
    ...now you see why?
    Put 'iWeapon = 0;' in DriverEnter - it will reset iWeapon to 0.
    Last edited by VendorX; 12-14-2011 at 02:56 PM.

  19. #19
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Yes i do now. That is what assigns iWeapon to the tank's iweapon, Yet, this script still doesn't work. btw, sorry if i come off as rude in this forum, for i don't mean for my words to give anyone that inflection.
    Last edited by 1Lt Coagulator; 12-14-2011 at 05:52 PM.

  20. #20
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Try put some logs around the iWeapon... Start in exec and look into log.

  21. #21
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    It's still not changing the iWeapon. It does change within the exec function, but inside the other uc file (pulseshell.uc, which DOESN'T have the exec function), it stays at 0. Maybe the fact that it's inside a timer function?

  22. #22
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    ...because iWeapon in ONSTankArtilleryCannon don't change...
    Code:
    	
    Tank = ONSTankArtilleryCannon(owner);
    ONSTankArtilleryCannon is a weapon not vehicle where you have exec function and where iWeapon is pushed...
    In that case you need:
    Code:
    // if Owner for ONSTankArtilleryCannon is a ONSTankArtillery.
    Tank = ONSTankArtillery(ONSTankArtilleryCannon(owner).Owner);
    ...or at end of exec setup iWeapon in ONSTankArtilleryCannon...

    Ps: post/upload your mod - i will try...
    Last edited by VendorX; 12-17-2011 at 08:27 AM.

  23. #23
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    It works now. This Is awesome. I can pm you a link (i'm not too sure if i want to release this or not, because it was just a project of mine). Thank you so much for your help. I do have one other question though: would you know how to move over a vehicle's gun using uscript? isn't it something like relativelocation or something in the default properties? I am trying to add two other guns on the back half of the goliath tank without using bones, because i can't get 3d models from unreal ed or anywhere else that i know of... They are literally hidden under the base of the main gun...

  24. #24
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    [Quote]
    ...
    isn't it something like relativelocation or something in the default properties?
    ...
    [Quote]
    ...it is.

  25. #25
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Thanks again.

    Now i've made it so that I have a linkable weapon (ill explain later) for a secondary weapon as well. the issue, is that i have on bone as mentioned above. I'm trying to recreat the second weapon, but with different coordinates than the first. How can I change the position? I know this is wrong, but here's what i made so far:

    Code:
                ONSArtillerySideGun(Weapons[2]).bSkipFire = True;
    			ONSArtillerySideGun(Weapons[2]).SetRelativeLocation(x=-53,y=-108,z=2,NewLocation);

  26. #26
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Look:
    Code:
    // SetRelativeRotation() sets the rotation relative to the actor's base
    native final function bool SetRelativeRotation( rotator NewRotation );
    native final function bool SetRelativeLocation( vector NewLocation );
    ...and you have:
    Code:
    ONSArtillerySideGun(Weapons[2]).SetRelativeLocation(x=-53,y=-108,z=2,NewLocation);
    ...should be:
    Code:
    ONSArtillerySideGun(Weapons[2]).SetRelativeLocation(vect(-53,-108,2));

  27. #27
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    awesome. thanks. I'm also having an issue with the linked weapon itself. I took the script from the cicada as a base, and now the issue is that both guns fire once, and then only the right gun fires. Here's the code:

    Code:
    class ONSArtillerySideGun extends ONSLinkableWeapon;
    
    #exec OBJ LOAD FILE=ONSBPTextures.utx
    #exec OBJ LOAD FILE=..\Animations\ONSWeapons-A.ukx
    
    var class<Projectile> TeamProjectileClasses[2];
    var float MinAim;
    
    //
    var bool bSkipFire;			// If true, it ignore this shot and pass it to it's linked weapon
    var bool bFiresRight;		// If true, this weapon will eject shells to the right instead of the left
    //
    
    function FireSingle(Controller C, bool bAltFire, optional bool bDontSkip)
    {
        if (!bSkipFire || bDontSkip)
        {
    		CalcWeaponFire();
    		if (bCorrectAim)
    			WeaponFireRotation = AdjustAim(false);
    
           	DualFireOffset *= -1;
    
    		Instigator.MakeNoise(1.0);
    
    	    if (bAltFire)
    	    {
    	    	FireCountdown = AltFireInterval;
    		    AltFire(C);
    		}
    		else
    		{
    			FireCountdown = FireInterval;
    			Fire(C);
    		}
    
    		AimLockReleaseTime = Level.TimeSeconds + FireCountdown * FireIntervalAimLock;
    	}
    	else
    	{
    	    FireCountdown = FireInterval;
    	}
    
    	bSkipFire = !bSkipFire;
    
    	if (ChildWeapon != none && ONSArtillerySideGun(ChildWeapon) != None)
            ONSArtillerySideGun(ChildWeapon).FireSingle(C, bAltFire, bDontSkip);
    
    }
    I'm going to look through this to see what I'm doing wrong.

  28. #28
    Banned
    Join Date
    Feb 2011
    Location
    BXL/Paris
    Posts
    2,169

    Default

    Code:
    function FireSingle(Controller C, bool bAltFire, optional bool bDontSkip)
    {
        if (!bSkipFire || bDontSkip)
        {
    	CalcWeaponFire();
    	if (bCorrectAim)
    	    WeaponFireRotation = AdjustAim(false);
    
           	DualFireOffset *= -1;
    
    	Instigator.MakeNoise(1.0);
    
    	if (bAltFire)
    	{
    	    FireCountdown = AltFireInterval;
    	    AltFire(C);
    	}
    	else
    	{
    	    FireCountdown = FireInterval;
    	    Fire(C);
    	}
    
    	AimLockReleaseTime = Level.TimeSeconds + FireCountdown * FireIntervalAimLock;
        }
        else
        {
    	FireCountdown = FireInterval;
        }
    
        bSkipFire = !bSkipFire;
    
        if (ChildWeapon != none && ONSArtillerySideGun(ChildWeapon) != None) //<- is called every time - right gun? shouldn't be in else..?
            ONSArtillerySideGun(ChildWeapon).FireSingle(C, bAltFire, bDontSkip);
    
    }
    From where is called FireSingle? ...From AttemptFire? Code - svp...
    If you want net replication - call Fire/AltFire in ChildWeapon is bad idea - use ClientStartFire...
    ...and what do you expect from this code?

  29. #29
    MSgt. Shooter Person
    Join Date
    Jul 2008
    Posts
    88

    Default

    Hi there. Sorry for the long-delayed reply, i've been busy with a minimester . anyway, here's a sample of what i've been working with (most up to date has custom skin that i'm NOT done with yet.)

    http://imageshack.us/g/651/shot00000zv.png/

    with that code, i want it to alternate fire between the left and right cannons. Here's the entire script, renamed 'TankDefWep'

    Code:
    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------
    class TankDefWep extends ONSLinkableWeapon;
    
    #exec OBJ LOAD FILE=ONSBPTextures.utx
    #exec OBJ LOAD FILE=..\Animations\ONSWeapons-A.ukx
    
    var Eleclines *****;
    
    var float MinAim;
    var class<Eleclines> EffectEmitterClass;
    //
    var bool bSkipFire;			// If true, it ignore this shot and pass it to it's linked weapon
    var bool bFiresRight;		// If true, this weapon will eject shells to the right instead of the left
    //
    var int bCharge;
    
    function FireSingle(Controller C, bool bAltFire, optional bool bDontSkip)
    {
        if (!bSkipFire || bDontSkip)
        {
    		CalcWeaponFire();
    		if (bCorrectAim)
    			WeaponFireRotation = AdjustAim(false);
    
           	DualFireOffset *= -1;
    
    		Instigator.MakeNoise(1.0);
    
    	    if (bAltFire)
    	    {
    	    	FireCountdown = AltFireInterval;
    		    AltFire(C);
    		}
    		else
    		{
    			FireCountdown = FireInterval;
    			Fire(C);
    		}
    
    		AimLockReleaseTime = Level.TimeSeconds + FireCountdown * FireIntervalAimLock;
    	}
    	else
    	{
    	    FireCountdown = FireInterval;
    	}
    
    	bSkipFire = !bSkipFire;
    
    	if (ChildWeapon != none && TankDefWep(ChildWeapon) != None)
            TankDefWep(ChildWeapon).FireSingle(C, bAltFire, bDontSkip);
    		
    
    }
    
    
    
    
    
    	
    	
    	
    	
    	//================
    simulated event FlashMuzzleFlash()
    {
        Super.FlashMuzzleFlash();
    	
    ***** = spawn(class'Eleclines');
    	
    	
     AttachToBone(*****, 'SideGunFirePointf');
    
    }
    
    
    
    
    static function StaticPrecache(LevelInfo L)
    {
        L.AddPrecacheMaterial(Material'XEffectMat.shock_mark_heat');
        L.AddPrecacheMaterial(Material'XEffectMat.shock_flash');
        L.AddPrecacheMaterial(Material'XEffectMat.purple_line');
        L.AddPrecacheMaterial(Material'XEffectMat.Shock_ring_a');
        L.AddPrecacheMaterial(Material'XWeapons_rc.ShockBeamTex');
        L.AddPrecacheMaterial(Material'XEffects.SaDScorcht');
        L.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_core_low');
        L.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_flare_a');
        L.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_core');
        L.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_Energy_green_faded');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Energy.EclipseCircle');
    	 L.AddPrecacheMaterial(Material'VMparticleTextures.TankFiringP.CloudParticleOrangeBMPtex');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.TracerShot');
    	    L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStarRed');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStar');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaHeadRed');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaHeadBlue');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.SmokePanels1');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStar2');
        L.AddPrecacheMaterial(Material'EpicParticles.Flares.FlashFlare1');
        L.AddPrecacheMaterial(Material'EmitterTextures.MultiFrame.rockchunks02');
        L.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaFlare');
    }
    
    simulated function UpdatePrecacheMaterials()
    {
        Level.AddPrecacheMaterial(Material'XEffectMat.shock_mark_heat');
        Level.AddPrecacheMaterial(Material'XEffectMat.shock_flash');
        Level.AddPrecacheMaterial(Material'XEffectMat.purple_line');
        Level.AddPrecacheMaterial(Material'XEffectMat.Shock_ring_a');
        Level.AddPrecacheMaterial(Material'XWeapons_rc.ShockBeamTex');
        Level.AddPrecacheMaterial(Material'XEffects.SaDScorcht');
        Level.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_core_low');
        Level.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_flare_a');
        Level.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_core');
        Level.AddPrecacheMaterial(Material'XEffectMat.Shock.shock_Energy_green_faded');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Energy.EclipseCircle');
    
        Level.AddPrecacheMaterial(Material'VMparticleTextures.TankFiringP.CloudParticleOrangeBMPtex');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.TracerShot');
    	 Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStarRed');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStar');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaHeadRed');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaHeadBlue');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.SmokePanels1');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaStar2');
        Level.AddPrecacheMaterial(Material'EpicParticles.Flares.FlashFlare1');
        Level.AddPrecacheMaterial(Material'EmitterTextures.MultiFrame.rockchunks02');
        Level.AddPrecacheMaterial(Material'AW-2004Particles.Weapons.PlasmaFlare');
    
        Super.UpdatePrecacheMaterials();
    }
    
    DefaultProperties
    {
        Mesh=Mesh'ONSBPAnimations.ArtillerySideGunMesh'
    	RedSkin=Texture'ONSBPTextures.Skins.SPMATan'
        BlueSkin=Texture'ONSBPTextures.Skins.SPMAGreen'
        YawBone=PassengerGunBase
        PitchBone=PassengerGunBarrel
        YawStartConstraint=0
        YawEndConstraint=65535
        PitchUpLimit=8000
        PitchDownLimit=62500
    //AmbientEffectEmitterClass=class'Onslaught.ONSRVChainGunFireEffect'
        FireInterval=0.5
            FireSoundClass=sound'ONSVehicleSounds-S.LaserSounds.Laser01'
        SoundVolume=255
        AmbientSoundScaling=1.3
      
    	//bIsRepeatingFF=True
    	 ProjectileClass=class'Onslaught.ONSHoverBikePlasmaProjectile'
        bAmbientFireSound=False
        WeaponFireAttachmentBone=SideGunFirePointf
        GunnerAttachmentBone=SideGunAttach
        bAimable=True
        DrawScale=1.0
        MinAim=0.925
        bInstantRotation=true
        bDoOffsetTrace=true
        EffectEmitterClass=class'Artillery.Eleclines'
        ShakeRotMag=(X=60.0,Y=20.0,Z=0.0)
        ShakeRotRate=(X=1000.0,Y=1000.0,Z=0.0)
    	RelativeLocation=(x=-53,y=108,z=2)
        ShakeRotTime=2
    
    	
       AIInfo(0)=(bLeadTarget=true,RefireRate=0.95)
        AIInfo(1)=(bLeadTarget=true,AimError=400,RefireRate=0.50)
    	
        CullDistance=3000.0
    }


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.