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

Jump to content

  • 124 Pages +
  • « First
  • 109
  • 110
  • 111
  • 112
  • 113
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   jimbob 

#3301

isnt it possible to force the player into a place of your desire using some sort of code magic regardless of where he starts initially?
like just semi randomly place the starting position, then use whatever code there is to teleport the player to XY coördinate and start from there?
0

User is offline   Danukem 

  • Duke Plus Developer

#3302

Well yes but that's not what I was asking. Also IIRC it's hard to do that without having the initial mapster position flash on the screen for an instant.
0

User is offline   Reaper_Man 

  • Once and Future King

#3303

View PostDanukem, on 19 April 2023 - 12:01 PM, said:

It would sure be useful if there were script access to the map start position. I mean the coordinates and angle of the green arrow start position in mapster, not the multiplayer Duke sprites. But AFAIK that is not the case. Anyone know different?

Looking at the source it seems like that's down in the engine side of things, and never exposed. I'd think the closest you could get is checking the player's position in EVENT_ENTERLEVEL, they should be initialized by that point.
1

User is offline   Danukem 

  • Duke Plus Developer

#3304

View PostReaper_Man, on 19 April 2023 - 04:34 PM, said:

Looking at the source it seems like that's down in the engine side of things, and never exposed. I'd think the closest you could get is checking the player's position in EVENT_ENTERLEVEL, they should be initialized by that point.


Thanks, but the particular issue that has been reported to me is that the angle of the green start arrow in mapster is not preserved and the player is starting at a different angle. I haven't checked yet but I suspect it is already messed up by the time of ENTERLEVEL
0

User is offline   Reaper_Man 

  • Once and Future King

#3305

Is it consistently off, as in is it a fixed offset? Is it related to the weird camera snap/turn that you see when you first load into a map?
0

User is offline   Danukem 

  • Duke Plus Developer

#3306

View PostReaper_Man, on 20 April 2023 - 02:03 PM, said:

Is it consistently off, as in is it a fixed offset? Is it related to the weird camera snap/turn that you see when you first load into a map?


I'm getting reports from mappers in our own project about the player always starting facing west on the maps they are working on, but that's definitely not the case when I test our predefined episodes. So I don't know... there might be an issue in my code somewhere.

Anyway, I still wish I could access the mapster start coords/angle in CON. Oh well.
0

User is offline   MC84 

#3307

Is there a simple way to lock an actor's movement so that they only move left or right relative to the player's position? Basically I've done these strafe animations, and they look great however only when the enemy is moving in a 'strafe' direction.. if they are moving towards or away from the player the animation/action looks a bit silly.

Currently my AI is just the following;

ai AIVALDODGE	AVALSTRAFE VALRUNVEL dodgebullet


I've tried it with 'geth' instead but that doesn't make much difference.
0

User is offline   Danukem 

  • Duke Plus Developer

#3308

Make the enemy face the player or figure out which angle faces the player, and then turn them 90 degrees (512 build degrees) in either direction from that angle.
1

User is offline   MC84 

#3309

Thanks Dan - I'm probably not quite at that level yet but I will attempt this a bit further down the track. For now I've got a different question relating to projectiles; basically I'm trying to do a molotov cocktail, and discovered that creating an object with arc isn't as straightforward as I thought... is the best way around this to use the eshoot command and then use setthisprojectile[RETURN].drop x after the fact?
0

User is offline   Danukem 

  • Duke Plus Developer

#3310

Why not set the projectile type to drop in the definition? Also, if you are going to do your own scripting I think it's worth your time to learn how to make an actor move orthagonally to the player. It requires a little bit of Eduke code (as opposed to using the old 1996 scripting system) but it's about as basic as it gets and what you learn will be useful for other things.
0

User is offline   MC84 

#3311

View PostDanukem, on 30 April 2023 - 02:49 AM, said:

