Home  |  About  | Last |  Submit  |  Contact
AllQuests.com



Previous Question:  Madness Guts in the RooM!!!  Duke Nukem 3D ModificationsNext Question:  How to install Grub from live Ubuntu cd.  Tutorials Tips
Question EDuke32 Scripting (CON coding) ( 3D Realms Forums Duke Nukem 3D Modifications )
Updated: 2008-05-08 18:43:58 (799)
EDuke32 Scripting (CON coding)

The name says it all. Will this thread become a place for people to post about CON coding problems, questions and puzzles, or just boast about their latest code? Dunno. Do we really want or need a thread like that? Dunno. But I've started a lot of little threads about coding problems, and I would like to try having one thread instead, at least for my own purposes. Everyone is welcome to join in.

So, to inaugerate this new thread, I have a problem which is illustrated by the following pic:


The player is standing on a transparent sprite bridge. The Enforcer, as you can see, has managed to fall under it, where no actor is supposed to go. There are no gaps in the bridge (at least none that the player can fall through). What I want to do is write code that will prevent actors from falling down there. This is a major problem for my bots, who jump a lot (it only happens to actors who jump, and only on the descent of a jump). A few seconds of fighting on the ice bridge, and all my bots end up stuck at the bottom. I used the Enforcer to illustrate, in order to show that it isn't a problem particular to my bots. Ideas?

Answers: EDuke32 Scripting (CON coding) ( 3D Realms Forums Duke Nukem 3D Modifications )
EDuke32 Scripting (CON coding)

Okay, I have an interesting question here:

For anyone who has been keeping tabs on my project, you'll possibly know that eventual plans include multi-character support in RPG style. This will require me to have variables and parameters for each character all at once. The space for variables is not my problem so much as the fact that I'm pretty sure if I don't use the proper methods[and perhaps even if I find a good enough one] that I'll hit the 98k compiling limit, as I am at just over 90k right now[and yes I have made sure to state stuff and reduce as much redundant code as I can and it still totals out to 90k].

The main dilemma is finding an effective switching method for giving the 'Player' the correct character's stats without having another character's stats bleeding over to them when a switch occurs. I have one method for this I am testing as I speak, but it appears it will require in eventuality a large amount of coding. There's 14 planned characters[including Duke though], so there's bound to be much code involved either way.

My current method involves using EVENT_GAME to keep tabs on the 'Selected Character' variable, and it would set the 'Player's' main parameters to the 'selected character's' parameters. This method indeed works so far, but it requires a lot of modifiying directly to the currently-selected character's stats in code that involves things like level, stats, inventory item times, powerup times, underwater lung times, etc... which requires large enough blocks of code to detect the character detected and set their stats properly. If I didn't already have 90k compiling size, I wouldn't be too worried about the current method.

However I believe personally there might be less code-intensive ways to perform this kind of thing that might prevent me from hitting 98k and having to ask for another compile size extension[which I know will break past-savegame compatibility from past experience if TerminX did decide to do it].

If there is nothing else that can be done, I still thank you for listening to my dilemma anyways. I'm asking this to you guys now because I've just starting using my above method and very little is really coded right now, and I wanted to know if anyone could think of a better and less code-heavy method before I get too immersed with either my method or another.

Lord Misfit

EDuke32 Scripting (CON coding)

Is this third person, seperate actors? Or is the player becoming each of these characters?

Mblackwell

EDuke32 Scripting (CON coding)

The 'player' is whatever character is selected at the moment, basically. There's the main player versions of parameters, and then each of the actual characters have their own parameters for each. This is for things like a status menu where you can compare the characters' stats in more detail, like in a real RPG game.

Lord Misfit

EDuke32 Scripting (CON coding)

I'm sure I'm not the only person to have encountered this problem... An actor moves into a wall, but instead of getting stopped by it, they suddenly pop-up to the top of the wall. I think it only happens with actors that are airborne. I would like to know how to prevent this from happening. Any ideas?

DeeperThought

EDuke32 Scripting (CON coding)

I've only experienced your “problem” in Mapster32 while browsing around, but it isn't a “problem” in that scenario.

Hendricks266

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Hendricks266
I've only experienced your ?problem? in Mapster32 while browsing around, but it isn't a ?problem? in that scenario.
Well, you wouldn't put scare quotes around it if it happened to you. I can assure you this problem is real!

DeeperThought

EDuke32 Scripting (CON coding)

Yes, yes. I just haven't experienced it in EDuke32.

Hendricks266

EDuke32 Scripting (CON coding)

Perhaps you're using movesprite with the wrong clipmask?

Mblackwell

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Mblackwell
Perhaps you're using movesprite with the wrong clipmask?
This has happened with different kinds of moves. It has happened with normal move commands, and it has happened with movesprite (using the correct clipmask, *cough *cough, or at least the one recommended by TX). In this instance, I am seeing it happen with shell casings. These are the normal, hardcoded shell casings while they are airborne, but they turn into actors when they hit the ground. At the beginning of E1L1, I fire a bunch bullets near that sloped structure in the middle of the roof, and the casings that hit a vertical (non-sloped) wall of the structure immediately pop-up to the top of it (and then roll to a stop, because of my code). Even if they hit near the bottom of the wall, they will end up on top of the thing. Pretty minor, I guess, but it annoys me.

