Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 124 Pages +
  • « First
  • 76
  • 77
  • 78
  • 79
  • 80
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#2304

Thank you very much for your replies so far, I've been working on this survival mod a lot lately, and I have to get the basic elements working properly before I add more "features", so I haven't added your code yet, but looks good... I'm having a rather odd problem here: My monsters spawn from the keycard actor. Different places on the map, several keycards has been placed so that monsters come from all directions. My problem is, that even though the keycards are placed at least 2400 mapster units away from forcefield/cieling door, they go right through it and gets stuck there, making it impossible to complete the round, because the monsters are trapped in a place that can only be unlocked later in the game. It seems that when the monsters spawn, they immediately walk towards a player, and doesn't get stopped by a door or forcefield. Any ideas to prevent this nonsense? I've tried to move the spawners further and further away from the doors and forcefields, but that's not helping either...
0

User is offline   Mark 

#2305

This may be a dumb suggestion but as a coding noob what popped into my head was... As a test I would tie the spawn to a different actor just to rule out the slim possibility that there is some hidden hardcoding for the keycard that is interfering. Probably not but I would want to rule out the chance.
1

User is offline   Danukem 

  • Duke Plus Developer

#2306

It's likely that the monsters are starting where they are supposed to but then are clipping right through the barrier. It's possible that something in your custom monster code is causing that, but it's also possible that it's just happening because Build. And that's no attack on Build -- if you were making a Fallout 4 mod you could have the same issue (monsters end up in strange places in Creation engine...)

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.
0

#2307

 Trooper Dan, on 19 August 2018 - 12:32 PM, said:

It's likely that the monsters are starting where they are supposed to but then are clipping right through the barrier. It's possible that something in your custom monster code is causing that, but it's also possible that it's just happening because Build. And that's no attack on Build -- if you were making a Fallout 4 mod you could have the same issue (monsters end up in strange places in Creation engine...)

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...
0

User is offline   Danukem 

  • Duke Plus Developer

#2308

 thisbecasper, on 19 August 2018 - 02:18 PM, said:

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.


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

0

#2309

 Trooper Dan, on 19 August 2018 - 02:30 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.


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?
0

User is offline   Danukem 

  • Duke Plus Developer

#2310

You want to look up whilevarn and headspritestat/nextspritestat

There's lots of examples of looping through sprites in published mods, such as pretty much any of mine.
1

#2311

I have a question regarding modding masked walls. I want to replace the regular waterfalls with a new animation so I use this:


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?
0

User is offline   Danukem 

  • Duke Plus Developer

#2312

Just use an animated texture and you won't have to mess with code at all.
0

#2313

 Trooper Dan, on 03 September 2018 - 03:17 AM, said:

Just use an animated texture and you won't have to mess with code at all.


Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?
0

User is offline   Danukem 

  • Duke Plus Developer

#2314

 December Man, on 03 September 2018 - 01:01 PM, said:

Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?


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?
1

#2315

 Trooper Dan, on 03 September 2018 - 01:10 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?


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

0

User is offline   Mark 

#2316

I want to add a lean to some 3D models. According to the wiki there are various commands such as pitch and roll but no example on how to use them. I tried a couple of ways in cons with no success.

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

0

User is offline   Danukem 

  • Duke Plus Developer

#2317

 Mark, on 07 September 2018 - 01:38 PM, said:

I want to add a lean to some 3D models. According to the wiki there are various commands such as pitch and roll but no example on how to use them. I tried a couple of ways in cons with no success.


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.
1

User is offline   Mark 

#2318

Thanks.

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.
0

User is offline   Danukem 

  • Duke Plus Developer

#2319

 Mark, on 07 September 2018 - 04:45 PM, said:

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.


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.
0

User is offline   Mark 

#2320

I learn better by example. I'm resigned to the fact I will never get so heavily into con coding as you or other "master coders". I haven't the patience. I'm certainly not a role model for other new coders. I will find an example in the wiki or other people's code. With it in front of me I have a much easier time figuring why it works and how to adapt it to what I need. Reading something that looks like techno-babble without a real world example in the wiki frustrates me.
0

#2321

Does someone have some code that teleports monsters close to the player consistently? And how do I make sure you can't pick up handbombs (a single pipe, be it your own or another player's)?

This post has been edited by thisbecasper: 18 September 2018 - 10:00 AM

0

User is offline   Zaxtor 

#2322

I think AMC mod has some code that those floating cultists teleports near or close of you.
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

1

User is offline   Perro Seco 

#2323

I've got a complicated question:

Posted Image

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?
0

User is offline   Mark 

#2324

I don't know how but it can be done. I'm pretty sure thats how the flashlight in the Graveyard TC works or the player light in DukePlus. Search for Darkus's original flashlight code on the forum. It may give you a hint on how its done.
1

User is offline   Hendricks266 

  • Weaponized Autism

  #2325

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.
3

User is offline   Perro Seco 

#2326

Thank you both for your help! I'll try both solutions.
0

User is offline   Danukem 

  • Duke Plus Developer

#2327

 Perro Seco, on 24 September 2018 - 02:17 PM, said:

Thank you both for your help! I'll try both solutions.


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.
0

#2328

DELETED

This post has been edited by thisbecasper: 25 September 2018 - 07:34 AM

0

User is offline   Perro Seco 

#2329

 Trooper Dan, on 24 September 2018 - 05:08 PM, said:

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.
I know this sounds surrealist, but I'm not interested in the sprites, but rather in their positions. In my TC I use Lezing's motorbike code (the same used in DNF 2013) to make drivable cars, but everytime I exit one, the player spawns just in the middle of it (player position = car position). I said I wanted to keep the sprites with the player because I thought the code provided would be useful to know those two positions everytime he exits the car, so you can move him to the left or, if there's a wall, to the right side of the car.

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?
0

User is offline   Danukem 

  • Duke Plus Developer

#2330

 Perro Seco, on 29 September 2018 - 06:50 AM, said:

I said I wanted to keep the sprites with the player because I thought the code provided would be useful to know those two positions everytime he exits the car, so you can move him to the left or, if there's a wall, to the right side of the car.


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:

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?


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.
1

#2331

Is there a way to have dynamic music i.e. music that changes depending on the room the player is in?
Also, the same thing but with messages displaying the name of the room the player has entered?
0

User is offline   Danukem 

  • Duke Plus Developer

#2332

For those kinds of effects you should make your own effect sprites, similar to sector effectors. The sprites would have vars on them, which are loaded from tags in the map. The vars would control their use of commands such as starttrackvar and quote. There are many examples of this from different mods -- it's not particularly difficult but I don't plan to write a tutorial.
1

User is offline   Danukem 

  • Duke Plus Developer

#2333

As an aside, I hope this doesn't offend anyone but I've noticed something about a lot of CON scripting questions. A lot of questions are of the form "Is it possible to do X?" but what they really mean is "Is there a command to do X?"

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.
4

Share this topic:


  • 124 Pages +
  • « First
  • 76
  • 77
  • 78
  • 79
  • 80
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options