Why not set the projectile type to drop in the definition? Also, if you are going to do your own scripting I think it's worth your time to learn how to make an actor move orthagonally to the player. It requires a little bit of Eduke code (as opposed to using the old 1996 scripting system) but it's about as basic as it gets and what you learn will be useful for other things.


Well the drop velocity works fine; however I wanted it to rise up in the air first before falling... and I agree with you - I wasn't being dismissive regarding your earlier post - I sincerely intend to figure out how to manipulate actor movement.
0

User is offline   Danukem 

  • Duke Plus Developer

#3312

View PostMC84, on 30 April 2023 - 03:03 AM, said:

Well the drop velocity works fine; however I wanted it to rise up in the air first before falling


That's why you use zshoot or ezshoot and put a negative vertical velocity on the projectile to compensate for the drop, in proportion to the xy distance to the target (the exact amount will also depend on the projectile's defined xy velocity).
2

User is offline   MC84 

#3313

That's what I was after! Thanks very much
0

#3314

Somehow an enemy spawned by Respawn has its projectiles popping up in the wrong palette (0) while the same enemy placed on the map from the start functions right. Both using the same tile, both using the same palette, and both displaying correctly.

onevent EVENT_SPAWN
  ifactor DRONEMOTHER
    ifg sprite[].xrepeat 4
      state mtrsort
endevent

state mtrsort
  cstator 257
  getactor[THISACTOR].pal queenp //palette stored at spawn
  ifspritepal 10
  {
	sizeat 38 44
	set queend 1
  }
  else
  sizeat 28 28
ends

//when the enemy fires the projectile
      eshoot RCORE3
	  setactor[RETURN].pal queenp //stored palette used



//the spritepal is kept as a var instead of being used directly because the palette is set to 6 before and after the behavior each tic
//swapping out 'getactor[THISACTOR].pal queenp' with 'set queenp #' did not fix

0

User is offline   Danukem 

  • Duke Plus Developer

#3315

Did you actually verify that queenp has the correct value (by logging it) at the point in the code where the spawned enemy is setting it on the projectile? It would be the first thing I would check and you didn't mention checking it.
0

#3316

View PostDanukem, on 06 May 2023 - 01:28 PM, said:

Did you actually verify that queenp has the correct value (by logging it) at the point in the code where the spawned enemy is setting it on the projectile? It would be the first thing I would check and you didn't mention checking it.


Spoiler

So Respawn is not using event_spawn?
If I'm reading this right sprite 414 is the placed enemy and sprite 5557 is the Respawn. I let them each fire the projectile once.
This would explain why 'set queenp 15' did not work earlier.
0

User is offline   Danukem 

  • Duke Plus Developer

#3317

View Postlllllllllllllll, on 06 May 2023 - 02:17 PM, said:

So Respawn is not using event_spawn?


You really need to learn how to debug and make it a habit.

With a few lines of code, you can log the sprite number and tile number of anything passing through EVENT_SPAWN to see what is happening there.

My guess: like most sprites without specific hardcoding, your enemy is spawning extremely small and therefore dodging your "state mtrsort". Remember, unless a custom actor is sized immediately in EVENT_EGS, it's going to be small until its actor code kicks in, which happens after EVENT_SPAWN
0

#3318

With something like that I would never figure it out on my own honestly. Up until now I had believed respawned objects that don't have their size set were spawning outside of the map since they never showed up otherwise. I figured out toughness 0 breaking useractors only because it also breaks hardcoded actors if their action is not set to the original frozen action when it is applied. When I was fixing the eggs reverting to unopen after thawing I was convinced there was an error somewhere in the sequence of checks I made for it and only figured out the hard code magic there because of assigning the main freeze frame to a custom action mistakenly thinking it was correcting an error somewhere.

What are you using to look at the hardcode?
0

User is offline   MC84 

#3319