EDIT: I have a workaround for this particular situation now. The casings do hitscans, and if the scan hits something right in front of them, they change their angle and "bounce" off it.

DeeperThought

EDuke32 Scripting (CON coding)

I tried hijacking the hard coded shell casings myself and I got really poor results. Every time I thought they were working well, I would encounter another situation in which there were problems. It's better to just make new shell casings out of projectiles and intercept the spawning of the hard coded ones.

TerminX

EDuke32 Scripting (CON coding)

The wall thing has been an engine problem since the dawn of time. In the mapster grid, its only a problem on downward and rightward facing walls. I dont know why this happens, but its an old problem.

Bonesnapper

EDuke32 Scripting (CON coding)

In mapster32 it would be a pain in the ass to edit if that didn't happen, if you want to get somewhere fast you can walk it instead of "flying" to go over things.

DavoX

EDuke32 Scripting (CON coding)

New question: is there a way to reduce the amount of knockback the player suffers when they take a hit without reducing the damage done to them? I don't really know of anything else to elaborate on this question.

Lord Misfit

EDuke32 Scripting (CON coding)

The only way I can see is to just counter that with moving the player in the opposite direction, but obviously that's a pretty sloppy solution.

I already asked this question and didn't get an answer, but is it not possible to give an action to a custom projectile? I've tried EVENT_EGS and EVENT_GAME and neither worked.

Jblade

EDuke32 Scripting (CON coding)

Do you just want multiple viewing angles, or do you want to have multiple frames of animation too?

DeeperThought

EDuke32 Scripting (CON coding)

Just multiple view angles for the time being, although I'm sure I'll be using multiple animation frames at some point as well.

Jblade

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Jblade
Just multiple view angles for the time being, although I'm sure I'll be using multiple animation frames at some point as well.
In that case, I would suggest you look at my Mario Nukem code, once again. The Koopa shells, when kicked, become projectiles that bounce around. They use viewing angles.

DeeperThought

EDuke32 Scripting (CON coding)

Ok, I'll take a look - thanks once again

Jblade

EDuke32 Scripting (CON coding)

New question:

In my mod a couple of my characters are meant to be so big and heavy they their jumping is subpar and they they should realistically be able to sink downwards automatically when submerged underwater when they're not moving[posxv = 0 & posyv = 0]. However when trying to do this, and using DNCOORDS to monitor my Z-position in the water, I notice they don't seem to sink[or rise] at all.

Code:
ifvare SECTORLOTAG 2
 {
// MAKES DUKE, ESSENCE AND CYBANIS SINK SLOWLY TOWARDS THE BOTTOM OF WATER SECTORS WHEN IDLE

    ifvare CHARACTERSELECTED? 1 // Duke
    {
     getactor[THISACTOR].z z
     addvar z 4
     setactor[THISACTOR].z z
    }
    else
    ifvare CHARACTERSELECTED? 6 // ESSence
    {
     getactor[THISACTOR].z z
     addvar z 16
     setactor[THISACTOR].z z
    }
    else
    ifvare CHARACTERSELECTED? 9 // Cybanis
    {
     getactor[THISACTOR].z z
     addvar z 12
     setactor[THISACTOR].z z
    }
// AIR TIME EFFECTS
  ifvarn SETAIRTIME 1
  {
    setplayer[THISACTOR].airleft AIRTIME 
    setvar SETAIRTIME 1
  }

  ifvarg INVULNTIME 0
  {
   ifvarg SCUBATIME 0
   {
    addvar SCUBATIME 1
    setplayer[THISACTOR].scuba_amount SCUBATIME 
   }
  }

  ifp pjetpack
  {
   addvar JETPACKBUBBLEVAR 1
   ifvare JETPACKBUBBLEVAR 16
   {
    spawn WATERBUBBLE 
    spawn WATERBUBBLE 
    spawn WATERBUBBLE 
    setvar JETPACKBUBBLEVAR 0
   }
  }

 }

  ifvarg SCUBATIME 0
  {
   ifvarl AIRTIME 1 { setvar AIRTIME 1 setplayer[THISACTOR].airleft 1 }
  }
  ifvarl AIRTIME 1
  {
   addvar AIRTICCOUNTER2 1
   ifvare AIRTICCOUNTER2 8
   {
    ifvarg INVULNTIME 0
    {
    }
    else
    {
     randvar TEMPMESS4 3
     addvarvar TEMPMESS1 TEMPMESS4
     getactor[THISACTOR].extra TEMPMESS3
     setvarvar TEMPMESS2 MAXHITPOINTS
     divvarvar TEMPMESS2 100
     subvar TEMPMESS2 1
     subvarvar TEMPMESS3 TEMPMESS2
     subvarvar TEMPMESS3 TEMPMESS1
     ifvarn CHEATGOD 1 { ifvarg TEMPMESS3 0 { setactor[THISACTOR].extra TEMPMESS3 } else { setactor[THISACTOR].extra 0 } }
    }
    setvar AIRTICCOUNTER2 0
   }
  }
  else
  {
    setvar TEMPMESS1 0
  }
