Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → random aiming....
random aiming....
2002-01-11, 9:06 AM #1
here i go again.. i'm trying to get the weapon to fire with less accuracy when the player moves... but when i got that thing below in the cog, I can't even select the weapon... what's wrong?

dummy = FireProjectile(player, projectile,
fireSound, 18, '0.0214 0.15 0.00', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2);

if (sloppy == IsThingMoving(player));
{
randVec = VectorSet((Rand()-0.9)*5, (Rand()-0.9)*5, 0.0);
}
else
{
randVec = VectorSet((Rand()0.0)*1, (Rand()0.0)*1, 0.0);
}
2002-01-11, 9:25 AM #2
Hmmmm, try this:

Code:
if (IsThingMoving(player))
{
  randVec = VectorSet((Rand()-0.9)*5, (Rand()-0.9)*5, 0.0);
}
else
{
  randVec = VectorSet(0, 0, 0);
}

dummy = FireProjectile(player, projectile, fireSound, 18, '0.0214 0.15 0.00', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2);


You just need to check if the thing is moving, dunno what you were tryin to do. [http://forums.massassi.net/html/smile.gif] Also, if you're not gonna have it be random at all if he's still, you just set the vector to 0/0/0. It would also help if the FireProjectile statement was after your random fire vector stuff. [http://forums.massassi.net/html/wink.gif]

[edit] Aha! Found your problem. You have a ; after the if statement, that'll cause the weapon to not be selectable. [/edit]

------------------
-Hell Raiser
Cogging type person that does, umm, stuff?
"Free, your, mind."
DBZ: TDIR has a new home!

[This message has been edited by Hell Raiser (edited January 11, 2002).]
-Hell Raiser
2002-01-11, 9:51 AM #3
i'm sorry.. but i can't know everything from the start.... thanks anyway!
2002-01-11, 10:29 AM #4
s'ok, gotta learn somehow. [http://forums.massassi.net/html/smile.gif]

------------------
-Hell Raiser
Cogging type person that does, umm, stuff?
"Free, your, mind."
DBZ: TDIR has a new home!
-Hell Raiser
2002-01-12, 4:24 AM #5
hmm... it's still the same problem.. when i change from any weapon without that code to weapons with it i see the dismount animation as usual but the weapon that is supposed to come up doesn't... and when i shoot, it's the weapon i changed from...
2002-01-12, 4:38 AM #6
Dont use 'Randvec' as a variable. That is a command, so that will cause problems. Change it to 'Randvec_' or the like.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2002-01-12, 10:39 AM #7
Use Cogwriter and check to see if you have any syntax errors. I always get that problem if the weapon I'm switching to has problems in the cog.

GBK, LEC uses randVec for a variable in the storm trooper rifle cog, that's where he got his base code from. [http://forums.massassi.net/html/smile.gif]

------------------
-Hell Raiser
Something Wiccan this way comes...
"Free, your, mind." - Morpheus, The Matrix
Cogging Guru for DBZ: TDIR
-Hell Raiser
2002-01-12, 2:40 PM #8
I suggest leaving Rand()-0.5 instead of changing to Rand()-0.9 if you wish the fire error to be based from the center

Everything else you should be fine

I also suggest that you make the weapon less accurate when firing in long brusts.

Also is it possible to make the weapon more accurate when crouching?

if (IsThingMoving(player)
{
randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
}
else
{
randVec = VectorSet(0, 0, 0);
}
dummy = FireProjectile(player, projectile, fireSound, 18, '0.0214 0.15 0.00', randVec, 1.0, 0x20, autoAimFOV, autoAimFOV*2);


------------------
"...and may the Force be with you."
-Luke Skywalker

Dark Luke, known for dressed like Vader (But no helmets and computer stuffs on), ignites his green lightsaber, ready to fight against evil and defend the light side.

Zone name: Deedlit6
Jedi vs. Sith - Dark Luke's Jedi Knight web site: Informations, addons, etc.
(Draws his undead great sword out, and with a variety of magical spells, gets ready to fight.

Music composer (presented as Undead Knight and maker of JK SP projects - download soundtrack of Dark Emperor 2 here!

Jedi vs. Sith - Dark Luke's Jedi Knight web site: Informations, addons, etc.
2002-01-13, 7:25 AM #9
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Darth Maul:

I also suggest that you make the weapon less accurate when firing in long brusts.

Also is it possible to make the weapon more accurate when crouching?
</font>


I've thought about those things but I'm not really sure how to make it less accurate when you fire in long bursts...

Do you mean making it more accurate even while you move when you crouch?
2002-01-13, 7:57 AM #10
Well when I experiment the cog with activated and deactivated messages, I found that if you hold your fire the weapon will continue to be activated, and when you stop the fire the deactivated message runs.

Then I made the cog to have a counter that increases by 1 when a shot is fired, and resets to 0 when you stop shooting. Accuracy is based on this brust number.

This cog weapon cog for a rifle/SMG that provides a 30 round clip capacity and accuracy decreases in long brusts. Feel free to use/copy/modifly it whatever to fulfill your needs. The less accuracy when moving and accuracy bonus when moving has not be implemented yet in this cog.

symbols

model povModel=strv.3do local
model weaponMesh=strg.3do local

keyframe mountAnim=StrVmnt.key local
keyframe dismountAnim=StrVdis.key local
keyframe povfireAnim=StrVpst1.key local
keyframe holsterAnim=kyhlstr.key local

sound mountSound=df_rif_ready.wav local
sound dismountSound=PutWeaponAway01.wav local
sound fireSound=30cal.wav local
sound outSound=trprout.wav local

template projectile=+chainbullet local

thing player local

vector randVec local

flex fireWait=0.05 local
flex holsterWait local
flex powerBoost local
flex autoAimFOV=25 local
flex autoAimMaxDist=5 local

int dummy local
int trackID=-1 local
int fireChannel=-1 local
int holsterTrack local
int mode local

int clipp=30 local
int brustnumber=0 local

message activated
message deactivated
message selected
message deselected
message autoselect
message fire
message timer
message trigger

end

# ========================================================================================

code

fire:
player = GetSourceRef();
mode = GetSenderRef();

// Check that the player is still alive.
if(GetThingHealth(player) <= 0)
{
Return;
}

// Check Ammo - If we are out, autoselect best weapon.
// It should always use two energy cells, but -- as in DF --
// allow the last fire if there is only one left...
if(GetInv(player, 11) < 1.0)
{
PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
if((GetAutoSwitch() & 1))
SelectWeapon(player, AutoSelectWeapon(player, 1));
Return;
}

if(mode == 0)
{

if(clipp <= 0)
{
nofire = 1;
reloadmode = 1;
settimer(firewait * 50);
//print("reload");
powerBoost = GetInv(player, 63);
//jkPlayPOVKey(player, dismountAnim, 0, 0x18);
// setmountwait(player, getkeylen(dsmountanim));
// holsterTrack = PlayKey(player, holsterAnim, 1, 0x18);
// holsterWait = GetKeyLen(holsterAnim);
// SetMountWait(player, holsterWait);

PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);

SetMountWait(player, GetKeyLen(mountAnim));
ChangeFireRate(player, fireWait /powerBoost);

clipp = 30;
return;
}
else if(nofire == 0)
{
//print("fire");
clipp = clipp - 1;
// Get random aiming error
if(brustnumber <= 1) randvec = vectorset(0, 0, 0);
else if(brustnumber <= 3) randvec = VectorSet((Rand()-0.5)*1, (Rand()-0.5)*2, 0.0);
if(brustnumber > 3) randVec = VectorSet((Rand()-0.5)*4, (Rand()-0.5)*5, 0.0);
printint(brustnumber);

SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
dummy = FireProjectile(player, projectile, fireSound, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
if(IsMulti())
{
ID = GetCurWeapon(player) * 10 + mode; //A unique ID to be retrieved in the trigger message with GetSourceRef().
SendTrigger(-1, ID, player, 0, 0, 0); //Send the trigger, so every player's computer will recieve the action
}

// SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));

ChangeInv( player, 11, -1.0 );
// jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
brustnumber = brustnumber + 1;
powerBoost = GetInv(player, 63);
ChangeFireRate(player, fireWait/powerBoost);
Return;
}
}
else if(clipp < 30)
{
nofire = 1;
reloadmode = 1;
settimer(firewait * 50);
//print("reload");
powerBoost = GetInv(player, 63);
//jkPlayPOVKey(player, dismountAnim, 0, 0x18);
// setmountwait(player, getkeylen(dsmountanim));
// holsterTrack = PlayKey(player, holsterAnim, 1, 0x18);
// holsterWait = GetKeyLen(holsterAnim);
// SetMountWait(player, holsterWait);

PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);

SetMountWait(player, GetKeyLen(mountAnim));
ChangeFireRate(player, fireWait /powerBoost);

clipp = 30;

return;
}

Return;

# ........................................................................................

activated:
player = GetSourceRef();
mode = GetSenderRef();

jkSetWaggle(player, '0.0 0.0 0.0', 0);
powerBoost = GetInv(player, 63);
ActivateWeapon(player, fireWait/powerBoost, mode);
Return;

# ........................................................................................

deactivated:
player = GetSourceRef();
jkSetWaggle(player, '10.0 7.0 0.0', 350);
DeactivateWeapon(player, mode);
nofire = 1;
reloadmode = 1;
settimer(firewait * 5);
brustnumber = 0;
Return;

# ........................................................................................

selected:
player = GetSourceRef();

PlayMode(player, 41);
PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
jkSetPOVModel(player, povModel);
SetArmedMode(player, 1);
jkSetWeaponMesh(player, weaponMesh);
jkSetWaggle(player, '10.0 7.0 0.0', 350);
trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
SetMountWait(player, GetKeyLen(mountAnim));
jkClearFlags(player, 0x5);
SetCurWeapon(player, 3);

Return;

# ........................................................................................

deselected:
player = GetSourceRef();

PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
jkPlayPOVKey(player, dismountAnim, 0, 0x18);
holsterWait = GetKeyLen(holsterAnim);
SetMountWait(player, holsterWait);
holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
SetTimerEx(holsterWait, 2, 0.0, 0.0);
if (trackID != -1)
{
jkStopPOVKey(player, trackID, 0);
trackID = -1;
}
jkSetWaggle(player, '0.0 0.0 0.0', 0);

Return;

# ........................................................................................

autoselect:
player = GetSourceRef();

// If the player has the weapon
if(GetInv(player, 3) != 0.0)
{
// If the player has ammo
if(GetInv(player, 11) != 0.0)
{
ReturnEx(600.0);
}
else
{
ReturnEx(-1.0);
}
}
else
{
ReturnEx(-1.0);
}

Return;

# ........................................................................................

timer:
if(reloadmode == 1)
{
print("timer contacted");
nofire = 0;
reloadmode = 0;
}

StopKey(player, holsterTrack, 0.0);
Return;

# ........................................................................................

trigger:
//Only fire on other player's comp...
if(GetLocalPlayerThing() == GetParam(0)) return; //If the shooter is yourself, then don't fire again.

if( (GetSourceRef() == 30) || (GetSourceRef() == 31) ) //In this case, bryar is weapon 2
{ //and fire mode could be 1 or 0. I just added to make a unique ID.
FireProjectile(GetParam(0), projectile, -1, 8, '0.0168 0.1896 0.00', randVec, 1.0, 0x30, autoAimFOV, autoAimFOV*2);
}
return;

# ........................................................................................


end

------------------
"...and may the Force be with you."
-Luke Skywalker

Dark Luke, known for dressed like Vader (But no helmets and computer stuffs on), ignites his green lightsaber, ready to fight against evil and defend the light side.

Zone name: Deedlit6
Jedi vs. Sith - Dark Luke's Jedi Knight web site: Informations, addons, etc.

[This message has been edited by Darth Maul (edited January 13, 2002).]
(Draws his undead great sword out, and with a variety of magical spells, gets ready to fight.

Music composer (presented as Undead Knight and maker of JK SP projects - download soundtrack of Dark Emperor 2 here!

Jedi vs. Sith - Dark Luke's Jedi Knight web site: Informations, addons, etc.
2002-01-13, 10:01 AM #11
Quote:
<font face="Verdana, Arial" size="2">
Also is it possible to make the weapon more accurate when crouching?
</font>



If(Isthingcrouching(Player) == 1) {}

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!