PDA

View Full Version : Reload key


Postal
11th Nov 2001, 11:21 AM
I want the guns in C4 to reload when you hit a key

but first when I tried Button bExtra3:
simulated function Tick(float DeltaTime)
{
if (Pawn(Owner) != None && Pawn(Owner).Weapon == self)
{
if (PlayerPawn(Owner).bExtra3 != 0)
{
GoToState('NewClip');
}
}
}

I got lotss of access nones, or something or another warning in the ut log

But when I when to using an exec function in the gun, sometime after a while in game it stops working.

What do you all suggest?

2COOL4-U
11th Nov 2001, 02:07 PM
could it be that the animations are not done for the weapons you want to reload, I think we here at Defence Alliance had a problem with no animations while the base weapon class was trying to play them, after that happend I couldn't do anything at all with the weapons until I killall'ed the weapon

Postal
11th Nov 2001, 02:11 PM
cant be that, alt fire currently also reloads the guns, no prob there.

its just a ways into the game, sometime the exec reload just stops working, with out giving ut any errors.

Oh, DA looks like it will be a real fun mod, looking foward to playing it, nice models too.

Sg_Jack
12th Nov 2001, 11:27 AM
I think the exec functions must be in a player class. You should make a subclass of Tournament player, and in this file put something like that :

exec function Firemodes()
{
if (weapon != None && weapon.IsA('ATFireArms'))
{
ATFireArms(weapon).SwitchFireMode();
}
}

I use this in my mod to add new functions for keys. They, you make a new keybinding class with this function. It's pretty easy.

But maybe you have already test it ?

Postal
12th Nov 2001, 06:25 PM
The very last thing I want to do is make a new playerclass, in fact I wont even do that.

Its possible to run execs in other classes too btw.

And you can always use tick, which I am about to go back to, but I would rather not. Unfortunaly sometimes in game the the exec stops working, but after switching weapons, it sometimes works again, perhaps theres some confilict with a state?

Sg_Jack
13th Nov 2001, 06:29 AM
Ok, i didn't knew you don't want to make a player class...

But there is somthing i don't understand : why don't you want to make binding keys ??? You could put your exec function in your weapon class, and assign it to a key.

You're not forced to make a tick function ? Why don't you test the ammo level (in a clip) before fire ? If there is no more bullets, the code goto a reload state.

I think it's better. If you use a tick function, you can (and you have ) conflicts if another function want to access a state in the same time of your tick...

What do you think ?

Postal
13th Nov 2001, 03:09 PM
ARG!

I dont want auto-reload, I spent a good bit a time a long time ago getting all of that out of there!

I have an exec in my weap class, but it doesnt always work, thats what this post is about.

Tick works fine for me ingame, but it make the logs hugh with its accessed nones, exec makes no errors, but doesnt always work, Im still wondering how to either make the tick not give accessed nones, or make the exec in gun work all the time.

Sg_Jack
14th Nov 2001, 11:35 AM
Hey, i'm trying to help you. So, don't answer me like this OK ??

I don't say you to make autoreload... You can either make a new key... Making a new key doesn't mean that you'll not control your reload process...

But you don't seem to understand that maybe your code don't work... So, if you want any solution, let's stay with your bug ok ?

Cya

Postal
14th Nov 2001, 03:07 PM
Why is everyone so touchy at the moment? I am getting frustrated, for I am not getting a single answer that can help?

I did make a new key, an exec function reload, but unforuntaly its doesnt always work, does anyone have an idea of why that may be?

OR, should I go back to useing tick to check for the player hitting button bextra3

there are no conflicts with my tick code, only access nones
but my exec, while creating no errors in log, still sometimes does not work in game(will work a while, stop working, then sometimes work again)

Sg_Jack
15th Nov 2001, 03:49 AM
Well, i'm not angry. I try to hlp you as best as i can, and you say me that you don't care about what i say...

You could be more friendly with something trying to help you...

About access nones, i have no idea sorry. Hope you'll find a solution :)

eXoR
15th Nov 2001, 04:24 AM
Originally posted by Postal

simulated function Tick(float DeltaTime)
{
if (Pawn(Owner) != None && Pawn(Owner).Weapon == self)
{
if (PlayerPawn(Owner).bExtra3 != 0)
{
GoToState('NewClip');
}
}
}


Hey,

I donít know what the problem is with your exec function. I use exec functions in my mutator, in a subclass of Actor. It works great, all the time.

Now, about your Tick implentation. The Accessed Noneís should be very obvious. In your if statement, you check if the weapons Owner is a valid Pawn, and then if itís current weapon is your gun. Then, if it is a Pawn and it is your gun, you cast the Owner reference to a PlayerPawn. Thus, if any Bot is holding your weapon, the Pawn check and the weapon check will be passed. But when you try to cast that Bot to a PlayerPawn, it wonít work and there you go Ė accessed none. So, changing your If statement to this:

if (Playerpawn(Owner) != None && Pawn(Owner).Weapon == self)

it will not pass if the Owner is a Bot, and thus the cast wonít be made, and thus there will be no accessed noneís. Hope this helps you,

eXoR.

Postal
15th Nov 2001, 02:46 PM
Finally! Very gratefull.