How to use pick up items in your title packs

Discuss everything related to custom data creation.

Moderator: NADEO

User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

Re: How to use pick up items in your title packs

Post by alividerci »

Eole wrote:@Alividerci:
If you're standing on an object and don't do a SetAnchor()/SetPlayer()/SetPosition()/Destroy the object/something else. Then yes, the object will keep triggering the OnPlayerTouchesItem event.
it is part of my code, i think trouble is here

Code: Select all

switch (Tag) {
		case C_Object["Armor"]: {
		if(_Player.ArmorMax < 500){
		  if(_Player.ArmorMax == _Player.Armor)
		  {
		  _Player.ArmorMax += C_Object_ArmorMaxValue;
		  _Player.Armor += C_Object_ArmorValue;
		  }

			_Player.Armor += C_Object_ArmorValue;
			//ObjectNextSpawn = Now + C_Timers["Armor"];
			if (_Player.Armor > C_ArmorReductionStart) {
				declare NextArmorReduction for _Player = -1;
				NextArmorReduction = Now + C_ArmorReductionPeriod;
			}
			_Object.SetPlayer(_Player);
			ObjectDestroy(_Object);
		  }
		  else
		  {
		  if(_Player.Armor == 400){_Player.Armor += 100; _Object.SetPlayer(_Player); ObjectDestroy(_Object);}
		  if(_Player.Armor == 300){_Player.Armor += 200; _Object.SetPlayer(_Player); ObjectDestroy(_Object);}
		  if(_Player.Armor == 200){_Player.Armor += 300; _Object.SetPlayer(_Player); ObjectDestroy(_Object);}
		  if(_Player.Armor == 100){_Player.Armor += 400; _Object.SetPlayer(_Player); ObjectDestroy(_Object);}
		  }
		}
		case C_Object["Rocket"]: {
		declare netwrite Net_Combo_AmmoMax for _Player = C_AmmoMax;
		declare CSmMode::EWeapon Weapon;	
        Weapon = CSmMode::EWeapon::Rocket;
		if(Net_Combo_AmmoMax["Rocket"] < 10){
		PickUpWeapon(_Player, Tag);
		_Object.SetPlayer(_Player);
		ObjectDestroy(_Object);
		}
		else{
		//AddPlayerAmmo(_Player, Weapon, 10.);
		//ObjectDestroy(_Object);
		}
		}
		case C_Object["Laser"]: {
		declare netwrite Net_Combo_AmmoMax for _Player = C_AmmoMax;
		declare CSmMode::EWeapon Weapon;	
        Weapon = CSmMode::EWeapon::Laser;
		if(Net_Combo_AmmoMax["Laser"] < 3){
		PickUpWeapon(_Player, Tag);
		_Object.SetPlayer(_Player);
		ObjectDestroy(_Object);
	    }
		else{
		//AddPlayerAmmo(_Player, Weapon, 3.);
		//ObjectDestroy(_Object);
		}
		}
		case C_Object["Nucleus"]: {
		declare netwrite Net_Combo_AmmoMax for _Player = C_AmmoMax;
		declare CSmMode::EWeapon Weapon;	
        Weapon = CSmMode::EWeapon::Nucleus;
		if(Net_Combo_AmmoMax["Nucleus"] < 5){
		PickUpWeapon(_Player, Tag);
		_Object.SetPlayer(_Player);
		ObjectDestroy(_Object);
		}
		else{
		//AddPlayerAmmo(_Player, Weapon, 5.);
		//ObjectDestroy(_Object);
		}
		}
		case C_Object["Arrow"]: {
		declare netwrite Net_Combo_AmmoMax for _Player = C_AmmoMax;
		declare CSmMode::EWeapon Weapon;	
        Weapon = CSmMode::EWeapon::Arrow;
		if(Net_Combo_AmmoMax["Arrow"] < 7){
		PickUpWeapon(_Player, Tag);
		_Object.SetPlayer(_Player);
		ObjectDestroy(_Object);
        }
		else{
		//AddPlayerAmmo(_Player, Weapon, 7.);
		//ObjectDestroy(_Object);
				}
			}
		}
If you have in the maximum number of shoots for any weapon, then you can no longer lift (the object is not destroyed, it is important) but if you ran over an object that can no longer pick up, in the case of self-destruction (etc) if you go over to a subject which you could not pick up you get +2 (or more)
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: How to use pick up items in your title packs

