[ManiaScript] Can't pickup items spawned on an items anchor

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

Post Reply
TheBigMiike
Posts: 1256
Joined: 06 Mar 2013, 16:12
Location: Vendée | France
Contact:

[ManiaScript] Can't pickup items spawned on an items anchor

Post by TheBigMiike »

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 ?
Image Image
User avatar
Nerpson
Translator
Translator
Posts: 1554
Joined: 27 Sep 2013, 18:02
Location: France
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Nerpson »

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.
ImageImageImageImage
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Dommy »

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).
:thumbsup:

Edit:
@Nerpson: You really check distance between every player and every item :shock: ? With many objects and players it's lagging more than Pursuit script :mrgreen: . (Completely ignoring that dedicated event for object pickup is there. ^^)
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
User avatar
Nerpson
Translator
Translator
Posts: 1554
Joined: 27 Sep 2013, 18:02
Location: France
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Nerpson »

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.
ImageImageImageImage
TheBigMiike
Posts: 1256
Joined: 06 Mar 2013, 16:12
Location: Vendée | France
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by TheBigMiike »

Thank you for your answers ;)

My script had strange reactions :shock: 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 :

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);
				
			....
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 :shock:
Image Image
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Dommy »

Interesting for me is what is the mysterious G_Objects[] variable, like there is no native, automatic Objects[] array :D
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
TheBigMiike
Posts: 1256
Joined: 06 Mar 2013, 16:12
Location: Vendée | France
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by TheBigMiike »

domino54 wrote:Interesting for me is what is the mysterious G_Objects[] variable, like there is no native, automatic Objects[] array :D
It's for storing time because after 30 seconds, the crystal disappears and spawn at another location ;)
(I copied Nerpson :oops: but I need this system for my gamemode too ^^)
Image Image
User avatar
Nerpson
Translator
Translator
Posts: 1554
Joined: 27 Sep 2013, 18:02
Location: France
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Nerpson »

You're welcome to base your gamemode on mine ^^ ...even if I'm not a very good example in ManiaScript. :lol:

When MC will be opened, I will take some time to create some tutorials on ManiaScript. I hope that you will Domino follow me. ;)
ImageImageImageImage
User avatar
Dommy
Translator
Translator
Posts: 1866
Joined: 25 Aug 2011, 21:45
Location: Poland
Contact:

Re: [ManiaScript] Can't pickup items spawned on an items anc

Post by Dommy »

I'll follow and keep highlighting mistakes :mrgreen:
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
Post Reply

Return to “ManiaScript”

Who is online

Users browsing this forum: No registered users and 1 guest