Page 2 of 17
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 13:24
by alividerci
wtf
http://img221.imageshack.us/img221/2296/33174062.png
122 line is
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
i change it line and error display again and again
if delete
Code: Select all
declare ItemArrow = CreateItem(ArrowId);
all work good
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 13:33
by steeffeen
that's too less information to help you..
how do you set ArrowId?
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 13:35
by alividerci
steeffeen wrote:that's too less information to help you..
how do you set ArrowId?
simple this part of code
Code: Select all
// Init variables
UpdatePlayerSpawnQueue();
G_TotalPlayersSpawned = G_PlayerSpawnQueue.count;
declare AutoActivationInProgress = False;
declare OffZoneBonus = G_TotalPlayersSpawned;
declare RoundEndRequested = False;
declare RoundWinnerId = NullId;
declare LastSpawnTime = -S_SpawnInterval * 1000;
declare LastMessageTime = Now;
declare LastUIUpdateTime = -C_UITickPeriod;
declare Goal <=> SM::GetPole("Goal", 0);
///items pickup
ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
declare ItemArmor = CreateItem(ArmorId);
declare ItemLaser = CreateItem(LaserId);
declare ItemNucleus = CreateItem(NucleusId);
declare ItemRocket = CreateItem(RocketId);
declare ItemArrow = CreateItem(ArrowId);
***
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 13:40
by steeffeen
when do you execute this code?
did you try to restart the game after adding the code? (so that's a clean execution)
did you log the content of ArrowId? (maybe it's Null)
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 13:42
by alividerci
steeffeen wrote:when do you execute this code?
did you try to restart the game after adding the code? (so that's a clean execution)
did you log the content of ArrowId? (maybe it's Null)
hmm i am restarted my title pack...logs where i look him?
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 14:17
by alividerci
Now you have to manage what happen when a player pick up an item:
Code: Select all
foreach (Event in PendingEvents) {
if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesItem) {
if (Event.Player != Null && Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
AttachItemToPlayer(Event.Item, Event.Player);
// Do something depending on the item
// ...
PassOn(Event);
}
}
}
AttachItemToPlayer() has two parameters:
- The item to pick up
- The player who'll receive the item
more information about this(for each box:for example 2 boxes such as in a combo)
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 14:31
by alividerci
I formed a few questions on this part of the code ...
1. How to verify that you pick up
2. As the selection immediately remove the object and then spawn after a certain time
Thank you for your attention
Re: How to use pick up items in your title packs
Posted: 22 Apr 2013, 18:24
by Eole
ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
This part of the code must be executed only once at the beginning of the script, before the loading of the map. From the code you pasted it seems it's in your ***StartMap*** or ***StartRound***. It should be in the ***StartServer*** section. Once it's done, try to restart your server and see if the error persists.
alividerci wrote:hmm i am restarted my title pack...logs where i look him?
If you press ctrl+g one time it will open a small log window at the bottom of the screen. Just use the log() function to write inside it.
alividerci wrote:I formed a few questions on this part of the code ...
1. How to verify that you pick up
2. As the selection immediately remove the object and then spawn after a certain time
Thank you for your attention
Some examples of code to manage items:
Code: Select all
// ---------------------------------- //
/** Spawn items
* This function must be called at each frame inside the play loop
*/
Void SpawnItems() {
// Loop on all the items the mapper put on the map
foreach (ItemAnchor in ItemAnchors) {
// Check if an item is already spawn on this anchor
declare ItemSpawned for ItemAnchor = False;
if (ItemSpawned) continue;
// Check if the respawn timer has been reach
declare ItemNextSpawn for ItemAnchor = Now;
if (ItemNextSpawn > Now) continue;
// Create an empty item
declare CSmItem Item;
// Depending on the item anchor tag, assign the right item
switch (ItemAnchor.Tag) {
case "Armor" : Item = CreateItem(ArmorId);
case "Rocket" : Item = CreateItem(RocketId);
case "Laser" : Item = CreateItem(LaserId);
case "Nucleus" : Item = CreateItem(NucleusId);
case "Arrow" : Item = CreateItem(ArrowId);
}
// If the item was correctly created
if (Item != Null) {
// Save from which anchor the item was spawned
declare AnchorId for Item = NullId;
AnchorId = ItemAnchor.Id;
// Save the tag of the anchor in the item
declare Tag for Item = ItemAnchor.Tag;
Tag = ItemAnchor.Tag;
// Spawn the item on the anchor
AttachItemToAnchor(Item, ItemAnchor);
ItemSpawned = True;
}
}
}
// ---------------------------------- //
/** Pick up item
*
* @param _Player The player who picked up the item
* @param _Item The item picked up by the player
*/
Void PickUpItem(CSmPlayer _Player, CSmItem _Item) {
if (_Player == Null || _Item == Null) return;
// Get the tag and the anchor of the item
declare Tag for _Item = "";
declare AnchorId for _Item = NullId;
// Check that the anchor associated with the item really exists
if (!ItemAnchors.existskey(AnchorId)) return;
declare ItemAnchor <=> ItemAnchors[AnchorId];
// We picked up the item, so it's not spawned on the anchor anymore
declare ItemSpawned for ItemAnchor = False;
ItemSpawned = False;
// Update the time of the next item respawn on this anchor
declare ItemNextSpawn for ItemAnchor = Now;
ItemNextSpawn = Now + 45000; ///< Respawn in 45 seconds
// Check the tag associated to the item and do something accordingly
switch (Tag) {
// If it's an armor, reload one armor point
case "Armor": {
_Player.Armor += 100;
}
// If it's a weapon, then switch to this weapon
case "Rocket": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Rocket, False);
}
case "Laser": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Laser, False);
}
case "Nucleus": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Nucleus, False);
}
case "Arrow": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Arrow, False);
}
}
// Attach the item to the player to display the blue flashing screen feedback
AttachItemToPlayer(_Item, _Player);
// Destroy the item after that
DestroyItem(_Item);
}
Re: How to use pick up items in your title packs
Posted: 23 Apr 2013, 04:56
by alividerci
Eole wrote:
ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
This part of the code must be executed only once at the beginning of the script, before the loading of the map. From the code you pasted it seems it's in your ***StartMap*** or ***StartRound***. It should be in the ***StartServer*** section. Once it's done, try to restart your server and see if the error persists.
alividerci wrote:hmm i am restarted my title pack...logs where i look him?
If you press ctrl+g one time it will open a small log window at the bottom of the screen. Just use the log() function to write inside it.
alividerci wrote:I formed a few questions on this part of the code ...
1. How to verify that you pick up
2. As the selection immediately remove the object and then spawn after a certain time
Thank you for your attention
Some examples of code to manage items:
Code: Select all
// ---------------------------------- //
/** Spawn items
* This function must be called at each frame inside the play loop
*/
Void SpawnItems() {
// Loop on all the items the mapper put on the map
foreach (ItemAnchor in ItemAnchors) {
// Check if an item is already spawn on this anchor
declare ItemSpawned for ItemAnchor = False;
if (ItemSpawned) continue;
// Check if the respawn timer has been reach
declare ItemNextSpawn for ItemAnchor = Now;
if (ItemNextSpawn > Now) continue;
// Create an empty item
declare CSmItem Item;
// Depending on the item anchor tag, assign the right item
switch (ItemAnchor.Tag) {
case "Armor" : Item = CreateItem(ArmorId);
case "Rocket" : Item = CreateItem(RocketId);
case "Laser" : Item = CreateItem(LaserId);
case "Nucleus" : Item = CreateItem(NucleusId);
case "Arrow" : Item = CreateItem(ArrowId);
}
// If the item was correctly created
if (Item != Null) {
// Save from which anchor the item was spawned
declare AnchorId for Item = NullId;
AnchorId = ItemAnchor.Id;
// Save the tag of the anchor in the item
declare Tag for Item = ItemAnchor.Tag;
Tag = ItemAnchor.Tag;
// Spawn the item on the anchor
AttachItemToAnchor(Item, ItemAnchor);
ItemSpawned = True;
}
}
}
// ---------------------------------- //
/** Pick up item
*
* @param _Player The player who picked up the item
* @param _Item The item picked up by the player
*/
Void PickUpItem(CSmPlayer _Player, CSmItem _Item) {
if (_Player == Null || _Item == Null) return;
// Get the tag and the anchor of the item
declare Tag for _Item = "";
declare AnchorId for _Item = NullId;
// Check that the anchor associated with the item really exists
if (!ItemAnchors.existskey(AnchorId)) return;
declare ItemAnchor <=> ItemAnchors[AnchorId];
// We picked up the item, so it's not spawned on the anchor anymore
declare ItemSpawned for ItemAnchor = False;
ItemSpawned = False;
// Update the time of the next item respawn on this anchor
declare ItemNextSpawn for ItemAnchor = Now;
ItemNextSpawn = Now + 45000; ///< Respawn in 45 seconds
// Check the tag associated to the item and do something accordingly
switch (Tag) {
// If it's an armor, reload one armor point
case "Armor": {
_Player.Armor += 100;
}
// If it's a weapon, then switch to this weapon
case "Rocket": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Rocket, False);
}
case "Laser": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Laser, False);
}
case "Nucleus": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Nucleus, False);
}
case "Arrow": {
SetPlayerWeapon(_Player, CSmMode::EWeapon::Arrow, False);
}
}
// Attach the item to the player to display the blue flashing screen feedback
AttachItemToPlayer(_Item, _Player);
// Destroy the item after that
DestroyItem(_Item);
}
If I understand you correctly I have to create a separate document and attach these features so?(or this to place in function part)
and why this code
Code: Select all
foreach (ItemAnchor in ItemAnchors) {
switch (ItemAnchor.ItemName) {
case "SMCommon\\Pickups\\Armor.Item.gbx": {
AttachItemToAnchor(ItemArmor, ItemAnchor);
}
}
}
sry but i dont understand what is it mean "This function must be called at each frame inside the play loop"
please give me example if you not busy
Re: How to use pick up items in your title packs
Posted: 23 Apr 2013, 09:10
by Eole
alividerci wrote:
If I understand you correctly I have to create a separate document and attach these features so?(or this to place in function part)
No, you can used this function directly in your game mode script. This is an example of the functions I use in the Combo mode to pick up items and respawn them at a determined interval.
alividerci wrote:
and why this code
Code: Select all
foreach (ItemAnchor in ItemAnchors) {
switch (ItemAnchor.ItemName) {
case "SMCommon\\Pickups\\Armor.Item.gbx": {
AttachItemToAnchor(ItemArmor, ItemAnchor);
}
}
}
This code is also valid and will spawn an armor on the anchor if you have correctly created an ItemArmor before.
alividerci wrote:
sry but i dont understand what is it mean "This function must be called at each frame inside the play loop"
please give me example if you not busy
The goal of the SpawnItems() function is to spawn items at a determined interval. So if you called it only once at the beginning of your script, then the item won't respawn once a player picked it up. Instead if you call it in the main loop of your game mode then it will verify at each frame if an object can spawn on each ItemAnchor.