The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

ut2004, passing information from a vehicle to the weapon it carries

  • Filter
  • Time
  • Show
Clear All
new posts

    ut2004, passing information from a vehicle to the weapon it carries

    Howdy Guys,

    I sure do hope this forum is still alive... Ok, I'm quite new at unreal scripting. I've been reading, searching, dissecting code and slowly picking up bits here and there for months now. As far as I have come, which given the complexity of this game is laughably little, I seem to be stymied.

    Basically, I've heavily modded a raptor. One of the refinements is that my raptor has a HUD that can 'lock' onto another flying vehicle and paint it with a box so it can be tracked where ever it may fly off to. The driver can then either fire a missile at that target or 'release' the lock and look for something else. That all works just fine, what I can't figure out is how to tell the weapon the modded raptor carries what if anything has been locked onto.

    The weapon passing target information to a launched missile was straightforward enough. The missile code has a 'settarget' function which I can invoke once a missile is spawned, much like what is found in the attackcraft code. I'd like to do something similar with the raptor coding wise. So, I built an updatetarget function in my weapon code.

    My understanding is that once the raptor is spawned, by the factory and a driver has entered it, the weapon is also spawned and stored in the driverweapons variable. No amount of pleading, coaxing, bribing or threatening the compiler will seem to allow me to get at the target setting function stored in the weapons coding ( rather like the settarget found in the missiles code ). Which I can't understand since right there in default section under driverweapons I'm setting which weapon is to be used (my custom one, that is).

    I was rather hoping someone could tell me if what I'm doing is even possible, or better yet explain to me just what the syntax on such a call would look like. I'm sorry for sounding petulant like this, I've rather had enough frustration for this month.

    Hi tramway,
    I think I understand the problem you are having, it sounds a little bit like a casting error. If the code won't compile and gives an error (UCC.log should list the errors and compiler messages if I recall correctly) you can post the error here. Have you looked at the other Onslaught vehicle source code examples? The Paladin (ONSShockTank.uc in the OnslaughtBP package) has an example of casting the Weapons array to the weapon to the specific weapon class to call a function in it:
    function ShouldTargetMissile(Projectile P)
    	local AIController C;
    	C = AIController(Controller);
    	if ( (C != None) && (C.Skill >= 2.0) )
    function bool Dodge(eDoubleClickDir DoubleClickMove)
    	return false;
    and here is another example from my own vehicle pack where the player uses the crouch button (in a ground based vehicle) to change the driver's weapon's firing mode:
    class ONS_LAV25AD extends ONSWheeledCraft;
    var float OldRise, JumpCountdown;
    // only execute on the server, change will be replicated to the clients
    function CheckJumpSwitch(float dt){
    	JumpCountdown -= dt;
        // If we are pressing the jump key, and its time to sample again, sample
        if (JumpCountdown <= 0.0 && Rise < 0 ){ // check to see if we are "crouching" (rise<0) to switch weapon types, since rise>0 is for the E-brake
            OldRise = Rise;
        	if ( AIController(Controller) != None )
        		Rise = 0;
        	JumpCountdown = 0.40;
            // kind of hacky, but check for the weapons and changing them
            if(LAV25AD_Turret(Weapons[0]) != none)
            else if(LAV25_Turret(Weapons[0]) != none)
        }else if( Rise >= 0.0) JumpCountdown = 0.0;
    In my own vehicle pack, I have the tracking function in the vehicle class (like what you described), but rather than passing the target variable down to the weapon, I have the weapon poll the vehicle to see what it is targeting when a homing missile is spawned (either way, vehicle->weapon or weapon->polls the vehicle, should work just fine).


      Bullseye! Got it in one. You were absolutely correct Meowcat, it was indeed a casting type error, and nope it would never ever have occurred to me to look at something like the paladin for a parallel. I won't make that oversight again. After the close to half an hour it took me to get over my chagrin I began disassembling all of the vehicles.

      Allow me to extend my most sincere thanks to you Meowcat, I was on the verge of throwing in the towel over my roadblock. In a mere paragraph you managed to completely reverse my outlook on my little project.


        Glad it worked out and that I could help!

        Its kind of incredible the types of examples that are in the UT2k4 script source. Since Epic basically made the game as an example of their Unreal 2.5 engine, it has at least one example of just about every function and behavior you could need.