StaticShape OnAdd

Post Reply
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

The onAdd event is called when function newObject is called (such as when you add something in the mission editor).
The onInit event is called when an instance of an object is executed (such as when a mission file is executed).

It's a good idea not to use the same name over and over again (such as "Laser"), as you've done.

Weapons, Projectiles, and Turrets should each have a unique name, to prevent confusion on both your part and the program's part.

I actually don't know how to add lasers to my maps, but I've been trying for years.

I've never seen the source code of a map that had lasers in it, but I've played maps that did have them, and it makes me want to add them to my maps even more...

If you know of a map that has working lasers, send it my way so I can dissect it and answer your question better.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

Yes, I was playing it earlier today, green with envy.

https://www.sendspace.com/file/skqpnq

Unfortunately, the download is no longer available.

Can you upload it again?
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

Perhaps the event is just "init", not "onInit"... I forget.

PS: My OCD is tingling...

You hard coded everything in Psychonaut. All of the positions, all of the rotations, everything. You didn't use groups. All of your traps, teleports, and perks are in MissionGroup. You've got too many indents on some lines and not enough on others. Random spaces before and after open parenthesis, but not after commas. Returns in functions that do nothing. Whitespace and comments that serve no purpose but to make me scroll further. Your spike trap doesn't move, it creates a whole new set (but not IN a set) of spikes in the down position and deletes them individually a second later.

I'm gonna have to rewrite the whole thing...

Teleports should consist of a trigger and at least one drop point marker in a group. If there are multiple drop points in the group, the trigger should select one at random. The message clients receive should be determined by the object name of the drop point. Example:

Code: Select all

messageAll(3, Client::getName(Player::getClient(%object)) @" has "@ Object::getName(%drop) @" the ruins!");
In this example, the object name (not the name property) of the drop point should either be "entered", "left", "returned from", or something like that.

Likewise, your spike trap should comprise of spikes and a trigger in a group. This way the function Spike::onTrigEnter(%this, %object, %trig) will automatically be called, and you can move the spikes up and down within that function. Since this code will repeat for each spike in the group, you should check if the player is not dead before bothering to kill them, so they don't get killed 16 times in a row.

But my biggest pet peeve of all, is the incorrect usage of variable names... You use %player interchangeably as player id and client id... I mean, you always store the client's ID in the variable, but then you feed that variable to functions that want player id's. After getting the client id from the object/player id, you get the client's control object and don't use it at all... Here's a hint, if the player moved into a trigger, it's most likely being controlled by it's client, so there's no need to get the controlled object of the client controlling an object. It's gonna be the same thing 99% of the time.

The only time it's not going to be the same thing, is when the player is a bot, or is piloting an OS missile or remote controlling a turret, and someone else pushes them into your triggers with a pitchfork or something. If you don't want your triggers to react to that circumstances, then you can exclude players not controlled by their client, but otherwise, I think if I shove some inept player who is staring at his wrist into one of your traps, they should get mangled in the trap.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

Oh, and I forgot to mention the fact that you used "0 0 "@ getWord(%rot, 2) on hard coded rotations, when you could have just made the first two axis of the rotation "0 0 "... in your hard code...

Do you see what you've done?

I'm at work, right now, obsessing about a pile of shit that doesn't even matter, because, surprisingly, your code actually works... GAH!

:cbaby:
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

No problem.

When I get home, I'll finish rewriting it and send it to you.

Might move some things around, too.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

That is really cool.

I tried something similar by hiding a control switch under the floor and using a trigger to activate it...

My intention was to do something like battlefield, where the number of people in the trigger affected the rate at which you controlled the switch, but it never worked right so I gave up and just let it activate the default switch behavior.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

I started cleaning up the code in Psychonaut, then tried to test it and realized the projectiles are mod specific.
I switched em to base lasers, and Tribes crashed when the lasers are spawned...

WTF.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

So, I guess I can't make maps with lasers compatible with v1.40 base, eh?

I'm gonna need to download, install, and configure, Tribes v1.11 and the Annihilation Mod just to test this shit.
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

targetLaser
SniperLaser

Both seem to crash v1.40 base mod.
Before I changed the projectile names in the map, I merely saw error messages in console explaining that CuttingLaserBeam and SeekerLaser don't exist.

I installed annihilation on a 1.11 copy of tribes, and hosted the map.. Everything works fine.
Started cleaning up the code and everything was fine.

Replaced your massive function that produces 7 cutting lasers, approximately 3 times a second with a simple function that produces the same 7 cutting lasers, but with completely random timing (each beam fires at a random interval between 0 and 1 seconds after the last beam in the same spot). This works flawlessly, and looks great, too, although I want to make the positions and rotations of the beams a bit random, too... But what do you think about this idea:
Instead of creating the beams at the start of the mission and repeating till the end, what if the beams were triggered while players are in the hallway (onTrigger). Also, what if the beams were parallel with the hallway, so as soon as you peak around the corner, the hallway lights up and you've got a 1/8 chance of getting sliced in half, 3 times per second, until you get to the switch? Also, what if the switch controlled the team of the bot that owns the lasers, so the lasers don't damage teammates?

Lastly, I moved all 20 spikes from the misc group to the spiketrap group which already contains the foottrap trigger. I deleted your 20 functions that create/delete new spikes 2 meters below the old ones, with 1 function that moves each of the old spikes down 2 meters, and slowly retracts. However, this function seems to think there is only 1 object in the spiketrap group (the trigger) and isn't moving the spikes... And I can't figure out why. ARG!!!
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: StaticShape OnAdd

Post by perrinoia »

OK, I figured out my problem... I moved all of the spikes to the wrong group.

I opened the map in the mission editor and could see what I did wrong in the object tree view.


<--- This video should be done uploading by 5:00 PM EST on March 20th, 2015 (my internets are slow).

It's all cleaned up, now... Ready to download.
Psychonaut.zip
(8.77 KiB) Downloaded 88 times
I didn't change the transforms of the lasers, or the allegiance of the bot. But I did reduce the number of bots because I don't see the need for 2, and I completely rewrote the trigger code for the spike trap and the scheduling of the laser trap. The rest of the code behaves exactly as it did before, but I reformatted it so it's easier for humans to read (and so the variable names make sense).
Image
Post Reply