The part of the code that I'm using for this is in RED. I don't have the posxv/posyv checks on there yet because it seems it doesn't work with or without the checks at the moment and I'll worry about adding those when I know the sinking code actually does its' job. >.>

Lord Misfit

EDuke32 Scripting (CON coding)

Don't modify their z, instead change the poszv.

Mblackwell

EDuke32 Scripting (CON coding)

Cool, that seems to work[although I gotta make it higher than 256 for any noticable effect to occur].

Lord Misfit

EDuke32 Scripting (CON coding)

Can you make a waypoint system for a floating model that makes a different action mid-air dependant on the lotag-palletenumber-anyotherindicator of the sprite that would be normally used as waypoint?

Let's say you want a model to follow a path mid-air and when it finds a waypoint with lotag 3 , the model spawns something.

DavoX

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DavoX
Can you make a waypoint system for a floating model that makes a different action mid-air dependant on the lotag-palletenumber-anyotherindicator of the sprite that would be normally used as waypoint?

Let's say you want a model to follow a path mid-air and when it finds a waypoint with lotag 3 , the model spawns something.
Yes, it can be done. Do you want to know how it can be done because you plan to code it yourself?

DeeperThought

EDuke32 Scripting (CON coding)

Yes, i don't know if i'll be able to pull it off by it doesn't hurt to try, and i might even learn a thing or two .

DavoX

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DavoX
Yes, i don't know if i'll be able to pull it off by it doesn't hurt to try, and i might even learn a thing or two .
On a scale of 10, coding waypoints has a difficulty of about 8 (plus or minus 2 points depending on how sophisticated and flexible you want the system to be). It's not something that you should undertake until you have more coding experience.

If what you described is all that the waypoint system needs to do, then it can be pretty simple. But before anyone starts coding it, it would be good to know whether multiple actors in the same map will be following waypoints, and whether they will be following different paths.

DeeperThought

EDuke32 Scripting (CON coding)

Nah, im talking about a waypoint system that any actor i decide could take at the moment, for example i want model A to follow this path, then on another map i want model B to follow another path...something like that.

I'm not talking about some uber duke-bot waypoint system.

DavoX

EDuke32 Scripting (CON coding)

What does the command 'getincangle' do, and what are the needed lines to use it? Normally I'd use trial and error but it takes 3 variables so obviously that's not really possible to do here. The same also goes for the 'jump' command heh

Jblade

EDuke32 Scripting (CON coding)

Is there something you are trying to accomplish, or do you just want to know about some random command for no particular reason?

DeeperThought

EDuke32 Scripting (CON coding)

I suppose it calculates absolute difference between angles.

Code:
short getincangle(short a,short na)
{
    a &= 2047;
    na &= 2047;

    if(klabs(a-na) < 1024)
        return (na-a);
    else
    {
        if(na > 1024) na -= 2048;
        if(a > 1024) a -= 2048;

        na -= 2048;
        a -= 2048;
        return (na-a);
    }
}

Hunter_rus

EDuke32 Scripting (CON coding)

You mean I wrote my own state for that when the command already existed?

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DeeperThought
Is there something you are trying to accomplish, or do you just want to know about some random command for no particular reason?
No particular reason

EDIT: never mind; I fixed my problem by giving it a strength after it had been hit. Should of figured that out sooner heh.

Jblade

EDuke32 Scripting (CON coding)

How do I get an actor (utilising Zshoot of course) to shoot at the same angle (up and down) as the player is? DT helped me with it on AMC but I'm still drawing blanks. I've tried using trial and error but so far all I can do is make it shoot up if the player's looking down and visa-versa.

Jblade

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Jblade
How do I get an actor (utilising Zshoot of course) to shoot at the same angle (up and down) as the player is? DT helped me with it on AMC but I'm still drawing blanks. I've tried using trial and error but so far all I can do is make it shoot up if the player's looking down and visa-versa.
Heh, well, I would start by multiplying that number by -1

DeeperThought

EDuke32 Scripting (CON coding)

heh, I tried that and it didn't work

Jblade

EDuke32 Scripting (CON coding)

I'm no expert (not even a beginner), but it sounds like you have your y-axis inverted (an option in Setup). Uninvert it, and maybe your plan will work.

Also, bear in mind that some players will invert the y-axis and some won't. Do you have a plan to deal with that?

Maruno

EDuke32 Scripting (CON coding)

That doesn't matter, as horiz values are the same in either case.

Mblackwell

EDuke32 Scripting (CON coding)

Is it not possible to half zoom minitext/gametext, as 5x5 font is still too big where I wish for it to be displayed.

Quakis

EDuke32 Scripting (CON coding)

Nope, not possible. You'll have to make a new font.

Mblackwell

EDuke32 Scripting (CON coding)

I did, and any small than 5x5 won't even look like letters anymore! The best approach is to go for graphics then.

Quakis

EDuke32 Scripting (CON coding)

no they dont... 29 make it freeze but anything above makes a jumpstart to about half speed... at least with my eduke (pc doesnt have internet and uses a dec 2006 build of eduke32) btw yes i do use two compleataly different pcs for this stuff

