
EDuke32 Scripting "CON coding help"
#2304 Posted 19 August 2018 - 07:06 AM
#2305 Posted 19 August 2018 - 09:07 AM
#2306 Posted 19 August 2018 - 12:32 PM
If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.
#2307 Posted 19 August 2018 - 02:18 PM
Trooper Dan, on 19 August 2018 - 12:32 PM, said:
If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.
Yeah, after some testing I've found that they clip through "doors" that are less than 256 units wide. I've considered what you are suggesting with the teleporting, but for now the map just have huge doors (they still try to clip it, but gets squished instead (mission accomplished?)).
A whole other thing, and I'm kinda embarrased to ask this but: What's the most elegant or simplest way to have a switch for things in general? Let me give an example: Monsters drop this crystalammo from time to time, and when the player picks it up, all monsters run a block of code. So what I'm currently doing is setting a global gamevar = 1 in the crystalammo code when the player picks it up while having the monsters check for this gamevar. Then I would like the gamevar to be set back to 0 when all monsters (actors, really) have been iterated once. I've come up with all kind of weird methods, but in the end they doesn't seem logical...
#2308 Posted 19 August 2018 - 02:30 PM
thisbecasper, on 19 August 2018 - 02:18 PM, said:
What does the block of code actually do? My first reaction would be to make the crystalammo run the code instead, by looping through all the monsters. I think this would be less confusing to read, as well.
EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.
This post has been edited by Trooper Dan: 19 August 2018 - 02:34 PM
#2309 Posted 19 August 2018 - 03:04 PM
Trooper Dan, on 19 August 2018 - 02:30 PM, said:
EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.
The code will do different things depending on the item the player picks up (but in this case it kills them), but stuff has to happen to the player too, but I guess that could be done by looping too. Only reason to why I'm not looping, is because I haven't learned it yet! Is there anything on the wiki about looping though actors?
#2310 Posted 19 August 2018 - 03:36 PM
There's lots of examples of looping through sprites in published mods, such as pretty much any of mine.
#2311 Posted 03 September 2018 - 02:30 AM
onevent EVENT_ENTERLEVEL { setvar w_wall_number 0 whilevarvarn w_wall_number NUMWALLS { getwall[w_wall_number].picnum w_wall_picnum ifvare w_wall_picnum 889 { setwall[w_wall_number].picnum 7224 } addvar w_wall_number 1 } } endevent
However, this does not cover masked walls. Wat do?
#2312 Posted 03 September 2018 - 03:17 AM
#2313 Posted 03 September 2018 - 01:01 PM
Trooper Dan, on 03 September 2018 - 03:17 AM, said:
Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?
#2314 Posted 03 September 2018 - 01:10 PM
December Man, on 03 September 2018 - 01:01 PM, said:
Are you saying there aren't enough spaces in the art file to put your new animation without bumping into some other existing tiles? Then that's a problem. What happens when you make your loop replace overpicnum as well as picnum?
#2315 Posted 03 September 2018 - 02:05 PM
Trooper Dan, on 03 September 2018 - 01:10 PM, said:
Well damn, haven't thought about doing it like this. It works! Thank you very much!
This post has been edited by December Man: 03 September 2018 - 02:05 PM
#2316 Posted 07 September 2018 - 01:38 PM
Then I had the bright idea that those commands are probably used in the maphacks files. Sure enough, there they are. So I created a MYPROJECT.MHK file and entered in the line "sprite 6673 pitch 128" . I wasn't sure if maphack files need to be called so I typed "include MYPROJECT.MHK at the top of GAME.CON
When run I get an con error message. "expected a keyword but found sprite"
How does one implement pitch, roll and the other similar commands?
Also, for sprite ID is pitch looking for the ID from Mapster or the ID from DEFS.CON? I'm assuming from mapster
This post has been edited by Mark: 07 September 2018 - 01:44 PM
#2317 Posted 07 September 2018 - 02:19 PM
Mark, on 07 September 2018 - 01:38 PM, said:
I don't know what went wrong, but you just set the .pitch and .roll members of the sprite struct to the values you want, either with numbers or gamevars.
https://wiki.eduke32.../Model_rotation
So for example seta[].pitch 512 would make the actor face plant.
#2318 Posted 07 September 2018 - 04:45 PM
This once again points out the severe lack of simple examples for entries. For instance, your example shows that the model to manipulate must be made an actor. Not mentioned in the wiki. Noob coders are not going to automatically know that like the experienced coder does. And since the only example I could find of that command was in a maphack file that was simply: "sprite 6673 pitch 128" I naturally figured thats how to use it. Now I know better.
#2319 Posted 07 September 2018 - 05:21 PM
Mark, on 07 September 2018 - 04:45 PM, said:
You can set the structs on any sprite in the game, it doesn't have to be an actor. I think the real issue here is that people look up individual pages that assume knowledge of how to use sprite structs, without knowing how to use sprite structs. Ideally, the novice CON coder has already read this page first:
https://wiki.eduke32...tructure_access
But it's not desirable to have tutorials on structure access in every entry about a sprite struct. That would make the entries bloated and hard to read, not to mention it would be a ton of work. The correct solution is to have the wiki organized in such a way that the novice has a clear order to read stuff in so they get all the basics. In theory, the novice would come here first and work their way through most of that page.
#2320 Posted 07 September 2018 - 05:35 PM
#2321 Posted 18 September 2018 - 09:08 AM
This post has been edited by thisbecasper: 18 September 2018 - 10:00 AM
#2322 Posted 18 September 2018 - 11:59 AM
Dunno the code but I know what you mean.
I'm trying to find out how is done.
if I find out ill let u know
I'm sure someone with more knowledge on things teleporting near players will help
This post has been edited by Zaxtor: 18 September 2018 - 11:59 AM
#2323 Posted 23 September 2018 - 05:26 AM

