Author
|
Topic: Weapon Editing LUA question (Read 822 times)
|
|
PieBaron
Member
Posts: 3
|
I am editing a weapon at the moment to try and create a simultaneous missile launch, so I made a copy of "AAmissile" and got the script for launching gas mines and put that script in instead, I made sure to rename every single instance where the weapon name was mentioned. For weapons there is usually two LUA files, one is for launch and energy consumption, the other has the data on the projectile, some are more complex.
So for a test, I kept all the AAmissile projectile data the same, but I edited the launch data to be that of the gasmine launching data.
In-game, the weapon loaded up and when I pressed fire the game crashed with error "line23: set_owner: object id () does not exist" Is there something simple I am doing wrong here?
I also noticed some of the weapons are not in the weapons directory, as well as explosion objects, for example; when a projectile explodes it chooses between explosions such as "small_explosion", "explosion2" etc, is there a way of editing or creating your own explosions?
I appreciate any help, ideally I would have wanted to craft a rocket that explodes after a certain distance into multiple projectiles that are going along the same trajectory (with reduced damage of course) I love cluster missiles.
|
|
|
|
Logged
|
|
|
|
|
HemuliMan
Member
Posts: 245
|
"In-game, the weapon loaded up and when I pressed fire the game crashed with error "line23: set_owner: object id () does not exist" Is there something simple I am doing wrong here?"
It would help if you posted the code here.
Maybe its that gasmineobj takes 1 argument less than aamissile and you forgot to add that one.
gasmine: function init(x_pos, y_pos, x_vel, y_vel, owner_id)
aamissile: function init(x_pos, y_pos, x_vel, y_vel, dir, owner_id)
Without giving the value for dir, AAmissile treats owner_id as dir, and set_owner function can't find the object id, because there isn't one.
Edit: updated the example-clustermissile in the attachment
Edit2: To the explosion question: Yes, you can create your own explosions.
|
|
|
« Last Edit: January 24, 2010, 01:23 by HemuliMan »
|
Logged
|
|
|
|
|
PieBaron
Member
Posts: 3
|
Thanks for the fast reply, the cmissile you attached is amazing.. The way I was trying to do it was much more primitive, you were right about the extra value (dir). That was really great help!
I only have the one other request about creating explosions, I have no coding experience and am slowly grasping certain rules by looking at the coding of already existing weapons and objects. Another little thing I wanted to do was to make another kind of trooper or at least to change the limit to the amount of little troopers the ships can drop, or even to make a sort of trooper pod that can be fired out of the ship that contains a little trooper squadron. But there's no data on the troopers in the weapons folder so I'm not really sure if "create_object("trooper"" would work since there isnt a trooper anywhere in the weapons dir. thanks again
|
|
|
|
|
Logged
|
|
|
|
|
HemuliMan
Member
Posts: 245
|
Troopers are built-in objects and thus they are missing in the weapons folder. It should be possible to create troopers, but I haven't tested it yet. id = create_object(name, ...) Creates an object, returns id number of the created object. If the object could not be created, returns 0.
Arguments depend on the object being created. If it is a scripted object, see the init() function of the object.
Built-in objects:
bullet, dumbfire, explosion, explosion2, nucleus_explosion, freezer, grenade, mine, shot, trooper: create_object(name, x_pos, y_pos, x_vel, y_vel) x_pos and y_pos and displacement in pixels from the center of the platform. x_vel and y_vel are start velocity. (Default bullet velocity is 220.) Note: setting velocity does not work for mines.
harpoon create_object("harpoon", type, x_pos, y_pos, x_vel, y_vel, dir) Type 1 is large, type 2 is small.
particle create_object("particle", x_pos, y_pos, x_vel, y_vel, color_r, color_g, color_b, size, water, lifetime, paint) Particles are "visual only" objects, with no other effects. Color is defined with RGB components, 0-255. Size is in pixels. (Only size < 10 is supported, >= 10 is currently a special case.) 'water' tells whether the particle can move in water, true/false. 'lifetime' is time in seconds before the particle vanishes 'paint' tells whether and how much the particle changes color of the ground it hits. It is a floating point number 0-1.
rope create_object("rope", type, lifetime, obj1_id, obj2_id) Type 1 is the "harpoon rope", type 2 is the "pilot rope". Lifetime is time in seconds before the rope disappears. Object ids define where the rope endpoints are attached. Id 0 is valid input, but the rope will not be created. Note: lifetime has no effect on type 2 rope.
laser beam create_object("laser", obj1, obj2, team)
smoke create_object("smoke", x_pos, y_pos, x_vel, y_vel, color_r, color_g, color_b, lifetime)
ship create_object("ship", x_pos, y_pos, x_vel, y_vel, dir)
splinter create_object(name, x_pos, y_pos, x_vel, y_vel, color_r, color_g, color_b) Color is defined with RGB components, 0-255.
wave_particle create_object("wave_particle_1", x_pos, y_pos, x_vel, y_vel, lifetime) create_object("wave_particle_2", x_pos, y_pos, x_vel, y_vel, lifetime, [power]) Special invisible objects used in explosions. Type 1 destroys ground, type 2 causes damage to objects. Default power is 1. Maybe I'll try to create my own explosion, when I got time and am not too lazy, and post it here.
|
|
|
|
« Last Edit: January 26, 2010, 22:46 by HemuliMan »
|
Logged
|
|
|
|
|
Crimsoni
Beta tester
Posts: 412
|
|
|
|
|
|
Logged
|
Epäonnistumisen vaara on suuri, kun kyvytön neuvoo halutonta tekemään tarpeetonta.
|
|
|
|
FinDudeX
Beta tester
Posts: 75
|
Yes there are two weapons (Medic and Engineer) there that are based on trooper. Mainly they work by having a "controller object" attached to a trooper.
I don't suggest you use that stuff directly, as they don't work in online play.
|
|
|
|
|
Logged
|
Kaikki pidätetään, myös oikeudet. ©
|
|
|
|
PieBaron
Member
Posts: 3
|
hope people are still reading this, below I have attached a few new weapons I made; earth bomb(missile) (spreads a lot of concrete), concrete bomblets, acid bombs, implosion rocket and a big acid missile
I've been looking into getting turrets to fire different projectiles, but am getting the old object id error with which this post started. But I think it is a lot more complicated to fix than the cluster missile weapon, I'm in the turret_gun(rename).lua file and in the "function init" section it only has "(turret_id, owner_id)" I think it gets its data from the turret.lua in the same folder.
So if I change the projectile from shot to any other kind of projectile, say for example "grenade2", in-game when the turret fires I get the invalid object id error.
Is there a simple way of sorting this out?
The laser turret works fine and the lasershot.lua has a lot more data in the function init field than LaserTurretGun.lua I tried changing the projectile for laser turret and got the same object id error.
below is the area I tried changing (I copied the turret folder and re-named all used files)
function shoot() if build_time_on() then return end dx, dy = get_dir_vector(get_dir()) create_object("grenade2", dx*4, dy*4, 300*dx, 300*dy) if this.clip == clip_size then play_sound("turret_gun1") end this.clip = this.clip - 1 if this.clip == 0 then this.load_start = get_time() end end
|
|
|
|
Logged
|
|
|
|
|
HemuliMan
Member
Posts: 245
|
Try create_object("grenade2", dx*4, dy*4, 300*dx, 300*dy, get_id()) instead of create_object("grenade2", dx*4, dy*4, 300*dx, 300*dy)
|
|
|
|
|
Logged
|
|
|
|
|
 |