Dopefish7590

EDuke32 Scripting (CON coding)

I have a question, is there anything about bullet spread in the con files?
I want to make the bullets from Duke's pistol not spread so much, so that I can actually shoot switches that are far off.

johndough

EDuke32 Scripting (CON coding)

Use EVENT_GETSHOTRANGE.

Hendricks266

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Hendricks266
Use EVENT_GETSHOTRANGE.
Does this only work in EDuke?
I was hoping for a quick con fix by changing a bullet spread number.
Do I have to rewrite the pistol code?

johndough

EDuke32 Scripting (CON coding)

Yes, it only works in EDuke32.

Have a look at this.

Hendricks266

EDuke32 Scripting (CON coding)

anyhting I can code ?
DT? Hellbound? Hendricks266? Lord Misfit?

Dopefish7590

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dopefish7590
anyhting I can code ?
DT? Hellbound? Hendricks266? Lord Misfit?
This next task is similar to a little touch I just added to one of the enemies in DNWMD. In your case, it involves the LIZMAN actor. First, look through his code and notice that he doesn't dodge very much, because of a ifrnd 1 condition that occurs in several places. Remove it. Next, increase the speed of his dodge move to 256, but do this without increasing the speed of his other moves. Lastly, make him spawn FRAMEEFFECT1 while he is dodging (and only while he is dodging). Test it by shooting some rockets at him.

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Hendricks266
Yes, it only works in EDuke32.

Have a look at this.
So I guess I use "event_getshotrange" and set "angrange" to 1.
Sorry if I'm a big noob here, but where and how do I use this code?
Do I add it to the pistol code in the con files?
I can't even find the code for the pistol in the con files.
I found "firstgunsprite" and "pistol_weapon" in the text, but there just isn't any real code that I can see.
It just looks like code for spawning and picking up the weapon and stuff.
I imagine a lot of the core behavior is hardcoded.

johndough

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DeeperThought
This next task is similar to a little touch I just added to one of the enemies in DNWMD. In your case, it involves the LIZMAN actor. First, look through his code and notice that he doesn't dodge very much, because of a ifrnd 1 condition that occurs in several places. Remove it. Next, increase the speed of his dodge move to 256, but do this without increasing the speed of his other moves. Lastly, make him spawn FRAMEEFFECT1 while he is dodging (and only while he is dodging). Test it by shooting some rockets at him.
ok...

Dopefish7590

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by johndough
So I guess I use "event_getshotrange" and set "angrange" to 1.
Sorry if I'm a big noob here, but where and how do I use this code?
Do I add it to the pistol code in the con files?
I can't even find the code for the pistol in the con files.
I found "firstgunsprite" and "pistol_weapon" in the text, but there just isn't any real code that I can see.
It just looks like code for spawning and picking up the weapon and stuff.
I imagine a lot of the core behavior is hardcoded.
Put this at the very bottom of your GAME.CON\EDUKE.CON file.

Code:
onevent EVENT_GETSHOTRANGE
ifvare WEAPON 1 { setvar ANGRANGE 1 }
endevent

Hendricks266

EDuke32 Scripting (CON coding)

OK, here's my newest problem. I have a useractor enemy robot thing which flies around. If it dies in the air, then falls to the ground, it spawns JIBS6, which of course it shouldn't, being a robot. The trouble is, this is hardcoded.

My plan to eliminate this was to put code in EVENT_EGS for JIBS6 which detects whether it was spawned by my robot actor, and if it was, then change the picnum to some scrap. Unfortunately, my plan was thwarted because the owner member of JIBS6 in that case is not the robot actor it is coming out of, but instead is the player. Obviously, I don't want to change all JIBS6 owned by the player. So, what can I do? Is this a bug in EDuke32?

DeeperThought

EDuke32 Scripting (CON coding)

The only reason I can think of for the player to be the owner is that it could be a way of not having to sync those JIBS in a multiplayer game.

Usurper

EDuke32 Scripting (CON coding)

All of the gibs are owned by the player. The game was apparently just coded that way, heh. I don't know if changing it will break anything.

TerminX

EDuke32 Scripting (CON coding)

Rather than risk breaking something by messing with owner, how about making a new member that always holds the true owner? Owner is screwed up; not only does it sometimes start with the wrong value, but it changes when the sprite is hit by a weapon. True owner wouldn't do that. Also, if the ifspawnedby command were based on true owner, then ifspawnedby and ifwasweapon would become different commands, which they should be.

DeeperThought

EDuke32 Scripting (CON coding)

It doesn't quite work like that. Messing with the internals like that invariably causes something else to break at some point down the line. I'll see about fixing it specifically for the gibs.

TerminX

EDuke32 Scripting (CON coding)

If I recall, DeeperThought once experimented with smoother running movement. Has anybody had any success with this? I briefly did it myself, but the way I did it wasn't as flexible or realistic as I wanted.

Dr. Kylstien

EDuke32 Scripting (CON coding)

I have code for that, but it's part of a project that I'm not talking about here.

