EDuke32 Scripting "CON coding help"
#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
#317 Posted 11 September 2009 - 04:23 PM
#318 Posted 11 September 2009 - 04:29 PM
getactor[THISACTOR].ang angvar ifhitweapon { setactor[THISACTOR].ang angvar
But that won't work unless the angle changes when ifhitweapon is checked. A foolproof method is to have the actor save their angle each tic at the end of their code, then restore to the saved angle when ifhitweapon is true
This post has been edited by DeeperThought: 11 September 2009 - 04:31 PM
#319 Posted 11 September 2009 - 04:58 PM
#320 Posted 12 September 2009 - 12:16 AM
#321 Posted 15 September 2009 - 04:23 AM
Any idea so that I can make it has no blank spot?
This post has been edited by Ilovefoxes: 15 September 2009 - 05:07 AM
#322 Posted 16 September 2009 - 04:10 PM
getactor[THISACTOR].z z2 getplayer[THISACTOR].i ID getactor[ID].z posz subvar z2 8192 subvarvar z2 posz ldist xyvalue2 THISACTOR ID mulvarvar z2 z2 mulvarvar xyvalue2 xyvalue2 addvarvar z2 xyvalue2 sqrt z2 z2 ezshoot z2 YELLOWROCKET /* getactor[THISACTOR].x x getactor[THISACTOR].y y getactor[THISACTOR].ang TEMP setvarvar y2 y addvar y2 128 rotatepoint x y x y2 TEMP x3 y3 setactor[RETURN].y y3 */
I was trying to make an actor shoot another from some distance with accurate vertical aim. The enemy targets player, and has rocket launcher mounted on his back, so he fires from a bit higher than the actor's Z. I thought of the case, draw some simple sketches and found out that phythagoras would just work fine. Difference between Z's form the height, their distance forms the base, and finally, the result forms the zvel it must come from. So, where have I been mistaken with this idea ? D:
[EDIT] : Forgot to say what doesn't work. The actor shoots at his feet if player is too far, and even behind himself which can actually go really far. If player is really close, then the rocket goes where it is supposed to, but most of the time, missed the player.
This post has been edited by XThX2: 16 September 2009 - 04:18 PM
#324 Posted 16 September 2009 - 04:21 PM
This post has been edited by DeeperThought: 16 September 2009 - 04:22 PM
#325 Posted 19 September 2009 - 04:23 PM
ifai AIHTROTELEPORT { ifvarand status 4 nullop else { ifvare temprand 0 setvar temprand -1 addvar status 4 } whilevarn spritenum 16384 { getactor[spritenum].picnum picnum ifvare picnum EFFECTSPRITE { getactor[spritenum].lotag lotag2 getactor[spritenum].hitag hitag2 whilevarn arrayholder 128 { setarray container[arrayholder] lotag2 setvarvar arraycheck container[arrayholder] setarray container[arrayholder] hitag2 setvarvar arraycheck2 container[arrayholder] ifvarvarn temprand randomvar5 ifvarvare randomvar5 arraycheck ifvarvare arraycheck2 yvel2 { getactor[THISACTOR].x mx getactor[THISACTOR].y my getactor[THISACTOR].z mz getactor[spritenum].x x2 getactor[spritenum].y y2 getactor[spritenum].z z2 getactor[spritenum].sectnum mysector sound TELEPORTER espawn TRANSPORTERBEAM setactor[RETURN].x mx setactor[RETURN].y my setactor[THISACTOR].x x2 setactor[THISACTOR].y y2 ifvarn mysector -1 setactor[THISACTOR].sectnum mysector subvar z2 1024 setactor[THISACTOR].z z2 sound TELEPORTER espawn TRANSPORTERBEAM setactor[RETURN].x x2 setactor[RETURN].y y2 setvarvar temprand randomvar5 ai AIHTROSHOOT1 } addvar arrayholder 1 } } addvar spritenum 1 } }
I wanted my guy to teleport to one of the "hitag" amount of teleporters which it's yvel also checks. I place hitag amounts of these "dummy actors" to where I Want this guy to teleport, and give them lotags starting from 0 to hitag. This guy randomly picks one of them, and teleports to the corresponding lotag of the randomed number. The problem is, it only teleports to a fixed place, which is only 1.
I thought of the general issue first, and thought that it was the tags of effectors not being set, and only the last one. So, I decided to use arrays and increase each array by 1, so that it would check it; in a secondary while loop. I'm not sure if I'm overcomplicating things, or missing something so little again; but this is basically the first time I touched arrays :/ (The idea is like in Heretic's D'sparil fight, the wizard randomly teleports to one of the 4 fixed places)
This post has been edited by XThX2: 19 September 2009 - 04:23 PM
#326 Posted 19 September 2009 - 04:28 PM
#327 Posted 19 September 2009 - 04:32 PM
ifspritepal 0 { ifrnd 72 { ai AIHTROPAIN sound HTRO_PAIN } } else { ifrnd 64 { ai AIHTROPAIN sound HTRO_PAIN } else { setvar randomvar5 0 setvar arrayholder 0 setvar arrayholder2 0 randvarvar randomvar5 yvel2 setvar spritenum 0 ai AIHTROTELEPORT } }
#328 Posted 19 September 2009 - 04:40 PM
The normal procedure when dealing with sprites that aren't SEs or the other hardcoded effect actors, is to get their lotags and hitags into variables at map load time using the eventloadactor command. Then you set their lotag and hitag struct members to 0 to prevent nasty hardcoded effects and refer only to the variables from that point forward. In your code you are checking the struct members, not the variables. Are you sure that isn't a problem?
#329 Posted 19 September 2009 - 06:06 PM
#330 Posted 19 September 2009 - 07:35 PM
Nfelli64, on Sep 19 2009, 07:06 PM, said:
Look at this and read the note at the top that I just edited:
http://wiki.eduke32.com/wiki/Confaq42
To reposition the camera, you will need to change the values of the camera variables (e.g. cameraang) in a display event. You will have to learn a lot of stuff before you can do that competently.