
EDuke32 Scripting "CON coding help"
#593 Posted 01 March 2011 - 03:28 AM
A) Did you copy the code to a con file that's been modified? If so, there's no guarantee the code will work with other code that's already been added (not without some extra modification, at least)
B ) When you copied the code beneath the APLAYER line, did you erase the APLAYER line itself? Two APLAYER lines could cause some problems if not an error itself.
C) When you copied the code, did you erase the notes that were slashed out on the sides? Those were only meant to help you understand what each step was doing, but if they were copied in with the code, they could possibly cause some kinks.
If the magazine isn't being reloaded, then something must be going wrong beneath the APLAYER line, because that's the only line in the code that actually reloads the magazine. If none of that helps, post your con file, and I'll take a look at it. Rest assure, though, I've done enough testing to know that it works.
This post has been edited by EmericaSkater: 01 March 2011 - 03:28 AM
#594 Posted 01 March 2011 - 03:52 AM
Thanks for helping me out

#595 Posted 01 March 2011 - 03:55 AM
#596 Posted 01 March 2011 - 04:35 AM
Attached File(s)
-
GAME.CON (149.21K)
Number of downloads: 830 -
Gamevars.con (143bytes)
Number of downloads: 782
#597 Posted 01 March 2011 - 05:09 AM
Change the block of code that's beneath the APLAYER line to this...
getplayer[THISACTOR].curr_weapon PWEAPON getplayer[THISACTOR].kickback_pic KICKBACK getplayer[THISACTOR].ammo_amount 1 PISTOLAMMO ifvare PWEAPON 1 { ifvarl PISTOLMAGAZINE 1 { getplayer[THISACTOR].weapon_pos PERPLAYER1 ifvarn PERPLAYER1 0 break else ifvarl PISTOLAMMO 1 break else { setplayer[THISACTOR].reloading 1 setplayer[THISACTOR].kickback_pic 4 } } ifvare KICKBACK 5 { ifvarg PISTOLAMMO 11 setvar PISTOLMAGAZINE 12 else setvarvar PISTOLMAGAZINE PISTOLAMMO } }
When I opened your con file (as well as Hendrick's first edit), the code was like this - -
getplayer[THISACTOR].curr_weapon PWEAPON getplayer[THISACTOR].kickback_pic KICKBACK getplayer[THISACTOR].ammo_amount 1 PISTOLAMMO ifvare PWEAPON 1 { ifvarl PISTOLMAGAZINE 1 { getplayer[THISACTOR].weapon_pos PERPLAYER1 ifvarn PERPLAYER1 0 break else ifvarl PISTOLAMMO 1 break else { setplayer[THISACTOR].reloading 1 setplayer[THISACTOR].kickback_pic 4 } ifvare KICKBACK 5 { ifvarg PISTOLAMMO 11 setvar PISTOLMAGAZINE 12 else setvarvar PISTOLMAGAZINE PISTOLAMMO } } } // this last bracket here is what did it. This belongs further up, beneath the code that sets the kickback pic to 4. With the code like this, the clip ONLY gets refreshed if the magazine count is less than zero.
You'll notice in the version of the tutorial on this thread, and the first version of the tutorial that was on the wiki, that bracket was where it belonged. Sorry for the confusion, I'll fix the wiki entry immediately.
This post has been edited by EmericaSkater: 01 March 2011 - 05:11 AM
#598 Posted 01 March 2011 - 05:17 AM

#599 Posted 01 March 2011 - 08:58 AM
#601 Posted 01 March 2011 - 01:09 PM
The Commander, on Mar 1 2011, 01:32 PM, said:
Hendricks contributes more to the wiki lately than anyone else. It's a public resource and the pages don't "belong" to anyone.
#602 Posted 01 March 2011 - 04:01 PM
The Commander, on Mar 1 2011, 01:32 PM, said:
I cleared out your talk page once because it was full of shit and I inadvertently made a mistake while optimizing EmericaSkater's code and making it so that newbies could actually read and understand what was previously a mess. Meddling?
http://wiki.eduke32....tructure_access
http://wiki.eduke32....fvar_conditions
http://wiki.eduke32....i/Findnearactor
http://wiki.eduke32.com/wiki/Spawn
http://wiki.eduke32.com/wiki/Shoot
http://wiki.eduke32....mevar_operators
I'd ban the spambots too but I'm not a sysop.
#603 Posted 01 March 2011 - 05:55 PM
The Commander, on Mar 1 2011, 11:32 AM, said:
He was just trying to help and it was the first contribution I've ever made to the wiki so it didn't really surprise me. I didn't know what I was doing in terms of formatting. Though I'll be honest, this - -
Hendricks266, on Mar 1 2011, 04:01 PM, said:
is a bit exaggerated. I wouldn't really call a few brackets on the same line a "mess" that people wouldn't be able to understand.
#604 Posted 03 March 2011 - 07:23 AM
EmericaSkater, on Mar 2 2011, 02:55 PM, said:
I think Hendricks took what I said a bit to seriously, maybe if I had removed the ugh and replaced it with a

My talk page was never full of shit?
This post has been edited by The Commander: 03 March 2011 - 07:26 AM
#606 Posted 03 March 2011 - 01:59 PM
Is there a command to change the name of the sprite in 2D mode depending on the lotag. For example, sector effector actor with lotag = 2 drawn as SE:2 EARTHQUAKE name.
#607 Posted 03 March 2011 - 02:08 PM
#608 Posted 03 March 2011 - 02:15 PM

EDIT:
I mean changing name of my sprite via script in 2D mode
This post has been edited by M210: 03 March 2011 - 02:20 PM
#610 Posted 03 March 2011 - 10:44 PM
Scott_AW, on Mar 4 2011, 07:38 AM, said:
Although it would be a nice feature.
It's not correctly right, because it's doesn't change name depending on lotag number
well, I'm understand now that it isn't possible

This post has been edited by M210: 03 March 2011 - 10:45 PM
#611 Posted 05 March 2011 - 10:58 PM
And then, a second question. I want my weapons to behave like the weapons in counter-strike. Meaning three things the weapons must be able to do.
-During the firing event, the weapon should play its entire shooting animation (from animated recoil to return-to-idle), but be able to be interrupted mid-animation for another shot if the firing rate settings allow it.
-Long reload animations.
-Misc. animation calls which prevent the player from firing until it's done. (Think attaching a silencer on the pistol from CS.)
But.. aren't all ingame animations bound to that.. preset kickback_pic thing?
Which.. the whole system there really confuses me, and I'm not really sure how to go about it all. Also, I say theoretical because I don't expect anyone to have to strain themselves by posting lengthy lines of code, thus doing the work for me.
#612 Posted 05 March 2011 - 11:53 PM
Wolf, on Mar 5 2011, 10:58 PM, said:
And then, a second question. I want my weapons to behave like the weapons in counter-strike. Meaning three things the weapons must be able to do.
-During the firing event, the weapon should play its entire shooting animation (from animated recoil to return-to-idle), but be able to be interrupted mid-animation for another shot if the firing rate settings allow it.
-Long reload animations.
-Misc. animation calls which prevent the player from firing until it's done. (Think attaching a silencer on the pistol from CS.)
But.. aren't all ingame animations bound to that.. preset kickback_pic thing?
Which.. the whole system there really confuses me, and I'm not really sure how to go about it all. Also, I say theoretical because I don't expect anyone to have to strain themselves by posting lengthy lines of code, thus doing the work for me.
Make an entire system based on manipulating your own game variables, custom projectiles and screen drawing commands. For what you want, bypassing the hardcoded system entirely would be best. You were on the right track when you talked about using a single weapon slot and changing its characteristics depending on which actual weapon the player is using. But I would not even bother with things like kickback_pic. You only need to know enough about the hardcoded shit like that to be able to disable it. One thing to keep in mind is that you can make the player shoot any projectile at any time simply by using the shoot command in the APLAYER actor code. So you don't need to make one of the hardcoded weapons fire. You could have the player locked on the Mighty Boot weapon slot but be shown holding a gun, and make it shoot when you presses fire, etc.
#613 Posted 07 March 2011 - 09:13 AM
M210, on Mar 3 2011, 11:15 PM, said:

EDIT:
I mean changing name of my sprite via script in 2D mode
It's possible now, take a look at a.m32.
Basically you can code the little label to display anything you want, but I wouldn't mess with the predefined effector sprites.
#614 Posted 07 March 2011 - 10:33 AM
This post has been edited by M210: 07 March 2011 - 10:54 AM
#615 Posted 07 March 2011 - 02:57 PM
Wolf, on Mar 6 2011, 06:58 AM, said:
What DeeperThought suggested is the best idea - one of my projects has over 80 weapons in itself and wrestling with the hardcoded nature of Duke's weapons is still a bit of a pain. It will simply be much better to code a seperate system and just disable Duke's stuff. You can recreate gun bobbing and stuff easily enough with some built in vars. It's also easier to manage ammo rather than the hard-coded stuff, if you want to have several categories of calibre rather than just saying 'MP5 ammo' or 'AK ammo' You can detect what key the player is pressing in the aplayer actor or one of the events, so using that you can tell the game to set the gun's animation to the first firing frame for high rate of fire weapons.
I also imagine you'll want to try and code the guns (eventually at some point) to become more inaccurate like in Counter-strike or Crossfire when you hold down fire. As far as I know event_shotrange is the only real way to modify accuracy for bullets - depending on the gun you'd have a variable controlling recoil that decreases accuracy the higher it gets (and naturally decreases when you don't fire)
#616 Posted 10 March 2011 - 12:44 PM
// Stupid-ass dipswitch define NCBPBUTTON1 3590 useractor notenemy NCBPBUTTON1 0 ifactioncount 1 break else ifpdistl 800 ifhitspace { setvarvar currlev LEVEL action CBPRESS ifactioncount 1 action ANULLACTION ifvare currlev 1 setvar NCBP1 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 2 setvar NCBP2 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 3 setvar NCBP3 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 4 setvar NCBP4 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 5 setvar NCBP5 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 6 setvar NCBP6 1 soundonce SWITCH_ON quote 150 // else ifvare currlev 7 setvar NCBP7 1 soundonce SWITCH_ON // else ifvare currlev 8 setvar NCBP8 1 soundonce SWITCH_ON // else break } enda
#617 Posted 10 March 2011 - 01:10 PM
#618 Posted 10 March 2011 - 01:28 PM
action CBPRESS 0 2 1 1 1
There probably are numerous problems with the code, infact the ammount of comments probably show just how poor my coding is.
#619 Posted 10 March 2011 - 01:34 PM
I'm not trying to help fix your code yet, I'm just trying to understand what is going on with the animation because I can't see the art file or whatever you are using for the graphics.
#620 Posted 10 March 2011 - 01:40 PM
There are actually 8 duplicates defined from how it was originally intended to be coded before I integrated it in one actor (the switch).
So yeah, switch can only be on or off. When I only had "action CBPRESS" in the code, it did the same thing and just flickered on and off.
#621 Posted 10 March 2011 - 02:00 PM
action CBPRESS 1 1 1 1 1
If not, then it's your fault and you need to change the art or whatever. With that in mind, here is some code that should work:
define NCBPBUTTON1 3590 useractor notenemy NCBPBUTTON1 0 ifaction CBPRESS break ifp pfacing // this is not perfect but it's good enough for now ifpdistl 800 ifhitspace ifcanseetarget { action CBPRESS sound SWITCH_ON quote 150 ifvare LEVEL 1 setvar NCBP1 1 else ifvare LEVEL 2 setvar NCBP2 1 else ifvare LEVEL 3 setvar NCBP3 1 else ifvare LEVEL 4 setvar NCBP4 1 else ifvare LEVEL 5 setvar NCBP5 1 else ifvare LEVEL 6 setvar NCBP6 1 else ifvare LEVEL 7 setvar NCBP7 1 else ifvare currlev 8 setvar NCBP8 1 } enda
Note that this code still looks kind of odd. Why do you have a different variable for each level? I'm sure you can get by with only one variable. Also, note that LEVEL equals 0 in the first level of an episode, and you have the switch doing nothing in the case. I'm not sure if that's what you intended.
This post has been edited by DeeperThought: 10 March 2011 - 03:25 PM
#622 Posted 10 March 2011 - 02:22 PM
The switch updates the HUD depending on what level you are on (there are 8 dots at the top, one to symbolise each level) and also causes a panel to dissapear in the hub map (LEVEL 0 - there is no switch in the hub map).
The code functions, but the switch does not change tile (the tile with the ON position) when I press it. It's probably my fault and I'm half inclined to leave it.