You could start by setting RUNNINGSPEED (as defined in user.con) at a very low value, then raise the player's runspeed in game depending on how long the player has been running. There are several other things you will have to do, too, in order to make sure that the player's walking speed isn't too slow and prevent other unwanted side effects (for example, if the player stops running for a split second and then starts again, you want them to lose some speed, but you don't want them to go all the way down to the starting runspeed).

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DeeperThought
I have code for that, but it's part of a project that I'm not talking about here.

You could start by setting RUNNINGSPEED (as defined in user.con) at a very low value, then raise the player's runspeed in game depending on how long the player has been running. There are several other things you will have to do, too, in order to make sure that the player's walking speed isn't too slow and prevent other unwanted side effects (for example, if the player stops running for a split second and then starts again, you want them to lose some speed, but you don't want them to go all the way down to the starting runspeed).
I don't think that will give me the kind of inertia I want. My attempt had a natural feel to the inertia, but it somewhat impeded strafing and the inertia was only in the direction faced by the player or the reverse angle.

Dr. Kylstien

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dr. Kylstien
I don't think that will give me the kind of inertia I want. My attempt had a natural feel to the inertia, but it somewhat impeded strafing and the inertia was only in the direction faced by the player or the reverse angle.
If you want realistic physics, then I guess you'll need to monitor posxv, posyv, the move and strafing events, and the player's angle, and constantly write to posxv and posyv so they change in a realistic way. You'll probably need to use the sin and cos functions and fun stuff like that. Other than that, I don't know what to tell you, unless you want to post your coding attempt in the hopes that someone will suggest improvements.

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by DeeperThought
If you want realistic physics, then I guess you'll need to monitor posxv, posyv, the move and strafing events, and the player's angle, and constantly write to posxv and posyv so they change in a realistic way. You'll probably need to use the sin and cos functions and fun stuff like that. Other than that, I don't know what to tell you, unless you want to post your coding attempt in the hopes that someone will suggest improvements.
That's exactly what I did, in fact. I'd like to figure out a way to fix those problems I mentioned though.

Edit: After a brief experiment with gamevars for x and y velocities (ice-skating anyone?), I switched back to the way I had it before. Now I just need to fix the strafing. What I've got is a speed gamevar and I'm using sin and cos to set the posxv and posyv. Strangely, enough, constantly setting the velocities doesn't completely prevent strafing, but it really slows. Any suggestions?

Dr. Kylstien

EDuke32 Scripting (CON coding)

You could always check for the key input for strafing .

Mblackwell

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Mblackwell
You could always check for the key input for strafing .
Already done. It's the actual movement that's tricky.

Dr. Kylstien

EDuke32 Scripting (CON coding)

I'm very hesitant to claim that I've found a bug in EDuke32 these days, but this latest problem has me stumped and I'm beginning to wonder...

First the code, then I'll describe the problem.

Code:
case KOOPASHELLPROJ
addvar countvar 1

ifp phigher nullop else
{
     ifpdistl 844
         ifvare knockback 0
             ifvarg countvar 6
    {
        state setknockback
        setvarvar debugvar countvar // debugvar is for display purposes only
        //addphealth -100
    }
}
break
Above is a case in EVENT_GAME. KOOPASHELLPROJ is a projectile. It has its own counter (countvar) which is per actor and starts at 0. State setknockback does some stuff to the player when the player is close and countvar reaches 7. The trouble is, if one of these projectiles is already in the air, and the player fires another one, the countvar on the new one does not start at 0 and is immediately high enough to activate state setknockback. It seems that the countvar on the new projectile is about as high as the countvar of the projectile that is already in the air, as though the new one is stealing the old one's ID or something. I have checked to make sure that countvar is indeed per actor, and I have checked for other code that could be changing the value.

DeeperThought

EDuke32 Scripting (CON coding)

Set countvar back to 0 when the actor is deleted. Mblackwell has already made it clear enough that per-actor vars are not reset when a sprite id slot is erased and then given to another totally different sprite.

Hendricks266

EDuke32 Scripting (CON coding)

You running that in EVENT_GAME?

Quick hypothesis:

Use getactorvar and put things into temp values and return the resultant value you want to the actor you want with sectorvar.

Another: Include a variable "BEENCHECKED" if false initialize countvar to 0, and otherwise add 1.

EG:

Code:
case KOOPASHELLPROJ
    ifvare BEENCHECKED 0
    {
       setvar BEENCHECKED 1
       setvar countvar 0
    }
    else
        addvar countvar 1

    ifp phigher nullop else
    {
         ifpdistl 844
             ifvare knockback 0
                 ifvarg countvar 6
        {
            state setknockback
            setvarvar debugvar countvar // debugvar is for display purposes only
            //addphealth -100
        }
    }
    break
And perhaps you must combine the two. I can't test anything at the moment. For all I know in EVENT_GAME it's technically setting vars within the player actor. But those are two suggestions. Play with them.