How does one go about calculating a relative location via CON? I've been working on some vehicle (3d model) damage states, and in the 'dead' state it spawns a smoke puff... I thought I was clever because I altered the y position of the spawned smoke to make it look like it was coming from the hood/engine... then I realized that if the 3D model was facing a different direction then the smoke would spawn with the y-adjusted position, which resulted in the smoke spawning by the side of the windows or even outside the vehicle... I'm not so much asking for a specific solution, I'm more curious what process people use to figure this sort of thing out.. My mind started wandering towards triangulation or something.. but maybe I'm overcomplicating things?
0

User is offline   VGames 

  • Extra Crispy

#3320

U need to get the Y position of the car itself, add or subtract from it to get the location of the hood, and then apply that to the smoke’s Y position.
0

#3321

rotatepoint will let you move the spawn to a constant position relative to the car's angle and the origin you pick
2

User is offline   MC84 

#3322

I've been messing around with menu display stuff and have been trying to get a 'monitor wall' effect happening, with randomly flickering screens. I've got the monitor tiles all arranged properly using rotatesprite, and have set the picnum to a gamevar that is determined via a switch statment. (There are 20 screens in total)
defstate testDISPLAY

ifcount 2
{
  randvar tempA 19
  switch tempA
    case 0 { setvar tempB 9705 resetcount } break
    case 1 { setvar tempB 9706 resetcount } break
    case 2 { setvar tempB 9707 resetcount } break
    case 3 { setvar tempB 9708 resetcount } break
    case 4 { setvar tempB 9709 resetcount } break
    case 5 { setvar tempB 9710 resetcount } break
    case 6 { setvar tempB 9711 resetcount } break
    case 7 { setvar tempB 9712 resetcount } break
    case 8 { setvar tempB 9713 resetcount } break
    case 9 { setvar tempB 9714 resetcount } break
    case 10 { setvar tempB 9715 resetcount } break
    case 11 { setvar tempB 9716 resetcount } break
    case 12 { setvar tempB 9717 resetcount } break
    case 13 { setvar tempB 9718 resetcount } break
    case 14 { setvar tempB 9719 resetcount } break
    case 15 { setvar tempB 9720 resetcount } break
    case 16 { setvar tempB 9721 resetcount } break
    case 17 { setvar tempB 9722 resetcount } break
    case 18 { setvar tempB 9723 resetcount } break
    case 19 { setvar tempB 9724 resetcount } break
    endswitch
}



{ rotatesprite 128 100 32768 0 tempB 0 0 0  windowx1 windowy1 windowx2 windowy2 }

etc etc



The problem is that this same gamevar will always return the same value; ie instead of having each monitor display different screens at any one time, they all cycle through the same sequence of images in unison. I know there's a very bloated solution to this problem that would involve creating 20 switch statements, with 20 vars but that seems pretty excessive to me... Is there a smarter way to go about this?

EDIT - It just occurred to me that displaying the above during EVENT_DISPLAYMENU doesn't show the animation anyway (I guess ifcount 2 is never true); so I'm not going to bother with this method for now.

This post has been edited by MC84: 06 June 2023 - 08:01 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#3323

What menu are you talking about? If it's the regular EDuke32 menu that displays when you press Esc, then the count will not advance because the game world is not running at that time. If you have that code in a display event, then I think count will default to the player actor's count which is doubtless already 2 or more. Then it will take whatever random value it rolls and display that tile and reset the count. With the count reset and no longer advancing, it will then continue to display that same tile since the variable will no longer change.
1

User is offline   Danukem 

  • Duke Plus Developer

#3324

I think the read-only variable totalclock does continue to advance in the menu, though.
0

User is offline   MC84 

#3325

View PostDanukem, on 06 June 2023 - 08:37 PM, said:

What menu are you talking about? If it's the regular EDuke32 menu that displays when you press Esc, then the count will not advance because the game world is not running at that time. If you have that code in a display event, then I think count will default to the player actor's count which is doubtless already 2 or more. Then it will take whatever random value it rolls and display that tile and reset the count. With the count reset and no longer advancing, it will then continue to display that same tile since the variable will no longer change.


