Forums WoW Modding Support Archives WoWModding Support Archives [DiscordArchive] do you mean a version using ground targeting or using unit data instead of one time accessed positio

[DiscordArchive] do you mean a version using ground targeting or using unit data instead of one time accessed positio

[DiscordArchive] do you mean a version using ground targeting or using unit data instead of one time accessed positio

Pages (5): Previous 1 2 3 4 5 Next
rektbyfaith
Administrator
0
06-17-2023, 05:24 PM
#11
Archived author: Kiffy • Posted: 2023-06-17T17:24:39.694000+00:00
Original source

yea Im just unsure of how it goes in terms of attatching and fetching a script
rektbyfaith
06-17-2023, 05:24 PM #11

Archived author: Kiffy • Posted: 2023-06-17T17:24:39.694000+00:00
Original source

yea Im just unsure of how it goes in terms of attatching and fetching a script

rektbyfaith
Administrator
0
06-17-2023, 05:27 PM
#12
Archived author: Nix • Posted: 2023-06-17T17:27:04.195000+00:00
Original source

Well, there is only one way to learn
rektbyfaith
06-17-2023, 05:27 PM #12

Archived author: Nix • Posted: 2023-06-17T17:27:04.195000+00:00
Original source

Well, there is only one way to learn

rektbyfaith
Administrator
0
06-17-2023, 05:29 PM
#13
Archived author: Nix • Posted: 2023-06-17T17:29:10.866000+00:00
Original source

There are examples by GPT4, so don't assume they'll just work out of the box.

Spellscript
```cpp
class spell_portal_creation_SpellScript : public SpellScript
{
PrepareSpellScript(spell_portal_creation_SpellScript);

void HandleAfterCast()
{
if (Unit* target = GetHitUnit())
{
// Spawn the portal at the caster's location
float x, y, z;
GetCaster()->GetPosition(x, y, z);
GameObject* portal = GetCaster()->SummonGameObject(100001, x, y, z, 0, 0, 0, 0, 0, 0);

// Save the target's location
target->GetPosition(x, y, z);
// Store these coordinates in the portal's AI
if (portal->AI())
portal->AI()->SetData(0, Position(x, y, z));
}
}

void Register() override
{
AfterCast += SpellCastFn(spell_portal_creation_SpellScript::HandleAfterCast);
}
};
```
rektbyfaith
06-17-2023, 05:29 PM #13

Archived author: Nix • Posted: 2023-06-17T17:29:10.866000+00:00
Original source

There are examples by GPT4, so don't assume they'll just work out of the box.

Spellscript
```cpp
class spell_portal_creation_SpellScript : public SpellScript
{
PrepareSpellScript(spell_portal_creation_SpellScript);

void HandleAfterCast()
{
if (Unit* target = GetHitUnit())
{
// Spawn the portal at the caster's location
float x, y, z;
GetCaster()->GetPosition(x, y, z);
GameObject* portal = GetCaster()->SummonGameObject(100001, x, y, z, 0, 0, 0, 0, 0, 0);

// Save the target's location
target->GetPosition(x, y, z);
// Store these coordinates in the portal's AI
if (portal->AI())
portal->AI()->SetData(0, Position(x, y, z));
}
}

void Register() override
{
AfterCast += SpellCastFn(spell_portal_creation_SpellScript::HandleAfterCast);
}
};
```

rektbyfaith
Administrator
0
06-17-2023, 05:29 PM
#14
Archived author: Nix • Posted: 2023-06-17T17:29:43.639000+00:00
Original source

Gameobject Script

```cpp
class go_portal : public GameObjectScript
{
public:
go_portal() : GameObjectScript("go_portal") { }

bool OnGossipHello(Player* player, GameObject* go) override
{
// Fetch the coordinates associated with this portal
Position pos;
if (go->AI())
pos = go->AI()->GetData(0);

// Add a gossip option that teleports to the stored location
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);

player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, go->GetGUID());
return true;
}

bool OnGossipSelect(Player* player, GameObject* /*go*/, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
if (action == GOSSIP_ACTION_INFO_DEF + 1)
{
// Teleport the player
Position pos;
if (go->AI())
pos = go->AI()->GetData(0);
player->TeleportTo(player->GetMapId(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), player->GetOrientation());
}
return true;
}
};
```
rektbyfaith
06-17-2023, 05:29 PM #14