Mblackwell

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Hendricks266
Set countvar back to 0 when the actor is deleted. Mblackwell has already made it clear enough that per-actor vars are not reset when a sprite id slot is erased and then given to another totally different sprite.
That bug was supposed to have been fixed a long time ago, and AFAIK it was fixed. I already tried setting countvar to 0 in EVENT_EGS, but that didn't work. If setting it to 0 when the sprite is spawned doesn't help, then I don't see how setting it to 0 when it is deleted is going to help either. Besides which, the problem occurs before any of the projectiles have been deleted. In fact, if you read my post, you'll see that it happens only when there is another of the projectiles still in the map.

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Mblackwell
For all I know in EVENT_GAME it's technically setting vars within the player actor. But those are two suggestions. Play with them.
If that were the case (which is what your first suggestion seems to assume, unless I have completely misunderstood it), then EVENT_GAME would not work at all (think about how typical EVENT_GAME code starts: getactor[THISACTOR].picnum ...).

As for the second suggestion: if BEENCHECKED is global or per-player, then it will stay at 1 and the problem will occur again. If it is per-actor, then it is just another per-actor var that can get screwed up by whatever is causing the problem in the first place.

I think I can work around this by putting some code in APLAYER, but I'm mainly curious about what is causing the problem.

DeeperThought

EDuke32 Scripting (CON coding)

make it per actor of course....

Mblackwell

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Mblackwell
make it per actor of course....
Nice try, but no, it didn't work. I have confirmed that per actor vars are starting at 0, as they're supposed to, so adding the extra code didn't do anything. Somehow countvar in one projectile is taking the value of countvar in a different projectile, after it spawns and initializes.

It works like this:

I fire projectile 1. No problems.

13 ticks later, I fire projectile 2. Proj 2 starts with countvar 0, but then, in the next tick, Proj 2's countvar = 14, a value which apparently got stolen from proj 1 somehow.

If I continue to fire a projectile every 13 ticks, their countvars will continue to be set to 14 after the first tick. So, apparently, the countvar is always stolen from the last one fired.

If I wait a bit longer, then the countvar will be set higher. But if I wait until the first projectile is gone from the map, then it works as it is supposed to.

I have no code anywhere that sets countvar externally -- countvar is always set from within an actor using setvar. I'm also not doing anything like spawning an actor which changes the value of countvar (I've made that kind of mistake a couple of times in the past). I guess there's not much point in listing all the things I'm not doing. Suffice it to say that I can't figure out how I could be doing it.

I have workaround code for this in APLAYER. But, this apparent bug could be affecting my other mods in ways that I'm not even aware of (it could be responsible for an unresolved bug in my DNA mod, for example, which uses lots of EVENT_GAME code on special projectiles) so it still concerns me.

DeeperThought

EDuke32 Scripting (CON coding)

How does operateactivators work?

Dr. Kylstien

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dr. Kylstien
How does operateactivators work?
I don't really know, but here's some cource code. Maybe you can figure it out.

This first bit pertains to the con command:

Code:
    case CON_ACTIVATEBYSECTOR:
    case CON_OPERATESECTORS:
    case CON_OPERATEACTIVATORS:
    case CON_SETASPECT:
    case CON_SSP:
        insptr++;
        {
            int var1 = GetGameVarID(*insptr++,g_i,g_p), var2;
            if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID)
            {
                var2 = g_p;
                insptr++;
            }
            else var2 = GetGameVarID(*insptr++,g_i,g_p);

            switch (tw)
            {
            case CON_ACTIVATEBYSECTOR:
                activatebysector(var1, var2);
                break;
            case CON_OPERATESECTORS:
                operatesectors(var1, var2);
                break;
            case CON_OPERATEACTIVATORS:
                operateactivators(var1, var2);
                break;
            case CON_SETASPECT:
                setaspect(var1, var2);
                break;
            case CON_SSP:
                ssp(var1, var2);
                break;
            }
            break;
        }
This next code is the function itself (which can be found in sector.c):

Code:
void operateactivators(int low,int snum)
{
    int i, j, k;
    short *p;
    walltype *wal;

    for (i=numcyclers-1;i>=0;i--)
    {
        p = &cyclers[i][0];

        if (p[4] == low)
        {
            p[5] = !p[5];

            sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3];
            wal = &wall[sector[p[0]].wallptr];
            for (j=sector[p[0]].wallnum;j > 0;j--,wal++)
                wal->shade = p[3];
        }
    }

    i = headspritestat[8];
    k = -1;
    while (i >= 0)
    {
        if (sprite[i].lotag == low)
        {
            if (sprite[i].picnum == ACTIVATORLOCKED)
            {
                if (sector[SECT].lotag&16384)
                    sector[SECT].lotag &= 65535-16384;
                else
                    sector[SECT].lotag |= 16384;

                if (snum >= 0)
                {
                    if (sector[SECT].lotag&16384)
                        FTA(4,&ps[snum]);
                    else FTA(8,&ps[snum]);
                }
            }
            else
            {
                switch (SHT)
                {
                case 0:
                    break;
                case 1:
                    if (sector[SECT].floorz != sector[SECT].ceilingz)
                    {
                        i = nextspritestat[i];
                        continue;
                    }
                    break;
                case 2:
                    if (sector[SECT].floorz == sector[SECT].ceilingz)
                    {
                        i = nextspritestat[i];
                        continue;
                    }
                    break;
                }

                if (sector[sprite[i].sectnum].lotag < 3)
                {
                    j = headspritesect[sprite[i].sectnum];
                    while (j >= 0)
                    {
                        if (sprite[j].statnum == 3) switch (sprite[j].lotag)
                            {
                            case 36:
                            case 31:
                            case 32:
                            case 18:
                                hittype[j].temp_data[0] = 1-hittype[j].temp_data[0];
                                callsound(SECT,j);
                                break;
                            }
                        j = nextspritesect[j];
                    }
                }

                if (k == -1 && (sector[SECT].lotag&0xff) == 22)
                    k = callsound(SECT,i);

                operatesectors(SECT,i);
            }
        }
        i = nextspritestat[i];
    }

    operaterespawns(low);
}
Have fun with that

