[DiscordArchive] Still got magic numbers but is this going to be an issue in spell script to check quest objective da
[DiscordArchive] Still got magic numbers but is this going to be an issue in spell script to check quest objective da
![[Image: image.png?ex=690c7898&is=690b2718&hm=762...4dbbfa964&]](https://cdn.discordapp.com/attachments/376457124726702080/1196219631757701210/image.png?ex=690c7898&is=690b2718&hm=7622ce83fee4d46aac3af7b91005136b6a878561567db73812cdcb04dbbfa964&)
Archived author: Malcrom • Posted: 2024-01-14T22:29:44.945000+00:00
Original source
Still got magic numbers but is this going to be an issue in spell script to check quest objective data?
![[Image: image.png?ex=690c7898&is=690b2718&hm=762...4dbbfa964&]](https://cdn.discordapp.com/attachments/376457124726702080/1196219631757701210/image.png?ex=690c7898&is=690b2718&hm=7622ce83fee4d46aac3af7b91005136b6a878561567db73812cdcb04dbbfa964&)
Archived author: Northstrider • Posted: 2024-01-14T22:34:59.179000+00:00
Original source
you have to check GetCaster() before casting it to player
Archived author: Malcrom • Posted: 2024-01-14T22:35:49.199000+00:00
Original source
i did
Archived author: Northstrider • Posted: 2024-01-14T22:36:26.360000+00:00
Original source
you did GetCaster()->ToPlayer(); this can crash if GetCaster() returns nullptr
Archived author: Malcrom • Posted: 2024-01-14T22:36:36.744000+00:00
Original source
if (!player || !target)
return;
Archived author: Northstrider • Posted: 2024-01-14T22:36:41.667000+00:00
Original source
read above
Archived author: Fabian • Posted: 2024-01-14T22:37:02.704000+00:00
Original source
he wants you to do a !caster
Archived author: Northstrider • Posted: 2024-01-14T22:37:16.710000+00:00
Original source
If you wanna go this route you can also do Object::ToPlayer(GetCaster())
Archived author: Malcrom • Posted: 2024-01-14T22:37:52.737000+00:00
Original source
```cpp
Player* player = GetCaster()->ToPlayer();
Creature* target = GetTarget()->ToCreature();
if (!player || !target)
return;
```
Archived author: Malcrom • Posted: 2024-01-14T22:37:58.876000+00:00
Original source
so thats not safe?