EDuke32 Scripting "CON coding help"
#361 Posted 07 October 2009 - 08:10 PM
Basically, what im trying to do is create a motion tracker ala Aliens that will appear in the lower right hand corner. The current weapon will be "holstered" and the motion tracker graphics displayed down there as part of the hud, then over the top of the graphics would be a small "zone" or "playpen" where any monsters within a certain units distance/radius would be displayed as white dots. This would update every couple seconds... So on, and so forth. Im not very experienced so obviously this is pretty tough. Im not even sure it can be done with Eduke, though I have seen something like this done with Wolfenstein 3D, and the 2D map was originally going to display monster sprites. so it should be possible... Anyway, help on this would be greatly appreciated.
#362 Posted 07 October 2009 - 08:16 PM
DeeperThought, on Oct 8 2009, 12:03 AM, said:
#363 Posted 07 October 2009 - 08:35 PM
Ilovefoxes, on Oct 7 2009, 09:16 PM, said:
gamevar player 0 0 gamevar counter 0 0 state countplayers headspritestat player 10 whilevarn player -1 { addvar counter 1 nextspritestat player player } ends
I guess that would work, but if you try it once the game is underway, it would count holoduke holograms as players.
#365 Posted 08 October 2009 - 12:15 AM
#366 Posted 08 October 2009 - 01:54 AM
DeeperThought, on Oct 8 2009, 01:15 AM, said:
Wouldnt giving it con exceptions work? IE... ifwasweapon...?
#367 Posted 08 October 2009 - 04:28 AM
Been digging through the Eduke wiki on this other thing im doing, and because im stupid I dont know what im looking for... I have the following code:
gamevar armorhud 0 2 gamevar armorhud2 0 2 gamevar xvar2 0 2 define ARMSCALE 1 onevent EVENT_DISPLAYREST { setvar xvar2 0 // set starting x coordinate getplayer[THISACTOR].shield_amount armorhud // get the player's health. ifvarg armorhud 0 { // only proceed if the player has any health. setvarvar armorhud2 armorhud // save a copy for later. divvar armorhud ARMSCALE // make each column worth 10 hp. modvar armorhud2 ARMSCALE // gets the remainder of the division so that... ifvarg armorhud2 0 { addvar armorhud 1 // ...we can round up. each column will only disappear when all 10 hp are gone. } whilevarn armorhud 0 { // repeat for each column rotatesprite xvar2 0 65536 0 199 0 1 16 0 0 xdim ydim // draws one column at (xvar,182) addvar xvar2 1 // move to the right subvar armorhud 1 // next column } } } endevent
Basically I figured i could duplicate the health bar code and point it towards the armor like it was nothing. I suppose if I knew what the heck I was doing that would help. I've tried a couple different strategies and I just dont get it... I dont even get how the health bar code actually finds the players health as it original is which basically leaves me unable to figure out the armor code either.
NOTE: I changed the gamevars for this one on the off chance it was causing some kind of a contradiction. I know that changing it to 'armorhud' does not make it put to armor.
This post has been edited by Commando Nukem: 08 October 2009 - 05:08 AM
#368 Posted 08 October 2009 - 11:01 AM
DeeperThought, on Oct 8 2009, 05:15 AM, said:
#370 Posted 08 October 2009 - 10:59 PM
M210, on Oct 8 2009, 01:55 PM, said:
It's possible, but it's about ten times more difficult than it sounds. First of all, using sizeat to change the height of the player sprite will not do what you want, so don't even try. It will warp your field of view (unless you are using Polymer), and it won't actually make the player's perspective any higher. You can, of course, use a higher resolution player sprite to make him appear taller in F7 view, but that won't make things look any different in first person view.
The most important thing is to move the game camera up, while being careful not to place it inside of a ceiling. I posted some code for this over at the 3DR forum for the other Blood TC. I think that was over a year ago, and I don't have a copy of it. It was not very complicated.
But the player's bullets and other projectiles will continue to have their old origin even if the camera is moved up. This means it will seem like you are shooting from your hip, or knee, and your shots will hit below the crosshair. To fix that, you have to move the shots (which is tricky in the case of bullets). I posted some code for this over at 3DR for the other Blood TC, around the same time as the other code.
It wouldn't surprise me if there were other things you have to change to make it work.
#371 Posted 09 October 2009 - 11:07 AM
Been trying to figure out how to display current ammo amount on screen with digitalnumber/digitalnumberz. I dont get it.
gamevar ammo 0 2 gamevar x 0 2 gamevar y 0 2 gamevar shade 0 2 gamevar pal 0 2 gamevar tilenum 0 2 gamevar orientation 0 2 onevent EVENT_DISPLAYREST { ifvarg ammo 0 { setvarvar tilenum ammo } setvar x 10 setvar y 20 setvar shade 0 setvar pal 0 setvar tilenum 2472 setvar orientation 0 getactor[THISACTOR].extra tilenum digitalnumberz tilenum x y ammo shade pal orientation 0 0 x y 65536 } endevent
Likely, this isnt doing anything. Just when I thought I was begining to understand... Nope.
I'm pretty sure my problem lies with "getactor[THISACTOR].extra" I couldnt figure out how to reference the current weapons ammunition, looking through the commands... Meh.
This post has been edited by Commando Nukem: 09 October 2009 - 11:14 AM
#372 Posted 09 October 2009 - 11:21 AM
Secondly, the ammo variable should be set to the ammo amount you want to display.
#373 Posted 09 October 2009 - 11:53 AM
DeeperThought, on Oct 9 2009, 12:21 PM, said:
Isnt it? setvar tilenum 2472 ...
I thought I had this too...
and then I tried changing this:
getactor[THISACTOR].extra tilenum
to this:
getactor[currentweapon].extra ammo
and again, nothing happened. It wouldnt be so bad if I was getting an error or something, but no... nothing, natta, zipola.
DeeperThought, on Oct 9 2009, 12:21 PM, said:
ifvarg ammo 0 ? I want it to display whatever the current ammount of ammo is for the current weapon. Obviously im missing something big along the way here... Merrgh. The code is "working" its just not showing up. references must be wrong.
#374 Posted 09 October 2009 - 12:14 PM
For example, it's true that one of your lines was "setvar tilenum 2472". Sure enough, that sets tilenum to 2472 But then, after that, in the same block of code, you added "getactor[THISACTOR].extra tilenum" which sets tilenum to the value of the current actor's extra member (which would be the current player's health amount). I guess you thought that tilenum would remain at 2472, despite that, but it's hard for me to fathom what your though process was.
#375 Posted 09 October 2009 - 12:24 PM
Commando Nukem, on Oct 9 2009, 03:07 PM, said:
ifvarg ammo 0 { setvarvar tilenum ammo }
In English, it says "if 'ammo' is greater than zero (ifvarg ammo 0), then 'tilenum' becomes equal to 'ammo' (setvarvar tilenum ammo)," which has no bearing on what you're trying to do and doesn't have any effect on the rest of the script.
The important thing is to change this:
Commando Nukem, on Oct 9 2009, 03:07 PM, said:
getactor[THISACTOR].extra tilenum
to:
getplayer[THISACTOR].ammo_amount[currentweapon] ammo
which sets 'ammo' to the ammo left (getplayer[].ammo_amount[]) in the current gun (currentweapon) for the current player (THISACTOR).
http://wiki.eduke32....iki/Ammo_amount
I share Deeperthought's sentiments, and suggest that you do some general study on computer programming, or at least look up each of the commands in the wiki.
This post has been edited by Dr. Kylstein: 09 October 2009 - 12:26 PM
#377 Posted 10 October 2009 - 03:37 AM
I mean I've coded in a computer system that reads saved gamevars and displays them onscreen as a status thing. When I press K to see my ally's stuff it just reads the gamevars in my config file rather than his; but of course from his point of view it's displaying his stuff and pressing K when I'm using the PC displays his again as well. When I try and read if the weapon is unlocked, since it's unlocked for me it works ok but since it's still locked on his system it comes out negative and so desyncs since the game doesn't understand that our configs would have different saved vars or something.
This post has been edited by James: 10 October 2009 - 03:38 AM
#378 Posted 10 October 2009 - 08:58 AM
James, on Oct 10 2009, 04:37 AM, said:
I mean I've coded in a computer system that reads saved gamevars and displays them onscreen as a status thing. When I press K to see my ally's stuff it just reads the gamevars in my config file rather than his; but of course from his point of view it's displaying his stuff and pressing K when I'm using the PC displays his again as well. When I try and read if the weapon is unlocked, since it's unlocked for me it works ok but since it's still locked on his system it comes out negative and so desyncs since the game doesn't understand that our configs would have different saved vars or something.
What if you did something like this:
gamevar initplayer NO 1 gamearray weapmods 8 // each element is a bitfield storing all weapon mods for a player gamevar myweapmods 0 1 // this is what is saved to the ini file gamevar temp 0 0 state initp setvar initplayer YES readgamevar myweapmods getactor[THISACTOR].yvel temp setarray weapmods[temp] myweapmods ends actor APLAYER MAXPLAYERHEALTH PSTAND 0 0 ifvare initp NO state initp
So what you do is read the array element corresponding to the player number, rather than reading the gamevar from the file. Then you can display each player's stuff separately. When you get a new weapon mod, you add that to myweapmods, save that gamevar, and then update the array accordingly.
EDIT: It would make things messy if players changed their IDs in mid-game, but the basic concept seems sound.
This post has been edited by DeeperThought: 10 October 2009 - 09:03 AM
#380 Posted 14 October 2009 - 08:13 AM
#381 Posted 14 October 2009 - 09:05 AM
For walls and sectors, there are several things to consider:
- The game code doesn't know which walls and sectors are getting rendered. Before implementing a way for the game code to tell CON, we would need to implement a way for the engine code to tell the game code. This would make the engine <-> game limit even more broken than it already is.
- Rendered doesn't necessarily mean visible, and possibly vice versa.
- These results would vary depending of the renderer that's being used, and would even vary with different performance settings in the same renderer. That means CON scripts could potentially make wrong assumptions and only work on the renderer they were developed against.
#382 Posted 14 October 2009 - 09:30 AM
Plagman, on Oct 14 2009, 10:05 AM, said:
For walls and sectors, there are several things to consider:
- The game code doesn't know which walls and sectors are getting rendered. Before implementing a way for the game code to tell CON, we would need to implement a way for the engine code to tell the game code. This would make the engine <-> game limit even more broken than it already is.
- Rendered doesn't necessarily mean visible, and possibly vice versa.
- These results would vary depending of the renderer that's being used, and would even vary with different performance settings in the same renderer. That means CON scripts could potentially make wrong assumptions and only work on the renderer they were developed against.
Thank you for the detailed reply.
About tsprite access:
I know that there's an event EVENT_ANIMATESPRITES which works sort of like EVENT_GAME, except for tsprites. But tsprites get processed in that event only if the corresponding game world sprite has had bit 4 (16) added to its mdflags member. I was confused and I also thought that sprites would be forced into the tsprite array by that flag whether they were rendered or not (which is why I thought it was impossible to determine whether they were actually being rendered). Fortunately the reality is more sensible than my assumption!
#383 Posted 15 October 2009 - 06:26 AM
Are they dire? are they things which can alter an actor's behaviour or sometihng else?
#384 Posted 15 October 2009 - 06:29 AM
#385 Posted 15 October 2009 - 08:28 AM
Here's a link to the fixed build.
Once again, Plagman, thanks!
#386 Posted 17 October 2009 - 06:21 AM
Quote
33317: 31337 {
33318: 1899 getactor 253 19 332 230 332 14
33325: 1901 divvarvar 332
33327: 4 guniqhudid 253 17
33330: 1902 cos 385
33332: 4 guniqhudid 253 15
33335: 1903 sin 386
33337: 4 guniqhudid 253 15
33340: 1904 hitscan
33341: 4 guniqhudid 253 0
33344: 4 guniqhudid 253 1
33347: 4 guniqhudid 253 2
33350: 4 guniqhudid 253 13 385 386 332current actor: 288 (2605)
g_errorLineNum: 0, g_tw: 386
This is the CON part that causes the error:
Quote
mulvar ATEMP 16384
divvarvar ATEMP sprite[THISACTOR].xvel
cos ANGX sprite[THISACTOR].ang
sin ANGY sprite[THISACTOR].ang
hitscan sprite[THISACTOR].x sprite[THISACTOR].y sprite[THISACTOR].z sprite[THISACTOR].sectnum ANGX ANGY ATEMP
RETURN RETURN ATARGET RETURN RETURN RETURN 4294901808
#387 Posted 18 October 2009 - 12:25 PM
#388 Posted 22 October 2009 - 06:54 PM
I'm developing a shield buff [like a status buff] for NR, which is supposed to in theory "block" and sometimes "reflect/deflect" mystic-based attacks [one example can be the Octabrain's/Cycloid's mindblasts. I got it to "block" okay, but I was curious if anyone had ever tried the "deflect" part in their own code runs before.
Basically what I'm hoping to pull off is that when a projectile that can be blocked/deflected hits the shield, the original Projectile copies certain properties to a new projectile of identical strength and stuff but with the player's owner id, and bounce it away from them. For the best effect in my opinion, I need to know if it's possible to make a projectile disappear mid-impact[as in it won't show it's impact/explosion animation and just vanishes instantly]. I'm not sure if it can be done with custom or hard-coded projectiles or not.
I'm going to eventually work at this, but I got other tweaks for earlier stuff to worry about before I do, and I figured on dropping this set of questions on you guys in the meantime.
This post has been edited by Lord Misfit: 22 October 2009 - 06:55 PM
#389 Posted 22 October 2009 - 07:04 PM
#390 Posted 22 October 2009 - 08:46 PM
Lord Misfit, on Oct 22 2009, 07:54 PM, said:
I've made a few player force fields that deflect projectiles. Just change the angle of the projectile, it's zvel and owner. You don't need to fire a new one. You can spawn an animation sprite at the point where it deflects and play a sound. Maybe the real problem is you don't know how to make the projectile deflect without it dying. You can have the projectile detect distance to the force field and hitscan for it, then turn it around before it actually hits anything. Another method is to allow it to hit, but use EVENT_KILLIT to cancel its death and then turn it around from there.