DeeperThought

EDuke32 Scripting (CON coding)

I already looked in the source code before you posted. On a wild guess I just supplied it a lotag and -1 as parameters and it seems to work. I think the second parameter may have something to do with a sector id.

Dr. Kylstien

EDuke32 Scripting (CON coding)

No, it's a player id.

TerminX

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by TerminX
No, it's a player id.
Would you mind explaining what it's used for?

-----------------------
Edit:
I'd also like to know what the maximum value is for a gamevar.

Dr. Kylstien

EDuke32 Scripting (CON coding)

ive been having abit of trouble getting code for only mking an enemy notice you if you are infornt of it... the actor just "freezes" and doesnt do anything i wrapped this code around the code in the actors main code state is there any way of fixing this?
Code:
state troopcode fall
 ifpdistl 500
  {
  ifangdiffl 512
   {
[actor code state here excluding ends]
   }
  }
ends

Dopefish7590

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dr. Kylstien
Would you mind explaining what it's used for?

-----------------------
Edit:
I'd also like to know what the maximum value is for a gamevar.
To know which player to transmit messages to iirc (I could be wrong).

Also I think it's 32768 (again, I could be wrong).

Mblackwell

EDuke32 Scripting (CON coding)

User defined gamevars take values from -2147483648 to 2147483647. Some of the special built in ones point to chars or shorts, so there are a handful of vars that have smaller ranges.

TerminX

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dopefish7590
ive been having abit of trouble getting code for only mking an enemy notice you if you are infornt of it... the actor just "freezes" and doesnt do anything i wrapped this code around the code in the actors main code state is there any way of fixing this?
Code:
state troopcode fall
 ifpdistl 500
  {
  ifangdiffl 512
   {
[actor code state here excluding ends]
   }
  }
ends
They are freezing because you told them not to execute any code unless the player is standing close enough to touch them. By the way, if the angle difference is small, that just means the player and monster are facing the same general direction, which doesn't necessarily correspond with whether the player is in the monster's field of view.

DeeperThought

EDuke32 Scripting (CON coding)

ah

Dopefish7590

EDuke32 Scripting (CON coding)

This is what I've been up to:



Find out how here.

Dr. Kylstien

EDuke32 Scripting (CON coding)

how do you display images from the *.art file somewhere on the screen

I know its possible but i just simply cant find the command...

anyone?

Dopefish7590

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dopefish7590
how do you display images from the *.art file somewhere on the screen

I know its possible but i just simply cant find the command...

anyone?
rotatesprite

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Dopefish7590
how do you display images from the *.art file somewhere on the screen

I know its possible but i just simply cant find the command...

anyone?
Screen drawing commands: http://wiki.eduke32.com/wiki/Categor...awing_commands

Devan

EDuke32 Scripting (CON coding)

ty

Dopefish7590

EDuke32 Scripting (CON coding)

Use rotatesprite, Quakis. It might take a lot of calls to that function, but you'll be able to zoom it out. Of course, on 320?200 resolution, it won't look like anything at all.

Hendricks266

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by Hendricks266
Use rotatesprite, Quakis. It might take a lot of calls to that function, but you'll be able to zoom it out. Of course, on 320?200 resolution, it won't look like anything at all.
I just turn the quotes into graphics instead, and call them up like so. Got what I wanted working though (mainly a test) and even solved an issue I was having before for my other project. Practise makes perfect!

Quakis

EDuke32 Scripting (CON coding)

Double post but stuck on a few pieces of code with a mouse cursor.

I call up an inventory tile and mouse cursor with EVENT_TURNAROUND. I've set up the mouse to move with aimup/down turnleft/right. However it won't move on the y axis unless I configure the digital axis in options to aimup/down. Suggestions?

Secondly it doesn't feel smooth and fast enough when moving like that in DNWMD. And I need to lock the player from moving about, I have an idea but when it comes to looking around... Suggestions?

Quakis

EDuke32 Scripting (CON coding)

Well, since you think I got it right in DNWMD, you could always look at the code and see how I did it