I want those two sprites to stay with the player. If he moves, they move with him, and if he rotates, they also rotate, but always keeping the same distance. Is this something possible to do?
#2324 Posted 23 September 2018 - 05:38 AM
#2325 Posted 23 September 2018 - 11:29 AM
defstate doangle getactor[THISACTOR].ang temp setactor[actor0].ang temp setactor[actor1].ang temp addvar temp 512 // rotate angle 90 degrees cos x temp sin y temp mulscale x2 radius x 14 mulscale y2 radius y 14 getactor[THISACTOR].x temp addvarvar temp x2 setactor[actor0].x temp getactor[THISACTOR].y temp addvarvar temp y2 setactor[actor0].y temp getactor[THISACTOR].x temp subvarvar temp x2 setactor[actor1].x temp getactor[THISACTOR].y temp subvarvar temp y2 setactor[actor1].y temp ends
There may be more steps for the motion to look correct in relation to movement interpolation.
#2327 Posted 24 September 2018 - 05:08 PM
Perro Seco, on 24 September 2018 - 02:17 PM, said:
The other solution that Mark referred to makes use of of the rotatepoint command; the results should be equivalent.
You have 3 choices with regard to how the side-sprites will appear to move: jumpy (current solutions), smooth, or smooth and laggy. The reason they will appear jumpy right now is that they are being teleported 30 times per second, but otherwise not moving. Whereas the player and other sprites get movement interpolation in between tics (that's what Hendricks266 was referring to.) I don't know how you would give them proper interpolation and also make them keep up with the player. An improper but proven way to do it is to set their t-sprites based on camera coordinates in a display event, in addition to setting their actual sprites in actor code.
#2328 Posted 25 September 2018 - 06:57 AM
This post has been edited by thisbecasper: 25 September 2018 - 07:34 AM
#2329 Posted 29 September 2018 - 06:50 AM
Trooper Dan, on 24 September 2018 - 05:08 PM, said:
I think I almost got what I want, but now I'm unable to change the player's position. I'm using setplayer[THISACTOR].posx and posy, but it doesn't seem to affect the position. Do I need something more or something completely different to change the position?
#2330 Posted 29 September 2018 - 06:59 AM
Perro Seco, on 29 September 2018 - 06:50 AM, said:
If that's all you need, then don't make extra sprites and don't do the calculations all the time. Just do the calculation once when the player exits the vehicle and move the player to those coordinates.
Perro Seco, on 29 September 2018 - 06:50 AM, said:
Changing the player coordinates is usually all you need for changing the player's actual position. It's better if you also update the player's sector, in case the new coordinates are in a new sector. You can feed your new coordinates into the updatesector or updatesectorz command, then set the player's cursectnum to the outputed sector (but don't set it if the output is -1 for some reason).
As for why it's not working when you set posx and posy, it could be because you aren't setting the sector but I think it's more likely something else which is blocking your attempt. The first thing I would check is make sure that Lezing's bike code is not setting the player's coords at that point, since it could be overriding your attempt. Also, you should verify 100% that you have calculated the new coordinates correctly. You can do a visual confirmation by espawning a sprite there and setting it to those coordinates; do so in F7 view mode so that you can see it in game and verify it is in the right place.
#2331 Posted 30 September 2018 - 02:10 PM
Also, the same thing but with messages displaying the name of the room the player has entered?
#2332 Posted 30 September 2018 - 03:08 PM
#2333 Posted 30 September 2018 - 03:18 PM
CON does have a huge number of commands which often do complex things. Want some money sprites to spawn and float realistically to the ground? Easy: use the money command. Want to make an earthquake? Easy: use the quake command. And so on. Those sorts of commands are like a vending machine -- you just press the right button and the thing you want comes out, already packaged for you. But in addition to the vending machine, CON also has a kitchen fully stocked with raw ingredients where you can make pretty much anything you want.
I think some people get caught up on the convenience of the vending machine and never learn how to cook. If you are making a mod that has non-trivial coded features, you should learn how to cook.