
EDuke32 Scripting "CON coding help"
#287 Posted 07 September 2009 - 03:02 AM
Can't seem to get that working, I fiddled with it a fair amount but just end up with errors, I will keep messing about with it.
@deeperthought
The problem with ang is that it makes the player face that way, so he is moving in the same direction when pressing that key as he was when pressing the other key. Also it causes the camera to face the other way (through a wall usually) and thus I have to tell the camera which way to face in the same event, which usually works but causes occasional flickering.
I guess I could always come up with a weird control scheme where you press the up key to move the player in the direction he is facing and you use the arrow keys to select the way you want him to face, I have played games with a similar scheme but they were top-down view - in fact I think I will give this a go and see how it feels, but my natural instinct when playing a side-scroller (which i spend 80% of my time doing) is to use traditional sidescrolling controls, so it would take some getting used to and I imagine other people wouldn't be too happy with it either.
I'm actually quite enjoying playing about with the codes, even when I get things wrong, interesting results sometimes occur, such as today I somehow managed to disable the gravity and the player exploded as soon as the level started, then you could not start a new game or restart the level, no idea how I managed that by just be messing with the health bar code.
#288 Posted 07 September 2009 - 03:04 AM
onevent EVENT_MOVEFORWARD ifvare mykeypress 1 nullop else { getplayer[THISACTOR].ang angle addvar angle 1024 setplayer[THISACTOR].ang angle setvar mykeypress 1 } endevent onevent EVENT_MOVEBACKWARD ifvare mykeypress 2 nullop else { getplayer[THISACTOR].ang angle subvar angle 1024 setplayer[THISACTOR].ang angle setvar mykeypress 2 } endevent
Here's the working code, in any case. I've used my own variables. In case you might need, define these at defs.con or user.con.
gamevar mykeypress 0 1
gamevar angle 0 1
This post has been edited by XThX2: 07 September 2009 - 03:05 AM
#289 Posted 07 September 2009 - 06:43 AM
Eventually i did this;
onevent EVENT_DISPLAYREST setvar cameradist 200000 setplayer[THISACTOR].look_ang angle endevent onevent EVENT_GAME setplayer[THISACTOR].look_ang angle endevent onevent EVENT_TURNLEFT setvar angle 512 setplayer[THISACTOR].ang 1024 endevent onevent EVENT_TURNRIGHT setvar angle 1536 setplayer[THISACTOR].ang 0 endevent
For some reason I also have to do "setplayer[THISACTOR].look_ang angle" under EVENT_GAME or else a horrid flicker occurs, i figure this is somewhat inefficient, but it runs on my Athlon XP so it can't be that bad, the controls in this manner are surprisingly fluent (i think that's the word) - at the moment the camera is facing forward when the game starts, but I think I know how to fix that (rearrange the code a bit and probably define "angle" as 1536 at the top of the .con).
#290 Posted 07 September 2009 - 07:52 PM
This post has been edited by Ilovefoxes: 07 September 2009 - 07:53 PM
#291 Posted 07 September 2009 - 08:03 PM
Ilovefoxes, on Sep 7 2009, 08:52 PM, said:
Yeah, they both have statnum 10, which is weird. Try "ifspawnedby APLAYER" which is only true for the hologram.
EDIT: This should work also -- ifvarvarn THISACTOR player[THISACTOR].i // hologram if true
This post has been edited by DeeperThought: 07 September 2009 - 08:10 PM
#292 Posted 07 September 2009 - 08:11 PM
Ilovefoxes: it doesn't look like you can in a reliable way. You would be much better off intercepting EVENT_HOLODUKEON and spawning the sprite yourself.
#294 Posted 08 September 2009 - 04:07 AM
Ilovefoxes, on Sep 8 2009, 05:52 AM, said:
Both are essentially the same actor. (Which is probably how the game fools enemies to attack it. )
If you want the holoduke actor to actually do simple stuff. Ifpdistg 1000 or ifspawnedby APLAYER might have some effect.
(However do seem have side effects while teleporting or jet packing against a ridge.)
However, the best method I found is to spawn your own actor and quickly turn the holoduke off to get rid of the holoduke actor.
XThX2 said:
I was the one that asked it back then. And came to the same conclusion.
This post has been edited by lycanox: 08 September 2009 - 04:11 AM
#295 Posted 08 September 2009 - 12:17 PM
I don't have access to my computer now so I can't give you my exact code (I'll try tomorrow) but here's the gist of it:
When my actor has a positive value from his htextra he'll then do the following (plus more but that's not relevent)
gamevar MYENEMY -1 2 // records who my actor will attack gamevar DTEMP1 -1 2 // records the ID of what projectile (or attack) that hit the actor gamevar DTEMP2 0 2 // used as a temp value gamevar DTEMP3 -1 2 // records the ID of who shot the actor or inflicted damage if melee gamevar RECORD1 -1 2 // used as a temp, in this case it'll record the distance obtained through the dist command gamevar RECORD2 -1 2 // used as a temp, in this case it'll record the distance obtained through the dist command ifvare DTEMP3 -1 // you were hit but this value was not set meaning it was a projectile that hit the actor { getactor[THISACTOR].htowner DTEMP3 // know who's hit you getactor[THISACTOR].htpicnum DTEMP1 // know what's hitting you } ifvare MYENEMY -1 setvarvar MYENEMY DTEMP3 // if you have no enemy ID then treat who hit you as the enemy else // you had an enemy ID but now you have 2! { ifvarg MYENEMY -1 // you have an enemy ID { getactor[MYENEMY]statnum DTEMP2 ifvarn DTEMP2 1024 dist [RECORD1] [THISACTOR] MYENEMY } else setvar RECORD1 99999 ifvarg DTEMP3 -1 // you have an ID of the projectile's owner { getactor[DTEMP3]statnum DTEMP2 ifvarn DTEMP2 1024 dist [RECORD2] [THISACTOR] DTEMP3 } else setvar RECORD2 99999 ifvarvarl RECORD2 RECORD1 setvarvar MYENEMY DTEMP3 // the new enemy is closer so record his ID! } setvar DTEMP1 -1 // erase the knowledge of who hit you - its no longer needed. setvar RECORD1 -1 setvar RECORD2 -1
My errors bascally say something like that "error with dist - invalid sprite" meaning the actor does not exist but I made sure its being checked for with the statnum checking.....
This post has been edited by Chip: 08 September 2009 - 12:33 PM
#296 Posted 08 September 2009 - 12:27 PM
#297 Posted 08 September 2009 - 12:32 PM
XThX2, on Sep 8 2009, 09:27 PM, said:
If you're refering to the [ ] on a gamevar in the dist command, that's because the game throws a fit if I don't put them on saying stuff like "RECORD1" is not a game array...
Quote
Ignore that, I've just written this out now so things like that which would cause the game to not load up don't exist in my real code.
Quote
I'm going to have to but I didn't get time today but the fact is by rights the game shouldn't read those dist commands if my actor doesn't have an enemy ID or if so then not if it has a statnum of 1024.
This post has been edited by Chip: 08 September 2009 - 12:32 PM
#298 Posted 08 September 2009 - 12:45 PM
#299 Posted 08 September 2009 - 12:51 PM
DeeperThought, on Sep 8 2009, 09:45 PM, said:
Here's a quick run down where the error happens:
ifvarg DTEMP3 -1 // you have an ID of the projectile's owner { getactor[DTEMP3]statnum DTEMP2 ifvarn DTEMP2 1024 dist [RECORD2] [THISACTOR] DTEMP3 } else setvar RECORD2 99999
If the gamevar DTEMP3 holds a value of 0+ then check its existance with the statnum. If the statnum gamevar is not 1024 then check the distance between the actor and the enemy id that DTEMP3 holds.
I'm going to have to post my actual code tomorrow but I'm certain there's no difference between this and that...with the exception that the main code checks to make sure the actor THISACTOR actually exists incase it was somehow running this state from beond the void.
#300 Posted 08 September 2009 - 01:07 PM
XThX2, on Sep 8 2009, 01:27 PM, said:
Right, but it's not his "actual code", so it's waste of our time to even look at it.
#301 Posted 09 September 2009 - 12:58 AM
#302 Posted 09 September 2009 - 02:25 AM
This post has been edited by Chip: 09 September 2009 - 02:26 AM
#303 Posted 09 September 2009 - 03:10 AM
Ilovefoxes, on Sep 9 2009, 10:58 AM, said:
You'll have to do better than sector[THISACTOR]. Get the sectnum from thisactor to a gamevar and then use sector[] on that.
#304 Posted 09 September 2009 - 06:35 AM
Plagman, on Sep 9 2009, 04:10 AM, said:
I thought those were supposed to be equivalent.
#305 Posted 09 September 2009 - 06:55 AM
DeeperThought, on Sep 9 2009, 04:35 PM, said:
Ah, then THISACTOR is smarter than I thought; anyway, it should be getsector[] and not sector[]. Is it allowed to use it directly as a gamevar or do you have to assign ceilingstat to an actual gamevar first?
#306 Posted 09 September 2009 - 07:08 AM
Plagman, on Sep 9 2009, 07:55 AM, said:
A while back, TerminX added the ability to refer to struct members as variables for the purpose of comparing values. For example, ifvare sprite[THISACTOR].pal 10 is equivalent to ifspritepal 10. What Ilovefoxes posted conforms to the new syntax and should work. We still have to put members into variables in order to set things, though. For example, this does not work: setactor[THISACTOR].z player[THISACTOR].posz
EDIT: That's wrong. What I should have is that struct members cannot be the targets of gamevar writes. For example, setvarvar player[THISACTOR].posz Z is not valid. On the other hand, setactor[THISACTOR].z player[THISACTOR].posz should work.
This post has been edited by DeeperThought: 10 September 2009 - 03:37 PM
#307 Posted 09 September 2009 - 06:40 PM
Heh, I would also like to use getplayer[sprite[sprite[THISACTOR].owner].yvel].extra, but this seems overpower. =P
This post has been edited by Ilovefoxes: 09 September 2009 - 07:24 PM
#308 Posted 09 September 2009 - 09:27 PM
Ilovefoxes, on Sep 9 2009, 07:40 PM, said:
That doesn't make sense. Extra is not even a member of the player struct. Also, it kind of defeats the purpose if you make your code hard to read.
#309 Posted 09 September 2009 - 09:44 PM
But I mean to replace this:
Quote
getactor[OWNER].x X
Quote
This post has been edited by Ilovefoxes: 09 September 2009 - 09:44 PM
#310 Posted 10 September 2009 - 05:18 AM
#311 Posted 10 September 2009 - 09:15 AM
if you are using something like:
Quote
sound PISTOL_RICOCHET
But this:
Quote
addphealth 10
You must understand that the sound is not part of the game, and may or may not be here depending of the player option (sound on/off, maximum number of sounds, especially the lenght of the user sound file, etc).
This post has been edited by Ilovefoxes: 10 September 2009 - 09:16 AM
#312 Posted 10 September 2009 - 12:03 PM
Example: actor suffers a single freeze blast hit - he then takes damage from a melee hit (set directly through an actor) - actor now dies.....but plays the "freeze" effect which is the end effect of dying to a freezeblast hit.
..unless ifwasweapon <NAME OF ACTOR INFLICTING DAMAGE!> works in over riding the last weapon? Pure assumption based on the fact that actors will hard codedly know who set damage on them (as I found out when my actor started attacking himself after suffering fall damage - my actors record the owner of the weapon as their enemy and since the fall damage was set by himself he then recorded his own ID as his enemy!)
This post has been edited by Chip: 10 September 2009 - 12:12 PM
#313 Posted 10 September 2009 - 12:59 PM
#314 Posted 10 September 2009 - 01:27 PM
It sets ifwasweapon to tilenumber -1. Which is not defined as a projectile in the game and thus makes the game run the standard hit and dead code.
setactor[THISACTOR].htpicnum -1
This post has been edited by lycanox: 10 September 2009 - 02:00 PM
#315 Posted 11 September 2009 - 11:42 AM
lycanox, on Sep 10 2009, 10:27 PM, said:
setactor[THISACTOR].htpicnum -1
And that was my problem! Because this was infront of the actor taking damage it gets overwritten as soon as the htextra becomes a positive value. Simply adding the set picnum thing after htextra was set works.
In addition to that
Quote
Well that certainly works as far as my tests went!
I had it play a quote if "ifwasweapon CHARMELEON" (name of actor) turned true and it certainly did when ever the actor CHARMELEON sets damage to the actor through setactor[MYENEMY].htextra.
#316 Posted 11 September 2009 - 03:12 PM
The question is, how can I go about disabling this ? I think this is hardcoded in enemy type actors.
This post has been edited by XThX2: 11 September 2009 - 03:12 PM