It sounds like you are using events to control the cursor (hard to tell because you didn't post code). A better way is to check the player's .ang and .horiz to see how much they have changed from the last tick and then move the cursor accordingly. You can lock those down and they will still change in between ticks (i.e. you check them at the beginning of the player code, then set them to the locked down values when you are done). You can stop the player from walking around with setplayer[THISACTOR].movement_lock 31 (a bitfield with 5 bits).

I'm not sure how clear that was. One nice thing about code is that, unlike human language, it is perfectly clear and unambiguous.

DeeperThought

EDuke32 Scripting (CON coding)

Quote:
I'm not sure how clear that was. One nice thing about code is that, unlike human language, it is perfectly clear and unambiguous.
Well, depending on who wrote it heh

Jblade

EDuke32 Scripting (CON coding)

Yes, I used events to control the cursor. I'll see what I can do then, sounds perfectly clear.

Quakis

EDuke32 Scripting (CON coding)

What's the best way to have different APLAYER actions (let's just say for different characters) without having to write tons of code for each set of actions? I thought about making the player sprite invisible and coding the APLAYER to spawn a dummy sprite that would do the required actions, but I'm not sure if there's a better way to do it.

Jblade

EDuke32 Scripting (CON coding)

I don't see why you can't just give new actions to the player itself, or how spawning a dummy sprite would save you any trouble.

DeeperThought

EDuke32 Scripting (CON coding)

Because it would mean having to add lots and lots of code to check each new action - the way it works now is to check what animation is playing and to play a corresponding one. I'd have to copy all that code for each different player sprite which is not only a lot of work but will also work up to be alot of code.

Jblade

EDuke32 Scripting (CON coding)

I wish I could help you but I'm clear on what you are trying to do exactly.

DeeperThought

EDuke32 Scripting (CON coding)

I think you mean 'not clear' :P Well, basically if you take a look at the default code:
Code:
  else
    ifaction PWALK
  {
    ifp pfalling
      action PFALLING
    else
      ifp pstanding
        action PSTAND
    else
      ifp prunning
        action PRUN
    else
      ifp pwalkingback
        action PWALKBACK
    else
      ifp prunningback
        action PRUNBACK
    else
      ifp pjumping
        action PJUMPING
    else
      ifp pducking
        action PDUCKING
  }
I'd basically have to have one of those, changed to the actions of the new player sprite, for every new player 'character' It might not seem much until you realise I'd have to do it for all the other animations as well, so the amount of work and code will soon add up. I'm contemplating 'rewriting' the player animation code though, so maybe I'm worrying over nothing heh.

Jblade

EDuke32 Scripting (CON coding)

How can I code soldier, which can defend you, shoot enemies and run and walk.

Is it impossible to do so?

The HJ

EDuke32 Scripting (CON coding)

JBlade: It might help slightly if you coded the transitions differently.

For example, you might use something like this as part of it--

Code:
ifp pwalking
{
    switch character
    case 1 action PWALK break
    case 2 action PWALK2 break
    case 3 action PWALK3 break
    endswitch
}
Of course, that is taken out of context, and there will be complications, but while it will require a lot of code for the player actions, it should be manageable.

DeeperThought

EDuke32 Scripting (CON coding)

Yeah, doing that would definitly cut the work down. I'll just have to grin and bear it in anycase - thanks

The HJ; if you look back a few pages, somebody already asked that question. It's definitly possible, but not the easiest thing for someone who doesn't code to do.

Jblade

EDuke32 Scripting (CON coding)

Ok, I need some help in coding. I made a sprite but not coded it yet. I t must work so that when player is near it, sprite disappears and quote shows on the screen. Please help

The HJ

EDuke32 Scripting (CON coding)

Quote:
Originally Posted by The HJ
Ok, I need some help in coding. I made a sprite but not coded it yet. I t must work so that when player is near it, sprite disappears and quote shows on the screen. Please help
define MYSPRITE #### // sprite must #### tile of art
definequote 125 I'M INVISIBLE!

useractor notenemy MYSPRITE

ifpdistl 2048
{
cstat 32768
quote 125
}
else
cstat 0

enda

DeeperThought

EDuke32 Scripting (CON coding)

I want to make it than when I have my main menu open in NR:IotM that you are frozen complete in place, including your Z position[so you are 'locked' in the air and don't fall]. Now, I tried multiple methods, and eventually tried having it constantly set poszv to 0 while the menu is open. Although this does SLOW down the player, they still very slightly descend to the ground even if it is set to 0.

Is there ANY way to completely prevent any form of vertical movement for the player and lock it out so they can't fall or rise if they are in the air? (ASIDE from setting the Jetpack to be on while the menu is open, because that just complicates matters if I have to do it that way)

Code:
ifvare mainmenu 1 
{
 setplayer[THISACTOR].posxv 0
 setplayer[THISACTOR].posyv 0
 setplayer[THISACTOR].poszv 0
}

Lord Misfit

 0 1 2 3 4 5 6 7
Previous Question:  Madness Guts in the RooM!!!  3D Realms Forums  Duke Nukem 3D ModificationsNext Question:  How to install Grub from live Ubuntu cd.  Ubuntu Forums  Tutorials Tips

- Source: EDuke32 Scripting (CON coding) 3D Realms Forums Duke Nukem 3D Modifications
- Previous Question: Madness Guts in the RooM!!! 3D Realms Forums Duke Nukem 3D Modifications
- Next Question: How to install Grub from live Ubuntu cd. Ubuntu Forums Tutorials Tips