Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

learning to add a weapon.

| Inside3d Forums Forum Index -> Tutorial Help

View previous topic :: View next topic
Author | Message
--- | ---
ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Sun Oct 12, 2008 7:51 am Post subject: learning to add a weapon. |

hey i been having an issue with compiling again... iv been trying all night its now 3:49 am... i just cant figure out what iv done wrong. this is the tutorial iv been fallowing : http://inside3d.com/showtutorial.php?id=60 the only part i didnt fallow was the part of adding it to the cheat command i dont want that. i just added a line in the fgd to add it to a map .
this is the error im getting.
_________________
QuakeDB - Quake ModDB Group

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Sun Oct 12, 2008 10:54 am Post subject: |

Error: Syntax error before 'else'. _________________ What's a signature?

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Sun Oct 12, 2008 8:05 pm Post subject: |

Probably you have an else that's been separated from its if statement by some code you added; or perhaps you deleted or rewrote an if statement and left the else dangling. Mind posting that section of items.qc (say, lines 400-500) so we can take a look?
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Sun Oct 12, 2008 8:08 pm Post subject: |

i dont think so it all looks right.... iv looked over the original code and it all seems to be set up exactly the same way.

Code:
/* ============= weapon_touch - lines 385- 505 ============= */
float() W_BestWeapon;
void() weapon_touch =
{
local float hadammo, best, new, old;
local entity stemp;
local float leave;
if (!(other.flags & FL_CLIENT))
return;
// if the player was using his best weapon, change up to the new one if better
stemp = self;
self = other;
best = W_BestWeapon();
self = stemp;
if (deathmatch == 2 || coop)
leave = 1;
else
leave = 0;
if (self.classname == "weapon_nailgun")
{
if (leave && (other.items & IT_NAILGUN) )
return;
hadammo = other.ammo_nails;
new = IT_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
}
else if (self.classname == "weapon_supernailgun")
{
if (leave && (other.items & IT_SUPER_NAILGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_NAILGUN;
other.ammo_nails = other.ammo_nails + 30;
}
else if (self.classname == "weapon_supershotgun")
{
if (other.ammo_shells = 20 && (other.items & IT_SUPER_SHOTGUN))
{
new = IT_Sniper;
other.ammo_shells = other.ammo_shells + 20;
}
if (leave && (other.items & IT_SUPER_SHOTGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
}
else if (self.classname == "weapon_rocketlauncher")
{
if (leave && (other.items & IT_ROCKET_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_ROCKET_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
}
else if (self.classname == "weapon_grenadelauncher")
{
if (leave && (other.items & IT_GRENADE_LAUNCHER) )
return;
hadammo = other.ammo_rockets;
new = IT_GRENADE_LAUNCHER;
other.ammo_rockets = other.ammo_rockets + 5;
}
else if (self.classname == "weapon_lightning")
{
if (leave && (other.items & IT_LIGHTNING) )
return;
hadammo = other.ammo_rockets;
new = IT_LIGHTNING;
other.ammo_cells = other.ammo_cells + 15;
}
else
objerror ("weapon_touch: unknown classname");
sprint (other, "You got the ");
sprint (other, self.netname);
sprint (other, "\n");
// weapon touch sound
sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
bound_other_ammo ();
// change to the weapon
old = other.items;
other.items = other.items | new;
stemp = self;
self = other;
if (!deathmatch)
self.weapon = new;
else
Deathmatch_Weapon (old, new);
W_SetCurrentAmmo();
self = stemp;
if (leave)
return;
// remove it in single player, or setup for respawning in deathmatch
self.model = string_null;
self.solid = SOLID_NOT;
if (deathmatch == 1)
self.nextthink = time + 30;
self.think = SUB_regen;
activator = other;
SUB_UseTargets(); // fire all targets / killtargets
};

_________________
QuakeDB - Quake ModDB Group

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Mon Oct 13, 2008 8:55 am Post subject: |

Looks fine as far as I can see. :/ The assignment in conditional comes from this line: if (other.ammo_shells = 20 && (other.items & IT_SUPER_SHOTGUN)) tbh the logic here is a little broken... but it shouldn't generate any actual compiler errors, it just won't run right.
19 lines later is this line:
else if (self.classname == "weapon_grenadelauncher")
I really don't see how that else could be misplaced.
The only thing I can think of is that its somehow complaining about something hidden in whitespace.. but that doesn't really make much sense, as it would be moaning about a missing operator rather than a variable.
Bizzare.
fix it!
_________________
What's a signature?

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Mon Oct 13, 2008 8:58 am Post subject: |

lol im trying to -.- _________________ QuakeDB - Quake ModDB Group

Back to top |

Wazat Joined: 15 Oct 2004 Posts: 732 Location: Middle 'o the desert, USA |

Posted: Mon Oct 13, 2008 7:22 pm Post subject: |

Yes, you'll want to fix the "if (other.ammo_shells = 20" to use a == instead of a = (a single = will set shells to 20 every time that if statement runs, which you probably don't want). Other than that, I'm not finding anything. The line it's giving the error on is this one, right?
else if (self.classname == "weapon_grenadelauncher")
You can also try using fteqcc to see if it says something different about the error, or tags a different line.
_________________
When my computer inevitably explodes and kills me, my cat inherits everything I own. He may be the only one capable of continuing my work.

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Tue Oct 14, 2008 2:23 am Post subject: |

ok, changing that fix it but now when i changed the fgd to add this weapon and i put it in my map and recompiled.... it doesnt show up ingame... here's my fgd qc...

Code:
@baseclass size(-16 -16 0, 16 16 32) color(0 0 200) base(Item, Appearflags) = Weapon [] @PointClass base(Weapon) = weapon_supershotgun : "Super shotgun" [] @PointClass base(Weapon) = weapon_nailgun : "Nailgun" [] @PointClass base(Weapon) = weapon_supernailgun : "Perforator" []
@PointClass base(Weapon) = weapon_grenadelauncher : "Grenade launcher" []
@PointClass base(Weapon) = weapon_rocketlauncher : "Rocket launcher" []
@PointClass base(Weapon) = weapon_lightning : "Thunderbolt" []
@PointClass base(Weapon) = weapon_sniper : "sniper" []

_________________
QuakeDB - Quake ModDB Group

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Wed Oct 15, 2008 6:27 am Post subject: |

Does anyone know why the sniper rifle wont show up in my map? does it have to do with how i added the sniper as a new weapon in the game? because im thinking the way that the tutorial show'd me how to add the new weapon makes it use the same everything that the shotgun does instead of actually creating a new weapon. i may be wrong, but im still learning -.-
_________________
QuakeDB - Quake ModDB Group

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Wed Oct 15, 2008 9:12 am Post subject: |

pardon me but it is 4am, and im barely awake

Code:
lse if (self.classname == "weapon_supershotgun") { if(other.shells = 100 && (other.items & IT_SUPER_SHOTGUN)) { new = IT_SNIPER;
other.ammo_shells = other.ammo_shells + 20;
}
if (leave && (other.items & IT_SUPER_SHOTGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
}

shouldn't this be like this?

Code:
else if (self.classname == "weapon_supershotgun") { if (other.shells == 100 && (other.items & IT_SUPER_SHOTGUN))//R00k added the '== 100' was '= 100' { new = IT_SNIPER;
other.ammo_shells = other.ammo_shells + 20;
}
else
{
if (leave && (other.items & IT_SUPER_SHOTGUN))
return;
hadammo = other.ammo_rockets; //what the f*ck is this here for??
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
}
}

Which basically means if you touch the DoubleShotgun , and you already had one, AND you have 100 shells, THEN, you magically have a SNIPER RIFLE now. This tut doesnt actually add a sniper rifle model to the map, it just changes the behavior of the DSG, under these circumstances.

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Wed Oct 15, 2008 8:25 pm Post subject: |

well... i decided to use the same code, but use the grenade launchers model... only difference. i mean id like to add a new weapon to an already existing slot just hit like 2 twice and you get the new weapon after you've picked it up. _________________
QuakeDB - Quake ModDB Group

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 968 Location: Florida, USA |

Posted: Sun Nov 23, 2008 6:32 am Post subject: |

still having issues with this.... i get issues here

Code:
{ if (other.shells = 10= && (other.items & IT_SUPER_SHOTGUN)) { new = IT_SNIPER; other.ammo_shells = other.ammo_shells + 20;
}
if (leave && (other.items & IT_SUPER_SHOTGUN) )
return;
hadammo = other.ammo_rockets;
new = IT_SUPER_SHOTGUN;
other.ammo_shells = other.ammo_shells + 5;
}

specifically here....

Code:
if (other.shells = 10= && (other.items & IT_SUPER_SHOTGUN))

_________________
QuakeDB - Quake ModDB Group

Back to top |

Dr. Shadowborg Inside3D Staff Joined: 16 Oct 2004 Posts: 726 |

Posted: Sun Nov 23, 2008 10:13 pm Post subject: |

ceriux wrote:

Code:
if (other.shells = 10= && (other.items & IT_SUPER_SHOTGUN))

The problem is that it should be this:

Code:
if (other.shells == 10 && (other.items & IT_SUPER_SHOTGUN))

also, you may want to look at the stuff in here:
http://qexpo.tastyspleen.net/booth.php?id=131
There's an issue or two that I hadn't thought of with tutorial 3, but aside from that it's mostly good stuff.
Also, just in case error wants to stab me for saying that I was going to put these up on I3D's tutorial section, I can only say that I'm currently horribly busy right now with real life / work issues / quake burnout.
_________________
"Roboto suggests Plasma Bazooka."

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Tutorial Help | All times are GMT
Page 1 of 1

Jump to:

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 © 2004 phpBB Group