Hi everyone
I'm currently learning ManiaScript and I try to make my first gamemode based on another one.
Goal : The winner is the first to have the maximum crystal amount so crystals spawn randomly on the map every 30 seconds. They spawn at one of the numerous locations specified by the map creator so players have to find and pick them. This is nearly this gamemode : viewtopic.php?f=10&t=29319 but with huge modifications
The problem : Crystals spawn but players can't pick them. When a player drop a crystal, I can pick up but not those that spawn on an anchor.
For picking up item, I use this event type :
Does the event CSmModeEvent::EType::OnPlayerObjectTouches is triggered when a player touches an object that spawn on an anchor ?
[ManiaScript] Can't pickup items spawned on an items anchor
Moderator: English Moderator
-
- Posts: 1256
- Joined: 06 Mar 2013, 16:12
- Manialink: explore
- Location: Vendée | France
- Contact:
- Nerpson
- Translator
- Posts: 1554
- Joined: 27 Sep 2013, 18:02
- Manialink: nerpson
- Location: France
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
This event is triggered when one or many players are in items' range.
Take care, this event is a bit buggy, when there is a lot of item, you should manually check the players and items' positions.
Take care, this event is a bit buggy, when there is a lot of item, you should manually check the players and items' positions.
- Dommy
- Translator
- Posts: 1866
- Joined: 25 Aug 2011, 21:45
- Manialink: exchange
- Location: Poland
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
This event is triggered when player walks into the item's trigger shape. Event is fired whenever player is in this shape and doesn't affect item or player (except blue screen glow when event is passed). You must despawn, destroy of set object player manually when event is thrown.
There is no difference whether item is in world or on anchor - it's the same (except you can't get object position tag if it's on anchor). I highly recommend checking also whether player is ESpawnStatus::Spawned (to avoid picking up just dropped item by a dead player).

Edit:
@Nerpson: You really check distance between every player and every item
? With many objects and players it's lagging more than Pursuit script
. (Completely ignoring that dedicated event for object pickup is there. ^^)
There is no difference whether item is in world or on anchor - it's the same (except you can't get object position tag if it's on anchor). I highly recommend checking also whether player is ESpawnStatus::Spawned (to avoid picking up just dropped item by a dead player).

Edit:
@Nerpson: You really check distance between every player and every item


Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
- Nerpson
- Translator
- Posts: 1554
- Joined: 27 Sep 2013, 18:02
- Manialink: nerpson
- Location: France
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
Yes I do that, but only when this event is triggered. Before, I used the event's object and player attributes but when items where numerous and close to each other, there was items that you couldn't deal with, strangely.
-
- Posts: 1256
- Joined: 06 Mar 2013, 16:12
- Manialink: explore
- Location: Vendée | France
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
Thank you for your answers
My script had strange reactions
so I finally rewrote the script and the CSmObject::EType::OnPlayerTouchesObject enum works well now.
@Nerpson That's what I did before I rewrote the script (I used your last gamemode for learning ManiaScript ^^) and it only worked for dropped items. I finally just replaced your work by this :
and it works properly now...
I don't understand why it doesn't worked yesterday
I had strange bugs.
Ex : I removed an instruction that removes an object when players touch him and ManiaScript continued to remove this object

My script had strange reactions

@Nerpson That's what I did before I rewrote the script (I used your last gamemode for learning ManiaScript ^^) and it only worked for dropped items. I finally just replaced your work by this :
Code: Select all
else if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject) {
// Increases the score
Event.Player.Score.Points += 1;
// Removes this object from the world
G_Objects.removekey(Event.Object);
....
I don't understand why it doesn't worked yesterday

Ex : I removed an instruction that removes an object when players touch him and ManiaScript continued to remove this object

- Dommy
- Translator
- Posts: 1866
- Joined: 25 Aug 2011, 21:45
- Manialink: exchange
- Location: Poland
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
Interesting for me is what is the mysterious G_Objects[] variable, like there is no native, automatic Objects[] array 

Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
-
- Posts: 1256
- Joined: 06 Mar 2013, 16:12
- Manialink: explore
- Location: Vendée | France
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
It's for storing time because after 30 seconds, the crystal disappears and spawn at another locationdomino54 wrote:Interesting for me is what is the mysterious G_Objects[] variable, like there is no native, automatic Objects[] array

(I copied Nerpson

- Nerpson
- Translator
- Posts: 1554
- Joined: 27 Sep 2013, 18:02
- Manialink: nerpson
- Location: France
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
You're welcome to base your gamemode on mine ^^ ...even if I'm not a very good example in ManiaScript.
When MC will be opened, I will take some time to create some tutorials on ManiaScript. I hope that you will Domino follow me.

When MC will be opened, I will take some time to create some tutorials on ManiaScript. I hope that you will Domino follow me.

- Dommy
- Translator
- Posts: 1866
- Joined: 25 Aug 2011, 21:45
- Manialink: exchange
- Location: Poland
- Contact:
Re: [ManiaScript] Can't pickup items spawned on an items anc
I'll follow and keep highlighting mistakes 

Ryzen 7 2700X, GTX 1070 Ti, 16 GB RAM, Windows 10 Insider Build
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
FORUM MODERATOR • CREATOR OF SHOOTMANIA GALAXY & TRACKMANIA² PURSUIT
Contact me via GALAXY & PURSUIT DISCORD
Who is online
Users browsing this forum: No registered users and 1 guest