Thanks for your explanation - I was referring to the current_menu 0 or MAIN_MENU screen. I decided to go for a much simpler approach but I noticed that even when the animation is set through BAFED or a def file it won't play during this particular screen. However when you press escape and enter current_menu 50 / INGAME the animation does play.
0

User is offline   MC84 

#3326

This was one of those '5 minute jobs' that I've spent hours scratching my head over... I just want to make a simple sound 'randomizer' that alternates between 3 sounds. I initially thought this would just be a case of an ifrnd with a switch statement... but the problem I was having was that my sounds starting playing on top of one another. I tried a number of things, and have alternated between using ifcount and using my own timer (soundtimer)...

The following actually seems to work (I put that spawn SMOKEPUFF1 bit in there just to check that the timer is actually counting down to zero ) however it only seems to play one of the 3 sounds. I've sat there in the level for 5 mins and it will just play the same sound over and over...

defstate AIRPORTPAstate
{  

  ifsound AIRPORTPA1 sub soundtimer 1 
  ifsound AIRPORTPA2 sub soundtimer 1
  ifsound AIRPORTPA3 sub soundtimer 1
  
  ife soundtimer 0 { spawn SMOKEPUFF1 set soundtimer 270 }
  else  
 
  ife soundtimer 270
  {
    randvar tempA 2
    switch tempA
      case 0 { sound AIRPORTPA1 break }
      case 1 { sound AIRPORTPA2 break }
      case 2 { sound AIRPORTPA3 break }
    endswitch
   }
   else nullop

  
}
ends


And then my actor itself is very basic;

useractor notenemy AIRPORTPA cstat 32768 state AIRPORTPAstate enda


TempA is a per-actor var (I also experimented with global vars but it didn't seem to make much difference). soundtimer is initiated to 270, as each sound is approx 9 seconds in length.

This post has been edited by MC84: 15 June 2023 - 09:48 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#3327

You don't any vars just to do that. This should work for example:

defstate AIRPORTPAstate

  ifsound AIRPORTPA1 break
  ifsound AIRPORTPA2 break
  ifsound AIRPORTPA3 break

  ifrnd 85 globalsound AIRPORTPA1 else
  ifrnd 128 globalsound AIRPORTPA2 else
  globalsound AIRPORTPA3

ends


1

User is offline   MC84 

#3328

View PostDanukem, on 15 June 2023 - 10:09 PM, said:

You don't any vars just to do that. This should work for example:


Thanks Dan - I like simple solutions. Well it works just as well my overly complex code, however it still only plays one of the sounds. I must have done something silly somewhere to cause that.
0

User is offline   Danukem 

  • Duke Plus Developer

#3329

View PostMC84, on 15 June 2023 - 11:51 PM, said:

Thanks Dan - I like simple solutions. Well it works just as well my overly complex code, however it still only plays one of the sounds. I must have done something silly somewhere to cause that.


Look carefully at your sound definitions. You may have accidentally pasted the same sound file name in all 3 of them, even though the sounds have different labels. I have done that before myself.
0

User is offline   MC84 

#3330

View PostDanukem, on 16 June 2023 - 12:11 AM, said:

Look carefully at your sound definitions. You may have accidentally pasted the same sound file name in all 3 of them, even though the sounds have different labels. I have done that before myself.


I checked those, and the thing is that when I say it was 'playing the same sound' the sound would actually change between quitting and reloading the map... it's just that it would play the same sound each 'session'.

Anyway I had my sounds defined as 0 0 0 3 0 ... I think I was doing that for ambient sounds? And then I changed it to 0 0 254 0 0 and now it actually cycles randomly through the 3 sounds. Thanks again!
0

Share this topic:


  • 124 Pages +
  • « First
  • 109
  • 110
  • 111
  • 112
  • 113
  • 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