Post by Eole »

Your code seems correct, but it's hard to say if this part can be the source of the error.
Maybe the function that spawn your objects spawns two items at the same location and time?
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

Re: How to use pick up items in your title packs

Post by alividerci »

Eole wrote:Your code seems correct, but it's hard to say if this part can be the source of the error.
Maybe the function that spawn your objects spawns two items at the same location and time?
I do not think so

Code: Select all

***PlayLoop***
***
// ---------------------------------- //
// Spawn items
Combo_SpawnObjects();
.....................
// On player touches Object
	else if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesObject) {
		if (Event.Player == Null) {
			Discard(Event);
		} else if (Event.Player != Null && Event.Player.SpawnStatus != CSmPlayer::ESpawnStatus::Spawned) {
			Discard(Event);
		} else {
		log("PickUpObject: "^Event.Object^" has: "^G_BonusBox.existskey(Event.Object.Id));
		PickUpObject(Event.Player, Event.Object);
		Discard(Event);
		}
	}
more?

function Combo_SpawnObjects(); in a script i called one moment
User avatar
Eole
Nadeo
Nadeo
Posts: 1265
Joined: 26 Apr 2011, 21:08

Re: How to use pick up items in your title packs

Post by Eole »

When the problem happens you see the log you added in the OnPlayerTouchesObject event two times with the same object id?
If you're respawning the object after some times when someone take it (like in Combo), maybe there's a problem with this function. By example the respawn timer of your object is not initialized properly. You walk on an object and take it. But the respawn function respawns it just after. So you're still on the object and take it again, but this time the respawn timer was initialized and the object doesn't respawn immediately. Or something like that ...
Contribute to the ManiaPlanet documentation on GitHub
A question about ManiaScript? Ask it here!
User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

Re: How to use pick up items in your title packs

Post by alividerci »

Eole wrote:When the problem happens you see the log you added in the OnPlayerTouchesObject event two times with the same object id?
If you're respawning the object after some times when someone take it (like in Combo), maybe there's a problem with this function. By example the respawn timer of your object is not initialized properly. You walk on an object and take it. But the respawn function respawns it just after. So you're still on the object and take it again, but this time the respawn timer was initialized and the object doesn't respawn immediately. Or something like that ...
yes function running, but i solved this problem....simple destroy when you have max limit of shoots
User avatar
faserg1
Posts: 446
Joined: 06 Jul 2011, 19:54
Location: Russia
Contact:

Re: How to use pick up items in your title packs

Post by faserg1 »

I think I know what's up. Maybe when player toches object the varible Spawned changeing on False without condition of MaxAmmo or Max Armor?
Есть вопросы? Только скайп - faserg1.
Image
Жизнь - это динамика ритма. Life is dynamic of rhythm.
User avatar
faserg1
Posts: 446
Joined: 06 Jul 2011, 19:54
Location: Russia
Contact:

Re: How to use pick up items in your title packs

Post by faserg1 »

Wow, I found (lol!) video, where in old SM was items.
There is:
http://youtu.be/fLLBUAGX-iU?t=1m4s
Есть вопросы? Только скайп - faserg1.
Image
Жизнь - это динамика ритма. Life is dynamic of rhythm.
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: How to use pick up items in your title packs

Post by steeffeen »

does anyone else experience that as well?

when i build a map in storm with some items and want to create a multiplayer game with the map it says that the items i've just placed are missing.. why isn't the game correctly looking for these items? i HAVE to include them in a title pack even though i just want to test something..
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    xbx
    Nadeo
    Nadeo
    Posts: 1289
    Joined: 14 Jun 2010, 17:35

    Re: How to use pick up items in your title packs

    Post by xbx »

    steeffeen wrote:does anyone else experience that as well?

    when i build a map in storm with some items and want to create a multiplayer game with the map it says that the items i've just placed are missing.. why isn't the game correctly looking for these items? i HAVE to include them in a title pack even though i just want to test something..
    Yes I'm afraid that at this point, there's no other way. Items not in title packs only appear in the editor IIRC.
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: How to use pick up items in your title packs

    Post by steeffeen »

    xbx wrote:Yes I'm afraid that at this point, there's no other way. Items not in title packs only appear in the editor IIRC.
    okay thanks for the info :thumbsup:
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      Post Reply

      Return to “Title Pack & Custom Data Creation”

      Who is online

      Users browsing this forum: No registered users and 1 guest