Archived author: Nix • Posted: 2023-06-17T17:29:43.639000+00:00
Original source

Gameobject Script

```cpp
class go_portal : public GameObjectScript
{
public:
go_portal() : GameObjectScript("go_portal") { }

bool OnGossipHello(Player* player, GameObject* go) override
{
// Fetch the coordinates associated with this portal
Position pos;
if (go->AI())
pos = go->AI()->GetData(0);

// Add a gossip option that teleports to the stored location
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Teleport", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);

player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, go->GetGUID());
return true;
}

bool OnGossipSelect(Player* player, GameObject* /*go*/, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
if (action == GOSSIP_ACTION_INFO_DEF + 1)
{
// Teleport the player
Position pos;
if (go->AI())
pos = go->AI()->GetData(0);
player->TeleportTo(player->GetMapId(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), player->GetOrientation());
}
return true;
}
};
```

rektbyfaith
Administrator
0
06-17-2023, 05:30 PM
#15
Archived author: Nix • Posted: 2023-06-17T17:30:19.398000+00:00
Original source

inside of gameobject_template, you'd set the scriptname to go_portal
rektbyfaith
06-17-2023, 05:30 PM #15

Archived author: Nix • Posted: 2023-06-17T17:30:19.398000+00:00
Original source

inside of gameobject_template, you'd set the scriptname to go_portal

rektbyfaith
Administrator
0
06-17-2023, 05:30 PM
#16
Archived author: Kiffy • Posted: 2023-06-17T17:30:19.992000+00:00
Original source

yeah it forgets the spellscript loader class by default but the methods are defo useful
rektbyfaith
06-17-2023, 05:30 PM #16

Archived author: Kiffy • Posted: 2023-06-17T17:30:19.992000+00:00
Original source

yeah it forgets the spellscript loader class by default but the methods are defo useful

rektbyfaith
Administrator
0
06-17-2023, 05:30 PM
#17
Archived author: Nix • Posted: 2023-06-17T17:30:37.985000+00:00
Original source

Yeah, it isn't that great at the big picture stuff
rektbyfaith
06-17-2023, 05:30 PM #17

Archived author: Nix • Posted: 2023-06-17T17:30:37.985000+00:00
Original source

Yeah, it isn't that great at the big picture stuff

rektbyfaith
Administrator
0
06-17-2023, 05:30 PM
#18
Archived author: Nix • Posted: 2023-06-17T17:30:54.697000+00:00
Original source

but this should kind of give you an idea, the spellscript loader stuff should be "easy" enough to figure out, there are literally hundreds of examples in the code.
rektbyfaith
06-17-2023, 05:30 PM #18

Archived author: Nix • Posted: 2023-06-17T17:30:54.697000+00:00
Original source

but this should kind of give you an idea, the spellscript loader stuff should be "easy" enough to figure out, there are literally hundreds of examples in the code.

rektbyfaith
Administrator
0
06-17-2023, 05:31 PM
#19
Archived author: Nix • Posted: 2023-06-17T17:31:29.278000+00:00
Original source

I'm sure you can fetch the go_portal script somehow, but it seems to want to use the AI() function, I'm unsure if that is the proper solution or not as I don't work with the emulator
rektbyfaith
06-17-2023, 05:31 PM #19

Archived author: Nix • Posted: 2023-06-17T17:31:29.278000+00:00
Original source

I'm sure you can fetch the go_portal script somehow, but it seems to want to use the AI() function, I'm unsure if that is the proper solution or not as I don't work with the emulator

rektbyfaith
Administrator
0
06-17-2023, 05:31 PM
#20
Archived author: Nix • Posted: 2023-06-17T17:31:40.055000+00:00
Original source

But this would be a step in the "right" direction if you will
rektbyfaith
06-17-2023, 05:31 PM #20

Archived author: Nix • Posted: 2023-06-17T17:31:40.055000+00:00
Original source

But this would be a step in the "right" direction if you will

Pages (5): Previous 1 2 3 4 5 Next
Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)