So I've been having a quick look at the speedball title, and I spotted a few (probably not very well documented to say the least ) things that could be used:
for attaching a marker to something (say, a ball), you don't have to change the position marker all the time. Instead
you can write:
A marker can be attached to:
pos = "x y z"
playerlogin="bob"
objectid="#124124124" (any CSmObject)
landmarktag="{{{BlockPoles[0].Id}}}" (or any CSmLandmark)
You could be actually throwing the ball object around, instead of using rockets / lasers to pass.
To do this, you have to add more info to the object when importing it in the importer. (see next post)
using say CSmModeEvent::EType::OnActionEvent,
with Event.ActionSlot == CSmModeEvent::EActionSlots::Activable1
(that is when the player presses '1' on the keyboard.)
In maniascript, the class describing dynamic objects is CSmObject.
When manipulating dynamic objects, the important thing to have in mind is that, at any moment, an object is in a given "status", namely
- OnPlayer
- OnAnchor
- InWorld
- Unspawned
To change the status of an object, use the corresponding method
- SetPlayer(CSmPlayer)
- SetAnchor(CSmObjectAnchor)
- SetPosition(Vec3) or SetPositionAndVel(Vec3, Vec3)
- SetUnspawned()
E.g. if a given item was previously "InWorld", a call to the method "SetAnchor" will change its status to "OnAnchor". In other words, calling more than one of these methods during the same frame is useless: only the last method call will be taken into account.
You can access the status of an object with the field Status, which returns a CSmObject::EStatus.
When the status is OnPlayer, the field Player gives you which player currently owns the object. Having this field Null is equivalent for the status not to be "OnPlayer".
When the status is OnAnchor, the field Anchor gives you which anchor currently holds the object. Having this field Null is equivalent for the status not to be "OnAnchor".
Here is a short description of what the various statuses mean.
"OnPlayer"
The object is linked to a player.
It is not present in the world - in other words, the object only exists "virtually".
If the field "Throwable" is set to True, then next time the player will use the "shoot" button (presumably, the left click of the mouse) the object will be thrown, which lead to 2 remarks
1. Its status will switch from "OnPlayer" to "InWorld",
2. The direction of the throw is given by the players aim, and the force by the field CSmPlayer.ThrowSpeed
A player throws all objects with the same speed. If the player owns several throwable objects, all of them will be thrown at the same time, with the same speed and the same direction.
When a player throws an object, he/she does not fires any projectile (like a rocket). He/She has to lift his/her finger and press the fire button again to do so.
"OnAnchor"
The object is linked to an anchor defined by the map. Physics does not apply here - the object does not move until its status changes to "InWorld". This presumably will be the status of objects at the beginning of the match if you want them to have a fixed position in the map.
"InWorld"
The object is somewhere in the world, visible, and subject just like us to the tough laws of physics. You can get the coordinates of an object with the field CSmObject.Position, and its velocity with CSmObject.Vel.
Any call to the method "SetPosition" or "SetPositionAndVel" will set the status of an object to "InWorld". The object is "teleported" at the given position, and the given speed vector will be applied. You will probably have to be careful not to set the position inside of a wall or somewhere not reachable.
If a player touches the object, it reacts like any other item by generating a PlayerTouchesItem event.
Notice that objects are not affected by special blocks such as trampolines or jump pads, and do not either bounce on players or other objects.
"Unspawned"
The object is nowhere, but can be accessed later on.